zitejs 0.9.153 → 0.9.155

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 (393) hide show
  1. package/dist/cjs/auth/actions.d.ts +28 -0
  2. package/dist/cjs/auth/actions.js +93 -0
  3. package/dist/cjs/auth/client.d.ts +357 -0
  4. package/dist/cjs/auth/client.js +66 -0
  5. package/dist/cjs/auth/config.js +9 -3
  6. package/dist/cjs/auth/index.d.ts +2 -249
  7. package/dist/cjs/auth/index.js +11 -108
  8. package/dist/cjs/auth/index.test.js +60 -0
  9. package/dist/cjs/auth/previewClaim.d.ts +7 -0
  10. package/dist/cjs/auth/previewClaim.js +16 -0
  11. package/dist/cjs/auth/profileUpdates.d.ts +9 -0
  12. package/dist/cjs/auth/profileUpdates.js +11 -0
  13. package/dist/cjs/backend/index.d.ts +6 -6
  14. package/dist/cjs/backend/index.js +13 -13
  15. package/dist/cjs/backend/index.test.js +102 -102
  16. package/dist/cjs/bundle/index.js +29 -16
  17. package/dist/cjs/caller/index.js +43 -43
  18. package/dist/cjs/check/index.d.ts +44 -1
  19. package/dist/cjs/check/index.js +198 -61
  20. package/dist/cjs/check/start/routeTree.d.ts +8 -0
  21. package/dist/cjs/check/start/routeTree.js +118 -0
  22. package/dist/cjs/check/start/tsgo.d.ts +2 -0
  23. package/dist/cjs/check/start/tsgo.js +35 -0
  24. package/dist/cjs/cli.js +19 -6
  25. package/dist/cjs/client/index.d.ts +2 -2
  26. package/dist/cjs/client/index.js +25 -25
  27. package/dist/cjs/dev/index.js +81 -53
  28. package/dist/cjs/dev/signin.d.ts +16 -0
  29. package/dist/cjs/dev/signin.js +84 -0
  30. package/dist/cjs/index.d.ts +5 -5
  31. package/dist/cjs/integrations/client.d.ts +3 -3
  32. package/dist/cjs/integrations/client.js +5 -4
  33. package/dist/cjs/integrations/client.test-d.js +15 -15
  34. package/dist/cjs/integrations/index.d.ts +2 -2
  35. package/dist/cjs/integrations/rules.js +42 -42
  36. package/dist/cjs/integrations/rules.test.js +60 -55
  37. package/dist/cjs/internal/appMode.d.ts +14 -0
  38. package/dist/cjs/internal/appMode.js +19 -0
  39. package/dist/cjs/internal/env.js +3 -2
  40. package/dist/cjs/internal/platformFetch.d.ts +2 -0
  41. package/dist/cjs/internal/platformFetch.js +14 -0
  42. package/dist/cjs/internal/reservedIds.d.ts +8 -0
  43. package/dist/cjs/internal/reservedIds.js +14 -0
  44. package/dist/cjs/internal/serviceUrls.d.ts +5 -0
  45. package/dist/cjs/internal/serviceUrls.js +14 -0
  46. package/dist/cjs/pdf/index.js +2 -1
  47. package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
  48. package/dist/cjs/runtime/index.d.ts +22 -22
  49. package/dist/cjs/runtime/index.js +28 -28
  50. package/dist/cjs/runtime/index.test.js +34 -34
  51. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +29 -29
  52. package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
  53. package/dist/cjs/sourceRoots.js +15 -15
  54. package/dist/cjs/sourceRoots.test.js +29 -27
  55. package/dist/cjs/start/build/entries.d.ts +25 -0
  56. package/dist/cjs/start/build/entries.js +121 -0
  57. package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
  58. package/dist/cjs/start/build/placeholders/devApp.js +6 -0
  59. package/dist/cjs/start/describe/describeBuilt.d.ts +5 -0
  60. package/dist/cjs/start/describe/describeBuilt.js +144 -0
  61. package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
  62. package/dist/cjs/start/platform/aiUsage.js +215 -0
  63. package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
  64. package/dist/cjs/start/platform/airtable/cache.js +93 -0
  65. package/dist/cjs/start/protocol.d.ts +19 -0
  66. package/dist/cjs/start/protocol.js +33 -0
  67. package/dist/cjs/start/serve/local/provider.d.ts +25 -0
  68. package/dist/cjs/start/serve/local/provider.js +196 -0
  69. package/dist/cjs/start/serve/provider.d.ts +19 -0
  70. package/dist/cjs/start/serve/provider.js +86 -0
  71. package/dist/cjs/start/types.d.ts +373 -0
  72. package/dist/cjs/start/types.js +2 -0
  73. package/dist/cjs/steps/index.d.ts +8 -8
  74. package/dist/cjs/steps/index.js +53 -53
  75. package/dist/cjs/steps/index.test.js +218 -218
  76. package/dist/cjs/sync/index.d.ts +1 -1
  77. package/dist/cjs/sync/index.js +28 -27
  78. package/dist/cjs/sync/lib.d.ts +15 -8
  79. package/dist/cjs/sync/lib.js +651 -665
  80. package/dist/cjs/sync/lib.test.js +81 -14
  81. package/dist/cjs/sync/sdkNames.d.ts +67 -9
  82. package/dist/cjs/sync/sdkNames.js +97 -31
  83. package/dist/cjs/sync/sdkNames.test.js +189 -113
  84. package/dist/cjs/types/fields.d.ts +1 -1
  85. package/dist/cjs/types/fields.js +105 -97
  86. package/dist/cjs/types/index.d.ts +2 -2
  87. package/dist/cjs/types/tables.d.ts +1 -1
  88. package/dist/cjs/upload/index.js +89 -24
  89. package/dist/cjs/upload/index.test.js +104 -1
  90. package/dist/cjs/vite/domTagNames.js +252 -252
  91. package/dist/cjs/vite/index.d.ts +1 -1
  92. package/dist/cjs/vite/index.js +51 -42
  93. package/dist/cjs/vite/index.test.js +10 -2
  94. package/dist/esm/auth/actions.d.ts +28 -0
  95. package/dist/esm/auth/actions.js +55 -0
  96. package/dist/esm/auth/client.d.ts +357 -0
  97. package/dist/esm/auth/client.js +62 -0
  98. package/dist/esm/auth/config.js +9 -3
  99. package/dist/esm/auth/index.d.ts +2 -249
  100. package/dist/esm/auth/index.js +2 -103
  101. package/dist/esm/auth/index.test.js +60 -0
  102. package/dist/esm/auth/previewClaim.d.ts +7 -0
  103. package/dist/esm/auth/previewClaim.js +12 -0
  104. package/dist/esm/auth/profileUpdates.d.ts +9 -0
  105. package/dist/esm/auth/profileUpdates.js +6 -0
  106. package/dist/esm/backend/index.d.ts +6 -6
  107. package/dist/esm/backend/index.js +13 -13
  108. package/dist/esm/backend/index.test.js +106 -106
  109. package/dist/esm/bundle/index.js +29 -16
  110. package/dist/esm/caller/index.js +44 -44
  111. package/dist/esm/check/index.d.ts +44 -1
  112. package/dist/esm/check/index.js +194 -61
  113. package/dist/esm/check/start/routeTree.d.ts +8 -0
  114. package/dist/esm/check/start/routeTree.js +77 -0
  115. package/dist/esm/check/start/tsgo.d.ts +2 -0
  116. package/dist/esm/check/start/tsgo.js +29 -0
  117. package/dist/esm/cli.js +19 -6
  118. package/dist/esm/client/index.d.ts +2 -2
  119. package/dist/esm/client/index.js +25 -25
  120. package/dist/esm/dev/index.js +88 -60
  121. package/dist/esm/dev/signin.d.ts +16 -0
  122. package/dist/esm/dev/signin.js +80 -0
  123. package/dist/esm/index.d.ts +5 -5
  124. package/dist/esm/index.js +3 -3
  125. package/dist/esm/integrations/client.d.ts +3 -3
  126. package/dist/esm/integrations/client.js +6 -5
  127. package/dist/esm/integrations/client.test-d.js +19 -19
  128. package/dist/esm/integrations/index.d.ts +2 -2
  129. package/dist/esm/integrations/index.js +1 -1
  130. package/dist/esm/integrations/rules.js +42 -42
  131. package/dist/esm/integrations/rules.test.js +62 -57
  132. package/dist/esm/internal/appMode.d.ts +14 -0
  133. package/dist/esm/internal/appMode.js +13 -0
  134. package/dist/esm/internal/env.js +3 -2
  135. package/dist/esm/internal/platformFetch.d.ts +2 -0
  136. package/dist/esm/internal/platformFetch.js +9 -0
  137. package/dist/esm/internal/reservedIds.d.ts +8 -0
  138. package/dist/esm/internal/reservedIds.js +10 -0
  139. package/dist/esm/internal/serviceUrls.d.ts +5 -0
  140. package/dist/esm/internal/serviceUrls.js +10 -0
  141. package/dist/esm/pdf/index.js +2 -1
  142. package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
  143. package/dist/esm/runtime/index.d.ts +22 -22
  144. package/dist/esm/runtime/index.js +31 -31
  145. package/dist/esm/runtime/index.test.js +36 -36
  146. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +30 -30
  147. package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
  148. package/dist/esm/signin/conformance.d.ts +100 -0
  149. package/dist/esm/signin/conformance.js +616 -0
  150. package/dist/esm/signin/cookies.d.ts +28 -0
  151. package/dist/esm/signin/cookies.js +67 -0
  152. package/dist/esm/signin/encoding.d.ts +1 -0
  153. package/dist/esm/signin/encoding.js +12 -0
  154. package/dist/esm/signin/endpoints.d.ts +12 -0
  155. package/dist/esm/signin/endpoints.js +32 -0
  156. package/dist/esm/signin/http.d.ts +25 -0
  157. package/dist/esm/signin/http.js +106 -0
  158. package/dist/esm/signin/index.d.ts +8 -0
  159. package/dist/esm/signin/index.js +9 -0
  160. package/dist/esm/signin/keys.d.ts +35 -0
  161. package/dist/esm/signin/keys.js +230 -0
  162. package/dist/esm/signin/paths.d.ts +2 -0
  163. package/dist/esm/signin/paths.js +5 -0
  164. package/dist/esm/signin/seal.d.ts +19 -0
  165. package/dist/esm/signin/seal.js +47 -0
  166. package/dist/esm/signin/signin.d.ts +60 -0
  167. package/dist/esm/signin/signin.js +447 -0
  168. package/dist/esm/signin/transport.d.ts +112 -0
  169. package/dist/esm/signin/transport.js +1 -0
  170. package/dist/esm/signin/verifier.d.ts +2 -0
  171. package/dist/esm/signin/verifier.js +4 -0
  172. package/dist/esm/signin/verify.d.ts +83 -0
  173. package/dist/esm/signin/verify.js +142 -0
  174. package/dist/esm/sourceRoots.js +17 -17
  175. package/dist/esm/sourceRoots.test.js +34 -32
  176. package/dist/esm/start/access.d.ts +19 -0
  177. package/dist/esm/start/access.js +43 -0
  178. package/dist/esm/start/auth.d.ts +28 -0
  179. package/dist/esm/start/auth.js +33 -0
  180. package/dist/esm/start/automations/quiet.d.ts +2 -0
  181. package/dist/esm/start/automations/quiet.js +36 -0
  182. package/dist/esm/start/automations/registration.d.ts +13 -0
  183. package/dist/esm/start/automations/registration.js +25 -0
  184. package/dist/esm/start/automations/steps.d.ts +29 -0
  185. package/dist/esm/start/automations/steps.js +95 -0
  186. package/dist/esm/start/automations/workflow.d.ts +83 -0
  187. package/dist/esm/start/automations/workflow.js +36 -0
  188. package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
  189. package/dist/esm/start/automations/workflow.test-d.js +130 -0
  190. package/dist/esm/start/automations/workflowRun.d.ts +130 -0
  191. package/dist/esm/start/automations/workflowRun.js +185 -0
  192. package/dist/esm/start/barrel.test-d.d.ts +10 -0
  193. package/dist/esm/start/barrel.test-d.js +6 -0
  194. package/dist/esm/start/build/entries.d.ts +25 -0
  195. package/dist/esm/start/build/entries.js +109 -0
  196. package/dist/esm/start/build/placeholders/authHooksModule.d.ts +1 -0
  197. package/dist/esm/start/build/placeholders/authHooksModule.js +3 -0
  198. package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
  199. package/dist/esm/start/build/placeholders/devApp.js +3 -0
  200. package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
  201. package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
  202. package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
  203. package/dist/esm/start/build/placeholders/siteHead.js +3 -0
  204. package/dist/esm/start/build/placeholders/workflowModules.d.ts +1 -0
  205. package/dist/esm/start/build/placeholders/workflowModules.js +3 -0
  206. package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
  207. package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
  208. package/dist/esm/start/build/registrationHash.d.ts +11 -0
  209. package/dist/esm/start/build/registrationHash.js +88 -0
  210. package/dist/esm/start/build/sdk/axios.d.ts +76 -0
  211. package/dist/esm/start/build/sdk/axios.js +253 -0
  212. package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
  213. package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
  214. package/dist/esm/start/build/sdk/undici.d.ts +34 -0
  215. package/dist/esm/start/build/sdk/undici.js +18 -0
  216. package/dist/esm/start/build/sdkPatches.d.ts +22 -0
  217. package/dist/esm/start/build/sdkPatches.js +430 -0
  218. package/dist/esm/start/build/siteHead.d.ts +26 -0
  219. package/dist/esm/start/build/siteHead.js +88 -0
  220. package/dist/esm/start/build/vite.d.ts +50 -0
  221. package/dist/esm/start/build/vite.js +487 -0
  222. package/dist/esm/start/classicOnly.d.ts +1 -0
  223. package/dist/esm/start/classicOnly.js +4 -0
  224. package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
  225. package/dist/esm/start/clientErrorMessage.test.js +105 -0
  226. package/dist/esm/start/describe/describe.d.ts +120 -0
  227. package/dist/esm/start/describe/describe.js +372 -0
  228. package/dist/esm/start/describe/describeBuilt.d.ts +5 -0
  229. package/dist/esm/start/describe/describeBuilt.js +102 -0
  230. package/dist/esm/start/describe/descriptions.d.ts +4 -0
  231. package/dist/esm/start/describe/descriptions.js +54 -0
  232. package/dist/esm/start/errors.d.ts +62 -0
  233. package/dist/esm/start/errors.js +163 -0
  234. package/dist/esm/start/errors.test.d.ts +1 -0
  235. package/dist/esm/start/errors.test.js +54 -0
  236. package/dist/esm/start/factories.d.ts +14 -0
  237. package/dist/esm/start/factories.js +23 -0
  238. package/dist/esm/start/factories.test-d.d.ts +2 -0
  239. package/dist/esm/start/factories.test-d.js +60 -0
  240. package/dist/esm/start/failures.d.ts +7 -0
  241. package/dist/esm/start/failures.js +62 -0
  242. package/dist/esm/start/fnFactory.d.ts +16 -0
  243. package/dist/esm/start/fnFactory.js +1 -0
  244. package/dist/esm/start/host.d.ts +3 -0
  245. package/dist/esm/start/host.js +4 -0
  246. package/dist/esm/start/index.d.ts +10 -0
  247. package/dist/esm/start/index.js +7 -0
  248. package/dist/esm/start/login.d.ts +5 -0
  249. package/dist/esm/start/login.js +29 -0
  250. package/dist/esm/start/middlewareKind.d.ts +13 -0
  251. package/dist/esm/start/middlewareKind.js +9 -0
  252. package/dist/esm/start/platform/aiUsage.d.ts +29 -0
  253. package/dist/esm/start/platform/aiUsage.js +210 -0
  254. package/dist/esm/start/platform/airtable/arrayFields.d.ts +10 -0
  255. package/dist/esm/start/platform/airtable/arrayFields.js +30 -0
  256. package/dist/esm/start/platform/airtable/built.d.ts +2 -0
  257. package/dist/esm/start/platform/airtable/built.js +3 -0
  258. package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
  259. package/dist/esm/start/platform/airtable/cache.js +89 -0
  260. package/dist/esm/start/platform/airtable/dispatch.d.ts +57 -0
  261. package/dist/esm/start/platform/airtable/dispatch.js +541 -0
  262. package/dist/esm/start/platform/airtable/formulas.d.ts +70 -0
  263. package/dist/esm/start/platform/airtable/formulas.js +261 -0
  264. package/dist/esm/start/platform/airtable/index.d.ts +6 -0
  265. package/dist/esm/start/platform/airtable/index.js +51 -0
  266. package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
  267. package/dist/esm/start/platform/airtable/settings.js +138 -0
  268. package/dist/esm/start/platform/analytics.d.ts +3 -0
  269. package/dist/esm/start/platform/analytics.js +59 -0
  270. package/dist/esm/start/platform/calls.d.ts +5 -0
  271. package/dist/esm/start/platform/calls.js +104 -0
  272. package/dist/esm/start/platform/caps.d.ts +9 -0
  273. package/dist/esm/start/platform/caps.js +35 -0
  274. package/dist/esm/start/platform/connections.d.ts +25 -0
  275. package/dist/esm/start/platform/connections.js +198 -0
  276. package/dist/esm/start/platform/data/baseRunner.d.ts +97 -0
  277. package/dist/esm/start/platform/data/baseRunner.js +117 -0
  278. package/dist/esm/start/platform/data/dispatch.d.ts +17 -0
  279. package/dist/esm/start/platform/data/dispatch.js +216 -0
  280. package/dist/esm/start/platform/data/fetch.d.ts +7 -0
  281. package/dist/esm/start/platform/data/fetch.js +9 -0
  282. package/dist/esm/start/platform/data/index.d.ts +27 -0
  283. package/dist/esm/start/platform/data/index.js +75 -0
  284. package/dist/esm/start/platform/data/names.d.ts +7 -0
  285. package/dist/esm/start/platform/data/names.js +18 -0
  286. package/dist/esm/start/platform/data/sqlNameMappings.d.ts +58 -0
  287. package/dist/esm/start/platform/data/sqlNameMappings.js +92 -0
  288. package/dist/esm/start/platform/data/transformations.d.ts +97 -0
  289. package/dist/esm/start/platform/data/transformations.js +262 -0
  290. package/dist/esm/start/platform/data/types.d.ts +94 -0
  291. package/dist/esm/start/platform/data/types.js +14 -0
  292. package/dist/esm/start/platform/local.d.ts +6 -0
  293. package/dist/esm/start/platform/local.js +18 -0
  294. package/dist/esm/start/platform/meta.d.ts +3 -0
  295. package/dist/esm/start/platform/meta.js +33 -0
  296. package/dist/esm/start/platform/outbound.d.ts +17 -0
  297. package/dist/esm/start/platform/outbound.js +510 -0
  298. package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
  299. package/dist/esm/start/platform/redactSecrets.js +156 -0
  300. package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
  301. package/dist/esm/start/platform/redactSecrets.test.js +151 -0
  302. package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
  303. package/dist/esm/start/platform/requestSecrets.js +41 -0
  304. package/dist/esm/start/platform/runLog.d.ts +40 -0
  305. package/dist/esm/start/platform/runLog.js +149 -0
  306. package/dist/esm/start/platform/services.d.ts +7 -0
  307. package/dist/esm/start/platform/services.js +46 -0
  308. package/dist/esm/start/platform/steps.d.ts +9 -0
  309. package/dist/esm/start/platform/steps.js +60 -0
  310. package/dist/esm/start/platform/telemetry.d.ts +13 -0
  311. package/dist/esm/start/platform/telemetry.js +71 -0
  312. package/dist/esm/start/platform/transport.d.ts +28 -0
  313. package/dist/esm/start/platform/transport.js +59 -0
  314. package/dist/esm/start/platformHead.d.ts +23 -0
  315. package/dist/esm/start/platformHead.js +133 -0
  316. package/dist/esm/start/previewClaim.d.ts +6 -0
  317. package/dist/esm/start/previewClaim.js +24 -0
  318. package/dist/esm/start/protocol.d.ts +19 -0
  319. package/dist/esm/start/protocol.js +27 -0
  320. package/dist/esm/start/roles.d.ts +12 -0
  321. package/dist/esm/start/roles.js +27 -0
  322. package/dist/esm/start/router.d.ts +44 -0
  323. package/dist/esm/start/router.js +280 -0
  324. package/dist/esm/start/serve/authHooks.d.ts +7 -0
  325. package/dist/esm/start/serve/authHooks.js +18 -0
  326. package/dist/esm/start/serve/demo.d.ts +9 -0
  327. package/dist/esm/start/serve/demo.js +24 -0
  328. package/dist/esm/start/serve/fetch.d.ts +1 -0
  329. package/dist/esm/start/serve/fetch.js +6 -0
  330. package/dist/esm/start/serve/instance.d.ts +12 -0
  331. package/dist/esm/start/serve/instance.js +134 -0
  332. package/dist/esm/start/serve/invoke.d.ts +13 -0
  333. package/dist/esm/start/serve/invoke.js +126 -0
  334. package/dist/esm/start/serve/local/load.d.ts +8 -0
  335. package/dist/esm/start/serve/local/load.js +44 -0
  336. package/dist/esm/start/serve/local/provider.d.ts +25 -0
  337. package/dist/esm/start/serve/local/provider.js +188 -0
  338. package/dist/esm/start/serve/local/signIn.d.ts +28 -0
  339. package/dist/esm/start/serve/local/signIn.js +123 -0
  340. package/dist/esm/start/serve/pageHead.d.ts +20 -0
  341. package/dist/esm/start/serve/pageHead.js +34 -0
  342. package/dist/esm/start/serve/provider.d.ts +19 -0
  343. package/dist/esm/start/serve/provider.js +78 -0
  344. package/dist/esm/start/serve/requestEnv.d.ts +2 -0
  345. package/dist/esm/start/serve/requestEnv.js +84 -0
  346. package/dist/esm/start/serve/scope.d.ts +18 -0
  347. package/dist/esm/start/serve/scope.js +67 -0
  348. package/dist/esm/start/serve/server.d.ts +56 -0
  349. package/dist/esm/start/serve/server.js +297 -0
  350. package/dist/esm/start/serve/uploads.d.ts +2 -0
  351. package/dist/esm/start/serve/uploads.js +49 -0
  352. package/dist/esm/start/serve/worker.d.ts +6 -0
  353. package/dist/esm/start/serve/worker.js +12 -0
  354. package/dist/esm/start/types.d.ts +373 -0
  355. package/dist/esm/start/types.js +1 -0
  356. package/dist/esm/start/version.d.ts +1 -0
  357. package/dist/esm/start/version.js +2 -0
  358. package/dist/esm/steps/index.d.ts +8 -8
  359. package/dist/esm/steps/index.js +54 -54
  360. package/dist/esm/steps/index.test.js +220 -220
  361. package/dist/esm/sync/index.d.ts +1 -1
  362. package/dist/esm/sync/index.js +32 -31
  363. package/dist/esm/sync/lib.d.ts +15 -8
  364. package/dist/esm/sync/lib.js +655 -669
  365. package/dist/esm/sync/lib.test.js +81 -14
  366. package/dist/esm/sync/sdkNames.d.ts +67 -9
  367. package/dist/esm/sync/sdkNames.js +94 -30
  368. package/dist/esm/sync/sdkNames.test.js +192 -116
  369. package/dist/esm/types/fields.d.ts +1 -1
  370. package/dist/esm/types/fields.js +106 -98
  371. package/dist/esm/types/index.d.ts +2 -2
  372. package/dist/esm/types/index.js +2 -2
  373. package/dist/esm/types/tables.d.ts +1 -1
  374. package/dist/esm/types/tables.js +2 -2
  375. package/dist/esm/upload/index.js +89 -24
  376. package/dist/esm/upload/index.test.js +104 -1
  377. package/dist/esm/vite/domTagNames.js +252 -252
  378. package/dist/esm/vite/index.d.ts +1 -1
  379. package/dist/esm/vite/index.js +56 -47
  380. package/dist/esm/vite/index.test.js +10 -2
  381. package/package.json +129 -16
  382. package/dist/cjs/auth-server/index.d.ts +0 -369
  383. package/dist/cjs/auth-server/index.js +0 -119
  384. package/dist/cjs/meta/index.d.ts +0 -14
  385. package/dist/cjs/meta/index.js +0 -12
  386. package/dist/cjs/notifications/index.d.ts +0 -25
  387. package/dist/cjs/notifications/index.js +0 -12
  388. package/dist/esm/auth-server/index.d.ts +0 -369
  389. package/dist/esm/auth-server/index.js +0 -116
  390. package/dist/esm/meta/index.d.ts +0 -14
  391. package/dist/esm/meta/index.js +0 -8
  392. package/dist/esm/notifications/index.d.ts +0 -25
  393. package/dist/esm/notifications/index.js +0 -8
@@ -3,51 +3,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.publicFieldDefinitionSchema = exports.updatedAtTemplateSchema = exports.createdAtTemplateSchema = exports.autonumberTemplateSchema = exports.formulaTemplateSchema = exports.sourceTemplateSchema = exports.userTemplateSchema = exports.updatedByTemplateSchema = exports.createdByTemplateSchema = exports.rollupTemplateSchema = exports.lookupTemplateSchema = exports.linkedRecordTemplateSchema = exports.percentTemplateSchema = exports.durationTemplateSchema = exports.ratingTemplateSchema = exports.phoneNumberTemplateSchema = exports.urlTemplateSchema = exports.emailTemplateSchema = exports.attachmentsTemplateSchema = exports.checkboxTemplateSchema = exports.datetimeTemplateSchema = exports.dateTemplateSchema = exports.multipleSelectTemplateSchema = exports.singleSelectTemplateSchema = exports.numberTemplateSchema = exports.richTextTemplateSchema = exports.longTextTemplateSchema = exports.singleLineTextTemplateSchema = exports.currencyTemplateSchema = exports.aiGenerationConfigSchema = exports.selectOptionSchema = exports.fieldTypeSchema = exports.fieldTypeEnum = exports.durationFormatEnum = exports.timeFormatEnum = exports.dateFormatEnum = exports.numberFormatEnum = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.numberFormatEnum = [
6
- "local",
7
- "comma_period",
8
- "period_comma",
9
- "space_comma",
10
- "space_period",
11
- "no_separator",
6
+ 'local',
7
+ 'comma_period',
8
+ 'period_comma',
9
+ 'space_comma',
10
+ 'space_period',
11
+ 'no_separator',
12
12
  ];
13
- exports.dateFormatEnum = ["local", "long", "us", "european", "iso"];
14
- exports.timeFormatEnum = ["12h", "24h"];
13
+ exports.dateFormatEnum = [
14
+ 'local',
15
+ 'long',
16
+ 'us',
17
+ 'european',
18
+ 'iso',
19
+ ];
20
+ exports.timeFormatEnum = ['12h', '24h'];
15
21
  exports.durationFormatEnum = [
16
- "h:mm",
17
- "h:mm:ss",
18
- "h:mm:ss.s",
19
- "h:mm:ss.ss",
20
- "h:mm:ss.sss",
22
+ 'h:mm',
23
+ 'h:mm:ss',
24
+ 'h:mm:ss.s',
25
+ 'h:mm:ss.ss',
26
+ 'h:mm:ss.sss',
21
27
  ];
22
28
  exports.fieldTypeEnum = [
23
- "currency",
24
- "single_line_text",
25
- "long_text",
26
- "rich_text",
27
- "number",
28
- "single_select",
29
- "multiple_select",
30
- "date",
31
- "datetime",
32
- "checkbox",
33
- "attachments",
34
- "email",
35
- "url",
36
- "phone_number",
37
- "rating",
38
- "duration",
39
- "percent",
40
- "linked_record",
41
- "lookup",
42
- "source",
43
- "formula",
44
- "autonumber",
45
- "created_at",
46
- "updated_at",
47
- "rollup",
48
- "created_by",
49
- "updated_by",
50
- "user",
29
+ 'currency',
30
+ 'single_line_text',
31
+ 'long_text',
32
+ 'rich_text',
33
+ 'number',
34
+ 'single_select',
35
+ 'multiple_select',
36
+ 'date',
37
+ 'datetime',
38
+ 'checkbox',
39
+ 'attachments',
40
+ 'email',
41
+ 'url',
42
+ 'phone_number',
43
+ 'rating',
44
+ 'duration',
45
+ 'percent',
46
+ 'linked_record',
47
+ 'lookup',
48
+ 'source',
49
+ 'formula',
50
+ 'autonumber',
51
+ 'created_at',
52
+ 'updated_at',
53
+ 'rollup',
54
+ 'created_by',
55
+ 'updated_by',
56
+ 'user',
51
57
  ];
52
58
  exports.fieldTypeSchema = zod_1.z.enum(exports.fieldTypeEnum);
53
59
  exports.selectOptionSchema = zod_1.z.object({
@@ -83,22 +89,22 @@ exports.singleSelectTemplateSchema = zod_1.z.object({
83
89
  options: zod_1.z
84
90
  .array(exports.selectOptionSchema)
85
91
  .nullish()
86
- .transform((opts) => (opts ?? []).filter((o) => o.label && o.label.trim() !== "")),
92
+ .transform(opts => (opts ?? []).filter(o => o.label && o.label.trim() !== '')),
87
93
  disableColors: zod_1.z
88
94
  .boolean()
89
95
  .nullish()
90
- .transform((v) => v ?? false),
96
+ .transform(v => v ?? false),
91
97
  defaultValue: zod_1.z.string().optional(),
92
98
  });
93
99
  exports.multipleSelectTemplateSchema = zod_1.z.object({
94
100
  options: zod_1.z
95
101
  .array(exports.selectOptionSchema)
96
102
  .nullish()
97
- .transform((opts) => (opts ?? []).filter((o) => o.label && o.label.trim() !== "")),
103
+ .transform(opts => (opts ?? []).filter(o => o.label && o.label.trim() !== '')),
98
104
  disableColors: zod_1.z
99
105
  .boolean()
100
106
  .nullish()
101
- .transform((v) => v ?? false),
107
+ .transform(v => v ?? false),
102
108
  defaultValue: zod_1.z.array(zod_1.z.string()).optional(),
103
109
  });
104
110
  exports.dateTemplateSchema = zod_1.z.object({
@@ -108,19 +114,19 @@ exports.datetimeTemplateSchema = zod_1.z.object({
108
114
  displayTimeZone: zod_1.z
109
115
  .boolean()
110
116
  .nullish()
111
- .transform((v) => v ?? false),
117
+ .transform(v => v ?? false),
112
118
  dateFormat: zod_1.z
113
119
  .enum(exports.dateFormatEnum)
114
120
  .nullish()
115
- .transform((v) => v ?? "local"),
121
+ .transform(v => v ?? 'local'),
116
122
  timeFormat: zod_1.z
117
123
  .enum(exports.timeFormatEnum)
118
124
  .nullish()
119
- .transform((v) => v ?? "12h"),
125
+ .transform(v => v ?? '12h'),
120
126
  timezone: zod_1.z
121
127
  .string()
122
128
  .nullish()
123
- .transform((v) => v ?? ""),
129
+ .transform(v => v ?? ''),
124
130
  });
125
131
  exports.checkboxTemplateSchema = zod_1.z.object({
126
132
  defaultValue: zod_1.z.boolean().optional(),
@@ -153,9 +159,7 @@ exports.lookupTemplateSchema = zod_1.z.object({
153
159
  linkedRecordFieldId: zod_1.z.string().min(1),
154
160
  lookupFieldId: zod_1.z.string().min(1),
155
161
  formulaExpression: zod_1.z.string().optional(),
156
- resultType: zod_1.z
157
- .enum(["text", "number", "date", "boolean", "array"])
158
- .optional(),
162
+ resultType: zod_1.z.enum(['text', 'number', 'date', 'boolean', 'array']).optional(),
159
163
  });
160
164
  exports.rollupTemplateSchema = zod_1.z.object({
161
165
  linkedRecordFieldId: zod_1.z.string().min(1),
@@ -165,7 +169,7 @@ exports.rollupTemplateSchema = zod_1.z.object({
165
169
  formatting: zod_1.z
166
170
  .object({
167
171
  numberDisplayType: zod_1.z
168
- .enum(["number", "currency", "percent", "duration"])
172
+ .enum(['number', 'currency', 'percent', 'duration'])
169
173
  .optional(),
170
174
  currencyCode: zod_1.z.string().optional(),
171
175
  decimalPlaces: zod_1.z.number().min(0).max(10).optional(),
@@ -180,9 +184,7 @@ exports.rollupTemplateSchema = zod_1.z.object({
180
184
  .optional(),
181
185
  filterEnabled: zod_1.z.boolean().optional(),
182
186
  sortEnabled: zod_1.z.boolean().optional(),
183
- resultType: zod_1.z
184
- .enum(["text", "number", "date", "boolean", "array"])
185
- .optional(),
187
+ resultType: zod_1.z.enum(['text', 'number', 'date', 'boolean', 'array']).optional(),
186
188
  });
187
189
  exports.createdByTemplateSchema = zod_1.z.object({});
188
190
  exports.updatedByTemplateSchema = zod_1.z.object({});
@@ -190,24 +192,30 @@ exports.userTemplateSchema = zod_1.z.object({
190
192
  allowMultiple: zod_1.z
191
193
  .boolean()
192
194
  .nullish()
193
- .transform((v) => v ?? false),
195
+ .transform(v => v ?? false),
194
196
  });
195
197
  exports.sourceTemplateSchema = zod_1.z.object({});
196
198
  const formulaFormattingSchema = zod_1.z
197
199
  .object({
198
200
  numberDisplayType: zod_1.z
199
- .enum(["number", "currency", "percent", "duration"])
201
+ .enum(['number', 'currency', 'percent', 'duration'])
200
202
  .optional(),
201
203
  currencyCode: zod_1.z.string().optional(),
202
204
  decimalPlaces: zod_1.z.number().min(0).max(10).optional(),
203
205
  numberFormat: zod_1.z
204
- .enum(["local", "comma_period", "period_comma", "space_comma", "space_period"])
206
+ .enum([
207
+ 'local',
208
+ 'comma_period',
209
+ 'period_comma',
210
+ 'space_comma',
211
+ 'space_period',
212
+ ])
205
213
  .optional(),
206
214
  })
207
215
  .optional();
208
216
  exports.formulaTemplateSchema = zod_1.z.object({
209
217
  expression: zod_1.z.string().min(1),
210
- resultType: zod_1.z.enum(["text", "number", "date", "boolean", "array"]),
218
+ resultType: zod_1.z.enum(['text', 'number', 'date', 'boolean', 'array']),
211
219
  formatting: formulaFormattingSchema,
212
220
  });
213
221
  exports.autonumberTemplateSchema = zod_1.z.object({});
@@ -215,152 +223,152 @@ exports.createdAtTemplateSchema = zod_1.z.object({
215
223
  displayTimeZone: zod_1.z
216
224
  .boolean()
217
225
  .nullish()
218
- .transform((v) => v ?? false),
226
+ .transform(v => v ?? false),
219
227
  dateFormat: zod_1.z
220
228
  .enum(exports.dateFormatEnum)
221
229
  .nullish()
222
- .transform((v) => v ?? "local"),
230
+ .transform(v => v ?? 'local'),
223
231
  timeFormat: zod_1.z
224
232
  .enum(exports.timeFormatEnum)
225
233
  .nullish()
226
- .transform((v) => v ?? "12h"),
234
+ .transform(v => v ?? '12h'),
227
235
  timezone: zod_1.z
228
236
  .string()
229
237
  .nullish()
230
- .transform((v) => v ?? ""),
238
+ .transform(v => v ?? ''),
231
239
  });
232
240
  exports.updatedAtTemplateSchema = zod_1.z.object({
233
241
  displayTimeZone: zod_1.z
234
242
  .boolean()
235
243
  .nullish()
236
- .transform((v) => v ?? false),
244
+ .transform(v => v ?? false),
237
245
  dateFormat: zod_1.z
238
246
  .enum(exports.dateFormatEnum)
239
247
  .nullish()
240
- .transform((v) => v ?? "local"),
248
+ .transform(v => v ?? 'local'),
241
249
  timeFormat: zod_1.z
242
250
  .enum(exports.timeFormatEnum)
243
251
  .nullish()
244
- .transform((v) => v ?? "12h"),
252
+ .transform(v => v ?? '12h'),
245
253
  timezone: zod_1.z
246
254
  .string()
247
255
  .nullish()
248
- .transform((v) => v ?? ""),
256
+ .transform(v => v ?? ''),
249
257
  });
250
258
  const basePublicFieldSchema = zod_1.z.object({
251
259
  name: zod_1.z.string(),
252
260
  });
253
- exports.publicFieldDefinitionSchema = zod_1.z.discriminatedUnion("type", [
261
+ exports.publicFieldDefinitionSchema = zod_1.z.discriminatedUnion('type', [
254
262
  basePublicFieldSchema.extend({
255
- type: zod_1.z.literal("currency"),
263
+ type: zod_1.z.literal('currency'),
256
264
  template: exports.currencyTemplateSchema,
257
265
  }),
258
266
  basePublicFieldSchema.extend({
259
- type: zod_1.z.literal("single_line_text"),
267
+ type: zod_1.z.literal('single_line_text'),
260
268
  template: exports.singleLineTextTemplateSchema,
261
269
  }),
262
270
  basePublicFieldSchema.extend({
263
- type: zod_1.z.literal("long_text"),
271
+ type: zod_1.z.literal('long_text'),
264
272
  template: exports.longTextTemplateSchema,
265
273
  }),
266
274
  basePublicFieldSchema.extend({
267
- type: zod_1.z.literal("rich_text"),
275
+ type: zod_1.z.literal('rich_text'),
268
276
  template: exports.richTextTemplateSchema,
269
277
  }),
270
278
  basePublicFieldSchema.extend({
271
- type: zod_1.z.literal("number"),
279
+ type: zod_1.z.literal('number'),
272
280
  template: exports.numberTemplateSchema,
273
281
  }),
274
282
  basePublicFieldSchema.extend({
275
- type: zod_1.z.literal("single_select"),
283
+ type: zod_1.z.literal('single_select'),
276
284
  template: exports.singleSelectTemplateSchema,
277
285
  }),
278
286
  basePublicFieldSchema.extend({
279
- type: zod_1.z.literal("multiple_select"),
287
+ type: zod_1.z.literal('multiple_select'),
280
288
  template: exports.multipleSelectTemplateSchema,
281
289
  }),
282
290
  basePublicFieldSchema.extend({
283
- type: zod_1.z.literal("date"),
291
+ type: zod_1.z.literal('date'),
284
292
  template: exports.dateTemplateSchema,
285
293
  }),
286
294
  basePublicFieldSchema.extend({
287
- type: zod_1.z.literal("datetime"),
295
+ type: zod_1.z.literal('datetime'),
288
296
  template: exports.datetimeTemplateSchema,
289
297
  }),
290
298
  basePublicFieldSchema.extend({
291
- type: zod_1.z.literal("checkbox"),
299
+ type: zod_1.z.literal('checkbox'),
292
300
  template: exports.checkboxTemplateSchema,
293
301
  }),
294
302
  basePublicFieldSchema.extend({
295
- type: zod_1.z.literal("attachments"),
303
+ type: zod_1.z.literal('attachments'),
296
304
  template: exports.attachmentsTemplateSchema,
297
305
  }),
298
306
  basePublicFieldSchema.extend({
299
- type: zod_1.z.literal("email"),
307
+ type: zod_1.z.literal('email'),
300
308
  template: exports.emailTemplateSchema,
301
309
  }),
302
310
  basePublicFieldSchema.extend({
303
- type: zod_1.z.literal("url"),
311
+ type: zod_1.z.literal('url'),
304
312
  template: exports.urlTemplateSchema,
305
313
  }),
306
314
  basePublicFieldSchema.extend({
307
- type: zod_1.z.literal("phone_number"),
315
+ type: zod_1.z.literal('phone_number'),
308
316
  template: exports.phoneNumberTemplateSchema,
309
317
  }),
310
318
  basePublicFieldSchema.extend({
311
- type: zod_1.z.literal("rating"),
319
+ type: zod_1.z.literal('rating'),
312
320
  template: exports.ratingTemplateSchema,
313
321
  }),
314
322
  basePublicFieldSchema.extend({
315
- type: zod_1.z.literal("duration"),
323
+ type: zod_1.z.literal('duration'),
316
324
  template: exports.durationTemplateSchema,
317
325
  }),
318
326
  basePublicFieldSchema.extend({
319
- type: zod_1.z.literal("percent"),
327
+ type: zod_1.z.literal('percent'),
320
328
  template: exports.percentTemplateSchema,
321
329
  }),
322
330
  basePublicFieldSchema.extend({
323
- type: zod_1.z.literal("linked_record"),
331
+ type: zod_1.z.literal('linked_record'),
324
332
  template: exports.linkedRecordTemplateSchema,
325
333
  }),
326
334
  basePublicFieldSchema.extend({
327
- type: zod_1.z.literal("lookup"),
335
+ type: zod_1.z.literal('lookup'),
328
336
  template: exports.lookupTemplateSchema,
329
337
  }),
330
338
  basePublicFieldSchema.extend({
331
- type: zod_1.z.literal("rollup"),
339
+ type: zod_1.z.literal('rollup'),
332
340
  template: exports.rollupTemplateSchema,
333
341
  }),
334
342
  basePublicFieldSchema.extend({
335
- type: zod_1.z.literal("created_by"),
343
+ type: zod_1.z.literal('created_by'),
336
344
  template: exports.createdByTemplateSchema,
337
345
  }),
338
346
  basePublicFieldSchema.extend({
339
- type: zod_1.z.literal("updated_by"),
347
+ type: zod_1.z.literal('updated_by'),
340
348
  template: exports.updatedByTemplateSchema,
341
349
  }),
342
350
  basePublicFieldSchema.extend({
343
- type: zod_1.z.literal("user"),
351
+ type: zod_1.z.literal('user'),
344
352
  template: exports.userTemplateSchema,
345
353
  }),
346
354
  basePublicFieldSchema.extend({
347
- type: zod_1.z.literal("source"),
355
+ type: zod_1.z.literal('source'),
348
356
  template: exports.sourceTemplateSchema,
349
357
  }),
350
358
  basePublicFieldSchema.extend({
351
- type: zod_1.z.literal("formula"),
359
+ type: zod_1.z.literal('formula'),
352
360
  template: exports.formulaTemplateSchema,
353
361
  }),
354
362
  basePublicFieldSchema.extend({
355
- type: zod_1.z.literal("autonumber"),
363
+ type: zod_1.z.literal('autonumber'),
356
364
  template: exports.autonumberTemplateSchema,
357
365
  }),
358
366
  basePublicFieldSchema.extend({
359
- type: zod_1.z.literal("created_at"),
367
+ type: zod_1.z.literal('created_at'),
360
368
  template: exports.createdAtTemplateSchema,
361
369
  }),
362
370
  basePublicFieldSchema.extend({
363
- type: zod_1.z.literal("updated_at"),
371
+ type: zod_1.z.literal('updated_at'),
364
372
  template: exports.updatedAtTemplateSchema,
365
373
  }),
366
374
  ]);
@@ -1,2 +1,2 @@
1
- export * from "./fields.js";
2
- export * from "./tables.js";
1
+ export * from './fields.js';
2
+ export * from './tables.js';
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  export declare const fieldSchema: z.ZodIntersection<z.ZodObject<{
3
3
  id: z.ZodString;
4
4
  order: z.ZodNumber;
@@ -6,6 +6,9 @@ exports.uploadFile = uploadFile;
6
6
  exports.useUpload = useUpload;
7
7
  const react_1 = require("react");
8
8
  const config_js_1 = require("../auth/config.js");
9
+ const appMode_js_1 = require("../internal/appMode.js");
10
+ const platformFetch_js_1 = require("../internal/platformFetch.js");
11
+ const serviceUrls_js_1 = require("../internal/serviceUrls.js");
9
12
  const constants_js_1 = require("../auth/constants.js");
10
13
  class FileUploadError extends Error {
11
14
  constructor(message) {
@@ -14,7 +17,16 @@ class FileUploadError extends Error {
14
17
  }
15
18
  }
16
19
  exports.FileUploadError = FileUploadError;
17
- function getZiteAppMode(hostname) {
20
+ /** As the platform served the page or request; a classic app's from its hostname. */
21
+ function getZiteAppMode() {
22
+ const served = (0, appMode_js_1.platformMode)();
23
+ if (served)
24
+ return served === 'preview' || served === 'validate' ? 'preview' : 'live';
25
+ // On a server, outside any request the platform served: there's no telling a preview from live.
26
+ if (typeof window === 'undefined') {
27
+ throw new FileUploadError('Upload from a page, or from a request the platform is serving');
28
+ }
29
+ const { hostname } = window.location;
18
30
  const maybeId = hostname.split('.')[0];
19
31
  if (maybeId?.startsWith(constants_js_1.ZITE_APP_EDITOR_HOSTNAME_PREFIX))
20
32
  return 'preview';
@@ -80,22 +92,80 @@ function authHeaders() {
80
92
  : null;
81
93
  return token ? { Authorization: 'Bearer ' + token } : {};
82
94
  }
83
- async function performUpload(data, filename) {
84
- const blob = toUploadBlob(data);
85
- const mode = getZiteAppMode(window.location.hostname);
95
+ // On Start the session's answer says whether to complete, and where. No credential goes with it, so the app token never
96
+ // reaches an origin the platform didn't name in the app's props.
97
+ const startCompletion = session => session.completeUrl ? { url: session.completeUrl, headers: {} } : undefined;
98
+ /** On a Start server holding an app token: the platform's uploads service, which reads the app and mode from the token. */
99
+ async function tokenRoutes() {
100
+ const provider = (0, appMode_js_1.platformProvider)();
101
+ const urls = provider?.urls;
102
+ const token = urls ? await provider?.token() : undefined;
103
+ if (!urls || !token)
104
+ return undefined;
105
+ return {
106
+ session: body => (0, platformFetch_js_1.platformFetch)(new Request((0, serviceUrls_js_1.serviceUrl)(urls, 'uploads'), {
107
+ method: 'POST',
108
+ headers: {
109
+ 'Content-Type': 'application/json',
110
+ Authorization: 'Bearer ' + token,
111
+ },
112
+ body,
113
+ })),
114
+ completion: startCompletion,
115
+ };
116
+ }
117
+ /** In a Start page: the app's own server, which asks the platform on its request's token, in the mode it was served. */
118
+ function pageRoutes() {
119
+ if (typeof window === 'undefined' || !(0, appMode_js_1.platformMode)())
120
+ return undefined;
121
+ return {
122
+ session: body => fetch(serviceUrls_js_1.UPLOAD_SESSION_PATH, {
123
+ method: 'POST',
124
+ headers: { 'Content-Type': 'application/json' },
125
+ body,
126
+ }),
127
+ completion: startCompletion,
128
+ };
129
+ }
130
+ /** A classic app's, and a Start server's on a host that sent no token. */
131
+ function publicRoutes() {
132
+ const mode = getZiteAppMode();
86
133
  const flowId = (0, config_js_1.getFlowId)();
87
- const sessionRes = await fetch((0, config_js_1.getApiUrl)() + '/v1/zite/public/' + flowId + '/upload-session?mode=' + mode, {
88
- method: 'POST',
89
- headers: {
90
- 'Content-Type': 'application/json',
91
- ...authHeaders(),
92
- },
93
- body: JSON.stringify({
94
- filename,
95
- uploadLength: blob.size,
96
- contentType: blob.type || 'application/octet-stream',
134
+ return {
135
+ session: body => fetch((0, config_js_1.getApiUrl)() +
136
+ '/v1/zite/public/' +
137
+ flowId +
138
+ '/upload-session?mode=' +
139
+ mode, {
140
+ method: 'POST',
141
+ headers: {
142
+ 'Content-Type': 'application/json',
143
+ ...authHeaders(),
144
+ },
145
+ body,
97
146
  }),
98
- });
147
+ // Gateways that predate the storage ledger omit the token. The file is
148
+ // already at fileUrl, so those uploads still succeed.
149
+ completion: session => session.completionToken
150
+ ? {
151
+ url: (0, config_js_1.getApiUrl)() +
152
+ '/v1/zite/public/' +
153
+ flowId +
154
+ '/complete-upload?mode=' +
155
+ mode,
156
+ headers: authHeaders(),
157
+ }
158
+ : undefined,
159
+ };
160
+ }
161
+ async function performUpload(data, filename) {
162
+ const blob = toUploadBlob(data);
163
+ const routes = (await tokenRoutes()) ?? pageRoutes() ?? publicRoutes();
164
+ const sessionRes = await routes.session(JSON.stringify({
165
+ filename,
166
+ uploadLength: blob.size,
167
+ contentType: blob.type || 'application/octet-stream',
168
+ }));
99
169
  if (!sessionRes.ok) {
100
170
  throw new FileUploadError(await readErrorMessage(sessionRes, 'Upload failed'));
101
171
  }
@@ -113,18 +183,13 @@ async function performUpload(data, filename) {
113
183
  if (!putRes.ok) {
114
184
  throw new FileUploadError('Upload failed');
115
185
  }
116
- // Gateways that predate the storage ledger omit the token. The file is
117
- // already at fileUrl, so those uploads still succeed.
118
- if (session.completionToken) {
119
- const completeRes = await fetch((0, config_js_1.getApiUrl)() +
120
- '/v1/zite/public/' +
121
- flowId +
122
- '/complete-upload?mode=' +
123
- mode, {
186
+ const completion = routes.completion(session);
187
+ if (completion) {
188
+ const completeRes = await fetch(completion.url, {
124
189
  method: 'POST',
125
190
  headers: {
126
191
  'Content-Type': 'application/json',
127
- ...authHeaders(),
192
+ ...completion.headers,
128
193
  },
129
194
  body: JSON.stringify({ completionToken: session.completionToken }),
130
195
  });