https://github.com/fflorent/poc-grist-codegen
POC for a Typescript Grist client
https://github.com/fflorent/poc-grist-codegen
Last synced: 10 months ago
JSON representation
POC for a Typescript Grist client
- Host: GitHub
- URL: https://github.com/fflorent/poc-grist-codegen
- Owner: fflorent
- License: mit
- Created: 2023-07-05T09:34:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T20:02:00.000Z (over 2 years ago)
- Last Synced: 2025-01-15T10:02:18.908Z (over 1 year ago)
- Language: TypeScript
- Size: 17.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# POC for a Typescript Grist client
This is a POC for a Typescript Grist API client.
It uses [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) to generate the API client and the [OpenAPI documentation of Grist](https://support.getgrist.com/api/) ([source code](https://github.com/gristlabs/grist-help/blob/master/api/grist.yml)).
## What should I look at?
What interest us is the process that generates the client (`./generate_client.sh`) and also the use of the client (`./cli-sample.ts`).
## Quick start for the POC demo
Just run the following commands:
```bash
$ npm install
$ npm run generate-client
$ ts-node ./cli-sample.ts --help
```
To list the content of a table:
```bash
$ 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):
```bash
$ ts-node ./cli-sample.ts -b BEARER -d DOC_ID -t TABLE_ID -u http://localhost:8484/api --recordToAdd '{"Name": "Some-Name", "Email": "foo@example.org"}'
```
## How does this work?
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.