@teamkeel/functions-runtime 0.413.2-next.1 → 0.413.2-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/scripts/oas.ts +86 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamkeel/functions-runtime",
3
- "version": "0.413.2-next.1",
3
+ "version": "0.413.2-next.2",
4
4
  "description": "Internal package used by @teamkeel/sdk",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "files": [
32
32
  "dist",
33
+ "scripts",
33
34
  "README.md"
34
35
  ],
35
36
  "devDependencies": {
package/scripts/oas.ts ADDED
@@ -0,0 +1,86 @@
1
+ import * as TJS from "typescript-json-schema";
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import { fileURLToPath } from "url";
5
+ import { dirname } from "path";
6
+ import alterschema from "alterschema";
7
+
8
+ // ************************************************************
9
+ // Generate the json schema from the UiApiUiConfig type
10
+ // ************************************************************
11
+
12
+ // @ts-ignore
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+
16
+ const program = TJS.getProgramFromFiles(
17
+ [path.resolve("./src/flows/ui/index.ts")],
18
+ {
19
+ strictNullChecks: true,
20
+ esModuleInterop: true,
21
+ skipLibCheck: true,
22
+ target: "ES2020",
23
+ module: "ESNext",
24
+ moduleResolution: "node",
25
+ lib: ["ES2020", "DOM"],
26
+ }
27
+ );
28
+
29
+ const generator = TJS.buildGenerator(program, {
30
+ required: true,
31
+ noExtraProps: true,
32
+ ref: true,
33
+ });
34
+
35
+ const generatorNoRef = TJS.buildGenerator(program, {
36
+ required: true,
37
+ noExtraProps: true,
38
+ ref: false,
39
+ });
40
+
41
+ if (!generator || !generatorNoRef) {
42
+ throw new Error("Failed to create generator");
43
+ }
44
+
45
+ try {
46
+ const outputDir = path.resolve(__dirname, "../../../runtime/openapi");
47
+ if (!fs.existsSync(outputDir)) {
48
+ console.error("Output directory does not exist");
49
+ process.exit(1);
50
+ }
51
+
52
+ // Generate the schema for ui config
53
+ const schema = generator.getSchemaForSymbol("UiApiUiConfig");
54
+
55
+ // Convert to latest JSON schema spec
56
+ // @ts-ignore
57
+ const schemaConverted = await alterschema(schema, "draft7", "2020-12");
58
+
59
+ // Write to file
60
+ fs.writeFileSync(
61
+ path.resolve(outputDir, "uiConfig.json"),
62
+ JSON.stringify(schemaConverted, null, 2)
63
+ );
64
+
65
+ // Generate the schema for ui config
66
+ const flowSchema = generatorNoRef.getSchemaForSymbol("FlowConfig");
67
+
68
+ // Convert to latest JSON schema spec
69
+ // @ts-ignore
70
+ const flowSchemaConverted = await alterschema(
71
+ flowSchema,
72
+ "draft7",
73
+ "2020-12"
74
+ );
75
+
76
+ // Write to file
77
+ fs.writeFileSync(
78
+ path.resolve(outputDir, "flowConfig.json"),
79
+ JSON.stringify(flowSchemaConverted, null, 2)
80
+ );
81
+
82
+ console.log("Successfully generated OpenAPI schema");
83
+ } catch (error) {
84
+ console.error("Error generating schema:", error);
85
+ process.exit(1);
86
+ }