This is a POC for a Typescript Grist API client.
It uses openapi-typescript-codegen to generate the API client and the OpenAPI documentation of Grist (source code).
What interest us is the process that generates the client (./generate_client.sh
) and also the use of the client (./cli-sample.ts
).
Just run the following commands:
$ npm install
$ npm run generate-client
$ ts-node ./cli-sample.ts --help
To list the content of a table:
$ ts-node ./cli-sample.ts -b BEARER -d DOC_ID -t TABLE_ID -u http://localhost:8484/api
To insert a record (replace the JSON by whatever you want to insert in the given table):
$ ts-node ./cli-sample.ts -b BEARER -d DOC_ID -t TABLE_ID -u http://localhost:8484/api --recordToAdd '{"Name": "Some-Name", "Email": "[email protected]"}'
Openapi-typescript-codegen parses the content of the yaml file and generates a client and the models to pass to the Client so it can handle the requests.