quickbase-js 0.1.0-beta.10

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 (165) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/LICENSE +21 -0
  3. package/README.md +179 -0
  4. package/api-examples.md +49 -0
  5. package/build-common.js +131 -0
  6. package/build-esm.js +71 -0
  7. package/build-umd.js +69 -0
  8. package/dist/esm/quickbase.d.ts +8081 -0
  9. package/dist/esm/quickbase.js +7928 -0
  10. package/dist/esm/quickbase.js.map +1 -0
  11. package/dist/esm/quickbase.min.js +2 -0
  12. package/dist/esm/quickbase.min.js.map +1 -0
  13. package/dist/umd/quickbase.umd.js +8504 -0
  14. package/dist/umd/quickbase.umd.js.map +1 -0
  15. package/dist/umd/quickbase.umd.min.js +2 -0
  16. package/dist/umd/quickbase.umd.min.js.map +1 -0
  17. package/docs/.vitepress/cache/deps/@theme_index.js +275 -0
  18. package/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
  19. package/docs/.vitepress/cache/deps/_metadata.json +40 -0
  20. package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js +12542 -0
  21. package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js.map +7 -0
  22. package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js +9719 -0
  23. package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js.map +7 -0
  24. package/docs/.vitepress/cache/deps/package.json +3 -0
  25. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4504 -0
  26. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  27. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +583 -0
  28. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  29. package/docs/.vitepress/cache/deps/vue.js +343 -0
  30. package/docs/.vitepress/cache/deps/vue.js.map +7 -0
  31. package/docs/.vitepress/config.mts +26 -0
  32. package/docs/api-examples.md +49 -0
  33. package/docs/index.md +59 -0
  34. package/docs/markdown-examples.md +85 -0
  35. package/docs-data/api-docs.json +4143 -0
  36. package/examples/quicbase-jsCDN.html +36 -0
  37. package/examples/react.js +48 -0
  38. package/examples/vanillajs.html +47 -0
  39. package/index.md +25 -0
  40. package/markdown-examples.md +85 -0
  41. package/open-api/fix-spec-main.ts +133 -0
  42. package/open-api/generate-unified-interface.ts +104 -0
  43. package/open-api/generateDocsJson.ts +24 -0
  44. package/open-api/output/quickbase-fixed.json +11191 -0
  45. package/open-api/post-process-generated.ts +226 -0
  46. package/open-api/regenerate-client.ts +117 -0
  47. package/open-api/schema/enhance-general.ts +111 -0
  48. package/open-api/schema/fix-arrays.ts +68 -0
  49. package/open-api/schema/tags/apps.ts +90 -0
  50. package/open-api/schema/tags/fields.ts +471 -0
  51. package/open-api/schema/tags/groups.ts +51 -0
  52. package/open-api/schema/tags/index.ts +66 -0
  53. package/open-api/schema/tags/records.ts +115 -0
  54. package/open-api/schema/tags/tables.ts +211 -0
  55. package/open-api/schema/tags/users.ts +47 -0
  56. package/open-api/types/spec.ts +42 -0
  57. package/open-api/utils/common.ts +29 -0
  58. package/open-api/utils/generateJsDoc.ts +74 -0
  59. package/open-api/utils/infer-schema.ts +40 -0
  60. package/open-api/utils/naming.ts +10 -0
  61. package/open-api/utils/sharedUtils.ts +352 -0
  62. package/package.json +96 -0
  63. package/playwright.config.ts +37 -0
  64. package/rollup.config.js +114 -0
  65. package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +46878 -0
  66. package/specs/split/apps.json +1315 -0
  67. package/specs/split/auth.json +191 -0
  68. package/specs/split/fields.json +3869 -0
  69. package/specs/split/records.json +754 -0
  70. package/specs/split/reports.json +619 -0
  71. package/specs/split/tables.json +1605 -0
  72. package/src/RateLimitError.ts +12 -0
  73. package/src/ThrottleBucket.ts +41 -0
  74. package/src/authorizationStrategy.ts +283 -0
  75. package/src/generated-unified/QuickbaseClient.ts +1135 -0
  76. package/src/generated-unified/missing-types-report.json +3 -0
  77. package/src/index.ts +1 -0
  78. package/src/invokeMethod.ts +245 -0
  79. package/src/quickbaseClient.ts +194 -0
  80. package/src/rateLimiter.ts +25 -0
  81. package/src/tokenCache.ts +35 -0
  82. package/src/utils.ts +50 -0
  83. package/tests/playwright/qb/auth/cacheSwitching.test.ts +159 -0
  84. package/tests/playwright/qb/auth/fetchTempToken401.test.ts +219 -0
  85. package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +162 -0
  86. package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +153 -0
  87. package/tests/playwright/qb/auth/getTempToken.test.ts +152 -0
  88. package/tests/playwright/qb/auth/tempTokenPrefetch.test.ts +179 -0
  89. package/tests/playwright/qb/auth/tempTokenRenewal.test.ts +133 -0
  90. package/tests/setup.ts +53 -0
  91. package/tests/vitest/qb/apps/copyApp.test.ts +76 -0
  92. package/tests/vitest/qb/apps/createApp.test.ts +64 -0
  93. package/tests/vitest/qb/apps/deleteApp.test.ts +76 -0
  94. package/tests/vitest/qb/apps/getApp.test.ts +44 -0
  95. package/tests/vitest/qb/apps/getAppEvents.test.ts +67 -0
  96. package/tests/vitest/qb/apps/updateApp.test.ts +58 -0
  97. package/tests/vitest/qb/auth/mockQuickbaseServer.ts +60 -0
  98. package/tests/vitest/qb/auth/retryUserToken401.test.ts +73 -0
  99. package/tests/vitest/qb/auth/ssoTokenIntegrationWithServer.test.ts +65 -0
  100. package/tests/vitest/qb/fields/createField.test.ts +77 -0
  101. package/tests/vitest/qb/fields/deleteFields.test.ts +83 -0
  102. package/tests/vitest/qb/fields/getField.test.ts +85 -0
  103. package/tests/vitest/qb/fields/getFieldUsage.test.ts +82 -0
  104. package/tests/vitest/qb/fields/getFields.test.ts +232 -0
  105. package/tests/vitest/qb/fields/getFieldsUsage.test.ts +77 -0
  106. package/tests/vitest/qb/fields/updateField.test.ts +93 -0
  107. package/tests/vitest/qb/formulas/runFormula.test.ts +96 -0
  108. package/tests/vitest/qb/index.ts +29 -0
  109. package/tests/vitest/qb/records/deleteRecords.test.ts +110 -0
  110. package/tests/vitest/qb/records/runQuery.test.ts +146 -0
  111. package/tests/vitest/qb/records/upsert.test.ts +102 -0
  112. package/tests/vitest/qb/tables/createRelationship.test.ts +102 -0
  113. package/tests/vitest/qb/tables/createTable.test.ts +55 -0
  114. package/tests/vitest/qb/tables/deleteRelationship.test.ts +143 -0
  115. package/tests/vitest/qb/tables/deleteTable.test.ts +50 -0
  116. package/tests/vitest/qb/tables/getAppTables.test.ts +46 -0
  117. package/tests/vitest/qb/tables/getRelationships.test.ts +80 -0
  118. package/tests/vitest/qb/tables/getTable.test.ts +26 -0
  119. package/tests/vitest/qb/tables/updateRelationship.test.ts +250 -0
  120. package/tests/vitest/qb/tables/updateTable.test.ts +48 -0
  121. package/tests/vitest/unit/ThrottleBucket.test.ts +95 -0
  122. package/tests/vitest/unit/apps/copyApp.test.ts +581 -0
  123. package/tests/vitest/unit/apps/createApp.test.ts +186 -0
  124. package/tests/vitest/unit/apps/deleteApp.test.ts +216 -0
  125. package/tests/vitest/unit/apps/getApp.test.ts +128 -0
  126. package/tests/vitest/unit/apps/getAppEvents.test.ts +193 -0
  127. package/tests/vitest/unit/apps/updateApp.test.ts +412 -0
  128. package/tests/vitest/unit/auth/fetchTempToken401.test.ts +63 -0
  129. package/tests/vitest/unit/auth/getTempToken.test.ts +119 -0
  130. package/tests/vitest/unit/auth/retryTempToken401.test.ts +95 -0
  131. package/tests/vitest/unit/auth/retryTempTokenMaxRetries.test.ts +206 -0
  132. package/tests/vitest/unit/auth/retryUserToken401.test.ts +69 -0
  133. package/tests/vitest/unit/auth/ssoTokenRefresh.test.ts +325 -0
  134. package/tests/vitest/unit/fields/createField.test.ts +451 -0
  135. package/tests/vitest/unit/fields/deleteFields.test.ts +141 -0
  136. package/tests/vitest/unit/fields/getField.test.ts +189 -0
  137. package/tests/vitest/unit/fields/getFieldUsage.test.ts +180 -0
  138. package/tests/vitest/unit/fields/getFields.test.ts +122 -0
  139. package/tests/vitest/unit/fields/getFieldsUsage.test.ts +160 -0
  140. package/tests/vitest/unit/fields/updateField.test.ts +285 -0
  141. package/tests/vitest/unit/formulas/runFormula.test.ts +205 -0
  142. package/tests/vitest/unit/index.ts +34 -0
  143. package/tests/vitest/unit/quickbaseClientHttpMethods.test.ts +139 -0
  144. package/tests/vitest/unit/rateLimit.test.ts +191 -0
  145. package/tests/vitest/unit/records/deleteRecords.test.ts +112 -0
  146. package/tests/vitest/unit/records/runQuery.test.ts +102 -0
  147. package/tests/vitest/unit/records/upsert.test.ts +234 -0
  148. package/tests/vitest/unit/tables/createRelationship.test.ts +212 -0
  149. package/tests/vitest/unit/tables/createTable.test.ts +70 -0
  150. package/tests/vitest/unit/tables/deleteRelationship.test.ts +97 -0
  151. package/tests/vitest/unit/tables/deleteTable.test.ts +77 -0
  152. package/tests/vitest/unit/tables/getAppTables.test.ts +85 -0
  153. package/tests/vitest/unit/tables/getRelationships.test.ts +259 -0
  154. package/tests/vitest/unit/tables/getTable.test.ts +233 -0
  155. package/tests/vitest/unit/tables/updateRelationship.test.ts +307 -0
  156. package/tests/vitest/unit/tables/updateTable.test.ts +80 -0
  157. package/tests/vitest/unit/tokenLifespan.test.ts +204 -0
  158. package/tests/vitest/unit/umd.test.ts +8 -0
  159. package/tools/log-gen.ts +251 -0
  160. package/tools/log-gen.yaml +4777 -0
  161. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  162. package/tsconfig.build.json +17 -0
  163. package/tsconfig.json +32 -0
  164. package/versionrc.json +9 -0
  165. package/vitest.config.ts +27 -0
@@ -0,0 +1,36 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <title>Quickbase</title>
6
+ <script src="https://cdn.jsdelivr.net/npm/quickbase-js@1.1.0-beta.6/dist/umd/quickbase.umd.min.js"></script>
7
+ </head>
8
+
9
+ <body>
10
+ <div>
11
+ <h1>Quickbase-js CDN Example</h1>
12
+ <p id="result">Loading...</p>
13
+ </div>
14
+ <script>
15
+ var realm = "xxxxxxxxxxxxxxxxxxxx"; // replace with your realm
16
+ var appId = "xxxxxxxxxxxxxxxxxxxx"; // replace with your app ID
17
+ if (typeof QuickbaseJS === "undefined") {
18
+ document.getElementById("result").textContent = "Error: Failed to load QuickbaseJS library.";
19
+ } else {
20
+ var qbClient = QuickbaseJS.quickbase({
21
+ realm,
22
+ useTempTokens: true
23
+ });
24
+
25
+ qbClient.getApp({ appId })
26
+ .then(function (app) {
27
+ document.getElementById("result").textContent = "App Name: " + app.name;
28
+ })
29
+ .catch(function (err) {
30
+ document.getElementById("result").textContent = "Error: " + (err.message || "Failed to load app");
31
+ });
32
+ }
33
+ </script>
34
+ </body>
35
+
36
+ </html>
@@ -0,0 +1,48 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import { quickbase } from "quickbase-js";
3
+
4
+ const App = () => {
5
+ const [appName, setAppName] = useState < string > "Loading...";
6
+ const [error, setError] = (useState < string) | (null > null);
7
+
8
+ useEffect(() => {
9
+ // Initialize the QuickBase client
10
+ const qb = quickbase({
11
+ realm: "your-realm", // Replace with actual QuickBase realm
12
+ // ## ------------------------------
13
+ // ## Authentication Options
14
+ // ## ------------------------------
15
+ // ## OPTION 1: User Token Authentication
16
+ // ## - Use this if you have a QuickBase user token (get it from "My Profile" > "Manage User Tokens")
17
+ // ## - Works in Node.js or browsers, ideal for standalone apps or testing outside QuickBase
18
+ // ## - Use the line below and replace with your token; comment out 'useTempTokens'
19
+ // userToken: "your-user-token",
20
+
21
+ // ## ------------------------------
22
+ // ## OPTION 2: Temporary Token Authentication
23
+ // ## - Use this for QuickBase code pages, leveraging the browser’s authenticated session
24
+ // ## - No user token needed; requires running in a QuickBase browser context
25
+ // ## - Uncomment the line below and comment out 'userToken' if using this option
26
+ // useTempTokens: true,
27
+ });
28
+
29
+ // Fetch the app
30
+ qb.getApp({ appId: "your-app-id" }) // Replace with actual app ID
31
+ .then((app) => {
32
+ setAppName(app.name);
33
+ })
34
+ .catch((err) => {
35
+ console.error("Error fetching app:", err);
36
+ setError("Failed to load app");
37
+ });
38
+ }, []); // Empty dependency array to run once on mount
39
+
40
+ return (
41
+ <div>
42
+ <h1>Quickbase Test</h1>
43
+ {error ? <p>{error}</p> : <p>App Name: {appName}</p>}
44
+ </div>
45
+ );
46
+ };
47
+
48
+ export default App;
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <title>Quickbase Test</title>
6
+ </head>
7
+
8
+ <body>
9
+ <div>
10
+ <h1>Quickbase Test</h1>
11
+ <p id="result">Loading...</p>
12
+ </div>
13
+ <script type="module">
14
+ import { quickbase } from 'quickbase-js';
15
+ // Initalize the QuickBase client
16
+ const qb = quickbase({
17
+ realm: 'your-realm', // Replace with actual QuickBase realm
18
+ // ## ------------------------------
19
+ // ## Authentication Options
20
+ // ## ----------------------------
21
+ // ## OPTION 1: User Token Authentication
22
+ // ## - Use this if you have a QuickBase user token (get it from "My Profile" > "Manage User Tokens")
23
+ // ## - Works in Node.js or browsers, ideal for standalone apps or testing outside QuickBase
24
+ // ## - Uncomment the line below and replace with your token; comment out 'useTempTokens'
25
+ // userToken: "your-user-token",
26
+
27
+ // ## ----------------------------
28
+ // ## OPTION 2: Temporary Token Authentication
29
+ // ## - Use this for QuickBase code pages, leveraging the browser’s authenticated session
30
+ // ## - No user token needed; requires running in a QuickBase browser context
31
+ // ## - Uncomment the line below and comment out 'userToken' if using this option
32
+ // useTempTokens: true,
33
+ });
34
+
35
+ // Fetch the app
36
+ qb.getApp({ appId: 'your-app-id' }) // Replace with actual app ID
37
+ .then((app) => {
38
+ document.getElementById('result').textContent = `App Name: ${app.name}`;
39
+ })
40
+ .catch((err) => {
41
+ console.error('Error fetching app:', err);
42
+ document.getElementById('result').textContent = err.message || 'Failed to load app';
43
+ });
44
+ </script>
45
+ </body>
46
+
47
+ </html>
package/index.md ADDED
@@ -0,0 +1,25 @@
1
+ ---
2
+ # https://vitepress.dev/reference/default-theme-home-page
3
+ layout: home
4
+
5
+ hero:
6
+ name: "Quickbase JS API Docs"
7
+ text: "Documentation for quickbase-js library"
8
+ tagline: My great project tagline
9
+ actions:
10
+ - theme: brand
11
+ text: Markdown Examples
12
+ link: /markdown-examples
13
+ - theme: alt
14
+ text: API Examples
15
+ link: /api-examples
16
+
17
+ features:
18
+ - title: Feature A
19
+ details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
20
+ - title: Feature B
21
+ details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
22
+ - title: Feature C
23
+ details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
24
+ ---
25
+
@@ -0,0 +1,85 @@
1
+ # Markdown Extension Examples
2
+
3
+ This page demonstrates some of the built-in markdown extensions provided by VitePress.
4
+
5
+ ## Syntax Highlighting
6
+
7
+ VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
8
+
9
+ **Input**
10
+
11
+ ````md
12
+ ```js{4}
13
+ export default {
14
+ data () {
15
+ return {
16
+ msg: 'Highlighted!'
17
+ }
18
+ }
19
+ }
20
+ ```
21
+ ````
22
+
23
+ **Output**
24
+
25
+ ```js{4}
26
+ export default {
27
+ data () {
28
+ return {
29
+ msg: 'Highlighted!'
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Custom Containers
36
+
37
+ **Input**
38
+
39
+ ```md
40
+ ::: info
41
+ This is an info box.
42
+ :::
43
+
44
+ ::: tip
45
+ This is a tip.
46
+ :::
47
+
48
+ ::: warning
49
+ This is a warning.
50
+ :::
51
+
52
+ ::: danger
53
+ This is a dangerous warning.
54
+ :::
55
+
56
+ ::: details
57
+ This is a details block.
58
+ :::
59
+ ```
60
+
61
+ **Output**
62
+
63
+ ::: info
64
+ This is an info box.
65
+ :::
66
+
67
+ ::: tip
68
+ This is a tip.
69
+ :::
70
+
71
+ ::: warning
72
+ This is a warning.
73
+ :::
74
+
75
+ ::: danger
76
+ This is a dangerous warning.
77
+ :::
78
+
79
+ ::: details
80
+ This is a details block.
81
+ :::
82
+
83
+ ## More
84
+
85
+ Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { promises as fs } from "fs";
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ import * as glob from "glob";
7
+ import { Spec } from "./types/spec.ts";
8
+ import { toCamelCase } from "./utils/naming.ts";
9
+
10
+ async function fixQuickBaseSpec(): Promise<void> {
11
+ const CODEGEN_DIR = path.dirname(fileURLToPath(import.meta.url));
12
+ const SPECS_DIR = path.join(CODEGEN_DIR, "..", "specs");
13
+ const OUTPUT_DIR = path.join(CODEGEN_DIR, "output");
14
+ console.log("Finding latest QuickBase RESTful API spec...");
15
+ const specFiles = glob.sync(path.join(SPECS_DIR, "QuickBase_RESTful_*.json"));
16
+ console.log("Spec files:", specFiles);
17
+
18
+ if (specFiles.length === 0) {
19
+ throw new Error(
20
+ "No QuickBase_RESTful_*.json files found in specs/ folder."
21
+ );
22
+ }
23
+
24
+ const inputFile = specFiles.sort().pop() as string;
25
+ const outputFile = path.join(OUTPUT_DIR, "quickbase-fixed.json");
26
+
27
+ console.log(`Reading ${path.basename(inputFile)} from specs/...`);
28
+ const specContent = await fs.readFile(inputFile, "utf8");
29
+ console.log("File read successfully");
30
+ const spec: Spec = JSON.parse(specContent);
31
+ console.log("JSON parsed successfully");
32
+
33
+ if (!spec.definitions || typeof spec.definitions !== "object") {
34
+ spec.definitions = {};
35
+ }
36
+ console.log("Spec definitions after initialization:", spec.definitions);
37
+
38
+ console.log(
39
+ "Original /apps/{appId}/events 200 schema:",
40
+ JSON.stringify(
41
+ spec.paths["/apps/{appId}/events"]?.get?.responses?.["200"]?.schema,
42
+ null,
43
+ 2
44
+ )
45
+ );
46
+
47
+ console.log("Fixing parameters...");
48
+ for (const pathKey in spec.paths) {
49
+ for (const method in spec.paths[pathKey]) {
50
+ const operation = spec.paths[pathKey][method];
51
+ if (operation.parameters) {
52
+ operation.parameters = operation.parameters
53
+ .filter(
54
+ (param) =>
55
+ !["QB-Realm-Hostname", "Authorization", "User-Agent"].includes(
56
+ param.name
57
+ )
58
+ )
59
+ .map((param) => {
60
+ param.name = toCamelCase(param.name);
61
+ if ("example" in param) delete param.example;
62
+ if ("schema" in param && param.in !== "body") delete param.schema;
63
+ if (!param.type && param.in !== "body") {
64
+ param.type = param.name.includes("Id") ? "string" : "string";
65
+ console.log(
66
+ `Set default type 'string' for ${pathKey}(${method}).${param.name}`
67
+ );
68
+ }
69
+ return param;
70
+ });
71
+ }
72
+ }
73
+ }
74
+
75
+ console.log("Spec definitions before enhanceTags:", spec.definitions);
76
+ console.log("Enhancing raw spec with tags...");
77
+ const { enhanceTags } = await import("./schema/tags/index.ts");
78
+ enhanceTags(spec);
79
+ console.log(
80
+ "After enhanceTags:",
81
+ JSON.stringify(
82
+ spec.paths["/apps/{appId}/events"]?.get?.responses?.["200"]?.schema,
83
+ null,
84
+ 2
85
+ )
86
+ );
87
+
88
+ console.log("Enhancing raw spec with general enhancements...");
89
+ const { enhanceGeneral } = await import("./schema/enhance-general.ts");
90
+ enhanceGeneral(spec);
91
+ console.log(
92
+ "After enhanceGeneral:",
93
+ JSON.stringify(
94
+ spec.paths["/apps/{appId}/events"]?.get?.responses?.["200"]?.schema,
95
+ null,
96
+ 2
97
+ )
98
+ );
99
+
100
+ console.log("Fixing array schemas...");
101
+ const { fixArrays } = await import("./schema/fix-arrays.ts");
102
+ fixArrays(spec);
103
+ console.log(
104
+ "After fixArrays:",
105
+ JSON.stringify(
106
+ spec.paths["/apps/{appId}/events"]?.get?.responses?.["200"]?.schema,
107
+ null,
108
+ 2
109
+ )
110
+ );
111
+
112
+ console.log("Removing unexpected top-level attributes...");
113
+ delete spec.operations;
114
+ delete spec.groups;
115
+ delete spec.components;
116
+
117
+ console.log(`Writing fixed spec to ${path.basename(outputFile)}...`);
118
+ await fs.mkdir(OUTPUT_DIR, { recursive: true });
119
+ await fs.writeFile(outputFile, JSON.stringify(spec, null, 2), "utf8");
120
+ console.log("Spec fixed successfully! Output written to:", outputFile);
121
+ }
122
+
123
+ async function main() {
124
+ try {
125
+ console.log("Starting...");
126
+ await fixQuickBaseSpec();
127
+ } catch (error) {
128
+ console.error("Error:", error);
129
+ process.exit(1);
130
+ }
131
+ }
132
+
133
+ main();
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env node
2
+
3
+ console.log("Script started");
4
+
5
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
6
+ console.log("FS modules imported");
7
+
8
+ import { join, dirname } from "path";
9
+ console.log("Path modules imported");
10
+
11
+ import { fileURLToPath } from "url";
12
+ console.log("URL module imported");
13
+
14
+ import { generateJsDoc } from "./utils/generateJsDoc.ts";
15
+ import {
16
+ PropertyDetail,
17
+ ParamDetail,
18
+ JsDocOptions,
19
+ mapOpenApiTypeToTs,
20
+ mapRefToType,
21
+ parseInterfaceProperties,
22
+ parseOpenApiOperations,
23
+ } from "./utils/sharedUtils.ts";
24
+ import { writeFileSafe, runTask } from "./utils/common.ts";
25
+
26
+ const __dirname = dirname(fileURLToPath(import.meta.url));
27
+ console.log("__dirname set:", __dirname);
28
+
29
+ const SPEC_FILE = join(__dirname, "output", "quickbase-fixed.json");
30
+ const OUTPUT_DIR = join(__dirname, "..", "src", "generated-unified");
31
+ const OUTPUT_FILE = join(OUTPUT_DIR, "QuickbaseClient.ts");
32
+ const MODELS_DIR = join(__dirname, "..", "src", "generated", "models");
33
+
34
+ function generateInterface(includeResponseProperties: boolean = false): void {
35
+ console.log(
36
+ "Generating interface with includeResponseProperties:",
37
+ includeResponseProperties
38
+ );
39
+
40
+ console.log("Checking spec file:", SPEC_FILE);
41
+ if (!existsSync(SPEC_FILE)) {
42
+ console.error(
43
+ `Spec file ${SPEC_FILE} not found. Run 'npm run fix-spec' first.`
44
+ );
45
+ process.exit(1);
46
+ }
47
+
48
+ console.log("Checking models directory:", MODELS_DIR);
49
+ if (!existsSync(MODELS_DIR)) {
50
+ console.error(
51
+ `Models directory ${MODELS_DIR} not found. Run 'npm run gen:openapi' first.`
52
+ );
53
+ process.exit(1);
54
+ }
55
+
56
+ const { operations, modelImports, missingTypes } = parseOpenApiOperations(
57
+ SPEC_FILE,
58
+ MODELS_DIR
59
+ );
60
+ console.log("Operations parsed:", operations.length);
61
+
62
+ const methods: string[] = operations.map((op) => {
63
+ const params = op.parameters
64
+ .map((p) => `${p.name}${p.required ? "" : "?"}: ${p.type}`)
65
+ .join("; ");
66
+ const jsDocOptions: JsDocOptions = {
67
+ summary: op.summary,
68
+ opId: op.name,
69
+ paramDetails: op.parameters,
70
+ returnType: op.returns,
71
+ returnTypeDetails: includeResponseProperties
72
+ ? op.returnTypeDetails || []
73
+ : [],
74
+ docLink: op.docLink,
75
+ };
76
+ const jsDoc = generateJsDoc(jsDocOptions);
77
+ return `${jsDoc}\n ${op.name}: (params: { ${params} }) => Promise<${op.returns}>;`;
78
+ });
79
+
80
+ console.log("Writing missing types report...");
81
+ writeFileSafe(
82
+ join(OUTPUT_DIR, "missing-types-report.json"),
83
+ JSON.stringify({ missingTypes: Array.from(missingTypes) }, null, 2)
84
+ );
85
+
86
+ const importStatement =
87
+ modelImports.size > 0
88
+ ? `import { ${Array.from(modelImports)
89
+ .sort()
90
+ .join(", ")} } from "../generated/models";`
91
+ : "";
92
+ const interfaceContent = `// Generated on ${new Date().toISOString()}\n${importStatement}\n\nexport interface QuickbaseClient {\n${methods.join(
93
+ "\n"
94
+ )}\n}\n`;
95
+
96
+ console.log("Ensuring output directory exists and writing interface...");
97
+ writeFileSafe(OUTPUT_FILE, interfaceContent);
98
+ console.log("Generated:", OUTPUT_FILE);
99
+ }
100
+
101
+ console.log("Entering runTask block");
102
+ runTask("generateInterface", () => generateInterface(true));
103
+
104
+ console.log("Script completed");
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { writeFileSync, existsSync, mkdirSync } from "fs";
4
+ import { join, dirname } from "path";
5
+ import { fileURLToPath } from "url";
6
+ import { parseOpenApiOperations } from "./utils/sharedUtils.ts";
7
+ import { writeFileSafe, runTask } from "./utils/common.ts";
8
+
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const SPEC_FILE = join(__dirname, "output", "quickbase-fixed.json");
11
+ const MODELS_DIR = join(__dirname, "..", "src", "generated", "models");
12
+ const DOCS_DATA_DIR = join(__dirname, "..", "docs-data");
13
+ const DOCS_JSON_FILE = join(DOCS_DATA_DIR, "api-docs.json");
14
+
15
+ function generateDocsJson(): void {
16
+ console.log("Generating docs JSON...");
17
+ const { operations } = parseOpenApiOperations(SPEC_FILE, MODELS_DIR);
18
+ writeFileSafe(DOCS_JSON_FILE, JSON.stringify(operations, null, 2), "utf8");
19
+ console.log("Generated docs JSON:", DOCS_JSON_FILE);
20
+ }
21
+
22
+ runTask("generateDocsJson", generateDocsJson);
23
+
24
+ console.log("Script completed");