quickbase-js 0.1.0-beta.12 → 0.1.0-beta.13
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/CHANGELOG.md +12 -0
- package/README.md +48 -18
- package/dist/esm/quickbase.d.ts +12 -3
- package/dist/esm/quickbase.js +416 -49
- package/dist/esm/quickbase.js.map +1 -1
- package/dist/esm/quickbase.min.js +1 -1
- package/dist/esm/quickbase.min.js.map +1 -1
- package/dist/umd/quickbase.umd.js +416 -49
- package/dist/umd/quickbase.umd.js.map +1 -1
- package/dist/umd/quickbase.umd.min.js +1 -1
- package/dist/umd/quickbase.umd.min.js.map +1 -1
- package/package.json +3 -1
- package/src/BurstAwareThrottleBucket.ts +57 -0
- package/src/{ThrottleBucket.ts → FlowThrottleBucket.ts} +5 -35
- package/src/RateThrottleBucket.ts +5 -0
- package/src/Semaphore.ts +33 -0
- package/src/authorizationStrategy.ts +12 -1
- package/src/generated-unified/QuickbaseClient.ts +1 -1
- package/src/invokeMethod.ts +94 -16
- package/src/pagination.ts +429 -0
- package/src/quickbaseClient.ts +56 -28
- package/src/rateLimiter.ts +3 -3
- package/tests/vitest/qb/quickbase-js/BurstAwareThrottleBucket.test.ts +125 -0
- package/tests/vitest/qb/{ThrottleBucket.test.ts → quickbase-js/FlowBucket.test.ts} +1 -1
- package/tests/vitest/qb/quickbase-js/paginationSkip.test.ts +111 -0
- package/tests/vitest/qb/records/runQuery.test.ts +1 -2
- package/tests/vitest/unit/auth/retryUserToken401.test.ts +7 -10
- package/tests/vitest/unit/quickbase-js/BurstAwareThrottleBucket.test.ts +108 -0
- package/tests/vitest/unit/{ThrottleBucket.test.ts → quickbase-js/FlowBucket.test.ts} +5 -5
- package/tests/vitest/unit/quickbase-js/pagination.test.ts +251 -0
- package/tests/vitest/unit/{quickbaseClientHttpMethods.test.ts → quickbase-js/quickbaseClientHttpMethods.test.ts} +13 -11
- package/tests/vitest/unit/records/runQuery.test.ts +3 -4
- package/tests/vitest/unit/umd.test.ts +0 -8
- /package/tests/vitest/unit/{rateLimit.test.ts → quickbase-js/rateLimit.test.ts} +0 -0
- /package/tests/vitest/unit/{tokenLifespan.test.ts → quickbase-js/tokenLifespan.test.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickbase-js",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.13",
|
|
4
4
|
"description": "QuickBase JavaScript client for frameworks and vanilla JS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/quickbase.js",
|
|
@@ -53,12 +53,14 @@
|
|
|
53
53
|
"test:vitest:qb:fields": "vitest run tests/vitest/qb/fields/*.test.ts",
|
|
54
54
|
"test:vitest:qb:records": "vitest run tests/vitest/qb/records/*.test.ts",
|
|
55
55
|
"test:vitest:qb:tables": "vitest run tests/vitest/qb/tables/*.test.ts",
|
|
56
|
+
"test:vitest:qb:quickbase-js": "vitest run tests/vitest/qb/quickbase-js/*.test.ts",
|
|
56
57
|
"test:vitest:unit:apps": "vitest run tests/vitest/unit/apps/*.test.ts",
|
|
57
58
|
"test:vitest:unit:auth": "vitest run tests/vitest/unit/auth/*.test.ts",
|
|
58
59
|
"test:vitest:unit:fields": "vitest run tests/vitest/unit/fields/*.test.ts",
|
|
59
60
|
"test:vitest:unit:formulas": "vitest run tests/vitest/unit/formulas/*.test.ts",
|
|
60
61
|
"test:vitest:unit:records": "vitest run tests/vitest/unit/records/*.test.ts",
|
|
61
62
|
"test:vitest:unit:tables": "vitest run tests/vitest/unit/tables/*.test.ts",
|
|
63
|
+
"test:vitest:unit:quickbase-js": "vitest run tests/vitest/unit/quickbase-js/*.test.ts",
|
|
62
64
|
"test:pw:qb:auth": "playwright test tests/playwright/qb/auth"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/BurstAwareThrottleBucket.ts
|
|
2
|
+
import { Semaphore } from "./Semaphore";
|
|
3
|
+
import { RateThrottleBucket } from "./RateThrottleBucket";
|
|
4
|
+
|
|
5
|
+
export class BurstAwareThrottleBucket implements RateThrottleBucket {
|
|
6
|
+
maxTokens: number;
|
|
7
|
+
windowSeconds: number;
|
|
8
|
+
requestTimestamps: number[] = [];
|
|
9
|
+
semaphore: Semaphore;
|
|
10
|
+
|
|
11
|
+
constructor(options: { maxTokens: number; windowSeconds: number }) {
|
|
12
|
+
this.maxTokens = options.maxTokens;
|
|
13
|
+
this.windowSeconds = options.windowSeconds;
|
|
14
|
+
this.semaphore = new Semaphore(this.maxTokens);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
countRequestsInWindow() {
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
this.requestTimestamps = this.requestTimestamps.filter(
|
|
20
|
+
(ts) => now - ts < this.windowSeconds * 1000
|
|
21
|
+
);
|
|
22
|
+
return this.requestTimestamps.length;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
availableTokens() {
|
|
26
|
+
const windowCount = this.countRequestsInWindow();
|
|
27
|
+
return Math.max(
|
|
28
|
+
0,
|
|
29
|
+
Math.min(100 - windowCount, this.maxTokens - windowCount)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async acquire() {
|
|
34
|
+
while (true) {
|
|
35
|
+
const available = this.availableTokens();
|
|
36
|
+
if (available > 0 && this.semaphore.available() > 0) {
|
|
37
|
+
await this.semaphore.acquire();
|
|
38
|
+
this.requestTimestamps.push(Date.now());
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
const oldestTimestamp = this.requestTimestamps[0];
|
|
43
|
+
let waitTime = 100;
|
|
44
|
+
if (oldestTimestamp) {
|
|
45
|
+
waitTime = Math.max(
|
|
46
|
+
0,
|
|
47
|
+
this.windowSeconds * 1000 - (now - oldestTimestamp)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
release() {
|
|
55
|
+
this.semaphore.release();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
1
|
+
// src/FlowThrottleBucket.ts
|
|
2
|
+
import { Semaphore } from "./Semaphore";
|
|
3
|
+
import { RateThrottleBucket } from "./RateThrottleBucket";
|
|
4
|
+
|
|
5
|
+
export class FlowThrottleBucket implements RateThrottleBucket {
|
|
3
6
|
private tokens: number;
|
|
4
7
|
private maxTokens: number;
|
|
5
8
|
private refillRate: number;
|
|
@@ -42,36 +45,3 @@ export class ConcurrentThrottleBucket {
|
|
|
42
45
|
this.semaphore.release();
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
class Semaphore {
|
|
47
|
-
private permits: number;
|
|
48
|
-
private waiting: Array<{ resolve: () => void; reject: (err: any) => void }> =
|
|
49
|
-
[];
|
|
50
|
-
|
|
51
|
-
constructor(maxPermits: number) {
|
|
52
|
-
this.permits = maxPermits;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async acquire(): Promise<void> {
|
|
56
|
-
if (this.permits > 0) {
|
|
57
|
-
this.permits -= 1;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
return new Promise((resolve, reject) => {
|
|
61
|
-
this.waiting.push({ resolve, reject });
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
release(): void {
|
|
66
|
-
this.permits += 1;
|
|
67
|
-
if (this.waiting.length > 0 && this.permits > 0) {
|
|
68
|
-
const { resolve } = this.waiting.shift()!;
|
|
69
|
-
this.permits -= 1;
|
|
70
|
-
resolve();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
available(): number {
|
|
75
|
-
return this.permits;
|
|
76
|
-
}
|
|
77
|
-
}
|
package/src/Semaphore.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/Semaphore.ts
|
|
2
|
+
export class Semaphore {
|
|
3
|
+
private permits: number;
|
|
4
|
+
private waiting: Array<{ resolve: () => void; reject: (err: any) => void }> =
|
|
5
|
+
[];
|
|
6
|
+
|
|
7
|
+
constructor(maxPermits: number) {
|
|
8
|
+
this.permits = maxPermits;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async acquire(): Promise<void> {
|
|
12
|
+
if (this.permits > 0) {
|
|
13
|
+
this.permits -= 1;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
this.waiting.push({ resolve, reject });
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
release(): void {
|
|
22
|
+
this.permits += 1;
|
|
23
|
+
if (this.waiting.length > 0 && this.permits > 0) {
|
|
24
|
+
const { resolve } = this.waiting.shift()!;
|
|
25
|
+
this.permits -= 1;
|
|
26
|
+
resolve();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
available(): number {
|
|
31
|
+
return this.permits;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// src/authorizationStrategy.ts
|
|
2
1
|
import { TokenCache } from "./tokenCache";
|
|
3
2
|
|
|
4
3
|
export interface AuthorizationStrategy {
|
|
@@ -109,6 +108,12 @@ export class TempTokenStrategy implements AuthorizationStrategy {
|
|
|
109
108
|
const newToken = await this.getToken(dbid);
|
|
110
109
|
if (newToken) {
|
|
111
110
|
this.tokenCache.set(dbid, newToken);
|
|
111
|
+
if (debug)
|
|
112
|
+
console.log(
|
|
113
|
+
`[${
|
|
114
|
+
methodName || "method"
|
|
115
|
+
}] Retrying with token: ${newToken.substring(0, 10)}...`
|
|
116
|
+
);
|
|
112
117
|
return newToken;
|
|
113
118
|
}
|
|
114
119
|
return null;
|
|
@@ -213,6 +218,12 @@ export class SsoTokenStrategy implements AuthorizationStrategy {
|
|
|
213
218
|
const newToken = await this.refreshSsoToken(debug || this.debug);
|
|
214
219
|
if (newToken) {
|
|
215
220
|
this.currentToken = newToken;
|
|
221
|
+
if (debug || this.debug)
|
|
222
|
+
console.log(
|
|
223
|
+
`[${
|
|
224
|
+
methodName || "method"
|
|
225
|
+
}] Retrying with token: ${newToken.substring(0, 10)}...`
|
|
226
|
+
);
|
|
216
227
|
return newToken;
|
|
217
228
|
}
|
|
218
229
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated on 2025-03-
|
|
1
|
+
// Generated on 2025-03-25T22:56:49.051Z
|
|
2
2
|
import { AddManagersToGroup200Response, AddManagersToGroupRequest, AddMembersToGroup200Response, AddMembersToGroupRequest, AddSubgroupsToGroup200Response, AddSubgroupsToGroupRequest, Audit200Response, ChangesetSolution200Response, ChangesetSolutionFromRecord200Response, CloneUserToken200Response, CopyApp200Response, CopyAppRequest, CreateApp200Response, CreateAppRequest, CreateField200Response, CreateFieldRequest, CreateRelationship200Response, CreateRelationshipRequest, CreateSolution200Response, CreateSolutionFromRecord200Response, CreateTable200Response, CreateTableRequest, DeactivateUserToken200Response, DeleteApp200Response, DeleteAppRequest, DeleteFields200Response, DeleteFieldsRequest, DeleteFile200Response, DeleteRecords200Response, DeleteRecordsRequest, DeleteRelationship200Response, DeleteTable200Response, DeleteUserToken200Response, DenyUsers200Response, DenyUsersAndGroups200Response, DenyUsersAndGroupsRequest, DenyUsersRequest, DownloadFile200Response, ExchangeSsoToken200Response, ExportSolution200Response, ExportSolutionToRecord200Response, GenerateDocument200Response, GetApp200Response, GetAppEvents200Response, GetAppTables200Response, GetField200Response, GetFieldUsage200Response, GetFields200Response, GetFieldsUsage200Response, GetRelationships200Response, GetReport200Response, GetTable200Response, GetTableReports200Response, GetTempTokenDBID200Response, GetUsers200Response, GetUsersRequest, PlatformAnalyticEventSummaries200Response, PlatformAnalyticReads200Response, RemoveManagersFromGroup200Response, RemoveManagersFromGroupRequest, RemoveMembersFromGroup200Response, RemoveMembersFromGroupRequest, RemoveSubgroupsFromGroup200Response, RemoveSubgroupsFromGroupRequest, RunFormula200Response, RunQuery200Response, RunQueryRequest, RunReport200Response, TransferUserToken200Response, UndenyUsers200Response, UndenyUsersRequest, UpdateApp200Response, UpdateAppRequest, UpdateField200Response, UpdateFieldRequest, UpdateRelationship200Response, UpdateRelationshipRequest, UpdateSolution200Response, UpdateSolutionToRecord200Response, UpdateTable200Response, UpdateTableRequest, Upsert200Response, Upsert207Response, UpsertRequest } from "../generated/models";
|
|
3
3
|
|
|
4
4
|
export interface QuickbaseClient {
|
package/src/invokeMethod.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// src/invokeMethod.ts
|
|
2
1
|
import { AuthorizationStrategy, extractDbid } from "./authorizationStrategy";
|
|
3
2
|
import { RateLimiter } from "./rateLimiter";
|
|
4
3
|
import { RateLimitError } from "./RateLimitError";
|
|
5
4
|
import { ResponseError } from "./generated/runtime";
|
|
6
5
|
import { QuickbaseClient } from "./quickbaseClient";
|
|
6
|
+
import { paginateRecords, isPaginatable } from "./pagination";
|
|
7
7
|
|
|
8
8
|
export type ApiMethod<K extends keyof QuickbaseClient> = (
|
|
9
9
|
requestParameters: Parameters<QuickbaseClient[K]>[0],
|
|
@@ -17,13 +17,34 @@ export interface MethodInfo<K extends keyof QuickbaseClient> {
|
|
|
17
17
|
httpMethod: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Invokes a Quick Base API method with the specified parameters, handling authentication, rate limiting, and pagination.
|
|
22
|
+
* @template K - The method name keyof QuickbaseClient.
|
|
23
|
+
* @param methodName - The API method to invoke (e.g., "runQuery", "changesetSolution").
|
|
24
|
+
* @param params - Parameters for the API method, potentially including skip, top, or a body.
|
|
25
|
+
* @param methodMap - Mapping of method names to their implementation details.
|
|
26
|
+
* @param baseHeaders - Base HTTP headers for API requests.
|
|
27
|
+
* @param authStrategy - Strategy for handling authentication tokens.
|
|
28
|
+
* @param rateLimiter - Rate limiting mechanism to respect API limits.
|
|
29
|
+
* @param transformDates - Function to transform date strings in the response.
|
|
30
|
+
* @param debug - If true, logs detailed invocation information.
|
|
31
|
+
* @param convertDates - If true, converts date strings to Date objects in the response.
|
|
32
|
+
* @param autoPaginate - If true, automatically paginates multi-page responses (default: true).
|
|
33
|
+
* @param attempt - Current retry attempt (default: 0).
|
|
34
|
+
* @param maxAttempts - Maximum number of retry attempts (default: rateLimiter.maxRetries + 1).
|
|
35
|
+
* @param isPaginating - Indicates if this call is part of an ongoing pagination (default: false).
|
|
36
|
+
* @returns A promise resolving to the API method's response.
|
|
37
|
+
* @throws {Error} If the method is not found or retries are exhausted.
|
|
38
|
+
*/
|
|
20
39
|
export async function invokeMethod<K extends keyof QuickbaseClient>(
|
|
21
40
|
methodName: K,
|
|
22
41
|
params: Parameters<QuickbaseClient[K]>[0] & {
|
|
23
42
|
dbid?: string;
|
|
24
43
|
tableId?: string;
|
|
25
44
|
appId?: string;
|
|
26
|
-
startTime?: number;
|
|
45
|
+
startTime?: number;
|
|
46
|
+
skip?: number;
|
|
47
|
+
top?: number;
|
|
27
48
|
},
|
|
28
49
|
methodMap: { [P in keyof QuickbaseClient]: MethodInfo<P> },
|
|
29
50
|
baseHeaders: Record<string, string>,
|
|
@@ -32,26 +53,46 @@ export async function invokeMethod<K extends keyof QuickbaseClient>(
|
|
|
32
53
|
transformDates: (obj: any, convertStringsToDates: boolean) => any,
|
|
33
54
|
debug: boolean | undefined,
|
|
34
55
|
convertDates: boolean,
|
|
56
|
+
autoPaginate: boolean = true,
|
|
35
57
|
attempt: number = 0,
|
|
36
|
-
maxAttempts: number = rateLimiter.maxRetries + 1
|
|
58
|
+
maxAttempts: number = rateLimiter.maxRetries + 1,
|
|
59
|
+
isPaginating: boolean = false
|
|
37
60
|
): Promise<ReturnType<QuickbaseClient[K]>> {
|
|
38
61
|
const methodInfo = methodMap[methodName];
|
|
39
62
|
if (!methodInfo) throw new Error(`Method ${methodName} not found`);
|
|
40
63
|
|
|
41
64
|
const hasBody = "body" in params && params.body !== undefined;
|
|
42
65
|
const body = hasBody ? params.body : undefined;
|
|
66
|
+
// Safely check for options only if body is an object
|
|
67
|
+
const options =
|
|
68
|
+
hasBody && body && typeof body === "object" && "options" in body
|
|
69
|
+
? (body as any).options
|
|
70
|
+
: undefined;
|
|
71
|
+
const adjustedParams = {
|
|
72
|
+
...params,
|
|
73
|
+
skip:
|
|
74
|
+
params.skip ?? (options && "skip" in options ? options.skip : undefined),
|
|
75
|
+
top: params.top ?? (options && "top" in options ? options.top : undefined),
|
|
76
|
+
};
|
|
77
|
+
|
|
43
78
|
const restParams: any = hasBody
|
|
44
79
|
? Object.fromEntries(
|
|
45
|
-
Object.entries(
|
|
80
|
+
Object.entries(adjustedParams).filter(
|
|
46
81
|
([key]) => key !== "body" && key !== "startTime"
|
|
47
82
|
)
|
|
48
83
|
)
|
|
49
|
-
: { ...
|
|
84
|
+
: { ...adjustedParams, startTime: undefined };
|
|
50
85
|
const requestParameters: any = {
|
|
51
86
|
...restParams,
|
|
52
87
|
...(hasBody ? { generated: body } : {}),
|
|
53
88
|
};
|
|
54
89
|
|
|
90
|
+
if (debug)
|
|
91
|
+
console.log(
|
|
92
|
+
"[invokeMethod] Adjusted params for pagination:",
|
|
93
|
+
adjustedParams
|
|
94
|
+
);
|
|
95
|
+
|
|
55
96
|
const requestOptions: RequestInit = {
|
|
56
97
|
credentials: methodName === "getTempTokenDBID" ? "include" : "omit",
|
|
57
98
|
method: methodInfo.httpMethod,
|
|
@@ -81,6 +122,25 @@ export async function invokeMethod<K extends keyof QuickbaseClient>(
|
|
|
81
122
|
?.toLowerCase();
|
|
82
123
|
if (contentType?.includes("application/json")) {
|
|
83
124
|
const jsonResponse = await rawResponse.json();
|
|
125
|
+
if (autoPaginate && !isPaginating && isPaginatable(jsonResponse)) {
|
|
126
|
+
if (debug)
|
|
127
|
+
console.log(
|
|
128
|
+
"[invokeMethod] Entering pagination with params:",
|
|
129
|
+
adjustedParams
|
|
130
|
+
);
|
|
131
|
+
return paginateRecords(
|
|
132
|
+
methodName,
|
|
133
|
+
adjustedParams,
|
|
134
|
+
methodMap,
|
|
135
|
+
baseHeaders,
|
|
136
|
+
authStrategy,
|
|
137
|
+
rateLimiter,
|
|
138
|
+
transformDates,
|
|
139
|
+
debug,
|
|
140
|
+
convertDates,
|
|
141
|
+
jsonResponse
|
|
142
|
+
);
|
|
143
|
+
}
|
|
84
144
|
return transformDates(jsonResponse, convertDates) as ReturnType<
|
|
85
145
|
QuickbaseClient[K]
|
|
86
146
|
>;
|
|
@@ -89,6 +149,25 @@ export async function invokeMethod<K extends keyof QuickbaseClient>(
|
|
|
89
149
|
}
|
|
90
150
|
if (rawResponse && typeof rawResponse.value === "function") {
|
|
91
151
|
const response = await rawResponse.value();
|
|
152
|
+
if (autoPaginate && !isPaginating && isPaginatable(response)) {
|
|
153
|
+
if (debug)
|
|
154
|
+
console.log(
|
|
155
|
+
"[invokeMethod] Entering pagination with params:",
|
|
156
|
+
adjustedParams
|
|
157
|
+
);
|
|
158
|
+
return paginateRecords(
|
|
159
|
+
methodName,
|
|
160
|
+
adjustedParams,
|
|
161
|
+
methodMap,
|
|
162
|
+
baseHeaders,
|
|
163
|
+
authStrategy,
|
|
164
|
+
rateLimiter,
|
|
165
|
+
transformDates,
|
|
166
|
+
debug,
|
|
167
|
+
convertDates,
|
|
168
|
+
response
|
|
169
|
+
);
|
|
170
|
+
}
|
|
92
171
|
return transformDates(response, convertDates) as ReturnType<
|
|
93
172
|
QuickbaseClient[K]
|
|
94
173
|
>;
|
|
@@ -135,13 +214,16 @@ export async function invokeMethod<K extends keyof QuickbaseClient>(
|
|
|
135
214
|
try {
|
|
136
215
|
await rateLimiter.throttle();
|
|
137
216
|
acquired = true;
|
|
138
|
-
const postThrottleTime = Date.now();
|
|
139
|
-
if (params.startTime !== undefined) params.startTime = postThrottleTime;
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
217
|
+
const postThrottleTime = Date.now();
|
|
218
|
+
if (params.startTime !== undefined) params.startTime = postThrottleTime;
|
|
219
|
+
const headers = { ...baseHeaders };
|
|
220
|
+
const finalRequest = { ...requestParameters, headers };
|
|
221
|
+
if (debug) console.log("[invokeMethod] Sending request:", finalRequest);
|
|
222
|
+
const responsePromise = methodInfo.method(finalRequest, {
|
|
223
|
+
...requestOptions,
|
|
224
|
+
headers,
|
|
225
|
+
});
|
|
226
|
+
rateLimiter.release();
|
|
145
227
|
const response = await responsePromise;
|
|
146
228
|
return await processResponse(response);
|
|
147
229
|
} catch (error: unknown) {
|
|
@@ -197,10 +279,6 @@ export async function invokeMethod<K extends keyof QuickbaseClient>(
|
|
|
197
279
|
token = newToken;
|
|
198
280
|
authStrategy.applyHeaders(baseHeaders, token);
|
|
199
281
|
requestOptions.headers = { ...baseHeaders };
|
|
200
|
-
if (debug)
|
|
201
|
-
console.log(
|
|
202
|
-
`[${methodName}] Retrying with token: ${token.substring(0, 10)}...`
|
|
203
|
-
);
|
|
204
282
|
attempt++;
|
|
205
283
|
continue;
|
|
206
284
|
}
|