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.
- package/README.md +145 -1107
- package/dist/auth/ticket.d.ts.map +1 -1
- package/dist/auth/ticket.js +4 -3
- package/dist/auth/ticket.js.map +1 -1
- package/dist/client/request.d.ts +4 -0
- package/dist/client/request.d.ts.map +1 -1
- package/dist/client/request.js +15 -3
- package/dist/client/request.js.map +1 -1
- package/dist/generated/client.d.ts +2 -0
- package/dist/generated/client.d.ts.map +1 -1
- package/dist/generated/client.js +134 -113
- package/dist/generated/client.js.map +1 -1
- package/dist/generated/types.d.ts +2700 -2256
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/generated/types.js +0 -2
- package/dist/generated/types.js.map +1 -1
- package/dist/quickbase.esm.js +3 -3
- package/dist/quickbase.esm.js.map +3 -3
- package/dist/quickbase.min.js +3 -3
- package/dist/quickbase.min.js.map +3 -3
- package/package.json +16 -13
- package/src/auth/index.ts +55 -0
- package/src/auth/sso-token.ts +143 -0
- package/src/auth/temp-token.ts +160 -0
- package/src/auth/ticket.ts +329 -0
- package/src/auth/token-cache.ts +97 -0
- package/src/auth/types.ts +50 -0
- package/src/auth/user-token.ts +38 -0
- package/src/cli/schema.ts +512 -0
- package/src/client/index.ts +36 -0
- package/src/client/pagination.ts +337 -0
- package/src/client/request.ts +544 -0
- package/src/client/retry.ts +169 -0
- package/src/client/throttle.ts +105 -0
- package/src/core/config.ts +160 -0
- package/src/core/dates.ts +63 -0
- package/src/core/errors.ts +349 -0
- package/src/core/index.ts +50 -0
- package/src/core/logger.ts +113 -0
- package/src/core/schema.ts +213 -0
- package/src/core/transform.ts +295 -0
- package/src/core/types.ts +337 -0
- package/src/generated/client.ts +1785 -0
- package/src/generated/operations.json +672 -0
- package/src/generated/types.ts +4884 -0
- package/src/index.ts +259 -0
- package/src/xml/codepages.ts +119 -0
- package/src/xml/dbvars.ts +75 -0
- package/src/xml/errors.ts +133 -0
- package/src/xml/fields.ts +121 -0
- package/src/xml/groups.ts +560 -0
- package/src/xml/html.ts +152 -0
- package/src/xml/index.ts +1196 -0
- package/src/xml/metadata.ts +111 -0
- package/src/xml/records.ts +301 -0
- package/src/xml/request.ts +238 -0
- package/src/xml/roles.ts +321 -0
- package/src/xml/schema.ts +436 -0
- package/src/xml/transform.ts +381 -0
- package/src/xml/types.ts +602 -0
- package/src/xml/users.ts +221 -0
- package/src/xml/webhooks.ts +260 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for the QuickBase SDK v2
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// Configuration Types
|
|
7
|
+
// =============================================================================
|
|
8
|
+
|
|
9
|
+
export interface QuickbaseConfig {
|
|
10
|
+
/** Your QuickBase realm (e.g., "mycompany" for mycompany.quickbase.com) */
|
|
11
|
+
realm: string;
|
|
12
|
+
|
|
13
|
+
/** Authentication configuration */
|
|
14
|
+
auth: AuthConfig;
|
|
15
|
+
|
|
16
|
+
/** Rate limiting and retry configuration */
|
|
17
|
+
rateLimit?: RateLimitConfig;
|
|
18
|
+
|
|
19
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
|
|
22
|
+
/** Enable debug logging (default: false) */
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
|
|
25
|
+
/** Custom fetch implementation (default: global fetch) */
|
|
26
|
+
fetchApi?: typeof fetch;
|
|
27
|
+
|
|
28
|
+
/** Base URL override (default: https://api.quickbase.com/v1) */
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
|
|
31
|
+
/** Automatically paginate all paginated requests when awaited (default: false) */
|
|
32
|
+
autoPaginate?: boolean;
|
|
33
|
+
|
|
34
|
+
/** Convert ISO date strings in responses to JavaScript Date objects (default: true) */
|
|
35
|
+
convertDates?: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Schema aliases for tables and fields.
|
|
39
|
+
* Allows using readable names instead of QuickBase IDs in queries.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* schema: {
|
|
44
|
+
* tables: {
|
|
45
|
+
* projects: {
|
|
46
|
+
* id: 'bqw3ryzab',
|
|
47
|
+
* fields: {
|
|
48
|
+
* name: 6,
|
|
49
|
+
* status: 7,
|
|
50
|
+
* dueDate: 12,
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
schema?: Schema;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Read-only mode prevents any write operations.
|
|
61
|
+
* Uses defense-in-depth with two layers:
|
|
62
|
+
* 1. Explicit blocklist of known write endpoints
|
|
63
|
+
* 2. HTTP method check (blocks POST/PUT/DELETE/PATCH unless allowlisted)
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const qb = createClient({
|
|
68
|
+
* realm: 'myrealm',
|
|
69
|
+
* auth: { type: 'user-token', userToken: '...' },
|
|
70
|
+
* readOnly: true,
|
|
71
|
+
* });
|
|
72
|
+
* // qb.runQuery() works
|
|
73
|
+
* // qb.upsert() throws ReadOnlyError
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
readOnly?: boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Application token for XML API calls.
|
|
80
|
+
*
|
|
81
|
+
* App tokens are only needed for the XML API when:
|
|
82
|
+
* - The app has "Require Application Tokens" enabled, AND
|
|
83
|
+
* - You're NOT using user token authentication (which bypasses app token checks)
|
|
84
|
+
*
|
|
85
|
+
* The JSON API does not use app tokens.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const qb = createClient({
|
|
90
|
+
* realm: 'myrealm',
|
|
91
|
+
* auth: { type: 'ticket', username: 'user@example.com', password: 'pass' },
|
|
92
|
+
* appToken: 'your-app-token',
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
appToken?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// =============================================================================
|
|
100
|
+
// Schema Types
|
|
101
|
+
// =============================================================================
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Field alias mapping: alias name -> field ID
|
|
105
|
+
* @example { name: 6, status: 7, dueDate: 12 }
|
|
106
|
+
*/
|
|
107
|
+
export interface FieldSchema {
|
|
108
|
+
[alias: string]: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Table schema with ID and field mappings
|
|
113
|
+
* @example { id: 'bqw3ryzab', fields: { name: 6, status: 7 } }
|
|
114
|
+
*/
|
|
115
|
+
export interface TableSchema {
|
|
116
|
+
/** QuickBase table ID (dbid) */
|
|
117
|
+
id: string;
|
|
118
|
+
/** Field alias mappings */
|
|
119
|
+
fields: FieldSchema;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Complete schema definition with table aliases
|
|
124
|
+
*/
|
|
125
|
+
export interface Schema {
|
|
126
|
+
tables: {
|
|
127
|
+
[alias: string]: TableSchema;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Resolved schema with bidirectional lookup maps for efficient alias resolution
|
|
133
|
+
*/
|
|
134
|
+
export interface ResolvedSchema {
|
|
135
|
+
/** Original schema definition */
|
|
136
|
+
original: Schema;
|
|
137
|
+
|
|
138
|
+
/** Table alias -> table ID */
|
|
139
|
+
tableAliasToId: Map<string, string>;
|
|
140
|
+
|
|
141
|
+
/** Table ID -> table alias */
|
|
142
|
+
tableIdToAlias: Map<string, string>;
|
|
143
|
+
|
|
144
|
+
/** Table ID -> (field alias -> field ID) */
|
|
145
|
+
fieldAliasToId: Map<string, Map<string, number>>;
|
|
146
|
+
|
|
147
|
+
/** Table ID -> (field ID -> field alias) */
|
|
148
|
+
fieldIdToAlias: Map<string, Map<number, string>>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export type AuthConfig =
|
|
152
|
+
| UserTokenAuthConfig
|
|
153
|
+
| TempTokenAuthConfig
|
|
154
|
+
| SsoTokenAuthConfig
|
|
155
|
+
| TicketAuthConfig;
|
|
156
|
+
|
|
157
|
+
export interface UserTokenAuthConfig {
|
|
158
|
+
type: 'user-token';
|
|
159
|
+
/** Your QuickBase user token */
|
|
160
|
+
userToken: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface TempTokenAuthConfig {
|
|
164
|
+
type: 'temp-token';
|
|
165
|
+
/**
|
|
166
|
+
* User token used to fetch temporary tokens (optional)
|
|
167
|
+
* Not required when running in QuickBase Code Pages - the browser session is used
|
|
168
|
+
*/
|
|
169
|
+
userToken?: string;
|
|
170
|
+
/** App token (optional, for apps that require it) */
|
|
171
|
+
appToken?: string;
|
|
172
|
+
/** Token lifespan in milliseconds (default: 290000 = ~4m50s) */
|
|
173
|
+
tokenLifespanMs?: number;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface SsoTokenAuthConfig {
|
|
177
|
+
type: 'sso';
|
|
178
|
+
/** SAML token for SSO authentication */
|
|
179
|
+
samlToken: string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Ticket authentication using username/password via XML API_Authenticate.
|
|
184
|
+
* Unlike user tokens, tickets properly attribute record changes (createdBy/modifiedBy)
|
|
185
|
+
* to the authenticated user.
|
|
186
|
+
*
|
|
187
|
+
* XML-API-TICKET: Remove this interface if XML API is discontinued.
|
|
188
|
+
*/
|
|
189
|
+
export interface TicketAuthConfig {
|
|
190
|
+
type: 'ticket';
|
|
191
|
+
/** QuickBase username (email address) */
|
|
192
|
+
username: string;
|
|
193
|
+
/** QuickBase password */
|
|
194
|
+
password: string;
|
|
195
|
+
/** Ticket validity in hours (default: 12, max: 4380 ~6 months) */
|
|
196
|
+
hours?: number;
|
|
197
|
+
/** Callback invoked when ticket expires - use to show login UI */
|
|
198
|
+
onExpired?: () => void;
|
|
199
|
+
/** Persist ticket to storage for session survival (default: none) */
|
|
200
|
+
persist?: 'sessionStorage' | 'localStorage';
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface RateLimitConfig {
|
|
204
|
+
/**
|
|
205
|
+
* Client-side proactive throttling (optional)
|
|
206
|
+
* QuickBase allows 100 requests per 10 seconds per user token
|
|
207
|
+
*/
|
|
208
|
+
proactiveThrottle?: {
|
|
209
|
+
enabled: boolean;
|
|
210
|
+
/** Requests allowed per 10 seconds (default: 100) */
|
|
211
|
+
requestsPer10Seconds?: number;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/** Retry configuration for rate limit and server errors */
|
|
215
|
+
retry?: RetryConfig;
|
|
216
|
+
|
|
217
|
+
/** Callback when rate limited */
|
|
218
|
+
onRateLimit?: (info: RateLimitInfo) => void;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface RetryConfig {
|
|
222
|
+
/** Maximum retry attempts (default: 3) */
|
|
223
|
+
maxAttempts?: number;
|
|
224
|
+
/** Initial delay in milliseconds (default: 1000) */
|
|
225
|
+
initialDelayMs?: number;
|
|
226
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
227
|
+
maxDelayMs?: number;
|
|
228
|
+
/** Backoff multiplier (default: 2) */
|
|
229
|
+
multiplier?: number;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// =============================================================================
|
|
233
|
+
// Runtime Types
|
|
234
|
+
// =============================================================================
|
|
235
|
+
|
|
236
|
+
export interface RequestContext {
|
|
237
|
+
/** The API method being called */
|
|
238
|
+
methodName: string;
|
|
239
|
+
/** Current attempt number (1-based) */
|
|
240
|
+
attempt: number;
|
|
241
|
+
/** Maximum attempts allowed */
|
|
242
|
+
maxAttempts: number;
|
|
243
|
+
/** Database ID (for temp token auth) */
|
|
244
|
+
dbid?: string;
|
|
245
|
+
/** Request start timestamp */
|
|
246
|
+
startTime: number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface RateLimitInfo {
|
|
250
|
+
/** When the rate limit occurred */
|
|
251
|
+
timestamp: Date;
|
|
252
|
+
/** The request URL */
|
|
253
|
+
requestUrl: string;
|
|
254
|
+
/** HTTP status code */
|
|
255
|
+
httpStatus: number;
|
|
256
|
+
/** Retry-After header value (seconds) */
|
|
257
|
+
retryAfter?: number;
|
|
258
|
+
/** Cloudflare ray ID */
|
|
259
|
+
cfRay?: string;
|
|
260
|
+
/** Transaction ID */
|
|
261
|
+
tid?: string;
|
|
262
|
+
/** QuickBase API ray ID */
|
|
263
|
+
qbApiRay?: string;
|
|
264
|
+
/** Which retry attempt this was */
|
|
265
|
+
attempt: number;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// =============================================================================
|
|
269
|
+
// Response Types
|
|
270
|
+
// =============================================================================
|
|
271
|
+
|
|
272
|
+
export interface PaginationMetadata {
|
|
273
|
+
totalRecords: number;
|
|
274
|
+
numRecords: number;
|
|
275
|
+
numFields: number;
|
|
276
|
+
skip?: number;
|
|
277
|
+
top?: number;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface PaginatedResponse<T> {
|
|
281
|
+
data: T[];
|
|
282
|
+
metadata: PaginationMetadata;
|
|
283
|
+
fields?: FieldInfo[];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface FieldInfo {
|
|
287
|
+
id: number;
|
|
288
|
+
label: string;
|
|
289
|
+
type: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// =============================================================================
|
|
293
|
+
// Internal Types
|
|
294
|
+
// =============================================================================
|
|
295
|
+
|
|
296
|
+
export interface ResolvedConfig {
|
|
297
|
+
realm: string;
|
|
298
|
+
baseUrl: string;
|
|
299
|
+
timeout: number;
|
|
300
|
+
debug: boolean;
|
|
301
|
+
fetchApi: typeof fetch;
|
|
302
|
+
auth: AuthConfig;
|
|
303
|
+
retry: Required<RetryConfig>;
|
|
304
|
+
proactiveThrottle: {
|
|
305
|
+
enabled: boolean;
|
|
306
|
+
requestsPer10Seconds: number;
|
|
307
|
+
};
|
|
308
|
+
onRateLimit?: (info: RateLimitInfo) => void;
|
|
309
|
+
autoPaginate: boolean;
|
|
310
|
+
convertDates: boolean;
|
|
311
|
+
/** Resolved schema with lookup maps (undefined if no schema provided) */
|
|
312
|
+
schema?: ResolvedSchema;
|
|
313
|
+
/** Read-only mode - blocks all write operations */
|
|
314
|
+
readOnly: boolean;
|
|
315
|
+
/** App token for XML API calls (optional) */
|
|
316
|
+
appToken?: string;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** Default configuration values */
|
|
320
|
+
export const DEFAULT_CONFIG = {
|
|
321
|
+
baseUrl: 'https://api.quickbase.com/v1',
|
|
322
|
+
timeout: 30000,
|
|
323
|
+
debug: false,
|
|
324
|
+
retry: {
|
|
325
|
+
maxAttempts: 3,
|
|
326
|
+
initialDelayMs: 1000,
|
|
327
|
+
maxDelayMs: 30000,
|
|
328
|
+
multiplier: 2,
|
|
329
|
+
},
|
|
330
|
+
proactiveThrottle: {
|
|
331
|
+
enabled: false,
|
|
332
|
+
requestsPer10Seconds: 100,
|
|
333
|
+
},
|
|
334
|
+
tempTokenLifespanMs: 290000, // ~4m50s (QuickBase tokens expire at 5m)
|
|
335
|
+
autoPaginate: false,
|
|
336
|
+
convertDates: true,
|
|
337
|
+
} as const;
|