zitejs 0.10.0-start.8 → 0.10.0

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 (417) 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 +15 -9
  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.d.ts +8 -0
  17. package/dist/cjs/bundle/index.js +38 -24
  18. package/dist/cjs/caller/index.js +43 -43
  19. package/dist/cjs/check/index.d.ts +44 -1
  20. package/dist/cjs/check/index.js +188 -113
  21. package/dist/cjs/check/start/routeTree.d.ts +8 -0
  22. package/dist/cjs/check/start/routeTree.js +118 -0
  23. package/dist/cjs/check/start/tsgo.d.ts +2 -0
  24. package/dist/cjs/check/start/tsgo.js +35 -0
  25. package/dist/cjs/cli.js +10 -4
  26. package/dist/cjs/client/index.d.ts +26 -2
  27. package/dist/cjs/client/index.js +25 -25
  28. package/dist/cjs/dev/index.js +79 -54
  29. package/dist/cjs/dev/signin.d.ts +16 -0
  30. package/dist/cjs/dev/signin.js +84 -0
  31. package/dist/cjs/index.d.ts +5 -5
  32. package/dist/cjs/integrations/client.d.ts +3 -3
  33. package/dist/cjs/integrations/client.js +5 -4
  34. package/dist/cjs/integrations/client.test-d.js +15 -15
  35. package/dist/cjs/integrations/index.d.ts +2 -2
  36. package/dist/cjs/integrations/rules.d.ts +1 -0
  37. package/dist/cjs/integrations/rules.js +48 -43
  38. package/dist/cjs/integrations/rules.test.js +60 -54
  39. package/dist/cjs/internal/appMode.d.ts +14 -0
  40. package/dist/cjs/internal/appMode.js +19 -0
  41. package/dist/cjs/internal/env.js +3 -2
  42. package/dist/cjs/internal/platformFetch.d.ts +2 -0
  43. package/dist/cjs/internal/platformFetch.js +14 -0
  44. package/dist/cjs/internal/reservedIds.d.ts +8 -0
  45. package/dist/cjs/internal/reservedIds.js +14 -0
  46. package/dist/cjs/internal/serviceUrls.d.ts +5 -0
  47. package/dist/cjs/internal/serviceUrls.js +14 -0
  48. package/dist/cjs/pdf/index.js +2 -1
  49. package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
  50. package/dist/cjs/runtime/index.d.ts +126 -39
  51. package/dist/cjs/runtime/index.js +32 -26
  52. package/dist/cjs/runtime/index.test.js +34 -34
  53. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +50 -0
  54. package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
  55. package/dist/cjs/sourceRoots.js +15 -15
  56. package/dist/cjs/sourceRoots.test.js +29 -27
  57. package/dist/cjs/start/{entries.d.ts → build/entries.d.ts} +9 -4
  58. package/dist/cjs/start/{entries.js → build/entries.js} +38 -21
  59. package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
  60. package/dist/cjs/start/build/placeholders/devApp.js +6 -0
  61. package/dist/{esm/start → cjs/start/describe}/describeBuilt.d.ts +2 -0
  62. package/dist/cjs/start/{describeBuilt.js → describe/describeBuilt.js} +55 -17
  63. package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
  64. package/dist/cjs/start/platform/aiUsage.js +215 -0
  65. package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
  66. package/dist/cjs/start/platform/airtable/cache.js +93 -0
  67. package/dist/cjs/start/protocol.d.ts +19 -0
  68. package/dist/cjs/start/protocol.js +33 -0
  69. package/dist/cjs/start/serve/local/provider.d.ts +25 -0
  70. package/dist/cjs/start/serve/local/provider.js +196 -0
  71. package/dist/cjs/start/serve/provider.d.ts +19 -0
  72. package/dist/cjs/start/serve/provider.js +86 -0
  73. package/dist/cjs/start/types.d.ts +373 -0
  74. package/dist/cjs/start/types.js +2 -0
  75. package/dist/cjs/steps/index.d.ts +78 -0
  76. package/dist/cjs/steps/index.js +507 -0
  77. package/dist/cjs/steps/index.test.js +635 -0
  78. package/dist/cjs/sync/index.d.ts +1 -1
  79. package/dist/cjs/sync/index.js +28 -27
  80. package/dist/cjs/sync/lib.d.ts +15 -8
  81. package/dist/cjs/sync/lib.js +655 -655
  82. package/dist/cjs/sync/lib.test.js +177 -46
  83. package/dist/cjs/sync/sdkNames.d.ts +67 -9
  84. package/dist/cjs/sync/sdkNames.js +97 -31
  85. package/dist/cjs/sync/sdkNames.test.js +189 -113
  86. package/dist/cjs/types/fields.d.ts +9 -2
  87. package/dist/cjs/types/fields.js +110 -96
  88. package/dist/cjs/types/index.d.ts +2 -2
  89. package/dist/cjs/types/tables.d.ts +17 -1
  90. package/dist/cjs/upload/index.js +89 -24
  91. package/dist/cjs/upload/index.test.js +104 -1
  92. package/dist/cjs/vite/domTagNames.js +252 -252
  93. package/dist/cjs/vite/index.d.ts +1 -1
  94. package/dist/cjs/vite/index.js +46 -42
  95. package/dist/esm/auth/actions.d.ts +28 -0
  96. package/dist/esm/auth/actions.js +55 -0
  97. package/dist/esm/auth/client.d.ts +357 -0
  98. package/dist/esm/auth/client.js +62 -0
  99. package/dist/esm/auth/config.js +9 -3
  100. package/dist/esm/auth/index.d.ts +2 -249
  101. package/dist/esm/auth/index.js +2 -103
  102. package/dist/esm/auth/index.test.js +60 -0
  103. package/dist/esm/auth/previewClaim.d.ts +7 -0
  104. package/dist/esm/auth/previewClaim.js +12 -0
  105. package/dist/esm/auth/profileUpdates.d.ts +9 -0
  106. package/dist/esm/auth/profileUpdates.js +6 -0
  107. package/dist/esm/backend/index.d.ts +15 -9
  108. package/dist/esm/backend/index.js +13 -13
  109. package/dist/esm/backend/index.test.js +106 -106
  110. package/dist/esm/bundle/index.d.ts +8 -0
  111. package/dist/esm/bundle/index.js +37 -24
  112. package/dist/esm/caller/index.js +44 -44
  113. package/dist/esm/check/index.d.ts +44 -1
  114. package/dist/esm/check/index.js +187 -116
  115. package/dist/esm/check/start/routeTree.d.ts +8 -0
  116. package/dist/esm/check/start/routeTree.js +77 -0
  117. package/dist/esm/check/start/tsgo.d.ts +2 -0
  118. package/dist/esm/check/start/tsgo.js +29 -0
  119. package/dist/esm/cli.js +10 -4
  120. package/dist/esm/client/index.d.ts +26 -2
  121. package/dist/esm/client/index.js +25 -25
  122. package/dist/esm/dev/index.js +86 -61
  123. package/dist/esm/dev/signin.d.ts +16 -0
  124. package/dist/esm/dev/signin.js +80 -0
  125. package/dist/esm/index.d.ts +5 -5
  126. package/dist/esm/index.js +3 -3
  127. package/dist/esm/integrations/client.d.ts +3 -3
  128. package/dist/esm/integrations/client.js +6 -5
  129. package/dist/esm/integrations/client.test-d.js +19 -19
  130. package/dist/esm/integrations/index.d.ts +2 -2
  131. package/dist/esm/integrations/index.js +1 -1
  132. package/dist/esm/integrations/rules.d.ts +1 -0
  133. package/dist/esm/integrations/rules.js +48 -43
  134. package/dist/esm/integrations/rules.test.js +62 -56
  135. package/dist/esm/internal/appMode.d.ts +14 -0
  136. package/dist/esm/internal/appMode.js +13 -0
  137. package/dist/esm/internal/env.js +3 -2
  138. package/dist/esm/internal/platformFetch.d.ts +2 -0
  139. package/dist/esm/internal/platformFetch.js +9 -0
  140. package/dist/esm/internal/reservedIds.d.ts +8 -0
  141. package/dist/esm/internal/reservedIds.js +10 -0
  142. package/dist/esm/internal/serviceUrls.d.ts +5 -0
  143. package/dist/esm/internal/serviceUrls.js +10 -0
  144. package/dist/esm/pdf/index.js +2 -1
  145. package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
  146. package/dist/esm/runtime/index.d.ts +126 -39
  147. package/dist/esm/runtime/index.js +35 -29
  148. package/dist/esm/runtime/index.test.js +36 -36
  149. package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
  150. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +48 -0
  151. package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
  152. package/dist/esm/signin/conformance.d.ts +100 -0
  153. package/dist/esm/signin/conformance.js +616 -0
  154. package/dist/esm/signin/cookies.d.ts +28 -0
  155. package/dist/esm/signin/cookies.js +67 -0
  156. package/dist/esm/signin/encoding.d.ts +1 -0
  157. package/dist/esm/signin/encoding.js +12 -0
  158. package/dist/esm/signin/endpoints.d.ts +12 -0
  159. package/dist/esm/signin/endpoints.js +32 -0
  160. package/dist/esm/signin/http.d.ts +25 -0
  161. package/dist/esm/signin/http.js +106 -0
  162. package/dist/esm/signin/index.d.ts +8 -0
  163. package/dist/esm/signin/index.js +9 -0
  164. package/dist/esm/signin/keys.d.ts +35 -0
  165. package/dist/esm/signin/keys.js +230 -0
  166. package/dist/esm/signin/paths.d.ts +2 -0
  167. package/dist/esm/signin/paths.js +5 -0
  168. package/dist/esm/signin/seal.d.ts +19 -0
  169. package/dist/esm/signin/seal.js +47 -0
  170. package/dist/esm/signin/signin.d.ts +60 -0
  171. package/dist/esm/signin/signin.js +447 -0
  172. package/dist/esm/signin/transport.d.ts +112 -0
  173. package/dist/esm/signin/transport.js +1 -0
  174. package/dist/esm/signin/verifier.d.ts +2 -0
  175. package/dist/esm/signin/verifier.js +4 -0
  176. package/dist/esm/signin/verify.d.ts +83 -0
  177. package/dist/esm/signin/verify.js +142 -0
  178. package/dist/esm/sourceRoots.js +17 -17
  179. package/dist/esm/sourceRoots.test.js +34 -32
  180. package/dist/esm/start/access.d.ts +19 -0
  181. package/dist/esm/start/access.js +43 -0
  182. package/dist/esm/start/auth.d.ts +28 -0
  183. package/dist/esm/start/auth.js +33 -0
  184. package/dist/esm/start/automations/quiet.d.ts +2 -0
  185. package/dist/esm/start/automations/quiet.js +36 -0
  186. package/dist/esm/start/{registration.d.ts → automations/registration.d.ts} +1 -1
  187. package/dist/esm/start/{registration.js → automations/registration.js} +11 -7
  188. package/dist/esm/start/automations/steps.d.ts +29 -0
  189. package/dist/esm/start/automations/steps.js +95 -0
  190. package/dist/esm/start/automations/workflow.d.ts +83 -0
  191. package/dist/esm/start/automations/workflow.js +36 -0
  192. package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
  193. package/dist/esm/start/automations/workflow.test-d.js +130 -0
  194. package/dist/esm/start/automations/workflowRun.d.ts +130 -0
  195. package/dist/esm/start/automations/workflowRun.js +185 -0
  196. package/dist/esm/start/barrel.test-d.d.ts +10 -0
  197. package/dist/esm/start/barrel.test-d.js +6 -0
  198. package/dist/esm/start/{entries.d.ts → build/entries.d.ts} +9 -4
  199. package/dist/esm/start/{entries.js → build/entries.js} +38 -22
  200. package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
  201. package/dist/esm/start/build/placeholders/devApp.js +3 -0
  202. package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
  203. package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
  204. package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
  205. package/dist/esm/start/build/placeholders/siteHead.js +3 -0
  206. package/dist/esm/start/{workflowModules.js → build/placeholders/workflowModules.js} +1 -1
  207. package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
  208. package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
  209. package/dist/esm/start/build/registrationHash.d.ts +11 -0
  210. package/dist/esm/start/build/registrationHash.js +88 -0
  211. package/dist/esm/start/build/sdk/axios.d.ts +76 -0
  212. package/dist/esm/start/build/sdk/axios.js +253 -0
  213. package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
  214. package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
  215. package/dist/esm/start/build/sdk/undici.d.ts +34 -0
  216. package/dist/esm/start/build/sdk/undici.js +18 -0
  217. package/dist/esm/start/build/sdkPatches.d.ts +22 -0
  218. package/dist/esm/start/build/sdkPatches.js +430 -0
  219. package/dist/esm/start/build/siteHead.d.ts +26 -0
  220. package/dist/esm/start/build/siteHead.js +88 -0
  221. package/dist/esm/start/build/vite.d.ts +50 -0
  222. package/dist/esm/start/build/vite.js +487 -0
  223. package/dist/esm/start/classicOnly.d.ts +1 -0
  224. package/dist/esm/start/classicOnly.js +4 -0
  225. package/dist/esm/start/describe/describe.d.ts +120 -0
  226. package/dist/esm/start/describe/describe.js +372 -0
  227. package/dist/{cjs/start → esm/start/describe}/describeBuilt.d.ts +2 -0
  228. package/dist/esm/start/describe/describeBuilt.js +102 -0
  229. package/dist/esm/start/{descriptions.js → describe/descriptions.js} +17 -10
  230. package/dist/esm/start/errors.d.ts +20 -4
  231. package/dist/esm/start/errors.js +90 -26
  232. package/dist/esm/start/errors.test.js +47 -16
  233. package/dist/esm/start/factories.d.ts +14 -0
  234. package/dist/esm/start/factories.js +23 -0
  235. package/dist/esm/start/factories.test-d.d.ts +2 -0
  236. package/dist/esm/start/factories.test-d.js +60 -0
  237. package/dist/esm/start/failures.d.ts +7 -0
  238. package/dist/esm/start/failures.js +62 -0
  239. package/dist/esm/start/fnFactory.d.ts +16 -0
  240. package/dist/esm/start/fnFactory.js +1 -0
  241. package/dist/esm/start/host.d.ts +2 -2
  242. package/dist/esm/start/host.js +3 -3
  243. package/dist/esm/start/index.d.ts +10 -63
  244. package/dist/esm/start/index.js +7 -149
  245. package/dist/esm/start/login.d.ts +5 -0
  246. package/dist/esm/start/login.js +29 -0
  247. package/dist/esm/start/middlewareKind.d.ts +13 -0
  248. package/dist/esm/start/middlewareKind.js +9 -0
  249. package/dist/esm/start/platform/aiUsage.d.ts +29 -0
  250. package/dist/esm/start/platform/aiUsage.js +210 -0
  251. package/dist/esm/start/platform/airtable/built.d.ts +2 -0
  252. package/dist/esm/start/platform/airtable/built.js +3 -0
  253. package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
  254. package/dist/esm/start/platform/airtable/cache.js +89 -0
  255. package/dist/esm/start/{airtable → platform/airtable}/dispatch.d.ts +5 -2
  256. package/dist/esm/start/{airtable → platform/airtable}/dispatch.js +195 -119
  257. package/dist/esm/start/{airtable → platform/airtable}/formulas.d.ts +2 -1
  258. package/dist/esm/start/{airtable → platform/airtable}/formulas.js +51 -25
  259. package/dist/esm/start/platform/airtable/index.d.ts +6 -0
  260. package/dist/esm/start/platform/airtable/index.js +51 -0
  261. package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
  262. package/dist/esm/start/platform/airtable/settings.js +138 -0
  263. package/dist/esm/start/platform/analytics.d.ts +3 -0
  264. package/dist/esm/start/platform/analytics.js +59 -0
  265. package/dist/esm/start/platform/calls.d.ts +5 -0
  266. package/dist/esm/start/platform/calls.js +104 -0
  267. package/dist/esm/start/platform/caps.d.ts +9 -0
  268. package/dist/esm/start/platform/caps.js +35 -0
  269. package/dist/esm/start/platform/connections.d.ts +25 -0
  270. package/dist/esm/start/platform/connections.js +198 -0
  271. package/dist/esm/start/{data → platform/data}/baseRunner.d.ts +11 -6
  272. package/dist/esm/start/platform/data/baseRunner.js +117 -0
  273. package/dist/esm/start/{data → platform/data}/dispatch.d.ts +3 -2
  274. package/dist/esm/start/{data → platform/data}/dispatch.js +69 -51
  275. package/dist/esm/start/platform/data/fetch.d.ts +7 -0
  276. package/dist/esm/start/platform/data/fetch.js +9 -0
  277. package/dist/esm/start/platform/data/index.d.ts +27 -0
  278. package/dist/esm/start/platform/data/index.js +75 -0
  279. package/dist/esm/start/platform/data/names.d.ts +7 -0
  280. package/dist/esm/start/platform/data/names.js +18 -0
  281. package/dist/esm/start/{data → platform/data}/transformations.d.ts +0 -31
  282. package/dist/esm/start/{data → platform/data}/transformations.js +0 -56
  283. package/dist/esm/start/{data → platform/data}/types.d.ts +4 -1
  284. package/dist/esm/start/{data → platform/data}/types.js +2 -2
  285. package/dist/esm/start/platform/local.d.ts +6 -0
  286. package/dist/esm/start/platform/local.js +18 -0
  287. package/dist/esm/start/platform/meta.d.ts +3 -0
  288. package/dist/esm/start/platform/meta.js +33 -0
  289. package/dist/esm/start/platform/outbound.d.ts +17 -0
  290. package/dist/esm/start/platform/outbound.js +510 -0
  291. package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
  292. package/dist/esm/start/{redactSecrets.js → platform/redactSecrets.js} +32 -7
  293. package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
  294. package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
  295. package/dist/esm/start/platform/requestSecrets.js +41 -0
  296. package/dist/esm/start/platform/runLog.d.ts +40 -0
  297. package/dist/esm/start/platform/runLog.js +149 -0
  298. package/dist/esm/start/platform/services.d.ts +7 -0
  299. package/dist/esm/start/platform/services.js +46 -0
  300. package/dist/esm/start/platform/steps.d.ts +9 -0
  301. package/dist/esm/start/platform/steps.js +60 -0
  302. package/dist/esm/start/platform/telemetry.d.ts +13 -0
  303. package/dist/esm/start/platform/telemetry.js +71 -0
  304. package/dist/esm/start/platform/transport.d.ts +28 -0
  305. package/dist/esm/start/platform/transport.js +59 -0
  306. package/dist/esm/start/platformHead.d.ts +23 -0
  307. package/dist/esm/start/platformHead.js +133 -0
  308. package/dist/esm/start/previewClaim.d.ts +3 -7
  309. package/dist/esm/start/previewClaim.js +9 -17
  310. package/dist/esm/start/protocol.d.ts +19 -0
  311. package/dist/esm/start/protocol.js +27 -0
  312. package/dist/esm/start/roles.d.ts +12 -0
  313. package/dist/esm/start/roles.js +27 -0
  314. package/dist/esm/start/router.d.ts +28 -4
  315. package/dist/esm/start/router.js +224 -21
  316. package/dist/esm/start/serve/authHooks.js +18 -0
  317. package/dist/esm/start/serve/demo.d.ts +9 -0
  318. package/dist/esm/start/serve/demo.js +24 -0
  319. package/dist/esm/start/serve/fetch.d.ts +1 -0
  320. package/dist/esm/start/serve/fetch.js +6 -0
  321. package/dist/esm/start/{instance.d.ts → serve/instance.d.ts} +6 -5
  322. package/dist/esm/start/serve/instance.js +134 -0
  323. package/dist/esm/start/serve/invoke.d.ts +13 -0
  324. package/dist/esm/start/serve/invoke.js +126 -0
  325. package/dist/esm/start/serve/local/load.d.ts +8 -0
  326. package/dist/esm/start/serve/local/load.js +44 -0
  327. package/dist/esm/start/serve/local/provider.d.ts +25 -0
  328. package/dist/esm/start/serve/local/provider.js +188 -0
  329. package/dist/esm/start/serve/local/signIn.d.ts +28 -0
  330. package/dist/esm/start/serve/local/signIn.js +123 -0
  331. package/dist/esm/start/serve/pageHead.d.ts +20 -0
  332. package/dist/esm/start/serve/pageHead.js +34 -0
  333. package/dist/esm/start/serve/provider.d.ts +19 -0
  334. package/dist/esm/start/serve/provider.js +78 -0
  335. package/dist/esm/start/serve/requestEnv.d.ts +2 -0
  336. package/dist/esm/start/serve/requestEnv.js +84 -0
  337. package/dist/esm/start/serve/scope.d.ts +18 -0
  338. package/dist/esm/start/serve/scope.js +67 -0
  339. package/dist/esm/start/serve/server.d.ts +56 -0
  340. package/dist/esm/start/serve/server.js +297 -0
  341. package/dist/esm/start/serve/uploads.d.ts +2 -0
  342. package/dist/esm/start/serve/uploads.js +49 -0
  343. package/dist/esm/start/serve/worker.d.ts +6 -0
  344. package/dist/esm/start/serve/worker.js +12 -0
  345. package/dist/esm/start/types.d.ts +270 -56
  346. package/dist/esm/start/version.d.ts +1 -1
  347. package/dist/esm/start/version.js +1 -1
  348. package/dist/esm/steps/index.d.ts +78 -0
  349. package/dist/esm/steps/index.js +502 -0
  350. package/dist/esm/steps/index.test.d.ts +1 -0
  351. package/dist/esm/steps/index.test.js +633 -0
  352. package/dist/esm/sync/index.d.ts +1 -1
  353. package/dist/esm/sync/index.js +32 -31
  354. package/dist/esm/sync/lib.d.ts +15 -8
  355. package/dist/esm/sync/lib.js +659 -659
  356. package/dist/esm/sync/lib.test.js +177 -46
  357. package/dist/esm/sync/sdkNames.d.ts +67 -9
  358. package/dist/esm/sync/sdkNames.js +94 -30
  359. package/dist/esm/sync/sdkNames.test.js +192 -116
  360. package/dist/esm/types/fields.d.ts +9 -2
  361. package/dist/esm/types/fields.js +110 -96
  362. package/dist/esm/types/index.d.ts +2 -2
  363. package/dist/esm/types/index.js +2 -2
  364. package/dist/esm/types/tables.d.ts +17 -1
  365. package/dist/esm/types/tables.js +2 -2
  366. package/dist/esm/upload/index.js +89 -24
  367. package/dist/esm/upload/index.test.js +104 -1
  368. package/dist/esm/vite/domTagNames.js +252 -252
  369. package/dist/esm/vite/index.d.ts +1 -1
  370. package/dist/esm/vite/index.js +51 -47
  371. package/package.json +95 -37
  372. package/dist/cjs/auth-server/index.d.ts +0 -369
  373. package/dist/cjs/auth-server/index.js +0 -119
  374. package/dist/cjs/start/problems.d.ts +0 -19
  375. package/dist/cjs/start/problems.js +0 -11
  376. package/dist/esm/auth-server/index.d.ts +0 -369
  377. package/dist/esm/auth-server/index.js +0 -116
  378. package/dist/esm/start/airtable/index.d.ts +0 -11
  379. package/dist/esm/start/airtable/index.js +0 -70
  380. package/dist/esm/start/authHooks.js +0 -10
  381. package/dist/esm/start/data/baseRunner.js +0 -83
  382. package/dist/esm/start/data/index.d.ts +0 -18
  383. package/dist/esm/start/data/index.js +0 -76
  384. package/dist/esm/start/describe.d.ts +0 -80
  385. package/dist/esm/start/describe.js +0 -197
  386. package/dist/esm/start/describeBuilt.js +0 -66
  387. package/dist/esm/start/instance.js +0 -80
  388. package/dist/esm/start/problems.d.ts +0 -19
  389. package/dist/esm/start/problems.js +0 -8
  390. package/dist/esm/start/redactSecrets.d.ts +0 -7
  391. package/dist/esm/start/runLog.d.ts +0 -8
  392. package/dist/esm/start/runLog.js +0 -76
  393. package/dist/esm/start/scope.d.ts +0 -15
  394. package/dist/esm/start/scope.js +0 -58
  395. package/dist/esm/start/server.d.ts +0 -55
  396. package/dist/esm/start/server.js +0 -317
  397. package/dist/esm/start/vite.d.ts +0 -9
  398. package/dist/esm/start/vite.js +0 -173
  399. package/dist/esm/start/worker.d.ts +0 -11
  400. package/dist/esm/start/worker.js +0 -20
  401. package/dist/esm/start/workflow.d.ts +0 -50
  402. package/dist/esm/start/workflow.js +0 -13
  403. package/dist/esm/start/workflow.test-d.js +0 -39
  404. package/dist/esm/start/workflowRun.d.ts +0 -80
  405. package/dist/esm/start/workflowRun.js +0 -108
  406. /package/dist/{esm/start/redactSecrets.test.d.ts → cjs/runtime/sendEmailParamsTypes.test-d.d.ts} +0 -0
  407. /package/dist/{esm/start/workflow.test-d.d.ts → cjs/steps/index.test.d.ts} +0 -0
  408. /package/dist/esm/start/{authHooksModule.d.ts → build/placeholders/authHooksModule.d.ts} +0 -0
  409. /package/dist/esm/start/{authHooksModule.js → build/placeholders/authHooksModule.js} +0 -0
  410. /package/dist/esm/start/{workflowModules.d.ts → build/placeholders/workflowModules.d.ts} +0 -0
  411. /package/dist/esm/start/{descriptions.d.ts → describe/descriptions.d.ts} +0 -0
  412. /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.d.ts +0 -0
  413. /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.js +0 -0
  414. /package/dist/esm/start/{data → platform/data}/sqlNameMappings.d.ts +0 -0
  415. /package/dist/esm/start/{data → platform/data}/sqlNameMappings.js +0 -0
  416. /package/dist/esm/start/{redactSecrets.test.js → platform/redactSecrets.test.js} +0 -0
  417. /package/dist/esm/start/{authHooks.d.ts → serve/authHooks.d.ts} +0 -0
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ /**
3
+ * What a call on an org's own AI key used, read from the provider's answer as
4
+ * classic's runtime reads it. For analytics only: the org pays the provider.
5
+ * OpenAI, Anthropic and Gemini; the host meters Zite's own key itself.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.meterAiResponse = exports.withStreamUsage = exports.AI_USAGE_HOSTS = void 0;
9
+ exports.AI_USAGE_HOSTS = {
10
+ 'api.openai.com': 'openai',
11
+ 'api.anthropic.com': 'anthropic',
12
+ 'generativelanguage.googleapis.com': 'gemini',
13
+ };
14
+ // Gemini's answers name no model, so it's read from the path: `/v1beta/models/gemini-2.0-flash:generateContent`.
15
+ const geminiModelOf = (url) => /\/models\/([^/:]+)/.exec(url.pathname)?.[1];
16
+ // Gemini's embeddings answer with no usage, so classic estimates their input at four characters a token.
17
+ const GEMINI_EMBED_PATH = /:(embedContent|batchEmbedContents)$/;
18
+ const geminiEmbedTokens = (body) => {
19
+ let parsed;
20
+ try {
21
+ parsed = typeof body === 'string' ? JSON.parse(body) : undefined;
22
+ }
23
+ catch {
24
+ return 0;
25
+ }
26
+ if (!isRecord(parsed))
27
+ return 0;
28
+ const contents = Array.isArray(parsed.requests)
29
+ ? parsed.requests.map(request => isRecord(request) ? request.content : undefined)
30
+ : [parsed.content];
31
+ const chars = contents
32
+ .flatMap(content => isRecord(content) && Array.isArray(content.parts) ? content.parts : [])
33
+ .reduce((sum, part) => sum +
34
+ (isRecord(part) && typeof part.text === 'string'
35
+ ? part.text.length
36
+ : 0), 0);
37
+ return chars > 0 ? Math.ceil(chars / 4) : 0;
38
+ };
39
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
40
+ const isNumber = (value) => typeof value === 'number' && Number.isFinite(value);
41
+ /** As classic: an OpenAI chat stream reports its usage only when asked to. The body to send instead, if any. */
42
+ const withStreamUsage = (url, method, body) => {
43
+ if (method !== 'POST' ||
44
+ typeof body !== 'string' ||
45
+ !url.pathname.endsWith('/chat/completions'))
46
+ return undefined;
47
+ try {
48
+ const json = JSON.parse(body);
49
+ if (!isRecord(json) || json.stream !== true)
50
+ return undefined;
51
+ const options = isRecord(json.stream_options) ? json.stream_options : {};
52
+ if (options.include_usage === true)
53
+ return undefined;
54
+ return JSON.stringify({
55
+ ...json,
56
+ stream_options: { ...options, include_usage: true },
57
+ });
58
+ }
59
+ catch {
60
+ return undefined;
61
+ }
62
+ };
63
+ exports.withStreamUsage = withStreamUsage;
64
+ // OpenAI and Gemini count cached tokens inside their input; classic takes them apart.
65
+ const tokensFromJson = (provider, body) => {
66
+ const tokens = {};
67
+ if (!isRecord(body))
68
+ return tokens;
69
+ if (provider === 'gemini') {
70
+ if (typeof body.model === 'string')
71
+ tokens.model = body.model;
72
+ const usage = isRecord(body.usageMetadata) ? body.usageMetadata : undefined;
73
+ if (!usage)
74
+ return tokens;
75
+ const cached = usage.cachedContentTokenCount;
76
+ if (isNumber(usage.promptTokenCount))
77
+ tokens.inputTokens =
78
+ usage.promptTokenCount - (isNumber(cached) ? cached : 0);
79
+ if (isNumber(usage.candidatesTokenCount))
80
+ tokens.outputTokens = usage.candidatesTokenCount;
81
+ if (isNumber(cached))
82
+ tokens.cachedReadInputTokens = cached;
83
+ return tokens;
84
+ }
85
+ if (provider === 'openai') {
86
+ const source = isRecord(body.response) ? body.response : body;
87
+ if (typeof source.model === 'string')
88
+ tokens.model = source.model;
89
+ const usage = isRecord(source.usage) ? source.usage : undefined;
90
+ if (!usage)
91
+ return tokens;
92
+ const details = (name) => isRecord(usage[name]) ? usage[name] : {};
93
+ const cached = details('prompt_tokens_details').cached_tokens ??
94
+ details('input_tokens_details').cached_tokens;
95
+ const input = usage.prompt_tokens ?? usage.input_tokens;
96
+ const output = usage.completion_tokens ?? usage.output_tokens;
97
+ if (isNumber(input))
98
+ tokens.inputTokens = input - (isNumber(cached) ? cached : 0);
99
+ if (isNumber(output))
100
+ tokens.outputTokens = output;
101
+ if (isNumber(cached))
102
+ tokens.cachedReadInputTokens = cached;
103
+ return tokens;
104
+ }
105
+ // A stream splits these: message_start has the input, message_delta the running output.
106
+ const message = isRecord(body.message) ? body.message : body;
107
+ if (typeof message.model === 'string')
108
+ tokens.model = message.model;
109
+ const usage = isRecord(message.usage)
110
+ ? message.usage
111
+ : isRecord(body.usage)
112
+ ? body.usage
113
+ : undefined;
114
+ if (!usage)
115
+ return tokens;
116
+ if (isNumber(usage.input_tokens))
117
+ tokens.inputTokens = usage.input_tokens;
118
+ if (isNumber(usage.output_tokens))
119
+ tokens.outputTokens = usage.output_tokens;
120
+ if (isNumber(usage.cache_read_input_tokens))
121
+ tokens.cachedReadInputTokens = usage.cache_read_input_tokens;
122
+ if (isNumber(usage.cache_creation_input_tokens))
123
+ tokens.cacheCreationInputTokens = usage.cache_creation_input_tokens;
124
+ return tokens;
125
+ };
126
+ // Later readings win: Anthropic's output is cumulative, OpenAI's usage comes last.
127
+ const merge = (into, next) => ({
128
+ model: next.model ?? into.model,
129
+ inputTokens: next.inputTokens ?? into.inputTokens,
130
+ outputTokens: next.outputTokens ?? into.outputTokens,
131
+ cachedReadInputTokens: next.cachedReadInputTokens ?? into.cachedReadInputTokens,
132
+ cacheCreationInputTokens: next.cacheCreationInputTokens ?? into.cacheCreationInputTokens,
133
+ });
134
+ const MAX_PENDING_LINE = 1024 * 1024;
135
+ const tokensFromStream = async (provider, stream, model) => {
136
+ const reader = stream.getReader();
137
+ const decoder = new TextDecoder();
138
+ let pending = '';
139
+ let tokens = { model };
140
+ const readLine = (line) => {
141
+ if (!line.startsWith('data:'))
142
+ return;
143
+ const payload = line.slice(5).trim();
144
+ if (!payload || payload === '[DONE]')
145
+ return;
146
+ try {
147
+ tokens = merge(tokens, tokensFromJson(provider, JSON.parse(payload)));
148
+ }
149
+ catch {
150
+ // Not JSON; nothing to count.
151
+ }
152
+ };
153
+ try {
154
+ for (;;) {
155
+ const { done, value } = await reader.read();
156
+ if (done)
157
+ break;
158
+ pending += decoder.decode(value, { stream: true });
159
+ const lines = pending.split('\n');
160
+ pending = lines.pop() ?? '';
161
+ if (pending.length > MAX_PENDING_LINE)
162
+ pending = '';
163
+ lines.forEach(readLine);
164
+ }
165
+ readLine(pending);
166
+ }
167
+ catch {
168
+ // What was read before the stream broke still counts.
169
+ }
170
+ return tokens;
171
+ };
172
+ const counted = (tokens) => tokens.inputTokens !== undefined || tokens.outputTokens !== undefined;
173
+ const usageOf = (provider, tokens, streaming) => counted(tokens)
174
+ ? {
175
+ provider,
176
+ ...Object.fromEntries(Object.entries(tokens).filter(([, value]) => value !== undefined)),
177
+ ...(streaming && { isStreaming: true }),
178
+ }
179
+ : undefined;
180
+ /**
181
+ * The response to hand the app, and its usage once read; a stream is split so the app reads one copy as it arrives.
182
+ * `request` is what the app sent, which names Gemini's model and holds what its embeddings are estimated from.
183
+ */
184
+ const meterAiResponse = (provider, response, request) => {
185
+ const type = response.headers.get('content-type') ?? '';
186
+ const model = provider === 'gemini' ? geminiModelOf(request.url) : undefined;
187
+ if (!response.ok)
188
+ return { response, usage: Promise.resolve(undefined) };
189
+ if (provider === 'gemini' && GEMINI_EMBED_PATH.test(request.url.pathname)) {
190
+ return {
191
+ response,
192
+ usage: Promise.resolve(usageOf(provider, { model, inputTokens: geminiEmbedTokens(request.body) }, false)),
193
+ };
194
+ }
195
+ if (!response.body)
196
+ return { response, usage: Promise.resolve(undefined) };
197
+ if (type.includes('text/event-stream')) {
198
+ const [forApp, forUs] = response.body.tee();
199
+ return {
200
+ response: new Response(forApp, response),
201
+ usage: tokensFromStream(provider, forUs, model).then(tokens => usageOf(provider, tokens, true)),
202
+ };
203
+ }
204
+ if (!type.includes('json'))
205
+ return { response, usage: Promise.resolve(undefined) };
206
+ return {
207
+ response,
208
+ usage: response
209
+ .clone()
210
+ .json()
211
+ .then((json) => usageOf(provider, merge({ model }, tokensFromJson(provider, json)), false))
212
+ .catch(() => undefined),
213
+ };
214
+ };
215
+ exports.meterAiResponse = meterAiResponse;
@@ -0,0 +1,17 @@
1
+ /** How long a read is served from the cache, as classic's. */
2
+ export declare const AIRTABLE_READ_TTL_MS = 10000;
3
+ export type AirtableCache = {
4
+ /** A read kept across requests; a write to `table` makes it stale. */
5
+ read<T>(table: string, key: string, load: () => Promise<T>): Promise<T>;
6
+ /** A write to `table`, which makes its reads stale in every isolate the cache reaches, this request's at once. */
7
+ wrote(table: string): Promise<void>;
8
+ };
9
+ /**
10
+ * One request's view of the cache for one connection. Entries are keyed by its token's hash, so only a caller holding
11
+ * the same token reads them, whoever shares the cache.
12
+ */
13
+ export declare const createAirtableCache: ({ token, waitUntil, now, }: {
14
+ token: string;
15
+ waitUntil?: (promise: Promise<unknown>) => void;
16
+ now?: () => number;
17
+ }) => Promise<AirtableCache | undefined>;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ // Classic keeps an Airtable read for 10 s across runs, in KV, and a write makes the table's reads stale wherever the
3
+ // version it bumps reaches (restly's apps/cloudflare-lambda/src/integrationCache.ts). A Start app keeps them in its
4
+ // Worker's own Cache API cache, per colo, on the same terms. Off Workers there is none, and each read goes to Airtable.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createAirtableCache = exports.AIRTABLE_READ_TTL_MS = void 0;
7
+ const CACHE_NAME = 'zite-airtable';
8
+ const ORIGIN = 'https://airtable-cache.zite.invalid';
9
+ /** How long a read is served from the cache, as classic's. */
10
+ exports.AIRTABLE_READ_TTL_MS = 10_000;
11
+ // What the cache may keep an entry for, past which it's gone whether read or not; classic's KV minimum.
12
+ const HARD_TTL_S = 60;
13
+ const VERSION_TTL_S = 24 * 60 * 60;
14
+ // Classic's cap, KV's largest value.
15
+ const MAX_ENTRY_CHARS = 25 * 1024 * 1024;
16
+ const openCache = async () => {
17
+ const storage = globalThis.caches;
18
+ if (!storage?.open)
19
+ return undefined;
20
+ try {
21
+ return await storage.open(CACHE_NAME);
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ };
27
+ const sha256 = async (text) => [
28
+ ...new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))),
29
+ ]
30
+ .map(b => b.toString(16).padStart(2, '0'))
31
+ .join('');
32
+ /**
33
+ * One request's view of the cache for one connection. Entries are keyed by its token's hash, so only a caller holding
34
+ * the same token reads them, whoever shares the cache.
35
+ */
36
+ const createAirtableCache = async ({ token, waitUntil, now = () => Date.now(), }) => {
37
+ const cache = await openCache();
38
+ if (!cache)
39
+ return undefined;
40
+ const scope = (await sha256(token)).slice(0, 32);
41
+ // This request's writes, added to what the cache says, so a read after a write misses even before the bump lands.
42
+ const bumps = new Map();
43
+ const at = (...parts) => new Request(`${ORIGIN}/${parts.map(encodeURIComponent).join('/')}`);
44
+ const stored = async (table) => {
45
+ const held = await cache
46
+ .match(at('v', scope, table))
47
+ .catch(() => undefined);
48
+ return Number.parseInt((await held?.text().catch(() => '')) ?? '', 10) || 0;
49
+ };
50
+ const kept = (put) => {
51
+ const quiet = put.catch((error) => console.warn('[zite] Airtable cache write failed', error));
52
+ waitUntil?.(quiet);
53
+ return quiet;
54
+ };
55
+ return {
56
+ async read(table, key, load) {
57
+ let entry;
58
+ try {
59
+ entry = at('r', scope, table, String((await stored(table)) + (bumps.get(table) ?? 0)), await sha256(key));
60
+ const held = await cache.match(entry);
61
+ const found = held
62
+ ? (await held.json())
63
+ : undefined;
64
+ if (found &&
65
+ typeof found.at === 'number' &&
66
+ now() - found.at < exports.AIRTABLE_READ_TTL_MS)
67
+ return found.value;
68
+ }
69
+ catch (error) {
70
+ console.warn('[zite] Airtable cache read failed', error);
71
+ }
72
+ const value = await load();
73
+ const body = entry ? JSON.stringify({ at: now(), value }) : undefined;
74
+ if (entry && body && body.length <= MAX_ENTRY_CHARS) {
75
+ void kept(cache.put(entry, new Response(body, {
76
+ headers: {
77
+ 'content-type': 'application/json',
78
+ 'cache-control': `max-age=${HARD_TTL_S}`,
79
+ },
80
+ })));
81
+ }
82
+ return value;
83
+ },
84
+ async wrote(table) {
85
+ bumps.set(table, (bumps.get(table) ?? 0) + 1);
86
+ const next = String((await stored(table)) + 1);
87
+ await kept(cache.put(at('v', scope, table), new Response(next, {
88
+ headers: { 'cache-control': `max-age=${VERSION_TTL_S}` },
89
+ })));
90
+ },
91
+ };
92
+ };
93
+ exports.createAirtableCache = createAirtableCache;
@@ -0,0 +1,19 @@
1
+ export { isReservedIntegrationId, RESERVED_INTEGRATION_IDS, } from '../internal/reservedIds.js';
2
+ export type { AppContext, ExpiringToken, HostConnection, HostMode, HostPage, HostProps, PlatformBinding, SiteHead, WebManifest, } from './types.js';
3
+ /** What the host dispatches a request to do beside serving it; without props, only `warm` and `describe`. */
4
+ export declare const INVOKE_KINDS: readonly ["webhook", "describe", "workflow", "register", "warm", "authHook", "function"];
5
+ export type InvokeKind = (typeof INVOKE_KINDS)[number];
6
+ export declare const isInvokeKind: (kind: unknown) => kind is InvokeKind;
7
+ /** `warm` or `describe`, on a request the host sends without props. */
8
+ export declare const INVOKE_HEADER = "x-zite-invoke";
9
+ /** Where the host POSTs a workflow, registration, auth hook or test run, with `{ input }`. */
10
+ export declare const INVOKE_PATH = "/_zite/invoke";
11
+ /** On describe's answer: the zitejs the build's server code was bundled from. */
12
+ export declare const RUNTIME_VERSION_HEADER = "x-zitejs-version";
13
+ /** An editor preview's access, on every same-origin fetch its pages make. */
14
+ export declare const PREVIEW_CLAIM_HEADER = "x-zite-preview";
15
+ /** At the gateway, the connection a call on Zite's AI key bills to. */
16
+ export declare const GATEWAY_CONNECTION_HEADER = "x-zite-gateway-connection";
17
+ /** On a demo's refused answer, beside its 403, so the platform's runtime shows the demo notice. */
18
+ export declare const ERROR_CODE_HEADER = "x-zite-error-code";
19
+ export declare const DEMO_READ_ONLY_CODE = "DEMO_READ_ONLY";
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ // What a Start build and the platform's host say to each other on the wire. Import-free but for the reserved ids,
3
+ // themselves import-free, so the host takes these without loading anything of zitejs.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.DEMO_READ_ONLY_CODE = exports.ERROR_CODE_HEADER = exports.GATEWAY_CONNECTION_HEADER = exports.PREVIEW_CLAIM_HEADER = exports.RUNTIME_VERSION_HEADER = exports.INVOKE_PATH = exports.INVOKE_HEADER = exports.isInvokeKind = exports.INVOKE_KINDS = exports.RESERVED_INTEGRATION_IDS = exports.isReservedIntegrationId = void 0;
6
+ var reservedIds_js_1 = require("../internal/reservedIds.js");
7
+ Object.defineProperty(exports, "isReservedIntegrationId", { enumerable: true, get: function () { return reservedIds_js_1.isReservedIntegrationId; } });
8
+ Object.defineProperty(exports, "RESERVED_INTEGRATION_IDS", { enumerable: true, get: function () { return reservedIds_js_1.RESERVED_INTEGRATION_IDS; } });
9
+ /** What the host dispatches a request to do beside serving it; without props, only `warm` and `describe`. */
10
+ exports.INVOKE_KINDS = [
11
+ 'webhook',
12
+ 'describe',
13
+ 'workflow',
14
+ 'register',
15
+ 'warm',
16
+ 'authHook',
17
+ 'function',
18
+ ];
19
+ const isInvokeKind = (kind) => exports.INVOKE_KINDS.includes(kind);
20
+ exports.isInvokeKind = isInvokeKind;
21
+ /** `warm` or `describe`, on a request the host sends without props. */
22
+ exports.INVOKE_HEADER = 'x-zite-invoke';
23
+ /** Where the host POSTs a workflow, registration, auth hook or test run, with `{ input }`. */
24
+ exports.INVOKE_PATH = '/_zite/invoke';
25
+ /** On describe's answer: the zitejs the build's server code was bundled from. */
26
+ exports.RUNTIME_VERSION_HEADER = 'x-zitejs-version';
27
+ /** An editor preview's access, on every same-origin fetch its pages make. */
28
+ exports.PREVIEW_CLAIM_HEADER = 'x-zite-preview';
29
+ /** At the gateway, the connection a call on Zite's AI key bills to. */
30
+ exports.GATEWAY_CONNECTION_HEADER = 'x-zite-gateway-connection';
31
+ /** On a demo's refused answer, beside its 403, so the platform's runtime shows the demo notice. */
32
+ exports.ERROR_CODE_HEADER = 'x-zite-error-code';
33
+ exports.DEMO_READ_ONLY_CODE = 'DEMO_READ_ONLY';
@@ -0,0 +1,25 @@
1
+ import type { AppContext, ExpiringToken, PlatformProvider, PlatformUrls } from '../../types.js';
2
+ /** What `local` reads, documented in `zitejs`'s help. */
3
+ export declare const LOCAL_ENV: {
4
+ readonly token: "ZITE_DEV_TOKEN";
5
+ readonly apiKey: "ZITE_DEV_API_KEY";
6
+ readonly urls: "ZITE_URLS";
7
+ readonly user: "ZITE_DEV_USER";
8
+ };
9
+ type Env = Record<string, string | undefined>;
10
+ /** `ZITE_URLS`, or a throw saying what it must name. */
11
+ export declare const localUrls: (raw: string | undefined) => PlatformUrls;
12
+ /** For tests: forget the minted dev token and what the backend said of it. */
13
+ export declare const resetDevToken: () => void;
14
+ export declare const mintDevToken: (backend: string, appId: string, apiKey: string) => Promise<ExpiringToken>;
15
+ /**
16
+ * What the backend says of a dev token, from the claims it verified, as OAuth's token introspection answers: asked
17
+ * once per token, whose claims never change. Throws, saying why, when it won't say.
18
+ */
19
+ export declare const describeDevToken: (backend: string, token: string) => Promise<AppContext>;
20
+ /**
21
+ * `local` when the developer set a dev token, or a key to mint them with, else undefined. Throws on env it can't read,
22
+ * so a typo fails loudly rather than signing nobody in.
23
+ */
24
+ export declare const localPlatform: (env?: Env, appId?: string | null) => PlatformProvider | undefined;
25
+ export {};
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localPlatform = exports.describeDevToken = exports.mintDevToken = exports.resetDevToken = exports.localUrls = exports.LOCAL_ENV = void 0;
4
+ // `local`: a developer's machine, with a dev token the backend minted, which the backend also describes.
5
+ const platformFetch_js_1 = require("../../../internal/platformFetch.js");
6
+ const devApp_js_1 = require("../../build/placeholders/devApp.js");
7
+ const provider_js_1 = require("../provider.js");
8
+ /** What `local` reads, documented in `zitejs`'s help. */
9
+ exports.LOCAL_ENV = {
10
+ token: 'ZITE_DEV_TOKEN',
11
+ apiKey: 'ZITE_DEV_API_KEY',
12
+ urls: 'ZITE_URLS',
13
+ user: 'ZITE_DEV_USER',
14
+ };
15
+ const processEnv = () => globalThis.process?.env;
16
+ // `local` may leave out the gateway (a call on Zite's AI key is then refused), `runs` (a preview sends no analytics,
17
+ // and `local` keeps no run detail) and each service's own URL.
18
+ const OPTIONAL_URLS = new Set([
19
+ 'gateway',
20
+ 'runs',
21
+ 'email',
22
+ 'pdf',
23
+ 'uploads',
24
+ 'steps',
25
+ 'schedules',
26
+ ]);
27
+ // Where the backend `ZITE_URLS` names answers a service it doesn't name. A dev token runs no workflow, so no steps.
28
+ const BACKEND_SERVICE_ROUTES = {
29
+ email: '/v1/start/app/email',
30
+ pdf: '/v1/start/app/pdf',
31
+ uploads: '/v1/start/app/uploads/session',
32
+ schedules: '/v1/start/app/schedules',
33
+ };
34
+ /** `ZITE_URLS`, or a throw saying what it must name. */
35
+ const localUrls = (raw) => {
36
+ let parsed;
37
+ try {
38
+ parsed = JSON.parse(raw ?? '');
39
+ }
40
+ catch {
41
+ parsed = undefined;
42
+ }
43
+ const given = (parsed ?? {});
44
+ const isUrl = (value) => typeof value === 'string' && /^https?:\/\//.test(value);
45
+ if (provider_js_1.URL_NAMES.some(name => given[name] === undefined
46
+ ? !OPTIONAL_URLS.has(name)
47
+ : !isUrl(given[name]))) {
48
+ throw new Error(`${exports.LOCAL_ENV.urls} must be JSON naming the baseRunner and backend URLs, and may name gateway, runs, email, pdf, uploads, steps and schedules`);
49
+ }
50
+ const urls = (0, provider_js_1.trimmed)(given);
51
+ const defaults = Object.fromEntries(Object.entries(BACKEND_SERVICE_ROUTES).map(([name, route]) => [
52
+ name,
53
+ `${urls.backend}${route}`,
54
+ ]));
55
+ return { ...defaults, ...urls };
56
+ };
57
+ exports.localUrls = localUrls;
58
+ const localUser = (raw) => {
59
+ if (!raw)
60
+ return null;
61
+ let given;
62
+ try {
63
+ given = JSON.parse(raw);
64
+ }
65
+ catch {
66
+ given = undefined;
67
+ }
68
+ if (typeof given?.id !== 'string' || typeof given.email !== 'string') {
69
+ throw new Error(`${exports.LOCAL_ENV.user} must be JSON with the stand-in user's id and email`);
70
+ }
71
+ const roles = Array.isArray(given.roles) ? given.roles : [];
72
+ return {
73
+ id: given.id,
74
+ email: given.email,
75
+ name: typeof given.name === 'string' ? given.name : given.email,
76
+ roles: roles.map((role) => typeof role === 'string' ? { id: role, name: role } : role),
77
+ isInternal: given.isInternal === true,
78
+ };
79
+ };
80
+ // The backend mints them for 15 minutes.
81
+ const RENEW_DEV_TOKEN_WITHIN_MS = 60_000;
82
+ const BACKEND_TIMEOUT_MS = 10_000;
83
+ // Per isolate, only answers, never a pending call: Workers ties a request's I/O to that request.
84
+ let held;
85
+ let described;
86
+ /** For tests: forget the minted dev token and what the backend said of it. */
87
+ const resetDevToken = () => {
88
+ held = undefined;
89
+ described = undefined;
90
+ };
91
+ exports.resetDevToken = resetDevToken;
92
+ const reasonOf = (response, answer) => {
93
+ const why = [answer?.message, answer?.error].find(text => typeof text === 'string');
94
+ return `${response.status}${why ? ` ${why}` : ''}`;
95
+ };
96
+ const mintDevToken = async (backend, appId, apiKey) => {
97
+ const response = await (0, platformFetch_js_1.platformFetch)(new Request(`${backend}/v1/start/apps/${encodeURIComponent(appId)}/dev-token`, {
98
+ method: 'POST',
99
+ headers: { authorization: `Bearer ${apiKey}` },
100
+ signal: AbortSignal.timeout(BACKEND_TIMEOUT_MS),
101
+ }));
102
+ const answer = (await response.json().catch(() => null));
103
+ if (response.ok && (0, provider_js_1.isExpiringToken)(answer))
104
+ return { token: answer.token, expiresAt: answer.expiresAt };
105
+ throw new Error(`The backend didn't mint a dev token for app ${appId} with ${exports.LOCAL_ENV.apiKey}: ${reasonOf(response, answer)}`);
106
+ };
107
+ exports.mintDevToken = mintDevToken;
108
+ const MODES = new Set([
109
+ 'live',
110
+ 'preview',
111
+ 'demo',
112
+ ]);
113
+ const isWhole = (value) => Number.isSafeInteger(value) && value >= 0;
114
+ const isText = (value) => typeof value === 'string' && value !== '';
115
+ const isTextOrNull = (value) => value === null || isText(value);
116
+ /** The backend's `/context` answer, or undefined when it isn't one. */
117
+ const appContextOf = (answer) => {
118
+ const given = answer;
119
+ if (!given ||
120
+ !isText(given.appId) ||
121
+ !isWhole(given.buildId) ||
122
+ !isTextOrNull(given.baseId) ||
123
+ !MODES.has(given.mode) ||
124
+ !(given.orgSettingsVersion === null || isWhole(given.orgSettingsVersion)) ||
125
+ typeof given.showZiteBadge !== 'boolean' ||
126
+ !isTextOrNull(given.appUrl)) {
127
+ return undefined;
128
+ }
129
+ return (0, provider_js_1.contextOf)(given);
130
+ };
131
+ /**
132
+ * What the backend says of a dev token, from the claims it verified, as OAuth's token introspection answers: asked
133
+ * once per token, whose claims never change. Throws, saying why, when it won't say.
134
+ */
135
+ const describeDevToken = async (backend, token) => {
136
+ const key = `${backend} ${token}`;
137
+ if (described?.key === key)
138
+ return described.context;
139
+ const response = await (0, platformFetch_js_1.platformFetch)(new Request(`${backend}/v1/start/app/context`, {
140
+ headers: { authorization: `Bearer ${token}` },
141
+ signal: AbortSignal.timeout(BACKEND_TIMEOUT_MS),
142
+ }));
143
+ const answer = await response.json().catch(() => null);
144
+ const context = response.ok ? appContextOf(answer) : undefined;
145
+ if (!context)
146
+ throw new Error(`The backend didn't say which app the dev token is for: ${reasonOf(response, answer)}`);
147
+ described = { key, context };
148
+ return context;
149
+ };
150
+ exports.describeDevToken = describeDevToken;
151
+ /** The app's dev token, minted with the developer's key, and minted again when the mint's expiry is near. */
152
+ const mintedDevToken = (backend, appId, apiKey) => {
153
+ const key = `${backend} ${appId} ${apiKey}`;
154
+ const token = (0, provider_js_1.renewedToken)({
155
+ held: () => (held?.key === key ? held.minted : undefined),
156
+ keep: minted => (held = { key, minted }),
157
+ renew: () => (0, exports.mintDevToken)(backend, appId, apiKey),
158
+ withinMs: RENEW_DEV_TOKEN_WITHIN_MS,
159
+ });
160
+ return async () => {
161
+ const minted = await token();
162
+ if (!minted)
163
+ throw new Error(`The backend didn't mint a dev token for app ${appId}`);
164
+ return minted;
165
+ };
166
+ };
167
+ // A given dev token is used as it is. A key mints them only under `vite dev`, which knows the app's id.
168
+ const localToken = (env, appId) => {
169
+ const given = env[exports.LOCAL_ENV.token];
170
+ if (given)
171
+ return () => async () => given;
172
+ const apiKey = env[exports.LOCAL_ENV.apiKey];
173
+ return apiKey && appId
174
+ ? backend => mintedDevToken(backend, appId, apiKey)
175
+ : undefined;
176
+ };
177
+ /**
178
+ * `local` when the developer set a dev token, or a key to mint them with, else undefined. Throws on env it can't read,
179
+ * so a typo fails loudly rather than signing nobody in.
180
+ */
181
+ const localPlatform = (env = processEnv() ?? {}, appId = devApp_js_1.devAppId) => {
182
+ const token = localToken(env, appId);
183
+ if (!token)
184
+ return undefined;
185
+ const urls = (0, exports.localUrls)(env[exports.LOCAL_ENV.urls]);
186
+ const user = localUser(env[exports.LOCAL_ENV.user]);
187
+ const tokenOf = token(urls.backend);
188
+ return {
189
+ kind: 'local',
190
+ urls,
191
+ user: () => user,
192
+ token: tokenOf,
193
+ context: async () => (0, exports.describeDevToken)(urls.backend, await tokenOf()),
194
+ };
195
+ };
196
+ exports.localPlatform = localPlatform;
@@ -0,0 +1,19 @@
1
+ import type { AppContext, ExpiringToken, HostProps, PlatformProvider, PlatformUrls } from '../types.js';
2
+ export declare const isExpiringToken: (value: unknown) => value is ExpiringToken;
3
+ /**
4
+ * The token to send: the one held until its expiry is near, then a renewed one. Callers at once share one renewal,
5
+ * and one that fails keeps the held token while it still serves.
6
+ */
7
+ export declare const renewedToken: ({ held, keep, renew, withinMs, }: {
8
+ held: () => {
9
+ token: string;
10
+ expiresAt?: number;
11
+ } | undefined;
12
+ keep: (fresh: ExpiringToken) => void;
13
+ renew: () => Promise<ExpiringToken | null>;
14
+ withinMs: number;
15
+ }) => (() => Promise<string | undefined>);
16
+ export declare const contextOf: ({ appId, buildId, baseId, mode, orgSettingsVersion, showZiteBadge, appUrl, }: AppContext) => AppContext;
17
+ export declare const URL_NAMES: readonly ["baseRunner", "backend", "gateway", "runs", "email", "pdf", "uploads", "steps", "schedules"];
18
+ export declare const trimmed: (urls: PlatformUrls) => PlatformUrls;
19
+ export declare const ziteProvider: (props: HostProps) => PlatformProvider;