quickbase-js 0.1.0-beta.13 → 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 (167) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/quickbase.d.ts +2 -1
  3. package/package.json +9 -4
  4. package/CHANGELOG.md +0 -239
  5. package/build-common.js +0 -131
  6. package/build-esm.js +0 -71
  7. package/build-umd.js +0 -69
  8. package/docs/.vitepress/cache/deps/@theme_index.js +0 -275
  9. package/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  10. package/docs/.vitepress/cache/deps/_metadata.json +0 -40
  11. package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js +0 -12542
  12. package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js.map +0 -7
  13. package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js +0 -9719
  14. package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js.map +0 -7
  15. package/docs/.vitepress/cache/deps/package.json +0 -3
  16. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4504
  17. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  18. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -583
  19. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  20. package/docs/.vitepress/cache/deps/vue.js +0 -343
  21. package/docs/.vitepress/cache/deps/vue.js.map +0 -7
  22. package/docs/.vitepress/config.mts +0 -26
  23. package/docs/api-examples.md +0 -49
  24. package/docs/index.md +0 -59
  25. package/docs/markdown-examples.md +0 -85
  26. package/docs-data/api-docs.json +0 -4143
  27. package/examples/quicbase-jsCDN.html +0 -36
  28. package/examples/react.js +0 -48
  29. package/examples/vanillajs.html +0 -47
  30. package/index.md +0 -25
  31. package/open-api/fix-spec-main.ts +0 -133
  32. package/open-api/generate-unified-interface.ts +0 -104
  33. package/open-api/generateDocsJson.ts +0 -24
  34. package/open-api/output/quickbase-fixed.json +0 -11191
  35. package/open-api/post-process-generated.ts +0 -226
  36. package/open-api/regenerate-client.ts +0 -117
  37. package/open-api/schema/enhance-general.ts +0 -111
  38. package/open-api/schema/fix-arrays.ts +0 -68
  39. package/open-api/schema/tags/apps.ts +0 -90
  40. package/open-api/schema/tags/fields.ts +0 -471
  41. package/open-api/schema/tags/groups.ts +0 -51
  42. package/open-api/schema/tags/index.ts +0 -66
  43. package/open-api/schema/tags/records.ts +0 -115
  44. package/open-api/schema/tags/tables.ts +0 -211
  45. package/open-api/schema/tags/users.ts +0 -47
  46. package/open-api/types/spec.ts +0 -42
  47. package/open-api/utils/common.ts +0 -29
  48. package/open-api/utils/generateJsDoc.ts +0 -74
  49. package/open-api/utils/infer-schema.ts +0 -40
  50. package/open-api/utils/naming.ts +0 -10
  51. package/open-api/utils/sharedUtils.ts +0 -352
  52. package/playwright.config.ts +0 -37
  53. package/rollup.config.js +0 -114
  54. package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -46878
  55. package/specs/split/apps.json +0 -1315
  56. package/specs/split/auth.json +0 -191
  57. package/specs/split/fields.json +0 -3869
  58. package/specs/split/records.json +0 -754
  59. package/specs/split/reports.json +0 -619
  60. package/specs/split/tables.json +0 -1605
  61. package/src/BurstAwareThrottleBucket.ts +0 -57
  62. package/src/FlowThrottleBucket.ts +0 -47
  63. package/src/RateLimitError.ts +0 -12
  64. package/src/RateThrottleBucket.ts +0 -5
  65. package/src/Semaphore.ts +0 -33
  66. package/src/authorizationStrategy.ts +0 -321
  67. package/src/generated-unified/QuickbaseClient.ts +0 -1135
  68. package/src/generated-unified/missing-types-report.json +0 -3
  69. package/src/index.ts +0 -1
  70. package/src/invokeMethod.ts +0 -290
  71. package/src/pagination.ts +0 -429
  72. package/src/quickbaseClient.ts +0 -227
  73. package/src/rateLimiter.ts +0 -30
  74. package/src/tokenCache.ts +0 -39
  75. package/src/utils.ts +0 -50
  76. package/tests/playwright/qb/auth/cacheSwitching.test.ts +0 -159
  77. package/tests/playwright/qb/auth/fetchTempToken401.test.ts +0 -219
  78. package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +0 -162
  79. package/tests/playwright/qb/auth/getAppWithTempTokenConcurrency.test.ts +0 -208
  80. package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +0 -153
  81. package/tests/playwright/qb/auth/getTempToken.test.ts +0 -152
  82. package/tests/playwright/qb/auth/tempTokenPrefetch.test.ts +0 -179
  83. package/tests/playwright/qb/auth/tempTokenRenewal.test.ts +0 -133
  84. package/tests/setup.ts +0 -53
  85. package/tests/vitest/qb/apps/copyApp.test.ts +0 -76
  86. package/tests/vitest/qb/apps/createApp.test.ts +0 -64
  87. package/tests/vitest/qb/apps/deleteApp.test.ts +0 -76
  88. package/tests/vitest/qb/apps/getApp.test.ts +0 -44
  89. package/tests/vitest/qb/apps/getAppEvents.test.ts +0 -67
  90. package/tests/vitest/qb/apps/updateApp.test.ts +0 -58
  91. package/tests/vitest/qb/auth/mockQuickbaseServer.ts +0 -60
  92. package/tests/vitest/qb/auth/retryUserToken401.test.ts +0 -73
  93. package/tests/vitest/qb/auth/ssoTokenConcurrency.test.ts +0 -68
  94. package/tests/vitest/qb/auth/ssoTokenIntegrationWithServer.test.ts +0 -65
  95. package/tests/vitest/qb/auth/userTokenConcurrency.test.ts +0 -63
  96. package/tests/vitest/qb/fields/createField.test.ts +0 -77
  97. package/tests/vitest/qb/fields/deleteFields.test.ts +0 -83
  98. package/tests/vitest/qb/fields/getField.test.ts +0 -85
  99. package/tests/vitest/qb/fields/getFieldUsage.test.ts +0 -82
  100. package/tests/vitest/qb/fields/getFields.test.ts +0 -232
  101. package/tests/vitest/qb/fields/getFieldsUsage.test.ts +0 -77
  102. package/tests/vitest/qb/fields/updateField.test.ts +0 -93
  103. package/tests/vitest/qb/formulas/runFormula.test.ts +0 -96
  104. package/tests/vitest/qb/index.ts +0 -29
  105. package/tests/vitest/qb/quickbase-js/BurstAwareThrottleBucket.test.ts +0 -125
  106. package/tests/vitest/qb/quickbase-js/FlowBucket.test.ts +0 -77
  107. package/tests/vitest/qb/quickbase-js/paginationSkip.test.ts +0 -111
  108. package/tests/vitest/qb/records/deleteRecords.test.ts +0 -110
  109. package/tests/vitest/qb/records/runQuery.test.ts +0 -145
  110. package/tests/vitest/qb/records/upsert.test.ts +0 -102
  111. package/tests/vitest/qb/tables/createRelationship.test.ts +0 -102
  112. package/tests/vitest/qb/tables/createTable.test.ts +0 -55
  113. package/tests/vitest/qb/tables/deleteRelationship.test.ts +0 -143
  114. package/tests/vitest/qb/tables/deleteTable.test.ts +0 -50
  115. package/tests/vitest/qb/tables/getAppTables.test.ts +0 -46
  116. package/tests/vitest/qb/tables/getRelationships.test.ts +0 -80
  117. package/tests/vitest/qb/tables/getTable.test.ts +0 -26
  118. package/tests/vitest/qb/tables/updateRelationship.test.ts +0 -250
  119. package/tests/vitest/qb/tables/updateTable.test.ts +0 -48
  120. package/tests/vitest/unit/apps/copyApp.test.ts +0 -581
  121. package/tests/vitest/unit/apps/createApp.test.ts +0 -186
  122. package/tests/vitest/unit/apps/deleteApp.test.ts +0 -216
  123. package/tests/vitest/unit/apps/getApp.test.ts +0 -128
  124. package/tests/vitest/unit/apps/getAppConcurrency.test.ts +0 -151
  125. package/tests/vitest/unit/apps/getAppEvents.test.ts +0 -193
  126. package/tests/vitest/unit/apps/updateApp.test.ts +0 -412
  127. package/tests/vitest/unit/auth/fetchTempToken401.test.ts +0 -81
  128. package/tests/vitest/unit/auth/getTempToken.test.ts +0 -119
  129. package/tests/vitest/unit/auth/retryTempToken401.test.ts +0 -95
  130. package/tests/vitest/unit/auth/retryTempTokenMaxRetries.test.ts +0 -206
  131. package/tests/vitest/unit/auth/retryUserToken401.test.ts +0 -66
  132. package/tests/vitest/unit/auth/ssoTokenRefresh.test.ts +0 -325
  133. package/tests/vitest/unit/auth/userTokenConcurrency.test.ts +0 -62
  134. package/tests/vitest/unit/fields/createField.test.ts +0 -451
  135. package/tests/vitest/unit/fields/deleteFields.test.ts +0 -141
  136. package/tests/vitest/unit/fields/getField.test.ts +0 -189
  137. package/tests/vitest/unit/fields/getFieldUsage.test.ts +0 -180
  138. package/tests/vitest/unit/fields/getFields.test.ts +0 -122
  139. package/tests/vitest/unit/fields/getFieldsUsage.test.ts +0 -160
  140. package/tests/vitest/unit/fields/updateField.test.ts +0 -285
  141. package/tests/vitest/unit/formulas/runFormula.test.ts +0 -205
  142. package/tests/vitest/unit/index.ts +0 -34
  143. package/tests/vitest/unit/quickbase-js/BurstAwareThrottleBucket.test.ts +0 -108
  144. package/tests/vitest/unit/quickbase-js/FlowBucket.test.ts +0 -101
  145. package/tests/vitest/unit/quickbase-js/pagination.test.ts +0 -251
  146. package/tests/vitest/unit/quickbase-js/quickbaseClientHttpMethods.test.ts +0 -141
  147. package/tests/vitest/unit/quickbase-js/rateLimit.test.ts +0 -191
  148. package/tests/vitest/unit/quickbase-js/tokenLifespan.test.ts +0 -204
  149. package/tests/vitest/unit/records/deleteRecords.test.ts +0 -112
  150. package/tests/vitest/unit/records/runQuery.test.ts +0 -101
  151. package/tests/vitest/unit/records/upsert.test.ts +0 -234
  152. package/tests/vitest/unit/tables/createRelationship.test.ts +0 -212
  153. package/tests/vitest/unit/tables/createTable.test.ts +0 -70
  154. package/tests/vitest/unit/tables/deleteRelationship.test.ts +0 -97
  155. package/tests/vitest/unit/tables/deleteTable.test.ts +0 -77
  156. package/tests/vitest/unit/tables/getAppTables.test.ts +0 -85
  157. package/tests/vitest/unit/tables/getRelationships.test.ts +0 -259
  158. package/tests/vitest/unit/tables/getTable.test.ts +0 -233
  159. package/tests/vitest/unit/tables/updateRelationship.test.ts +0 -307
  160. package/tests/vitest/unit/tables/updateTable.test.ts +0 -80
  161. package/tools/log-gen.ts +0 -251
  162. package/tools/log-gen.yaml +0 -4829
  163. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  164. package/tsconfig.build.json +0 -17
  165. package/tsconfig.json +0 -32
  166. package/versionrc.json +0 -9
  167. 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
- }