quickbase-js 0.1.0-beta.13 → 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 +1 -1
- package/dist/esm/quickbase.d.ts +2 -1
- package/package.json +9 -4
- package/CHANGELOG.md +0 -239
- 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/BurstAwareThrottleBucket.ts +0 -57
- package/src/FlowThrottleBucket.ts +0 -47
- package/src/RateLimitError.ts +0 -12
- package/src/RateThrottleBucket.ts +0 -5
- package/src/Semaphore.ts +0 -33
- package/src/authorizationStrategy.ts +0 -321
- 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 -290
- package/src/pagination.ts +0 -429
- package/src/quickbaseClient.ts +0 -227
- 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/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/quickbase-js/BurstAwareThrottleBucket.test.ts +0 -125
- package/tests/vitest/qb/quickbase-js/FlowBucket.test.ts +0 -77
- package/tests/vitest/qb/quickbase-js/paginationSkip.test.ts +0 -111
- package/tests/vitest/qb/records/deleteRecords.test.ts +0 -110
- package/tests/vitest/qb/records/runQuery.test.ts +0 -145
- 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/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 -66
- 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/quickbase-js/BurstAwareThrottleBucket.test.ts +0 -108
- package/tests/vitest/unit/quickbase-js/FlowBucket.test.ts +0 -101
- package/tests/vitest/unit/quickbase-js/pagination.test.ts +0 -251
- package/tests/vitest/unit/quickbase-js/quickbaseClientHttpMethods.test.ts +0 -141
- package/tests/vitest/unit/quickbase-js/rateLimit.test.ts +0 -191
- package/tests/vitest/unit/quickbase-js/tokenLifespan.test.ts +0 -204
- package/tests/vitest/unit/records/deleteRecords.test.ts +0 -112
- package/tests/vitest/unit/records/runQuery.test.ts +0 -101
- 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/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,212 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
createClient,
|
|
4
|
-
mockFetch,
|
|
5
|
-
QB_TABLE_ID_1,
|
|
6
|
-
QB_TABLE_ID_2,
|
|
7
|
-
} from "@tests/setup.ts";
|
|
8
|
-
import {
|
|
9
|
-
CreateRelationship200Response,
|
|
10
|
-
CreateRelationshipRequest,
|
|
11
|
-
} from "/home/drew/Projects/quickbase-js/src/generated/models";
|
|
12
|
-
|
|
13
|
-
describe("QuickbaseClient Unit - createRelationship", () => {
|
|
14
|
-
let client: ReturnType<typeof createClient>;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
mockFetch.mockClear();
|
|
18
|
-
client = createClient(mockFetch, { debug: true });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("initializes without errors", () => {
|
|
22
|
-
expect(client).toBeDefined();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("has createRelationship method", () => {
|
|
26
|
-
expect(typeof client.createRelationship).toBe("function");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("sends correct request and handles successful response", async () => {
|
|
30
|
-
const mockResponse: CreateRelationship200Response = {
|
|
31
|
-
id: 6,
|
|
32
|
-
foreignKeyField: {
|
|
33
|
-
id: 6,
|
|
34
|
-
label: "my relationship field",
|
|
35
|
-
type: "numeric",
|
|
36
|
-
},
|
|
37
|
-
lookupFields: [
|
|
38
|
-
{ id: 7, label: "Field 1", type: "text" },
|
|
39
|
-
{ id: 8, label: "Field 2", type: "text" },
|
|
40
|
-
{ id: 9, label: "Field 3", type: "text" },
|
|
41
|
-
],
|
|
42
|
-
isCrossApp: false,
|
|
43
|
-
parentTableId: QB_TABLE_ID_1,
|
|
44
|
-
childTableId: QB_TABLE_ID_2,
|
|
45
|
-
summaryFields: [
|
|
46
|
-
{ id: 10, label: "my first summary field", type: "numeric" },
|
|
47
|
-
{ id: 11, label: "my second summary field", type: "numeric" },
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
mockFetch.mockResolvedValueOnce({
|
|
52
|
-
ok: true,
|
|
53
|
-
status: 200,
|
|
54
|
-
json: () => Promise.resolve(mockResponse),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const requestBody: CreateRelationshipRequest = {
|
|
58
|
-
parentTableId: QB_TABLE_ID_1,
|
|
59
|
-
foreignKeyField: { label: "my relationship field" },
|
|
60
|
-
lookupFieldIds: [1, 2, 3],
|
|
61
|
-
summaryFields: [
|
|
62
|
-
{
|
|
63
|
-
summaryFid: 3,
|
|
64
|
-
label: "my first summary field",
|
|
65
|
-
accumulationType: "AVG",
|
|
66
|
-
where: "{'3'.EX.1}",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
summaryFid: 4,
|
|
70
|
-
label: "my second summary field",
|
|
71
|
-
accumulationType: "SUM",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const tableId = QB_TABLE_ID_2;
|
|
77
|
-
|
|
78
|
-
const result = await client.createRelationship({
|
|
79
|
-
tableId,
|
|
80
|
-
body: requestBody,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
84
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
85
|
-
`https://api.quickbase.com/v1/tables/${QB_TABLE_ID_2}/relationship`,
|
|
86
|
-
expect.objectContaining({
|
|
87
|
-
method: "POST",
|
|
88
|
-
headers: expect.objectContaining({
|
|
89
|
-
"Content-Type": "application/json",
|
|
90
|
-
"QB-Realm-Hostname": "builderprogram-dbradford6815.quickbase.com",
|
|
91
|
-
Authorization:
|
|
92
|
-
"QB-USER-TOKEN b9f3pk_q4jd_0_b4qu5eebyvuix3xs57ysd7zn3",
|
|
93
|
-
}),
|
|
94
|
-
body: JSON.stringify(requestBody),
|
|
95
|
-
})
|
|
96
|
-
);
|
|
97
|
-
expect(result).toEqual(mockResponse);
|
|
98
|
-
expect(result.id).toBe(6);
|
|
99
|
-
expect(result.parentTableId).toBe(QB_TABLE_ID_1);
|
|
100
|
-
expect(result.childTableId).toBe(QB_TABLE_ID_2);
|
|
101
|
-
expect(result.foreignKeyField).toBeDefined();
|
|
102
|
-
if (result.foreignKeyField) {
|
|
103
|
-
expect(result.foreignKeyField.label).toBe("my relationship field");
|
|
104
|
-
}
|
|
105
|
-
expect(result.lookupFields).toHaveLength(3);
|
|
106
|
-
expect(result.summaryFields).toBeDefined();
|
|
107
|
-
if (result.summaryFields) {
|
|
108
|
-
expect(result.summaryFields).toHaveLength(2);
|
|
109
|
-
expect(result.summaryFields[0].label).toBe("my first summary field");
|
|
110
|
-
expect(result.summaryFields[1].label).toBe("my second summary field");
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("handles error from TablesApi", async () => {
|
|
115
|
-
mockFetch.mockResolvedValueOnce({
|
|
116
|
-
ok: false,
|
|
117
|
-
status: 400,
|
|
118
|
-
json: () => Promise.resolve({ message: "Invalid request payload" }),
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const requestBody: CreateRelationshipRequest = {
|
|
122
|
-
parentTableId: QB_TABLE_ID_1,
|
|
123
|
-
foreignKeyField: { label: "my relationship field" },
|
|
124
|
-
lookupFieldIds: [1, 2, 3],
|
|
125
|
-
summaryFields: [
|
|
126
|
-
{ summaryFid: 3, label: "invalid", accumulationType: "INVALID" },
|
|
127
|
-
],
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const tableId = QB_TABLE_ID_2;
|
|
131
|
-
|
|
132
|
-
await expect(
|
|
133
|
-
client.createRelationship({
|
|
134
|
-
tableId,
|
|
135
|
-
body: requestBody,
|
|
136
|
-
})
|
|
137
|
-
).rejects.toThrow("API Error: Invalid request payload (Status: 400)");
|
|
138
|
-
|
|
139
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
140
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
141
|
-
`https://api.quickbase.com/v1/tables/${QB_TABLE_ID_2}/relationship`,
|
|
142
|
-
expect.objectContaining({
|
|
143
|
-
method: "POST",
|
|
144
|
-
headers: expect.objectContaining({
|
|
145
|
-
"Content-Type": "application/json",
|
|
146
|
-
"QB-Realm-Hostname": "builderprogram-dbradford6815.quickbase.com",
|
|
147
|
-
Authorization:
|
|
148
|
-
"QB-USER-TOKEN b9f3pk_q4jd_0_b4qu5eebyvuix3xs57ysd7zn3",
|
|
149
|
-
}),
|
|
150
|
-
body: JSON.stringify(requestBody),
|
|
151
|
-
})
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("handles response with undefined foreignKeyField and summaryFields", async () => {
|
|
156
|
-
const mockResponse: CreateRelationship200Response = {
|
|
157
|
-
id: 6,
|
|
158
|
-
foreignKeyField: undefined,
|
|
159
|
-
lookupFields: [
|
|
160
|
-
{ id: 7, label: "Field 1", type: "text" },
|
|
161
|
-
{ id: 8, label: "Field 2", type: "text" },
|
|
162
|
-
{ id: 9, label: "Field 3", type: "text" },
|
|
163
|
-
],
|
|
164
|
-
isCrossApp: false,
|
|
165
|
-
parentTableId: QB_TABLE_ID_1,
|
|
166
|
-
childTableId: QB_TABLE_ID_2,
|
|
167
|
-
summaryFields: undefined,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
mockFetch.mockResolvedValueOnce({
|
|
171
|
-
ok: true,
|
|
172
|
-
status: 200,
|
|
173
|
-
json: () => Promise.resolve(mockResponse),
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const requestBody: CreateRelationshipRequest = {
|
|
177
|
-
parentTableId: QB_TABLE_ID_1,
|
|
178
|
-
foreignKeyField: undefined,
|
|
179
|
-
lookupFieldIds: [1, 2, 3],
|
|
180
|
-
summaryFields: undefined,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const tableId = QB_TABLE_ID_2;
|
|
184
|
-
|
|
185
|
-
const result = await client.createRelationship({
|
|
186
|
-
tableId,
|
|
187
|
-
body: requestBody,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
191
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
192
|
-
`https://api.quickbase.com/v1/tables/${QB_TABLE_ID_2}/relationship`,
|
|
193
|
-
expect.objectContaining({
|
|
194
|
-
method: "POST",
|
|
195
|
-
headers: expect.objectContaining({
|
|
196
|
-
"Content-Type": "application/json",
|
|
197
|
-
"QB-Realm-Hostname": "builderprogram-dbradford6815.quickbase.com",
|
|
198
|
-
Authorization:
|
|
199
|
-
"QB-USER-TOKEN b9f3pk_q4jd_0_b4qu5eebyvuix3xs57ysd7zn3",
|
|
200
|
-
}),
|
|
201
|
-
body: JSON.stringify(requestBody),
|
|
202
|
-
})
|
|
203
|
-
);
|
|
204
|
-
expect(result).toEqual(mockResponse);
|
|
205
|
-
expect(result.id).toBe(6);
|
|
206
|
-
expect(result.parentTableId).toBe(QB_TABLE_ID_1);
|
|
207
|
-
expect(result.childTableId).toBe(QB_TABLE_ID_2);
|
|
208
|
-
expect(result.foreignKeyField).toBeUndefined();
|
|
209
|
-
expect(result.lookupFields).toHaveLength(3);
|
|
210
|
-
expect(result.summaryFields).toBeUndefined();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// tests/vitest/unit/records/createTable.test.ts
|
|
2
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
createClient,
|
|
5
|
-
mockFetch,
|
|
6
|
-
QB_APP_ID,
|
|
7
|
-
QB_REALM,
|
|
8
|
-
QB_USER_TOKEN,
|
|
9
|
-
} from "@tests/setup.ts";
|
|
10
|
-
|
|
11
|
-
describe("QuickbaseClient Unit - createTable", () => {
|
|
12
|
-
let client: ReturnType<typeof createClient>;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
mockFetch.mockClear();
|
|
16
|
-
client = createClient(mockFetch, { debug: true });
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("calls createTable successfully with user token", async () => {
|
|
20
|
-
const mockBody = {
|
|
21
|
-
name: "TestTable",
|
|
22
|
-
description: "Unit test table",
|
|
23
|
-
singleRecordName: "Test",
|
|
24
|
-
pluralRecordName: "Tests",
|
|
25
|
-
};
|
|
26
|
-
const mockResponse = {
|
|
27
|
-
id: "newly-created-table-id-1234567890", // Changed from "buya8h9iz"
|
|
28
|
-
name: "TestTable",
|
|
29
|
-
alias: "_DBID_TESTTABLE",
|
|
30
|
-
description: "Unit test table",
|
|
31
|
-
created: new Date("2025-03-10T21:00:00.000Z"),
|
|
32
|
-
updated: new Date("2025-03-10T21:00:00.000Z"),
|
|
33
|
-
nextRecordId: 1,
|
|
34
|
-
nextFieldId: 6,
|
|
35
|
-
defaultSortFieldId: 2,
|
|
36
|
-
defaultSortOrder: "DESC",
|
|
37
|
-
keyFieldId: 3,
|
|
38
|
-
singleRecordName: "Test",
|
|
39
|
-
pluralRecordName: "Tests",
|
|
40
|
-
sizeLimit: "500 MB",
|
|
41
|
-
spaceUsed: "0 KB",
|
|
42
|
-
spaceRemaining: "500 MB",
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
mockFetch.mockResolvedValueOnce({
|
|
46
|
-
ok: true,
|
|
47
|
-
status: 200,
|
|
48
|
-
json: () => Promise.resolve(mockResponse),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const response = await client.createTable({
|
|
52
|
-
appId: QB_APP_ID,
|
|
53
|
-
body: mockBody,
|
|
54
|
-
});
|
|
55
|
-
expect(response).toEqual(mockResponse);
|
|
56
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
57
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
58
|
-
`https://api.quickbase.com/v1/tables?appId=${QB_APP_ID}`,
|
|
59
|
-
expect.objectContaining({
|
|
60
|
-
method: "POST",
|
|
61
|
-
headers: expect.objectContaining({
|
|
62
|
-
"Content-Type": "application/json",
|
|
63
|
-
"QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
|
|
64
|
-
Authorization: `QB-USER-TOKEN ${QB_USER_TOKEN}`,
|
|
65
|
-
}),
|
|
66
|
-
body: JSON.stringify(mockBody),
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// tests/vitest/unit/tables/deleteRelationship.test.ts
|
|
2
|
-
|
|
3
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
4
|
-
import {
|
|
5
|
-
createClient,
|
|
6
|
-
mockFetch,
|
|
7
|
-
QB_TABLE_ID_2, // Child table
|
|
8
|
-
} from "@tests/setup.ts";
|
|
9
|
-
|
|
10
|
-
describe("QuickbaseClient Unit - deleteRelationship", () => {
|
|
11
|
-
let client: ReturnType<typeof createClient>;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
mockFetch.mockClear();
|
|
15
|
-
client = createClient(mockFetch, { debug: true });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("initializes without errors", () => {
|
|
19
|
-
expect(client).toBeDefined();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("has deleteRelationship method", () => {
|
|
23
|
-
expect(typeof client.deleteRelationship).toBe("function");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("sends correct DELETE request and handles successful response", async () => {
|
|
27
|
-
// Mock response for a successful deletion
|
|
28
|
-
const mockResponse = {
|
|
29
|
-
deletedRelationshipId: 6, // Matches the relationshipId
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
mockFetch.mockResolvedValueOnce({
|
|
33
|
-
ok: true,
|
|
34
|
-
status: 200,
|
|
35
|
-
json: () => Promise.resolve(mockResponse),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const tableId = QB_TABLE_ID_2; // Child table
|
|
39
|
-
const relationshipId = 6; // Example relationship ID (foreign key field ID)
|
|
40
|
-
|
|
41
|
-
const result = await client.deleteRelationship({
|
|
42
|
-
tableId,
|
|
43
|
-
relationshipId,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Verify the fetch call
|
|
47
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
48
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
49
|
-
`https://api.quickbase.com/v1/tables/${QB_TABLE_ID_2}/relationship/6`,
|
|
50
|
-
expect.objectContaining({
|
|
51
|
-
method: "DELETE",
|
|
52
|
-
headers: expect.objectContaining({
|
|
53
|
-
"Content-Type": "application/json",
|
|
54
|
-
"QB-Realm-Hostname": "builderprogram-dbradford6815.quickbase.com",
|
|
55
|
-
Authorization:
|
|
56
|
-
"QB-USER-TOKEN b9f3pk_q4jd_0_b4qu5eebyvuix3xs57ysd7zn3",
|
|
57
|
-
}),
|
|
58
|
-
})
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// Verify the response
|
|
62
|
-
expect(result).toEqual(mockResponse);
|
|
63
|
-
expect(result.deletedRelationshipId).toBe(6);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("handles error when relationship is not found", async () => {
|
|
67
|
-
mockFetch.mockResolvedValueOnce({
|
|
68
|
-
ok: false,
|
|
69
|
-
status: 404,
|
|
70
|
-
json: () => Promise.resolve({ message: "Relationship not found" }),
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const tableId = QB_TABLE_ID_2;
|
|
74
|
-
const relationshipId = 999; // Non-existent relationship ID
|
|
75
|
-
|
|
76
|
-
await expect(
|
|
77
|
-
client.deleteRelationship({
|
|
78
|
-
tableId,
|
|
79
|
-
relationshipId,
|
|
80
|
-
})
|
|
81
|
-
).rejects.toThrow("API Error: Relationship not found (Status: 404)");
|
|
82
|
-
|
|
83
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
84
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
85
|
-
`https://api.quickbase.com/v1/tables/${QB_TABLE_ID_2}/relationship/999`,
|
|
86
|
-
expect.objectContaining({
|
|
87
|
-
method: "DELETE",
|
|
88
|
-
headers: expect.objectContaining({
|
|
89
|
-
"Content-Type": "application/json",
|
|
90
|
-
"QB-Realm-Hostname": "builderprogram-dbradford6815.quickbase.com",
|
|
91
|
-
Authorization:
|
|
92
|
-
"QB-USER-TOKEN b9f3pk_q4jd_0_b4qu5eebyvuix3xs57ysd7zn3",
|
|
93
|
-
}),
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// tests/vitest/unit/records/deleteTable.test.ts
|
|
2
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
createClient,
|
|
5
|
-
mockFetch,
|
|
6
|
-
QB_APP_ID,
|
|
7
|
-
QB_TABLE_ID_1,
|
|
8
|
-
QB_REALM,
|
|
9
|
-
QB_USER_TOKEN,
|
|
10
|
-
} from "@tests/setup.ts";
|
|
11
|
-
|
|
12
|
-
describe("QuickbaseClient Unit - deleteTable", () => {
|
|
13
|
-
let client: ReturnType<typeof createClient>;
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
mockFetch.mockClear();
|
|
17
|
-
client = createClient(mockFetch, { debug: true });
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("calls deleteTable successfully with user token", async () => {
|
|
21
|
-
const mockResponse = {
|
|
22
|
-
deletedTableId: QB_TABLE_ID_1,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
mockFetch.mockResolvedValueOnce({
|
|
26
|
-
ok: true,
|
|
27
|
-
status: 200,
|
|
28
|
-
json: () => Promise.resolve(mockResponse),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const response = await client.deleteTable({
|
|
32
|
-
tableId: QB_TABLE_ID_1,
|
|
33
|
-
appId: QB_APP_ID,
|
|
34
|
-
});
|
|
35
|
-
expect(response).toEqual(mockResponse);
|
|
36
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
37
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
38
|
-
`https://api.quickbase.com/v1/tables/${QB_TABLE_ID_1}?appId=${QB_APP_ID}`,
|
|
39
|
-
expect.objectContaining({
|
|
40
|
-
method: "DELETE",
|
|
41
|
-
headers: expect.objectContaining({
|
|
42
|
-
"Content-Type": "application/json",
|
|
43
|
-
"QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
|
|
44
|
-
Authorization: `QB-USER-TOKEN ${QB_USER_TOKEN}`,
|
|
45
|
-
}),
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("handles 404 error for non-existent table", async () => {
|
|
51
|
-
mockFetch.mockResolvedValueOnce({
|
|
52
|
-
ok: false,
|
|
53
|
-
status: 404,
|
|
54
|
-
json: () =>
|
|
55
|
-
Promise.resolve({
|
|
56
|
-
message: "Invalid DBID",
|
|
57
|
-
description: "Table not found in app.",
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
await expect(
|
|
62
|
-
client.deleteTable({ tableId: QB_TABLE_ID_1, appId: QB_APP_ID })
|
|
63
|
-
).rejects.toThrow("API Error: Invalid DBID (Status: 404)");
|
|
64
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
65
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
66
|
-
`https://api.quickbase.com/v1/tables/${QB_TABLE_ID_1}?appId=${QB_APP_ID}`,
|
|
67
|
-
expect.objectContaining({
|
|
68
|
-
method: "DELETE",
|
|
69
|
-
headers: expect.objectContaining({
|
|
70
|
-
"Content-Type": "application/json",
|
|
71
|
-
"QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
|
|
72
|
-
Authorization: `QB-USER-TOKEN ${QB_USER_TOKEN}`,
|
|
73
|
-
}),
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// tests/vitest/unit/tables/getAppTables.test.ts
|
|
2
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
createClient,
|
|
5
|
-
mockFetch,
|
|
6
|
-
QB_APP_ID,
|
|
7
|
-
QB_REALM,
|
|
8
|
-
QB_USER_TOKEN,
|
|
9
|
-
} from "@tests/setup.ts";
|
|
10
|
-
|
|
11
|
-
describe("QuickbaseClient Unit - getAppTables", () => {
|
|
12
|
-
let client: ReturnType<typeof createClient>;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
mockFetch.mockClear();
|
|
16
|
-
client = createClient(mockFetch, { debug: true }); // Add debug: true for consistency
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("calls getAppTables successfully", async () => {
|
|
20
|
-
mockFetch.mockImplementation((url: string, options: any) => {
|
|
21
|
-
console.log("Mock fetch for getAppTables:", url, options);
|
|
22
|
-
return Promise.resolve({
|
|
23
|
-
ok: true,
|
|
24
|
-
status: 200,
|
|
25
|
-
json: () =>
|
|
26
|
-
Promise.resolve([
|
|
27
|
-
{
|
|
28
|
-
id: "buwai2zr4",
|
|
29
|
-
name: "Root",
|
|
30
|
-
alias: "_DBID_ROOT",
|
|
31
|
-
description: "",
|
|
32
|
-
created: new Date("2025-02-13T18:22:33.000Z"),
|
|
33
|
-
updated: new Date("2025-02-13T18:22:34.000Z"),
|
|
34
|
-
nextRecordId: 1,
|
|
35
|
-
nextFieldId: 6,
|
|
36
|
-
defaultSortFieldId: 2,
|
|
37
|
-
defaultSortOrder: "DESC",
|
|
38
|
-
keyFieldId: 3,
|
|
39
|
-
singleRecordName: "Root",
|
|
40
|
-
pluralRecordName: "Roots",
|
|
41
|
-
sizeLimit: "500 MB",
|
|
42
|
-
spaceUsed: "0 KB",
|
|
43
|
-
spaceRemaining: "500 MB",
|
|
44
|
-
},
|
|
45
|
-
]),
|
|
46
|
-
} as Response);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const result = await client.getAppTables({ appId: QB_APP_ID });
|
|
50
|
-
console.log("getAppTables response:", result);
|
|
51
|
-
expect(result).toEqual(
|
|
52
|
-
expect.arrayContaining([
|
|
53
|
-
expect.objectContaining({
|
|
54
|
-
id: "buwai2zr4",
|
|
55
|
-
name: "Root",
|
|
56
|
-
alias: "_DBID_ROOT",
|
|
57
|
-
description: "",
|
|
58
|
-
created: new Date("2025-02-13T18:22:33.000Z"),
|
|
59
|
-
updated: new Date("2025-02-13T18:22:34.000Z"),
|
|
60
|
-
nextRecordId: 1,
|
|
61
|
-
nextFieldId: 6,
|
|
62
|
-
defaultSortFieldId: 2,
|
|
63
|
-
defaultSortOrder: "DESC",
|
|
64
|
-
keyFieldId: 3,
|
|
65
|
-
singleRecordName: "Root",
|
|
66
|
-
pluralRecordName: "Roots",
|
|
67
|
-
sizeLimit: "500 MB",
|
|
68
|
-
spaceUsed: "0 KB",
|
|
69
|
-
spaceRemaining: "500 MB",
|
|
70
|
-
}),
|
|
71
|
-
])
|
|
72
|
-
);
|
|
73
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
74
|
-
`https://api.quickbase.com/v1/tables?appId=${QB_APP_ID}`,
|
|
75
|
-
expect.objectContaining({
|
|
76
|
-
method: "GET",
|
|
77
|
-
headers: expect.objectContaining({
|
|
78
|
-
"QB-Realm-Hostname": `${QB_REALM}.quickbase.com`,
|
|
79
|
-
Authorization: `QB-USER-TOKEN ${QB_USER_TOKEN}`,
|
|
80
|
-
"Content-Type": "application/json",
|
|
81
|
-
}),
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
});
|