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,12 +0,0 @@
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
- }
@@ -1,41 +0,0 @@
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
- }
@@ -1,246 +0,0 @@
1
- // src/authorizationStrategy.ts
2
-
3
- import { TokenCache } from "./tokenCache";
4
-
5
- export interface AuthorizationStrategy {
6
- getToken(dbid: string): Promise<string | undefined>;
7
- applyHeaders(headers: Record<string, string>, token: string): void;
8
- handleError(
9
- status: number,
10
- params: any,
11
- fetchTempToken: (dbid: string) => Promise<string>,
12
- attempt: number,
13
- maxAttempts: number,
14
- debug?: boolean,
15
- methodName?: string
16
- ): Promise<string | null>;
17
- }
18
-
19
- export class TempTokenStrategy implements AuthorizationStrategy {
20
- constructor(
21
- private tokenCache: TokenCache,
22
- private initialTempToken?: string
23
- ) {}
24
-
25
- async getToken(dbid: string): Promise<string | undefined> {
26
- return this.tokenCache.get(dbid) || this.initialTempToken;
27
- }
28
-
29
- applyHeaders(headers: Record<string, string>, token: string): void {
30
- headers["Authorization"] = `QB-TEMP-TOKEN ${token}`;
31
- }
32
-
33
- async handleError(
34
- status: number,
35
- params: any,
36
- fetchTempToken: (dbid: string) => Promise<string>,
37
- attempt: number,
38
- maxAttempts: number,
39
- debug?: boolean,
40
- methodName?: string
41
- ): Promise<string | null> {
42
- if (status !== 401 || attempt >= maxAttempts - 1) return null;
43
- if (debug)
44
- console.log(
45
- `Authorization error for ${
46
- methodName || "method"
47
- } (temp token), refreshing token:`
48
- );
49
- const dbid = extractDbid(params);
50
- if (!dbid) {
51
- if (debug)
52
- console.log(
53
- `No dbid available for ${
54
- methodName || "method"
55
- }, skipping token refresh`
56
- );
57
- return null;
58
- }
59
- if (debug) console.log(`Refreshing temp token for dbid: ${dbid}`);
60
- const newToken = await fetchTempToken(dbid);
61
- this.tokenCache.set(dbid, newToken);
62
- return newToken;
63
- }
64
- }
65
-
66
- export class UserTokenStrategy implements AuthorizationStrategy {
67
- constructor(private userToken: string) {}
68
-
69
- async getToken(_dbid: string): Promise<string> {
70
- return this.userToken;
71
- }
72
-
73
- applyHeaders(headers: Record<string, string>, token: string): void {
74
- headers["Authorization"] = `QB-USER-TOKEN ${token}`;
75
- }
76
-
77
- async handleError(
78
- status: number,
79
- _params: any,
80
- _fetchTempToken: (dbid: string) => Promise<string>,
81
- attempt: number,
82
- maxAttempts: number,
83
- debug?: boolean,
84
- methodName?: string
85
- ): Promise<string | null> {
86
- if (status !== 401 || attempt >= maxAttempts - 1) return null;
87
- if (debug)
88
- console.log(
89
- `Retrying ${
90
- methodName || "method"
91
- } with existing user token: ${this.userToken.substring(0, 10)}...`
92
- );
93
- return this.userToken;
94
- }
95
- }
96
-
97
- export class SsoTokenStrategy implements AuthorizationStrategy {
98
- private currentToken: string | undefined;
99
-
100
- constructor(
101
- private samlToken: string,
102
- private realm: string,
103
- private fetchApi: typeof fetch,
104
- private debug: boolean = false
105
- ) {}
106
-
107
- async getToken(_dbid: string): Promise<string | undefined> {
108
- if (!this.currentToken) {
109
- this.currentToken = await this.fetchSsoToken({
110
- grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
111
- requested_token_type:
112
- "urn:quickbase:params:oauth:token-type:temp_token",
113
- subject_token: this.samlToken,
114
- subject_token_type: "urn:ietf:params:oauth:token-type:saml2",
115
- });
116
- }
117
- return this.currentToken;
118
- }
119
-
120
- applyHeaders(headers: Record<string, string>, token: string): void {
121
- headers["Authorization"] = `QB-TEMP-TOKEN ${token}`;
122
- }
123
-
124
- async handleError(
125
- status: number,
126
- _params: any,
127
- _fetchTempToken: (dbid: string) => Promise<string>,
128
- attempt: number,
129
- maxAttempts: number,
130
- debug?: boolean,
131
- methodName?: string
132
- ): Promise<string | null> {
133
- if (status !== 401 || attempt >= maxAttempts - 1) return null;
134
-
135
- if (debug || this.debug) {
136
- console.log(
137
- `Authorization error for ${
138
- methodName || "method"
139
- } (SSO), refreshing token`
140
- );
141
- }
142
-
143
- const newToken = await this.refreshSsoToken(debug || this.debug);
144
- if (newToken) {
145
- this.currentToken = newToken;
146
- return newToken;
147
- }
148
- return null;
149
- }
150
-
151
- private async refreshSsoToken(debug: boolean = false): Promise<string> {
152
- const payload = {
153
- grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
154
- requested_token_type: "urn:quickbase:params:oauth:token-type:temp_token",
155
- subject_token: this.samlToken,
156
- subject_token_type: "urn:ietf:params:oauth:token-type:saml2",
157
- };
158
-
159
- const response = await this.fetchApi(
160
- `https://api.quickbase.com/v1/auth/oauth/token`,
161
- {
162
- method: "POST",
163
- headers: {
164
- "QB-Realm-Hostname": `${this.realm}.quickbase.com`,
165
- "Content-Type": "application/json",
166
- },
167
- body: JSON.stringify(payload),
168
- credentials: "omit",
169
- }
170
- );
171
-
172
- if (!response.ok) {
173
- const errorBody = await response.json().catch(() => ({}));
174
- if (debug) {
175
- console.log(`[SSO Refresh] Failed: ${response.status}`, errorBody);
176
- }
177
- throw new Error(
178
- `SSO token refresh failed: ${errorBody.message || "Unknown error"}`
179
- );
180
- }
181
-
182
- const result = await response.json();
183
- const newToken = result.access_token;
184
- if (!newToken) {
185
- throw new Error("No access token returned from SSO token exchange");
186
- }
187
-
188
- if (debug) {
189
- console.log(`[SSO Refresh] New token: ${newToken.substring(0, 10)}...`);
190
- }
191
- return newToken;
192
- }
193
-
194
- private async fetchSsoToken(params: {
195
- grant_type: string;
196
- requested_token_type: string;
197
- subject_token: string;
198
- subject_token_type: string;
199
- }): Promise<string> {
200
- const response = await this.fetchApi(
201
- `https://api.quickbase.com/v1/auth/oauth/token`,
202
- {
203
- method: "POST",
204
- headers: {
205
- "QB-Realm-Hostname": `${this.realm}.quickbase.com`,
206
- "Content-Type": "application/json",
207
- },
208
- body: JSON.stringify(params),
209
- credentials: "omit",
210
- }
211
- );
212
-
213
- if (!response.ok) {
214
- const errorBody = await response.json().catch(() => ({}));
215
- if (this.debug) {
216
- console.log(`[fetchSsoToken] Failed: ${response.status}`, errorBody);
217
- }
218
- throw new Error(
219
- `SSO token fetch failed: ${errorBody.message || "Unknown error"}`
220
- );
221
- }
222
-
223
- const result = await response.json();
224
- const newToken = result.access_token;
225
- if (!newToken) {
226
- throw new Error("No access token returned from SSO token exchange");
227
- }
228
-
229
- if (this.debug) {
230
- console.log(
231
- `[fetchSsoToken] Fetched token: ${newToken.substring(0, 10)}...`
232
- );
233
- }
234
- return newToken;
235
- }
236
- }
237
-
238
- export function extractDbid(params: any): string | undefined {
239
- return (
240
- params.dbid ||
241
- params.tableId ||
242
- params.appId ||
243
- params.body?.from ||
244
- params.body?.to
245
- );
246
- }