quickbase-js 0.1.0-beta.9 → 1.0.0

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 (146) hide show
  1. package/README.md +270 -60
  2. package/dist/esm/quickbase.d.ts +2553 -3220
  3. package/dist/esm/quickbase.js +1545 -3443
  4. package/dist/esm/quickbase.js.map +1 -1
  5. package/dist/esm/quickbase.min.js +1 -1
  6. package/dist/esm/quickbase.min.js.map +1 -1
  7. package/dist/umd/quickbase.umd.js +1544 -3625
  8. package/dist/umd/quickbase.umd.js.map +1 -1
  9. package/dist/umd/quickbase.umd.min.js +1 -1
  10. package/dist/umd/quickbase.umd.min.js.map +1 -1
  11. package/package.json +25 -12
  12. package/CHANGELOG.md +0 -184
  13. package/build-common.js +0 -131
  14. package/build-esm.js +0 -71
  15. package/build-umd.js +0 -69
  16. package/examples/quicbase-jsCDN.html +0 -36
  17. package/examples/react.js +0 -48
  18. package/examples/vanillajs.html +0 -47
  19. package/open-api/fix-spec-main.ts +0 -97
  20. package/open-api/generate-override-report.ts +0 -214
  21. package/open-api/generate-unified-interface.ts +0 -336
  22. package/open-api/output/override-report.html +0 -11
  23. package/open-api/output/override-report.json +0 -14395
  24. package/open-api/output/quickbase-fixed.json +0 -11191
  25. package/open-api/regenerate-client.ts +0 -116
  26. package/open-api/schema/enhance-general.ts +0 -100
  27. package/open-api/schema/fix-arrays.ts +0 -69
  28. package/open-api/schema/tags/apps.ts +0 -90
  29. package/open-api/schema/tags/fields.ts +0 -471
  30. package/open-api/schema/tags/groups.ts +0 -51
  31. package/open-api/schema/tags/index.ts +0 -66
  32. package/open-api/schema/tags/records.ts +0 -115
  33. package/open-api/schema/tags/tables.ts +0 -211
  34. package/open-api/schema/tags/users.ts +0 -47
  35. package/open-api/types/spec.ts +0 -42
  36. package/open-api/utils/generateJsDoc.ts +0 -96
  37. package/open-api/utils/infer-schema.ts +0 -40
  38. package/open-api/utils/naming.ts +0 -10
  39. package/playwright.config.ts +0 -37
  40. package/rollup.config.js +0 -114
  41. package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -46878
  42. package/specs/split/apps.json +0 -1315
  43. package/specs/split/auth.json +0 -191
  44. package/specs/split/fields.json +0 -3869
  45. package/specs/split/records.json +0 -754
  46. package/specs/split/reports.json +0 -619
  47. package/specs/split/tables.json +0 -1605
  48. package/src/RateLimitError.ts +0 -12
  49. package/src/ThrottleBucket.ts +0 -41
  50. package/src/authorizationStrategy.ts +0 -246
  51. package/src/generated-unified/QuickbaseClient.ts +0 -1049
  52. package/src/generated-unified/missing-types-report.json +0 -3
  53. package/src/index.ts +0 -1
  54. package/src/invokeMethod.ts +0 -242
  55. package/src/quickbaseClient.ts +0 -271
  56. package/src/rateLimiter.ts +0 -25
  57. package/src/tokenCache.ts +0 -35
  58. package/src/utils.ts +0 -7
  59. package/test-esm.js +0 -1
  60. package/test-results.json +0 -2050
  61. package/test-umd.js +0 -1
  62. package/test.ts +0 -1
  63. package/tests/playwright/qb/auth/cacheSwitching.test.ts +0 -159
  64. package/tests/playwright/qb/auth/fetchTempToken401.test.ts +0 -219
  65. package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +0 -162
  66. package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +0 -153
  67. package/tests/playwright/qb/auth/getTempToken.test.ts +0 -152
  68. package/tests/playwright/qb/auth/tempTokenPrefetch.test.ts +0 -179
  69. package/tests/playwright/qb/auth/tempTokenRenewal.test.ts +0 -133
  70. package/tests/setup.ts +0 -53
  71. package/tests/vitest/qb/apps/copyApp.test.ts +0 -76
  72. package/tests/vitest/qb/apps/createApp.test.ts +0 -64
  73. package/tests/vitest/qb/apps/deleteApp.test.ts +0 -76
  74. package/tests/vitest/qb/apps/getApp.test.ts +0 -44
  75. package/tests/vitest/qb/apps/getAppEvents.test.ts +0 -67
  76. package/tests/vitest/qb/apps/updateApp.test.ts +0 -58
  77. package/tests/vitest/qb/auth/mockQuickbaseServer.ts +0 -60
  78. package/tests/vitest/qb/auth/retryUserToken401.test.ts +0 -73
  79. package/tests/vitest/qb/auth/ssoTokenIntegrationWithServer.test.ts +0 -65
  80. package/tests/vitest/qb/fields/createField.test.ts +0 -77
  81. package/tests/vitest/qb/fields/deleteFields.test.ts +0 -83
  82. package/tests/vitest/qb/fields/getField.test.ts +0 -85
  83. package/tests/vitest/qb/fields/getFieldUsage.test.ts +0 -82
  84. package/tests/vitest/qb/fields/getFields.test.ts +0 -232
  85. package/tests/vitest/qb/fields/getFieldsUsage.test.ts +0 -77
  86. package/tests/vitest/qb/fields/updateField.test.ts +0 -93
  87. package/tests/vitest/qb/formulas/runFormula.test.ts +0 -96
  88. package/tests/vitest/qb/index.ts +0 -29
  89. package/tests/vitest/qb/records/deleteRecords.test.ts +0 -110
  90. package/tests/vitest/qb/records/runQuery.test.ts +0 -146
  91. package/tests/vitest/qb/records/upsert.test.ts +0 -102
  92. package/tests/vitest/qb/tables/createRelationship.test.ts +0 -102
  93. package/tests/vitest/qb/tables/createTable.test.ts +0 -55
  94. package/tests/vitest/qb/tables/deleteRelationship.test.ts +0 -143
  95. package/tests/vitest/qb/tables/deleteTable.test.ts +0 -50
  96. package/tests/vitest/qb/tables/getAppTables.test.ts +0 -46
  97. package/tests/vitest/qb/tables/getRelationships.test.ts +0 -80
  98. package/tests/vitest/qb/tables/getTable.test.ts +0 -26
  99. package/tests/vitest/qb/tables/updateRelationship.test.ts +0 -250
  100. package/tests/vitest/qb/tables/updateTable.test.ts +0 -48
  101. package/tests/vitest/unit/ThrottleBucket.test.ts +0 -95
  102. package/tests/vitest/unit/apps/copyApp.test.ts +0 -581
  103. package/tests/vitest/unit/apps/createApp.test.ts +0 -186
  104. package/tests/vitest/unit/apps/deleteApp.test.ts +0 -216
  105. package/tests/vitest/unit/apps/getApp.test.ts +0 -128
  106. package/tests/vitest/unit/apps/getAppEvents.test.ts +0 -193
  107. package/tests/vitest/unit/apps/updateApp.test.ts +0 -412
  108. package/tests/vitest/unit/auth/fetchTempToken401.test.ts +0 -63
  109. package/tests/vitest/unit/auth/getTempToken.test.ts +0 -119
  110. package/tests/vitest/unit/auth/retryTempToken401.test.ts +0 -95
  111. package/tests/vitest/unit/auth/retryTempTokenMaxRetries.test.ts +0 -235
  112. package/tests/vitest/unit/auth/retryUserToken401.test.ts +0 -69
  113. package/tests/vitest/unit/auth/ssoTokenRefresh.test.ts +0 -325
  114. package/tests/vitest/unit/fields/createField.test.ts +0 -451
  115. package/tests/vitest/unit/fields/deleteFields.test.ts +0 -141
  116. package/tests/vitest/unit/fields/getField.test.ts +0 -189
  117. package/tests/vitest/unit/fields/getFieldUsage.test.ts +0 -180
  118. package/tests/vitest/unit/fields/getFields.test.ts +0 -122
  119. package/tests/vitest/unit/fields/getFieldsUsage.test.ts +0 -160
  120. package/tests/vitest/unit/fields/updateField.test.ts +0 -285
  121. package/tests/vitest/unit/formulas/runFormula.test.ts +0 -205
  122. package/tests/vitest/unit/index.ts +0 -34
  123. package/tests/vitest/unit/inferHttpMethod.test.ts +0 -131
  124. package/tests/vitest/unit/rateLimit.test.ts +0 -191
  125. package/tests/vitest/unit/records/deleteRecords.test.ts +0 -112
  126. package/tests/vitest/unit/records/runQuery.test.ts +0 -102
  127. package/tests/vitest/unit/records/upsert.test.ts +0 -234
  128. package/tests/vitest/unit/tables/createRelationship.test.ts +0 -212
  129. package/tests/vitest/unit/tables/createTable.test.ts +0 -70
  130. package/tests/vitest/unit/tables/deleteRelationship.test.ts +0 -97
  131. package/tests/vitest/unit/tables/deleteTable.test.ts +0 -77
  132. package/tests/vitest/unit/tables/getAppTables.test.ts +0 -85
  133. package/tests/vitest/unit/tables/getRelationships.test.ts +0 -259
  134. package/tests/vitest/unit/tables/getTable.test.ts +0 -233
  135. package/tests/vitest/unit/tables/updateRelationship.test.ts +0 -307
  136. package/tests/vitest/unit/tables/updateTable.test.ts +0 -80
  137. package/tests/vitest/unit/tokenLifespan.test.ts +0 -204
  138. package/tests/vitest/unit/umd.test.ts +0 -8
  139. package/text.txt +0 -104
  140. package/tools/log-gen.ts +0 -244
  141. package/tools/log-gen.yaml +0 -5424
  142. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  143. package/tsconfig.build.json +0 -17
  144. package/tsconfig.json +0 -32
  145. package/versionrc.json +0 -9
  146. package/vitest.config.ts +0 -27
@@ -1,471 +0,0 @@
1
- // schema/tags/fields.ts
2
- import { Operation, Parameter, Spec } from "../../types/spec.ts";
3
- import { normalizeDefinitionName } from "../../utils/naming.ts";
4
-
5
- export function enhanceFields(
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("Fields")) {
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
- let requiredFields: string[];
32
-
33
- if (method === "delete") {
34
- // DELETE /fields (deleteFields)
35
- properties = {
36
- fieldIds: { type: "array", items: { type: "integer" } },
37
- };
38
- requiredFields = ["fieldIds"];
39
- } else {
40
- // Common properties for createField and updateField
41
- properties = {
42
- label: { type: "string", description: "The label of the field" },
43
- fieldType: {
44
- type: "string",
45
- description: "The type of the field",
46
- enum: [
47
- "text",
48
- "text-multiple-choice",
49
- "text-multi-line",
50
- "rich-text",
51
- "numeric",
52
- "currency",
53
- "percent",
54
- "rating",
55
- "date",
56
- "date-time",
57
- "time-of-day",
58
- "duration",
59
- "checkbox",
60
- "user",
61
- "multi-user",
62
- "address",
63
- "email",
64
- "phone",
65
- "url",
66
- "file",
67
- "record-id",
68
- ],
69
- },
70
- fieldHelp: {
71
- type: "string",
72
- description: "Help text for the field",
73
- nullable: true,
74
- },
75
- addToForms: {
76
- type: "boolean",
77
- description: "Whether to add the field to forms",
78
- nullable: true,
79
- },
80
- permissions: {
81
- anyOf: [
82
- {
83
- type: "array",
84
- items: { $ref: "#/definitions/Permission" },
85
- },
86
- { type: "null" },
87
- ],
88
- description: "Custom permissions for the field",
89
- },
90
- required: {
91
- type: "boolean",
92
- description: "Whether the field is required",
93
- nullable: true,
94
- },
95
- unique: {
96
- type: "boolean",
97
- description: "Whether the field must have unique values",
98
- nullable: true,
99
- },
100
- noWrap: {
101
- type: "boolean",
102
- description: "Whether text wrapping is disabled",
103
- nullable: true,
104
- },
105
- bold: {
106
- type: "boolean",
107
- description: "Whether the field is bolded",
108
- nullable: true,
109
- },
110
- appearsByDefault: {
111
- type: "boolean",
112
- description: "Whether the field appears by default in reports",
113
- nullable: true,
114
- },
115
- findEnabled: {
116
- type: "boolean",
117
- description: "Whether the field is searchable",
118
- nullable: true,
119
- },
120
- doesDataCopy: {
121
- type: "boolean",
122
- description: "Whether the field copies data",
123
- nullable: true,
124
- },
125
- audited: {
126
- type: "boolean",
127
- description: "Whether changes to the field are audited",
128
- nullable: true,
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
- },
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
- }
455
- }
456
-
457
- spec.definitions[requestName] = {
458
- type: "object",
459
- properties,
460
- required: requiredFields,
461
- description: operation.summary || `Request body for ${opId}`,
462
- };
463
- }
464
- param.schema = { $ref: `#/definitions/${requestName}` };
465
- console.log(
466
- `Ensured ${requestName} in definitions for ${pathKey}(${method})`
467
- );
468
- }
469
- });
470
- }
471
- }
@@ -1,51 +0,0 @@
1
- // schema/tags/groups.ts
2
- import { Operation, Parameter, Spec } from "../../types/spec.ts";
3
- import { normalizeDefinitionName } from "../../utils/naming.ts";
4
-
5
- export function enhanceGroups(
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 (
14
- operation.parameters &&
15
- operation.tags?.includes("Groups") &&
16
- operation.summary?.toLowerCase().includes("subgroup")
17
- ) {
18
- operation.parameters.forEach((param: Parameter) => {
19
- if (param.in === "body") {
20
- if (!param.schema) param.schema = {};
21
- let requestName =
22
- param.schema.$ref?.split("/").pop() || `${opId}Request`;
23
- requestName = normalizeDefinitionName(requestName);
24
-
25
- if (
26
- !spec.definitions[requestName] ||
27
- !spec.definitions[requestName].type ||
28
- Object.keys(spec.definitions[requestName]?.properties || {})
29
- .length === 0
30
- ) {
31
- console.log(
32
- `Defining schema for ${requestName} in ${pathKey}(${method})`
33
- );
34
- const properties = {
35
- groupIds: { type: "array", items: { type: "string" } },
36
- };
37
- spec.definitions[requestName] = {
38
- type: "object",
39
- properties,
40
- required: Object.keys(properties),
41
- description: operation.summary || `Request body for ${opId}`,
42
- };
43
- }
44
- param.schema = { $ref: `#/definitions/${requestName}` };
45
- console.log(
46
- `Ensured ${requestName} in definitions for ${pathKey}(${method})`
47
- );
48
- }
49
- });
50
- }
51
- }
@@ -1,66 +0,0 @@
1
- // open-api/schema/tags/index.ts
2
- import { Operation, Parameter, Spec } from "../../types/spec.ts";
3
- import { normalizeDefinitionName } from "../../utils/naming.ts";
4
- import { enhanceUsers } from "./users.ts";
5
- import { enhanceGroups } from "./groups.ts";
6
- import { enhanceRecords } from "./records.ts";
7
- import { enhanceApps } from "./apps.ts";
8
- import { enhanceFields } from "./fields.ts";
9
- import { enhanceTables } from "./tables.ts";
10
-
11
- export function enhanceTags(spec: Spec): void {
12
- console.log("enhanceTags version: 2025-03-16-fix-applied"); // Confirmation log
13
-
14
- for (const pathKey in spec.paths) {
15
- for (const method in spec.paths[pathKey]) {
16
- const operation: Operation = spec.paths[pathKey][method];
17
- const opId =
18
- operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
19
-
20
- if (operation.parameters) {
21
- operation.parameters.forEach((param: Parameter) => {
22
- if (param.in === "body") {
23
- if (!param.schema) param.schema = {};
24
- let requestName =
25
- param.schema.$ref?.split("/").pop() || `${opId}Request`;
26
- requestName = normalizeDefinitionName(requestName);
27
-
28
- if (spec.definitions[requestName]?.type === "array") {
29
- console.log(
30
- `Wrapping array schema for ${requestName} in ${pathKey}(${method})`
31
- );
32
- const arraySchema = spec.definitions[requestName];
33
- let wrapperPropName = operation.tags?.includes("Users")
34
- ? "userIds"
35
- : "items";
36
- if (
37
- operation.tags?.includes("Groups") &&
38
- operation.summary?.toLowerCase().includes("subgroup")
39
- ) {
40
- wrapperPropName = "groupIds";
41
- }
42
- spec.definitions[requestName] = {
43
- type: "object",
44
- properties: { [wrapperPropName]: arraySchema },
45
- required: arraySchema.minItems > 0 ? [wrapperPropName] : [],
46
- description:
47
- arraySchema.description || `Request body for ${opId}`,
48
- };
49
- param.schema = { $ref: `#/definitions/${requestName}` };
50
- console.log(
51
- `Ensured ${requestName} in definitions for ${pathKey}(${method})`
52
- );
53
- }
54
- }
55
- });
56
- }
57
-
58
- enhanceUsers(spec, pathKey, method, operation);
59
- enhanceGroups(spec, pathKey, method, operation);
60
- enhanceRecords(spec, pathKey, method, operation);
61
- enhanceApps(spec, pathKey, method, operation);
62
- enhanceFields(spec, pathKey, method, operation);
63
- enhanceTables(spec, pathKey, method, operation);
64
- }
65
- }
66
- }