quickbase-js 1.1.0-beta.6 → 1.1.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/README.md +253 -135
- package/dist/esm/quickbase.d.ts +5614 -2861
- package/dist/esm/quickbase.js +3204 -2116
- 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 +3533 -2325
- 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 +49 -32
- package/CHANGELOG.md +0 -93
- package/build.js +0 -186
- package/dist/umd/quickbase.umd.d.ts +0 -5341
- package/examples/react.js +0 -48
- package/examples/vanillajs.html +0 -47
- package/examples/vanillatest.html +0 -49
- package/log-gen.yaml +0 -1372
- package/open-api/definitions/apps.ts +0 -274
- package/open-api/definitions/auth.ts +0 -10
- package/open-api/definitions/fields.ts +0 -751
- package/open-api/definitions/index.ts +0 -18
- package/open-api/definitions/records.ts +0 -269
- package/open-api/definitions/relationships.ts +0 -90
- package/open-api/definitions/reports.ts +0 -10
- package/open-api/definitions/tables.ts +0 -112
- package/open-api/fix-spec-main.ts +0 -176
- package/open-api/generate-unified-interface.ts +0 -170
- package/open-api/output/quickbase-fixed.json +0 -6760
- package/open-api/paths/apps.ts +0 -100
- package/open-api/paths/auth.ts +0 -25
- package/open-api/paths/fields.ts +0 -207
- package/open-api/paths/index.ts +0 -17
- package/open-api/paths/records.ts +0 -68
- package/open-api/paths/relationships.ts +0 -32
- package/open-api/paths/reports.ts +0 -34
- package/open-api/paths/tables.ts +0 -162
- package/open-api/regenerate-client.ts +0 -110
- package/playwright-results.txt/.last-run.json +0 -4
- package/playwright.config.ts +0 -37
- package/rollup.config.mjs +0 -114
- package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -46878
- package/src/generated-unified/QuickbaseClient.ts +0 -62
- package/src/index.ts +0 -1
- package/src/quickbaseClient.ts +0 -313
- package/src/tokenCache.ts +0 -51
- package/test-artifacts/.last-run.json +0 -6
- package/test-esm.js +0 -1
- package/test-results.json +0 -2050
- package/test-umd.js +0 -1
- package/test.ts +0 -1
- package/tests/playwright/qb/auth/cacheSwitching.test.ts +0 -189
- package/tests/playwright/qb/auth/fetchTempToken401.test.ts +0 -217
- package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +0 -151
- package/tests/playwright/qb/auth/getTempToken.test.ts +0 -180
- package/tests/playwright/qb/auth/tokenPrefetch.test.ts +0 -192
- package/tests/playwright/qb/auth/tokenRenewal.test.ts +0 -110
- package/tests/playwright/qb/auth/umd.test.ts +0 -10
- package/tests/setup.ts +0 -51
- 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 -40
- package/tests/vitest/qb/fields/createField.test.ts +0 -78
- package/tests/vitest/qb/fields/deleteFields.test.ts +0 -89
- package/tests/vitest/qb/fields/getField.test.ts +0 -85
- package/tests/vitest/qb/fields/getFieldUsage.test.ts +0 -174
- package/tests/vitest/qb/fields/getFields.test.ts +0 -232
- package/tests/vitest/qb/fields/getFieldsUsage.test.ts +0 -77
- package/tests/vitest/qb/index.ts +0 -28
- 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/createTable.test.ts +0 -55
- 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/updateTable.test.ts +0 -48
- package/tests/vitest/unit/apps/copyApp.test.ts +0 -282
- package/tests/vitest/unit/apps/createApp.test.ts +0 -125
- package/tests/vitest/unit/apps/deleteApp.test.ts +0 -215
- package/tests/vitest/unit/apps/getApp.test.ts +0 -86
- package/tests/vitest/unit/auth/fetchTempToken401.test.ts +0 -85
- package/tests/vitest/unit/auth/getTempToken.test.ts +0 -95
- package/tests/vitest/unit/auth/retryOn401.test.ts +0 -106
- package/tests/vitest/unit/auth/two401s.test.ts +0 -77
- package/tests/vitest/unit/fields/createField.test.ts +0 -391
- 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 -147
- package/tests/vitest/unit/fields/getFields.test.ts +0 -122
- package/tests/vitest/unit/fields/getFieldsUsage.test.ts +0 -160
- package/tests/vitest/unit/index.ts +0 -33
- 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 -218
- package/tests/vitest/unit/tables/createTable.test.ts +0 -70
- 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/updateTable.test.ts +0 -80
- package/tests/vitest/unit/umd.test.ts +0 -8
- package/text.txt +0 -104
- package/tools/log-gen.ts +0 -175
- package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
- package/tsconfig.build.json +0 -17
- package/tsconfig.json +0 -29
- package/versionrc.json +0 -9
- package/vitest.config.ts +0 -27
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
2
|
-
import { join, dirname } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { OpenAPIV2 } from "openapi-types";
|
|
5
|
-
|
|
6
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const SPEC_FILE = join(__dirname, "output", "quickbase-fixed.json"); // Remains relative to open-api/
|
|
8
|
-
const OUTPUT_DIR = join(__dirname, "..", "src", "generated-unified"); // Updated to src/generated-unified/
|
|
9
|
-
const OUTPUT_FILE = join(OUTPUT_DIR, "QuickbaseClient.ts");
|
|
10
|
-
|
|
11
|
-
// Placeholder for simplifyName (since utils.ts is missing)
|
|
12
|
-
function simplifyName(name: string): string {
|
|
13
|
-
return name
|
|
14
|
-
.replace(/ById$/, "")
|
|
15
|
-
.replace(/Api$/, "")
|
|
16
|
-
.replace(/^(\w)/, (_, c) => c.toLowerCase());
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function generateInterface() {
|
|
20
|
-
if (!existsSync(SPEC_FILE)) {
|
|
21
|
-
console.error(
|
|
22
|
-
`Spec file ${SPEC_FILE} not found. Run 'npm run fix-spec' first.`
|
|
23
|
-
);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
console.log("Generating unified QuickbaseClient interface...");
|
|
28
|
-
const spec = JSON.parse(
|
|
29
|
-
readFileSync(SPEC_FILE, "utf8")
|
|
30
|
-
) as OpenAPIV2.Document;
|
|
31
|
-
const { paths } = spec;
|
|
32
|
-
|
|
33
|
-
const modelImports = new Set<string>();
|
|
34
|
-
const methods: string[] = [];
|
|
35
|
-
|
|
36
|
-
for (const [path, methodsObj] of Object.entries(
|
|
37
|
-
paths as OpenAPIV2.PathsObject
|
|
38
|
-
)) {
|
|
39
|
-
if (!methodsObj) continue;
|
|
40
|
-
|
|
41
|
-
for (const [method, operation] of Object.entries(
|
|
42
|
-
methodsObj as OpenAPIV2.PathItemObject
|
|
43
|
-
)) {
|
|
44
|
-
const op = operation as OpenAPIV2.OperationObject | undefined;
|
|
45
|
-
if (!op || !op.operationId) continue;
|
|
46
|
-
|
|
47
|
-
const opId = simplifyName(op.operationId);
|
|
48
|
-
const params = (op.parameters || [])
|
|
49
|
-
.filter((p) => {
|
|
50
|
-
const param = p as OpenAPIV2.ParameterObject;
|
|
51
|
-
return !["QB-Realm-Hostname", "Authorization", "User-Agent"].includes(
|
|
52
|
-
param.name
|
|
53
|
-
);
|
|
54
|
-
})
|
|
55
|
-
.map((p) => {
|
|
56
|
-
const param = p as OpenAPIV2.ParameterObject;
|
|
57
|
-
const type = param.type
|
|
58
|
-
? mapOpenApiTypeToTs(param.type)
|
|
59
|
-
: param.schema
|
|
60
|
-
? mapRefToType(param.schema, modelImports)
|
|
61
|
-
: "any";
|
|
62
|
-
return `${param.name}${param.required ? "" : "?"}: ${type}`;
|
|
63
|
-
})
|
|
64
|
-
.join("; ");
|
|
65
|
-
|
|
66
|
-
const successResponses = ["200", "207"]
|
|
67
|
-
.map((code) => ({
|
|
68
|
-
code,
|
|
69
|
-
response: op.responses?.[code] as
|
|
70
|
-
| OpenAPIV2.ResponseObject
|
|
71
|
-
| undefined,
|
|
72
|
-
}))
|
|
73
|
-
.filter(({ response }) => response?.schema);
|
|
74
|
-
const returnTypes = successResponses.map(({ response }) =>
|
|
75
|
-
mapRefToType(response!.schema, modelImports)
|
|
76
|
-
);
|
|
77
|
-
const uniqueReturnTypes = [...new Set(returnTypes)];
|
|
78
|
-
const returnType =
|
|
79
|
-
uniqueReturnTypes.length > 0 ? uniqueReturnTypes.join(" | ") : "void";
|
|
80
|
-
|
|
81
|
-
methods.push(
|
|
82
|
-
` ${opId}: (params: { ${params} }) => Promise<${returnType}>;`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const importStatement =
|
|
88
|
-
modelImports.size > 0
|
|
89
|
-
? `import { ${Array.from(modelImports)
|
|
90
|
-
.sort()
|
|
91
|
-
.join(", ")} } from "../generated/models";`
|
|
92
|
-
: "";
|
|
93
|
-
|
|
94
|
-
const interfaceContent = `// Generated on ${new Date().toISOString()}\n${importStatement}\n\nexport interface QuickbaseClient {\n${methods.join(
|
|
95
|
-
"\n"
|
|
96
|
-
)}\n}\n`;
|
|
97
|
-
|
|
98
|
-
if (!existsSync(OUTPUT_DIR)) {
|
|
99
|
-
mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
100
|
-
}
|
|
101
|
-
writeFileSync(OUTPUT_FILE, interfaceContent, "utf8");
|
|
102
|
-
console.log(`Generated ${OUTPUT_FILE}`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function mapOpenApiTypeToTs(
|
|
106
|
-
openApiType: string | string[] | undefined
|
|
107
|
-
): string {
|
|
108
|
-
const type = Array.isArray(openApiType)
|
|
109
|
-
? openApiType[0]
|
|
110
|
-
: openApiType || "any";
|
|
111
|
-
switch (type.toLowerCase()) {
|
|
112
|
-
case "integer":
|
|
113
|
-
case "int":
|
|
114
|
-
return "number";
|
|
115
|
-
case "string":
|
|
116
|
-
return "string";
|
|
117
|
-
case "boolean":
|
|
118
|
-
return "boolean";
|
|
119
|
-
default:
|
|
120
|
-
return "any";
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function mapRefToType(
|
|
125
|
-
schema: OpenAPIV2.SchemaObject | OpenAPIV2.ReferenceObject | undefined,
|
|
126
|
-
modelImports: Set<string>
|
|
127
|
-
): string {
|
|
128
|
-
if (!schema) return "any";
|
|
129
|
-
|
|
130
|
-
if ("$ref" in schema && schema.$ref) {
|
|
131
|
-
const model = schema.$ref.split("/").pop()!;
|
|
132
|
-
modelImports.add(model);
|
|
133
|
-
return model;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (schema.type === "array" && schema.items) {
|
|
137
|
-
const itemType =
|
|
138
|
-
"$ref" in schema.items && schema.items.$ref
|
|
139
|
-
? schema.items.$ref.split("/").pop()!
|
|
140
|
-
: mapOpenApiTypeToTs(schema.items.type);
|
|
141
|
-
if ("$ref" in schema.items && schema.items.$ref) modelImports.add(itemType);
|
|
142
|
-
return `${itemType}[]`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (schema.type === "object" && schema.additionalProperties) {
|
|
146
|
-
const additionalProps = schema.additionalProperties as
|
|
147
|
-
| OpenAPIV2.SchemaObject
|
|
148
|
-
| OpenAPIV2.ReferenceObject
|
|
149
|
-
| boolean;
|
|
150
|
-
if (typeof additionalProps === "boolean") {
|
|
151
|
-
return "{ [key: string]: any }";
|
|
152
|
-
}
|
|
153
|
-
const valueType =
|
|
154
|
-
"$ref" in additionalProps && additionalProps.$ref
|
|
155
|
-
? additionalProps.$ref.split("/").pop()!
|
|
156
|
-
: mapOpenApiTypeToTs(additionalProps.type);
|
|
157
|
-
if ("$ref" in additionalProps && additionalProps.$ref)
|
|
158
|
-
modelImports.add(valueType);
|
|
159
|
-
return `{ [key: string]: ${valueType} }`;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return mapOpenApiTypeToTs(schema.type);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
generateInterface();
|
|
167
|
-
} catch (error) {
|
|
168
|
-
console.error("Generation failed:", error);
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|