quickbase-js 1.1.0-beta.3 → 1.1.0-beta.5

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +115 -5
  3. package/build.js +175 -55
  4. package/dist/{quickbase.d.ts → esm/quickbase.d.ts} +1108 -349
  5. package/dist/{quickbase.js → esm/quickbase.js} +828 -263
  6. package/dist/esm/quickbase.js.map +1 -0
  7. package/dist/esm/quickbase.min.js +2 -0
  8. package/dist/esm/quickbase.min.js.map +1 -0
  9. package/dist/umd/quickbase.umd.d.ts +5341 -0
  10. package/dist/umd/quickbase.umd.js +7696 -0
  11. package/dist/umd/quickbase.umd.js.map +1 -0
  12. package/dist/umd/quickbase.umd.min.js +2 -0
  13. package/dist/umd/quickbase.umd.min.js.map +1 -0
  14. package/examples/react.js +12 -12
  15. package/examples/vanillajs.html +12 -12
  16. package/log-gen.yaml +536 -1915
  17. package/open-api/definitions/apps.ts +274 -0
  18. package/open-api/definitions/auth.ts +10 -0
  19. package/open-api/definitions/fields.ts +751 -0
  20. package/open-api/definitions/index.ts +18 -0
  21. package/open-api/definitions/records.ts +269 -0
  22. package/open-api/definitions/relationships.ts +90 -0
  23. package/open-api/definitions/reports.ts +10 -0
  24. package/open-api/definitions/tables.ts +112 -0
  25. package/{src/code-generation → open-api}/fix-spec-main.ts +3 -3
  26. package/{src/code-generation → open-api}/generate-unified-interface.ts +42 -17
  27. package/{src/code-generation → open-api}/output/quickbase-fixed.json +3244 -4586
  28. package/open-api/paths/apps.ts +100 -0
  29. package/open-api/paths/auth.ts +25 -0
  30. package/open-api/paths/fields.ts +207 -0
  31. package/open-api/paths/index.ts +17 -0
  32. package/open-api/paths/records.ts +68 -0
  33. package/open-api/paths/relationships.ts +32 -0
  34. package/open-api/paths/reports.ts +34 -0
  35. package/open-api/paths/tables.ts +162 -0
  36. package/{src/code-generation → open-api}/regenerate-client.ts +4 -4
  37. package/package.json +34 -25
  38. package/playwright-results.txt/.last-run.json +4 -0
  39. package/playwright.config.ts +1 -1
  40. package/rollup.config.mjs +114 -0
  41. package/src/generated-unified/QuickbaseClient.ts +7 -6
  42. package/test-artifacts/.last-run.json +4 -2
  43. package/test-esm.js +1 -0
  44. package/test-umd.js +1 -0
  45. package/test.ts +1 -0
  46. package/tests/playwright/qb/auth/umd.test.ts +10 -0
  47. package/tests/vitest/qb/fields/createField.test.ts +78 -0
  48. package/tests/vitest/qb/fields/deleteFields.test.ts +89 -0
  49. package/tests/vitest/qb/fields/getField.test.ts +85 -0
  50. package/tests/vitest/qb/fields/getFieldUsage.test.ts +174 -0
  51. package/tests/vitest/qb/fields/getFieldsUsage.test.ts +77 -0
  52. package/tests/vitest/qb/index.ts +25 -1
  53. package/tests/vitest/unit/fields/createField.test.ts +391 -0
  54. package/tests/vitest/unit/fields/deleteFields.test.ts +141 -0
  55. package/tests/vitest/unit/fields/getField.test.ts +189 -0
  56. package/tests/vitest/unit/fields/getFieldUsage.test.ts +147 -0
  57. package/tests/vitest/unit/fields/getFieldsUsage.test.ts +160 -0
  58. package/tests/vitest/unit/index.ts +30 -1
  59. package/tests/vitest/unit/umd.test.ts +8 -0
  60. package/{src → tools}/log-gen.ts +14 -10
  61. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  62. package/tsconfig.build.json +17 -0
  63. package/tsconfig.json +5 -5
  64. package/dist/quickbase.js.map +0 -1
  65. package/rollup.config.js +0 -70
  66. package/src/code-generation/fix-spec-definitions.ts +0 -809
  67. package/src/code-generation/fix-spec-paths.ts +0 -439
  68. package/test-artifacts/test-results.json +0 -829
  69. /package/{src/specs → specs}/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.1.0-beta.5](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.1.0-beta.4...v1.1.0-beta.5) (2025-03-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * ESM and UMD build prod ([49513e9](https://github.com/DrewBradfordXYZ/quickbase-js/commit/49513e902e7bf4dd35da3c6508242e96507a91bd))
11
+ * ESM and UMD support and src folder reorganization ([dc0170b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/dc0170b547e6e9e57a117fbcccfdbeb86e48a8c7))
12
+
13
+ ## [1.1.0-beta.4](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.1.0-beta.3...v1.1.0-beta.4) (2025-03-12)
14
+
15
+
16
+ ### Features
17
+
18
+ * createField and deleteFields tests are passing ([4b47c4d](https://github.com/DrewBradfordXYZ/quickbase-js/commit/4b47c4deb9b3d731e6e7938c12fcebe97830568b))
19
+ * createField mock and integration tests pass ([b227c73](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b227c73b08f7efa5ce5f3d0c2897f82c8976a009))
20
+ * deleteFields spec update ([1f8beca](https://github.com/DrewBradfordXYZ/quickbase-js/commit/1f8becaca0d6b7950648c1b9bc2b0215781fa829))
21
+ * getFeildsUsage.test.ts unit and integration tests pass ([82a4886](https://github.com/DrewBradfordXYZ/quickbase-js/commit/82a488622967ec24a8767cbb19c59ef4ce808749))
22
+ * getField.test.ts unit and integration tests pass ([3e50b70](https://github.com/DrewBradfordXYZ/quickbase-js/commit/3e50b704f0ebea47f2fee3d02d811ea1b43db6c4))
23
+ * getFieldsUsage fix spec ([031faaa](https://github.com/DrewBradfordXYZ/quickbase-js/commit/031faaaeab9597f35fdd1ddcf5157ce5d774390b))
24
+ * getFieldUsage spec and unit test pass ([ac2824b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/ac2824b226140dde99e33cf594d57bd6ffd4dc39))
25
+ * getFieldUsage unit and integration tests pass ([e62b586](https://github.com/DrewBradfordXYZ/quickbase-js/commit/e62b586d534620479a25dda2796ba5dcb8043705))
26
+ * split up fix-spec-paths and fix-spec-definitions into many files ([20d3246](https://github.com/DrewBradfordXYZ/quickbase-js/commit/20d32464e6337028778845fa55fbb19c5543f7eb))
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * cleanup createField.test.ts logging ([7b1306b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/7b1306bd8eb49e2c932ce267f33457e949e0f74b))
32
+ * createField test syntax update ([043f964](https://github.com/DrewBradfordXYZ/quickbase-js/commit/043f964a47346878440eb73cc10c110dab904ad7))
33
+ * getFieldsUsage type fix ([4c6f271](https://github.com/DrewBradfordXYZ/quickbase-js/commit/4c6f271d123131ae13a236664f28fbbdfde3d564))
34
+ * update deleteFields error type spec ([1788e1c](https://github.com/DrewBradfordXYZ/quickbase-js/commit/1788e1ce6d4d2c8df871ec8b112be908d706f884))
35
+
5
36
  ## [1.1.0-beta.3](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.1.0-beta.2...v1.1.0-beta.3) (2025-03-11)
6
37
 
7
38
  ### Features
package/README.md CHANGED
@@ -1,14 +1,124 @@
1
1
  # quickbase-js
2
2
 
3
+ # Installation
4
+
5
+ ```bash
6
+ npm install --save quickbase-js
7
+ ```
8
+
9
+ ## Example
10
+
11
+ ```html
12
+ <!DOCTYPE html>
13
+ <html>
14
+ <head>
15
+ <title>Quickbase Test</title>
16
+ </head>
17
+
18
+ <body>
19
+ <div>
20
+ <h1>Quickbase Test</h1>
21
+ <p id="result">Loading...</p>
22
+ </div>
23
+ <script type="module">
24
+ import { quickbase } from "quickbase-js";
25
+ // Initalize the QuickBase client
26
+ const qb = quickbase({
27
+ realm: "your-realm", // Replace with actual QuickBase realm
28
+ // ## ------------------------------
29
+ // ## Authentication Options
30
+ // ## ----------------------------
31
+ // ## OPTION 1: User Token Authentication
32
+ // ## - Use this if you have a QuickBase user token.
33
+ // ## - Works in Node.js or browsers, ideal for standalone apps or testing outside QuickBase
34
+ // ## - Uncomment the line below and replace with your token; comment out 'useTempTokens'
35
+ // userToken: "your-user-token",
36
+
37
+ // ## ----------------------------
38
+ // ## OPTION 2: Temporary Token Authentication
39
+ // ## - Use this for QuickBase code pages, leveraging the browser’s authenticated session
40
+ // ## - No user token needed; requires running in a QuickBase browser context
41
+ // ## - Uncomment the line below and comment out 'userToken' if using this option
42
+ // useTempTokens: true,
43
+ });
44
+
45
+ // Fetch the app
46
+ qb.getApp({ appId: "your-app-id" }) // Replace with actual app ID
47
+ .then((app) => {
48
+ document.getElementById(
49
+ "result"
50
+ ).textContent = `App Name: ${app.name}`;
51
+ })
52
+ .catch((err) => {
53
+ console.error("Error fetching app:", err);
54
+ document.getElementById("result").textContent =
55
+ err.message || "Failed to load app";
56
+ });
57
+ </script>
58
+ </body>
59
+ </html>
60
+ ```
61
+
3
62
  # Development workflow
4
63
 
5
64
  ```bash
6
- npm run fix-spec
7
- npm run regenerate
8
- npm run generate-unified
65
+ npm run regenerate:all
9
66
  npm run build
10
- npm run test
11
- npm run test:pw:qb:all
67
+ npm run test:all
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ ### Node.js (ESM - Recommended)
73
+
74
+ For modern Node.js applications, use ES modules:
75
+
76
+ ```javascript
77
+ // ESM (Node.js) - Recommended
78
+ import { quickbase } from "quickbase-js";
79
+ const qb = quickbase({ realm: "example", userToken: "your-token" });
80
+
81
+ // Example: Fetching an app
82
+ const app = await qb.getApp({ appId: "your-app-id" });
83
+ console.log(app);
84
+
85
+ // Example: Creating a record with temporary token
86
+ const qbTemp = quickbase({ realm: "example", useTempTokens: true });
87
+ const record = await qbTemp.upsert({
88
+ body: {
89
+ to: "your-table-id",
90
+ data: [
91
+ {
92
+ /* record data */
93
+ },
94
+ ],
95
+ },
96
+ });
97
+ console.log(record);
98
+ ```
99
+
100
+ ```javascript
101
+ // Example: TypeScript ESM (Recommended)
102
+ import { quickbase } from "quickbase-js";
103
+ const qbTyped: QuickbaseClient = quickbase({
104
+ realm: "example",
105
+ userToken: "your-token",
106
+ });
107
+ const typedApp = await qbTyped.getApp({ appId: "your-app-id" });
108
+ console.log(typedApp);
109
+ ```
110
+
111
+ ```javascript
112
+ // Example: UMD via CDN (QuickBase Code Pages)
113
+ // Note: This is HTML, not JavaScript, and should be used in a browser environment
114
+
115
+ <script src="https://cdn.jsdelivr.net/npm/quickbase-js@1.1.0-beta.4/dist/umd/quickbase.umd.js"></script>
116
+ <script>
117
+ const qb = new QuickbaseJS({ realm: 'example', useTempTokens: true });
118
+ // Example: Fetching an app
119
+ qb.getApp({ appId: 'your-app-id' }).then(app => console.log(app));
120
+ </script>
121
+
12
122
  ```
13
123
 
14
124
  ## In QuickBase Code Pages (Browser Environment)
package/build.js CHANGED
@@ -1,66 +1,186 @@
1
- #!/usr/bin/env node
2
- const { readFile, writeFile } = require("fs/promises");
3
- const { execSync } = require("child_process");
4
- const esbuild = require("esbuild");
5
- const pkg = require("./package.json");
1
+ import { execSync } from 'child_process';
2
+ import { rollup } from 'rollup';
3
+ import terser from '@rollup/plugin-terser';
4
+ import nodeResolve from '@rollup/plugin-node-resolve';
5
+ import commonjs from '@rollup/plugin-commonjs';
6
+ import dts from 'rollup-plugin-dts';
7
+ import { rimrafSync } from 'rimraf';
8
+ import { copyFileSync, readdirSync, readFileSync, writeFileSync, mkdirSync, statSync } from 'fs';
9
+ import { join } from 'path';
6
10
 
7
- async function build() {
8
- try {
9
- // Compile TypeScript
10
- console.log("Compiling TypeScript...");
11
- execSync("npx tsc -b", { stdio: "inherit" });
11
+ // Clean the dist folder
12
+ rimrafSync('dist');
13
+ rimrafSync('dist/temp-src');
12
14
 
13
- // Format with Prettier
14
- console.log("Formatting files with Prettier...");
15
- execSync("npx prettier --write src/**/*.ts dist/**/*.js", {
16
- stdio: "inherit",
17
- });
15
+ // Step 1: Copy runtime-relevant files from src/ to dist/temp-src and remove .ts extensions
16
+ const srcDir = join(process.cwd(), 'src');
17
+ const tempSrcDir = join(process.cwd(), 'dist/temp-src');
18
+ const runtimeDirs = ['generated', 'generated-unified'];
19
+ const runtimeFiles = ['index.ts', 'quickbaseClient.ts', 'tokenCache.ts'];
18
20
 
19
- // Bundle for Browser
20
- console.log("Bundling for Browser...");
21
- await esbuild.build({
22
- entryPoints: ["dist/QuickBaseClient.js"],
23
- bundle: true,
24
- minify: true,
21
+ function copyAndRewriteTsExtensions(src, dest) {
22
+ console.log(`Copying from ${src} to ${dest}`);
23
+ mkdirSync(dest, { recursive: true });
24
+ const files = readdirSync(src, { withFileTypes: true });
25
+ for (const file of files) {
26
+ const srcPath = join(src, file.name);
27
+ const destPath = join(dest, file.name);
28
+ if (file.isDirectory()) {
29
+ if (runtimeDirs.includes(file.name) || runtimeDirs.some(dir => src.includes(dir))) {
30
+ copyAndRewriteTsExtensions(srcPath, destPath);
31
+ } else {
32
+ console.log(`Skipping non-runtime directory ${srcPath}`);
33
+ }
34
+ } else if (file.name.endsWith('.ts')) {
35
+ if (runtimeFiles.includes(file.name) || src.includes('generated') || src.includes('generated-unified')) {
36
+ console.log(`Processing ${srcPath} -> ${destPath}`);
37
+ let content = readFileSync(srcPath, 'utf8');
38
+ content = content.replace(/(from\s+["']\.[\w\/-]+)\.ts(["'])/g, '$1$2');
39
+ content = content.replace(/(export\s+\*\s+from\s+["']\.[\w\/-]+)\.ts(["'])/g, '$1$2');
40
+ writeFileSync(destPath, content, 'utf8');
41
+ } else {
42
+ console.log(`Skipping non-runtime file ${srcPath}`);
43
+ }
44
+ } else {
45
+ console.log(`Skipping non-.ts file ${srcPath}`);
46
+ }
47
+ }
48
+ }
49
+ copyAndRewriteTsExtensions(srcDir, tempSrcDir);
50
+
51
+ // Step 2: Compile TypeScript to JavaScript with tsc
52
+ console.log('Running tsc...');
53
+ const tsFiles = readdirSync(tempSrcDir, { recursive: true })
54
+ .filter(file => file.endsWith('.ts'))
55
+ .map(file => join(tempSrcDir, file));
56
+ const tscCommand = `npx tsc ${tsFiles.join(' ')} --outDir ${join(process.cwd(), 'dist/temp')} --module ESNext --target ESNext --sourceMap --moduleResolution bundler --baseUrl ${process.cwd()}`;
57
+ console.log(`Command: ${tscCommand}`);
58
+ execSync(tscCommand, { stdio: 'inherit' });
59
+
60
+ // Step 3: Rollup configuration
61
+ const isProd = process.env.NODE_ENV === 'production';
62
+ const external = [
63
+ 'node:http', 'node:https', 'node:zlib', 'node:stream', 'node:buffer',
64
+ 'node:util', 'node:url', 'node:net', 'node:fs', 'node:path', 'node-fetch',
65
+ ];
66
+ const globals = { 'node-fetch': 'fetch' };
67
+
68
+ // Function to create Rollup bundle
69
+ async function createBundle(input, plugins, format, outputOptions) {
70
+ const bundle = await rollup({
71
+ input,
72
+ external,
73
+ plugins,
74
+ });
75
+ await bundle.write(outputOptions);
76
+ await bundle.close();
77
+ }
78
+
79
+ // ESM Builds
80
+ console.log('Building ESM bundles...');
81
+ // Unminified ESM build (always generated)
82
+ await createBundle(
83
+ 'dist/temp/quickbaseClient.js',
84
+ [
85
+ nodeResolve({ preferBuiltins: true }),
86
+ commonjs(),
87
+ ],
88
+ 'esm',
89
+ {
90
+ dir: 'dist/esm',
91
+ format: 'esm',
92
+ sourcemap: true,
93
+ entryFileNames: 'quickbase.js',
94
+ }
95
+ );
96
+
97
+ // Minified ESM build (only in production)
98
+ if (isProd) {
99
+ await createBundle(
100
+ 'dist/temp/quickbaseClient.js',
101
+ [
102
+ nodeResolve({ preferBuiltins: true }),
103
+ commonjs(),
104
+ terser(),
105
+ ],
106
+ 'esm',
107
+ {
108
+ dir: 'dist/esm',
109
+ format: 'esm',
25
110
  sourcemap: true,
26
- target: ["es2015"],
27
- outfile: "dist/quickbase-client.browser.min.js",
28
- });
111
+ entryFileNames: 'quickbase.min.js',
112
+ }
113
+ );
114
+ }
29
115
 
30
- // Load Sources
31
- console.log("Loading Sources...");
32
- const browserSource = await readFile(
33
- "dist/quickbase-client.browser.min.js",
34
- "utf8"
35
- );
36
- const cjsSource = await readFile("dist/QuickBaseClient.js", "utf8");
37
- const license = await readFile("LICENSE", "utf8");
116
+ // UMD Builds
117
+ console.log('Building UMD bundles...');
118
+ // Unminified UMD build (always generated)
119
+ await createBundle(
120
+ 'dist/temp/quickbaseClient.js',
121
+ [
122
+ nodeResolve({ preferBuiltins: true, browser: true }),
123
+ commonjs(),
124
+ ],
125
+ 'umd',
126
+ {
127
+ file: join(process.cwd(), 'dist/umd', 'quickbase.umd.js'),
128
+ format: 'umd',
129
+ name: 'QuickbaseJS',
130
+ sourcemap: true,
131
+ globals,
132
+ }
133
+ );
134
+
135
+ // Minified UMD build (only in production)
136
+ if (isProd) {
137
+ await createBundle(
138
+ 'dist/temp/quickbaseClient.js',
139
+ [
140
+ nodeResolve({ preferBuiltins: true, browser: true }),
141
+ commonjs(),
142
+ terser(),
143
+ ],
144
+ 'umd',
145
+ {
146
+ file: join(process.cwd(), 'dist/umd', 'quickbase.umd.min.js'),
147
+ format: 'umd',
148
+ name: 'QuickbaseJS',
149
+ sourcemap: true,
150
+ globals,
151
+ }
152
+ );
153
+ }
38
154
 
39
- // Build Header
40
- console.log("Adding Metadata...");
41
- const header = [
42
- "/*! ",
43
- ` * ${pkg.name} v${pkg.version}`,
44
- ` * ${pkg.description || "A QuickBase API Client"}`,
45
- ` * License: ${pkg.license}`,
46
- ` * ${license}`,
47
- " */",
48
- ].join("\n");
155
+ // Declarations
156
+ console.log('Generating declarations...');
157
+ const dtsBundle = await rollup({
158
+ input: 'src/quickbaseClient.ts',
159
+ plugins: [dts({ tsconfig: './tsconfig.json', respectExternal: true })],
160
+ });
161
+ await dtsBundle.write({ file: 'dist/esm/quickbase.d.ts', format: 'esm' });
162
+ await dtsBundle.write({ file: 'dist/umd/quickbase.umd.d.ts', format: 'umd' });
163
+ await dtsBundle.close();
49
164
 
50
- // Write Output Files
51
- await Promise.all([
52
- writeFile(
53
- "dist/quickbase-client.browser.min.js",
54
- header + "\n" + browserSource
55
- ),
56
- writeFile("dist/QuickBaseClient.js", header + "\n" + cjsSource),
57
- ]);
165
+ // Clean up
166
+ rimrafSync('dist/temp');
167
+ rimrafSync('dist/temp-src');
58
168
 
59
- console.log("Build completed successfully.");
60
- } catch (error) {
61
- console.error("Build failed:", error);
62
- process.exit(1);
169
+ // List generated files and their sizes
170
+ console.log('\nGenerated files:');
171
+ function listFilesWithSizes(dir, prefix = '') {
172
+ const files = readdirSync(dir, { withFileTypes: true });
173
+ for (const file of files) {
174
+ const filePath = join(dir, file.name);
175
+ if (file.isDirectory()) {
176
+ listFilesWithSizes(filePath, `${prefix}${file.name}/`);
177
+ } else {
178
+ const stats = statSync(filePath);
179
+ const sizeKB = (stats.size / 1024).toFixed(2);
180
+ console.log(`${prefix}${file.name} - ${sizeKB} KB`);
181
+ }
63
182
  }
64
183
  }
184
+ listFilesWithSizes(join(process.cwd(), 'dist'));
65
185
 
66
- build();
186
+ console.log('\nBuild completed successfully');