MuckRock / documentcloud

DocumentCloud's back end source code - Please report bugs, issues and feature requests to info@documentcloud.org
https://www.documentcloud.org
GNU Affero General Public License v3.0
32 stars 8 forks source link

JavaScript library for DocumentCloud API #162

Open eyeseast opened 1 year ago

eyeseast commented 1 year ago

Let's build a standalone javascript client for the DocumentCloud API. We can start by extracting some of the code uses in the new Add-Ons UI, since it's built on native fetch. Ideally, this library should work in all javascript environments: the browser, NodeJS and Deno.

eyeseast commented 1 year ago

We probably want to write this in TypeScript and include types that the DocumentCloud frontend can use.

eyeseast commented 1 year ago

Once this has its own repo, probably want to make a dedicated project board for it, too.

eyeseast commented 1 year ago

Looking at Svelte's approach, this seems eminently reasonable: https://news.ycombinator.com/item?id=35892250

It looks like all the files are JS, so imports work as normal and everything works without a build step, while types get defined in separate definition files like this one: https://github.com/sveltejs/svelte/blob/master/packages/svelte/src/compiler/interfaces.d.ts

eyeseast commented 1 year ago

The JSDoc approach looks like it also solves this problem: https://stackoverflow.com/questions/62619058/appending-js-extension-on-relative-import-statements-during-typescript-compilat