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.
Files changed (123) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/LICENSE +21 -0
  3. package/README.md +204 -0
  4. package/build-common.js +131 -0
  5. package/build-esm.js +71 -0
  6. package/build-umd.js +69 -0
  7. package/dist/esm/quickbase.d.ts +7594 -0
  8. package/dist/esm/quickbase.js +9752 -0
  9. package/dist/esm/quickbase.js.map +1 -0
  10. package/dist/esm/quickbase.min.js +2 -0
  11. package/dist/esm/quickbase.min.js.map +1 -0
  12. package/dist/umd/quickbase.umd.js +10502 -0
  13. package/dist/umd/quickbase.umd.js.map +1 -0
  14. package/dist/umd/quickbase.umd.min.js +2 -0
  15. package/dist/umd/quickbase.umd.min.js.map +1 -0
  16. package/examples/quicbase-jsCDN.html +36 -0
  17. package/examples/react.js +48 -0
  18. package/examples/vanillajs.html +47 -0
  19. package/notes.txt +158 -0
  20. package/open-api/fix-spec-main.ts +96 -0
  21. package/open-api/generate-unified-interface.ts +277 -0
  22. package/open-api/output/override-report.json +58 -0
  23. package/open-api/output/quickbase-fixed.json +10610 -0
  24. package/open-api/regenerate-client.ts +116 -0
  25. package/open-api/schema/enhance-general.ts +100 -0
  26. package/open-api/schema/fix-arrays.ts +69 -0
  27. package/open-api/schema/tags/apps.ts +90 -0
  28. package/open-api/schema/tags/fields.ts +156 -0
  29. package/open-api/schema/tags/groups.ts +51 -0
  30. package/open-api/schema/tags/index.ts +68 -0
  31. package/open-api/schema/tags/records.ts +115 -0
  32. package/open-api/schema/tags/tables.ts +211 -0
  33. package/open-api/schema/tags/users.ts +47 -0
  34. package/open-api/types/spec.ts +41 -0
  35. package/open-api/utils/infer-schema.ts +40 -0
  36. package/open-api/utils/naming.ts +10 -0
  37. package/package.json +91 -0
  38. package/playwright.config.ts +37 -0
  39. package/rollup.config.js +114 -0
  40. package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +46878 -0
  41. package/specs/split/apps.json +1315 -0
  42. package/specs/split/auth.json +191 -0
  43. package/specs/split/fields.json +3869 -0
  44. package/specs/split/records.json +754 -0
  45. package/specs/split/reports.json +619 -0
  46. package/specs/split/tables.json +1605 -0
  47. package/src/generated-unified/QuickbaseClient.ts +359 -0
  48. package/src/generated-unified/missing-types-report.json +3 -0
  49. package/src/index.ts +1 -0
  50. package/src/quickbaseClient.ts +402 -0
  51. package/src/tokenCache.ts +51 -0
  52. package/src/utils.ts +7 -0
  53. package/test-esm.js +1 -0
  54. package/test-results.json +2050 -0
  55. package/test-umd.js +1 -0
  56. package/test.ts +1 -0
  57. package/tests/playwright/qb/auth/cacheSwitching.test.ts +159 -0
  58. package/tests/playwright/qb/auth/fetchTempToken401.test.ts +219 -0
  59. package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +162 -0
  60. package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +153 -0
  61. package/tests/playwright/qb/auth/getTempToken.test.ts +152 -0
  62. package/tests/playwright/qb/auth/tokenPrefetch.test.ts +179 -0
  63. package/tests/playwright/qb/auth/tokenRenewal.test.ts +133 -0
  64. package/tests/setup.ts +51 -0
  65. package/tests/vitest/qb/apps/copyApp.test.ts +76 -0
  66. package/tests/vitest/qb/apps/createApp.test.ts +64 -0
  67. package/tests/vitest/qb/apps/deleteApp.test.ts +76 -0
  68. package/tests/vitest/qb/apps/getApp.test.ts +40 -0
  69. package/tests/vitest/qb/fields/createField.test.ts +78 -0
  70. package/tests/vitest/qb/fields/deleteFields.test.ts +89 -0
  71. package/tests/vitest/qb/fields/getField.test.ts +85 -0
  72. package/tests/vitest/qb/fields/getFieldUsage.test.ts +174 -0
  73. package/tests/vitest/qb/fields/getFields.test.ts +232 -0
  74. package/tests/vitest/qb/fields/getFieldsUsage.test.ts +77 -0
  75. package/tests/vitest/qb/index.ts +28 -0
  76. package/tests/vitest/qb/records/deleteRecords.test.ts +110 -0
  77. package/tests/vitest/qb/records/runQuery.test.ts +146 -0
  78. package/tests/vitest/qb/records/upsert.test.ts +102 -0
  79. package/tests/vitest/qb/tables/createTable.test.ts +55 -0
  80. package/tests/vitest/qb/tables/deleteTable.test.ts +50 -0
  81. package/tests/vitest/qb/tables/getAppTables.test.ts +46 -0
  82. package/tests/vitest/qb/tables/getRelationships.test.ts +80 -0
  83. package/tests/vitest/qb/tables/getTable.test.ts +26 -0
  84. package/tests/vitest/qb/tables/updateTable.test.ts +48 -0
  85. package/tests/vitest/unit/apps/copyApp.test.ts +488 -0
  86. package/tests/vitest/unit/apps/createApp.test.ts +186 -0
  87. package/tests/vitest/unit/apps/deleteApp.test.ts +216 -0
  88. package/tests/vitest/unit/apps/getApp.test.ts +128 -0
  89. package/tests/vitest/unit/auth/fetchTempToken401.test.ts +82 -0
  90. package/tests/vitest/unit/auth/getTempToken.test.ts +95 -0
  91. package/tests/vitest/unit/auth/retryOn401.test.ts +116 -0
  92. package/tests/vitest/unit/auth/two401s.test.ts +86 -0
  93. package/tests/vitest/unit/fields/createField.test.ts +391 -0
  94. package/tests/vitest/unit/fields/deleteFields.test.ts +141 -0
  95. package/tests/vitest/unit/fields/getField.test.ts +189 -0
  96. package/tests/vitest/unit/fields/getFieldUsage.test.ts +147 -0
  97. package/tests/vitest/unit/fields/getFields.test.ts +122 -0
  98. package/tests/vitest/unit/fields/getFieldsUsage.test.ts +160 -0
  99. package/tests/vitest/unit/index.ts +33 -0
  100. package/tests/vitest/unit/records/deleteRecords.test.ts +112 -0
  101. package/tests/vitest/unit/records/runQuery.test.ts +102 -0
  102. package/tests/vitest/unit/records/upsert.test.ts +234 -0
  103. package/tests/vitest/unit/tables/createTable.test.ts +70 -0
  104. package/tests/vitest/unit/tables/deleteTable.test.ts +77 -0
  105. package/tests/vitest/unit/tables/getAppTables.test.ts +85 -0
  106. package/tests/vitest/unit/tables/getRelationships.test.ts +259 -0
  107. package/tests/vitest/unit/tables/getTable.test.ts +233 -0
  108. package/tests/vitest/unit/tables/updateTable.test.ts +80 -0
  109. package/tests/vitest/unit/umd.test.ts +8 -0
  110. package/text.txt +104 -0
  111. package/tools/generate-types.ts +29 -0
  112. package/tools/log-gen.ts +231 -0
  113. package/tools/log-gen.yaml +3826 -0
  114. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  115. package/tools/openapi-schema-validator.ts +38 -0
  116. package/tools/spec-analyzer.ts +163 -0
  117. package/tools/split-spec.ts +148 -0
  118. package/tools/test-import.ts +3 -0
  119. package/tools/validate-spec.ts +40 -0
  120. package/tsconfig.build.json +17 -0
  121. package/tsconfig.json +29 -0
  122. package/versionrc.json +9 -0
  123. package/vitest.config.ts +27 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,129 @@
1
+ # Changelog
2
+
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
+
5
+ ## [0.1.0-beta.7](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.1.0-beta.6...v0.1.0-beta.7) (2025-03-16)
6
+
7
+
8
+ ### Features
9
+
10
+ * added Record, hybrid semantic naming, fully typed QuickbaseClient with few response models left as type:any ([535a02e](https://github.com/DrewBradfordXYZ/quickbase-js/commit/535a02e10d5974d2a2deb6dc213286da94d68dea))
11
+ * all fields tests pass ([84c539f](https://github.com/DrewBradfordXYZ/quickbase-js/commit/84c539fce7ba9d57c997b831be404a1398a6ac25))
12
+ * all types, methods and files generated ([f25bea0](https://github.com/DrewBradfordXYZ/quickbase-js/commit/f25bea0e65a019d75b39a9caf85901d520bf1ac8))
13
+ * build files always produce production code ([2f78598](https://github.com/DrewBradfordXYZ/quickbase-js/commit/2f785984416c61e1b3deda2b801071cbb1303a74))
14
+ * copyApp unit test passes ([0e13f91](https://github.com/DrewBradfordXYZ/quickbase-js/commit/0e13f918c5daabbbd6e17c2424b3f18eca2eb3a4))
15
+ * FieldMap issue resolved ([b3b7b41](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b3b7b415d6a0f7701851f32a5e0b1207a07ba481))
16
+ * getApp and deleteApp test passes ([f5225e0](https://github.com/DrewBradfordXYZ/quickbase-js/commit/f5225e06299de58f34d6a765e73268d9a54e807d))
17
+ * getAppEvents spec update ([1028255](https://github.com/DrewBradfordXYZ/quickbase-js/commit/10282559cd76d004899fa2ebcea6f5f435ffae2b))
18
+ * import and upsert success ([ea9d9ee](https://github.com/DrewBradfordXYZ/quickbase-js/commit/ea9d9eef8384ad73b8cffb8183fbc374ab9cc25b))
19
+ * log-gen yaml file gets created next to the build file ([cfe25af](https://github.com/DrewBradfordXYZ/quickbase-js/commit/cfe25afb60498909d2bac8ec963484e1c1b42d3f))
20
+ * logging for swagger2.0 ([819aa17](https://github.com/DrewBradfordXYZ/quickbase-js/commit/819aa170cfc02e4e5b223ac13834d50bce5dda93))
21
+ * missing-types-report updated to empty on success ([e35b28d](https://github.com/DrewBradfordXYZ/quickbase-js/commit/e35b28d61563b21f7bad3e1c9c3751bfa254ab4a))
22
+ * QuickbaseClient is fully-typed from raw spec ([5c875c2](https://github.com/DrewBradfordXYZ/quickbase-js/commit/5c875c2ee07c38731c5609c384aaa8d3fbbdd64a))
23
+ * reorganize open-api folder ([a0fe5bd](https://github.com/DrewBradfordXYZ/quickbase-js/commit/a0fe5bda606c37e7636d36c7fc5e233d191ac249))
24
+ * simplifyName refactor again ([2a2952e](https://github.com/DrewBradfordXYZ/quickbase-js/commit/2a2952ea90fab818501d17908d6cd85a79c41adb))
25
+ * split up fix-spec- files ([85b6a3e](https://github.com/DrewBradfordXYZ/quickbase-js/commit/85b6a3efb92520a46aa619bdfc4bf70d06984b3f))
26
+ * unit auth tests pass ([494897f](https://github.com/DrewBradfordXYZ/quickbase-js/commit/494897f4551854096f89b1af43df4a455dfd9f4b))
27
+ * unit records tests pass ([8160b53](https://github.com/DrewBradfordXYZ/quickbase-js/commit/8160b53378447fcd8e37fac178e7d4693b502288))
28
+ * unit tables tests pass ([c4ec0ac](https://github.com/DrewBradfordXYZ/quickbase-js/commit/c4ec0ac378dd03e5d018b4ea83530e2c0fe905a2))
29
+ * unit tests for apps folder is passing ([72ae8e5](https://github.com/DrewBradfordXYZ/quickbase-js/commit/72ae8e529cddc66626617c6b1ff672f40763f7b7))
30
+ * update scripts to call integration tests, all tests pass ([08911f7](https://github.com/DrewBradfordXYZ/quickbase-js/commit/08911f76b214e6eb3ca8b4362c156d55383d7264))
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * added back CreateRelationshipRequest and UpdateRelationshipRequest ([0d932ee](https://github.com/DrewBradfordXYZ/quickbase-js/commit/0d932eed8b603c6b84e13b8834a89722b91fabf3))
36
+ * generate-unified-interface type fixes ([b8acd16](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b8acd16805f456336d396856c6ff88a29aa02813))
37
+ * playwright cleanup and type fixes ([ff30a15](https://github.com/DrewBradfordXYZ/quickbase-js/commit/ff30a15c1a244c7eb1ad4f52941f60b775bb88d4))
38
+ * remove the old /paths /definitons completely in scripts ([48ee6a3](https://github.com/DrewBradfordXYZ/quickbase-js/commit/48ee6a3b15579ca9224b89acde73f492e0769cab))
39
+ * update tags/tables.ts to match raw schema ([c6ed554](https://github.com/DrewBradfordXYZ/quickbase-js/commit/c6ed554f0994187224219b454d1e8671307fc189))
40
+
41
+ ## [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)
42
+
43
+
44
+ ### Features
45
+
46
+ * omit credientials for all api calls that are not fetching a temp token ([b1b4aae](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b1b4aae02aaa655e6eaab2fe0d532d526e6dc69f))
47
+
48
+ ## [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)
49
+
50
+
51
+ ### Features
52
+
53
+ * ESM and UMD build prod ([49513e9](https://github.com/DrewBradfordXYZ/quickbase-js/commit/49513e902e7bf4dd35da3c6508242e96507a91bd))
54
+ * ESM and UMD support and src folder reorganization ([dc0170b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/dc0170b547e6e9e57a117fbcccfdbeb86e48a8c7))
55
+
56
+ ## [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)
57
+
58
+
59
+ ### Features
60
+
61
+ * createField and deleteFields tests are passing ([4b47c4d](https://github.com/DrewBradfordXYZ/quickbase-js/commit/4b47c4deb9b3d731e6e7938c12fcebe97830568b))
62
+ * createField mock and integration tests pass ([b227c73](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b227c73b08f7efa5ce5f3d0c2897f82c8976a009))
63
+ * deleteFields spec update ([1f8beca](https://github.com/DrewBradfordXYZ/quickbase-js/commit/1f8becaca0d6b7950648c1b9bc2b0215781fa829))
64
+ * getFeildsUsage.test.ts unit and integration tests pass ([82a4886](https://github.com/DrewBradfordXYZ/quickbase-js/commit/82a488622967ec24a8767cbb19c59ef4ce808749))
65
+ * getField.test.ts unit and integration tests pass ([3e50b70](https://github.com/DrewBradfordXYZ/quickbase-js/commit/3e50b704f0ebea47f2fee3d02d811ea1b43db6c4))
66
+ * getFieldsUsage fix spec ([031faaa](https://github.com/DrewBradfordXYZ/quickbase-js/commit/031faaaeab9597f35fdd1ddcf5157ce5d774390b))
67
+ * getFieldUsage spec and unit test pass ([ac2824b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/ac2824b226140dde99e33cf594d57bd6ffd4dc39))
68
+ * getFieldUsage unit and integration tests pass ([e62b586](https://github.com/DrewBradfordXYZ/quickbase-js/commit/e62b586d534620479a25dda2796ba5dcb8043705))
69
+ * split up fix-spec-paths and fix-spec-definitions into many files ([20d3246](https://github.com/DrewBradfordXYZ/quickbase-js/commit/20d32464e6337028778845fa55fbb19c5543f7eb))
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * cleanup createField.test.ts logging ([7b1306b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/7b1306bd8eb49e2c932ce267f33457e949e0f74b))
75
+ * createField test syntax update ([043f964](https://github.com/DrewBradfordXYZ/quickbase-js/commit/043f964a47346878440eb73cc10c110dab904ad7))
76
+ * getFieldsUsage type fix ([4c6f271](https://github.com/DrewBradfordXYZ/quickbase-js/commit/4c6f271d123131ae13a236664f28fbbdfde3d564))
77
+ * update deleteFields error type spec ([1788e1c](https://github.com/DrewBradfordXYZ/quickbase-js/commit/1788e1ce6d4d2c8df871ec8b112be908d706f884))
78
+
79
+ ## [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)
80
+
81
+ ### Features
82
+
83
+ - copyApp fix-spec updates ([4c10ab4](https://github.com/DrewBradfordXYZ/quickbase-js/commit/4c10ab41464df047402a207c7b9e81026a7b6202))
84
+ - copyApp unit test passes ([b121bf1](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b121bf1d0130f338f131de5417896d798fe90db3))
85
+ - deleteApp fix spec added ([b27ce11](https://github.com/DrewBradfordXYZ/quickbase-js/commit/b27ce11e2b08bc631d7656dedec57f6f5e579450))
86
+ - fix-spec-\* for getRelationship interface ([aad9fbd](https://github.com/DrewBradfordXYZ/quickbase-js/commit/aad9fbd7fc92b8aaaef901174c81169543ae86d2))
87
+ - getRelationship unit and integration test pass ([a1269bb](https://github.com/DrewBradfordXYZ/quickbase-js/commit/a1269bb60523944bdf5030404539043c967f0b83))
88
+ - updated Upsert200Response and Upsert207Response, deleteRecords.test.ts integration type issues resolved ([d39dad5](https://github.com/DrewBradfordXYZ/quickbase-js/commit/d39dad55d783d280db9dbae2ca4c782df3a1f12e))
89
+ - usertokens 401s do not generate a token, createApp unit and integration tests, deleteApp integration tests pass ([e3a092d](https://github.com/DrewBradfordXYZ/quickbase-js/commit/e3a092d76f283d5c5200ddbb5afd32782fc15379))
90
+
91
+ ## [1.1.0-beta.2](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.1.0-beta.1...v1.1.0-beta.2) (2025-03-11)
92
+
93
+ ## [1.1.0-beta.1](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.1.0-beta.0...v1.1.0-beta.1) (2025-03-11)
94
+
95
+ ### Features
96
+
97
+ - runQuery.test.ts integration test pass ([180b17f](https://github.com/DrewBradfordXYZ/quickbase-js/commit/180b17f265c26a0d23bde3ca6993bad1ba4f65ee))
98
+ - runQuery.test.ts unit test pass ([84e2fc4](https://github.com/DrewBradfordXYZ/quickbase-js/commit/84e2fc4f237d5f558fcd20d7b6b8eb83f685d7ac))
99
+
100
+ ### Bug Fixes
101
+
102
+ - added stub variables to unit tests ([d84b534](https://github.com/DrewBradfordXYZ/quickbase-js/commit/d84b5344201300d8d59e622b025d96ad9813d4eb))
103
+ - create env stubs for mock tests and update getTables.test.ts ([3d31c9e](https://github.com/DrewBradfordXYZ/quickbase-js/commit/3d31c9ebc9f852b99d1a807759490055d75c6396))
104
+
105
+ ## [1.1.0-beta.0](https://github.com/DrewBradfordXYZ/quickbase-js/compare/v1.0.1-beta.0...v1.1.0-beta.0) (2025-03-11)
106
+
107
+ ### Features
108
+
109
+ - add deleteTable integration test with 404 verification ([277aec6](https://github.com/DrewBradfordXYZ/quickbase-js/commit/277aec66a3047fab687ce81ad42b9371e8c2bf56))
110
+ - deleteRecords integration and unit tests ([d3beba1](https://github.com/DrewBradfordXYZ/quickbase-js/commit/d3beba1a362b13166b38f59eeea83c289ddaf999))
111
+ - integration tests for deleteRecords and upsert pass ([759978b](https://github.com/DrewBradfordXYZ/quickbase-js/commit/759978bc13cb1c50c03770232eb02a1c3c08428d))
112
+ - mock deleteRecords passes ([a167028](https://github.com/DrewBradfordXYZ/quickbase-js/commit/a1670286def030950c568e92ca99ea12e20d5b62))
113
+ - upsert mock test passes ([dde6d07](https://github.com/DrewBradfordXYZ/quickbase-js/commit/dde6d07d4c4c73bd14189f87fdc6347744004e4e))
114
+
115
+ ### Bug Fixes
116
+
117
+ - all vitests are passing again ([7206ba3](https://github.com/DrewBradfordXYZ/quickbase-js/commit/7206ba3f28bd7a3c7f5d699988e9a9a1f0053f42))
118
+ - fix-spec and test updates for createTable ([9c0cdd3](https://github.com/DrewBradfordXYZ/quickbase-js/commit/9c0cdd3b707971e6fb8f3e73598e3a600ff2b33d))
119
+ - fix-spec for upsertRecords and createApp ([d12de40](https://github.com/DrewBradfordXYZ/quickbase-js/commit/d12de40feac35e5d86a0b7d5019d8058cdfcffd9))
120
+ - fix-spec getTable ([1eb936c](https://github.com/DrewBradfordXYZ/quickbase-js/commit/1eb936c360ce5df4818b8d5ef7ccf4dc6b769af0))
121
+ - fix-spec getTable deleteTable ([236349a](https://github.com/DrewBradfordXYZ/quickbase-js/commit/236349af9e30776e00754232d83d76e065aab00b))
122
+ - fix-spec updates for createApp ([3614958](https://github.com/DrewBradfordXYZ/quickbase-js/commit/36149589ff2544ec50a82d9dc9b183f15d07778d))
123
+ - fix-spec updateTable ([26e278c](https://github.com/DrewBradfordXYZ/quickbase-js/commit/26e278cdbbe96d33e51f14e90ebb2c8b47d70f07))
124
+ - getTables test pass, change order for extractDbid to assign temp token dbid ([37b7685](https://github.com/DrewBradfordXYZ/quickbase-js/commit/37b7685d55a0f64e62cb91ad23df28d4916d5a50))
125
+ - upsert unit test type fixes ([8460cc8](https://github.com/DrewBradfordXYZ/quickbase-js/commit/8460cc8e63564bc8602dc12a9b6415094cc215f0))
126
+
127
+ ### 1.0.1-beta.0 (2025-03-10)
128
+
129
+ Testing done in a consuming library for getApp() and getFields()
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Drew Bradford
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # quickbase-js
2
+
3
+ # Installation
4
+
5
+ ```bash
6
+ npm install --save quickbase-js
7
+ ```
8
+
9
+ ## Examples
10
+
11
+ ### CDN Code Page
12
+
13
+ ```html
14
+ <!DOCTYPE html>
15
+ <html>
16
+ <head>
17
+ <title>Quickbase</title>
18
+ <script src="https://cdn.jsdelivr.net/npm/quickbase-js@1.1.0-beta.6/dist/umd/quickbase.umd.min.js"></script>
19
+ </head>
20
+
21
+ <body>
22
+ <div>
23
+ <h1>Quickbase-js CDN Example</h1>
24
+ <p id="result">Loading...</p>
25
+ </div>
26
+ <script>
27
+ var realm = "xxxxxxxxxxxxxxxxxxxx"; // replace with your realm
28
+ var appId = "xxxxxxxxxxxxxxxxxxxx"; // replace with your app ID
29
+ if (typeof QuickbaseJS === "undefined") {
30
+ document.getElementById("result").textContent =
31
+ "Error: Failed to load QuickbaseJS library.";
32
+ } else {
33
+ var qbClient = QuickbaseJS.quickbase({
34
+ realm,
35
+ useTempTokens: true,
36
+ });
37
+
38
+ qbClient
39
+ .getApp({ appId })
40
+ .then(function (app) {
41
+ document.getElementById("result").textContent =
42
+ "App Name: " + app.name;
43
+ })
44
+ .catch(function (err) {
45
+ document.getElementById("result").textContent =
46
+ "Error: " + (err.message || "Failed to load app");
47
+ });
48
+ }
49
+ </script>
50
+ </body>
51
+ </html>
52
+ ```
53
+
54
+ # Development workflow
55
+
56
+ ```bash
57
+ npm run gen:all
58
+ npm run build
59
+ npm run test:all
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ### Node.js (ESM - Recommended)
65
+
66
+ For modern Node.js applications, use ES modules:
67
+
68
+ ```javascript
69
+ // ESM (Node.js) - Recommended
70
+ import { quickbase } from "quickbase-js";
71
+ const qb = quickbase({ realm: "example", userToken: "your-token" });
72
+
73
+ // Example: Fetching an app
74
+ const app = await qb.getApp({ appId: "your-app-id" });
75
+ console.log(app);
76
+
77
+ // Example: Creating a record with temporary token
78
+ const qbTemp = quickbase({ realm: "example", useTempTokens: true });
79
+ const record = await qbTemp.upsert({
80
+ body: {
81
+ to: "your-table-id",
82
+ data: [
83
+ {
84
+ /* record data */
85
+ },
86
+ ],
87
+ },
88
+ });
89
+ console.log(record);
90
+ ```
91
+
92
+ ```javascript
93
+ // Example: TypeScript ESM (Recommended)
94
+ import { quickbase } from "quickbase-js";
95
+ const qbTyped: QuickbaseClient = quickbase({
96
+ realm: "example",
97
+ userToken: "your-token",
98
+ });
99
+ const typedApp = await qbTyped.getApp({ appId: "your-app-id" });
100
+ console.log(typedApp);
101
+ ```
102
+
103
+ ```javascript
104
+ // Example: UMD via CDN (QuickBase Code Pages)
105
+ // Note: This is HTML, not JavaScript, and should be used in a browser environment
106
+
107
+ <script src="https://cdn.jsdelivr.net/npm/quickbase-js@1.1.0-beta.4/dist/umd/quickbase.umd.js"></script>
108
+ <script>
109
+ const qb = new QuickbaseJS({ realm: 'example', useTempTokens: true });
110
+ // Example: Fetching an app
111
+ qb.getApp({ appId: 'your-app-id' }).then(app => console.log(app));
112
+ </script>
113
+
114
+ ```
115
+
116
+ ## In QuickBase Code Pages (Browser Environment)
117
+
118
+ ### useTempTokens: true:
119
+
120
+ Token Fetch: Auto-fetches temporary tokens using the provided fetchApi (or window.fetch by default) with cookies (withCredentials: true in the internal tokenClient).
121
+
122
+ Subsequent Calls (e.g., getApp): Uses the same fetchApi (or window.fetch) with the QB-TEMP-TOKEN {TOKEN} header. No additional config needed beyond realm and useTempTokens.
123
+
124
+ How It Works: Leverages the browser’s session cookies for the initial token fetch, then uses the token for all API calls. In a real code page, window.fetch handles both steps seamlessly.
125
+
126
+ Test Output: The test uses page.evaluate for token fetch and node-fetch for getApp to bypass Playwright’s browser fetch issue, but in a code page, it’s all window.fetch.
127
+
128
+ ### userToken:
129
+
130
+ All Calls: Uses the provided fetchApi (or window.fetch by default) with the QB-USER-TOKEN {TOKEN} header. No session cookies needed (credentials: "omit").
131
+
132
+ How It Works: The user token authenticates directly, independent of the browser session, making it straightforward and reliable.
133
+
134
+ Test Output: Confirms this with page.evaluate sending QB-USER-TOKEN.
135
+
136
+ ## In Node.js (Non-Browser Environment)
137
+
138
+ ### userToken:
139
+
140
+ All Calls: Works with a provided fetchApi (e.g., fetchApi: node-fetch). Sets QB-USER-TOKEN {TOKEN} header.
141
+
142
+ How It Works: Fully functional as long as fetchApi is supplied (e.g., node-fetch), since user tokens don’t require a browser session.
143
+
144
+ Requirement: Must provide fetchApi explicitly (no default in Node.js).
145
+
146
+ ### useTempTokens: true:
147
+
148
+ Behavior: Fails with a clear error unless a browser-like fetchApi is provided:
149
+
150
+ "Temporary tokens require a browser environment or a custom fetchApi with browser-like session support"
151
+
152
+ How It Works: Temp tokens need a browser session with cookies, which Node.js can’t provide natively. A custom fetchApi (e.g., via Puppeteer) could work but is impractical for typical Node.js use.
153
+
154
+ Practicality: Effectively unusable in Node.js without external browser support, aligning with QuickBase’s temp token requirement.
155
+
156
+ ## getTempTokenDBID
157
+
158
+ Temporary Token Handling with getTempTokenDBID
159
+ The QuickBase API provides the getTempTokenDBID method to fetch temporary tokens (QB-TEMP-TOKEN) for browser-based authentication, typically using session credentials (e.g., cookies). These tokens are short-lived (~5 minutes) and intended for secure, client-side API calls. In the generated OpenAPI client, getTempTokenDBID makes a straightforward GET request to /v1/auth/temporary/{dbid} and returns { temporaryAuthorization: string }. However, this raw implementation lacks caching and doesn’t optimize repeated calls, which can lead to unnecessary API requests.
160
+ In quickbaseClient.ts, we enhance getTempTokenDBID when useTempTokens: true is enabled, wrapping it with intelligent token management:
161
+ Caching: We introduce a TokenCache to store temporary tokens by dbid. Before fetching a new token, the client checks the cache. If a valid token exists, it’s returned immediately, avoiding redundant API calls.
162
+
163
+ Custom Fetch Logic: Instead of relying solely on the generated method, we use a custom fetchTempToken function to fetch tokens. This ensures consistency with browser-based session authentication (credentials: "include") and allows us to cache the result.
164
+
165
+ Early Returns: For getTempTokenDBID, we bypass the generated method’s execution by returning the cached or freshly fetched token directly. This prevents unnecessary calls to the underlying API when the token is already available or just retrieved.
166
+
167
+ Why This Matters
168
+ Efficiency: Caching reduces API requests, crucial for performance in browser environments where temp tokens are fetched frequently but don’t change within their lifespan.
169
+
170
+ Seamless Integration: The wrapper supports both QB-USER-TOKEN (server-side) and QB-TEMP-TOKEN (client-side) workflows, controlled by the useTempTokens config. This makes the client versatile for different use cases.
171
+
172
+ Testability: The enhancement fixes issues in unit tests (e.g., getTempToken.test.ts) by ensuring predictable behavior—fetching once and reusing cached tokens—avoiding unexpected errors from redundant calls.
173
+
174
+ How It Works
175
+ When you call client.getTempTokenDBID({ dbid: "someDbid" }) with useTempTokens: true:
176
+ Cache Check: Looks for an existing token in tokenCache for the given dbid.
177
+
178
+ Fetch if Needed: If no cached token exists, fetchTempToken requests a new one from /v1/auth/temporary/{dbid} and caches it.
179
+
180
+ Return Early: Returns { temporaryAuthorization: token } immediately, skipping the generated method’s execution.
181
+
182
+ For other methods (e.g., getFields), the fetched temp token is applied to the Authorization header, ensuring authenticated API calls without re-fetching.
183
+
184
+ ## 401 Unauthorized Error Behavior
185
+
186
+ The quickbase-js library manages 401 Unauthorized errors from the QuickBase API when using temporary tokens (useTempTokens: true). Normally, it keeps tokens fresh via a time-managed cache intending to never have a 401 Unauthorized error, but there is added safety measures incase a 401 happens to occur.
187
+
188
+ If a 401 happens, the library tries once more with a fresh temporary token.
189
+
190
+ It gets the new token using fetchTempToken and retries the call.
191
+
192
+ If the retry fails with another 401, it stops and throws an error like API Error: Unauthorized (Status: 401).
193
+
194
+ Fetching a New Token:
195
+ If fetchTempToken itself gets a 401 (e.g., no valid login session), it doesn’t retry.
196
+
197
+ It throws an error right away: API Error: Unauthorized (Status: 401).
198
+
199
+ Why It’s Like This
200
+ One Retry: Retries once to fix expired tokens, but stops to avoid endless tries.
201
+
202
+ Fast Fail: No retry on fetchTempToken 401s means you know quickly if login is broken.
203
+
204
+ No Loops: Built to never get stuck retrying forever.
@@ -0,0 +1,131 @@
1
+ // build-common.js
2
+ import { execSync } from "child_process";
3
+ import { rollup } from "rollup";
4
+ import terser from "@rollup/plugin-terser";
5
+ import nodeResolve from "@rollup/plugin-node-resolve";
6
+ import commonjs from "@rollup/plugin-commonjs";
7
+ import dts from "rollup-plugin-dts";
8
+ import { rimrafSync } from "rimraf";
9
+ import {
10
+ copyFileSync,
11
+ readdirSync,
12
+ readFileSync,
13
+ writeFileSync,
14
+ mkdirSync,
15
+ statSync,
16
+ } from "fs";
17
+ import { join } from "path";
18
+
19
+ export const external = [
20
+ "node:http",
21
+ "node:https",
22
+ "node:zlib",
23
+ "node:stream",
24
+ "node:buffer",
25
+ "node:util",
26
+ "node:url",
27
+ "node:net",
28
+ "node:fs",
29
+ "node:path",
30
+ "node-fetch",
31
+ ];
32
+ export const globals = { "node-fetch": "fetch" };
33
+
34
+ export const srcDir = join(process.cwd(), "src");
35
+ export const tempSrcDir = join(process.cwd(), "dist/temp-src");
36
+ export const excludeDirs = ["specs"];
37
+ export const excludeFiles = ["generated/index.ts"]; // Exclude generated/index.ts to avoid duplicate exports
38
+
39
+ export function copyAndRewriteTsExtensions(src, dest) {
40
+ console.log(`Copying from ${src} to ${dest}`);
41
+ mkdirSync(dest, { recursive: true });
42
+ const files = readdirSync(src, { withFileTypes: true });
43
+
44
+ for (const file of files) {
45
+ const srcPath = join(src, file.name);
46
+ const destPath = join(dest, file.name);
47
+
48
+ if (file.isDirectory()) {
49
+ if (excludeDirs.includes(file.name)) {
50
+ console.log(`Skipping excluded directory ${srcPath}`);
51
+ continue;
52
+ }
53
+ copyAndRewriteTsExtensions(srcPath, destPath);
54
+ } else if (file.name.endsWith(".ts")) {
55
+ if (excludeFiles.some((excluded) => srcPath.includes(excluded))) {
56
+ console.log(`Skipping excluded file ${srcPath}`);
57
+ continue;
58
+ }
59
+ console.log(`Processing ${srcPath} -> ${destPath}`);
60
+ let fileContent = readFileSync(srcPath, "utf8");
61
+
62
+ // Remove .ts extensions from import/export statements for runtime compatibility
63
+ fileContent = removeTsExtensionsFromImports(fileContent);
64
+ fileContent = removeTsExtensionsFromStarExports(fileContent);
65
+
66
+ writeFileSync(destPath, fileContent, "utf8");
67
+ } else {
68
+ console.log(`Skipping non-.ts file ${srcPath}`);
69
+ }
70
+ }
71
+ }
72
+
73
+ export function removeTsExtensionsFromImports(content) {
74
+ // Matches: 'from "./some/path.ts"' or 'from "../another.ts"'
75
+ const importPattern = /from\s+(['"])(\.[\w\/-]+)\.ts\1/g;
76
+ return content.replace(importPattern, `from $1$2$1`);
77
+ }
78
+
79
+ export function removeTsExtensionsFromStarExports(content) {
80
+ // Matches: 'export * from "./some/path.ts"' or 'export * from "../another.ts"'
81
+ const exportStarPattern = /export\s+\*\s+from\s+(['"])(\.[\w\/-]+)\.ts\1/g;
82
+ return content.replace(exportStarPattern, `export * from $1$2$1`);
83
+ }
84
+
85
+ export async function createBundle(input, plugins, format, outputOptions) {
86
+ const bundle = await rollup({
87
+ input,
88
+ external,
89
+ plugins,
90
+ });
91
+ await bundle.write(outputOptions);
92
+ await bundle.close();
93
+ }
94
+
95
+ export function compileTypeScript() {
96
+ console.log("Running tsc...");
97
+ const tsFiles = readdirSync(tempSrcDir, { recursive: true })
98
+ .filter((file) => file.endsWith(".ts"))
99
+ .map((file) => join(tempSrcDir, file));
100
+ const tscCommand = `npx tsc ${tsFiles.join(" ")} --outDir ${join(
101
+ process.cwd(),
102
+ "dist/temp"
103
+ )} --module ESNext --target ESNext --sourceMap --moduleResolution bundler --baseUrl ${process.cwd()}`;
104
+ console.log(`Command: ${tscCommand}`);
105
+ execSync(tscCommand, { stdio: "inherit" });
106
+ }
107
+
108
+ export async function generateDeclarations() {
109
+ console.log("Generating declarations...");
110
+ const dtsBundle = await rollup({
111
+ input: "src/quickbaseClient.ts",
112
+ plugins: [dts({ tsconfig: "./tsconfig.json", respectExternal: true })],
113
+ });
114
+ await dtsBundle.write({ file: "dist/esm/quickbase.d.ts", format: "esm" });
115
+ await dtsBundle.write({ file: "dist/umd/quickbase.umd.d.ts", format: "umd" });
116
+ await dtsBundle.close();
117
+ }
118
+
119
+ export function listFilesWithSizes(dir, prefix = "") {
120
+ const files = readdirSync(dir, { withFileTypes: true });
121
+ for (const file of files) {
122
+ const filePath = join(dir, file.name);
123
+ if (file.isDirectory()) {
124
+ listFilesWithSizes(filePath, `${prefix}${file.name}/`);
125
+ } else {
126
+ const stats = statSync(filePath);
127
+ const sizeKB = (stats.size / 1024).toFixed(2);
128
+ console.log(`${prefix}${file.name} - ${sizeKB} KB`);
129
+ }
130
+ }
131
+ }
package/build-esm.js ADDED
@@ -0,0 +1,71 @@
1
+ import { rimrafSync } from "rimraf";
2
+ import { join } from "path";
3
+ import nodeResolve from "@rollup/plugin-node-resolve";
4
+ import commonjs from "@rollup/plugin-commonjs";
5
+ import terser from "@rollup/plugin-terser";
6
+ import {
7
+ copyAndRewriteTsExtensions,
8
+ compileTypeScript,
9
+ createBundle,
10
+ external,
11
+ globals,
12
+ srcDir,
13
+ tempSrcDir,
14
+ generateDeclarations,
15
+ listFilesWithSizes,
16
+ } from "./build-common.js";
17
+
18
+ // Clean specific folders for ESM build
19
+ rimrafSync("dist/esm");
20
+ rimrafSync("dist/temp");
21
+ rimrafSync("dist/temp-src");
22
+
23
+ // Copy and rewrite TS files
24
+ copyAndRewriteTsExtensions(srcDir, tempSrcDir);
25
+
26
+ // Compile TypeScript
27
+ compileTypeScript();
28
+
29
+ // ESM Builds
30
+ console.log("Building ESM bundles...");
31
+
32
+ // Generate unminified ESM bundle
33
+ console.log("Building unminified ESM bundle...");
34
+ await createBundle(
35
+ "dist/temp/quickbaseClient.js",
36
+ [nodeResolve({ preferBuiltins: true }), commonjs()],
37
+ "esm",
38
+ {
39
+ dir: "dist/esm",
40
+ format: "esm",
41
+ sourcemap: true,
42
+ entryFileNames: "quickbase.js",
43
+ }
44
+ );
45
+
46
+ // Generate minified ESM bundle
47
+ console.log("Building minified ESM bundle...");
48
+ await createBundle(
49
+ "dist/temp/quickbaseClient.js",
50
+ [nodeResolve({ preferBuiltins: true }), commonjs(), terser()],
51
+ "esm",
52
+ {
53
+ dir: "dist/esm",
54
+ format: "esm",
55
+ sourcemap: true,
56
+ entryFileNames: "quickbase.min.js",
57
+ }
58
+ );
59
+
60
+ // Generate declarations
61
+ await generateDeclarations();
62
+
63
+ // Clean up
64
+ rimrafSync("dist/temp");
65
+ rimrafSync("dist/temp-src");
66
+
67
+ // List generated files
68
+ console.log("\nGenerated files:");
69
+ listFilesWithSizes(join(process.cwd(), "dist/esm"));
70
+
71
+ console.log("\nESM build completed successfully");
package/build-umd.js ADDED
@@ -0,0 +1,69 @@
1
+ import { rimrafSync } from "rimraf";
2
+ import { join } from "path";
3
+ import nodeResolve from "@rollup/plugin-node-resolve";
4
+ import commonjs from "@rollup/plugin-commonjs";
5
+ import terser from "@rollup/plugin-terser";
6
+ import {
7
+ copyAndRewriteTsExtensions,
8
+ compileTypeScript,
9
+ createBundle,
10
+ external,
11
+ globals,
12
+ srcDir,
13
+ tempSrcDir,
14
+ listFilesWithSizes,
15
+ } from "./build-common.js";
16
+
17
+ // Clean specific folders for UMD build
18
+ rimrafSync("dist/umd");
19
+ rimrafSync("dist/temp");
20
+ rimrafSync("dist/temp-src");
21
+
22
+ // Copy and rewrite TS files
23
+ copyAndRewriteTsExtensions(srcDir, tempSrcDir);
24
+
25
+ // Compile TypeScript
26
+ compileTypeScript();
27
+
28
+ // UMD Builds
29
+ console.log("Building UMD bundles...");
30
+
31
+ // Generate unminified UMD bundle
32
+ console.log("Building unminified UMD bundle...");
33
+ await createBundle(
34
+ "dist/temp/quickbaseClient.js",
35
+ [nodeResolve({ preferBuiltins: true, browser: true }), commonjs()],
36
+ "umd",
37
+ {
38
+ file: join(process.cwd(), "dist/umd", "quickbase.umd.js"),
39
+ format: "umd",
40
+ name: "QuickbaseJS",
41
+ sourcemap: true,
42
+ globals,
43
+ }
44
+ );
45
+
46
+ // Generate minified UMD bundle
47
+ console.log("Building minified UMD bundle...");
48
+ await createBundle(
49
+ "dist/temp/quickbaseClient.js",
50
+ [nodeResolve({ preferBuiltins: true, browser: true }), commonjs(), terser()],
51
+ "umd",
52
+ {
53
+ file: join(process.cwd(), "dist/umd", "quickbase.umd.min.js"),
54
+ format: "umd",
55
+ name: "QuickbaseJS",
56
+ sourcemap: true,
57
+ globals,
58
+ }
59
+ );
60
+
61
+ // Clean up
62
+ rimrafSync("dist/temp");
63
+ rimrafSync("dist/temp-src");
64
+
65
+ // List generated files
66
+ console.log("\nGenerated files:");
67
+ listFilesWithSizes(join(process.cwd(), "dist/umd"));
68
+
69
+ console.log("\nUMD build completed successfully");