quickbase-js 0.1.0-beta.12 → 0.1.0-beta.14
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 +48 -18
- package/dist/esm/quickbase.d.ts +13 -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 +11 -4
- package/CHANGELOG.md +0 -227
- package/build-common.js +0 -131
- package/build-esm.js +0 -71
- package/build-umd.js +0 -69
- package/docs/.vitepress/cache/deps/@theme_index.js +0 -275
- package/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
- package/docs/.vitepress/cache/deps/_metadata.json +0 -40
- package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js +0 -12542
- package/docs/.vitepress/cache/deps/chunk-5A67QEFC.js.map +0 -7
- package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js +0 -9719
- package/docs/.vitepress/cache/deps/chunk-7D4P4MMP.js.map +0 -7
- package/docs/.vitepress/cache/deps/package.json +0 -3
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4504
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -583
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
- package/docs/.vitepress/cache/deps/vue.js +0 -343
- package/docs/.vitepress/cache/deps/vue.js.map +0 -7
- package/docs/.vitepress/config.mts +0 -26
- package/docs/api-examples.md +0 -49
- package/docs/index.md +0 -59
- package/docs/markdown-examples.md +0 -85
- package/docs-data/api-docs.json +0 -4143
- package/examples/quicbase-jsCDN.html +0 -36
- package/examples/react.js +0 -48
- package/examples/vanillajs.html +0 -47
- package/index.md +0 -25
- package/open-api/fix-spec-main.ts +0 -133
- package/open-api/generate-unified-interface.ts +0 -104
- package/open-api/generateDocsJson.ts +0 -24
- package/open-api/output/quickbase-fixed.json +0 -11191
- package/open-api/post-process-generated.ts +0 -226
- package/open-api/regenerate-client.ts +0 -117
- package/open-api/schema/enhance-general.ts +0 -111
- package/open-api/schema/fix-arrays.ts +0 -68
- package/open-api/schema/tags/apps.ts +0 -90
- package/open-api/schema/tags/fields.ts +0 -471
- package/open-api/schema/tags/groups.ts +0 -51
- package/open-api/schema/tags/index.ts +0 -66
- package/open-api/schema/tags/records.ts +0 -115
- package/open-api/schema/tags/tables.ts +0 -211
- package/open-api/schema/tags/users.ts +0 -47
- package/open-api/types/spec.ts +0 -42
- package/open-api/utils/common.ts +0 -29
- package/open-api/utils/generateJsDoc.ts +0 -74
- package/open-api/utils/infer-schema.ts +0 -40
- package/open-api/utils/naming.ts +0 -10
- package/open-api/utils/sharedUtils.ts +0 -352
- package/playwright.config.ts +0 -37
- package/rollup.config.js +0 -114
- package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -46878
- package/specs/split/apps.json +0 -1315
- package/specs/split/auth.json +0 -191
- package/specs/split/fields.json +0 -3869
- package/specs/split/records.json +0 -754
- package/specs/split/reports.json +0 -619
- package/specs/split/tables.json +0 -1605
- package/src/RateLimitError.ts +0 -12
- package/src/ThrottleBucket.ts +0 -77
- package/src/authorizationStrategy.ts +0 -310
- package/src/generated-unified/QuickbaseClient.ts +0 -1135
- package/src/generated-unified/missing-types-report.json +0 -3
- package/src/index.ts +0 -1
- package/src/invokeMethod.ts +0 -212
- package/src/quickbaseClient.ts +0 -199
- package/src/rateLimiter.ts +0 -30
- package/src/tokenCache.ts +0 -39
- package/src/utils.ts +0 -50
- package/tests/playwright/qb/auth/cacheSwitching.test.ts +0 -159
- package/tests/playwright/qb/auth/fetchTempToken401.test.ts +0 -219
- package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +0 -162
- package/tests/playwright/qb/auth/getAppWithTempTokenConcurrency.test.ts +0 -208
- package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +0 -153
- package/tests/playwright/qb/auth/getTempToken.test.ts +0 -152
- package/tests/playwright/qb/auth/tempTokenPrefetch.test.ts +0 -179
- package/tests/playwright/qb/auth/tempTokenRenewal.test.ts +0 -133
- package/tests/setup.ts +0 -53
- package/tests/vitest/qb/ThrottleBucket.test.ts +0 -77
- package/tests/vitest/qb/apps/copyApp.test.ts +0 -76
- package/tests/vitest/qb/apps/createApp.test.ts +0 -64
- package/tests/vitest/qb/apps/deleteApp.test.ts +0 -76
- package/tests/vitest/qb/apps/getApp.test.ts +0 -44
- package/tests/vitest/qb/apps/getAppEvents.test.ts +0 -67
- package/tests/vitest/qb/apps/updateApp.test.ts +0 -58
- package/tests/vitest/qb/auth/mockQuickbaseServer.ts +0 -60
- package/tests/vitest/qb/auth/retryUserToken401.test.ts +0 -73
- package/tests/vitest/qb/auth/ssoTokenConcurrency.test.ts +0 -68
- package/tests/vitest/qb/auth/ssoTokenIntegrationWithServer.test.ts +0 -65
- package/tests/vitest/qb/auth/userTokenConcurrency.test.ts +0 -63
- package/tests/vitest/qb/fields/createField.test.ts +0 -77
- package/tests/vitest/qb/fields/deleteFields.test.ts +0 -83
- package/tests/vitest/qb/fields/getField.test.ts +0 -85
- package/tests/vitest/qb/fields/getFieldUsage.test.ts +0 -82
- package/tests/vitest/qb/fields/getFields.test.ts +0 -232
- package/tests/vitest/qb/fields/getFieldsUsage.test.ts +0 -77
- package/tests/vitest/qb/fields/updateField.test.ts +0 -93
- package/tests/vitest/qb/formulas/runFormula.test.ts +0 -96
- package/tests/vitest/qb/index.ts +0 -29
- package/tests/vitest/qb/records/deleteRecords.test.ts +0 -110
- package/tests/vitest/qb/records/runQuery.test.ts +0 -146
- package/tests/vitest/qb/records/upsert.test.ts +0 -102
- package/tests/vitest/qb/tables/createRelationship.test.ts +0 -102
- package/tests/vitest/qb/tables/createTable.test.ts +0 -55
- package/tests/vitest/qb/tables/deleteRelationship.test.ts +0 -143
- package/tests/vitest/qb/tables/deleteTable.test.ts +0 -50
- package/tests/vitest/qb/tables/getAppTables.test.ts +0 -46
- package/tests/vitest/qb/tables/getRelationships.test.ts +0 -80
- package/tests/vitest/qb/tables/getTable.test.ts +0 -26
- package/tests/vitest/qb/tables/updateRelationship.test.ts +0 -250
- package/tests/vitest/qb/tables/updateTable.test.ts +0 -48
- package/tests/vitest/unit/ThrottleBucket.test.ts +0 -101
- package/tests/vitest/unit/apps/copyApp.test.ts +0 -581
- package/tests/vitest/unit/apps/createApp.test.ts +0 -186
- package/tests/vitest/unit/apps/deleteApp.test.ts +0 -216
- package/tests/vitest/unit/apps/getApp.test.ts +0 -128
- package/tests/vitest/unit/apps/getAppConcurrency.test.ts +0 -151
- package/tests/vitest/unit/apps/getAppEvents.test.ts +0 -193
- package/tests/vitest/unit/apps/updateApp.test.ts +0 -412
- package/tests/vitest/unit/auth/fetchTempToken401.test.ts +0 -81
- package/tests/vitest/unit/auth/getTempToken.test.ts +0 -119
- package/tests/vitest/unit/auth/retryTempToken401.test.ts +0 -95
- package/tests/vitest/unit/auth/retryTempTokenMaxRetries.test.ts +0 -206
- package/tests/vitest/unit/auth/retryUserToken401.test.ts +0 -69
- package/tests/vitest/unit/auth/ssoTokenRefresh.test.ts +0 -325
- package/tests/vitest/unit/auth/userTokenConcurrency.test.ts +0 -62
- package/tests/vitest/unit/fields/createField.test.ts +0 -451
- package/tests/vitest/unit/fields/deleteFields.test.ts +0 -141
- package/tests/vitest/unit/fields/getField.test.ts +0 -189
- package/tests/vitest/unit/fields/getFieldUsage.test.ts +0 -180
- package/tests/vitest/unit/fields/getFields.test.ts +0 -122
- package/tests/vitest/unit/fields/getFieldsUsage.test.ts +0 -160
- package/tests/vitest/unit/fields/updateField.test.ts +0 -285
- package/tests/vitest/unit/formulas/runFormula.test.ts +0 -205
- package/tests/vitest/unit/index.ts +0 -34
- package/tests/vitest/unit/quickbaseClientHttpMethods.test.ts +0 -139
- package/tests/vitest/unit/rateLimit.test.ts +0 -191
- package/tests/vitest/unit/records/deleteRecords.test.ts +0 -112
- package/tests/vitest/unit/records/runQuery.test.ts +0 -102
- package/tests/vitest/unit/records/upsert.test.ts +0 -234
- package/tests/vitest/unit/tables/createRelationship.test.ts +0 -212
- package/tests/vitest/unit/tables/createTable.test.ts +0 -70
- package/tests/vitest/unit/tables/deleteRelationship.test.ts +0 -97
- package/tests/vitest/unit/tables/deleteTable.test.ts +0 -77
- package/tests/vitest/unit/tables/getAppTables.test.ts +0 -85
- package/tests/vitest/unit/tables/getRelationships.test.ts +0 -259
- package/tests/vitest/unit/tables/getTable.test.ts +0 -233
- package/tests/vitest/unit/tables/updateRelationship.test.ts +0 -307
- package/tests/vitest/unit/tables/updateTable.test.ts +0 -80
- package/tests/vitest/unit/tokenLifespan.test.ts +0 -204
- package/tests/vitest/unit/umd.test.ts +0 -8
- package/tools/log-gen.ts +0 -251
- package/tools/log-gen.yaml +0 -4829
- package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
- package/tsconfig.build.json +0 -17
- package/tsconfig.json +0 -32
- package/versionrc.json +0 -9
- package/vitest.config.ts +0 -27
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// tests/vitest/qb/ThrottleBucket.test.ts
|
|
2
|
-
import { describe, it, expect } from "vitest";
|
|
3
|
-
import { quickbase } from "../../../src/quickbaseClient";
|
|
4
|
-
|
|
5
|
-
describe("QuickbaseClient with ConcurrentThrottleBucket Integration Tests", () => {
|
|
6
|
-
it("handles concurrent API calls with burst and rate limiting in strict order", async () => {
|
|
7
|
-
const mockFetch = async (
|
|
8
|
-
url: string,
|
|
9
|
-
options: RequestInit
|
|
10
|
-
): Promise<Response> => {
|
|
11
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
12
|
-
return new Response(JSON.stringify({ id: "mock-app" }), {
|
|
13
|
-
status: 200,
|
|
14
|
-
headers: { "Content-Type": "application/json" },
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const qbClient = quickbase({
|
|
19
|
-
realm: "test",
|
|
20
|
-
userToken: "mock-token",
|
|
21
|
-
throttle: { rate: 5, burst: 3 },
|
|
22
|
-
fetchApi: mockFetch,
|
|
23
|
-
debug: true,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const throttleTimes: number[] = [];
|
|
27
|
-
const startTimes: number[] = new Array(6).fill(0);
|
|
28
|
-
const completionTimes: number[] = [];
|
|
29
|
-
const recordTime = async (index: number) => {
|
|
30
|
-
const preThrottle = Date.now();
|
|
31
|
-
throttleTimes[index] = preThrottle;
|
|
32
|
-
await qbClient.getApp({
|
|
33
|
-
appId: "mock-app-id",
|
|
34
|
-
startTime: startTimes[index],
|
|
35
|
-
});
|
|
36
|
-
completionTimes[index] = Date.now();
|
|
37
|
-
startTimes[index] = startTimes[index] || Date.now() - 500;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const startTime = Date.now();
|
|
41
|
-
const promises = [];
|
|
42
|
-
for (let i = 0; i < 6; i++) {
|
|
43
|
-
promises.push(recordTime(i));
|
|
44
|
-
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
45
|
-
}
|
|
46
|
-
await Promise.all(promises);
|
|
47
|
-
|
|
48
|
-
const relativeThrottleTimes = throttleTimes.map((t) => t - startTime);
|
|
49
|
-
const relativeStartTimes = startTimes.map((t) => t - startTime);
|
|
50
|
-
const durations = completionTimes.map((t) => t - startTime);
|
|
51
|
-
const timings = completionTimes.map((t, i) => t - startTimes[i]);
|
|
52
|
-
|
|
53
|
-
console.log("Relative Throttle Times:", relativeThrottleTimes);
|
|
54
|
-
console.log("Relative Start Times (post-throttle):", relativeStartTimes);
|
|
55
|
-
console.log("Durations (completion times):", durations);
|
|
56
|
-
console.log("Timings (fetch durations):", timings);
|
|
57
|
-
console.log("Total Duration:", Date.now() - startTime);
|
|
58
|
-
|
|
59
|
-
const totalDuration = Date.now() - startTime;
|
|
60
|
-
expect(totalDuration).toBeGreaterThanOrEqual(1000);
|
|
61
|
-
expect(totalDuration).toBeLessThan(1200); // Adjusted back to ~1100ms
|
|
62
|
-
|
|
63
|
-
expect(durations.length).toBe(6);
|
|
64
|
-
expect(durations.slice(0, 3).every((d) => d >= 500 && d < 550)).toBe(true);
|
|
65
|
-
|
|
66
|
-
// Sort durations to handle out-of-order completion
|
|
67
|
-
const sortedDurations = [...durations].sort((a, b) => a - b);
|
|
68
|
-
expect(sortedDurations[3]).toBeGreaterThanOrEqual(650);
|
|
69
|
-
expect(sortedDurations[3]).toBeLessThan(750);
|
|
70
|
-
expect(sortedDurations[4]).toBeGreaterThanOrEqual(850);
|
|
71
|
-
expect(sortedDurations[4]).toBeLessThan(950);
|
|
72
|
-
expect(sortedDurations[5]).toBeGreaterThanOrEqual(1050);
|
|
73
|
-
expect(sortedDurations[5]).toBeLessThan(1150);
|
|
74
|
-
|
|
75
|
-
expect(timings.every((t) => t >= 500 && t < 550)).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// tests/vitest/qb/apps/copyApp.test.ts
|
|
2
|
-
import { test, expect } from "vitest";
|
|
3
|
-
import { quickbase } from "../../../../src/quickbaseClient";
|
|
4
|
-
|
|
5
|
-
test(
|
|
6
|
-
"QuickbaseClient Integration - copyApp > creates a new copied app in QuickBase",
|
|
7
|
-
{ timeout: 30000 }, // Increased to 30 seconds
|
|
8
|
-
async () => {
|
|
9
|
-
const config = {
|
|
10
|
-
realm: process.env.QB_REALM || "",
|
|
11
|
-
userToken: process.env.QB_USER_TOKEN || "",
|
|
12
|
-
debug: true,
|
|
13
|
-
};
|
|
14
|
-
const client = quickbase(config);
|
|
15
|
-
const appId = process.env.QB_APP_ID || ""; // The source app ID to copy from
|
|
16
|
-
|
|
17
|
-
const copyAppName = `CopiedApp_${Date.now()}`; // Unique name to avoid conflicts
|
|
18
|
-
const copyBody = {
|
|
19
|
-
name: copyAppName,
|
|
20
|
-
description: "Test copied app",
|
|
21
|
-
properties: {
|
|
22
|
-
keepData: false,
|
|
23
|
-
excludeFiles: true,
|
|
24
|
-
usersAndRoles: false,
|
|
25
|
-
assignUserToken: true,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
console.log("Config used:", {
|
|
30
|
-
...config,
|
|
31
|
-
userToken: config.userToken ? "[REDACTED]" : "", // Avoid logging sensitive token
|
|
32
|
-
});
|
|
33
|
-
console.log("Copying app with:", copyBody);
|
|
34
|
-
const startTime = Date.now();
|
|
35
|
-
let response;
|
|
36
|
-
try {
|
|
37
|
-
response = await client.copyApp({ appId, body: copyBody });
|
|
38
|
-
const duration = Date.now() - startTime;
|
|
39
|
-
console.log(`copyApp completed in ${duration}ms`);
|
|
40
|
-
console.log("Real API response:", response);
|
|
41
|
-
|
|
42
|
-
expect(response).toBeDefined();
|
|
43
|
-
expect(response.id).toBeDefined();
|
|
44
|
-
expect(response.name).toBe(copyAppName);
|
|
45
|
-
expect(response.description).toBe(copyBody.description);
|
|
46
|
-
expect(response.created).toBeInstanceOf(Date);
|
|
47
|
-
expect(response.updated).toBeInstanceOf(Date);
|
|
48
|
-
expect(response.dateFormat).toMatch(/^\w{2}-\w{2}-\w{4}$/); // e.g., "MM-DD-YYYY"
|
|
49
|
-
expect(typeof response.timeZone).toBe("string"); // Simplified check
|
|
50
|
-
expect(typeof response.hasEveryoneOnTheInternet).toBe("boolean");
|
|
51
|
-
expect(response.ancestorId).toBe(appId); // Should match the source app ID
|
|
52
|
-
expect(
|
|
53
|
-
response.dataClassification === undefined ||
|
|
54
|
-
typeof response.dataClassification === "string"
|
|
55
|
-
).toBe(true); // Allow undefined or string
|
|
56
|
-
expect(
|
|
57
|
-
response.variables === undefined || Array.isArray(response.variables)
|
|
58
|
-
).toBe(true); // Allow undefined or array
|
|
59
|
-
} catch (error) {
|
|
60
|
-
const duration = Date.now() - startTime;
|
|
61
|
-
console.error(`copyApp failed after ${duration}ms:`, error);
|
|
62
|
-
throw error; // Re-throw to fail the test
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Cleanup: Delete the copied app using deleteApp
|
|
66
|
-
const deleteStartTime = Date.now();
|
|
67
|
-
const deleteResponse = await client.deleteApp({
|
|
68
|
-
appId: response.id,
|
|
69
|
-
body: { name: copyAppName },
|
|
70
|
-
});
|
|
71
|
-
const deleteDuration = Date.now() - deleteStartTime;
|
|
72
|
-
console.log(`deleteApp completed in ${deleteDuration}ms`);
|
|
73
|
-
console.log("Cleanup - Deleted app:", deleteResponse);
|
|
74
|
-
expect(deleteResponse.deletedAppId).toBe(response.id);
|
|
75
|
-
}
|
|
76
|
-
);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// tests/vitest/qb/apps/createApp.test.ts
|
|
2
|
-
import { test, expect } from "vitest";
|
|
3
|
-
import { quickbase } from "../../../../src/quickbaseClient";
|
|
4
|
-
|
|
5
|
-
test(
|
|
6
|
-
"QuickbaseClient Integration - createApp > creates a new app in QuickBase",
|
|
7
|
-
{ timeout: 30000 },
|
|
8
|
-
async () => {
|
|
9
|
-
const config = {
|
|
10
|
-
realm: process.env.QB_REALM || "",
|
|
11
|
-
userToken: process.env.QB_USER_TOKEN || "",
|
|
12
|
-
debug: true,
|
|
13
|
-
useTempTokens: false,
|
|
14
|
-
};
|
|
15
|
-
const client = quickbase(config);
|
|
16
|
-
|
|
17
|
-
const appName = `TestApp_${Date.now()}`;
|
|
18
|
-
const createBody = {
|
|
19
|
-
name: appName,
|
|
20
|
-
description: "Test app creation",
|
|
21
|
-
assignToken: true,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
console.log("Config used:", {
|
|
25
|
-
...config,
|
|
26
|
-
userToken: config.userToken ? "[REDACTED]" : "",
|
|
27
|
-
});
|
|
28
|
-
console.log("Creating app with:", createBody);
|
|
29
|
-
const createStartTime = Date.now();
|
|
30
|
-
let response;
|
|
31
|
-
try {
|
|
32
|
-
response = await client.createApp({ body: createBody });
|
|
33
|
-
const createDuration = Date.now() - createStartTime;
|
|
34
|
-
console.log(`createApp completed in ${createDuration}ms`);
|
|
35
|
-
console.log("Real API response:", response);
|
|
36
|
-
|
|
37
|
-
expect(response).toBeDefined();
|
|
38
|
-
expect(response.id).toBeDefined();
|
|
39
|
-
expect(response.name).toBe(appName);
|
|
40
|
-
expect(response.description).toBe(createBody.description);
|
|
41
|
-
expect(response.created).toBeInstanceOf(Date);
|
|
42
|
-
expect(response.updated).toBeInstanceOf(Date);
|
|
43
|
-
expect(response.dateFormat).toMatch(/^\w{2}-\w{2}-\w{4}$/);
|
|
44
|
-
expect(typeof response.timeZone).toBe("string");
|
|
45
|
-
expect(typeof response.hasEveryoneOnTheInternet).toBe("boolean");
|
|
46
|
-
expect(
|
|
47
|
-
response.dataClassification === undefined ||
|
|
48
|
-
typeof response.dataClassification === "string"
|
|
49
|
-
).toBe(true);
|
|
50
|
-
expect(
|
|
51
|
-
response.variables === undefined || Array.isArray(response.variables)
|
|
52
|
-
).toBe(true);
|
|
53
|
-
|
|
54
|
-
// Cleanup: Delete the app after assertions
|
|
55
|
-
const deleteBody = { name: appName };
|
|
56
|
-
await client.deleteApp({ appId: response.id, body: deleteBody });
|
|
57
|
-
console.log("Cleanup: App deleted:", response.id);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
const createDuration = Date.now() - createStartTime;
|
|
60
|
-
console.error(`createApp failed after ${createDuration}ms:`, error);
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
);
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// tests/vitest/qb/apps/deleteApp.test.ts
|
|
2
|
-
import { test, expect } from "vitest";
|
|
3
|
-
import { quickbase } from "../../../../src/quickbaseClient";
|
|
4
|
-
|
|
5
|
-
test(
|
|
6
|
-
"QuickbaseClient Integration - deleteApp > deletes an app in QuickBase",
|
|
7
|
-
{ timeout: 30000 },
|
|
8
|
-
async () => {
|
|
9
|
-
const config = {
|
|
10
|
-
realm: process.env.QB_REALM || "",
|
|
11
|
-
userToken: process.env.QB_USER_TOKEN || "",
|
|
12
|
-
debug: true,
|
|
13
|
-
useTempTokens: false,
|
|
14
|
-
};
|
|
15
|
-
const client = quickbase(config);
|
|
16
|
-
|
|
17
|
-
const appName = `TempApp_${Date.now()}`;
|
|
18
|
-
const createBody = {
|
|
19
|
-
name: appName,
|
|
20
|
-
description: "Temporary app for deleteApp test",
|
|
21
|
-
assignToken: true, // Match createApp.test.ts
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
console.log("Config used:", {
|
|
25
|
-
...config,
|
|
26
|
-
userToken: config.userToken ? "[REDACTED]" : "",
|
|
27
|
-
});
|
|
28
|
-
console.log("Creating temporary app with:", createBody);
|
|
29
|
-
const createStartTime = Date.now();
|
|
30
|
-
let createResponse;
|
|
31
|
-
try {
|
|
32
|
-
createResponse = await client.createApp({ body: createBody });
|
|
33
|
-
const createDuration = Date.now() - createStartTime;
|
|
34
|
-
console.log(`createApp completed in ${createDuration}ms`);
|
|
35
|
-
console.log("Created app response:", createResponse);
|
|
36
|
-
|
|
37
|
-
expect(createResponse).toBeDefined();
|
|
38
|
-
expect(createResponse.id).toBeDefined();
|
|
39
|
-
expect(createResponse.name).toBe(appName);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
const createDuration = Date.now() - createStartTime;
|
|
42
|
-
console.error(`createApp failed after ${createDuration}ms:`, error);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const deleteBody = {
|
|
47
|
-
name: appName,
|
|
48
|
-
};
|
|
49
|
-
console.log("Deleting app with:", deleteBody);
|
|
50
|
-
const deleteStartTime = Date.now();
|
|
51
|
-
try {
|
|
52
|
-
const deleteResponse = await client.deleteApp({
|
|
53
|
-
appId: createResponse.id,
|
|
54
|
-
body: deleteBody,
|
|
55
|
-
});
|
|
56
|
-
const deleteDuration = Date.now() - deleteStartTime;
|
|
57
|
-
console.log(`deleteApp completed in ${deleteDuration}ms`);
|
|
58
|
-
console.log("Delete app response:", deleteResponse);
|
|
59
|
-
|
|
60
|
-
expect(deleteResponse).toBeDefined();
|
|
61
|
-
expect(deleteResponse.deletedAppId).toBe(createResponse.id);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
const deleteDuration = Date.now() - deleteStartTime;
|
|
64
|
-
console.error(`deleteApp failed after ${deleteDuration}ms:`, error);
|
|
65
|
-
if (error instanceof Error && "response" in error) {
|
|
66
|
-
try {
|
|
67
|
-
const errorBody = await (error as any).response.json();
|
|
68
|
-
console.error("Full deleteApp error response:", errorBody);
|
|
69
|
-
} catch (e) {
|
|
70
|
-
console.error("Could not parse error response:", e);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// tests/vitest/qb/apps/getApp.test.ts
|
|
2
|
-
import { test, expect } from "vitest";
|
|
3
|
-
import { quickbase } from "../../../../src/quickbaseClient";
|
|
4
|
-
|
|
5
|
-
test(
|
|
6
|
-
"QuickbaseClient Integration - getApp > fetches real app data from QuickBase",
|
|
7
|
-
{ timeout: 10000 },
|
|
8
|
-
async () => {
|
|
9
|
-
const config = {
|
|
10
|
-
realm: process.env.QB_REALM || "",
|
|
11
|
-
userToken: process.env.QB_USER_TOKEN || "",
|
|
12
|
-
debug: true,
|
|
13
|
-
};
|
|
14
|
-
const client = quickbase(config);
|
|
15
|
-
const getAppId = "buwai2zpe";
|
|
16
|
-
|
|
17
|
-
console.log("Config used:", config);
|
|
18
|
-
const result = await client.getApp({ appId: getAppId });
|
|
19
|
-
console.log("Real API response:", result);
|
|
20
|
-
|
|
21
|
-
expect(result).toEqual({
|
|
22
|
-
id: getAppId,
|
|
23
|
-
name: "qb-copy",
|
|
24
|
-
created: expect.any(Date),
|
|
25
|
-
updated: expect.any(Date),
|
|
26
|
-
description: "",
|
|
27
|
-
timeZone: "(UTC-08:00) Pacific Time (US & Canada)",
|
|
28
|
-
dateFormat: "MM-DD-YYYY",
|
|
29
|
-
hasEveryoneOnTheInternet: false,
|
|
30
|
-
memoryInfo: { estMemory: 0, estMemoryInclDependentApps: 0 },
|
|
31
|
-
securityProperties: {
|
|
32
|
-
allowClone: false,
|
|
33
|
-
allowExport: true,
|
|
34
|
-
enableAppTokens: true,
|
|
35
|
-
hideFromPublic: false,
|
|
36
|
-
mustBeRealmApproved: false,
|
|
37
|
-
useIPFilter: false,
|
|
38
|
-
},
|
|
39
|
-
ancestorId: undefined,
|
|
40
|
-
dataClassification: undefined,
|
|
41
|
-
variables: [{ name: "TestVar", value: "TestValue" }],
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
);
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "vitest";
|
|
2
|
-
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
|
-
|
|
4
|
-
test(
|
|
5
|
-
"QuickbaseClient Integration - getAppEvents > fetches real app events from QuickBase",
|
|
6
|
-
{ timeout: 10000 },
|
|
7
|
-
async () => {
|
|
8
|
-
const config = {
|
|
9
|
-
realm: process.env.QB_REALM || "",
|
|
10
|
-
userToken: process.env.QB_USER_TOKEN || "",
|
|
11
|
-
debug: true,
|
|
12
|
-
};
|
|
13
|
-
const client = quickbase(config);
|
|
14
|
-
const appId = "buwai2zpe"; // Same app ID as getApp test
|
|
15
|
-
|
|
16
|
-
console.log("Config used:", config);
|
|
17
|
-
const result = await client.getAppEvents({ appId });
|
|
18
|
-
console.log("Real API response:", result);
|
|
19
|
-
|
|
20
|
-
// Validate the response is an array of events
|
|
21
|
-
expect(result).toBeInstanceOf(Array);
|
|
22
|
-
|
|
23
|
-
// Check that each event has the required properties
|
|
24
|
-
result.forEach((event) => {
|
|
25
|
-
expect(event).toHaveProperty("type");
|
|
26
|
-
expect([
|
|
27
|
-
"qb-action",
|
|
28
|
-
"webhook",
|
|
29
|
-
"email-notification",
|
|
30
|
-
"subscription",
|
|
31
|
-
"reminder",
|
|
32
|
-
"automation",
|
|
33
|
-
]).toContain(event.type);
|
|
34
|
-
|
|
35
|
-
expect(event).toHaveProperty("owner");
|
|
36
|
-
expect(event.owner).toHaveProperty("email");
|
|
37
|
-
expect(typeof event.owner.email).toBe("string");
|
|
38
|
-
expect(event.owner).toHaveProperty("id");
|
|
39
|
-
expect(typeof event.owner.id).toBe("string");
|
|
40
|
-
expect(event.owner).toHaveProperty("name");
|
|
41
|
-
expect(typeof event.owner.name).toBe("string");
|
|
42
|
-
// userName is optional, so we don't enforce it
|
|
43
|
-
|
|
44
|
-
expect(event).toHaveProperty("isActive");
|
|
45
|
-
expect(typeof event.isActive).toBe("boolean");
|
|
46
|
-
|
|
47
|
-
expect(event).toHaveProperty("tableId");
|
|
48
|
-
expect(typeof event.tableId).toBe("string");
|
|
49
|
-
|
|
50
|
-
// Name is present for all types except automation
|
|
51
|
-
if (event.type !== "automation") {
|
|
52
|
-
expect(event).toHaveProperty("name");
|
|
53
|
-
expect(typeof event.name).toBe("string");
|
|
54
|
-
} else {
|
|
55
|
-
expect(event.name).toBeUndefined();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// URL is only present for automation
|
|
59
|
-
if (event.type === "automation") {
|
|
60
|
-
expect(event).toHaveProperty("url");
|
|
61
|
-
expect(typeof event.url).toBe("string");
|
|
62
|
-
} else {
|
|
63
|
-
expect(event.url).toBeUndefined();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
);
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "vitest";
|
|
2
|
-
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
|
-
|
|
4
|
-
test(
|
|
5
|
-
"QuickbaseClient Integration - updateApp > updates real app data in QuickBase",
|
|
6
|
-
{ timeout: 10000 },
|
|
7
|
-
async () => {
|
|
8
|
-
const config = {
|
|
9
|
-
realm: process.env.QB_REALM || "",
|
|
10
|
-
userToken: process.env.QB_USER_TOKEN || "",
|
|
11
|
-
debug: true,
|
|
12
|
-
};
|
|
13
|
-
const client = quickbase(config);
|
|
14
|
-
const appId = "buwai2zpe"; // Same app ID as before
|
|
15
|
-
|
|
16
|
-
// Original app data (to restore later if needed)
|
|
17
|
-
const originalApp = await client.getApp({ appId });
|
|
18
|
-
console.log("Original app data:", originalApp);
|
|
19
|
-
|
|
20
|
-
// Update request
|
|
21
|
-
const updateRequest = {
|
|
22
|
-
name: "qb-copy-updated",
|
|
23
|
-
description: "Updated via integration test",
|
|
24
|
-
variables: [{ name: "TestVar", value: "TestValue" }],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
console.log("Config used:", config);
|
|
28
|
-
console.log("Update request:", updateRequest);
|
|
29
|
-
const result = await client.updateApp({ appId, body: updateRequest });
|
|
30
|
-
console.log("Real API response:", result);
|
|
31
|
-
|
|
32
|
-
// Validate the response
|
|
33
|
-
expect(result).toHaveProperty("id", appId);
|
|
34
|
-
expect(result).toHaveProperty("name", "qb-copy-updated");
|
|
35
|
-
expect(result).toHaveProperty(
|
|
36
|
-
"description",
|
|
37
|
-
"Updated via integration test"
|
|
38
|
-
);
|
|
39
|
-
expect(result).toHaveProperty("variables");
|
|
40
|
-
expect(result.variables).toContainEqual({
|
|
41
|
-
name: "TestVar",
|
|
42
|
-
value: "TestValue",
|
|
43
|
-
});
|
|
44
|
-
expect(result).toHaveProperty("created");
|
|
45
|
-
expect(result.created).toBeInstanceOf(Date);
|
|
46
|
-
expect(result).toHaveProperty("updated");
|
|
47
|
-
expect(result.updated).toBeInstanceOf(Date);
|
|
48
|
-
|
|
49
|
-
// Optional: Restore original name to avoid permanent changes
|
|
50
|
-
const restoreRequest = {
|
|
51
|
-
name: originalApp.name,
|
|
52
|
-
description: originalApp.description,
|
|
53
|
-
variables: originalApp.variables,
|
|
54
|
-
};
|
|
55
|
-
await client.updateApp({ appId, body: restoreRequest });
|
|
56
|
-
console.log("Restored app to:", originalApp.name);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// tests/vitest/qb/auth/mockQuickbaseServer.ts
|
|
2
|
-
import express from "express";
|
|
3
|
-
|
|
4
|
-
export function startMockQuickbaseServer(port: number = 3000) {
|
|
5
|
-
const app = express();
|
|
6
|
-
app.use(express.json());
|
|
7
|
-
let failNextCall = false;
|
|
8
|
-
|
|
9
|
-
app.post("/v1/auth/oauth/token", (req, res) => {
|
|
10
|
-
const { subject_token } = req.body;
|
|
11
|
-
console.log("[Mock Server] Received SSO token request:", req.body);
|
|
12
|
-
if (!subject_token) {
|
|
13
|
-
return res.status(400).json({ message: "Missing SAML token" });
|
|
14
|
-
}
|
|
15
|
-
res.json({
|
|
16
|
-
access_token: "mock-temp-token",
|
|
17
|
-
token_type: "Bearer",
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
app.get("/v1/apps/:appId", (req, res) => {
|
|
22
|
-
const authHeader = req.headers.authorization;
|
|
23
|
-
console.log(
|
|
24
|
-
"[Mock Server] Received getApp request:",
|
|
25
|
-
req.params,
|
|
26
|
-
"Auth:",
|
|
27
|
-
authHeader
|
|
28
|
-
);
|
|
29
|
-
if (!authHeader || !authHeader.startsWith("QB-TEMP-TOKEN")) {
|
|
30
|
-
return res.status(401).json({ message: "Unauthorized" });
|
|
31
|
-
}
|
|
32
|
-
if (failNextCall) {
|
|
33
|
-
failNextCall = false;
|
|
34
|
-
return res.status(401).json({ message: "Token expired" });
|
|
35
|
-
}
|
|
36
|
-
res.json({
|
|
37
|
-
id: req.params.appId,
|
|
38
|
-
name: "Mock App",
|
|
39
|
-
created: "2025-03-19T12:00:00Z",
|
|
40
|
-
updated: "2025-03-19T12:00:00Z",
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
app.post("/mock/toggle-fail", (req, res) => {
|
|
45
|
-
failNextCall = true;
|
|
46
|
-
console.log("[Mock Server] Toggling next getApp call to fail with 401");
|
|
47
|
-
res.sendStatus(200);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const server = app.listen(port, () => {
|
|
51
|
-
console.log(`Mock QuickBase server running on port ${port}`);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
server,
|
|
56
|
-
close: () => server.close(),
|
|
57
|
-
toggleFail: () =>
|
|
58
|
-
fetch(`http://localhost:${port}/mock/toggle-fail`, { method: "POST" }),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { describe, it, vi, expect, beforeEach } from "vitest";
|
|
2
|
-
import { quickbase, QuickbaseClient } from "../../../../src/quickbaseClient";
|
|
3
|
-
|
|
4
|
-
describe("QuickbaseClient Integration - User Token Retry on 401", () => {
|
|
5
|
-
let client: QuickbaseClient;
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
const userToken = process.env.QB_USER_TOKEN;
|
|
9
|
-
const realm = process.env.QB_REALM;
|
|
10
|
-
const tableId = process.env.QB_TABLE_ID_1; // Consistent env var name
|
|
11
|
-
|
|
12
|
-
if (!userToken) {
|
|
13
|
-
throw new Error(
|
|
14
|
-
"QB_USER_TOKEN environment variable is required for integration test"
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
if (!tableId) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
"QB_TABLE_ID_1 environment variable is required for integration test"
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const config = {
|
|
24
|
-
realm,
|
|
25
|
-
userToken,
|
|
26
|
-
debug: true,
|
|
27
|
-
};
|
|
28
|
-
console.log("[quickbaseTest] Config:", {
|
|
29
|
-
realm,
|
|
30
|
-
userToken: userToken.substring(0, 10) + "...",
|
|
31
|
-
tableId, // Log to confirm
|
|
32
|
-
debug: true,
|
|
33
|
-
});
|
|
34
|
-
client = quickbase(config);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it(
|
|
38
|
-
"successfully retrieves fields with user token, retrying on transient 401 if needed",
|
|
39
|
-
async () => {
|
|
40
|
-
const consoleSpy = vi.spyOn(console, "log");
|
|
41
|
-
|
|
42
|
-
const tableId = process.env.QB_TABLE_ID_1!; // Match beforeEach
|
|
43
|
-
let fields;
|
|
44
|
-
try {
|
|
45
|
-
fields = await client.getFields({ tableId });
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error("[integrationTest] Failed to retrieve fields:", error);
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
expect(fields).toBeInstanceOf(Array);
|
|
52
|
-
expect(fields.length).toBeGreaterThan(0);
|
|
53
|
-
expect(fields[0]).toHaveProperty("id");
|
|
54
|
-
expect(fields[0]).toHaveProperty("label");
|
|
55
|
-
|
|
56
|
-
console.log("[integrationTest] Fields retrieved:", fields.length);
|
|
57
|
-
|
|
58
|
-
const retryLog = consoleSpy.mock.calls.some((call) =>
|
|
59
|
-
call[0].includes("Retrying getFields with existing user token")
|
|
60
|
-
);
|
|
61
|
-
if (retryLog) {
|
|
62
|
-
console.log("[integrationTest] Retry on 401 detected");
|
|
63
|
-
} else {
|
|
64
|
-
console.log(
|
|
65
|
-
"[integrationTest] No 401 retries observed (expected if no transient failure)"
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
consoleSpy.mockRestore();
|
|
70
|
-
},
|
|
71
|
-
{ timeout: 10000 }
|
|
72
|
-
);
|
|
73
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// tests/vitest/qb/auth/ssoTokenConcurrency.test.ts
|
|
2
|
-
import { test, expect, vi } from "vitest";
|
|
3
|
-
import { quickbase } from "../../../../src/quickbaseClient";
|
|
4
|
-
import { startMockQuickbaseServer } from "./mockQuickbaseServer";
|
|
5
|
-
import { QB_APP_ID, QB_REALM } from "@tests/setup.ts";
|
|
6
|
-
|
|
7
|
-
test(
|
|
8
|
-
"QuickbaseClient Integration - getApp with SsoTokenStrategy Concurrency",
|
|
9
|
-
async () => {
|
|
10
|
-
const mockServer = startMockQuickbaseServer(3000);
|
|
11
|
-
|
|
12
|
-
// Spy on console.log before any actions
|
|
13
|
-
const consoleSpy = vi.spyOn(console, "log");
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const client = quickbase({
|
|
17
|
-
realm: QB_REALM,
|
|
18
|
-
useSso: true,
|
|
19
|
-
samlToken: "mock-saml-token",
|
|
20
|
-
debug: true,
|
|
21
|
-
baseUrl: "http://localhost:3000/v1",
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const concurrentRequests = [
|
|
25
|
-
client.getApp({ appId: QB_APP_ID }),
|
|
26
|
-
client.getApp({ appId: QB_APP_ID }),
|
|
27
|
-
client.getApp({ appId: QB_APP_ID }),
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const results = await Promise.all(concurrentRequests);
|
|
31
|
-
|
|
32
|
-
expect(results).toHaveLength(3);
|
|
33
|
-
results.forEach((result) =>
|
|
34
|
-
expect(result).toEqual({
|
|
35
|
-
id: QB_APP_ID,
|
|
36
|
-
name: "Mock App",
|
|
37
|
-
created: expect.any(Date),
|
|
38
|
-
updated: expect.any(Date),
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// Verify token fetch and waits using console logs
|
|
43
|
-
const logs = consoleSpy.mock.calls;
|
|
44
|
-
const tokenFetchLogs = logs.filter((call) =>
|
|
45
|
-
call[0].includes("[fetchSsoToken] Fetched token")
|
|
46
|
-
);
|
|
47
|
-
expect(tokenFetchLogs).toHaveLength(1); // Single fetch with synchronization
|
|
48
|
-
|
|
49
|
-
const waitLogs = logs.filter((call) =>
|
|
50
|
-
call[0].includes("Waiting for existing SSO fetch")
|
|
51
|
-
);
|
|
52
|
-
expect(waitLogs.length).toBeGreaterThanOrEqual(2); // At least two waits
|
|
53
|
-
|
|
54
|
-
const appRequestLogs = logs.filter((call) =>
|
|
55
|
-
call[0].includes("Received getApp request")
|
|
56
|
-
);
|
|
57
|
-
expect(appRequestLogs).toHaveLength(3);
|
|
58
|
-
|
|
59
|
-
console.log(
|
|
60
|
-
"SsoTokenStrategy: Single token fetch with concurrent waits confirmed."
|
|
61
|
-
);
|
|
62
|
-
} finally {
|
|
63
|
-
mockServer.close();
|
|
64
|
-
consoleSpy.mockRestore();
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
{ timeout: 20000 }
|
|
68
|
-
);
|