Skip to content

Commit

Permalink
first pass at ts sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitRanque committed Sep 21, 2023
1 parent 13aea2e commit 345b618
Show file tree
Hide file tree
Showing 17 changed files with 3,848 additions and 0 deletions.
1 change: 1 addition & 0 deletions ts-connector-sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
29 changes: 29 additions & 0 deletions ts-connector-sdk/generate-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { writeFileSync } from "fs";
import { compileFromFile } from "json-schema-to-typescript";

const schemas = [
"CapabilitiesResponse",
"SchemaResponse",
"QueryRequest",
"QueryResponse",
"ErrorResponse",
"ExplainResponse",
"MutationRequest",
"MutationResponse",
];

async function generate() {
console.log("Generating types...");
for (const schema of schemas) {
writeFileSync(
`./schemas/${schema}.d.ts`,
await compileFromFile(`../api_schemas/generated/${schema}.schema.json`)
);
}
console.log("done!");
}

generate();

// notes to self: dynamic type generation seems to not be working corectly due to generated type size
// generating the types as a build step seems to work, except for query response. This could be an issue with the query response schema
Loading

0 comments on commit 345b618

Please sign in to comment.