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,307 +0,0 @@
1
- import { describe, it, expect, beforeEach, vi } from "vitest";
2
- import {
3
- createClient,
4
- mockFetch,
5
- QB_REALM,
6
- QB_USER_TOKEN,
7
- QB_TABLE_ID_1,
8
- } from "@tests/setup.ts";
9
- import {
10
- UpdateRelationshipRequest,
11
- UpdateRelationship200Response,
12
- } from "@/generated/models";
13
-
14
- describe("QuickbaseClient Unit - updateRelationship", () => {
15
- let client: ReturnType<typeof createClient>;
16
-
17
- beforeEach(() => {
18
- mockFetch.mockClear();
19
- });
20
-
21
- it("initializes without errors and has updateRelationship method", () => {
22
- client = createClient(mockFetch, { debug: true });
23
- expect(client).toBeDefined();
24
- expect(typeof client.updateRelationship).toBe("function");
25
- });
26
-
27
- it("updates relationship successfully with user token", async () => {
28
- client = createClient(mockFetch, { debug: true });
29
-
30
- const tableId = QB_TABLE_ID_1;
31
- const relationshipId = 6;
32
-
33
- const request: UpdateRelationshipRequest = {
34
- lookupFieldIds: [4, 5, 6],
35
- summaryFields: [
36
- {
37
- summaryFid: 3,
38
- label: "my summary field",
39
- accumulationType: "COUNT",
40
- where: "{'3'.EX.'1'}",
41
- },
42
- ],
43
- };
44
-
45
- const mockResponse: UpdateRelationship200Response = {
46
- id: relationshipId,
47
- parentTableId: "bck7gp3q2",
48
- childTableId: tableId,
49
- foreignKeyField: {
50
- id: relationshipId,
51
- label: "Related record",
52
- type: "numeric",
53
- },
54
- isCrossApp: false,
55
- lookupFields: [
56
- { id: 4, label: "Field 4", type: "text" },
57
- { id: 5, label: "Field 5", type: "numeric" },
58
- { id: 6, label: "Field 6", type: "date" },
59
- ],
60
- summaryFields: [{ id: 8, label: "my summary field", type: "numeric" }],
61
- };
62
-
63
- mockFetch.mockResolvedValueOnce({
64
- ok: true,
65
- status: 200,
66
- json: () => Promise.resolve(mockResponse),
67
- });
68
-
69
- const result = await client.updateRelationship({
70
- tableId,
71
- relationshipId,
72
- body: request,
73
- });
74
-
75
- expect(result).toEqual(mockResponse);
76
- expect(mockFetch).toHaveBeenCalledWith(
77
- `https://api.quickbase.com/v1/tables/${tableId}/relationship/${relationshipId}`,
78
- expect.objectContaining({
79
- method: "POST",
80
- headers: expect.objectContaining({
81
- "QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
82
- Authorization: `QB-USER-TOKEN ${QB_USER_TOKEN}`,
83
- "Content-Type": "application/json",
84
- }),
85
- body: JSON.stringify(request),
86
- credentials: "omit",
87
- })
88
- );
89
- });
90
-
91
- it("updates relationship successfully with temp token", async () => {
92
- client = createClient(mockFetch, { useTempTokens: true, debug: true });
93
-
94
- const tableId = QB_TABLE_ID_1;
95
- const relationshipId = 6;
96
-
97
- const request: UpdateRelationshipRequest = {
98
- lookupFieldIds: [7],
99
- summaryFields: [
100
- {
101
- summaryFid: 0,
102
- label: "Count of Records",
103
- accumulationType: "COUNT",
104
- where: "{'3'.GT.0}",
105
- },
106
- ],
107
- };
108
-
109
- const mockResponse: UpdateRelationship200Response = {
110
- id: relationshipId,
111
- parentTableId: "bck7gp3q2",
112
- childTableId: tableId,
113
- foreignKeyField: {
114
- id: relationshipId,
115
- label: "Related record",
116
- type: "numeric",
117
- },
118
- isCrossApp: false,
119
- lookupFields: [{ id: 7, label: "record - text field", type: "text" }],
120
- summaryFields: [{ id: 9, label: "Count of Records", type: "numeric" }],
121
- };
122
-
123
- mockFetch
124
- .mockResolvedValueOnce({
125
- ok: true,
126
- status: 200,
127
- json: () => Promise.resolve({ temporaryAuthorization: "temp_token" }),
128
- })
129
- .mockResolvedValueOnce({
130
- ok: true,
131
- status: 200,
132
- json: () => Promise.resolve(mockResponse),
133
- });
134
-
135
- const result = await client.updateRelationship({
136
- tableId,
137
- relationshipId,
138
- body: request,
139
- });
140
-
141
- expect(result).toEqual(mockResponse);
142
- expect(mockFetch).toHaveBeenCalledTimes(2);
143
- expect(mockFetch).toHaveBeenNthCalledWith(
144
- 1,
145
- `https://api.quickbase.com/v1/auth/temporary/${tableId}`,
146
- expect.objectContaining({
147
- method: "GET",
148
- headers: expect.objectContaining({
149
- "QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
150
- "Content-Type": "application/json",
151
- }),
152
- credentials: "include",
153
- })
154
- );
155
- expect(mockFetch).toHaveBeenNthCalledWith(
156
- 2,
157
- `https://api.quickbase.com/v1/tables/${tableId}/relationship/${relationshipId}`,
158
- expect.objectContaining({
159
- method: "POST",
160
- headers: expect.objectContaining({
161
- "QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
162
- Authorization: "QB-TEMP-TOKEN temp_token",
163
- "Content-Type": "application/json",
164
- }),
165
- body: JSON.stringify(request),
166
- credentials: "omit",
167
- })
168
- );
169
- });
170
-
171
- it("retries successfully after 401 with temp token", async () => {
172
- client = createClient(mockFetch, { useTempTokens: true, debug: true });
173
-
174
- const tableId = QB_TABLE_ID_1;
175
- const relationshipId = 6;
176
-
177
- const request: UpdateRelationshipRequest = {
178
- lookupFieldIds: [4],
179
- };
180
-
181
- const mockResponse: UpdateRelationship200Response = {
182
- id: relationshipId,
183
- parentTableId: "bck7gp3q2",
184
- childTableId: tableId,
185
- foreignKeyField: {
186
- id: relationshipId,
187
- label: "Related record",
188
- type: "numeric",
189
- },
190
- isCrossApp: false,
191
- lookupFields: [{ id: 4, label: "Field 4", type: "text" }],
192
- summaryFields: [],
193
- };
194
-
195
- mockFetch
196
- .mockResolvedValueOnce({
197
- ok: true,
198
- status: 200,
199
- json: () =>
200
- Promise.resolve({ temporaryAuthorization: "initial_token" }),
201
- })
202
- .mockResolvedValueOnce({
203
- ok: false,
204
- status: 401,
205
- json: () => Promise.resolve({ message: "Unauthorized" }),
206
- })
207
- .mockResolvedValueOnce({
208
- ok: true,
209
- status: 200,
210
- json: () => Promise.resolve({ temporaryAuthorization: "new_token" }),
211
- })
212
- .mockResolvedValueOnce({
213
- ok: true,
214
- status: 200,
215
- json: () => Promise.resolve(mockResponse),
216
- });
217
-
218
- const consoleSpy = vi.spyOn(console, "log");
219
- const result = await client.updateRelationship({
220
- tableId,
221
- relationshipId,
222
- body: request,
223
- });
224
-
225
- expect(result).toEqual(mockResponse);
226
- expect(mockFetch).toHaveBeenCalledTimes(4);
227
- expect(mockFetch).toHaveBeenNthCalledWith(
228
- 1,
229
- `https://api.quickbase.com/v1/auth/temporary/${tableId}`,
230
- expect.any(Object)
231
- );
232
- expect(mockFetch).toHaveBeenNthCalledWith(
233
- 2,
234
- `https://api.quickbase.com/v1/tables/${tableId}/relationship/${relationshipId}`,
235
- expect.objectContaining({
236
- headers: expect.objectContaining({
237
- Authorization: "QB-TEMP-TOKEN initial_token",
238
- }),
239
- })
240
- );
241
- expect(mockFetch).toHaveBeenNthCalledWith(
242
- 3,
243
- `https://api.quickbase.com/v1/auth/temporary/${tableId}`,
244
- expect.any(Object)
245
- );
246
- expect(mockFetch).toHaveBeenNthCalledWith(
247
- 4,
248
- `https://api.quickbase.com/v1/tables/${tableId}/relationship/${relationshipId}`,
249
- expect.objectContaining({
250
- headers: expect.objectContaining({
251
- Authorization: "QB-TEMP-TOKEN new_token",
252
- }),
253
- })
254
- );
255
-
256
- // Updated log expectations
257
- expect(consoleSpy).toHaveBeenCalledWith(
258
- "Authorization error for updateRelationship (temp token), refreshing token:"
259
- );
260
- expect(consoleSpy).toHaveBeenCalledWith(
261
- expect.stringContaining(
262
- "[updateRelationship] Retrying with token: new_tok"
263
- )
264
- );
265
-
266
- consoleSpy.mockRestore();
267
- });
268
-
269
- it("handles 400 error for invalid request", async () => {
270
- client = createClient(mockFetch, { debug: true });
271
-
272
- const tableId = QB_TABLE_ID_1;
273
- const relationshipId = 6;
274
-
275
- const request: UpdateRelationshipRequest = {
276
- lookupFieldIds: [-1],
277
- };
278
-
279
- mockFetch.mockResolvedValueOnce({
280
- ok: false,
281
- status: 400,
282
- json: () => Promise.resolve({ message: "Invalid field ID" }),
283
- });
284
-
285
- await expect(
286
- client.updateRelationship({
287
- tableId,
288
- relationshipId,
289
- body: request,
290
- })
291
- ).rejects.toThrow("API Error: Invalid field ID (Status: 400)");
292
-
293
- expect(mockFetch).toHaveBeenCalledWith(
294
- `https://api.quickbase.com/v1/tables/${tableId}/relationship/${relationshipId}`,
295
- expect.objectContaining({
296
- method: "POST",
297
- headers: expect.objectContaining({
298
- "QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
299
- Authorization: `QB-USER-TOKEN ${QB_USER_TOKEN}`,
300
- "Content-Type": "application/json",
301
- }),
302
- body: JSON.stringify(request),
303
- credentials: "omit",
304
- })
305
- );
306
- });
307
- });
@@ -1,80 +0,0 @@
1
- // tests/vitest/unit/records/updateTable.test.ts
2
- import { describe, it, expect, beforeEach } from "vitest";
3
- import {
4
- createClient,
5
- mockFetch,
6
- QB_APP_ID,
7
- QB_TABLE_ID_1,
8
- } from "@tests/setup.ts";
9
-
10
- describe("QuickbaseClient Unit - updateTable", () => {
11
- let client: ReturnType<typeof createClient>;
12
-
13
- beforeEach(() => {
14
- mockFetch.mockClear();
15
- client = createClient(mockFetch, { debug: true });
16
- });
17
-
18
- it("calls updateTable successfully with temp token", async () => {
19
- client = createClient(mockFetch, { debug: true, useTempTokens: true });
20
-
21
- const mockBody = {
22
- name: "Updated Root",
23
- description: "Updated description",
24
- };
25
- const mockResponse = {
26
- id: QB_TABLE_ID_1,
27
- name: "Updated Root",
28
- alias: "_DBID_ROOT",
29
- description: "Updated description",
30
- created: new Date("2025-02-13T18:22:33.000Z"),
31
- updated: new Date("2025-03-10T12:00:00.000Z"),
32
- nextRecordId: 1,
33
- nextFieldId: 6,
34
- defaultSortFieldId: 2,
35
- defaultSortOrder: "DESC",
36
- keyFieldId: 3,
37
- singleRecordName: "Root",
38
- pluralRecordName: "Roots",
39
- sizeLimit: "500 MB",
40
- spaceUsed: "0 KB",
41
- spaceRemaining: "500 MB",
42
- };
43
-
44
- mockFetch
45
- .mockResolvedValueOnce({
46
- ok: true,
47
- status: 200,
48
- json: () => Promise.resolve({ temporaryAuthorization: "temp_token" }),
49
- })
50
- .mockResolvedValueOnce({
51
- ok: true,
52
- status: 200,
53
- json: () => Promise.resolve(mockResponse),
54
- });
55
-
56
- const response = await client.updateTable({
57
- tableId: QB_TABLE_ID_1,
58
- appId: QB_APP_ID,
59
- body: mockBody,
60
- });
61
- expect(response).toEqual(mockResponse);
62
- expect(mockFetch).toHaveBeenCalledTimes(2);
63
- expect(mockFetch).toHaveBeenCalledWith(
64
- `https://api.quickbase.com/v1/auth/temporary/${QB_TABLE_ID_1}`,
65
- expect.any(Object)
66
- );
67
- expect(mockFetch).toHaveBeenCalledWith(
68
- `https://api.quickbase.com/v1/tables/${QB_TABLE_ID_1}?appId=${QB_APP_ID}`,
69
- expect.objectContaining({
70
- method: "POST",
71
- headers: expect.objectContaining({
72
- "QB-Realm-Hostname": `${process.env.QB_REALM}.quickbase.com`,
73
- Authorization: "QB-TEMP-TOKEN temp_token",
74
- "Content-Type": "application/json",
75
- }),
76
- body: JSON.stringify(mockBody),
77
- })
78
- );
79
- });
80
- });
package/tools/log-gen.ts DELETED
@@ -1,251 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from "fs";
3
- import path from "path";
4
- import { fileURLToPath } from "url";
5
- import yaml from "js-yaml";
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
-
10
- const rootDir: string = "./";
11
- const excludeDirs: string[] = [
12
- "node_modules",
13
- ".git",
14
- "specs",
15
- "open-api/output",
16
- ];
17
-
18
- // prettier-ignore
19
- const includeFolders: string[] = [
20
- // "open-api/utils",
21
- // "open-api/schema",
22
- // "open-api"
23
- ];
24
-
25
- // prettier-ignore
26
- const includeRecursiveFolders: string[] = [
27
- // "open-api/schema/tags",
28
- // "open-api",
29
- // "tools"
30
- // "tests",
31
- // "tests/vitest/unit",
32
- // "tests/vitest/qb"
33
- ];
34
-
35
- // prettier-ignore
36
- const includeFiles: string[] = [
37
- // "package.json",
38
- // "tests/setup.ts",
39
- // "vitest.config.ts",
40
-
41
- // "open-api/generate-unified-interface.ts",
42
- // "open-api/utils/generateDocsJson.ts",
43
-
44
- // "tsconfig.json",
45
- // "tsconfig.build.json",
46
- // "rollup.config.js",
47
- // "build-common.js",
48
- // "build-umd.js",
49
- // "build-esm.js",
50
-
51
- "src/quickbaseClient.ts",
52
- "src/invokeMethod.ts",
53
- "src/generated-unified/QuickbaseClient.ts",
54
- "src/authorizationStrategy.ts",
55
- "src/rateLimiter.ts",
56
- "src/RateLimitError.ts",
57
- "src/ThrottleBucket.ts",
58
- "src/tokenCache.ts",
59
- "src/utils.ts",
60
- // "src/generated/models/GetFieldsUsage200Response.ts",
61
- // "src/generated/models/GetFieldsUsage200ResponseItemsInner.ts",
62
- // "src/generated/runtime.ts",
63
- // "src/generated/apis/AuthApi.ts",
64
- // "src/generated/apis/FieldsApi.ts",
65
- // "src/generated/apis/AppsApi.ts",
66
-
67
- ];
68
-
69
- const projectGoals: string[] = [
70
- "A library for interacting with the QuickBase RESTful API.",
71
- "Use OpenAPI to generate types and methods using a proxy. Validate with tests.",
72
- "Provide robust and intuitive temporary token support for browser environments.",
73
- "User Tokens support both Node.js and browser environments.",
74
- "Use case: JS frameworks like React, Vue, and Angular hosted in QuickBase code pages.",
75
- "Enable a flexible or native fetch in the browser.",
76
- "Enable a flexible fetch framework in Node.js.",
77
- "#",
78
- "No manual updating methods when the QuickBase API changes.",
79
- "The proxy magic dynamically maps generated methods and types.",
80
- "#",
81
- "TokenCache is defined per quickbaseClient call, so each instance has its own isolated TokenCache.",
82
- "Each quickbase client instance has an isolated and individual token cache.",
83
- ];
84
-
85
- const pipelineOverview: string[] = [
86
- "What I’m Trying to Do",
87
- "My approach is to ensure AppsApi.ts is generated with getAppById so QuickbaseClient.ts can map it to client.getApp. Steps include:",
88
- "Fix fix-spec.ts:",
89
- 'Add tags: ["Apps"] to /apps/* endpoints to group them into AppsApi.ts.',
90
- "Ensure all endpoints and models are correctly defined and typed.",
91
- "Debug regenerate-client.ts:",
92
- "Enhance logging to catch why AppsApi.ts isn’t generated.",
93
- "Test if getAppById appears in another file (e.g., DefaultApi.ts).",
94
- "Update QuickbaseClient.ts:",
95
- "Adjust imports to use the correct API class once generated.",
96
- "Test and Iterate:",
97
- "Run npm run fix-spec, npm run regenerate, and npm run test to verify AppsApi.ts exists and test.ts works.",
98
- "The latest fix-spec.ts with tags aims to force the generator to create AppsApi.ts, addressing the missing file issue.",
99
- "Relevant Project Files",
100
- "Here’s a list of files that would help understand and resolve this problem, along with their roles:",
101
- "src/code-generation/fix-spec.ts:",
102
- "Role: Modifies the original QuickBase spec (e.g., QuickBase_RESTful_*.json) to create quickbase-fixed.json with required endpoints (e.g., /apps/{appId}).",
103
- "Relevance: Defines the spec fed to the generator; errors here affect generation.",
104
- "src/code-generation/quickbase-fixed.json:",
105
- "Role: The processed OpenAPI spec used by regenerate-client.ts to generate code.",
106
- 'Relevance: Confirms if /apps/{appId} is correctly structured with operationId: "getAppById".',
107
- "src/code-generation/regenerate-client.ts:",
108
- "Role: Runs OpenAPI Generator to produce src/generated/ files (APIs and models) and fixes .ts extensions with ts-morph.",
109
- "Relevance: Controls the generation process; logs reveal why AppsApi.ts is missing.",
110
- "src/generated/apis/AppsApi.ts (if exists):",
111
- "Role: Should contain getAppById method for /apps/{appId} GET.",
112
- "Relevance: Missing file is the core issue; its absence breaks QuickbaseClient.ts.",
113
- "src/generated/apis/DefaultApi.ts:",
114
- "Role: Default API class for untagged operations.",
115
- "Relevance: Might contain getAppById if tags are misconfigured.",
116
- "src/QuickbaseClient.ts:",
117
- "Role: Wraps generated API classes (e.g., AppsApi) in a Proxy for ergonomic calls (e.g., client.getApp).",
118
- "Relevance: Fails to import AppsApi.ts, causing the runtime error.",
119
- "src/test.ts:",
120
- "Role: Test script calling client.getApp({ appId }).",
121
- "Relevance: Final validation point; shows if the fix works.",
122
- ".env.development:",
123
- "Role: Stores QB_REALM, QB_USER_TOKEN, QB_APP_ID for API authentication.",
124
- "Relevance: Ensures the API call has valid credentials (not the current issue, but critical for success).",
125
- "src/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json (or similar):",
126
- "Role: Original QuickBase API spec before fix-spec.ts processing.",
127
- "Relevance: Shows how /apps/{appId} was originally defined, helping identify conflicts.",
128
- "package.json:",
129
- "Role: Defines scripts (fix-spec, regenerate, test) and dependencies (e.g., ts-node, openapi-generator-cli).",
130
- "Relevance: Confirms script commands and versions align with our process.",
131
- "What We Achieved",
132
- "Goal Met: You can now call client.getApp({ appId: \"buwai2zpe\" }) and get the app details { id: 'buwai2zpe', name: 'qb-copy' }.",
133
- "Fixes Applied:",
134
- 'Added tags: ["Apps"] in fix-spec.ts to ensure AppsApi.ts is generated with getAppById.',
135
- "Updated QuickbaseClient.ts to:",
136
- "Use prototype methods via Object.getOwnPropertyNames.",
137
- "Bind methods to preserve context with .bind(api).",
138
- "Handle getAppById’s direct JSON return instead of a Response object.",
139
- "Result: The ergonomic API you wanted (client.getApp) works seamlessly with the generated AppsApi.ts.",
140
- "Why It Works Now",
141
- "fix-spec.ts:",
142
- 'Correctly defined /apps/{appId} with operationId: "getAppById" and tags: ["Apps"], ensuring AppsApi.ts generation.',
143
- "regenerate-client.ts:",
144
- "Successfully ran OpenAPI Generator to produce AppsApi.ts with getAppById.",
145
- "QuickbaseClient.ts:",
146
- "buildMethodMap now captures getAppById and maps it to getApp.",
147
- "invokeMethod passes { appId: 'buwai2zpe' } as requestParameters and handles the JSON response directly.",
148
- "test.ts:",
149
- "Calls client.getApp and logs the result, proving the end-to-end flow.",
150
- ];
151
-
152
- interface TreeNode {
153
- name: string;
154
- type: "directory" | "file";
155
- contents?: string;
156
- children?: TreeNode[];
157
- }
158
-
159
- function buildTree(dir: string): TreeNode {
160
- const node: TreeNode = {
161
- name: path.basename(dir) || "",
162
- type: "directory",
163
- children: [],
164
- };
165
-
166
- const files: fs.Dirent[] = fs.readdirSync(dir, { withFileTypes: true });
167
-
168
- files.forEach((file: fs.Dirent) => {
169
- const filePath: string = path.join(dir, file.name);
170
- const relativePath: string = path
171
- .relative(rootDir, filePath)
172
- .replace(/\\/g, "/");
173
-
174
- if (file.isDirectory() && excludeDirs.includes(relativePath)) return;
175
-
176
- const childNode: TreeNode = {
177
- name: file.name,
178
- type: file.isDirectory() ? "directory" : "file",
179
- };
180
-
181
- if (file.isDirectory()) {
182
- childNode.children = buildTree(filePath).children;
183
- } else {
184
- const isInIncludeFolder = includeFolders.some((folder) => {
185
- const folderPath = folder.endsWith("/") ? folder : folder + "/";
186
- return (
187
- relativePath.startsWith(folderPath) &&
188
- relativePath.split("/").length === folderPath.split("/").length
189
- );
190
- });
191
-
192
- const isInIncludeRecursiveFolder = includeRecursiveFolders.some(
193
- (folder) =>
194
- relativePath.startsWith(folder + "/") || relativePath === folder
195
- );
196
-
197
- const shouldInclude =
198
- includeFiles.includes(relativePath) ||
199
- isInIncludeFolder ||
200
- isInIncludeRecursiveFolder;
201
-
202
- if (shouldInclude) {
203
- // Check if the file is in open-api/output
204
- const isInOutputDir = relativePath.startsWith("open-api/output/");
205
-
206
- if (!isInOutputDir) {
207
- // Only read contents if not in output directory
208
- try {
209
- childNode.contents = fs.readFileSync(filePath, "utf8");
210
- } catch (err: unknown) {
211
- childNode.contents = `[Error reading file: ${
212
- (err as Error).message
213
- }]`;
214
- }
215
- } else {
216
- // For files in output directory, just mark their existence
217
- childNode.contents = "[File contents excluded - output directory]";
218
- }
219
- }
220
- }
221
-
222
- node.children!.push(childNode);
223
- });
224
-
225
- return node;
226
- }
227
-
228
- function generateTreeSnapshot(): string {
229
- const snapshot = {
230
- project: "quickbase-js",
231
- date: new Date().toLocaleDateString(),
232
- root: path.resolve(rootDir),
233
- goals: projectGoals,
234
- pipelineOverview: pipelineOverview,
235
- tree: buildTree(rootDir),
236
- };
237
-
238
- return yaml.dump(snapshot, { lineWidth: -2 });
239
- }
240
-
241
- try {
242
- const output: string = generateTreeSnapshot();
243
- const outputPath: string = path.join(__dirname, "log-gen.yaml");
244
- fs.writeFileSync(outputPath, output, "utf8");
245
- const lineCount: number = output.split("\n").length - 0;
246
- console.log("log-gen.yaml");
247
- console.log(`Lines: ${lineCount}`);
248
- } catch (error: unknown) {
249
- console.error("Failed to generate tree snapshot:", (error as Error).message);
250
- process.exit(0);
251
- }