MCPcopy Create free account
hub / github.com/code-with-antonio/resonance / main

Function main

scripts/sync-api.ts:21–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19const OUTPUT_PATH = path.resolve(__dirname, "../src/types/chatterbox-api.d.ts");
20
21async function main() {
22 const apiUrl = process.env.CHATTERBOX_API_URL;
23
24 if (!apiUrl) {
25 console.error("Error: CHATTERBOX_API_URL environment variable is required");
26 process.exit(1);
27 }
28
29 const openApiUrl = `${apiUrl}/openapi.json`;
30 console.log(`Fetching OpenAPI spec from: ${openApiUrl}`);
31
32 const ast = await openapiTS(new URL(openApiUrl));
33 const contents = astToString(ast);
34
35 // Ensure output directory exists
36 const outputDir = path.dirname(OUTPUT_PATH);
37 if (!fs.existsSync(outputDir)) {
38 fs.mkdirSync(outputDir, { recursive: true });
39 }
40
41 // Add header comment
42 const header = `/**
43* This file is auto-generated by scripts/sync-api.ts
44* Do not edit manually. Run \`npm run sync-api\` to regenerate.
45*
46* Generated from: ${openApiUrl}
47* Generated at: ${new Date().toISOString()}
48*/
49 `;
50
51 fs.writeFileSync(OUTPUT_PATH, header + contents);
52 console.log(`Types written to: ${OUTPUT_PATH}`);
53}
54
55main().catch((err) => {
56 console.error("Failed to sync API types:", err);

Callers 1

sync-api.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected