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,29 @@
|
|
|
1
|
+
// tools/generate-types.ts
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import * as glob from "glob";
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
|
|
8
|
+
async function generateTypes(): Promise<void> {
|
|
9
|
+
const CODEGEN_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const SPLIT_DIR = path.join(CODEGEN_DIR, "..", "specs", "split");
|
|
11
|
+
const OUTPUT_DIR = path.join(CODEGEN_DIR, "..", "src", "generated-types");
|
|
12
|
+
|
|
13
|
+
await fs.mkdir(OUTPUT_DIR, { recursive: true });
|
|
14
|
+
|
|
15
|
+
const specFiles = glob.sync(path.join(SPLIT_DIR, "*.json"));
|
|
16
|
+
for (const specFile of specFiles) {
|
|
17
|
+
const category = path.basename(specFile, ".json");
|
|
18
|
+
const outputFile = path.join(OUTPUT_DIR, `${category}.ts`);
|
|
19
|
+
console.log(`Generating types for ${category}...`);
|
|
20
|
+
execSync(`npx openapi-typescript ${specFile} --output ${outputFile}`, {
|
|
21
|
+
stdio: "inherit",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
generateTypes().catch((error) => {
|
|
27
|
+
console.error("Failed to generate types:", error);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
});
|
package/tools/log-gen.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import yaml from "js-yaml";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const rootDir: string = "./";
|
|
11
|
+
const excludeDirs: string[] = [
|
|
12
|
+
"node_modules",
|
|
13
|
+
".git",
|
|
14
|
+
"specs",
|
|
15
|
+
"open-api/output",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
const includeFolders: string[] = [
|
|
20
|
+
// "open-api",
|
|
21
|
+
// "open-api/definitions",
|
|
22
|
+
// "open-api/paths",
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
// prettier-ignore
|
|
26
|
+
const includeRecursiveFolders: string[] = [
|
|
27
|
+
"open-api"
|
|
28
|
+
// "tests",
|
|
29
|
+
// "tests/vitest/unit",
|
|
30
|
+
// "tests/vitest/qb"
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
// prettier-ignore
|
|
34
|
+
const includeFiles: string[] = [
|
|
35
|
+
// "package.json",
|
|
36
|
+
// "tsconfig.json",
|
|
37
|
+
// "tsconfig.build.json",
|
|
38
|
+
// "rollup.config.js",
|
|
39
|
+
// "vitest.config.ts",
|
|
40
|
+
// "build-common.js",
|
|
41
|
+
// "build-umd.js",
|
|
42
|
+
// "build-esm.js",
|
|
43
|
+
// "src/tokenCache.ts",
|
|
44
|
+
// "src/generated/runtime.ts",
|
|
45
|
+
// "src/quickbaseClient.ts",
|
|
46
|
+
// "src/generated-unified/QuickbaseClient.ts",
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const projectGoals: string[] = [
|
|
50
|
+
"A library for interacting with the QuickBase RESTful API.",
|
|
51
|
+
"Use OpenAPI to generate types and methods using a proxy. Validate with tests.",
|
|
52
|
+
"Provide robust and intuitive temporary token support for browser environments.",
|
|
53
|
+
"User Tokens support both Node.js and browser environments.",
|
|
54
|
+
"Use case: JS frameworks like React, Vue, and Angular hosted in QuickBase code pages.",
|
|
55
|
+
"Enable a flexible or native fetch in the browser.",
|
|
56
|
+
"Enable a flexible fetch framework in Node.js.",
|
|
57
|
+
"#",
|
|
58
|
+
"No manual updating methods when the QuickBase API changes.",
|
|
59
|
+
"The proxy magic dynamically maps generated methods and types.",
|
|
60
|
+
"#",
|
|
61
|
+
"TokenCache is defined per quickbaseClient call, so each instance has its own isolated TokenCache.",
|
|
62
|
+
"Each quickbase client instance has an isolated and individual token cache.",
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const pipelineOverview: string[] = [
|
|
66
|
+
"What I’m Trying to Do",
|
|
67
|
+
"My approach is to ensure AppsApi.ts is generated with getAppById so QuickbaseClient.ts can map it to client.getApp. Steps include:",
|
|
68
|
+
"Fix fix-spec.ts:",
|
|
69
|
+
'Add tags: ["Apps"] to /apps/* endpoints to group them into AppsApi.ts.',
|
|
70
|
+
"Ensure all endpoints and models are correctly defined and typed.",
|
|
71
|
+
"Debug regenerate-client.ts:",
|
|
72
|
+
"Enhance logging to catch why AppsApi.ts isn’t generated.",
|
|
73
|
+
"Test if getAppById appears in another file (e.g., DefaultApi.ts).",
|
|
74
|
+
"Update QuickbaseClient.ts:",
|
|
75
|
+
"Adjust imports to use the correct API class once generated.",
|
|
76
|
+
"Test and Iterate:",
|
|
77
|
+
"Run npm run fix-spec, npm run regenerate, and npm run test to verify AppsApi.ts exists and test.ts works.",
|
|
78
|
+
"The latest fix-spec.ts with tags aims to force the generator to create AppsApi.ts, addressing the missing file issue.",
|
|
79
|
+
"Relevant Project Files",
|
|
80
|
+
"Here’s a list of files that would help understand and resolve this problem, along with their roles:",
|
|
81
|
+
"src/code-generation/fix-spec.ts:",
|
|
82
|
+
"Role: Modifies the original QuickBase spec (e.g., QuickBase_RESTful_*.json) to create quickbase-fixed.json with required endpoints (e.g., /apps/{appId}).",
|
|
83
|
+
"Relevance: Defines the spec fed to the generator; errors here affect generation.",
|
|
84
|
+
"src/code-generation/quickbase-fixed.json:",
|
|
85
|
+
"Role: The processed OpenAPI spec used by regenerate-client.ts to generate code.",
|
|
86
|
+
'Relevance: Confirms if /apps/{appId} is correctly structured with operationId: "getAppById".',
|
|
87
|
+
"src/code-generation/regenerate-client.ts:",
|
|
88
|
+
"Role: Runs OpenAPI Generator to produce src/generated/ files (APIs and models) and fixes .ts extensions with ts-morph.",
|
|
89
|
+
"Relevance: Controls the generation process; logs reveal why AppsApi.ts is missing.",
|
|
90
|
+
"src/generated/apis/AppsApi.ts (if exists):",
|
|
91
|
+
"Role: Should contain getAppById method for /apps/{appId} GET.",
|
|
92
|
+
"Relevance: Missing file is the core issue; its absence breaks QuickbaseClient.ts.",
|
|
93
|
+
"src/generated/apis/DefaultApi.ts:",
|
|
94
|
+
"Role: Default API class for untagged operations.",
|
|
95
|
+
"Relevance: Might contain getAppById if tags are misconfigured.",
|
|
96
|
+
"src/QuickbaseClient.ts:",
|
|
97
|
+
"Role: Wraps generated API classes (e.g., AppsApi) in a Proxy for ergonomic calls (e.g., client.getApp).",
|
|
98
|
+
"Relevance: Fails to import AppsApi.ts, causing the runtime error.",
|
|
99
|
+
"src/test.ts:",
|
|
100
|
+
"Role: Test script calling client.getApp({ appId }).",
|
|
101
|
+
"Relevance: Final validation point; shows if the fix works.",
|
|
102
|
+
".env.development:",
|
|
103
|
+
"Role: Stores QB_REALM, QB_USER_TOKEN, QB_APP_ID for API authentication.",
|
|
104
|
+
"Relevance: Ensures the API call has valid credentials (not the current issue, but critical for success).",
|
|
105
|
+
"src/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json (or similar):",
|
|
106
|
+
"Role: Original QuickBase API spec before fix-spec.ts processing.",
|
|
107
|
+
"Relevance: Shows how /apps/{appId} was originally defined, helping identify conflicts.",
|
|
108
|
+
"package.json:",
|
|
109
|
+
"Role: Defines scripts (fix-spec, regenerate, test) and dependencies (e.g., ts-node, openapi-generator-cli).",
|
|
110
|
+
"Relevance: Confirms script commands and versions align with our process.",
|
|
111
|
+
"What We Achieved",
|
|
112
|
+
"Goal Met: You can now call client.getApp({ appId: \"buwai2zpe\" }) and get the app details { id: 'buwai2zpe', name: 'qb-copy' }.",
|
|
113
|
+
"Fixes Applied:",
|
|
114
|
+
'Added tags: ["Apps"] in fix-spec.ts to ensure AppsApi.ts is generated with getAppById.',
|
|
115
|
+
"Updated QuickbaseClient.ts to:",
|
|
116
|
+
"Use prototype methods via Object.getOwnPropertyNames.",
|
|
117
|
+
"Bind methods to preserve context with .bind(api).",
|
|
118
|
+
"Handle getAppById’s direct JSON return instead of a Response object.",
|
|
119
|
+
"Result: The ergonomic API you wanted (client.getApp) works seamlessly with the generated AppsApi.ts.",
|
|
120
|
+
"Why It Works Now",
|
|
121
|
+
"fix-spec.ts:",
|
|
122
|
+
'Correctly defined /apps/{appId} with operationId: "getAppById" and tags: ["Apps"], ensuring AppsApi.ts generation.',
|
|
123
|
+
"regenerate-client.ts:",
|
|
124
|
+
"Successfully ran OpenAPI Generator to produce AppsApi.ts with getAppById.",
|
|
125
|
+
"QuickbaseClient.ts:",
|
|
126
|
+
"buildMethodMap now captures getAppById and maps it to getApp.",
|
|
127
|
+
"invokeMethod passes { appId: 'buwai2zpe' } as requestParameters and handles the JSON response directly.",
|
|
128
|
+
"test.ts:",
|
|
129
|
+
"Calls client.getApp and logs the result, proving the end-to-end flow.",
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
interface TreeNode {
|
|
133
|
+
name: string;
|
|
134
|
+
type: "directory" | "file";
|
|
135
|
+
contents?: string;
|
|
136
|
+
children?: TreeNode[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function buildTree(dir: string): TreeNode {
|
|
140
|
+
const node: TreeNode = {
|
|
141
|
+
name: path.basename(dir) || "",
|
|
142
|
+
type: "directory",
|
|
143
|
+
children: [],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const files: fs.Dirent[] = fs.readdirSync(dir, { withFileTypes: true });
|
|
147
|
+
|
|
148
|
+
files.forEach((file: fs.Dirent) => {
|
|
149
|
+
const filePath: string = path.join(dir, file.name);
|
|
150
|
+
const relativePath: string = path
|
|
151
|
+
.relative(rootDir, filePath)
|
|
152
|
+
.replace(/\\/g, "/");
|
|
153
|
+
|
|
154
|
+
if (file.isDirectory() && excludeDirs.includes(relativePath)) return;
|
|
155
|
+
|
|
156
|
+
const childNode: TreeNode = {
|
|
157
|
+
name: file.name,
|
|
158
|
+
type: file.isDirectory() ? "directory" : "file",
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
if (file.isDirectory()) {
|
|
162
|
+
childNode.children = buildTree(filePath).children;
|
|
163
|
+
} else {
|
|
164
|
+
const isInIncludeFolder = includeFolders.some((folder) => {
|
|
165
|
+
const folderPath = folder.endsWith("/") ? folder : folder + "/";
|
|
166
|
+
return (
|
|
167
|
+
relativePath.startsWith(folderPath) &&
|
|
168
|
+
relativePath.split("/").length === folderPath.split("/").length
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const isInIncludeRecursiveFolder = includeRecursiveFolders.some(
|
|
173
|
+
(folder) =>
|
|
174
|
+
relativePath.startsWith(folder + "/") || relativePath === folder
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const shouldInclude =
|
|
178
|
+
includeFiles.includes(relativePath) ||
|
|
179
|
+
isInIncludeFolder ||
|
|
180
|
+
isInIncludeRecursiveFolder;
|
|
181
|
+
|
|
182
|
+
if (shouldInclude) {
|
|
183
|
+
// Check if the file is in open-api/output
|
|
184
|
+
const isInOutputDir = relativePath.startsWith("open-api/output/");
|
|
185
|
+
|
|
186
|
+
if (!isInOutputDir) {
|
|
187
|
+
// Only read contents if not in output directory
|
|
188
|
+
try {
|
|
189
|
+
childNode.contents = fs.readFileSync(filePath, "utf8");
|
|
190
|
+
} catch (err: unknown) {
|
|
191
|
+
childNode.contents = `[Error reading file: ${
|
|
192
|
+
(err as Error).message
|
|
193
|
+
}]`;
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
// For files in output directory, just mark their existence
|
|
197
|
+
childNode.contents = "[File contents excluded - output directory]";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
node.children!.push(childNode);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
return node;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function generateTreeSnapshot(): string {
|
|
209
|
+
const snapshot = {
|
|
210
|
+
project: "quickbase-js",
|
|
211
|
+
date: new Date().toLocaleDateString(),
|
|
212
|
+
root: path.resolve(rootDir),
|
|
213
|
+
goals: projectGoals,
|
|
214
|
+
pipelineOverview: pipelineOverview,
|
|
215
|
+
tree: buildTree(rootDir),
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return yaml.dump(snapshot, { lineWidth: -2 });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
try {
|
|
222
|
+
const output: string = generateTreeSnapshot();
|
|
223
|
+
const outputPath: string = path.join(__dirname, "log-gen.yaml");
|
|
224
|
+
fs.writeFileSync(outputPath, output, "utf8");
|
|
225
|
+
const lineCount: number = output.split("\n").length - 0;
|
|
226
|
+
console.log("log-gen.yaml");
|
|
227
|
+
console.log(`Lines: ${lineCount}`);
|
|
228
|
+
} catch (error: unknown) {
|
|
229
|
+
console.error("Failed to generate tree snapshot:", (error as Error).message);
|
|
230
|
+
process.exit(0);
|
|
231
|
+
}
|