quickbase-js 1.1.0-beta.4 → 1.1.0-beta.6

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 (52) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +54 -0
  3. package/build.js +175 -55
  4. package/dist/{quickbase.js → esm/quickbase.js} +5 -3
  5. package/dist/esm/quickbase.js.map +1 -0
  6. package/dist/esm/quickbase.min.js +2 -0
  7. package/dist/esm/quickbase.min.js.map +1 -0
  8. package/dist/umd/quickbase.umd.d.ts +5341 -0
  9. package/dist/umd/quickbase.umd.js +7698 -0
  10. package/dist/umd/quickbase.umd.js.map +1 -0
  11. package/dist/umd/quickbase.umd.min.js +2 -0
  12. package/dist/umd/quickbase.umd.min.js.map +1 -0
  13. package/examples/vanillatest.html +49 -0
  14. package/log-gen.yaml +884 -6055
  15. package/{src/code-generation → open-api}/fix-spec-main.ts +1 -1
  16. package/{src/code-generation → open-api}/generate-unified-interface.ts +42 -17
  17. package/{src/code-generation → open-api}/regenerate-client.ts +4 -4
  18. package/package.json +25 -14
  19. package/rollup.config.mjs +114 -0
  20. package/src/generated-unified/QuickbaseClient.ts +1 -1
  21. package/src/quickbaseClient.ts +5 -3
  22. package/test-artifacts/.last-run.json +4 -2
  23. package/test-esm.js +1 -0
  24. package/test-umd.js +1 -0
  25. package/test.ts +1 -0
  26. package/tests/playwright/qb/auth/umd.test.ts +10 -0
  27. package/tests/vitest/unit/umd.test.ts +8 -0
  28. package/{src → tools}/log-gen.ts +16 -14
  29. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  30. package/tsconfig.build.json +17 -0
  31. package/tsconfig.json +5 -5
  32. package/dist/quickbase.js.map +0 -1
  33. package/rollup.config.js +0 -70
  34. /package/dist/{quickbase.d.ts → esm/quickbase.d.ts} +0 -0
  35. /package/{src/code-generation → open-api}/definitions/apps.ts +0 -0
  36. /package/{src/code-generation → open-api}/definitions/auth.ts +0 -0
  37. /package/{src/code-generation → open-api}/definitions/fields.ts +0 -0
  38. /package/{src/code-generation → open-api}/definitions/index.ts +0 -0
  39. /package/{src/code-generation → open-api}/definitions/records.ts +0 -0
  40. /package/{src/code-generation → open-api}/definitions/relationships.ts +0 -0
  41. /package/{src/code-generation → open-api}/definitions/reports.ts +0 -0
  42. /package/{src/code-generation → open-api}/definitions/tables.ts +0 -0
  43. /package/{src/code-generation → open-api}/output/quickbase-fixed.json +0 -0
  44. /package/{src/code-generation → open-api}/paths/apps.ts +0 -0
  45. /package/{src/code-generation → open-api}/paths/auth.ts +0 -0
  46. /package/{src/code-generation → open-api}/paths/fields.ts +0 -0
  47. /package/{src/code-generation → open-api}/paths/index.ts +0 -0
  48. /package/{src/code-generation → open-api}/paths/records.ts +0 -0
  49. /package/{src/code-generation → open-api}/paths/relationships.ts +0 -0
  50. /package/{src/code-generation → open-api}/paths/reports.ts +0 -0
  51. /package/{src/code-generation → open-api}/paths/tables.ts +0 -0
  52. /package/{src/specs → specs}/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
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.6](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.1.0-beta.5...v1.1.0-beta.6) (2025-03-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * omit credientials for all api calls that are not fetching a temp token ([b1b4aae](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b1b4aae02aaa655e6eaab2fe0d532d526e6dc69f))
11
+
12
+ ## [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)
13
+
14
+
15
+ ### Features
16
+
17
+ * ESM and UMD build prod ([49513e9](https://github.com/DrewBradfordXYZ/quickbase-js/commit/49513e902e7bf4dd35da3c6508242e96507a91bd))
18
+ * ESM and UMD support and src folder reorganization ([dc0170b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/dc0170b547e6e9e57a117fbcccfdbeb86e48a8c7))
19
+
5
20
  ## [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)
6
21
 
7
22
 
package/README.md CHANGED
@@ -67,6 +67,60 @@ npm run build
67
67
  npm run test:all
68
68
  ```
69
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
+
122
+ ```
123
+
70
124
  ## In QuickBase Code Pages (Browser Environment)
71
125
 
72
126
  ### useTempTokens: true:
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');
@@ -7087,7 +7087,7 @@ function quickbase(config) {
7087
7087
  basePath: baseUrl,
7088
7088
  headers: { ...baseHeaders },
7089
7089
  fetchApi: fetchApi || defaultFetch,
7090
- credentials: useTempTokens ? "include" : "omit",
7090
+ credentials: "omit", // Default to "omit" for all requests
7091
7091
  });
7092
7092
  if (!configuration.fetchApi && typeof globalThis.window === "undefined") {
7093
7093
  throw new Error("fetchApi must be provided in non-browser environments (e.g., Node.js)");
@@ -7131,7 +7131,7 @@ function quickbase(config) {
7131
7131
  const response = await effectiveFetch(`https://api.quickbase.com/v1/auth/temporary/${dbid}`, {
7132
7132
  method: "GET",
7133
7133
  headers: { ...baseHeaders },
7134
- credentials: "include",
7134
+ credentials: "include", // Explicitly include credentials for token fetch
7135
7135
  });
7136
7136
  if (!response.ok) {
7137
7137
  const errorBody = await response.json();
@@ -7157,7 +7157,9 @@ function quickbase(config) {
7157
7157
  methodInfo.paramMap[0] === "requestParameters"
7158
7158
  ? { requestParameters: params }
7159
7159
  : params;
7160
- let requestOptions = {};
7160
+ let requestOptions = {
7161
+ credentials: "omit", // Explicitly set to "omit" for API calls
7162
+ };
7161
7163
  const selectedToken = initialTempToken || (userToken && !useTempTokens ? userToken : undefined);
7162
7164
  if (methodName === "getTempTokenDBID" && useTempTokens) {
7163
7165
  const dbid = extractDbid(params, "No dbid provided for getTempTokenDBID");