quickbase-js 1.0.1-beta.0 → 1.1.0-beta.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.
- package/CHANGELOG.md +24 -0
- package/dist/{quickbaseClient.d.ts → quickbase.d.ts} +344 -339
- package/dist/{quickbaseClient.js → quickbase.js} +350 -266
- package/dist/quickbase.js.map +1 -0
- package/log-gen.yaml +3565 -0
- package/package.json +11 -7
- package/rollup.config.js +2 -2
- package/src/code-generation/fix-spec-definitions.ts +417 -68
- package/src/code-generation/fix-spec-paths.ts +207 -2
- package/src/code-generation/output/quickbase-fixed.json +646 -1122
- package/src/generated-unified/QuickbaseClient.ts +9 -8
- package/src/log-gen.ts +82 -35
- package/src/quickbaseClient.ts +39 -42
- package/test-artifacts/test-results.json +173 -1145
- package/tests/playwright/qb/auth/cacheSwitching.test.ts +2 -2
- package/tests/playwright/qb/auth/fetchTempToken401.test.ts +2 -2
- package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +2 -2
- package/tests/playwright/qb/auth/getTempToken.test.ts +2 -2
- package/tests/playwright/qb/auth/tokenPrefetch.test.ts +2 -2
- package/tests/playwright/qb/auth/tokenRenewal.test.ts +2 -2
- package/tests/setup.ts +16 -8
- package/tests/vitest/qb/apps/getApp.test.ts +37 -43
- package/tests/vitest/qb/records/deleteRecords.test.ts +78 -0
- package/tests/vitest/qb/records/upsert.test.ts +72 -0
- package/tests/vitest/qb/tables/createTable.test.ts +55 -0
- package/tests/vitest/qb/tables/deleteTable.test.ts +50 -0
- package/tests/vitest/qb/tables/getAppTables.test.ts +43 -64
- package/tests/vitest/qb/tables/getTable.test.ts +26 -0
- package/tests/vitest/qb/tables/updateTable.test.ts +48 -0
- package/tests/vitest/unit/apps/getApp.test.ts +1 -1
- package/tests/vitest/unit/auth/fetchTempToken401.test.ts +4 -3
- package/tests/vitest/unit/auth/getTempToken.test.ts +8 -9
- package/tests/vitest/unit/auth/retryOn401.test.ts +1 -1
- package/tests/vitest/unit/auth/two401s.test.ts +1 -1
- package/tests/vitest/unit/fields/getFields.test.ts +1 -1
- package/tests/vitest/unit/records/deleteRecords.test.ts +118 -0
- package/tests/vitest/unit/records/upsert.test.ts +228 -0
- package/tests/vitest/unit/tables/createTable.test.ts +62 -0
- package/tests/vitest/unit/tables/deleteTable.test.ts +68 -0
- package/tests/vitest/unit/tables/getAppTables.test.ts +1 -1
- package/tests/vitest/unit/tables/getTable.test.ts +212 -0
- package/tests/vitest/unit/tables/updateTable.test.ts +74 -0
- package/tsconfig.json +3 -2
- package/vitest.config.ts +3 -2
- package/dist/quickbaseClient.js.map +0 -1
- package/logGen.yaml +0 -1820
- package/src/utils.ts +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tests/playwright/qb/auth/cacheSwitching.test.ts
|
|
2
2
|
import { test, expect } from "@playwright/test";
|
|
3
|
-
import {
|
|
3
|
+
import { quickbase } from "../../../../src/quickbaseClient.ts";
|
|
4
4
|
import fetch from "node-fetch";
|
|
5
5
|
import dotenv from "dotenv";
|
|
6
6
|
|
|
@@ -137,7 +137,7 @@ test.describe("QuickbaseClient Integration - Cache Switching with Temp Tokens",
|
|
|
137
137
|
return fetchResponse;
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
-
const client =
|
|
140
|
+
const client = quickbase({
|
|
141
141
|
realm,
|
|
142
142
|
useTempTokens: true,
|
|
143
143
|
debug: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tests/playwright/qb/auth/tokenInvalidation.test.ts
|
|
2
2
|
import { test, expect } from "@playwright/test";
|
|
3
|
-
import {
|
|
3
|
+
import { quickbase } from "../../../../src/quickbaseClient.ts";
|
|
4
4
|
import fetch from "node-fetch";
|
|
5
5
|
import dotenv from "dotenv";
|
|
6
6
|
|
|
@@ -141,7 +141,7 @@ test.describe("QuickbaseClient Integration - Token Invalidation with Cached Toke
|
|
|
141
141
|
return fetchResponse;
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
const client =
|
|
144
|
+
const client = quickbase({
|
|
145
145
|
realm,
|
|
146
146
|
useTempTokens: true,
|
|
147
147
|
debug: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tests/integration/auth/getAppWithUserToken.test.ts
|
|
2
2
|
import { test, expect } from "@playwright/test";
|
|
3
|
-
import {
|
|
3
|
+
import { quickbase } from "../../../../src/quickbaseClient.ts";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
|
|
6
6
|
dotenv.config();
|
|
@@ -89,7 +89,7 @@ test.describe("QuickbaseClient Integration - getApp with User Token", () => {
|
|
|
89
89
|
console.log("Post-login URL after app navigation:", currentUrl);
|
|
90
90
|
|
|
91
91
|
// Create Quickbase client with user token
|
|
92
|
-
const client =
|
|
92
|
+
const client = quickbase({
|
|
93
93
|
realm,
|
|
94
94
|
userToken, // Use user token instead of temp tokens
|
|
95
95
|
debug: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tests/integration/auth/getTempToken.test.ts
|
|
2
2
|
import { test, expect } from "@playwright/test";
|
|
3
|
-
import {
|
|
3
|
+
import { quickbase } from "../../../../src/quickbaseClient.ts";
|
|
4
4
|
import fetch from "node-fetch";
|
|
5
5
|
import dotenv from "dotenv";
|
|
6
6
|
|
|
@@ -132,7 +132,7 @@ test.describe("QuickbaseClient Integration - getApp with Temp Tokens", () => {
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
// Single client with conditional fetch
|
|
135
|
-
const client =
|
|
135
|
+
const client = quickbase({
|
|
136
136
|
realm,
|
|
137
137
|
useTempTokens: true,
|
|
138
138
|
debug: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tests/playwright/qb/auth/tokenPrefetch.test.ts
|
|
2
2
|
import { test, expect } from "@playwright/test";
|
|
3
|
-
import {
|
|
3
|
+
import { quickbase } from "../../../../src/quickbaseClient.ts";
|
|
4
4
|
import fetch from "node-fetch";
|
|
5
5
|
import dotenv from "dotenv";
|
|
6
6
|
|
|
@@ -134,7 +134,7 @@ test.describe("QuickbaseClient Integration - Token Pre-Fetch and Cache Reuse", (
|
|
|
134
134
|
return fetchResponse;
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
-
const client =
|
|
137
|
+
const client = quickbase({
|
|
138
138
|
realm,
|
|
139
139
|
useTempTokens: true,
|
|
140
140
|
debug: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tests/playwright/qb/auth/tokenRenewal.test.ts
|
|
2
2
|
import { test, expect } from "@playwright/test";
|
|
3
|
-
import {
|
|
3
|
+
import { quickbase } from "../../../../src/quickbaseClient.ts";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
|
|
6
6
|
dotenv.config();
|
|
@@ -70,7 +70,7 @@ test.describe("QuickbaseClient Integration - Temp Token Renewal", () => {
|
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const client =
|
|
73
|
+
const client = quickbase({
|
|
74
74
|
realm,
|
|
75
75
|
useTempTokens: true,
|
|
76
76
|
debug: true,
|
package/tests/setup.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import dotenv from "dotenv";
|
|
1
|
+
// @tests/setup.ts
|
|
3
2
|
import { vi } from "vitest";
|
|
3
|
+
import { quickbase } from "../src/quickbaseClient.ts";
|
|
4
|
+
import type { QuickbaseConfig } from "../src/quickbaseClient.ts";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
export const mockFetch = vi.fn();
|
|
6
7
|
|
|
7
8
|
export const createClient = (
|
|
8
9
|
fetchApi?: any,
|
|
9
10
|
config: Partial<QuickbaseConfig> = {}
|
|
10
|
-
) =>
|
|
11
|
-
|
|
12
|
-
realm: process.env.QB_REALM || "
|
|
13
|
-
userToken: process.env.QB_USER_TOKEN || "
|
|
11
|
+
) => {
|
|
12
|
+
const client = quickbase({
|
|
13
|
+
realm: process.env.QB_REALM || "test-realm", // Match upsert.test.ts
|
|
14
|
+
userToken: process.env.QB_USER_TOKEN || "test-token", // Match upsert.test.ts
|
|
14
15
|
debug: true,
|
|
15
16
|
fetchApi,
|
|
16
17
|
...config,
|
|
17
18
|
});
|
|
19
|
+
console.log("[createClient] Config:", config); // Debug config
|
|
20
|
+
console.log("[createClient] Returning:", client); // Debug client
|
|
21
|
+
return client;
|
|
22
|
+
};
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
// Mock env variables for consistency
|
|
25
|
+
vi.stubEnv("QB_REALM", "builderprogram-dbradford6815");
|
|
26
|
+
vi.stubEnv("QB_USER_TOKEN", "b9f3pk_q4jd_0_b4qu5eebyvuix3xs57ysd7zn3");
|
|
27
|
+
vi.stubEnv("QB_APP_ID", "buwai2zpe");
|
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
test(
|
|
5
|
+
"QuickbaseClient Integration - getApp > fetches real app data 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 getAppId = "buwai2zpe";
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const getAppId = process.env.QB_APP_ID;
|
|
11
|
-
if (!getAppId) throw new Error("QB_APP_ID is not defined in .env");
|
|
12
|
-
if (!process.env.QB_REALM)
|
|
13
|
-
throw new Error("QB_REALM is not defined in .env");
|
|
14
|
-
if (!process.env.QB_USER_TOKEN)
|
|
15
|
-
throw new Error("QB_USER_TOKEN is not defined in .env");
|
|
16
|
+
console.log("Config used:", config);
|
|
17
|
+
const result = await client.getApp({ appId: getAppId });
|
|
18
|
+
console.log("Real API response:", result);
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
hideFromPublic: false,
|
|
39
|
-
mustBeRealmApproved: false,
|
|
40
|
-
useIPFilter: false,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
{ timeout: 10000 }
|
|
45
|
-
);
|
|
46
|
-
});
|
|
20
|
+
expect(result).toEqual({
|
|
21
|
+
id: getAppId,
|
|
22
|
+
name: "qb-copy",
|
|
23
|
+
created: expect.any(Date), // Matches Date object from client
|
|
24
|
+
updated: expect.any(Date), // Matches Date object from client
|
|
25
|
+
description: "",
|
|
26
|
+
timeZone: "(UTC-08:00) Pacific Time (US & Canada)",
|
|
27
|
+
dateFormat: "MM-DD-YYYY",
|
|
28
|
+
hasEveryoneOnTheInternet: false,
|
|
29
|
+
memoryInfo: { estMemory: 0, estMemoryInclDependentApps: 0 },
|
|
30
|
+
securityProperties: {
|
|
31
|
+
allowClone: false,
|
|
32
|
+
allowExport: true,
|
|
33
|
+
enableAppTokens: true,
|
|
34
|
+
hideFromPublic: false,
|
|
35
|
+
mustBeRealmApproved: false,
|
|
36
|
+
useIPFilter: false,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// tests/vitest/qb/records/deleteRecords.test.ts
|
|
2
|
+
import { describe, test, expect, beforeEach, afterEach } from "vitest";
|
|
3
|
+
import { quickbase } from "@/quickbaseClient.ts";
|
|
4
|
+
|
|
5
|
+
const TABLE_ID = "buwai2zws";
|
|
6
|
+
const UNIQUE_FIELD_ID = 3; // Record ID field
|
|
7
|
+
const MARKER_FIELD_ID = 6; // Text field for marking test records
|
|
8
|
+
|
|
9
|
+
describe("QuickbaseClient - DeleteRecords Integration", () => {
|
|
10
|
+
const qb = quickbase({
|
|
11
|
+
realm: "builderprogram-dbradford6815",
|
|
12
|
+
userToken: process.env.QB_USER_TOKEN,
|
|
13
|
+
debug: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(async () => {
|
|
17
|
+
try {
|
|
18
|
+
await qb.deleteRecords({
|
|
19
|
+
body: {
|
|
20
|
+
from: TABLE_ID,
|
|
21
|
+
where: `{${MARKER_FIELD_ID}.CT.'test-marker-delete'}`,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
} catch (e) {
|
|
25
|
+
// Ignore if no records exist
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(async () => {
|
|
30
|
+
try {
|
|
31
|
+
await qb.deleteRecords({
|
|
32
|
+
body: {
|
|
33
|
+
from: TABLE_ID,
|
|
34
|
+
where: `{${MARKER_FIELD_ID}.CT.'test-marker-delete'}`,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
} catch (e) {}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test(
|
|
41
|
+
"deletes a newly upserted record",
|
|
42
|
+
async () => {
|
|
43
|
+
const upsertResponse = await qb.upsert({
|
|
44
|
+
body: {
|
|
45
|
+
to: TABLE_ID,
|
|
46
|
+
data: [{ [MARKER_FIELD_ID]: { value: "test-marker-delete" } }],
|
|
47
|
+
fieldsToReturn: [UNIQUE_FIELD_ID], // Return record ID
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const recordId = upsertResponse.metadata.createdRecordIds[0];
|
|
51
|
+
expect(recordId).toBeDefined();
|
|
52
|
+
expect(upsertResponse.data[0][UNIQUE_FIELD_ID].value).toBe(recordId);
|
|
53
|
+
|
|
54
|
+
const deleteResponse = await qb.deleteRecords({
|
|
55
|
+
body: { from: TABLE_ID, where: `{${UNIQUE_FIELD_ID}.EX.${recordId}}` },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(deleteResponse).toEqual({ numberDeleted: 1 });
|
|
59
|
+
|
|
60
|
+
const checkResponse = await qb.deleteRecords({
|
|
61
|
+
body: { from: TABLE_ID, where: `{${UNIQUE_FIELD_ID}.EX.${recordId}}` },
|
|
62
|
+
});
|
|
63
|
+
expect(checkResponse.numberDeleted).toBe(0);
|
|
64
|
+
},
|
|
65
|
+
{ timeout: 10000 }
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
test(
|
|
69
|
+
"handles empty result when no records match",
|
|
70
|
+
async () => {
|
|
71
|
+
const response = await qb.deleteRecords({
|
|
72
|
+
body: { from: TABLE_ID, where: "{3.EX.'999999'}" },
|
|
73
|
+
});
|
|
74
|
+
expect(response).toEqual({ numberDeleted: 0 });
|
|
75
|
+
},
|
|
76
|
+
{ timeout: 10000 }
|
|
77
|
+
);
|
|
78
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// tests/vitest/qb/records/upsert.test.ts
|
|
2
|
+
import { describe, test, expect, beforeEach, afterEach } from "vitest";
|
|
3
|
+
import { quickbase } from "@/quickbaseClient.ts";
|
|
4
|
+
|
|
5
|
+
const TABLE_ID = "buwai2zws";
|
|
6
|
+
const MARKER_FIELD_ID = 6; // Text field for marking test records
|
|
7
|
+
|
|
8
|
+
describe("QuickbaseClient - Upsert Integration", () => {
|
|
9
|
+
const qb = quickbase({
|
|
10
|
+
realm: "builderprogram-dbradford6815",
|
|
11
|
+
userToken: process.env.QB_USER_TOKEN,
|
|
12
|
+
debug: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
try {
|
|
17
|
+
await qb.deleteRecords({
|
|
18
|
+
body: {
|
|
19
|
+
from: TABLE_ID,
|
|
20
|
+
where: `{${MARKER_FIELD_ID}.CT.'test-marker-upsert'}`,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {
|
|
24
|
+
// Ignore if no records exist
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(async () => {
|
|
29
|
+
try {
|
|
30
|
+
await qb.deleteRecords({
|
|
31
|
+
body: {
|
|
32
|
+
from: TABLE_ID,
|
|
33
|
+
where: `{${MARKER_FIELD_ID}.CT.'test-marker-upsert'}`,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
} catch (e) {}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test(
|
|
40
|
+
"creates a new record successfully",
|
|
41
|
+
async () => {
|
|
42
|
+
const response = await qb.upsert({
|
|
43
|
+
body: {
|
|
44
|
+
to: TABLE_ID,
|
|
45
|
+
data: [{ [MARKER_FIELD_ID]: { value: "test-marker-upsert" } }],
|
|
46
|
+
fieldsToReturn: [MARKER_FIELD_ID, 3], // Return marker and record ID
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(response.metadata.createdRecordIds.length).toBe(1);
|
|
51
|
+
expect(response.data).toHaveLength(1);
|
|
52
|
+
expect(response.data[0][MARKER_FIELD_ID].value).toBe(
|
|
53
|
+
"test-marker-upsert"
|
|
54
|
+
);
|
|
55
|
+
expect(response.data[0][3].value).toBeDefined(); // Record ID assigned by QuickBase
|
|
56
|
+
expect(response.metadata.totalNumberOfRecordsProcessed).toBe(1);
|
|
57
|
+
},
|
|
58
|
+
{ timeout: 10000 }
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
test(
|
|
62
|
+
"handles empty data gracefully",
|
|
63
|
+
async () => {
|
|
64
|
+
await expect(
|
|
65
|
+
qb.upsert({
|
|
66
|
+
body: { to: TABLE_ID, data: [] },
|
|
67
|
+
})
|
|
68
|
+
).rejects.toThrow("API Error: Bad Request (Status: 400)");
|
|
69
|
+
},
|
|
70
|
+
{ timeout: 10000 }
|
|
71
|
+
);
|
|
72
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
|
+
|
|
4
|
+
test(
|
|
5
|
+
"QuickbaseClient Integration - createTable > creates a new table 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";
|
|
15
|
+
|
|
16
|
+
const tableName = `TestTable_${Date.now()}`;
|
|
17
|
+
const createBody = {
|
|
18
|
+
name: tableName,
|
|
19
|
+
description: "Test table creation",
|
|
20
|
+
singleRecordName: "TestRecord",
|
|
21
|
+
pluralRecordName: "TestRecords",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
console.log("Config used:", config);
|
|
25
|
+
console.log("Creating table with:", createBody);
|
|
26
|
+
const response = await client.createTable({ appId, body: createBody });
|
|
27
|
+
|
|
28
|
+
expect(response).toBeDefined();
|
|
29
|
+
expect(response.id).toBeDefined();
|
|
30
|
+
expect(response.name).toBe(tableName);
|
|
31
|
+
expect(response.description).toBe(createBody.description);
|
|
32
|
+
expect(response.singleRecordName).toBe(createBody.singleRecordName);
|
|
33
|
+
expect(response.pluralRecordName).toBe(createBody.pluralRecordName);
|
|
34
|
+
expect(response.alias).toMatch(/^_DBID_/);
|
|
35
|
+
expect(response.created).toBeInstanceOf(Date);
|
|
36
|
+
expect(response.updated).toBeInstanceOf(Date);
|
|
37
|
+
expect(response.nextRecordId).toBeGreaterThanOrEqual(1);
|
|
38
|
+
expect(response.nextFieldId).toBeGreaterThanOrEqual(1);
|
|
39
|
+
expect(response.defaultSortFieldId).toBeGreaterThanOrEqual(0);
|
|
40
|
+
expect(response.keyFieldId).toBeGreaterThanOrEqual(1);
|
|
41
|
+
expect(response.sizeLimit).toMatch(/^\d+\sMB$/); // e.g., "500 MB"
|
|
42
|
+
expect(response.spaceUsed).toMatch(/^\d+\s(KB|MB)$/); // e.g., "0 KB"
|
|
43
|
+
expect(response.spaceRemaining).toMatch(/^\d+\sMB$/); // e.g., "500 MB"
|
|
44
|
+
|
|
45
|
+
console.log("Real API response:", response);
|
|
46
|
+
|
|
47
|
+
// Cleanup: Delete the table to avoid clutter
|
|
48
|
+
const deleteResponse = await client.deleteTable({
|
|
49
|
+
tableId: response.id,
|
|
50
|
+
appId,
|
|
51
|
+
});
|
|
52
|
+
expect(deleteResponse.deletedTableId).toBe(response.id);
|
|
53
|
+
console.log("Cleanup - Deleted table:", deleteResponse);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
|
+
|
|
4
|
+
test(
|
|
5
|
+
"QuickbaseClient Integration - deleteTable > deletes a table in QuickBase",
|
|
6
|
+
{ timeout: 20000 },
|
|
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";
|
|
15
|
+
|
|
16
|
+
// Step 1: Create a temporary table to delete
|
|
17
|
+
const tableName = `DeleteTest_${Date.now()}`;
|
|
18
|
+
const createBody = {
|
|
19
|
+
name: tableName,
|
|
20
|
+
description: "Temporary table for delete test",
|
|
21
|
+
singleRecordName: "DeleteTest",
|
|
22
|
+
pluralRecordName: "DeleteTests",
|
|
23
|
+
};
|
|
24
|
+
console.log("Creating temporary table with:", createBody);
|
|
25
|
+
const createResponse = await client.createTable({
|
|
26
|
+
appId,
|
|
27
|
+
body: createBody,
|
|
28
|
+
});
|
|
29
|
+
expect(createResponse.id).toBeDefined();
|
|
30
|
+
expect(createResponse.name).toBe(tableName);
|
|
31
|
+
console.log("Created table:", createResponse);
|
|
32
|
+
const tableId = createResponse.id;
|
|
33
|
+
|
|
34
|
+
// Step 2: Delete the table
|
|
35
|
+
console.log("Deleting table:", { tableId, appId });
|
|
36
|
+
const deleteResponse = await client.deleteTable({ tableId, appId });
|
|
37
|
+
expect(deleteResponse).toBeDefined();
|
|
38
|
+
expect(deleteResponse.deletedTableId).toBe(tableId);
|
|
39
|
+
console.log("Delete API response:", deleteResponse);
|
|
40
|
+
|
|
41
|
+
// Step 3: Verify the table is gone
|
|
42
|
+
try {
|
|
43
|
+
await client.getTable({ tableId, appId });
|
|
44
|
+
throw new Error("Table should not exist after deletion");
|
|
45
|
+
} catch (error) {
|
|
46
|
+
expect(error.message).toMatch(/404|not found/i); // Expect a 404 error
|
|
47
|
+
console.log("Verified table deletion:", error.message);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
@@ -1,67 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
test(
|
|
5
|
+
"QuickbaseClient Integration - getAppTables > fetches real table data 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 tablesAppId = "buwai2zpe";
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const tablesAppId = process.env.QB_APP_ID;
|
|
11
|
-
if (!tablesAppId) throw new Error("QB_APP_ID is not defined in .env");
|
|
12
|
-
if (!process.env.QB_REALM)
|
|
13
|
-
throw new Error("QB_REALM is not defined in .env");
|
|
14
|
-
if (!process.env.QB_USER_TOKEN)
|
|
15
|
-
throw new Error("QB_USER_TOKEN is not defined in .env");
|
|
16
|
+
console.log("Config used:", config);
|
|
17
|
+
const result = await client.getAppTables({ appId: tablesAppId });
|
|
18
|
+
console.log("Real API response:", result);
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
expect.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
expect.objectContaining({
|
|
45
|
-
alias: "_DBID_ROLES",
|
|
46
|
-
created: new Date("2025-02-13T18:22:33Z"),
|
|
47
|
-
defaultSortFieldId: 2,
|
|
48
|
-
defaultSortOrder: "DESC",
|
|
49
|
-
description: "",
|
|
50
|
-
id: "buwai2z3s",
|
|
51
|
-
keyFieldId: 3,
|
|
52
|
-
name: "Roles",
|
|
53
|
-
nextFieldId: 6,
|
|
54
|
-
nextRecordId: 1,
|
|
55
|
-
pluralRecordName: "Roles",
|
|
56
|
-
singleRecordName: "Role",
|
|
57
|
-
sizeLimit: "500 MB",
|
|
58
|
-
spaceRemaining: "500 MB",
|
|
59
|
-
spaceUsed: "0 KB",
|
|
60
|
-
updated: new Date("2025-02-13T18:22:34Z"),
|
|
61
|
-
}),
|
|
62
|
-
])
|
|
63
|
-
);
|
|
64
|
-
},
|
|
65
|
-
{ timeout: 10000 }
|
|
66
|
-
);
|
|
67
|
-
});
|
|
20
|
+
expect(result).toBeDefined();
|
|
21
|
+
expect(result).toBeInstanceOf(Array);
|
|
22
|
+
expect(result.length).toBeGreaterThan(0);
|
|
23
|
+
expect(result).toEqual(
|
|
24
|
+
expect.arrayContaining([
|
|
25
|
+
expect.objectContaining({
|
|
26
|
+
id: "buwai2zr4",
|
|
27
|
+
alias: "_DBID_ROOT",
|
|
28
|
+
name: expect.any(String), // Allow dynamic name due to updateTable
|
|
29
|
+
description: expect.any(String), // Allow dynamic description
|
|
30
|
+
created: expect.any(Date),
|
|
31
|
+
updated: expect.any(Date), // Allow varying timestamps
|
|
32
|
+
nextRecordId: expect.any(Number),
|
|
33
|
+
nextFieldId: expect.any(Number),
|
|
34
|
+
defaultSortFieldId: expect.any(Number),
|
|
35
|
+
defaultSortOrder: "DESC",
|
|
36
|
+
keyFieldId: expect.any(Number),
|
|
37
|
+
singleRecordName: "Root",
|
|
38
|
+
pluralRecordName: "Roots",
|
|
39
|
+
sizeLimit: "500 MB",
|
|
40
|
+
spaceUsed: expect.any(String),
|
|
41
|
+
spaceRemaining: "500 MB",
|
|
42
|
+
}),
|
|
43
|
+
])
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
|
+
|
|
4
|
+
test(
|
|
5
|
+
"QuickbaseClient Integration - getTable > fetches real table data 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 tableId = "buwai2zr4";
|
|
15
|
+
const appId = "buwai2zpe";
|
|
16
|
+
|
|
17
|
+
console.log("Config used:", config);
|
|
18
|
+
const response = await client.getTable({ tableId, appId });
|
|
19
|
+
expect(response).toBeDefined();
|
|
20
|
+
expect(response.id).toBe(tableId);
|
|
21
|
+
expect(response.name).toBe("Root"); // Expect original name
|
|
22
|
+
expect(response.alias).toBe("_DBID_ROOT");
|
|
23
|
+
expect(response.created).toBeInstanceOf(Date);
|
|
24
|
+
console.log("Real API response:", response);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { quickbase } from "../../../../src/quickbaseClient";
|
|
3
|
+
|
|
4
|
+
test(
|
|
5
|
+
"QuickbaseClient Integration - updateTable > updates real table 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";
|
|
15
|
+
const tableId = "buwai2zr4";
|
|
16
|
+
const updatedBody = {
|
|
17
|
+
name: "Root Updated " + Date.now(),
|
|
18
|
+
description: "Integration test update",
|
|
19
|
+
};
|
|
20
|
+
const originalBody = {
|
|
21
|
+
name: "Root",
|
|
22
|
+
description: "",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
console.log("Config used:", config);
|
|
26
|
+
// Update the table
|
|
27
|
+
const response = await client.updateTable({
|
|
28
|
+
tableId,
|
|
29
|
+
appId,
|
|
30
|
+
body: updatedBody,
|
|
31
|
+
});
|
|
32
|
+
expect(response).toBeDefined();
|
|
33
|
+
expect(response.id).toBe(tableId);
|
|
34
|
+
expect(response.name).toBe(updatedBody.name);
|
|
35
|
+
expect(response.description).toBe(updatedBody.description);
|
|
36
|
+
console.log("Real API response:", response);
|
|
37
|
+
|
|
38
|
+
// Cleanup: Revert the table to original state
|
|
39
|
+
const cleanupResponse = await client.updateTable({
|
|
40
|
+
tableId,
|
|
41
|
+
appId,
|
|
42
|
+
body: originalBody,
|
|
43
|
+
});
|
|
44
|
+
expect(cleanupResponse.name).toBe(originalBody.name);
|
|
45
|
+
expect(cleanupResponse.description).toBe(originalBody.description);
|
|
46
|
+
console.log("Cleanup API response:", cleanupResponse);
|
|
47
|
+
}
|
|
48
|
+
);
|