quickbase-js 2.3.0 → 2.4.1

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 (62) hide show
  1. package/README.md +145 -1107
  2. package/dist/auth/ticket.d.ts.map +1 -1
  3. package/dist/auth/ticket.js +4 -3
  4. package/dist/auth/ticket.js.map +1 -1
  5. package/dist/client/request.d.ts +4 -0
  6. package/dist/client/request.d.ts.map +1 -1
  7. package/dist/client/request.js +15 -3
  8. package/dist/client/request.js.map +1 -1
  9. package/dist/generated/client.d.ts +2 -0
  10. package/dist/generated/client.d.ts.map +1 -1
  11. package/dist/generated/client.js +134 -113
  12. package/dist/generated/client.js.map +1 -1
  13. package/dist/generated/types.d.ts +2700 -2256
  14. package/dist/generated/types.d.ts.map +1 -1
  15. package/dist/generated/types.js +0 -2
  16. package/dist/generated/types.js.map +1 -1
  17. package/dist/quickbase.esm.js +3 -3
  18. package/dist/quickbase.esm.js.map +3 -3
  19. package/dist/quickbase.min.js +3 -3
  20. package/dist/quickbase.min.js.map +3 -3
  21. package/package.json +16 -13
  22. package/src/auth/index.ts +55 -0
  23. package/src/auth/sso-token.ts +143 -0
  24. package/src/auth/temp-token.ts +160 -0
  25. package/src/auth/ticket.ts +329 -0
  26. package/src/auth/token-cache.ts +97 -0
  27. package/src/auth/types.ts +50 -0
  28. package/src/auth/user-token.ts +38 -0
  29. package/src/cli/schema.ts +512 -0
  30. package/src/client/index.ts +36 -0
  31. package/src/client/pagination.ts +337 -0
  32. package/src/client/request.ts +544 -0
  33. package/src/client/retry.ts +169 -0
  34. package/src/client/throttle.ts +105 -0
  35. package/src/core/config.ts +160 -0
  36. package/src/core/dates.ts +63 -0
  37. package/src/core/errors.ts +349 -0
  38. package/src/core/index.ts +50 -0
  39. package/src/core/logger.ts +113 -0
  40. package/src/core/schema.ts +213 -0
  41. package/src/core/transform.ts +295 -0
  42. package/src/core/types.ts +337 -0
  43. package/src/generated/client.ts +1785 -0
  44. package/src/generated/operations.json +672 -0
  45. package/src/generated/types.ts +4884 -0
  46. package/src/index.ts +259 -0
  47. package/src/xml/codepages.ts +119 -0
  48. package/src/xml/dbvars.ts +75 -0
  49. package/src/xml/errors.ts +133 -0
  50. package/src/xml/fields.ts +121 -0
  51. package/src/xml/groups.ts +560 -0
  52. package/src/xml/html.ts +152 -0
  53. package/src/xml/index.ts +1196 -0
  54. package/src/xml/metadata.ts +111 -0
  55. package/src/xml/records.ts +301 -0
  56. package/src/xml/request.ts +238 -0
  57. package/src/xml/roles.ts +321 -0
  58. package/src/xml/schema.ts +436 -0
  59. package/src/xml/transform.ts +381 -0
  60. package/src/xml/types.ts +602 -0
  61. package/src/xml/users.ts +221 -0
  62. package/src/xml/webhooks.ts +260 -0
@@ -0,0 +1,381 @@
1
+ /**
2
+ * XML API Response Transformation
3
+ *
4
+ * Transforms XML API responses to use field and table aliases as keys
5
+ * when a schema is configured, similar to the JSON API transformation.
6
+ *
7
+ * Without schema: record.fields is an array accessed by index or id
8
+ * With schema: record.fields is keyed by alias (e.g., record.fields.name)
9
+ *
10
+ * XML-API: Remove this file when QuickBase discontinues the XML API.
11
+ * To find all XML API code, search for: XML-API
12
+ */
13
+
14
+ import type { ResolvedSchema } from '../core/types.js';
15
+ import { getFieldAlias, getTableAlias } from '../core/schema.js';
16
+ import type {
17
+ RecordField,
18
+ SchemaField,
19
+ GetRecordInfoResult,
20
+ GetSchemaResult,
21
+ FieldAddChoicesResult,
22
+ FieldRemoveChoicesResult,
23
+ DatabaseInfo,
24
+ GrantedDBsResult,
25
+ GrantedDBsForGroupResult,
26
+ GetAppDTMInfoResult,
27
+ FindDBByNameResult,
28
+ SchemaChildTable,
29
+ } from './types.js';
30
+
31
+ // =============================================================================
32
+ // Extended Types with Aliases
33
+ // =============================================================================
34
+
35
+ /**
36
+ * RecordField as returned in the keyed object (alias is the key)
37
+ */
38
+ export interface RecordFieldWithAlias extends RecordField {
39
+ /** Field alias (duplicated from key for convenience) */
40
+ alias?: string;
41
+ }
42
+
43
+ /**
44
+ * SchemaField as returned in the keyed object (alias is the key)
45
+ */
46
+ export interface SchemaFieldWithAlias extends SchemaField {
47
+ /** Field alias (duplicated from key for convenience) */
48
+ alias?: string;
49
+ /** Summary reference field alias */
50
+ summaryReferenceFidAlias?: string;
51
+ /** Summary target field alias */
52
+ summaryTargetFidAlias?: string;
53
+ }
54
+
55
+ /**
56
+ * DatabaseInfo keyed by alias
57
+ */
58
+ export interface DatabaseInfoWithAlias extends DatabaseInfo {
59
+ /** Table alias (duplicated from key for convenience) */
60
+ alias?: string;
61
+ }
62
+
63
+ /**
64
+ * SchemaChildTable keyed by alias
65
+ */
66
+ export interface SchemaChildTableWithAlias extends SchemaChildTable {
67
+ /** Table alias (duplicated from key for convenience) */
68
+ alias?: string;
69
+ }
70
+
71
+ /**
72
+ * GetRecordInfoResult with fields keyed by alias.
73
+ * Access: result.fields.name.value
74
+ */
75
+ export interface GetRecordInfoResultWithAlias extends Omit<GetRecordInfoResult, 'fields'> {
76
+ fields: Record<string, RecordFieldWithAlias>;
77
+ }
78
+
79
+ /**
80
+ * GetSchemaResult with fields keyed by alias.
81
+ * Access: result.table.fields.name, result.table.childTables.tasks
82
+ */
83
+ export interface GetSchemaResultWithAlias extends Omit<GetSchemaResult, 'table'> {
84
+ table: Omit<GetSchemaResult['table'], 'fields' | 'childTables'> & {
85
+ fields?: Record<string, SchemaFieldWithAlias>;
86
+ childTables?: Record<string, SchemaChildTableWithAlias>;
87
+ };
88
+ }
89
+
90
+ /**
91
+ * FieldAddChoicesResult with alias
92
+ */
93
+ export interface FieldAddChoicesResultWithAlias extends FieldAddChoicesResult {
94
+ /** Field alias from schema (if available) */
95
+ fieldAlias?: string;
96
+ }
97
+
98
+ /**
99
+ * FieldRemoveChoicesResult with alias
100
+ */
101
+ export interface FieldRemoveChoicesResultWithAlias extends FieldRemoveChoicesResult {
102
+ /** Field alias from schema (if available) */
103
+ fieldAlias?: string;
104
+ }
105
+
106
+ /**
107
+ * GrantedDBsResult with databases keyed by alias.
108
+ * Access: result.databases.projects.dbname
109
+ */
110
+ export interface GrantedDBsResultWithAlias extends Omit<GrantedDBsResult, 'databases'> {
111
+ databases: Record<string, DatabaseInfoWithAlias>;
112
+ }
113
+
114
+ /**
115
+ * GrantedDBsForGroupResult with databases keyed by alias.
116
+ */
117
+ export interface GrantedDBsForGroupResultWithAlias extends Omit<GrantedDBsForGroupResult, 'databases'> {
118
+ databases: Record<string, { dbid: string; name: string; alias?: string }>;
119
+ }
120
+
121
+ /**
122
+ * GetAppDTMInfoResult with tables keyed by alias.
123
+ * Access: result.tables.projects.lastModifiedTime
124
+ */
125
+ export interface GetAppDTMInfoResultWithAlias extends Omit<GetAppDTMInfoResult, 'tables'> {
126
+ appId: string;
127
+ appAlias?: string;
128
+ lastModifiedTime?: string;
129
+ lastRecModTime?: string;
130
+ tables: Record<
131
+ string,
132
+ {
133
+ id: string;
134
+ alias?: string;
135
+ lastModifiedTime?: string;
136
+ lastRecModTime?: string;
137
+ }
138
+ >;
139
+ }
140
+
141
+ /**
142
+ * FindDBByNameResult with alias
143
+ */
144
+ export interface FindDBByNameResultWithAlias extends FindDBByNameResult {
145
+ /** Table alias from schema (if available) */
146
+ alias?: string;
147
+ }
148
+
149
+ // =============================================================================
150
+ // Transformation Functions
151
+ // =============================================================================
152
+
153
+ /**
154
+ * Convert a fields array to a keyed object.
155
+ * Keys are field aliases (if in schema) or field IDs (as strings).
156
+ */
157
+ function fieldsArrayToMap<T extends RecordField>(
158
+ fields: T[],
159
+ schema: ResolvedSchema | undefined,
160
+ tableId: string
161
+ ): Record<string, T & { alias?: string }> {
162
+ const result: Record<string, T & { alias?: string }> = {};
163
+
164
+ for (const field of fields) {
165
+ const alias = schema ? getFieldAlias(schema, tableId, field.id) : undefined;
166
+ const key = alias ?? String(field.id);
167
+ result[key] = alias ? { ...field, alias } : field;
168
+ }
169
+
170
+ return result;
171
+ }
172
+
173
+ /**
174
+ * Convert a databases array to a keyed object.
175
+ * Keys are table aliases (if in schema) or dbids.
176
+ */
177
+ function databasesArrayToMap<T extends { dbid: string }>(
178
+ databases: T[],
179
+ schema: ResolvedSchema | undefined
180
+ ): Record<string, T & { alias?: string }> {
181
+ const result: Record<string, T & { alias?: string }> = {};
182
+
183
+ for (const db of databases) {
184
+ const alias = schema ? getTableAlias(schema, db.dbid) : undefined;
185
+ const key = alias ?? db.dbid;
186
+ result[key] = alias ? { ...db, alias } : db;
187
+ }
188
+
189
+ return result;
190
+ }
191
+
192
+ /**
193
+ * Convert a tables array to a keyed object.
194
+ * Keys are table aliases (if in schema) or table IDs.
195
+ */
196
+ function tablesArrayToMap<T extends { id: string }>(
197
+ tables: T[],
198
+ schema: ResolvedSchema | undefined
199
+ ): Record<string, T & { alias?: string }> {
200
+ const result: Record<string, T & { alias?: string }> = {};
201
+
202
+ for (const table of tables) {
203
+ const alias = schema ? getTableAlias(schema, table.id) : undefined;
204
+ const key = alias ?? table.id;
205
+ result[key] = alias ? { ...table, alias } : table;
206
+ }
207
+
208
+ return result;
209
+ }
210
+
211
+ /**
212
+ * Transform a SchemaField to include extra alias properties
213
+ */
214
+ function transformSchemaFieldAliases(
215
+ field: SchemaField,
216
+ schema: ResolvedSchema,
217
+ tableId: string
218
+ ): SchemaFieldWithAlias {
219
+ const result: SchemaFieldWithAlias = { ...field };
220
+
221
+ const alias = getFieldAlias(schema, tableId, field.id);
222
+ if (alias) result.alias = alias;
223
+
224
+ if (field.summaryReferenceFid !== undefined) {
225
+ const refAlias = getFieldAlias(schema, tableId, field.summaryReferenceFid);
226
+ if (refAlias) result.summaryReferenceFidAlias = refAlias;
227
+ }
228
+
229
+ if (field.summaryTargetFid !== undefined) {
230
+ const targetAlias = getFieldAlias(schema, tableId, field.summaryTargetFid);
231
+ if (targetAlias) result.summaryTargetFidAlias = targetAlias;
232
+ }
233
+
234
+ return result;
235
+ }
236
+
237
+ /**
238
+ * Transform GetRecordInfoResult to key fields by alias.
239
+ * Access: result.fields.name.value (instead of result.fields[0].value)
240
+ */
241
+ export function transformGetRecordInfoResult(
242
+ result: GetRecordInfoResult,
243
+ schema: ResolvedSchema | undefined,
244
+ tableId: string
245
+ ): GetRecordInfoResultWithAlias {
246
+ return {
247
+ ...result,
248
+ fields: fieldsArrayToMap(result.fields, schema, tableId),
249
+ };
250
+ }
251
+
252
+ /**
253
+ * Transform GetSchemaResult to key fields and child tables by alias.
254
+ * Access: result.table.fields.name, result.table.childTables.tasks
255
+ */
256
+ export function transformGetSchemaResult(
257
+ result: GetSchemaResult,
258
+ schema: ResolvedSchema | undefined,
259
+ tableId: string
260
+ ): GetSchemaResultWithAlias {
261
+ const transformedTable: GetSchemaResultWithAlias['table'] = {
262
+ ...result.table,
263
+ fields: undefined,
264
+ childTables: undefined,
265
+ };
266
+
267
+ // Transform fields to keyed object with extra alias properties
268
+ if (result.table.fields) {
269
+ const fieldsMap: Record<string, SchemaFieldWithAlias> = {};
270
+ for (const field of result.table.fields) {
271
+ const transformed = schema
272
+ ? transformSchemaFieldAliases(field, schema, tableId)
273
+ : field;
274
+ const alias = schema ? getFieldAlias(schema, tableId, field.id) : undefined;
275
+ const key = alias ?? String(field.id);
276
+ fieldsMap[key] = alias ? { ...transformed, alias } : transformed;
277
+ }
278
+ transformedTable.fields = fieldsMap;
279
+ }
280
+
281
+ // Transform child tables to keyed object
282
+ if (result.table.childTables) {
283
+ const childTablesMap: Record<string, SchemaChildTableWithAlias> = {};
284
+ for (const ct of result.table.childTables) {
285
+ const alias = schema ? getTableAlias(schema, ct.dbid) : undefined;
286
+ const key = alias ?? ct.dbid;
287
+ childTablesMap[key] = alias ? { ...ct, alias } : ct;
288
+ }
289
+ transformedTable.childTables = childTablesMap;
290
+ }
291
+
292
+ return {
293
+ ...result,
294
+ table: transformedTable,
295
+ };
296
+ }
297
+
298
+ /**
299
+ * Transform FieldAddChoicesResult to include field alias
300
+ */
301
+ export function transformFieldAddChoicesResult(
302
+ result: FieldAddChoicesResult,
303
+ schema: ResolvedSchema | undefined,
304
+ tableId: string
305
+ ): FieldAddChoicesResultWithAlias {
306
+ if (!schema) return result;
307
+
308
+ const alias = getFieldAlias(schema, tableId, result.fieldId);
309
+ return alias ? { ...result, fieldAlias: alias } : result;
310
+ }
311
+
312
+ /**
313
+ * Transform FieldRemoveChoicesResult to include field alias
314
+ */
315
+ export function transformFieldRemoveChoicesResult(
316
+ result: FieldRemoveChoicesResult,
317
+ schema: ResolvedSchema | undefined,
318
+ tableId: string
319
+ ): FieldRemoveChoicesResultWithAlias {
320
+ if (!schema) return result;
321
+
322
+ const alias = getFieldAlias(schema, tableId, result.fieldId);
323
+ return alias ? { ...result, fieldAlias: alias } : result;
324
+ }
325
+
326
+ /**
327
+ * Transform GrantedDBsResult to key databases by alias.
328
+ * Access: result.databases.projects.dbname
329
+ */
330
+ export function transformGrantedDBsResult(
331
+ result: GrantedDBsResult,
332
+ schema: ResolvedSchema | undefined
333
+ ): GrantedDBsResultWithAlias {
334
+ return {
335
+ ...result,
336
+ databases: databasesArrayToMap(result.databases, schema),
337
+ };
338
+ }
339
+
340
+ /**
341
+ * Transform GrantedDBsForGroupResult to key databases by alias.
342
+ */
343
+ export function transformGrantedDBsForGroupResult(
344
+ result: GrantedDBsForGroupResult,
345
+ schema: ResolvedSchema | undefined
346
+ ): GrantedDBsForGroupResultWithAlias {
347
+ return {
348
+ ...result,
349
+ databases: databasesArrayToMap(result.databases, schema),
350
+ };
351
+ }
352
+
353
+ /**
354
+ * Transform GetAppDTMInfoResult to key tables by alias.
355
+ * Access: result.tables.projects.lastModifiedTime
356
+ */
357
+ export function transformGetAppDTMInfoResult(
358
+ result: GetAppDTMInfoResult,
359
+ schema: ResolvedSchema | undefined
360
+ ): GetAppDTMInfoResultWithAlias {
361
+ const appAlias = schema ? getTableAlias(schema, result.appId) : undefined;
362
+
363
+ return {
364
+ ...result,
365
+ appAlias,
366
+ tables: tablesArrayToMap(result.tables, schema),
367
+ };
368
+ }
369
+
370
+ /**
371
+ * Transform FindDBByNameResult to include table alias
372
+ */
373
+ export function transformFindDBByNameResult(
374
+ result: FindDBByNameResult,
375
+ schema: ResolvedSchema | undefined
376
+ ): FindDBByNameResultWithAlias {
377
+ if (!schema) return result;
378
+
379
+ const alias = getTableAlias(schema, result.dbid);
380
+ return alias ? { ...result, alias } : result;
381
+ }