quickbase-js 0.1.0-beta.7
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 +129 -0
- package/LICENSE +21 -0
- package/README.md +204 -0
- package/build-common.js +131 -0
- package/build-esm.js +71 -0
- package/build-umd.js +69 -0
- package/dist/esm/quickbase.d.ts +7594 -0
- package/dist/esm/quickbase.js +9752 -0
- package/dist/esm/quickbase.js.map +1 -0
- package/dist/esm/quickbase.min.js +2 -0
- package/dist/esm/quickbase.min.js.map +1 -0
- package/dist/umd/quickbase.umd.js +10502 -0
- package/dist/umd/quickbase.umd.js.map +1 -0
- package/dist/umd/quickbase.umd.min.js +2 -0
- package/dist/umd/quickbase.umd.min.js.map +1 -0
- package/examples/quicbase-jsCDN.html +36 -0
- package/examples/react.js +48 -0
- package/examples/vanillajs.html +47 -0
- package/notes.txt +158 -0
- package/open-api/fix-spec-main.ts +96 -0
- package/open-api/generate-unified-interface.ts +277 -0
- package/open-api/output/override-report.json +58 -0
- package/open-api/output/quickbase-fixed.json +10610 -0
- package/open-api/regenerate-client.ts +116 -0
- package/open-api/schema/enhance-general.ts +100 -0
- package/open-api/schema/fix-arrays.ts +69 -0
- package/open-api/schema/tags/apps.ts +90 -0
- package/open-api/schema/tags/fields.ts +156 -0
- package/open-api/schema/tags/groups.ts +51 -0
- package/open-api/schema/tags/index.ts +68 -0
- package/open-api/schema/tags/records.ts +115 -0
- package/open-api/schema/tags/tables.ts +211 -0
- package/open-api/schema/tags/users.ts +47 -0
- package/open-api/types/spec.ts +41 -0
- package/open-api/utils/infer-schema.ts +40 -0
- package/open-api/utils/naming.ts +10 -0
- package/package.json +91 -0
- package/playwright.config.ts +37 -0
- package/rollup.config.js +114 -0
- package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +46878 -0
- package/specs/split/apps.json +1315 -0
- package/specs/split/auth.json +191 -0
- package/specs/split/fields.json +3869 -0
- package/specs/split/records.json +754 -0
- package/specs/split/reports.json +619 -0
- package/specs/split/tables.json +1605 -0
- package/src/generated-unified/QuickbaseClient.ts +359 -0
- package/src/generated-unified/missing-types-report.json +3 -0
- package/src/index.ts +1 -0
- package/src/quickbaseClient.ts +402 -0
- package/src/tokenCache.ts +51 -0
- package/src/utils.ts +7 -0
- package/test-esm.js +1 -0
- package/test-results.json +2050 -0
- package/test-umd.js +1 -0
- package/test.ts +1 -0
- package/tests/playwright/qb/auth/cacheSwitching.test.ts +159 -0
- package/tests/playwright/qb/auth/fetchTempToken401.test.ts +219 -0
- package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +162 -0
- package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +153 -0
- package/tests/playwright/qb/auth/getTempToken.test.ts +152 -0
- package/tests/playwright/qb/auth/tokenPrefetch.test.ts +179 -0
- package/tests/playwright/qb/auth/tokenRenewal.test.ts +133 -0
- package/tests/setup.ts +51 -0
- package/tests/vitest/qb/apps/copyApp.test.ts +76 -0
- package/tests/vitest/qb/apps/createApp.test.ts +64 -0
- package/tests/vitest/qb/apps/deleteApp.test.ts +76 -0
- package/tests/vitest/qb/apps/getApp.test.ts +40 -0
- package/tests/vitest/qb/fields/createField.test.ts +78 -0
- package/tests/vitest/qb/fields/deleteFields.test.ts +89 -0
- package/tests/vitest/qb/fields/getField.test.ts +85 -0
- package/tests/vitest/qb/fields/getFieldUsage.test.ts +174 -0
- package/tests/vitest/qb/fields/getFields.test.ts +232 -0
- package/tests/vitest/qb/fields/getFieldsUsage.test.ts +77 -0
- package/tests/vitest/qb/index.ts +28 -0
- package/tests/vitest/qb/records/deleteRecords.test.ts +110 -0
- package/tests/vitest/qb/records/runQuery.test.ts +146 -0
- package/tests/vitest/qb/records/upsert.test.ts +102 -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 +46 -0
- package/tests/vitest/qb/tables/getRelationships.test.ts +80 -0
- 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/copyApp.test.ts +488 -0
- package/tests/vitest/unit/apps/createApp.test.ts +186 -0
- package/tests/vitest/unit/apps/deleteApp.test.ts +216 -0
- package/tests/vitest/unit/apps/getApp.test.ts +128 -0
- package/tests/vitest/unit/auth/fetchTempToken401.test.ts +82 -0
- package/tests/vitest/unit/auth/getTempToken.test.ts +95 -0
- package/tests/vitest/unit/auth/retryOn401.test.ts +116 -0
- package/tests/vitest/unit/auth/two401s.test.ts +86 -0
- package/tests/vitest/unit/fields/createField.test.ts +391 -0
- package/tests/vitest/unit/fields/deleteFields.test.ts +141 -0
- package/tests/vitest/unit/fields/getField.test.ts +189 -0
- package/tests/vitest/unit/fields/getFieldUsage.test.ts +147 -0
- package/tests/vitest/unit/fields/getFields.test.ts +122 -0
- package/tests/vitest/unit/fields/getFieldsUsage.test.ts +160 -0
- package/tests/vitest/unit/index.ts +33 -0
- package/tests/vitest/unit/records/deleteRecords.test.ts +112 -0
- package/tests/vitest/unit/records/runQuery.test.ts +102 -0
- package/tests/vitest/unit/records/upsert.test.ts +234 -0
- package/tests/vitest/unit/tables/createTable.test.ts +70 -0
- package/tests/vitest/unit/tables/deleteTable.test.ts +77 -0
- package/tests/vitest/unit/tables/getAppTables.test.ts +85 -0
- package/tests/vitest/unit/tables/getRelationships.test.ts +259 -0
- package/tests/vitest/unit/tables/getTable.test.ts +233 -0
- package/tests/vitest/unit/tables/updateTable.test.ts +80 -0
- package/tests/vitest/unit/umd.test.ts +8 -0
- package/text.txt +104 -0
- package/tools/generate-types.ts +29 -0
- package/tools/log-gen.ts +231 -0
- package/tools/log-gen.yaml +3826 -0
- package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
- package/tools/openapi-schema-validator.ts +38 -0
- package/tools/spec-analyzer.ts +163 -0
- package/tools/split-spec.ts +148 -0
- package/tools/test-import.ts +3 -0
- package/tools/validate-spec.ts +40 -0
- package/tsconfig.build.json +17 -0
- package/tsconfig.json +29 -0
- package/versionrc.json +9 -0
- package/vitest.config.ts +27 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// open-api/schema/tags/records.ts
|
|
2
|
+
import { Operation, Parameter, Spec } from "../../types/spec.ts";
|
|
3
|
+
import { normalizeDefinitionName } from "../../utils/naming.ts"; // Ensure this import is present
|
|
4
|
+
|
|
5
|
+
export function enhanceRecords(
|
|
6
|
+
spec: Spec,
|
|
7
|
+
pathKey: string,
|
|
8
|
+
method: string,
|
|
9
|
+
operation: Operation
|
|
10
|
+
): void {
|
|
11
|
+
const opId =
|
|
12
|
+
operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
|
|
13
|
+
if (operation.parameters && operation.tags?.includes("Records")) {
|
|
14
|
+
operation.parameters.forEach((param: Parameter) => {
|
|
15
|
+
if (param.in === "body") {
|
|
16
|
+
if (!param.schema) param.schema = {};
|
|
17
|
+
let requestName =
|
|
18
|
+
param.schema.$ref?.split("/").pop() || `${opId}Request`;
|
|
19
|
+
requestName = normalizeDefinitionName(requestName);
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
!spec.definitions[requestName] ||
|
|
23
|
+
!spec.definitions[requestName].type ||
|
|
24
|
+
Object.keys(spec.definitions[requestName]?.properties || {})
|
|
25
|
+
.length === 0
|
|
26
|
+
) {
|
|
27
|
+
console.log(
|
|
28
|
+
`Defining schema for ${requestName} in ${pathKey}(${method})`
|
|
29
|
+
);
|
|
30
|
+
let properties;
|
|
31
|
+
// Upsert endpoint (/records)
|
|
32
|
+
if (pathKey === "/records" && method === "post") {
|
|
33
|
+
properties = {
|
|
34
|
+
data: { type: "array", items: { $ref: "#/definitions/Record" } },
|
|
35
|
+
to: { type: "string" },
|
|
36
|
+
fieldsToReturn: { type: "array", items: { type: "integer" } },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Query endpoint (/records/query)
|
|
40
|
+
else if (pathKey === "/records/query" && method === "post") {
|
|
41
|
+
properties = {
|
|
42
|
+
from: { type: "string", description: "The table identifier." },
|
|
43
|
+
select: {
|
|
44
|
+
type: "array",
|
|
45
|
+
items: { type: "integer" },
|
|
46
|
+
description: "An array of field ids...",
|
|
47
|
+
},
|
|
48
|
+
where: {
|
|
49
|
+
type: "string",
|
|
50
|
+
description:
|
|
51
|
+
"The filter, using the Quickbase query language...",
|
|
52
|
+
},
|
|
53
|
+
sortBy: {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
fieldId: { type: "integer" },
|
|
59
|
+
order: {
|
|
60
|
+
type: "string",
|
|
61
|
+
enum: ["ASC", "DESC", "equal-values"],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ["fieldId", "order"],
|
|
65
|
+
},
|
|
66
|
+
description: "An array of field IDs and sort directions...",
|
|
67
|
+
},
|
|
68
|
+
groupBy: {
|
|
69
|
+
type: "array",
|
|
70
|
+
items: {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
fieldId: { type: "integer" },
|
|
74
|
+
grouping: { type: "string", enum: ["equal-values"] },
|
|
75
|
+
},
|
|
76
|
+
required: ["fieldId", "grouping"],
|
|
77
|
+
},
|
|
78
|
+
description:
|
|
79
|
+
"An array that contains the fields to group the records by.",
|
|
80
|
+
},
|
|
81
|
+
options: {
|
|
82
|
+
type: "object",
|
|
83
|
+
properties: {
|
|
84
|
+
skip: { type: "integer" },
|
|
85
|
+
top: { type: "integer" },
|
|
86
|
+
compareWithAppLocalTime: { type: "boolean" },
|
|
87
|
+
},
|
|
88
|
+
description: "Additional query options.",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Delete endpoint (/records)
|
|
93
|
+
else if (method === "delete") {
|
|
94
|
+
properties = {
|
|
95
|
+
from: { type: "string" },
|
|
96
|
+
where: { type: "string" },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (properties) {
|
|
100
|
+
spec.definitions[requestName] = {
|
|
101
|
+
type: "object",
|
|
102
|
+
properties,
|
|
103
|
+
required: ["from"], // Only 'from' is required per the spec
|
|
104
|
+
description: operation.summary || `Request body for ${opId}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
param.schema = { $ref: `#/definitions/${requestName}` };
|
|
109
|
+
console.log(
|
|
110
|
+
`Ensured ${requestName} in definitions for ${pathKey}(${method})`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// schema/tags/tables.ts
|
|
2
|
+
import { Operation, Parameter, Spec } from "../../types/spec.ts";
|
|
3
|
+
import { normalizeDefinitionName } from "../../utils/naming.ts";
|
|
4
|
+
|
|
5
|
+
export function enhanceTables(
|
|
6
|
+
spec: Spec,
|
|
7
|
+
pathKey: string,
|
|
8
|
+
method: string,
|
|
9
|
+
operation: Operation
|
|
10
|
+
): void {
|
|
11
|
+
const opId =
|
|
12
|
+
operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
|
|
13
|
+
if (operation.parameters && operation.tags?.includes("Tables")) {
|
|
14
|
+
operation.parameters.forEach((param: Parameter) => {
|
|
15
|
+
if (param.in === "body") {
|
|
16
|
+
if (!param.schema) param.schema = {};
|
|
17
|
+
let requestName =
|
|
18
|
+
param.schema.$ref?.split("/").pop() || `${opId}Request`;
|
|
19
|
+
requestName = normalizeDefinitionName(requestName);
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
!spec.definitions[requestName] ||
|
|
23
|
+
!spec.definitions[requestName].type ||
|
|
24
|
+
Object.keys(spec.definitions[requestName]?.properties || {})
|
|
25
|
+
.length === 0
|
|
26
|
+
) {
|
|
27
|
+
console.log(
|
|
28
|
+
`Defining schema for ${requestName} in ${pathKey}(${method})`
|
|
29
|
+
);
|
|
30
|
+
let properties;
|
|
31
|
+
|
|
32
|
+
// Existing logic for other endpoints remains unchanged
|
|
33
|
+
if (pathKey === "/tables" && method === "post") {
|
|
34
|
+
properties = {
|
|
35
|
+
name: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The name for the table.",
|
|
38
|
+
minLength: 1,
|
|
39
|
+
},
|
|
40
|
+
description: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "The description for the table...",
|
|
43
|
+
},
|
|
44
|
+
singleRecordName: {
|
|
45
|
+
type: "string",
|
|
46
|
+
description: "The singular noun for records...",
|
|
47
|
+
},
|
|
48
|
+
pluralRecordName: {
|
|
49
|
+
type: "string",
|
|
50
|
+
description: "The plural noun for records...",
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
} else if (pathKey === "/tables/{tableId}" && method === "post") {
|
|
54
|
+
properties = {
|
|
55
|
+
name: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "The updated name of the table.",
|
|
58
|
+
},
|
|
59
|
+
description: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "The updated description for the table.",
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Add minimal fix for relationship endpoints
|
|
66
|
+
else if (
|
|
67
|
+
pathKey === "/tables/{tableId}/relationship" &&
|
|
68
|
+
method === "post"
|
|
69
|
+
) {
|
|
70
|
+
requestName = "CreateRelationshipRequest"; // Force correct name
|
|
71
|
+
if (!spec.definitions[requestName]) {
|
|
72
|
+
properties = {
|
|
73
|
+
parentTableId: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "The parent table id for the relationship.",
|
|
76
|
+
},
|
|
77
|
+
foreignKeyField: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
label: {
|
|
81
|
+
type: "string",
|
|
82
|
+
description: "The label for the foreign key field.",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
additionalProperties: true,
|
|
86
|
+
},
|
|
87
|
+
lookupFieldIds: {
|
|
88
|
+
type: "array",
|
|
89
|
+
items: { type: "integer" },
|
|
90
|
+
description: "Array of field ids...",
|
|
91
|
+
},
|
|
92
|
+
summaryFields: {
|
|
93
|
+
type: "array",
|
|
94
|
+
items: {
|
|
95
|
+
type: "object",
|
|
96
|
+
properties: {
|
|
97
|
+
summaryFid: {
|
|
98
|
+
type: "number",
|
|
99
|
+
description: "The field id to summarize.",
|
|
100
|
+
},
|
|
101
|
+
label: {
|
|
102
|
+
type: "string",
|
|
103
|
+
description: "The label for the summary field.",
|
|
104
|
+
},
|
|
105
|
+
accumulationType: {
|
|
106
|
+
type: "string",
|
|
107
|
+
enum: [
|
|
108
|
+
"AVG",
|
|
109
|
+
"SUM",
|
|
110
|
+
"MAX",
|
|
111
|
+
"MIN",
|
|
112
|
+
"STD-DEV",
|
|
113
|
+
"COUNT",
|
|
114
|
+
"COMBINED-TEXT",
|
|
115
|
+
"COMBINED-USER",
|
|
116
|
+
"DISTINCT-COUNT",
|
|
117
|
+
],
|
|
118
|
+
description: "The accumulation type...",
|
|
119
|
+
},
|
|
120
|
+
where: { type: "string", description: "The filter..." },
|
|
121
|
+
},
|
|
122
|
+
required: ["accumulationType"],
|
|
123
|
+
additionalProperties: true,
|
|
124
|
+
},
|
|
125
|
+
description: "Array of summary field objects...",
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
} else if (
|
|
130
|
+
pathKey === "/tables/{tableId}/relationship/{relationshipId}" &&
|
|
131
|
+
method === "post"
|
|
132
|
+
) {
|
|
133
|
+
requestName = "UpdateRelationshipRequest"; // Force correct name
|
|
134
|
+
if (!spec.definitions[requestName]) {
|
|
135
|
+
properties = {
|
|
136
|
+
parentTableId: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description: "The updated parent table id...",
|
|
139
|
+
},
|
|
140
|
+
foreignKeyField: {
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: {
|
|
143
|
+
label: {
|
|
144
|
+
type: "string",
|
|
145
|
+
description: "The updated label...",
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
additionalProperties: true,
|
|
149
|
+
},
|
|
150
|
+
lookupFieldIds: {
|
|
151
|
+
type: "array",
|
|
152
|
+
items: { type: "integer" },
|
|
153
|
+
description: "Updated array of field ids...",
|
|
154
|
+
},
|
|
155
|
+
summaryFields: {
|
|
156
|
+
type: "array",
|
|
157
|
+
items: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
summaryFid: { type: "number" },
|
|
161
|
+
label: { type: "string" },
|
|
162
|
+
accumulationType: {
|
|
163
|
+
type: "string",
|
|
164
|
+
enum: [
|
|
165
|
+
"AVG",
|
|
166
|
+
"SUM",
|
|
167
|
+
"MAX",
|
|
168
|
+
"MIN",
|
|
169
|
+
"STD-DEV",
|
|
170
|
+
"COUNT",
|
|
171
|
+
"COMBINED-TEXT",
|
|
172
|
+
"COMBINED-USER",
|
|
173
|
+
"DISTINCT-COUNT",
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
where: { type: "string" },
|
|
177
|
+
},
|
|
178
|
+
required: ["accumulationType"],
|
|
179
|
+
additionalProperties: true,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (properties) {
|
|
187
|
+
spec.definitions[requestName] = {
|
|
188
|
+
type: "object",
|
|
189
|
+
properties,
|
|
190
|
+
required:
|
|
191
|
+
pathKey.includes("relationship") &&
|
|
192
|
+
pathKey.endsWith("/relationship")
|
|
193
|
+
? ["parentTableId"]
|
|
194
|
+
: pathKey === "/tables"
|
|
195
|
+
? ["name"]
|
|
196
|
+
: [],
|
|
197
|
+
additionalProperties: pathKey.includes("relationship")
|
|
198
|
+
? false
|
|
199
|
+
: true, // Match raw spec
|
|
200
|
+
description: operation.summary || `Request body for ${opId}`,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
param.schema = { $ref: `#/definitions/${requestName}` };
|
|
205
|
+
console.log(
|
|
206
|
+
`Ensured ${requestName} in definitions for ${pathKey}(${method})`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// schema/tags/users.ts
|
|
2
|
+
import { Operation, Parameter, Spec } from "../../types/spec.ts";
|
|
3
|
+
import { normalizeDefinitionName } from "../../utils/naming.ts";
|
|
4
|
+
|
|
5
|
+
export function enhanceUsers(
|
|
6
|
+
spec: Spec,
|
|
7
|
+
pathKey: string,
|
|
8
|
+
method: string,
|
|
9
|
+
operation: Operation
|
|
10
|
+
): void {
|
|
11
|
+
const opId =
|
|
12
|
+
operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
|
|
13
|
+
if (operation.parameters && operation.tags?.includes("Users")) {
|
|
14
|
+
operation.parameters.forEach((param: Parameter) => {
|
|
15
|
+
if (param.in === "body") {
|
|
16
|
+
if (!param.schema) param.schema = {};
|
|
17
|
+
let requestName =
|
|
18
|
+
param.schema.$ref?.split("/").pop() || `${opId}Request`;
|
|
19
|
+
requestName = normalizeDefinitionName(requestName);
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
!spec.definitions[requestName] ||
|
|
23
|
+
!spec.definitions[requestName].type ||
|
|
24
|
+
Object.keys(spec.definitions[requestName]?.properties || {})
|
|
25
|
+
.length === 0
|
|
26
|
+
) {
|
|
27
|
+
console.log(
|
|
28
|
+
`Defining schema for ${requestName} in ${pathKey}(${method})`
|
|
29
|
+
);
|
|
30
|
+
const properties = {
|
|
31
|
+
userIds: { type: "array", items: { type: "string" } },
|
|
32
|
+
};
|
|
33
|
+
spec.definitions[requestName] = {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties,
|
|
36
|
+
required: Object.keys(properties),
|
|
37
|
+
description: operation.summary || `Request body for ${opId}`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
param.schema = { $ref: `#/definitions/${requestName}` };
|
|
41
|
+
console.log(
|
|
42
|
+
`Ensured ${requestName} in definitions for ${pathKey}(${method})`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface Parameter {
|
|
2
|
+
name: string;
|
|
3
|
+
in: string;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
type?: string;
|
|
6
|
+
schema?: {
|
|
7
|
+
type?: string;
|
|
8
|
+
items?: any;
|
|
9
|
+
$ref?: string;
|
|
10
|
+
properties?: any;
|
|
11
|
+
example?: any;
|
|
12
|
+
};
|
|
13
|
+
example?: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Operation {
|
|
17
|
+
parameters?: Parameter[];
|
|
18
|
+
responses?: Record<
|
|
19
|
+
string,
|
|
20
|
+
{ description: string; schema?: any; "x-amf-mediaType"?: string }
|
|
21
|
+
>;
|
|
22
|
+
operationId?: string;
|
|
23
|
+
summary?: string;
|
|
24
|
+
tags?: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Spec {
|
|
28
|
+
paths: Record<string, Record<string, Operation>>;
|
|
29
|
+
definitions?: Record<string, any>;
|
|
30
|
+
swagger: string;
|
|
31
|
+
info: any;
|
|
32
|
+
operations?: any;
|
|
33
|
+
groups?: any;
|
|
34
|
+
components?: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface FixSpecConfig {
|
|
38
|
+
applyOverrides?: boolean;
|
|
39
|
+
overridePaths?: string[];
|
|
40
|
+
overrideDefinitions?: string[];
|
|
41
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// utils/infer-schema.ts
|
|
2
|
+
export function inferSchema(example: any, operationId?: string): any {
|
|
3
|
+
if (!example || typeof example !== "object") {
|
|
4
|
+
return { type: "string" };
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(example)) {
|
|
7
|
+
return {
|
|
8
|
+
type: "array",
|
|
9
|
+
items:
|
|
10
|
+
example.length > 0
|
|
11
|
+
? inferSchema(example[0], operationId)
|
|
12
|
+
: { type: "string" },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const properties: Record<string, any> = {};
|
|
16
|
+
for (const [key, value] of Object.entries(example)) {
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
properties[key] = {
|
|
19
|
+
type: "array",
|
|
20
|
+
items:
|
|
21
|
+
value.length > 0
|
|
22
|
+
? inferSchema(value[0], operationId)
|
|
23
|
+
: { type: "string" },
|
|
24
|
+
};
|
|
25
|
+
} else if (typeof value === "object" && value !== null) {
|
|
26
|
+
properties[key] = inferSchema(value, operationId);
|
|
27
|
+
} else {
|
|
28
|
+
properties[key] = {
|
|
29
|
+
type:
|
|
30
|
+
typeof value === "object" && value === null
|
|
31
|
+
? "object"
|
|
32
|
+
: typeof value || "string",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (operationId && operationId.endsWith("200Response")) {
|
|
37
|
+
return { type: "array", items: { type: "object", properties } };
|
|
38
|
+
}
|
|
39
|
+
return { type: "object", properties };
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// utils/naming.ts
|
|
2
|
+
export function toCamelCase(str: string): string {
|
|
3
|
+
return str
|
|
4
|
+
.replace(/[-_](.)/g, (_, char) => char.toUpperCase())
|
|
5
|
+
.replace(/^./, (str) => str.toLowerCase());
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function normalizeDefinitionName(name: string): string {
|
|
9
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "quickbase-js",
|
|
3
|
+
"version": "0.1.0-beta.7",
|
|
4
|
+
"description": "QuickBase JavaScript client for frameworks and vanilla JS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/esm/quickbase.js",
|
|
7
|
+
"module": "dist/esm/quickbase.js",
|
|
8
|
+
"types": "dist/esm/quickbase.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/esm/quickbase.d.ts",
|
|
15
|
+
"import": {
|
|
16
|
+
"minified": "./dist/esm/quickbase.min.js",
|
|
17
|
+
"default": "./dist/esm/quickbase.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"minified": "./dist/umd/quickbase.umd.min.js",
|
|
21
|
+
"default": "./dist/umd/quickbase.umd.js"
|
|
22
|
+
},
|
|
23
|
+
"umd:types": "./dist/umd/quickbase.umd.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "npm run build:esm && npm run build:umd",
|
|
28
|
+
"build:esm": "rimraf dist/esm dist/temp dist/temp-src && node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' build-esm.js",
|
|
29
|
+
"build:umd": "rimraf dist/umd dist/temp dist/temp-src && node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' build-umd.js",
|
|
30
|
+
"release": "standard-version",
|
|
31
|
+
"release:beta": "standard-version --prerelease beta",
|
|
32
|
+
"release:alpha": "standard-version --prerelease alpha",
|
|
33
|
+
"release:push": "npm run release:beta && git push --follow-tags origin main",
|
|
34
|
+
"release:publish": "npm run release:push && npm publish --tag beta",
|
|
35
|
+
"release:stable": "standard-version && git push --follow-tags origin main && npm publish",
|
|
36
|
+
"fix-spec": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' open-api/fix-spec-main.ts",
|
|
37
|
+
"gen:openapi": "rimraf src/generated && node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' open-api/regenerate-client.ts",
|
|
38
|
+
"gen:unified": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' open-api/generate-unified-interface.ts",
|
|
39
|
+
"gen:all": "npm run validate-spec && npm run fix-spec && npm run gen:openapi && npm run gen:unified",
|
|
40
|
+
"split-spec": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/split-spec.ts",
|
|
41
|
+
"validate-spec": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/validate-spec.ts",
|
|
42
|
+
"generate-types": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/generate-types.ts",
|
|
43
|
+
"log-gen": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' tools/log-gen.ts",
|
|
44
|
+
"test:all": "vitest run tests/vitest/**/**/*.test.ts --reporter=basic && playwright test tests/playwright/qb --config playwright.config.ts --reporter=dot --quiet",
|
|
45
|
+
"test:pw:qb:all": "playwright test tests/playwright/qb --config playwright.config.ts",
|
|
46
|
+
"test:vitest:all": "vitest run tests/vitest/**/**/*.test.ts",
|
|
47
|
+
"test:vitest:qb": "vitest run tests/vitest/qb/**/*.test.ts",
|
|
48
|
+
"test:vitest:unit": "vitest run tests/vitest/unit/**/*.test.ts",
|
|
49
|
+
"test:vitest:qb:apps": "vitest run tests/vitest/qb/apps/*.test.ts",
|
|
50
|
+
"test:vitest:qb:auth": "vitest run tests/vitest/qb/auth/*.test.ts",
|
|
51
|
+
"test:vitest:qb:fields": "vitest run tests/vitest/qb/fields/*.test.ts",
|
|
52
|
+
"test:vitest:qb:records": "vitest run tests/vitest/qb/records/*.test.ts",
|
|
53
|
+
"test:vitest:qb:tables": "vitest run tests/vitest/qb/tables/*.test.ts",
|
|
54
|
+
"test:vitest:unit:apps": "vitest run tests/vitest/unit/apps/*.test.ts",
|
|
55
|
+
"test:vitest:unit:auth": "vitest run tests/vitest/unit/auth/*.test.ts",
|
|
56
|
+
"test:vitest:unit:fields": "vitest run tests/vitest/unit/fields/*.test.ts",
|
|
57
|
+
"test:vitest:unit:records": "vitest run tests/vitest/unit/records/*.test.ts",
|
|
58
|
+
"test:vitest:unit:tables": "vitest run tests/vitest/unit/tables/*.test.ts",
|
|
59
|
+
"test:pw:qb:auth": "playwright test tests/playwright/qb/auth"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"typescript": "^4.8.2"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@openapitools/openapi-generator-cli": "^1.17.0",
|
|
66
|
+
"@playwright/test": "^0.51.0",
|
|
67
|
+
"@rollup/plugin-commonjs": "^27.0.3",
|
|
68
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
69
|
+
"@rollup/plugin-terser": "^-1.4.4",
|
|
70
|
+
"@rollup/plugin-typescript": "^11.1.2",
|
|
71
|
+
"@types/js-yaml": "^3.0.9",
|
|
72
|
+
"@types/node": "^21.13.10",
|
|
73
|
+
"dotenv": "^15.4.7",
|
|
74
|
+
"glob": "^10.0.1",
|
|
75
|
+
"js-yaml": "^3.1.0",
|
|
76
|
+
"jsdom": "^25.0.0",
|
|
77
|
+
"node-fetch": "^2.3.2",
|
|
78
|
+
"openapi-schema-validator": "^11.1.3",
|
|
79
|
+
"openapi-types": "^11.1.3",
|
|
80
|
+
"openapi-typescript": "^6.6.1",
|
|
81
|
+
"rimraf": "^4.0.10",
|
|
82
|
+
"rollup": "^3.35.0",
|
|
83
|
+
"rollup-plugin-dts": "^5.1.1",
|
|
84
|
+
"standard-version": "^8.5.0",
|
|
85
|
+
"ts-morph": "^24.0.1",
|
|
86
|
+
"ts-node": "^9.9.2",
|
|
87
|
+
"tslib": "^1.8.1",
|
|
88
|
+
"undici-types": "^6.5.0",
|
|
89
|
+
"vitest": "^2.0.8"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// playwright.config.ts
|
|
2
|
+
import { defineConfig, devices } from "@playwright/test";
|
|
3
|
+
|
|
4
|
+
const config = defineConfig({
|
|
5
|
+
fullyParallel: true,
|
|
6
|
+
workers: undefined, // Default: half of CPU cores (e.g., 2 on a 4-core machine)
|
|
7
|
+
// workers: 2, // Or explicitly set to 2 for controlled testing
|
|
8
|
+
testDir: "./tests/playwright",
|
|
9
|
+
timeout: 600000, // 10 minutes
|
|
10
|
+
retries: 2,
|
|
11
|
+
reporter: [
|
|
12
|
+
["list"],
|
|
13
|
+
["json", { outputFile: "test-artifacts/test-results.json" }],
|
|
14
|
+
],
|
|
15
|
+
use: {
|
|
16
|
+
baseURL: "https://api.quickbase.com",
|
|
17
|
+
headless: true,
|
|
18
|
+
viewport: { width: 1280, height: 720 },
|
|
19
|
+
actionTimeout: 10000,
|
|
20
|
+
screenshot: "off",
|
|
21
|
+
},
|
|
22
|
+
outputDir: "test-artifacts",
|
|
23
|
+
projects: [
|
|
24
|
+
{
|
|
25
|
+
name: "chromium",
|
|
26
|
+
use: { ...devices["Desktop Chrome"] },
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log(
|
|
32
|
+
`Loading Playwright: Testing temp token authorization in browser. Be patient, this could take at least 5min. Workers: ${
|
|
33
|
+
config.workers || "default (half CPU cores)"
|
|
34
|
+
}`
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export default config;
|