quickbase-js 2.4.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 (46) hide show
  1. package/README.md +144 -76
  2. package/dist/quickbase.esm.js +3 -3
  3. package/dist/quickbase.min.js +3 -3
  4. package/dist/quickbase.min.js.map +1 -1
  5. package/package.json +13 -9
  6. package/src/auth/index.ts +55 -0
  7. package/src/auth/sso-token.ts +143 -0
  8. package/src/auth/temp-token.ts +160 -0
  9. package/src/auth/ticket.ts +329 -0
  10. package/src/auth/token-cache.ts +97 -0
  11. package/src/auth/types.ts +50 -0
  12. package/src/auth/user-token.ts +38 -0
  13. package/src/cli/schema.ts +512 -0
  14. package/src/client/index.ts +36 -0
  15. package/src/client/pagination.ts +337 -0
  16. package/src/client/request.ts +544 -0
  17. package/src/client/retry.ts +169 -0
  18. package/src/client/throttle.ts +105 -0
  19. package/src/core/config.ts +160 -0
  20. package/src/core/dates.ts +63 -0
  21. package/src/core/errors.ts +349 -0
  22. package/src/core/index.ts +50 -0
  23. package/src/core/logger.ts +113 -0
  24. package/src/core/schema.ts +213 -0
  25. package/src/core/transform.ts +295 -0
  26. package/src/core/types.ts +337 -0
  27. package/src/generated/client.ts +1785 -0
  28. package/src/generated/operations.json +672 -0
  29. package/src/generated/types.ts +4884 -0
  30. package/src/index.ts +259 -0
  31. package/src/xml/codepages.ts +119 -0
  32. package/src/xml/dbvars.ts +75 -0
  33. package/src/xml/errors.ts +133 -0
  34. package/src/xml/fields.ts +121 -0
  35. package/src/xml/groups.ts +560 -0
  36. package/src/xml/html.ts +152 -0
  37. package/src/xml/index.ts +1196 -0
  38. package/src/xml/metadata.ts +111 -0
  39. package/src/xml/records.ts +301 -0
  40. package/src/xml/request.ts +238 -0
  41. package/src/xml/roles.ts +321 -0
  42. package/src/xml/schema.ts +436 -0
  43. package/src/xml/transform.ts +381 -0
  44. package/src/xml/types.ts +602 -0
  45. package/src/xml/users.ts +221 -0
  46. package/src/xml/webhooks.ts +260 -0
@@ -0,0 +1,602 @@
1
+ /**
2
+ * XML API Types
3
+ *
4
+ * Type definitions for the legacy QuickBase XML API.
5
+ *
6
+ * XML-API: Remove this file when QuickBase discontinues the XML API.
7
+ * To find all XML API code, search for: XML-API
8
+ */
9
+
10
+ /**
11
+ * Minimal interface for making XML API calls.
12
+ * This interface avoids circular dependencies between the xml package
13
+ * and the main client.
14
+ */
15
+ export interface XmlCaller {
16
+ /**
17
+ * Get the QuickBase realm name (e.g., "mycompany")
18
+ */
19
+ realm(): string;
20
+
21
+ /**
22
+ * Execute an XML API request
23
+ * @param dbid - The database ID to make the request against
24
+ * @param action - The QUICKBASE-ACTION header value (e.g., "API_GetRoleInfo")
25
+ * @param body - The XML request body (wrapped in <qdbapi> tags)
26
+ * @returns The raw XML response body as a string
27
+ */
28
+ doXml(dbid: string, action: string, body: string): Promise<string>;
29
+ }
30
+
31
+ /**
32
+ * Base structure for all XML API responses.
33
+ * Every XML response contains these fields.
34
+ */
35
+ export interface BaseResponse {
36
+ action: string;
37
+ errcode: number;
38
+ errtext: string;
39
+ errdetail?: string;
40
+ }
41
+
42
+ // ============================================================================
43
+ // Role Types
44
+ // ============================================================================
45
+
46
+ /**
47
+ * Access level for a role
48
+ */
49
+ export interface RoleAccess {
50
+ /** Access level ID: 1=Administrator, 2=Basic Access with Share, 3=Basic Access */
51
+ id: number;
52
+ /** Text description of the access level */
53
+ description: string;
54
+ }
55
+
56
+ /**
57
+ * A role defined in a QuickBase application
58
+ */
59
+ export interface Role {
60
+ /** Unique role ID */
61
+ id: number;
62
+ /** Display name of the role */
63
+ name: string;
64
+ /** Access level granted by this role */
65
+ access: RoleAccess;
66
+ }
67
+
68
+ /**
69
+ * Role with membership information (from GetUserRole)
70
+ */
71
+ export interface UserRole extends Role {
72
+ /** How this role was assigned (only present when includeGroups=true) */
73
+ member?: RoleMember;
74
+ }
75
+
76
+ /**
77
+ * Describes how a role was assigned to a user
78
+ */
79
+ export interface RoleMember {
80
+ /** "user", "group", or "domainGroup" */
81
+ type: string;
82
+ /** Name of the user or group */
83
+ name: string;
84
+ }
85
+
86
+ /**
87
+ * User with their assigned roles
88
+ */
89
+ export interface UserWithRoles {
90
+ /** QuickBase user ID (e.g., "112149.bhsv") */
91
+ id: string;
92
+ /** "user" for individual users or "group" for groups */
93
+ type: string;
94
+ /** Display name */
95
+ name: string;
96
+ /** First name (may be empty for groups) */
97
+ firstName?: string;
98
+ /** Last name (may be empty for groups) */
99
+ lastName?: string;
100
+ /** Timestamp of last access (milliseconds since epoch) */
101
+ lastAccess?: string;
102
+ /** Human-readable last access time */
103
+ lastAccessAppLocal?: string;
104
+ /** Roles assigned to this user */
105
+ roles: Role[];
106
+ }
107
+
108
+ // ============================================================================
109
+ // Group Types
110
+ // ============================================================================
111
+
112
+ /**
113
+ * A QuickBase group
114
+ */
115
+ export interface Group {
116
+ /** Group ID (e.g., "1217.dgpt") */
117
+ id: string;
118
+ /** Group name */
119
+ name: string;
120
+ /** Group description */
121
+ description?: string;
122
+ /** Whether the group is managed by a user (vs. system) */
123
+ managedByUser?: boolean;
124
+ }
125
+
126
+ /**
127
+ * User within a group
128
+ */
129
+ export interface GroupUser {
130
+ /** User ID */
131
+ id: string;
132
+ /** First name */
133
+ firstName: string;
134
+ /** Last name */
135
+ lastName: string;
136
+ /** Email address */
137
+ email: string;
138
+ /** Screen name */
139
+ screenName?: string;
140
+ /** Whether the user is an admin */
141
+ isAdmin?: boolean;
142
+ }
143
+
144
+ /**
145
+ * Manager of a group
146
+ */
147
+ export interface GroupManager {
148
+ /** Manager ID */
149
+ id: string;
150
+ /** First name */
151
+ firstName: string;
152
+ /** Last name */
153
+ lastName: string;
154
+ /** Email address */
155
+ email: string;
156
+ /** Screen name */
157
+ screenName?: string;
158
+ /** Whether the manager is also a member */
159
+ isMember?: boolean;
160
+ }
161
+
162
+ /**
163
+ * Subgroup reference
164
+ */
165
+ export interface Subgroup {
166
+ /** Subgroup ID */
167
+ id: string;
168
+ }
169
+
170
+ // ============================================================================
171
+ // User Types
172
+ // ============================================================================
173
+
174
+ /**
175
+ * User information from GetUserInfo
176
+ */
177
+ export interface UserInfo {
178
+ /** QuickBase user ID */
179
+ id: string;
180
+ /** First name */
181
+ firstName: string;
182
+ /** Last name */
183
+ lastName: string;
184
+ /** Login name (may be undefined for anonymous users or when email was provided) */
185
+ login?: string;
186
+ /** Email address (may be undefined for anonymous users) */
187
+ email?: string;
188
+ /** Screen name */
189
+ screenName?: string;
190
+ /** Whether the user's email is verified */
191
+ isVerified?: boolean;
192
+ /** Whether the user uses external authentication (SSO) */
193
+ externalAuth?: boolean;
194
+ }
195
+
196
+ // ============================================================================
197
+ // Schema Types
198
+ // ============================================================================
199
+
200
+ /**
201
+ * Field definition from GetSchema
202
+ */
203
+ export interface SchemaField {
204
+ /** Field ID */
205
+ id: number;
206
+ /** Field type (e.g., "text", "numeric", "date") */
207
+ fieldType: string;
208
+ /** Base type (e.g., "text", "int64") */
209
+ baseType?: string;
210
+ /** Field mode (e.g., "lookup", "formula") */
211
+ mode?: string;
212
+ /** Field label */
213
+ label: string;
214
+ /** Help text */
215
+ fieldHelp?: string;
216
+ /** Whether field is required */
217
+ required?: boolean;
218
+ /** Whether field must be unique */
219
+ unique?: boolean;
220
+ /** No text wrap */
221
+ nowrap?: boolean;
222
+ /** Bold text */
223
+ bold?: boolean;
224
+ /** Appears by default in reports */
225
+ appearsByDefault?: boolean;
226
+ /** Find enabled */
227
+ findEnabled?: boolean;
228
+ /** Allow new choices (for multi-choice fields) */
229
+ allowNewChoices?: boolean;
230
+ /** Sort choices as given */
231
+ sortAsGiven?: boolean;
232
+ /** Carry choices */
233
+ carryChoices?: boolean;
234
+ /** Is foreign key */
235
+ foreignKey?: boolean;
236
+ /** Does total */
237
+ doesTotal?: boolean;
238
+ /** Does average */
239
+ doesAverage?: boolean;
240
+ /** Default value kind */
241
+ defaultKind?: string;
242
+ /** Default value */
243
+ defaultValue?: string;
244
+ /** Choices for multi-choice fields */
245
+ choices?: string[];
246
+ /** Summary reference field ID */
247
+ summaryReferenceFid?: number;
248
+ /** Summary target field ID */
249
+ summaryTargetFid?: number;
250
+ /** Summary function (Total, Average, etc.) */
251
+ summaryFunction?: string;
252
+ }
253
+
254
+ /**
255
+ * Query/Report definition from GetSchema
256
+ */
257
+ export interface SchemaQuery {
258
+ /** Query ID */
259
+ id: number;
260
+ /** Query name */
261
+ name: string;
262
+ /** Query type (e.g., "table", "calendar") */
263
+ type?: string;
264
+ /** Query description */
265
+ description?: string;
266
+ /** Query criteria */
267
+ criteria?: string;
268
+ /** Column list */
269
+ columnList?: string;
270
+ /** Sort list */
271
+ sortList?: string;
272
+ /** Query options */
273
+ options?: string;
274
+ /** Calculated fields list */
275
+ calcFields?: string;
276
+ }
277
+
278
+ /**
279
+ * Application variable from GetSchema
280
+ */
281
+ export interface SchemaVariable {
282
+ /** Variable name */
283
+ name: string;
284
+ /** Variable value */
285
+ value: string;
286
+ }
287
+
288
+ /**
289
+ * Child table reference from GetSchema
290
+ */
291
+ export interface SchemaChildTable {
292
+ /** Child table name reference */
293
+ name: string;
294
+ /** Child table DBID */
295
+ dbid: string;
296
+ }
297
+
298
+ /**
299
+ * Original info block from GetSchema
300
+ */
301
+ export interface SchemaOriginal {
302
+ appId?: string;
303
+ tableId?: string;
304
+ /** Creation time (ms since epoch) */
305
+ createdTime?: string;
306
+ /** Modification time (ms since epoch) */
307
+ modifiedTime?: string;
308
+ nextRecordId?: number;
309
+ nextFieldId?: number;
310
+ nextQueryId?: number;
311
+ defaultSortFid?: number;
312
+ defaultSortOrder?: number;
313
+ }
314
+
315
+ /**
316
+ * Table/App schema from GetSchema
317
+ */
318
+ export interface SchemaTable {
319
+ /** Table/App name */
320
+ name: string;
321
+ /** Description */
322
+ description?: string;
323
+ /** Original metadata */
324
+ original?: SchemaOriginal;
325
+ /** Application variables */
326
+ variables?: SchemaVariable[];
327
+ /** Child tables (for app-level schema) */
328
+ childTables?: SchemaChildTable[];
329
+ /** Fields (for table-level schema) */
330
+ fields?: SchemaField[];
331
+ /** Queries/Reports */
332
+ queries?: SchemaQuery[];
333
+ }
334
+
335
+ // ============================================================================
336
+ // App Discovery Types
337
+ // ============================================================================
338
+
339
+ /**
340
+ * Database info from GrantedDBs
341
+ */
342
+ export interface DatabaseInfo {
343
+ /** Database ID */
344
+ dbid: string;
345
+ /** Database name */
346
+ name: string;
347
+ /** Ancestor app ID (if copied from another app) */
348
+ ancestorAppId?: string;
349
+ /** Oldest ancestor app ID */
350
+ oldestAncestorAppId?: string;
351
+ }
352
+
353
+ /**
354
+ * Database info from GetDBInfo
355
+ */
356
+ export interface DBInfo {
357
+ /** Database/table name */
358
+ name: string;
359
+ /** Number of records */
360
+ numRecords: number;
361
+ /** Manager's user ID */
362
+ managerId?: string;
363
+ /** Manager's name */
364
+ managerName?: string;
365
+ /** Last record modification time (ms since epoch) */
366
+ lastRecModTime?: string;
367
+ /** Last schema modification time (ms since epoch) */
368
+ lastModifiedTime?: string;
369
+ /** Creation time (ms since epoch) */
370
+ createdTime?: string;
371
+ /** Time zone */
372
+ timeZone?: string;
373
+ /** Version */
374
+ version?: string;
375
+ }
376
+
377
+ // ============================================================================
378
+ // Record Types
379
+ // ============================================================================
380
+
381
+ /**
382
+ * Field value from GetRecordInfo
383
+ */
384
+ export interface RecordField {
385
+ /** Field ID */
386
+ id: number;
387
+ /** Field name */
388
+ name: string;
389
+ /** Field type */
390
+ type: string;
391
+ /** Raw value */
392
+ value: string;
393
+ /** Human-readable value (for dates, etc.) */
394
+ printable?: string;
395
+ }
396
+
397
+ // ============================================================================
398
+ // Code Page Types
399
+ // ============================================================================
400
+
401
+ /**
402
+ * Page type for AddReplaceDBPage
403
+ */
404
+ export enum PageType {
405
+ /** XSL stylesheet or HTML page */
406
+ XSLOrHTML = 1,
407
+ /** Exact Form */
408
+ ExactForm = 3,
409
+ }
410
+
411
+ // ============================================================================
412
+ // Webhook Types
413
+ // ============================================================================
414
+
415
+ /**
416
+ * Webhook trigger type.
417
+ * Can be combined, e.g., 'adm' for all triggers.
418
+ */
419
+ export type WebhookTrigger = 'a' | 'd' | 'm' | 'ad' | 'am' | 'dm' | 'adm';
420
+
421
+ /**
422
+ * Webhook message format
423
+ */
424
+ export type WebhookMessageFormat = 'XML' | 'JSON' | 'RAW';
425
+
426
+ /**
427
+ * Webhook HTTP verb
428
+ */
429
+ export type WebhookHTTPVerb = 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
430
+
431
+ /**
432
+ * Webhook header key-value pair
433
+ */
434
+ export interface WebhookHeader {
435
+ key: string;
436
+ value: string;
437
+ }
438
+
439
+ /**
440
+ * Options for creating a webhook
441
+ */
442
+ export interface WebhooksCreateOptions {
443
+ /** A unique name for the webhook (required) */
444
+ label: string;
445
+ /** Endpoint URL - must start with https:// (required) */
446
+ webhookUrl: string;
447
+ /** Description of the webhook */
448
+ description?: string;
449
+ /** Filter criteria to trigger the webhook */
450
+ query?: string;
451
+ /** When to trigger: 'a' (add), 'd' (delete), 'm' (modify), or combinations like 'adm' */
452
+ workflowWhen?: WebhookTrigger;
453
+ /** HTTP headers for the webhook request */
454
+ headers?: WebhookHeader[];
455
+ /** Payload of the webhook (empty by default) */
456
+ message?: string;
457
+ /** Format of the payload: XML (default), JSON, or RAW */
458
+ messageFormat?: WebhookMessageFormat;
459
+ /** HTTP method: POST (default), GET, PUT, PATCH, DELETE */
460
+ httpVerb?: WebhookHTTPVerb;
461
+ /** Field IDs - webhook fires only when these fields change. If empty, fires on any change. */
462
+ triggerFields?: number[];
463
+ }
464
+
465
+ /**
466
+ * Options for editing a webhook
467
+ */
468
+ export interface WebhooksEditOptions extends WebhooksCreateOptions {
469
+ /** When true, clears the field trigger criteria (fires on any field) */
470
+ clearTriggerFields?: boolean;
471
+ }
472
+
473
+ /**
474
+ * Legacy webhook options (deprecated - use WebhooksCreateOptions)
475
+ * @deprecated Use WebhooksCreateOptions instead
476
+ */
477
+ export interface WebhookOptions {
478
+ /** Webhook name */
479
+ name?: string;
480
+ /** URL to call */
481
+ url?: string;
482
+ /** Trigger type */
483
+ trigger?: string;
484
+ }
485
+
486
+ // ============================================================================
487
+ // Result Types (returned by XmlClient methods)
488
+ // ============================================================================
489
+
490
+ export interface GetRoleInfoResult {
491
+ roles: Role[];
492
+ }
493
+
494
+ export interface UserRolesResult {
495
+ users: UserWithRoles[];
496
+ }
497
+
498
+ export interface GetUserRoleResult {
499
+ userId: string;
500
+ userName: string;
501
+ roles: UserRole[];
502
+ }
503
+
504
+ export interface GetSchemaResult {
505
+ timeZone?: string;
506
+ dateFormat?: string;
507
+ table: SchemaTable;
508
+ }
509
+
510
+ export interface GrantedDBsResult {
511
+ databases: DatabaseInfo[];
512
+ }
513
+
514
+ export interface FindDBByNameResult {
515
+ dbid: string;
516
+ /** Echoed from request (may not always be present) */
517
+ name?: string;
518
+ }
519
+
520
+ export interface GetUsersInGroupResult {
521
+ id: string;
522
+ name: string;
523
+ description?: string;
524
+ users: GroupUser[];
525
+ managers: GroupManager[];
526
+ subgroups: Subgroup[];
527
+ }
528
+
529
+ export interface CreateGroupResult {
530
+ group: Group;
531
+ }
532
+
533
+ export interface GetGroupRoleResult {
534
+ roles: Array<{ id: number; name: string }>;
535
+ }
536
+
537
+ export interface ProvisionUserResult {
538
+ userId: string;
539
+ }
540
+
541
+ export interface AddReplaceDBPageResult {
542
+ pageId: number;
543
+ }
544
+
545
+ export interface FieldAddChoicesResult {
546
+ fieldId: number;
547
+ fieldName: string;
548
+ numAdded: number;
549
+ }
550
+
551
+ export interface FieldRemoveChoicesResult {
552
+ fieldId: number;
553
+ fieldName: string;
554
+ numRemoved: number;
555
+ }
556
+
557
+ export interface DoQueryCountResult {
558
+ numMatches: number;
559
+ }
560
+
561
+ export interface GetRecordInfoResult {
562
+ recordId: number;
563
+ numFields: number;
564
+ updateId?: string;
565
+ fields: RecordField[];
566
+ }
567
+
568
+ export interface GrantedGroupsResult {
569
+ groups: Array<{ id: string; name: string }>;
570
+ }
571
+
572
+ export interface GrantedDBsForGroupResult {
573
+ databases: Array<{ dbid: string; name: string }>;
574
+ }
575
+
576
+ export interface GetAppDTMInfoResult {
577
+ appId: string;
578
+ lastModifiedTime?: string;
579
+ lastRecModTime?: string;
580
+ tables: Array<{ id: string; lastModifiedTime?: string; lastRecModTime?: string }>;
581
+ }
582
+
583
+ export interface GetAncestorInfoResult {
584
+ ancestorAppId?: string;
585
+ oldestAncestorAppId?: string;
586
+ }
587
+
588
+ export interface ImportFromCSVResult {
589
+ numRecsAdded: number;
590
+ numRecsUpdated: number;
591
+ numRecsInput: number;
592
+ recordIds: Array<{ recordId: number; updateId?: string }>;
593
+ }
594
+
595
+ export interface CopyMasterDetailResult {
596
+ newRid: number;
597
+ numCreated: number;
598
+ }
599
+
600
+ export interface WebhookResult {
601
+ webhookId: number;
602
+ }