quickbase-js 0.1.0-beta.12 → 0.1.0-beta.14

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 (168) hide show
  1. package/README.md +48 -18
  2. package/dist/esm/quickbase.d.ts +13 -3
  3. package/dist/esm/quickbase.js +416 -49
  4. package/dist/esm/quickbase.js.map +1 -1
  5. package/dist/esm/quickbase.min.js +1 -1
  6. package/dist/esm/quickbase.min.js.map +1 -1
  7. package/dist/umd/quickbase.umd.js +416 -49
  8. package/dist/umd/quickbase.umd.js.map +1 -1
  9. package/dist/umd/quickbase.umd.min.js +1 -1
  10. package/dist/umd/quickbase.umd.min.js.map +1 -1
  11. package/package.json +11 -4
  12. package/CHANGELOG.md +0 -227
  13. package/build-common.js +0 -131
  14. package/build-esm.js +0 -71
  15. package/build-umd.js +0 -69
  16. package/docs/.vitepress/cache/deps/@theme_index.js +0 -275
  17. package/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  18. package/docs/.vitepress/cache/deps/_metadata.json +0 -40
  19. package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js +0 -12542
  20. package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js.map +0 -7
  21. package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js +0 -9719
  22. package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js.map +0 -7
  23. package/docs/.vitepress/cache/deps/package.json +0 -3
  24. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4504
  25. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  26. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -583
  27. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  28. package/docs/.vitepress/cache/deps/vue.js +0 -343
  29. package/docs/.vitepress/cache/deps/vue.js.map +0 -7
  30. package/docs/.vitepress/config.mts +0 -26
  31. package/docs/api-examples.md +0 -49
  32. package/docs/index.md +0 -59
  33. package/docs/markdown-examples.md +0 -85
  34. package/docs-data/api-docs.json +0 -4143
  35. package/examples/quicbase-jsCDN.html +0 -36
  36. package/examples/react.js +0 -48
  37. package/examples/vanillajs.html +0 -47
  38. package/index.md +0 -25
  39. package/open-api/fix-spec-main.ts +0 -133
  40. package/open-api/generate-unified-interface.ts +0 -104
  41. package/open-api/generateDocsJson.ts +0 -24
  42. package/open-api/output/quickbase-fixed.json +0 -11191
  43. package/open-api/post-process-generated.ts +0 -226
  44. package/open-api/regenerate-client.ts +0 -117
  45. package/open-api/schema/enhance-general.ts +0 -111
  46. package/open-api/schema/fix-arrays.ts +0 -68
  47. package/open-api/schema/tags/apps.ts +0 -90
  48. package/open-api/schema/tags/fields.ts +0 -471
  49. package/open-api/schema/tags/groups.ts +0 -51
  50. package/open-api/schema/tags/index.ts +0 -66
  51. package/open-api/schema/tags/records.ts +0 -115
  52. package/open-api/schema/tags/tables.ts +0 -211
  53. package/open-api/schema/tags/users.ts +0 -47
  54. package/open-api/types/spec.ts +0 -42
  55. package/open-api/utils/common.ts +0 -29
  56. package/open-api/utils/generateJsDoc.ts +0 -74
  57. package/open-api/utils/infer-schema.ts +0 -40
  58. package/open-api/utils/naming.ts +0 -10
  59. package/open-api/utils/sharedUtils.ts +0 -352
  60. package/playwright.config.ts +0 -37
  61. package/rollup.config.js +0 -114
  62. package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -46878
  63. package/specs/split/apps.json +0 -1315
  64. package/specs/split/auth.json +0 -191
  65. package/specs/split/fields.json +0 -3869
  66. package/specs/split/records.json +0 -754
  67. package/specs/split/reports.json +0 -619
  68. package/specs/split/tables.json +0 -1605
  69. package/src/RateLimitError.ts +0 -12
  70. package/src/ThrottleBucket.ts +0 -77
  71. package/src/authorizationStrategy.ts +0 -310
  72. package/src/generated-unified/QuickbaseClient.ts +0 -1135
  73. package/src/generated-unified/missing-types-report.json +0 -3
  74. package/src/index.ts +0 -1
  75. package/src/invokeMethod.ts +0 -212
  76. package/src/quickbaseClient.ts +0 -199
  77. package/src/rateLimiter.ts +0 -30
  78. package/src/tokenCache.ts +0 -39
  79. package/src/utils.ts +0 -50
  80. package/tests/playwright/qb/auth/cacheSwitching.test.ts +0 -159
  81. package/tests/playwright/qb/auth/fetchTempToken401.test.ts +0 -219
  82. package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +0 -162
  83. package/tests/playwright/qb/auth/getAppWithTempTokenConcurrency.test.ts +0 -208
  84. package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +0 -153
  85. package/tests/playwright/qb/auth/getTempToken.test.ts +0 -152
  86. package/tests/playwright/qb/auth/tempTokenPrefetch.test.ts +0 -179
  87. package/tests/playwright/qb/auth/tempTokenRenewal.test.ts +0 -133
  88. package/tests/setup.ts +0 -53
  89. package/tests/vitest/qb/ThrottleBucket.test.ts +0 -77
  90. package/tests/vitest/qb/apps/copyApp.test.ts +0 -76
  91. package/tests/vitest/qb/apps/createApp.test.ts +0 -64
  92. package/tests/vitest/qb/apps/deleteApp.test.ts +0 -76
  93. package/tests/vitest/qb/apps/getApp.test.ts +0 -44
  94. package/tests/vitest/qb/apps/getAppEvents.test.ts +0 -67
  95. package/tests/vitest/qb/apps/updateApp.test.ts +0 -58
  96. package/tests/vitest/qb/auth/mockQuickbaseServer.ts +0 -60
  97. package/tests/vitest/qb/auth/retryUserToken401.test.ts +0 -73
  98. package/tests/vitest/qb/auth/ssoTokenConcurrency.test.ts +0 -68
  99. package/tests/vitest/qb/auth/ssoTokenIntegrationWithServer.test.ts +0 -65
  100. package/tests/vitest/qb/auth/userTokenConcurrency.test.ts +0 -63
  101. package/tests/vitest/qb/fields/createField.test.ts +0 -77
  102. package/tests/vitest/qb/fields/deleteFields.test.ts +0 -83
  103. package/tests/vitest/qb/fields/getField.test.ts +0 -85
  104. package/tests/vitest/qb/fields/getFieldUsage.test.ts +0 -82
  105. package/tests/vitest/qb/fields/getFields.test.ts +0 -232
  106. package/tests/vitest/qb/fields/getFieldsUsage.test.ts +0 -77
  107. package/tests/vitest/qb/fields/updateField.test.ts +0 -93
  108. package/tests/vitest/qb/formulas/runFormula.test.ts +0 -96
  109. package/tests/vitest/qb/index.ts +0 -29
  110. package/tests/vitest/qb/records/deleteRecords.test.ts +0 -110
  111. package/tests/vitest/qb/records/runQuery.test.ts +0 -146
  112. package/tests/vitest/qb/records/upsert.test.ts +0 -102
  113. package/tests/vitest/qb/tables/createRelationship.test.ts +0 -102
  114. package/tests/vitest/qb/tables/createTable.test.ts +0 -55
  115. package/tests/vitest/qb/tables/deleteRelationship.test.ts +0 -143
  116. package/tests/vitest/qb/tables/deleteTable.test.ts +0 -50
  117. package/tests/vitest/qb/tables/getAppTables.test.ts +0 -46
  118. package/tests/vitest/qb/tables/getRelationships.test.ts +0 -80
  119. package/tests/vitest/qb/tables/getTable.test.ts +0 -26
  120. package/tests/vitest/qb/tables/updateRelationship.test.ts +0 -250
  121. package/tests/vitest/qb/tables/updateTable.test.ts +0 -48
  122. package/tests/vitest/unit/ThrottleBucket.test.ts +0 -101
  123. package/tests/vitest/unit/apps/copyApp.test.ts +0 -581
  124. package/tests/vitest/unit/apps/createApp.test.ts +0 -186
  125. package/tests/vitest/unit/apps/deleteApp.test.ts +0 -216
  126. package/tests/vitest/unit/apps/getApp.test.ts +0 -128
  127. package/tests/vitest/unit/apps/getAppConcurrency.test.ts +0 -151
  128. package/tests/vitest/unit/apps/getAppEvents.test.ts +0 -193
  129. package/tests/vitest/unit/apps/updateApp.test.ts +0 -412
  130. package/tests/vitest/unit/auth/fetchTempToken401.test.ts +0 -81
  131. package/tests/vitest/unit/auth/getTempToken.test.ts +0 -119
  132. package/tests/vitest/unit/auth/retryTempToken401.test.ts +0 -95
  133. package/tests/vitest/unit/auth/retryTempTokenMaxRetries.test.ts +0 -206
  134. package/tests/vitest/unit/auth/retryUserToken401.test.ts +0 -69
  135. package/tests/vitest/unit/auth/ssoTokenRefresh.test.ts +0 -325
  136. package/tests/vitest/unit/auth/userTokenConcurrency.test.ts +0 -62
  137. package/tests/vitest/unit/fields/createField.test.ts +0 -451
  138. package/tests/vitest/unit/fields/deleteFields.test.ts +0 -141
  139. package/tests/vitest/unit/fields/getField.test.ts +0 -189
  140. package/tests/vitest/unit/fields/getFieldUsage.test.ts +0 -180
  141. package/tests/vitest/unit/fields/getFields.test.ts +0 -122
  142. package/tests/vitest/unit/fields/getFieldsUsage.test.ts +0 -160
  143. package/tests/vitest/unit/fields/updateField.test.ts +0 -285
  144. package/tests/vitest/unit/formulas/runFormula.test.ts +0 -205
  145. package/tests/vitest/unit/index.ts +0 -34
  146. package/tests/vitest/unit/quickbaseClientHttpMethods.test.ts +0 -139
  147. package/tests/vitest/unit/rateLimit.test.ts +0 -191
  148. package/tests/vitest/unit/records/deleteRecords.test.ts +0 -112
  149. package/tests/vitest/unit/records/runQuery.test.ts +0 -102
  150. package/tests/vitest/unit/records/upsert.test.ts +0 -234
  151. package/tests/vitest/unit/tables/createRelationship.test.ts +0 -212
  152. package/tests/vitest/unit/tables/createTable.test.ts +0 -70
  153. package/tests/vitest/unit/tables/deleteRelationship.test.ts +0 -97
  154. package/tests/vitest/unit/tables/deleteTable.test.ts +0 -77
  155. package/tests/vitest/unit/tables/getAppTables.test.ts +0 -85
  156. package/tests/vitest/unit/tables/getRelationships.test.ts +0 -259
  157. package/tests/vitest/unit/tables/getTable.test.ts +0 -233
  158. package/tests/vitest/unit/tables/updateRelationship.test.ts +0 -307
  159. package/tests/vitest/unit/tables/updateTable.test.ts +0 -80
  160. package/tests/vitest/unit/tokenLifespan.test.ts +0 -204
  161. package/tests/vitest/unit/umd.test.ts +0 -8
  162. package/tools/log-gen.ts +0 -251
  163. package/tools/log-gen.yaml +0 -4829
  164. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  165. package/tsconfig.build.json +0 -17
  166. package/tsconfig.json +0 -32
  167. package/versionrc.json +0 -9
  168. package/vitest.config.ts +0 -27
@@ -1,226 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
4
- import { join, dirname } from "path";
5
- import { fileURLToPath } from "url";
6
-
7
- const __dirname = dirname(fileURLToPath(import.meta.url));
8
- const GENERATED_DIR = join(__dirname, "..", "src", "generated");
9
- const MODELS_DIR = join(GENERATED_DIR, "models");
10
- const SPEC_FILE = join(__dirname, "output", "quickbase-fixed.json");
11
-
12
- function toPascalCase(str: string): string {
13
- return str.replace(/(^\w|_\w)/g, (match) =>
14
- match.replace("_", "").toUpperCase()
15
- );
16
- }
17
-
18
- function ensureDir(dir: string) {
19
- if (!existsSync(dir)) {
20
- mkdirSync(dir, { recursive: true });
21
- }
22
- }
23
-
24
- function mapOpenApiTypeToTs(openApiType: string): string {
25
- switch (openApiType) {
26
- case "integer":
27
- case "number":
28
- return "number";
29
- case "string":
30
- return "string";
31
- case "boolean":
32
- return "boolean";
33
- case "object":
34
- return "object";
35
- default:
36
- return "any";
37
- }
38
- }
39
-
40
- function generateItemsInnerInterface(
41
- itemSchema: any,
42
- itemName: string
43
- ): string {
44
- const properties = itemSchema?.properties || {};
45
- const propsStr = Object.entries(properties)
46
- .map(([key, prop]: [string, any]) => {
47
- let type;
48
- if (key === "permissions" && prop.type === "array") {
49
- type = "Permission[]";
50
- } else if (key === "properties" && prop.type === "object") {
51
- type = "{ [key: string]: any }";
52
- } else {
53
- type = mapOpenApiTypeToTs(prop.type);
54
- }
55
- const isRequired = itemSchema.required?.includes(key);
56
- const description = prop.description ? ` * ${prop.description}` : "";
57
- return ` /**
58
- ${description}
59
- * @type {${type}}
60
- */
61
- ${key}${isRequired ? "" : "?"}: ${type};`;
62
- })
63
- .join("\n");
64
-
65
- const additionalProps =
66
- itemSchema.additionalProperties === true
67
- ? ` /**
68
- * Allows additional unspecified properties
69
- * @type {any}
70
- */
71
- [key: string]: any;`
72
- : "";
73
-
74
- return `
75
- /* Auto-generated by post-process-generated.ts */
76
- import { mapValues } from '../runtime';
77
- import { Permission } from './Permission';
78
-
79
- /**
80
- * Auto-generated model for ${itemName}
81
- */
82
- export interface ${itemName} {
83
- ${propsStr}
84
- ${additionalProps}
85
- }
86
-
87
- export function ${itemName}FromJSON(json: any): ${itemName} {
88
- return json || {};
89
- }
90
-
91
- export function ${itemName}ToJSON(value?: ${itemName} | null): any {
92
- return value || {};
93
- }
94
- `.trim();
95
- }
96
-
97
- function postProcessGeneratedFiles() {
98
- console.log("Starting post-processing...");
99
- console.log("Spec file path:", SPEC_FILE);
100
-
101
- try {
102
- if (!existsSync(SPEC_FILE)) {
103
- console.error(
104
- `Spec file ${SPEC_FILE} not found. Run 'npm run fix-spec' first.`
105
- );
106
- process.exit(1);
107
- }
108
-
109
- const spec = JSON.parse(readFileSync(SPEC_FILE, "utf8"));
110
- console.log("Spec loaded successfully.");
111
-
112
- const responseMap: Record<string, string> = {};
113
- for (const pathKey in spec.paths) {
114
- const pathObj = spec.paths[pathKey];
115
- if (!pathObj || typeof pathObj !== "object") continue;
116
- for (const method in pathObj) {
117
- const operation = pathObj[method];
118
- const opId =
119
- operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
120
- const response = operation.responses?.["200"];
121
- if (response && response.schema?.$ref) {
122
- const refName = response.schema.$ref.split("/").pop() || "";
123
- responseMap[opId] = refName;
124
- console.log(`Mapped ${opId} to ${refName}`);
125
- }
126
- }
127
- }
128
-
129
- for (const [opId, refName] of Object.entries(responseMap)) {
130
- try {
131
- const def = spec.definitions[refName];
132
- if (!def) {
133
- console.log(`Definition for ${refName} not found; skipping`);
134
- continue;
135
- }
136
-
137
- const responseFile = join(MODELS_DIR, `${toPascalCase(refName)}.ts`);
138
-
139
- if (def.type === "array") {
140
- const itemRef = def.items?.$ref
141
- ? def.items.$ref.split("/").pop()
142
- : `${toPascalCase(refName)}ItemsInner`;
143
- const itemsFile = join(MODELS_DIR, `${itemRef}.ts`);
144
-
145
- if (!existsSync(itemsFile)) {
146
- console.log(`Creating missing ${itemRef}.ts`);
147
- const content = def.items?.$ref
148
- ? `
149
- /* Auto-generated by post-process-generated.ts */
150
- import { mapValues } from '../runtime';
151
-
152
- /**
153
- * Auto-generated model for ${itemRef}
154
- */
155
- export interface ${itemRef} {
156
- [key: string]: any; // Placeholder; refine as needed
157
- }
158
-
159
- export function ${itemRef}FromJSON(json: any): ${itemRef} {
160
- return json || {};
161
- }
162
-
163
- export function ${itemRef}ToJSON(value?: ${itemRef} | null): any {
164
- return value || {};
165
- }
166
- `
167
- : generateItemsInnerInterface(def.items || {}, itemRef);
168
- ensureDir(MODELS_DIR);
169
- writeFileSync(itemsFile, content.trim(), "utf8");
170
- }
171
-
172
- if (existsSync(responseFile)) {
173
- console.log(`Rewriting ${refName}.ts as array`);
174
- const content = `
175
- /* Auto-generated by post-process-generated.ts */
176
- import { ${itemRef}, ${itemRef}FromJSON, ${itemRef}ToJSON } from './${itemRef}';
177
-
178
- /**
179
- * Response for ${opId}
180
- */
181
- export type ${toPascalCase(refName)} = ${itemRef}[];
182
-
183
- /**
184
- * Convert JSON to ${toPascalCase(refName)}
185
- */
186
- export function ${toPascalCase(refName)}FromJSON(json: any): ${toPascalCase(
187
- refName
188
- )} {
189
- if (!json) return [];
190
- return json.map(${itemRef}FromJSON);
191
- }
192
-
193
- /**
194
- * Convert ${toPascalCase(refName)} to JSON
195
- */
196
- export function ${toPascalCase(refName)}ToJSON(value?: ${toPascalCase(
197
- refName
198
- )} | null): any {
199
- if (!value) return [];
200
- return value.map(${itemRef}ToJSON);
201
- }
202
- `;
203
- writeFileSync(responseFile, content.trim(), "utf8");
204
- }
205
- } else if (def.type === "object") {
206
- console.log(`Processing ${refName}.ts as object`);
207
- const content = generateItemsInnerInterface(
208
- def,
209
- toPascalCase(refName)
210
- );
211
- ensureDir(MODELS_DIR);
212
- writeFileSync(responseFile, content.trim(), "utf8");
213
- }
214
- } catch (error) {
215
- console.error(`Error processing ${refName}:`, error);
216
- }
217
- }
218
-
219
- console.log("Post-processing complete.");
220
- } catch (error) {
221
- console.error("Error in post-processing:", error);
222
- process.exit(1);
223
- }
224
- }
225
-
226
- postProcessGeneratedFiles();
@@ -1,117 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { execSync } from "child_process";
4
- import { existsSync } from "fs";
5
- import { join } from "path";
6
- import { fileURLToPath } from "url";
7
- import fetch from "node-fetch";
8
- import readline from "readline";
9
-
10
- const CURRENT_JAR_VERSION = "7.12.0";
11
- const MAVEN_METADATA_URL =
12
- "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml";
13
- const CODEGEN_DIR = join(fileURLToPath(import.meta.url), "..");
14
- const JARS_DIR = join(CODEGEN_DIR, "..", "tools", "openapi-jars");
15
- const SPEC_INPUT = join(CODEGEN_DIR, "output", "quickbase-fixed.json");
16
- const OUTPUT_DIR = join(CODEGEN_DIR, "..", "src", "generated");
17
-
18
- async function getLatestVersion(): Promise<string> {
19
- const response = await fetch(MAVEN_METADATA_URL);
20
- if (!response.ok)
21
- throw new Error(`Failed to fetch Maven metadata: ${response.statusText}`);
22
- const text = await response.text();
23
- const match = text.match(/<latest>(.*?)<\/latest>/);
24
- if (!match)
25
- throw new Error("Couldn’t parse latest version from Maven metadata");
26
- return match[1];
27
- }
28
-
29
- async function checkAndPromptForUpdate(messages: string[]): Promise<string> {
30
- const latestVersion = await getLatestVersion();
31
- if (latestVersion === CURRENT_JAR_VERSION) {
32
- messages.push(`Current version (${CURRENT_JAR_VERSION}) is the latest.`);
33
- return CURRENT_JAR_VERSION;
34
- }
35
-
36
- messages.push(
37
- `Newer version available: ${latestVersion} (current: ${CURRENT_JAR_VERSION})`
38
- );
39
- const rl = readline.createInterface({
40
- input: process.stdin,
41
- output: process.stdout,
42
- });
43
-
44
- return new Promise((resolve) => {
45
- const prompt = "Do you want to update to the latest version? (y/n): ";
46
- messages.push(prompt);
47
- rl.question(prompt, (answer) => {
48
- rl.close();
49
- if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") {
50
- messages.push(`Switching to version ${latestVersion}...`);
51
- resolve(latestVersion);
52
- } else {
53
- messages.push(`Sticking with version ${CURRENT_JAR_VERSION}.`);
54
- resolve(CURRENT_JAR_VERSION);
55
- }
56
- });
57
- });
58
- }
59
-
60
- async function ensureJarExists(
61
- version: string,
62
- messages: string[]
63
- ): Promise<string> {
64
- const jarPath = join(JARS_DIR, `openapi-generator-cli-${version}.jar`);
65
- const jarUrl = `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${version}/openapi-generator-cli-${version}.jar`;
66
-
67
- if (!existsSync(jarPath)) {
68
- messages.push(`Downloading OpenAPI Generator CLI v${version}...`);
69
- try {
70
- execSync(`curl -L -o ${jarPath} ${jarUrl}`, { stdio: "inherit" });
71
- messages.push(`Downloaded ${jarPath}`);
72
- } catch (error) {
73
- messages.push("Failed to download JAR.");
74
- throw error;
75
- }
76
- } else {
77
- messages.push(`Using existing ${jarPath}`);
78
- }
79
- return jarPath;
80
- }
81
-
82
- function regenerateClient(jarPath: string, messages: string[]) {
83
- messages.push("Regenerating client from spec...");
84
- const command = `java -jar ${jarPath} generate -i ${SPEC_INPUT} -g typescript-fetch -o ${OUTPUT_DIR} --additional-properties=generateAliasAsModel=true,withInterfaces=true,supportsES6=true,modelPropertyNaming=original`;
85
- try {
86
- execSync(command, { stdio: "inherit" });
87
- messages.push("Client regeneration complete.");
88
- } catch (error) {
89
- messages.push("Regeneration failed.");
90
- throw error;
91
- }
92
- }
93
-
94
- async function main() {
95
- const messages: string[] = [];
96
- try {
97
- if (!existsSync(SPEC_INPUT)) {
98
- console.error(
99
- `Spec file ${SPEC_INPUT} does not exist. Run 'npm run fix-spec' first.`
100
- );
101
- process.exit(1);
102
- }
103
- const versionToUse = await checkAndPromptForUpdate(messages);
104
- const jarPath = await ensureJarExists(versionToUse, messages);
105
- regenerateClient(jarPath, messages);
106
- } catch (error) {
107
- console.error("Error occurred during process:", error);
108
- } finally {
109
- console.log("\n--- Key Messages ---");
110
- messages.forEach((msg) => console.log(msg));
111
- }
112
- }
113
-
114
- main().catch((error) => {
115
- console.error("Error in regeneration process:", error);
116
- process.exit(1);
117
- });
@@ -1,111 +0,0 @@
1
- import { Operation, Parameter, Spec } from "../types/spec.ts";
2
- import { inferSchema } from "../utils/infer-schema.ts";
3
-
4
- export function enhanceGeneral(spec: Spec): void {
5
- spec.definitions = spec.definitions || {};
6
-
7
- if (!spec.definitions["Record"]) {
8
- spec.definitions["Record"] = {
9
- type: "object",
10
- additionalProperties: {
11
- type: "object",
12
- properties: { value: { type: "string" } },
13
- required: ["value"],
14
- },
15
- description: "A generic QuickBase record with field ID-value pairs",
16
- };
17
- console.log("Added Record to definitions");
18
- }
19
-
20
- if (!spec.definitions["Permission"]) {
21
- spec.definitions["Permission"] = {
22
- type: "object",
23
- properties: {
24
- role: { type: "string", description: "The role name" },
25
- permissionType: {
26
- type: "string",
27
- description: "Permission type (e.g., View, Modify)",
28
- },
29
- roleId: { type: "integer", description: "The role identifier" },
30
- },
31
- required: ["role", "permissionType", "roleId"],
32
- description: "A single permission entry for a field",
33
- };
34
- console.log("Added Permission to definitions");
35
- }
36
-
37
- for (const pathKey in spec.paths) {
38
- for (const method in spec.paths[pathKey]) {
39
- const operation: Operation = spec.paths[pathKey][method];
40
- const opId =
41
- operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
42
-
43
- if (operation.parameters) {
44
- operation.parameters.forEach((param: Parameter) => {
45
- if (param.in !== "body" && !param.type && !param.schema) {
46
- param.type = param.name.includes("Id") ? "string" : "string";
47
- console.log(
48
- `Set default type 'string' for ${pathKey}(${method}).${param.name}`
49
- );
50
- }
51
- });
52
- }
53
-
54
- if (operation.responses) {
55
- for (const status in operation.responses) {
56
- const response = operation.responses[status];
57
- if (response.schema) {
58
- const cleanStatus = status.replace("/", "_");
59
- const responseName = `${opId}${cleanStatus}Response`;
60
- if (!spec.definitions[responseName]) {
61
- console.log(
62
- `Adding ${responseName} to definitions for ${pathKey}(${method})`
63
- );
64
- let schemaToUse = response.schema;
65
- // Only infer from example if schema is truly empty
66
- if (
67
- !schemaToUse.type &&
68
- !schemaToUse.items &&
69
- !schemaToUse.properties
70
- ) {
71
- if (response["x-amf-mediaType"]) {
72
- const mediaType = response["x-amf-mediaType"];
73
- if (mediaType === "application/octet-stream") {
74
- schemaToUse = {
75
- type: "object",
76
- properties: {
77
- data: { type: "string", format: "binary" },
78
- },
79
- description:
80
- schemaToUse?.description || "Binary file content",
81
- };
82
- } else if (mediaType === "application/x-yaml") {
83
- schemaToUse = {
84
- type: "object",
85
- properties: {
86
- content: { type: "string", format: "yaml" },
87
- },
88
- description: "YAML-formatted data",
89
- };
90
- } else if (
91
- mediaType === "application/json" &&
92
- schemaToUse.example
93
- ) {
94
- schemaToUse = inferSchema(
95
- schemaToUse.example,
96
- responseName
97
- );
98
- schemaToUse.description =
99
- response.description || `Response for ${opId}`;
100
- }
101
- }
102
- }
103
- spec.definitions[responseName] = schemaToUse;
104
- }
105
- response.schema = { $ref: `#/definitions/${responseName}` };
106
- }
107
- }
108
- }
109
- }
110
- }
111
- }
@@ -1,68 +0,0 @@
1
- // schema/fix-arrays.ts
2
- import { Parameter, Spec } from "../types/spec.ts";
3
-
4
- export function fixArrays(spec: Spec): void {
5
- for (const pathKey in spec.paths) {
6
- for (const method in spec.paths[pathKey]) {
7
- const operation = spec.paths[pathKey][method];
8
- if (operation.parameters) {
9
- operation.parameters.forEach((param: Parameter) => {
10
- if (param.schema?.type === "array" && !param.schema.items) {
11
- console.log(
12
- `Fixing array schema for ${pathKey}(${method}).${param.name}`
13
- );
14
- param.schema.items = { type: "string" };
15
- }
16
- if (param.schema?.properties) {
17
- for (const propKey in param.schema.properties) {
18
- const prop = param.schema.properties[propKey];
19
- if (prop.type === "array" && !prop.items) {
20
- console.log(
21
- `Fixing nested array for ${pathKey}(${method}).${param.name}.${propKey}`
22
- );
23
- prop.items = { type: "string" };
24
- }
25
- }
26
- }
27
- });
28
- }
29
- if (operation.responses) {
30
- for (const status in operation.responses) {
31
- const response = operation.responses[status];
32
- if (response.schema?.type === "array" && !response.schema.items) {
33
- console.log(
34
- `Fixing array schema for ${pathKey}(${method}).responses.${status}`
35
- );
36
- response.schema.items = { type: "string" };
37
- }
38
- if (response.schema?.properties) {
39
- for (const propKey in response.schema.properties) {
40
- const prop = response.schema.properties[propKey];
41
- if (prop.type === "array" && !prop.items) {
42
- console.log(
43
- `Fixing nested array for ${pathKey}(${method}).responses.${status}.${propKey}`
44
- );
45
- prop.items = { type: "string" };
46
- }
47
- }
48
- }
49
- }
50
- }
51
- }
52
- }
53
-
54
- console.log("Fixing array schemas in definitions...");
55
- const definitions = spec.definitions || {};
56
- for (const defKey in definitions) {
57
- const def = definitions[defKey];
58
- if (def.properties) {
59
- for (const propKey in def.properties) {
60
- const prop = def.properties[propKey];
61
- if (prop.type === "array" && !prop.items) {
62
- console.log(`Fixing missing items in ${defKey}.${propKey}`);
63
- prop.items = { type: "string" };
64
- }
65
- }
66
- }
67
- }
68
- }
@@ -1,90 +0,0 @@
1
- // schema/tags/apps.ts
2
- import { Operation, Parameter, Spec } from "../../types/spec.ts";
3
- import { normalizeDefinitionName } from "../../utils/naming.ts";
4
-
5
- export function enhanceApps(
6
- spec: Spec,
7
- pathKey: string,
8
- method: string,
9
- operation: Operation
10
- ): void {
11
- const opId =
12
- operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
13
- if (operation.parameters && operation.tags?.includes("Apps")) {
14
- operation.parameters.forEach((param: Parameter) => {
15
- if (param.in === "body") {
16
- if (!param.schema) param.schema = {};
17
- let requestName =
18
- param.schema.$ref?.split("/").pop() || `${opId}Request`;
19
- requestName = normalizeDefinitionName(requestName);
20
-
21
- if (
22
- !spec.definitions[requestName] ||
23
- !spec.definitions[requestName].type ||
24
- Object.keys(spec.definitions[requestName]?.properties || {})
25
- .length === 0
26
- ) {
27
- console.log(
28
- `Defining schema for ${requestName} in ${pathKey}(${method})`
29
- );
30
- let properties;
31
- if (pathKey.includes("/copy") && method === "post") {
32
- properties = {
33
- name: { type: "string", description: "The name of the new app." },
34
- description: {
35
- type: "string",
36
- description: "A description for the new app.",
37
- },
38
- properties: {
39
- type: "object",
40
- properties: {
41
- keepData: {
42
- type: "boolean",
43
- description: "Whether to copy data.",
44
- },
45
- excludeFiles: {
46
- type: "boolean",
47
- description: "Whether to exclude files.",
48
- },
49
- usersAndRoles: {
50
- type: "boolean",
51
- description: "Whether to copy users and roles.",
52
- },
53
- assignUserToken: {
54
- type: "boolean",
55
- description: "Whether to assign the user token.",
56
- },
57
- },
58
- description: "Options for customizing the app copy process.",
59
- },
60
- };
61
- } else {
62
- properties = {
63
- name: { type: "string", description: "The name of the app." },
64
- description: {
65
- type: "string",
66
- description: "A description for the app.",
67
- },
68
- assignToken: {
69
- type: "boolean",
70
- description: "Whether to assign the user token.",
71
- },
72
- };
73
- }
74
- spec.definitions[requestName] = {
75
- type: "object",
76
- properties,
77
- required: Object.keys(properties).filter(
78
- (key) => key !== "description" && key !== "properties"
79
- ),
80
- description: operation.summary || `Request body for ${opId}`,
81
- };
82
- }
83
- param.schema = { $ref: `#/definitions/${requestName}` };
84
- console.log(
85
- `Ensured ${requestName} in definitions for ${pathKey}(${method})`
86
- );
87
- }
88
- });
89
- }
90
- }