quickbase-js 0.1.0-beta.7 → 0.1.0-beta.9
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.
- package/CHANGELOG.md +55 -0
- package/README.md +46 -130
- package/dist/esm/quickbase.d.ts +1292 -125
- package/dist/esm/quickbase.js +666 -190
- package/dist/esm/quickbase.js.map +1 -1
- package/dist/esm/quickbase.min.js +1 -1
- package/dist/esm/quickbase.min.js.map +1 -1
- package/dist/umd/quickbase.umd.js +674 -189
- package/dist/umd/quickbase.umd.js.map +1 -1
- package/dist/umd/quickbase.umd.min.js +1 -1
- package/dist/umd/quickbase.umd.min.js.map +1 -1
- package/open-api/fix-spec-main.ts +69 -68
- package/open-api/generate-override-report.ts +214 -0
- package/open-api/generate-unified-interface.ts +162 -103
- package/open-api/output/override-report.html +11 -0
- package/open-api/output/override-report.json +14395 -58
- package/open-api/output/quickbase-fixed.json +583 -2
- package/open-api/schema/tags/fields.ts +331 -16
- package/open-api/schema/tags/index.ts +2 -4
- package/open-api/types/spec.ts +2 -1
- package/open-api/utils/generateJsDoc.ts +96 -0
- package/package.json +33 -33
- package/src/RateLimitError.ts +12 -0
- package/src/ThrottleBucket.ts +41 -0
- package/src/authorizationStrategy.ts +246 -0
- package/src/generated-unified/QuickbaseClient.ts +809 -119
- package/src/invokeMethod.ts +242 -0
- package/src/quickbaseClient.ts +117 -248
- package/src/rateLimiter.ts +25 -0
- package/src/tokenCache.ts +10 -26
- package/tests/setup.ts +2 -0
- package/tests/vitest/qb/apps/getApp.test.ts +6 -2
- package/tests/vitest/qb/apps/getAppEvents.test.ts +67 -0
- package/tests/vitest/qb/apps/updateApp.test.ts +58 -0
- package/tests/vitest/qb/auth/mockQuickbaseServer.ts +60 -0
- package/tests/vitest/qb/auth/retryUserToken401.test.ts +73 -0
- package/tests/vitest/qb/auth/ssoTokenIntegrationWithServer.test.ts +65 -0
- package/tests/vitest/qb/fields/createField.test.ts +1 -2
- package/tests/vitest/qb/fields/deleteFields.test.ts +10 -16
- package/tests/vitest/qb/fields/getFieldUsage.test.ts +58 -150
- package/tests/vitest/qb/fields/updateField.test.ts +93 -0
- package/tests/vitest/qb/formulas/runFormula.test.ts +96 -0
- package/tests/vitest/qb/index.ts +1 -0
- package/tests/vitest/qb/tables/createRelationship.test.ts +102 -0
- package/tests/vitest/qb/tables/deleteRelationship.test.ts +143 -0
- package/tests/vitest/qb/tables/updateRelationship.test.ts +250 -0
- package/tests/vitest/unit/ThrottleBucket.test.ts +95 -0
- package/tests/vitest/unit/apps/copyApp.test.ts +133 -40
- package/tests/vitest/unit/apps/getAppEvents.test.ts +193 -0
- package/tests/vitest/unit/apps/updateApp.test.ts +412 -0
- package/tests/vitest/unit/auth/fetchTempToken401.test.ts +7 -26
- package/tests/vitest/unit/auth/getTempToken.test.ts +42 -18
- package/tests/vitest/unit/auth/retryTempToken401.test.ts +95 -0
- package/tests/vitest/unit/auth/retryTempTokenMaxRetries.test.ts +235 -0
- package/tests/vitest/unit/auth/retryUserToken401.test.ts +69 -0
- package/tests/vitest/unit/auth/ssoTokenRefresh.test.ts +325 -0
- package/tests/vitest/unit/fields/createField.test.ts +180 -120
- package/tests/vitest/unit/fields/getFieldUsage.test.ts +47 -14
- package/tests/vitest/unit/fields/updateField.test.ts +285 -0
- package/tests/vitest/unit/formulas/runFormula.test.ts +205 -0
- package/tests/vitest/unit/index.ts +2 -1
- package/tests/vitest/unit/inferHttpMethod.test.ts +131 -0
- package/tests/vitest/unit/rateLimit.test.ts +191 -0
- package/tests/vitest/unit/tables/createRelationship.test.ts +212 -0
- package/tests/vitest/unit/tables/deleteRelationship.test.ts +97 -0
- package/tests/vitest/unit/tables/updateRelationship.test.ts +307 -0
- package/tests/vitest/unit/tokenLifespan.test.ts +204 -0
- package/tools/log-gen.ts +20 -7
- package/tools/log-gen.yaml +3446 -1848
- package/tsconfig.json +5 -2
- package/vitest.config.ts +2 -2
- package/notes.txt +0 -158
- package/tests/vitest/unit/auth/retryOn401.test.ts +0 -116
- package/tests/vitest/unit/auth/two401s.test.ts +0 -86
- package/tools/generate-types.ts +0 -29
- package/tools/openapi-schema-validator.ts +0 -38
- package/tools/spec-analyzer.ts +0 -163
- package/tools/split-spec.ts +0 -148
- package/tools/test-import.ts +0 -3
- package/tools/validate-spec.ts +0 -40
- /package/tests/playwright/qb/auth/{tokenPrefetch.test.ts → tempTokenPrefetch.test.ts} +0 -0
- /package/tests/playwright/qb/auth/{tokenRenewal.test.ts → tempTokenRenewal.test.ts} +0 -0
|
@@ -28,11 +28,16 @@ export function enhanceFields(
|
|
|
28
28
|
`Defining schema for ${requestName} in ${pathKey}(${method})`
|
|
29
29
|
);
|
|
30
30
|
let properties;
|
|
31
|
+
let requiredFields: string[];
|
|
32
|
+
|
|
31
33
|
if (method === "delete") {
|
|
34
|
+
// DELETE /fields (deleteFields)
|
|
32
35
|
properties = {
|
|
33
36
|
fieldIds: { type: "array", items: { type: "integer" } },
|
|
34
37
|
};
|
|
38
|
+
requiredFields = ["fieldIds"];
|
|
35
39
|
} else {
|
|
40
|
+
// Common properties for createField and updateField
|
|
36
41
|
properties = {
|
|
37
42
|
label: { type: "string", description: "The label of the field" },
|
|
38
43
|
fieldType: {
|
|
@@ -122,27 +127,337 @@ export function enhanceFields(
|
|
|
122
127
|
description: "Whether changes to the field are audited",
|
|
123
128
|
nullable: true,
|
|
124
129
|
},
|
|
130
|
+
properties: {
|
|
131
|
+
type: "object",
|
|
132
|
+
description: "Specific field properties",
|
|
133
|
+
properties: {
|
|
134
|
+
numLines: {
|
|
135
|
+
type: "integer",
|
|
136
|
+
description:
|
|
137
|
+
"The number of lines shown in QuickBase for this text field",
|
|
138
|
+
},
|
|
139
|
+
maxLength: {
|
|
140
|
+
type: "integer",
|
|
141
|
+
description:
|
|
142
|
+
"The maximum number of characters allowed for entry",
|
|
143
|
+
},
|
|
144
|
+
appendOnly: {
|
|
145
|
+
type: "boolean",
|
|
146
|
+
description: "Whether this field is append-only",
|
|
147
|
+
},
|
|
148
|
+
sortAsGiven: {
|
|
149
|
+
type: "boolean",
|
|
150
|
+
description:
|
|
151
|
+
"Indicates if the listed entries sort as entered vs alphabetically",
|
|
152
|
+
},
|
|
153
|
+
allowMentions: {
|
|
154
|
+
type: "boolean",
|
|
155
|
+
description:
|
|
156
|
+
"If someone can @mention users in the rich text field",
|
|
157
|
+
},
|
|
158
|
+
comments: {
|
|
159
|
+
type: "string",
|
|
160
|
+
description:
|
|
161
|
+
"The comments entered on the field properties by an administrator",
|
|
162
|
+
},
|
|
163
|
+
doesTotal: {
|
|
164
|
+
type: "boolean",
|
|
165
|
+
description:
|
|
166
|
+
"Whether this field totals in reports within the product",
|
|
167
|
+
},
|
|
168
|
+
autoSave: {
|
|
169
|
+
type: "boolean",
|
|
170
|
+
description: "Whether the link field will auto save",
|
|
171
|
+
},
|
|
172
|
+
defaultValueLuid: {
|
|
173
|
+
type: "integer",
|
|
174
|
+
description: "Default user id value",
|
|
175
|
+
},
|
|
176
|
+
useI18NFormat: {
|
|
177
|
+
type: "boolean",
|
|
178
|
+
description:
|
|
179
|
+
"Whether phone numbers should be in E.164 standard international format",
|
|
180
|
+
},
|
|
181
|
+
maxVersions: {
|
|
182
|
+
type: "integer",
|
|
183
|
+
description:
|
|
184
|
+
"The maximum number of versions configured for a file attachment",
|
|
185
|
+
},
|
|
186
|
+
format: {
|
|
187
|
+
type: "integer",
|
|
188
|
+
description: "The format to display time",
|
|
189
|
+
},
|
|
190
|
+
carryChoices: {
|
|
191
|
+
type: "boolean",
|
|
192
|
+
description:
|
|
193
|
+
"Whether the field should carry its multiple choice fields when copied",
|
|
194
|
+
},
|
|
195
|
+
linkText: {
|
|
196
|
+
type: "string",
|
|
197
|
+
description:
|
|
198
|
+
"The configured text value that replaces the URL users see",
|
|
199
|
+
},
|
|
200
|
+
parentFieldId: {
|
|
201
|
+
type: "integer",
|
|
202
|
+
description:
|
|
203
|
+
"The id of the parent composite field, when applicable",
|
|
204
|
+
},
|
|
205
|
+
displayTimezone: {
|
|
206
|
+
type: "boolean",
|
|
207
|
+
description:
|
|
208
|
+
"Indicates whether to display the timezone within the product",
|
|
209
|
+
},
|
|
210
|
+
summaryTargetFieldId: {
|
|
211
|
+
type: "integer",
|
|
212
|
+
description:
|
|
213
|
+
"The id of the field used to aggregate values from the child",
|
|
214
|
+
},
|
|
215
|
+
allowNewChoices: {
|
|
216
|
+
type: "boolean",
|
|
217
|
+
description:
|
|
218
|
+
"Indicates if users can add new choices to a selection list",
|
|
219
|
+
},
|
|
220
|
+
defaultToday: {
|
|
221
|
+
type: "boolean",
|
|
222
|
+
description:
|
|
223
|
+
"Indicates if the field value is defaulted today for new records",
|
|
224
|
+
},
|
|
225
|
+
units: {
|
|
226
|
+
type: "string",
|
|
227
|
+
description: "The units label",
|
|
228
|
+
},
|
|
229
|
+
openTargetIn: {
|
|
230
|
+
type: "string",
|
|
231
|
+
enum: ["sameWindow", "newWindow", "popup"],
|
|
232
|
+
description:
|
|
233
|
+
"Indicates which target the URL should open in when clicked",
|
|
234
|
+
},
|
|
235
|
+
lookupTargetFieldId: {
|
|
236
|
+
type: "integer",
|
|
237
|
+
description:
|
|
238
|
+
"The id of the field that is the target on the parent table for this lookup",
|
|
239
|
+
},
|
|
240
|
+
summaryFunction: {
|
|
241
|
+
type: "string",
|
|
242
|
+
enum: [
|
|
243
|
+
"AVG",
|
|
244
|
+
"SUM",
|
|
245
|
+
"MAX",
|
|
246
|
+
"MIN",
|
|
247
|
+
"STD-DEV",
|
|
248
|
+
"COUNT",
|
|
249
|
+
"COMBINED-TEXT",
|
|
250
|
+
"COMBINED-USER",
|
|
251
|
+
"DISTINCT-COUNT",
|
|
252
|
+
],
|
|
253
|
+
description: "The accumulation type for the summary field",
|
|
254
|
+
},
|
|
255
|
+
sourceFieldId: {
|
|
256
|
+
type: "integer",
|
|
257
|
+
description: "The id of the source field",
|
|
258
|
+
},
|
|
259
|
+
doesAverage: {
|
|
260
|
+
type: "boolean",
|
|
261
|
+
description:
|
|
262
|
+
"Whether this field averages in reports within the product",
|
|
263
|
+
},
|
|
264
|
+
formula: {
|
|
265
|
+
type: "string",
|
|
266
|
+
description:
|
|
267
|
+
"The formula of the field as configured in QuickBase",
|
|
268
|
+
},
|
|
269
|
+
decimalPlaces: {
|
|
270
|
+
type: "integer",
|
|
271
|
+
description:
|
|
272
|
+
"The number of decimal places displayed in the product",
|
|
273
|
+
},
|
|
274
|
+
defaultCountryCode: {
|
|
275
|
+
type: "string",
|
|
276
|
+
description:
|
|
277
|
+
"Controls the default country shown on international phone widgets",
|
|
278
|
+
},
|
|
279
|
+
displayMonth: {
|
|
280
|
+
type: "string",
|
|
281
|
+
description: "How to display months",
|
|
282
|
+
},
|
|
283
|
+
seeVersions: {
|
|
284
|
+
type: "boolean",
|
|
285
|
+
description:
|
|
286
|
+
"Indicates if users can see other versions of a file attachment",
|
|
287
|
+
},
|
|
288
|
+
defaultKind: {
|
|
289
|
+
type: "string",
|
|
290
|
+
description: "The user default type",
|
|
291
|
+
},
|
|
292
|
+
displayEmail: {
|
|
293
|
+
type: "string",
|
|
294
|
+
description: "How the email is displayed",
|
|
295
|
+
},
|
|
296
|
+
coverText: {
|
|
297
|
+
type: "string",
|
|
298
|
+
description:
|
|
299
|
+
"Alternate user-friendly text for displaying a link",
|
|
300
|
+
},
|
|
301
|
+
currencySymbol: {
|
|
302
|
+
type: "string",
|
|
303
|
+
description:
|
|
304
|
+
"The currency symbol used when displaying field values",
|
|
305
|
+
},
|
|
306
|
+
summaryQuery: {
|
|
307
|
+
type: "string",
|
|
308
|
+
description: "The summary query",
|
|
309
|
+
},
|
|
310
|
+
targetFieldId: {
|
|
311
|
+
type: "integer",
|
|
312
|
+
description: "The id of the target field",
|
|
313
|
+
},
|
|
314
|
+
displayUser: {
|
|
315
|
+
type: "string",
|
|
316
|
+
description: "The configured option for how users display",
|
|
317
|
+
},
|
|
318
|
+
blankIsZero: {
|
|
319
|
+
type: "boolean",
|
|
320
|
+
description:
|
|
321
|
+
"Whether a blank value is treated as 0 in calculations",
|
|
322
|
+
},
|
|
323
|
+
exact: {
|
|
324
|
+
type: "boolean",
|
|
325
|
+
description:
|
|
326
|
+
"Whether an exact match is required for a report link",
|
|
327
|
+
},
|
|
328
|
+
defaultDomain: {
|
|
329
|
+
type: "string",
|
|
330
|
+
description: "Default email domain",
|
|
331
|
+
},
|
|
332
|
+
defaultValue: {
|
|
333
|
+
type: "string",
|
|
334
|
+
description: "The default value configured for a field",
|
|
335
|
+
},
|
|
336
|
+
abbreviate: {
|
|
337
|
+
type: "boolean",
|
|
338
|
+
description:
|
|
339
|
+
"Don't show the URL protocol when showing the URL",
|
|
340
|
+
},
|
|
341
|
+
numberFormat: {
|
|
342
|
+
type: "integer",
|
|
343
|
+
description:
|
|
344
|
+
"The format used for displaying numeric values",
|
|
345
|
+
},
|
|
346
|
+
targetTableName: {
|
|
347
|
+
type: "string",
|
|
348
|
+
description: "The field's target table name",
|
|
349
|
+
},
|
|
350
|
+
appearsAs: {
|
|
351
|
+
type: "string",
|
|
352
|
+
description:
|
|
353
|
+
"The link text; if empty, the URL will be used",
|
|
354
|
+
},
|
|
355
|
+
width: {
|
|
356
|
+
type: "integer",
|
|
357
|
+
description: "The field's HTML input width in the product",
|
|
358
|
+
},
|
|
359
|
+
currencyFormat: {
|
|
360
|
+
type: "string",
|
|
361
|
+
enum: ["left", "right", "middle"],
|
|
362
|
+
description:
|
|
363
|
+
"The currency format used when displaying field values",
|
|
364
|
+
},
|
|
365
|
+
displayDayOfWeek: {
|
|
366
|
+
type: "boolean",
|
|
367
|
+
description:
|
|
368
|
+
"Indicates whether to display the day of the week",
|
|
369
|
+
},
|
|
370
|
+
summaryReferenceFieldId: {
|
|
371
|
+
type: "integer",
|
|
372
|
+
description:
|
|
373
|
+
"The id of the field that is the reference in the relationship",
|
|
374
|
+
},
|
|
375
|
+
commaStart: {
|
|
376
|
+
type: "integer",
|
|
377
|
+
description: "The number of digits before commas display",
|
|
378
|
+
},
|
|
379
|
+
choices: {
|
|
380
|
+
type: "array",
|
|
381
|
+
items: { type: "string" },
|
|
382
|
+
description:
|
|
383
|
+
"An array of entries that exist for a field offering choices",
|
|
384
|
+
},
|
|
385
|
+
targetTableId: {
|
|
386
|
+
type: "string",
|
|
387
|
+
description: "The id of the target table",
|
|
388
|
+
},
|
|
389
|
+
displayRelative: {
|
|
390
|
+
type: "boolean",
|
|
391
|
+
description: "Whether to display time as relative",
|
|
392
|
+
},
|
|
393
|
+
compositeFields: {
|
|
394
|
+
type: "array",
|
|
395
|
+
items: { type: "object", additionalProperties: true },
|
|
396
|
+
description:
|
|
397
|
+
"An array of fields that make up a composite field (e.g., address)",
|
|
398
|
+
},
|
|
399
|
+
displayCheckboxAsText: {
|
|
400
|
+
type: "boolean",
|
|
401
|
+
description:
|
|
402
|
+
"Indicates whether checkbox values are shown as text in reports",
|
|
403
|
+
},
|
|
404
|
+
versionMode: {
|
|
405
|
+
type: "string",
|
|
406
|
+
enum: ["keepallversions", "keeplastversions"],
|
|
407
|
+
description: "Version modes for files",
|
|
408
|
+
},
|
|
409
|
+
snapFieldId: {
|
|
410
|
+
type: "integer",
|
|
411
|
+
description: "The id of the field used to snapshot values",
|
|
412
|
+
},
|
|
413
|
+
hours24: {
|
|
414
|
+
type: "boolean",
|
|
415
|
+
description:
|
|
416
|
+
"Indicates whether to display time in 24-hour format",
|
|
417
|
+
},
|
|
418
|
+
sortAlpha: {
|
|
419
|
+
type: "boolean",
|
|
420
|
+
description:
|
|
421
|
+
"Whether to sort alphabetically (default is by record ID)",
|
|
422
|
+
},
|
|
423
|
+
hasExtension: {
|
|
424
|
+
type: "boolean",
|
|
425
|
+
description: "Whether this field has a phone extension",
|
|
426
|
+
},
|
|
427
|
+
useNewWindow: {
|
|
428
|
+
type: "boolean",
|
|
429
|
+
description:
|
|
430
|
+
"Indicates if the file should open a new window when clicked",
|
|
431
|
+
},
|
|
432
|
+
displayAsLink: {
|
|
433
|
+
type: "boolean",
|
|
434
|
+
description:
|
|
435
|
+
"Indicates if the field should be shown as a hyperlink",
|
|
436
|
+
},
|
|
437
|
+
lookupReferenceFieldId: {
|
|
438
|
+
type: "integer",
|
|
439
|
+
description:
|
|
440
|
+
"The id of the field that is the reference for this lookup",
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
nullable: true,
|
|
444
|
+
},
|
|
125
445
|
};
|
|
446
|
+
|
|
447
|
+
// Adjust required fields based on operation
|
|
448
|
+
if (pathKey.includes("{fieldId}") && method === "post") {
|
|
449
|
+
// UpdateField (POST /fields/{fieldId})
|
|
450
|
+
requiredFields = ["label"]; // fieldType is not allowed in updates
|
|
451
|
+
} else {
|
|
452
|
+
// CreateField (POST /fields)
|
|
453
|
+
requiredFields = ["label", "fieldType"];
|
|
454
|
+
}
|
|
126
455
|
}
|
|
456
|
+
|
|
127
457
|
spec.definitions[requestName] = {
|
|
128
458
|
type: "object",
|
|
129
459
|
properties,
|
|
130
|
-
required:
|
|
131
|
-
(key) =>
|
|
132
|
-
![
|
|
133
|
-
"fieldHelp",
|
|
134
|
-
"addToForms",
|
|
135
|
-
"permissions",
|
|
136
|
-
"required",
|
|
137
|
-
"unique",
|
|
138
|
-
"noWrap",
|
|
139
|
-
"bold",
|
|
140
|
-
"appearsByDefault",
|
|
141
|
-
"findEnabled",
|
|
142
|
-
"doesDataCopy",
|
|
143
|
-
"audited",
|
|
144
|
-
].includes(key)
|
|
145
|
-
),
|
|
460
|
+
required: requiredFields,
|
|
146
461
|
description: operation.summary || `Request body for ${opId}`,
|
|
147
462
|
};
|
|
148
463
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// schema/tags/index.ts
|
|
1
|
+
// open-api/schema/tags/index.ts
|
|
2
2
|
import { Operation, Parameter, Spec } from "../../types/spec.ts";
|
|
3
3
|
import { normalizeDefinitionName } from "../../utils/naming.ts";
|
|
4
4
|
import { enhanceUsers } from "./users.ts";
|
|
@@ -9,7 +9,7 @@ import { enhanceFields } from "./fields.ts";
|
|
|
9
9
|
import { enhanceTables } from "./tables.ts";
|
|
10
10
|
|
|
11
11
|
export function enhanceTags(spec: Spec): void {
|
|
12
|
-
|
|
12
|
+
console.log("enhanceTags version: 2025-03-16-fix-applied"); // Confirmation log
|
|
13
13
|
|
|
14
14
|
for (const pathKey in spec.paths) {
|
|
15
15
|
for (const method in spec.paths[pathKey]) {
|
|
@@ -17,7 +17,6 @@ export function enhanceTags(spec: Spec): void {
|
|
|
17
17
|
const opId =
|
|
18
18
|
operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
|
|
19
19
|
|
|
20
|
-
// Handle array schemas
|
|
21
20
|
if (operation.parameters) {
|
|
22
21
|
operation.parameters.forEach((param: Parameter) => {
|
|
23
22
|
if (param.in === "body") {
|
|
@@ -56,7 +55,6 @@ export function enhanceTags(spec: Spec): void {
|
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
// Apply tag-specific enhancements
|
|
60
58
|
enhanceUsers(spec, pathKey, method, operation);
|
|
61
59
|
enhanceGroups(spec, pathKey, method, operation);
|
|
62
60
|
enhanceRecords(spec, pathKey, method, operation);
|
package/open-api/types/spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// open-api/types/spec.ts
|
|
1
2
|
export interface Parameter {
|
|
2
3
|
name: string;
|
|
3
4
|
in: string;
|
|
@@ -26,7 +27,7 @@ export interface Operation {
|
|
|
26
27
|
|
|
27
28
|
export interface Spec {
|
|
28
29
|
paths: Record<string, Record<string, Operation>>;
|
|
29
|
-
definitions
|
|
30
|
+
definitions: Record<string, any>; // Required, no longer optional
|
|
30
31
|
swagger: string;
|
|
31
32
|
info: any;
|
|
32
33
|
operations?: any;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
interface ParamDetail {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
required: boolean;
|
|
5
|
+
properties: {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
required: boolean;
|
|
9
|
+
jsdoc?: string;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface JsDocOptions {
|
|
14
|
+
summary: string;
|
|
15
|
+
opId: string;
|
|
16
|
+
paramDetails: ParamDetail[];
|
|
17
|
+
returnType: string;
|
|
18
|
+
returnTypeDetails: {
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
required: boolean;
|
|
22
|
+
jsdoc?: string;
|
|
23
|
+
}[];
|
|
24
|
+
docLink: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function generateJsDoc({
|
|
28
|
+
summary,
|
|
29
|
+
opId,
|
|
30
|
+
paramDetails,
|
|
31
|
+
returnType,
|
|
32
|
+
returnTypeDetails,
|
|
33
|
+
docLink,
|
|
34
|
+
}: JsDocOptions): string {
|
|
35
|
+
const jsDocLines: string[] = [
|
|
36
|
+
` /**`,
|
|
37
|
+
` * ${summary}`,
|
|
38
|
+
` *`,
|
|
39
|
+
` * @param {Object} params _Object containing the parameters for_ ${opId}`,
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// Parameters section
|
|
43
|
+
if (paramDetails.length > 0) {
|
|
44
|
+
paramDetails.forEach((p) => {
|
|
45
|
+
jsDocLines.push(
|
|
46
|
+
` * @param {${p.type}} params.${p.name} _${
|
|
47
|
+
p.required ? "Required" : "Optional"
|
|
48
|
+
} parameter with properties_`
|
|
49
|
+
);
|
|
50
|
+
if (p.properties.length > 0) {
|
|
51
|
+
p.properties.forEach((prop) => {
|
|
52
|
+
const propDesc = prop.jsdoc
|
|
53
|
+
? prop.jsdoc.replace(/@type\s*{[^}]+}\s*@memberof\s*\w+/, "").trim()
|
|
54
|
+
: `Type: ${prop.type}`;
|
|
55
|
+
jsDocLines.push(
|
|
56
|
+
` * - **${prop.name}** (\`${prop.type}\`${
|
|
57
|
+
prop.required ? ", required" : ", optional"
|
|
58
|
+
}) _${propDesc}_`
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
jsDocLines.push(` * No parameters`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Returns section
|
|
68
|
+
jsDocLines.push(` *`);
|
|
69
|
+
if (returnTypeDetails.length > 0) {
|
|
70
|
+
jsDocLines.push(
|
|
71
|
+
` * @returns {Promise<${returnType}>} _Promise resolving to the ${opId} response with properties_`
|
|
72
|
+
);
|
|
73
|
+
returnTypeDetails.forEach((prop) => {
|
|
74
|
+
const propDesc = prop.jsdoc
|
|
75
|
+
? prop.jsdoc.replace(/@type\s*{[^}]+}\s*@memberof\s*\w+/, "").trim()
|
|
76
|
+
: `Type: ${prop.type}`;
|
|
77
|
+
jsDocLines.push(
|
|
78
|
+
` * - **${prop.name}** (\`${prop.type}\`${
|
|
79
|
+
prop.required ? ", required" : ", optional"
|
|
80
|
+
}) _${propDesc}_`
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
jsDocLines.push(
|
|
85
|
+
` * @returns {Promise<${returnType}>} _Promise resolving to the ${opId} response_`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
jsDocLines.push(
|
|
90
|
+
` *`,
|
|
91
|
+
` * @see {@link ${docLink}} Official Quickbase API documentation`
|
|
92
|
+
);
|
|
93
|
+
jsDocLines.push(` */`);
|
|
94
|
+
|
|
95
|
+
return jsDocLines.join("\n");
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickbase-js",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.9",
|
|
4
4
|
"description": "QuickBase JavaScript client for frameworks and vanilla JS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/quickbase.js",
|
|
@@ -34,12 +34,10 @@
|
|
|
34
34
|
"release:publish": "npm run release:push && npm publish --tag beta",
|
|
35
35
|
"release:stable": "standard-version && git push --follow-tags origin main && npm publish",
|
|
36
36
|
"fix-spec": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' open-api/fix-spec-main.ts",
|
|
37
|
+
"generate-report": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' open-api/generate-override-report.ts",
|
|
37
38
|
"gen:openapi": "rimraf src/generated && node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' open-api/regenerate-client.ts",
|
|
38
39
|
"gen:unified": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' open-api/generate-unified-interface.ts",
|
|
39
|
-
"gen:all": "npm run
|
|
40
|
-
"split-spec": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/split-spec.ts",
|
|
41
|
-
"validate-spec": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/validate-spec.ts",
|
|
42
|
-
"generate-types": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/generate-types.ts",
|
|
40
|
+
"gen:all": "npm run fix-spec && npm run generate-report && npm run gen:openapi && npm run gen:unified",
|
|
43
41
|
"log-gen": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/log-gen.ts",
|
|
44
42
|
"test:all": "vitest run tests/vitest/**/**/*.test.ts --reporter=basic && playwright test tests/playwright/qb --config playwright.config.ts --reporter=dot --quiet",
|
|
45
43
|
"test:pw:qb:all": "playwright test tests/playwright/qb --config playwright.config.ts",
|
|
@@ -54,38 +52,40 @@
|
|
|
54
52
|
"test:vitest:unit:apps": "vitest run tests/vitest/unit/apps/*.test.ts",
|
|
55
53
|
"test:vitest:unit:auth": "vitest run tests/vitest/unit/auth/*.test.ts",
|
|
56
54
|
"test:vitest:unit:fields": "vitest run tests/vitest/unit/fields/*.test.ts",
|
|
55
|
+
"test:vitest:unit:formulas": "vitest run tests/vitest/unit/formulas/*.test.ts",
|
|
57
56
|
"test:vitest:unit:records": "vitest run tests/vitest/unit/records/*.test.ts",
|
|
58
57
|
"test:vitest:unit:tables": "vitest run tests/vitest/unit/tables/*.test.ts",
|
|
59
58
|
"test:pw:qb:auth": "playwright test tests/playwright/qb/auth"
|
|
60
59
|
},
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"typescript": "^4.8.2"
|
|
63
|
-
},
|
|
64
60
|
"devDependencies": {
|
|
65
|
-
"@openapitools/openapi-generator-cli": "^
|
|
66
|
-
"@playwright/test": "^
|
|
67
|
-
"@rollup/plugin-commonjs": "^
|
|
68
|
-
"@rollup/plugin-node-resolve": "^
|
|
69
|
-
"@rollup/plugin-terser": "
|
|
70
|
-
"@rollup/plugin-typescript": "^
|
|
71
|
-
"@types/
|
|
72
|
-
"@types/
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
61
|
+
"@openapitools/openapi-generator-cli": "^2.18.4",
|
|
62
|
+
"@playwright/test": "^1.51.0",
|
|
63
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
64
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
65
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
66
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
67
|
+
"@types/fast-json-patch": "^1.0.4",
|
|
68
|
+
"@types/js-yaml": "^4.0.9",
|
|
69
|
+
"@types/node": "^22.13.10",
|
|
70
|
+
"dotenv": "^16.4.7",
|
|
71
|
+
"express": "^4.21.2",
|
|
72
|
+
"fast-json-patch": "^3.1.1",
|
|
73
|
+
"glob": "^10.4.5",
|
|
74
|
+
"js-yaml": "^4.1.0",
|
|
75
|
+
"jsdom": "^26.0.0",
|
|
76
|
+
"node-fetch": "^3.3.2",
|
|
77
|
+
"openapi-schema-validator": "^12.1.3",
|
|
78
|
+
"openapi-types": "^12.1.3",
|
|
79
|
+
"openapi-typescript": "^7.6.1",
|
|
80
|
+
"rimraf": "^5.0.10",
|
|
81
|
+
"rollup": "^4.35.0",
|
|
82
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
83
|
+
"standard-version": "^9.5.0",
|
|
84
|
+
"ts-morph": "^25.0.1",
|
|
85
|
+
"ts-node": "^10.9.2",
|
|
86
|
+
"tslib": "^2.8.1",
|
|
87
|
+
"typescript": "^5.8.2",
|
|
88
|
+
"undici-types": "^7.5.0",
|
|
89
|
+
"vitest": "^3.0.8"
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/RateLimitError.ts
|
|
2
|
+
export class RateLimitError extends Error {
|
|
3
|
+
public readonly status: number;
|
|
4
|
+
public readonly retryAfter?: number;
|
|
5
|
+
|
|
6
|
+
constructor(message: string, status: number, retryAfter?: number) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "RateLimitError";
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.retryAfter = retryAfter; // Seconds from Retry-After header, if present
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/ThrottleBucket.ts
|
|
2
|
+
export class ThrottleBucket {
|
|
3
|
+
private tokens: number;
|
|
4
|
+
private maxTokens: number;
|
|
5
|
+
private refillRate: number; // Tokens per second
|
|
6
|
+
private lastRefill: number;
|
|
7
|
+
private pending: Promise<void> = Promise.resolve(); // Queue for sequential execution
|
|
8
|
+
|
|
9
|
+
constructor(rate: number, burst: number) {
|
|
10
|
+
this.tokens = burst;
|
|
11
|
+
this.maxTokens = burst;
|
|
12
|
+
this.refillRate = rate;
|
|
13
|
+
this.lastRefill = Date.now();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private refill(): void {
|
|
17
|
+
const now = Date.now();
|
|
18
|
+
const elapsed = (now - this.lastRefill) / 1000; // Seconds elapsed
|
|
19
|
+
const newTokens = elapsed * this.refillRate;
|
|
20
|
+
this.tokens = Math.min(this.maxTokens, this.tokens + newTokens);
|
|
21
|
+
this.lastRefill = now;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async acquire(): Promise<void> {
|
|
25
|
+
// Chain the new acquisition onto the pending queue
|
|
26
|
+
const previous = this.pending;
|
|
27
|
+
this.pending = (async () => {
|
|
28
|
+
await previous; // Wait for prior calls to complete
|
|
29
|
+
this.refill();
|
|
30
|
+
if (this.tokens >= 1) {
|
|
31
|
+
this.tokens -= 1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const waitTime = ((1 - this.tokens) / this.refillRate) * 1000; // ms until next token
|
|
35
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
36
|
+
this.refill();
|
|
37
|
+
this.tokens -= 1;
|
|
38
|
+
})();
|
|
39
|
+
await this.pending;
|
|
40
|
+
}
|
|
41
|
+
}
|