zitejs 0.10.0-start.3 → 0.10.0-start.30

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 (414) 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 +123 -5
  14. package/dist/cjs/backend/index.js +13 -13
  15. package/dist/cjs/backend/index.test.js +144 -86
  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 +14 -0
  37. package/dist/cjs/integrations/rules.js +67 -33
  38. package/dist/cjs/integrations/rules.test.js +60 -53
  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} +13 -4
  58. package/dist/cjs/start/{entries.js → build/entries.js} +49 -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.d.ts +1 -0
  78. package/dist/cjs/steps/index.test.js +635 -0
  79. package/dist/cjs/sync/index.d.ts +1 -1
  80. package/dist/cjs/sync/index.js +28 -27
  81. package/dist/cjs/sync/lib.d.ts +15 -8
  82. package/dist/cjs/sync/lib.js +660 -663
  83. package/dist/cjs/sync/lib.test.js +177 -46
  84. package/dist/cjs/sync/sdkNames.d.ts +67 -9
  85. package/dist/cjs/sync/sdkNames.js +97 -31
  86. package/dist/cjs/sync/sdkNames.test.js +189 -113
  87. package/dist/cjs/types/fields.d.ts +9 -2
  88. package/dist/cjs/types/fields.js +110 -96
  89. package/dist/cjs/types/index.d.ts +2 -2
  90. package/dist/cjs/types/tables.d.ts +17 -1
  91. package/dist/cjs/upload/index.js +89 -24
  92. package/dist/cjs/upload/index.test.js +104 -1
  93. package/dist/cjs/vite/domTagNames.js +252 -252
  94. package/dist/cjs/vite/index.d.ts +1 -1
  95. package/dist/cjs/vite/index.js +51 -42
  96. package/dist/cjs/vite/index.test.js +10 -2
  97. package/dist/esm/auth/actions.d.ts +28 -0
  98. package/dist/esm/auth/actions.js +55 -0
  99. package/dist/esm/auth/client.d.ts +357 -0
  100. package/dist/esm/auth/client.js +62 -0
  101. package/dist/esm/auth/config.js +9 -3
  102. package/dist/esm/auth/index.d.ts +2 -249
  103. package/dist/esm/auth/index.js +2 -103
  104. package/dist/esm/auth/index.test.js +60 -0
  105. package/dist/esm/auth/previewClaim.d.ts +7 -0
  106. package/dist/esm/auth/previewClaim.js +12 -0
  107. package/dist/esm/auth/profileUpdates.d.ts +9 -0
  108. package/dist/esm/auth/profileUpdates.js +6 -0
  109. package/dist/esm/backend/index.d.ts +123 -5
  110. package/dist/esm/backend/index.js +13 -13
  111. package/dist/esm/backend/index.test.js +148 -90
  112. package/dist/esm/bundle/index.d.ts +8 -0
  113. package/dist/esm/bundle/index.js +37 -24
  114. package/dist/esm/caller/index.js +44 -44
  115. package/dist/esm/check/index.d.ts +44 -1
  116. package/dist/esm/check/index.js +187 -116
  117. package/dist/esm/check/start/routeTree.d.ts +8 -0
  118. package/dist/esm/check/start/routeTree.js +77 -0
  119. package/dist/esm/check/start/tsgo.d.ts +2 -0
  120. package/dist/esm/check/start/tsgo.js +29 -0
  121. package/dist/esm/cli.js +10 -4
  122. package/dist/esm/client/index.d.ts +26 -2
  123. package/dist/esm/client/index.js +25 -25
  124. package/dist/esm/dev/index.js +86 -61
  125. package/dist/esm/dev/signin.d.ts +16 -0
  126. package/dist/esm/dev/signin.js +80 -0
  127. package/dist/esm/index.d.ts +5 -5
  128. package/dist/esm/index.js +3 -3
  129. package/dist/esm/integrations/client.d.ts +3 -3
  130. package/dist/esm/integrations/client.js +6 -5
  131. package/dist/esm/integrations/client.test-d.js +19 -19
  132. package/dist/esm/integrations/index.d.ts +2 -2
  133. package/dist/esm/integrations/index.js +1 -1
  134. package/dist/esm/integrations/rules.d.ts +14 -0
  135. package/dist/esm/integrations/rules.js +67 -33
  136. package/dist/esm/integrations/rules.test.js +62 -55
  137. package/dist/esm/internal/appMode.d.ts +14 -0
  138. package/dist/esm/internal/appMode.js +13 -0
  139. package/dist/esm/internal/env.js +3 -2
  140. package/dist/esm/internal/platformFetch.d.ts +2 -0
  141. package/dist/esm/internal/platformFetch.js +9 -0
  142. package/dist/esm/internal/reservedIds.d.ts +8 -0
  143. package/dist/esm/internal/reservedIds.js +10 -0
  144. package/dist/esm/internal/serviceUrls.d.ts +5 -0
  145. package/dist/esm/internal/serviceUrls.js +10 -0
  146. package/dist/esm/pdf/index.js +2 -1
  147. package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
  148. package/dist/esm/runtime/index.d.ts +126 -39
  149. package/dist/esm/runtime/index.js +35 -29
  150. package/dist/esm/runtime/index.test.js +36 -36
  151. package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
  152. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +48 -0
  153. package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
  154. package/dist/esm/signin/conformance.d.ts +100 -0
  155. package/dist/esm/signin/conformance.js +616 -0
  156. package/dist/esm/signin/cookies.d.ts +28 -0
  157. package/dist/esm/signin/cookies.js +67 -0
  158. package/dist/esm/signin/encoding.d.ts +1 -0
  159. package/dist/esm/signin/encoding.js +12 -0
  160. package/dist/esm/signin/endpoints.d.ts +12 -0
  161. package/dist/esm/signin/endpoints.js +32 -0
  162. package/dist/esm/signin/http.d.ts +25 -0
  163. package/dist/esm/signin/http.js +106 -0
  164. package/dist/esm/signin/index.d.ts +8 -0
  165. package/dist/esm/signin/index.js +9 -0
  166. package/dist/esm/signin/keys.d.ts +35 -0
  167. package/dist/esm/signin/keys.js +230 -0
  168. package/dist/esm/signin/paths.d.ts +2 -0
  169. package/dist/esm/signin/paths.js +5 -0
  170. package/dist/esm/signin/seal.d.ts +19 -0
  171. package/dist/esm/signin/seal.js +47 -0
  172. package/dist/esm/signin/signin.d.ts +60 -0
  173. package/dist/esm/signin/signin.js +447 -0
  174. package/dist/esm/signin/transport.d.ts +112 -0
  175. package/dist/esm/signin/transport.js +1 -0
  176. package/dist/esm/signin/verifier.d.ts +2 -0
  177. package/dist/esm/signin/verifier.js +4 -0
  178. package/dist/esm/signin/verify.d.ts +83 -0
  179. package/dist/esm/signin/verify.js +142 -0
  180. package/dist/esm/sourceRoots.js +17 -17
  181. package/dist/esm/sourceRoots.test.js +34 -32
  182. package/dist/esm/start/access.d.ts +19 -0
  183. package/dist/esm/start/access.js +43 -0
  184. package/dist/esm/start/auth.d.ts +28 -0
  185. package/dist/esm/start/auth.js +33 -0
  186. package/dist/esm/start/automations/quiet.d.ts +2 -0
  187. package/dist/esm/start/automations/quiet.js +36 -0
  188. package/dist/esm/start/automations/registration.d.ts +13 -0
  189. package/dist/esm/start/automations/registration.js +25 -0
  190. package/dist/esm/start/automations/steps.d.ts +29 -0
  191. package/dist/esm/start/automations/steps.js +95 -0
  192. package/dist/esm/start/automations/workflow.d.ts +83 -0
  193. package/dist/esm/start/automations/workflow.js +36 -0
  194. package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
  195. package/dist/esm/start/automations/workflow.test-d.js +130 -0
  196. package/dist/esm/start/automations/workflowRun.d.ts +130 -0
  197. package/dist/esm/start/automations/workflowRun.js +185 -0
  198. package/dist/esm/start/barrel.test-d.d.ts +10 -0
  199. package/dist/esm/start/barrel.test-d.js +6 -0
  200. package/dist/esm/start/{entries.d.ts → build/entries.d.ts} +13 -4
  201. package/dist/esm/start/build/entries.js +109 -0
  202. package/dist/esm/start/build/placeholders/authHooksModule.d.ts +1 -0
  203. package/dist/esm/start/build/placeholders/authHooksModule.js +3 -0
  204. package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
  205. package/dist/esm/start/build/placeholders/devApp.js +3 -0
  206. package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
  207. package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
  208. package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
  209. package/dist/esm/start/build/placeholders/siteHead.js +3 -0
  210. package/dist/esm/start/{workflowModules.js → build/placeholders/workflowModules.js} +1 -1
  211. package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
  212. package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
  213. package/dist/esm/start/build/registrationHash.d.ts +11 -0
  214. package/dist/esm/start/build/registrationHash.js +88 -0
  215. package/dist/esm/start/build/sdk/axios.d.ts +76 -0
  216. package/dist/esm/start/build/sdk/axios.js +253 -0
  217. package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
  218. package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
  219. package/dist/esm/start/build/sdk/undici.d.ts +34 -0
  220. package/dist/esm/start/build/sdk/undici.js +18 -0
  221. package/dist/esm/start/build/sdkPatches.d.ts +22 -0
  222. package/dist/esm/start/build/sdkPatches.js +430 -0
  223. package/dist/esm/start/build/siteHead.d.ts +26 -0
  224. package/dist/esm/start/build/siteHead.js +88 -0
  225. package/dist/esm/start/build/vite.d.ts +50 -0
  226. package/dist/esm/start/build/vite.js +487 -0
  227. package/dist/esm/start/classicOnly.d.ts +1 -0
  228. package/dist/esm/start/classicOnly.js +4 -0
  229. package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
  230. package/dist/esm/start/clientErrorMessage.test.js +105 -0
  231. package/dist/esm/start/describe/describe.d.ts +120 -0
  232. package/dist/esm/start/describe/describe.js +372 -0
  233. package/dist/{cjs/start → esm/start/describe}/describeBuilt.d.ts +2 -0
  234. package/dist/esm/start/describe/describeBuilt.js +102 -0
  235. package/dist/esm/start/{descriptions.js → describe/descriptions.js} +17 -10
  236. package/dist/esm/start/errors.d.ts +62 -0
  237. package/dist/esm/start/errors.js +163 -0
  238. package/dist/esm/start/errors.test.d.ts +1 -0
  239. package/dist/esm/start/errors.test.js +54 -0
  240. package/dist/esm/start/factories.d.ts +14 -0
  241. package/dist/esm/start/factories.js +23 -0
  242. package/dist/esm/start/factories.test-d.d.ts +2 -0
  243. package/dist/esm/start/factories.test-d.js +60 -0
  244. package/dist/esm/start/failures.d.ts +7 -0
  245. package/dist/esm/start/failures.js +62 -0
  246. package/dist/esm/start/fnFactory.d.ts +16 -0
  247. package/dist/esm/start/fnFactory.js +1 -0
  248. package/dist/esm/start/host.d.ts +2 -2
  249. package/dist/esm/start/host.js +3 -3
  250. package/dist/esm/start/index.d.ts +10 -70
  251. package/dist/esm/start/index.js +7 -152
  252. package/dist/esm/start/login.d.ts +5 -0
  253. package/dist/esm/start/login.js +29 -0
  254. package/dist/esm/start/middlewareKind.d.ts +13 -0
  255. package/dist/esm/start/middlewareKind.js +9 -0
  256. package/dist/esm/start/platform/aiUsage.d.ts +29 -0
  257. package/dist/esm/start/platform/aiUsage.js +210 -0
  258. package/dist/esm/start/platform/airtable/arrayFields.d.ts +10 -0
  259. package/dist/esm/start/platform/airtable/arrayFields.js +30 -0
  260. package/dist/esm/start/platform/airtable/built.d.ts +2 -0
  261. package/dist/esm/start/platform/airtable/built.js +3 -0
  262. package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
  263. package/dist/esm/start/platform/airtable/cache.js +89 -0
  264. package/dist/esm/start/platform/airtable/dispatch.d.ts +57 -0
  265. package/dist/esm/start/platform/airtable/dispatch.js +541 -0
  266. package/dist/esm/start/platform/airtable/formulas.d.ts +70 -0
  267. package/dist/esm/start/platform/airtable/formulas.js +261 -0
  268. package/dist/esm/start/platform/airtable/index.d.ts +6 -0
  269. package/dist/esm/start/platform/airtable/index.js +51 -0
  270. package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
  271. package/dist/esm/start/platform/airtable/settings.js +138 -0
  272. package/dist/esm/start/platform/analytics.d.ts +3 -0
  273. package/dist/esm/start/platform/analytics.js +59 -0
  274. package/dist/esm/start/platform/calls.d.ts +5 -0
  275. package/dist/esm/start/platform/calls.js +104 -0
  276. package/dist/esm/start/platform/caps.d.ts +9 -0
  277. package/dist/esm/start/platform/caps.js +35 -0
  278. package/dist/esm/start/platform/connections.d.ts +25 -0
  279. package/dist/esm/start/platform/connections.js +198 -0
  280. package/dist/esm/start/platform/data/baseRunner.d.ts +97 -0
  281. package/dist/esm/start/platform/data/baseRunner.js +117 -0
  282. package/dist/esm/start/platform/data/dispatch.d.ts +17 -0
  283. package/dist/esm/start/platform/data/dispatch.js +216 -0
  284. package/dist/esm/start/platform/data/fetch.d.ts +7 -0
  285. package/dist/esm/start/platform/data/fetch.js +9 -0
  286. package/dist/esm/start/platform/data/index.d.ts +27 -0
  287. package/dist/esm/start/platform/data/index.js +75 -0
  288. package/dist/esm/start/platform/data/names.d.ts +7 -0
  289. package/dist/esm/start/platform/data/names.js +18 -0
  290. package/dist/esm/start/platform/data/sqlNameMappings.d.ts +58 -0
  291. package/dist/esm/start/platform/data/sqlNameMappings.js +92 -0
  292. package/dist/esm/start/platform/data/transformations.d.ts +97 -0
  293. package/dist/esm/start/platform/data/transformations.js +262 -0
  294. package/dist/esm/start/platform/data/types.d.ts +94 -0
  295. package/dist/esm/start/platform/data/types.js +14 -0
  296. package/dist/esm/start/platform/local.d.ts +6 -0
  297. package/dist/esm/start/platform/local.js +18 -0
  298. package/dist/esm/start/platform/meta.d.ts +3 -0
  299. package/dist/esm/start/platform/meta.js +33 -0
  300. package/dist/esm/start/platform/outbound.d.ts +17 -0
  301. package/dist/esm/start/platform/outbound.js +510 -0
  302. package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
  303. package/dist/esm/start/platform/redactSecrets.js +156 -0
  304. package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
  305. package/dist/esm/start/platform/redactSecrets.test.js +151 -0
  306. package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
  307. package/dist/esm/start/platform/requestSecrets.js +41 -0
  308. package/dist/esm/start/platform/runLog.d.ts +40 -0
  309. package/dist/esm/start/platform/runLog.js +149 -0
  310. package/dist/esm/start/platform/services.d.ts +7 -0
  311. package/dist/esm/start/platform/services.js +46 -0
  312. package/dist/esm/start/platform/steps.d.ts +9 -0
  313. package/dist/esm/start/platform/steps.js +60 -0
  314. package/dist/esm/start/platform/telemetry.d.ts +13 -0
  315. package/dist/esm/start/platform/telemetry.js +71 -0
  316. package/dist/esm/start/platform/transport.d.ts +28 -0
  317. package/dist/esm/start/platform/transport.js +59 -0
  318. package/dist/esm/start/platformHead.d.ts +23 -0
  319. package/dist/esm/start/platformHead.js +133 -0
  320. package/dist/esm/start/previewClaim.d.ts +6 -0
  321. package/dist/esm/start/previewClaim.js +24 -0
  322. package/dist/esm/start/protocol.d.ts +19 -0
  323. package/dist/esm/start/protocol.js +27 -0
  324. package/dist/esm/start/roles.d.ts +12 -0
  325. package/dist/esm/start/roles.js +27 -0
  326. package/dist/esm/start/router.d.ts +33 -6
  327. package/dist/esm/start/router.js +259 -16
  328. package/dist/esm/start/serve/authHooks.d.ts +7 -0
  329. package/dist/esm/start/serve/authHooks.js +18 -0
  330. package/dist/esm/start/serve/demo.d.ts +9 -0
  331. package/dist/esm/start/serve/demo.js +24 -0
  332. package/dist/esm/start/serve/fetch.d.ts +1 -0
  333. package/dist/esm/start/serve/fetch.js +6 -0
  334. package/dist/esm/start/{instance.d.ts → serve/instance.d.ts} +7 -7
  335. package/dist/esm/start/serve/instance.js +134 -0
  336. package/dist/esm/start/serve/invoke.d.ts +13 -0
  337. package/dist/esm/start/serve/invoke.js +126 -0
  338. package/dist/esm/start/serve/local/load.d.ts +8 -0
  339. package/dist/esm/start/serve/local/load.js +44 -0
  340. package/dist/esm/start/serve/local/provider.d.ts +25 -0
  341. package/dist/esm/start/serve/local/provider.js +188 -0
  342. package/dist/esm/start/serve/local/signIn.d.ts +28 -0
  343. package/dist/esm/start/serve/local/signIn.js +123 -0
  344. package/dist/esm/start/serve/pageHead.d.ts +20 -0
  345. package/dist/esm/start/serve/pageHead.js +34 -0
  346. package/dist/esm/start/serve/provider.d.ts +19 -0
  347. package/dist/esm/start/serve/provider.js +78 -0
  348. package/dist/esm/start/serve/requestEnv.d.ts +2 -0
  349. package/dist/esm/start/serve/requestEnv.js +84 -0
  350. package/dist/esm/start/serve/scope.d.ts +18 -0
  351. package/dist/esm/start/serve/scope.js +67 -0
  352. package/dist/esm/start/serve/server.d.ts +56 -0
  353. package/dist/esm/start/serve/server.js +297 -0
  354. package/dist/esm/start/serve/uploads.d.ts +2 -0
  355. package/dist/esm/start/serve/uploads.js +49 -0
  356. package/dist/esm/start/serve/worker.d.ts +6 -0
  357. package/dist/esm/start/serve/worker.js +12 -0
  358. package/dist/esm/start/types.d.ts +316 -24
  359. package/dist/esm/start/version.d.ts +1 -0
  360. package/dist/esm/start/version.js +2 -0
  361. package/dist/esm/steps/index.d.ts +78 -0
  362. package/dist/esm/steps/index.js +502 -0
  363. package/dist/esm/steps/index.test.d.ts +1 -0
  364. package/dist/esm/steps/index.test.js +633 -0
  365. package/dist/esm/sync/index.d.ts +1 -1
  366. package/dist/esm/sync/index.js +32 -31
  367. package/dist/esm/sync/lib.d.ts +15 -8
  368. package/dist/esm/sync/lib.js +664 -667
  369. package/dist/esm/sync/lib.test.js +177 -46
  370. package/dist/esm/sync/sdkNames.d.ts +67 -9
  371. package/dist/esm/sync/sdkNames.js +94 -30
  372. package/dist/esm/sync/sdkNames.test.js +192 -116
  373. package/dist/esm/types/fields.d.ts +9 -2
  374. package/dist/esm/types/fields.js +110 -96
  375. package/dist/esm/types/index.d.ts +2 -2
  376. package/dist/esm/types/index.js +2 -2
  377. package/dist/esm/types/tables.d.ts +17 -1
  378. package/dist/esm/types/tables.js +2 -2
  379. package/dist/esm/upload/index.js +89 -24
  380. package/dist/esm/upload/index.test.js +104 -1
  381. package/dist/esm/vite/domTagNames.js +252 -252
  382. package/dist/esm/vite/index.d.ts +1 -1
  383. package/dist/esm/vite/index.js +56 -47
  384. package/dist/esm/vite/index.test.js +10 -2
  385. package/package.json +111 -40
  386. package/dist/cjs/auth-server/index.d.ts +0 -369
  387. package/dist/cjs/auth-server/index.js +0 -119
  388. package/dist/cjs/start/problems.d.ts +0 -19
  389. package/dist/cjs/start/problems.js +0 -11
  390. package/dist/esm/auth-server/index.d.ts +0 -369
  391. package/dist/esm/auth-server/index.js +0 -116
  392. package/dist/esm/start/describe.d.ts +0 -56
  393. package/dist/esm/start/describe.js +0 -147
  394. package/dist/esm/start/describeBuilt.js +0 -66
  395. package/dist/esm/start/entries.js +0 -82
  396. package/dist/esm/start/instance.js +0 -73
  397. package/dist/esm/start/problems.d.ts +0 -19
  398. package/dist/esm/start/problems.js +0 -8
  399. package/dist/esm/start/runLog.d.ts +0 -5
  400. package/dist/esm/start/runLog.js +0 -18
  401. package/dist/esm/start/scope.d.ts +0 -15
  402. package/dist/esm/start/scope.js +0 -58
  403. package/dist/esm/start/server.d.ts +0 -37
  404. package/dist/esm/start/server.js +0 -159
  405. package/dist/esm/start/vite.d.ts +0 -9
  406. package/dist/esm/start/vite.js +0 -143
  407. package/dist/esm/start/workflow.d.ts +0 -36
  408. package/dist/esm/start/workflow.js +0 -13
  409. package/dist/esm/start/workflow.test-d.js +0 -24
  410. package/dist/esm/start/workflowRun.d.ts +0 -80
  411. package/dist/esm/start/workflowRun.js +0 -107
  412. /package/dist/{esm/start/workflow.test-d.d.ts → cjs/runtime/sendEmailParamsTypes.test-d.d.ts} +0 -0
  413. /package/dist/esm/start/{workflowModules.d.ts → build/placeholders/workflowModules.d.ts} +0 -0
  414. /package/dist/esm/start/{descriptions.d.ts → describe/descriptions.d.ts} +0 -0
@@ -0,0 +1,151 @@
1
+ // Classic's cases (restly shared/src/redactSecrets.test.ts), for the port beside it.
2
+ import { describe, it, expect } from 'vitest';
3
+ import { redactSecrets, REDACTED } from './redactSecrets.js';
4
+ describe('redactSecrets', () => {
5
+ describe('keeps the surrounding message', () => {
6
+ it('redacts a connection string password but keeps scheme, user and host', () => {
7
+ expect(redactSecrets('Failed to sync roster: postgres://svc:hunter2@db.internal:5432/prod')).toBe(`Failed to sync roster: postgres://svc:${REDACTED}@db.internal:5432/prod`);
8
+ });
9
+ it('leaves the sentence readable around a redacted key', () => {
10
+ expect(redactSecrets('Stripe rejected the charge (key sk_live_abcdefghijklmnop1234) — retry later')).toBe(`Stripe rejected the charge (key ${REDACTED}) — retry later`);
11
+ });
12
+ it('does not swallow text following a key=value pair', () => {
13
+ expect(redactSecrets('config invalid: api_key=abc123def456, region=us-west-2')).toBe(`config invalid: api_key=${REDACTED}, region=us-west-2`);
14
+ });
15
+ });
16
+ describe('credential formats', () => {
17
+ it('redacts bearer tokens', () => {
18
+ expect(redactSecrets('Authorization: Bearer abcdef1234567890XYZ')).toBe(`Authorization: Bearer ${REDACTED}`);
19
+ });
20
+ it('redacts a short opaque bearer token', () => {
21
+ // RFC 6750 token68 permits values this short, so shape decides, not length.
22
+ expect(redactSecrets('Authorization: Bearer abc123')).toBe(`Authorization: Bearer ${REDACTED}`);
23
+ });
24
+ it('redacts short Basic credentials, which base64 makes legitimately tiny', () => {
25
+ // base64("u:pw") — four characters.
26
+ expect(redactSecrets('Authorization: Basic dTpw')).toBe(`Authorization: Basic ${REDACTED}`);
27
+ expect(redactSecrets('basic YWI6Y2Q=')).toBe(`basic ${REDACTED}`);
28
+ });
29
+ it('redacts a full-length Basic credential', () => {
30
+ expect(redactSecrets('Basic YWxhZGRpbjpvcGVuc2VzYW1l')).toBe(`Basic ${REDACTED}`);
31
+ });
32
+ it('redacts JWTs', () => {
33
+ const jwt = 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dQw4w9WgXcQ';
34
+ expect(redactSecrets(`token rejected: ${jwt}`)).toBe(`token rejected: ${REDACTED}`);
35
+ });
36
+ it('redacts OpenAI and Anthropic style keys', () => {
37
+ expect(redactSecrets('sk-ant-api03-abcdefghijklmnopqrstuv')).toBe(REDACTED);
38
+ expect(redactSecrets('sk-abcdefghijklmnopqrstuvwxyz')).toBe(REDACTED);
39
+ });
40
+ it('redacts AWS access key ids and Google API keys', () => {
41
+ expect(redactSecrets('using AKIAIOSFODNN7EXAMPLE for s3')).toBe(`using ${REDACTED} for s3`);
42
+ expect(redactSecrets('key AIzaSyA1234567890abcdefghijklmnopqrstuvw rejected')).toBe(`key ${REDACTED} rejected`);
43
+ });
44
+ it('redacts GitHub and Slack tokens', () => {
45
+ expect(redactSecrets('ghp_abcdefghijklmnopqrstuvwxyz0123456789')).toBe(REDACTED);
46
+ expect(redactSecrets('xoxb-1234567890-abcdefghij')).toBe(REDACTED);
47
+ });
48
+ it('redacts credential key/value pairs in either separator style', () => {
49
+ expect(redactSecrets('password: hunter2')).toBe(`password: ${REDACTED}`);
50
+ expect(redactSecrets('client_secret=s3cr3tvalue')).toBe(`client_secret=${REDACTED}`);
51
+ });
52
+ it('redacts the secret in a URL-encoded token exchange body', () => {
53
+ expect(redactSecrets('grant_type=client_credentials&client_id=3MVG9abc&client_secret=8F2A1B9C')).toBe(`grant_type=client_credentials&client_id=3MVG9abc&client_secret=${REDACTED}`);
54
+ });
55
+ it('redacts credential members of a JSON body, keeping the rest', () => {
56
+ expect(redactSecrets('{"client_id":"3MVG9abc","client_secret":"8F2A1B9C","grant_type":"client_credentials"}')).toBe(`{"client_id":"3MVG9abc","client_secret":"${REDACTED}","grant_type":"client_credentials"}`);
57
+ expect(redactSecrets('{"refreshToken": "a\\"b", "page": 2}')).toBe(`{"refreshToken": "${REDACTED}", "page": 2}`);
58
+ });
59
+ it('redacts credential members of JSON serialized inside a JSON string', () => {
60
+ expect(redactSecrets(String.raw `{"body":"{\"client_secret\":\"8F2A1B9C\",\"grant_type\":\"client_credentials\"}"}`)).toBe(String.raw `{"body":"{\"client_secret\":\"${REDACTED}\",\"grant_type\":\"client_credentials\"}"}`);
61
+ expect(redactSecrets(String.raw `{\"password\":\"a\\\"b\\\\\",\"page\":2}`)).toBe(String.raw `{\"password\":\"${REDACTED}\",\"page\":2}`);
62
+ });
63
+ it('redacts a key at the start of a line in a multi-line message', () => {
64
+ expect(redactSecrets('connection failed\napi_key=abc123def456')).toBe(`connection failed\napi_key=${REDACTED}`);
65
+ });
66
+ it('redacts every occurrence, not just the first', () => {
67
+ expect(redactSecrets('api_key=aaa111 and api_key=bbb222')).toBe(`api_key=${REDACTED} and api_key=${REDACTED}`);
68
+ });
69
+ });
70
+ describe('leaves app-authored prose alone', () => {
71
+ it('does not touch an ordinary user-facing message', () => {
72
+ const message = 'CAPACITY EXCEEDED: The following week(s) are now full: Week #11. Please select different weeks or join the waitlist.';
73
+ expect(redactSecrets(message)).toBe(message);
74
+ });
75
+ it('does not touch a parseable frontend signal', () => {
76
+ const message = 'CLOTHES_CHANGE_PENDING:recSHyUztFA6rF5UA';
77
+ expect(redactSecrets(message)).toBe(message);
78
+ });
79
+ it('does not redact prose that merely mentions a password', () => {
80
+ const message = 'Your password must be at least 8 characters long.';
81
+ expect(redactSecrets(message)).toBe(message);
82
+ });
83
+ it('does not redact the word "Bearer" without a token-shaped value', () => {
84
+ const message = 'Include a Bearer token in the Authorization header.';
85
+ expect(redactSecrets(message)).toBe(message);
86
+ });
87
+ it('does not redact "Basic" followed by an ordinary word', () => {
88
+ // The reason the Basic matcher guards on shape rather than length: a
89
+ // subscription app's own copy reads exactly like a short credential.
90
+ for (const message of [
91
+ 'Your Basic plan does not include this feature.',
92
+ 'Basic tier limits reached.',
93
+ 'Basic Auth is required for this endpoint.',
94
+ 'Upgrade from Basic Plan to continue.',
95
+ ]) {
96
+ expect(redactSecrets(message)).toBe(message);
97
+ }
98
+ });
99
+ it('does not redact a Stripe publishable key, which is meant to be public', () => {
100
+ const message = 'pk_live_abcdefghijklmnop1234 is not a secret key';
101
+ expect(redactSecrets(message)).toBe(message);
102
+ });
103
+ it('does not treat a URL with a port as userinfo', () => {
104
+ const message = 'GET https://api.example.com:8443/v1/records failed';
105
+ expect(redactSecrets(message)).toBe(message);
106
+ });
107
+ it('does not match a credential key embedded in a longer name', () => {
108
+ // "reset_password_url" ends in "password" but names a link, not a secret.
109
+ const message = 'reset_password_url=https://example.org/reset';
110
+ expect(redactSecrets(message)).toBe(message);
111
+ const json = '{"reset_password_url":"https://example.org/reset"}';
112
+ expect(redactSecrets(json)).toBe(json);
113
+ });
114
+ it('returns short or empty input untouched', () => {
115
+ expect(redactSecrets('')).toBe('');
116
+ expect(redactSecrets('nope')).toBe('nope');
117
+ });
118
+ });
119
+ describe('repeated use', () => {
120
+ it('is stable across calls despite module-level global regexes', () => {
121
+ const message = 'api_key=abc123def456';
122
+ const first = redactSecrets(message);
123
+ const second = redactSecrets(message);
124
+ expect(first).toBe(second);
125
+ expect(first).toBe(`api_key=${REDACTED}`);
126
+ });
127
+ it('is idempotent', () => {
128
+ const once = redactSecrets('postgres://svc:hunter2@db.internal/prod');
129
+ expect(redactSecrets(once)).toBe(once);
130
+ });
131
+ });
132
+ describe('large input', () => {
133
+ // It runs synchronously on raw sandbox output, so anything worse than
134
+ // linear blocks the event loop long enough to fail health checks. Both
135
+ // inputs took several seconds at this size before the patterns were capped.
136
+ it.each([
137
+ ['an unbroken alphanumeric run', 'aB3dE9fG1h'],
138
+ ['a run of -eyJ fragments', '-eyJabcdefgh'],
139
+ ])('stays fast on %s', (_, unit) => {
140
+ const text = unit.repeat(10_000);
141
+ const started = performance.now();
142
+ expect(redactSecrets(text)).toBe(text);
143
+ expect(performance.now() - started).toBeLessThan(2000);
144
+ });
145
+ it('still redacts a long scheme and a JWT after the caps', () => {
146
+ expect(redactSecrets('averyveryveryveryveryveryverylongscheme://svc:hunter2@db.internal')).toBe(`averyveryveryveryveryveryverylongscheme://svc:${REDACTED}@db.internal`);
147
+ const jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U';
148
+ expect(redactSecrets(`x-${jwt}`)).toBe(`x-${REDACTED}`);
149
+ });
150
+ });
151
+ });
@@ -0,0 +1,15 @@
1
+ import type { HostRequestState } from '../types.js';
2
+ /** Shorter values (a region, a flag) aren't tokens, and could match by chance. */
3
+ export declare const MIN_TOKEN_LENGTH = 8;
4
+ /** The backend's stand-in for Zite's own AI key, naming the connection a call bills to. Nowhere is it a key. */
5
+ export declare const GATEWAY_MARKER: RegExp;
6
+ /**
7
+ * The secret values a request was handed: each connection's fields but its status and base URL, and its env vars. A
8
+ * connection's own URL (an instance, an account) says which call failed; a user's secret may be a URL.
9
+ */
10
+ export declare const handedSecrets: (host: Pick<HostRequestState, "env" | "envConnections">, connections: Iterable<unknown>) => string[];
11
+ /**
12
+ * What a visitor's error is redacted of: only what this request was handed, the connections the host sent and the
13
+ * ones its code asked for, and its env vars, longest first. Never another request's.
14
+ */
15
+ export declare const requestSecrets: (host: HostRequestState | undefined) => string[];
@@ -0,0 +1,41 @@
1
+ /** Shorter values (a region, a flag) aren't tokens, and could match by chance. */
2
+ export const MIN_TOKEN_LENGTH = 8;
3
+ /** The backend's stand-in for Zite's own AI key, naming the connection a call bills to. Nowhere is it a key. */
4
+ export const GATEWAY_MARKER = /^zite_gateway:[a-z]+:(.+)$/;
5
+ const isUrl = (value) => /^https?:\/\//i.test(value);
6
+ /**
7
+ * The secret values a request was handed: each connection's fields but its status and base URL, and its env vars. A
8
+ * connection's own URL (an instance, an account) says which call failed; a user's secret may be a URL.
9
+ */
10
+ export const handedSecrets = (host, connections) => {
11
+ const values = [];
12
+ const add = (value, urls) => {
13
+ if (typeof value !== 'string' ||
14
+ value.length < MIN_TOKEN_LENGTH ||
15
+ GATEWAY_MARKER.test(value))
16
+ return;
17
+ if (urls || !isUrl(value))
18
+ values.push(value);
19
+ };
20
+ for (const connection of connections) {
21
+ for (const [field, value] of Object.entries((connection ?? {}))) {
22
+ if (field !== 'status' && field !== 'baseUrl')
23
+ add(value, false);
24
+ }
25
+ }
26
+ for (const [key, value] of Object.entries(host.env ?? {}))
27
+ add(value, !host.envConnections?.[key]);
28
+ return values;
29
+ };
30
+ /**
31
+ * What a visitor's error is redacted of: only what this request was handed, the connections the host sent and the
32
+ * ones its code asked for, and its env vars, longest first. Never another request's.
33
+ */
34
+ export const requestSecrets = (host) => host
35
+ ? [
36
+ ...new Set(handedSecrets(host, [
37
+ ...Object.values(host.connections ?? {}),
38
+ ...(host.connectionAnswers?.values() ?? []),
39
+ ])),
40
+ ].sort((a, b) => b.length - a.length)
41
+ : [];
@@ -0,0 +1,40 @@
1
+ import type { CallRecord, HostRequestState, PlatformCallInput, PlatformCallResult, RunRecord } from '../types.js';
2
+ export declare const preview: (value: unknown) => string | undefined;
3
+ export declare const errorOf: (error: unknown) => NonNullable<RunRecord["error"]>;
4
+ /** Which call: what the run log names it by. */
5
+ export type CallKey = Pick<CallRecord, 'integrationId' | 'className' | 'methodName'>;
6
+ /** What a call answered, or why it failed. */
7
+ export type CallOutcome = {
8
+ value: unknown;
9
+ } | {
10
+ error: {
11
+ code: string;
12
+ message: string;
13
+ };
14
+ };
15
+ /** A call's record for the run log, from when it started. `outputs` previews what it answered. */
16
+ export declare const callRecord: (key: CallKey, params: unknown, at: number, outcome: CallOutcome, outputs?: (value: unknown) => string | undefined) => CallRecord;
17
+ /** Runs one of the app's platform calls and keeps its record, a failure included, for the request's run detail. */
18
+ export declare function recordCall<T>(host: HostRequestState, key: CallKey, params: unknown, run: () => Promise<T>): Promise<T>;
19
+ /** A call answered in the app, kept for the run's detail, which goes with the response's. A `note` stands for its error. */
20
+ export declare const notedCall: (host: HostRequestState, input: PlatformCallInput, result: PlatformCallResult, { outputs, note, }?: {
21
+ outputs?: (value: unknown) => string | undefined;
22
+ note?: string;
23
+ }) => PlatformCallResult;
24
+ /** A platform call that failed on our side: logged, and answered as nothing the app can act on. */
25
+ export declare const somethingWentWrong: (host: HostRequestState, input: PlatformCallInput, error: unknown) => PlatformCallResult;
26
+ /** A call that left the app for a service, failures included, reported for its run as it ends. */
27
+ export declare const reportedCall: (host: HostRequestState, input: PlatformCallInput, run: () => Promise<PlatformCallResult>) => Promise<PlatformCallResult>;
28
+ /** How a run ended, as the run log keeps it. */
29
+ export declare const ranTo: (outcome: {
30
+ output: unknown;
31
+ } | {
32
+ error: unknown;
33
+ }) => Pick<RunRecord, "output" | "error">;
34
+ /** One run of app code for the request's run log, timed from `startedAt` to now. */
35
+ export declare const recordRun: (host: HostRequestState | undefined, run: Omit<RunRecord, "durationMs">, endedAt?: number) => void;
36
+ /**
37
+ * A server route's run, which run capture doesn't see: its body in, and its status and body out. The bodies are
38
+ * read from copies after the fact, so the response never waits; the run log waits for them before it flushes.
39
+ */
40
+ export declare function recordRoute<T>(host: HostRequestState | undefined, request: Request, run: () => Promise<T>): Promise<T>;
@@ -0,0 +1,149 @@
1
+ import { asZiteError } from '../errors.js';
2
+ import { textUpTo } from './caps.js';
3
+ import { sendRunReport } from './telemetry.js';
4
+ // Classic's per-field cap. The host caps again; this keeps a large value from crossing at all.
5
+ const RUN_FIELD_LIMIT = 50 * 1024;
6
+ const capped = (text) => text.length > RUN_FIELD_LIMIT ? `${text.slice(0, RUN_FIELD_LIMIT)}…` : text;
7
+ export const preview = (value) => {
8
+ if (value === undefined)
9
+ return undefined;
10
+ if (typeof value === 'object' &&
11
+ value !== null &&
12
+ Symbol.asyncIterator in value)
13
+ return '[stream]';
14
+ try {
15
+ const json = JSON.stringify(value);
16
+ return json === undefined ? undefined : capped(json);
17
+ }
18
+ catch {
19
+ return '[unserializable]';
20
+ }
21
+ };
22
+ export const errorOf = (error) => ({
23
+ code: asZiteError(error)?.code ?? 'INTERNAL_ERROR',
24
+ message: error instanceof Error ? error.message : String(error),
25
+ ...(error instanceof Error && error.stack
26
+ ? { stack: capped(error.stack) }
27
+ : {}),
28
+ });
29
+ /** A call's record for the run log, from when it started. `outputs` previews what it answered. */
30
+ export const callRecord = (key, params, at, outcome, outputs = preview) => ({
31
+ integrationId: key.integrationId,
32
+ className: key.className,
33
+ methodName: key.methodName,
34
+ at,
35
+ durationMs: Date.now() - at,
36
+ inputs: preview(params),
37
+ ...('value' in outcome
38
+ ? { outputs: outputs(outcome.value) }
39
+ : { error: { code: outcome.error.code, message: outcome.error.message } }),
40
+ });
41
+ /** Runs one of the app's platform calls and keeps its record, a failure included, for the request's run detail. */
42
+ export async function recordCall(host, key, params, run) {
43
+ const at = Date.now();
44
+ const keep = (outcome) => (host.calls ??= []).push(callRecord(key, params, at, outcome));
45
+ try {
46
+ const value = await run();
47
+ keep({ value });
48
+ return value;
49
+ }
50
+ catch (error) {
51
+ keep({ error: errorOf(error) });
52
+ throw error;
53
+ }
54
+ }
55
+ /** A call answered in the app, kept for the run's detail, which goes with the response's. A `note` stands for its error. */
56
+ export const notedCall = (host, input, result, { outputs = preview, note, } = {}) => {
57
+ const outcome = 'value' in result || note === undefined
58
+ ? result
59
+ : { error: { ...result.error, message: note } };
60
+ (host.calls ??= []).push(callRecord(input, input.params, Date.now(), outcome, outputs));
61
+ return result;
62
+ };
63
+ /** A platform call that failed on our side: logged, and answered as nothing the app can act on. */
64
+ export const somethingWentWrong = (host, input, error) => {
65
+ console.error('[zite] platform call failed', {
66
+ requestId: host.requestId,
67
+ call: `${input.className}.${input.methodName}`,
68
+ error: errorOf(error).message,
69
+ });
70
+ return { error: { code: 'INTERNAL_ERROR', message: 'Something went wrong' } };
71
+ };
72
+ // Sent as the call ends rather than with the response's flush, which a request past its deadline never reaches.
73
+ // `local` has no run log to send it to.
74
+ const report = (host, record) => {
75
+ if (host.provider?.kind === 'local') {
76
+ (host.calls ??= []).push(record);
77
+ return;
78
+ }
79
+ const sent = sendRunReport(host, { runs: [], calls: [record] }).catch((error) => console.error("[zite] couldn't record a platform call", error));
80
+ host.waitUntil?.(sent);
81
+ };
82
+ /** A call that left the app for a service, failures included, reported for its run as it ends. */
83
+ export const reportedCall = async (host, input, run) => {
84
+ const at = Date.now();
85
+ const result = await run().catch((error) => somethingWentWrong(host, input, error));
86
+ report(host, callRecord(input, input.params, at, result));
87
+ return result;
88
+ };
89
+ /** How a run ended, as the run log keeps it. */
90
+ export const ranTo = (outcome) => 'error' in outcome
91
+ ? { error: errorOf(outcome.error) }
92
+ : { output: preview(outcome.output) };
93
+ /** One run of app code for the request's run log, timed from `startedAt` to now. */
94
+ export const recordRun = (host, run, endedAt = Date.now()) => {
95
+ host?.runs.push({ ...run, durationMs: endedAt - run.startedAt });
96
+ };
97
+ const TEXT_BODY = /^(application\/(json|x-www-form-urlencoded)|text\/(?!event-stream))/i;
98
+ // Up to the cap of a copy of the body, so the app still reads the original. Uploads and streams aren't read.
99
+ const bodyText = async (message) => {
100
+ if (!message.body ||
101
+ !TEXT_BODY.test(message.headers.get('content-type') ?? ''))
102
+ return undefined;
103
+ const text = await textUpTo(message.clone(), RUN_FIELD_LIMIT, {
104
+ truncate: true,
105
+ });
106
+ return text === undefined ? undefined : capped(text);
107
+ };
108
+ /**
109
+ * A server route's run, which run capture doesn't see: its body in, and its status and body out. The bodies are
110
+ * read from copies after the fact, so the response never waits; the run log waits for them before it flushes.
111
+ */
112
+ export async function recordRoute(host, request, run) {
113
+ if (!host)
114
+ return run();
115
+ const startedAt = Date.now();
116
+ const path = new URL(request.url).pathname;
117
+ const input = bodyText(request).catch(() => undefined);
118
+ const record = (outcome) => {
119
+ const endedAt = Date.now();
120
+ const recorded = (async () => {
121
+ const fields = { input: await input, ...(await outcome) };
122
+ recordRun(host, {
123
+ fn: `route:${request.method} ${path}`,
124
+ name: path,
125
+ nested: false,
126
+ startedAt,
127
+ ...fields,
128
+ }, endedAt);
129
+ })();
130
+ (host.pending ??= []).push(recorded.catch(() => { }));
131
+ };
132
+ try {
133
+ const out = await run();
134
+ const response = out instanceof Response
135
+ ? out
136
+ : out?.response;
137
+ if (response instanceof Response) {
138
+ record(bodyText(response).then(body => ({ output: preview({ status: response.status, body }) }), () => ({})));
139
+ }
140
+ else {
141
+ record(Promise.resolve({}));
142
+ }
143
+ return out;
144
+ }
145
+ catch (error) {
146
+ record(Promise.resolve(ranTo({ error })));
147
+ throw error;
148
+ }
149
+ }
@@ -0,0 +1,7 @@
1
+ import type { HostRequestState, PlatformCallInput, PlatformCallResult } from '../types.js';
2
+ export type Service = 'email' | 'pdf' | 'schedules';
3
+ /**
4
+ * One service call, reported for the run as it ends. As classic answers a demo: email pretends to succeed and
5
+ * schedules, which would queue runs on the author's live app, are refused.
6
+ */
7
+ export declare const serviceCall: (host: HostRequestState, input: PlatformCallInput, service: Service) => Promise<PlatformCallResult>;
@@ -0,0 +1,46 @@
1
+ // Email, PDFs and schedules on the request's token, each at the URL the platform names for it, answering as classic's
2
+ // do.
3
+ import { serviceUrl } from '../../internal/serviceUrls.js';
4
+ import { isZiteErrorCode } from '../errors.js';
5
+ import { reportedCall } from './runLog.js';
6
+ import { DEMO_REFUSED, PlatformError, requireAccess, sendOnToken, } from './transport.js';
7
+ // Attachments take up to 30 s each, and a render 30 s, as on classic.
8
+ const SERVICE_TIMEOUT_MS = 90_000;
9
+ const bodyOf = (host, { integrationId, methodName, params }, service) => service === 'email'
10
+ ? { integrationId, params, mode: host.mode }
11
+ : service === 'pdf'
12
+ ? { params }
13
+ : { methodName, params };
14
+ // A 4xx naming a ZiteError code, or any 400, says what the app got wrong, as its error; anything else is ours.
15
+ const send = async (access, service, body) => {
16
+ const response = await sendOnToken(access.token, serviceUrl(access.urls, service), {
17
+ method: 'POST',
18
+ body: JSON.stringify(body),
19
+ timeoutMs: SERVICE_TIMEOUT_MS,
20
+ });
21
+ const answer = (await response.json().catch(() => null));
22
+ const message = typeof answer?.error === 'string'
23
+ ? answer.error
24
+ : `The ${service === 'pdf' ? 'PDF' : service} call failed`;
25
+ if (response.status >= 400 &&
26
+ response.status < 500 &&
27
+ isZiteErrorCode(answer?.code))
28
+ return { error: { code: answer.code, message } };
29
+ if (response.status === 400)
30
+ return { error: { code: 'BAD_REQUEST', message } };
31
+ if (!response.ok)
32
+ throw new PlatformError(service, response.status);
33
+ return { value: answer };
34
+ };
35
+ /**
36
+ * One service call, reported for the run as it ends. As classic answers a demo: email pretends to succeed and
37
+ * schedules, which would queue runs on the author's live app, are refused.
38
+ */
39
+ export const serviceCall = async (host, input, service) => {
40
+ if (host.mode === 'demo' && service === 'email')
41
+ return { value: { success: true } };
42
+ if (host.mode === 'demo' && service === 'schedules')
43
+ return DEMO_REFUSED;
44
+ const access = await requireAccess(host);
45
+ return reportedCall(host, input, () => send(access, service, bodyOf(host, input, service)));
46
+ };
@@ -0,0 +1,9 @@
1
+ import type { HostRequestState } from '../types.js';
2
+ /** Where a run's step results are kept and read back. */
3
+ export type StepStore = {
4
+ /** Fails if the run can't save a step: checked before the first one runs, whose side effects would go unsaved. */
5
+ ready(): Promise<void>;
6
+ load(): Promise<Record<string, unknown>>;
7
+ persist(name: string, value: unknown, durationMs?: number): Promise<void>;
8
+ };
9
+ export declare const platformSteps: (host: HostRequestState | undefined) => StepStore;
@@ -0,0 +1,60 @@
1
+ // A workflow run's saved steps at the platform's steps service, on the request's token, which says the workflow and
2
+ // run. The step runtime calls these directly; they never cross the SDK transport.
3
+ import { serviceUrl } from '../../internal/serviceUrls.js';
4
+ import { STEP_RESULT_MAX_BYTES } from '../../steps/index.js';
5
+ import { ZiteError } from '../errors.js';
6
+ import { NoPlatformError, platformJson, requireAccess } from './transport.js';
7
+ const refused = (message) => new ZiteError('BAD_REQUEST', message);
8
+ export const platformSteps = (host) => {
9
+ const at = async () => {
10
+ if (!host)
11
+ throw refused('step.run runs only in a workflow');
12
+ const access = await requireAccess(host);
13
+ if (host.invoke?.kind !== 'workflow')
14
+ throw refused('step.run runs only in a workflow');
15
+ // Before any step's value leaves the app: with no workspace database there's nowhere to keep it.
16
+ if ((await host.provider?.context())?.baseId === null)
17
+ throw refused('Durable steps need the workspace database, and this app has none');
18
+ const url = serviceUrl(access.urls, 'steps');
19
+ // A failure on our side reaches the run as nothing it can act on; the log keeps why.
20
+ const send = async (method, body) => {
21
+ try {
22
+ return await platformJson(access, method, url, 'steps', body);
23
+ }
24
+ catch (error) {
25
+ if (error instanceof NoPlatformError)
26
+ throw error;
27
+ console.error("[zite] the run's saved steps failed", {
28
+ requestId: host.requestId,
29
+ error: error instanceof Error ? error.message : String(error),
30
+ });
31
+ throw new ZiteError('INTERNAL_ERROR', 'Something went wrong');
32
+ }
33
+ };
34
+ return { send, workflow: host.invoke.name };
35
+ };
36
+ return {
37
+ ready: async () => {
38
+ await at();
39
+ },
40
+ load: async () => (await (await at()).send('GET'))
41
+ .memos,
42
+ persist: async (name, value, durationMs) => {
43
+ const { send, workflow } = await at();
44
+ if (name.length === 0 || name.length > 255)
45
+ throw refused('A step needs a name of 1 to 255 characters');
46
+ if (new TextEncoder().encode(JSON.stringify(value ?? null)).length >
47
+ STEP_RESULT_MAX_BYTES) {
48
+ throw refused(`step "${name}" returned more than ${STEP_RESULT_MAX_BYTES / 1024}KB`);
49
+ }
50
+ await send('POST', {
51
+ workflow,
52
+ name,
53
+ value: value ?? null,
54
+ ...(durationMs !== undefined &&
55
+ Number.isInteger(durationMs) &&
56
+ durationMs >= 0 && { durationMs }),
57
+ });
58
+ },
59
+ };
60
+ };
@@ -0,0 +1,13 @@
1
+ import type { CallRecord, FetchRecord, HostRequestState, RunRecord } from '../types.js';
2
+ export type RunReport = {
3
+ runs: RunRecord[];
4
+ calls?: CallRecord[];
5
+ fetches?: FetchRecord[];
6
+ };
7
+ /** The report in as few sends as fit under the runs service's limit, each record whole. */
8
+ export declare const reportSends: (report: RunReport) => RunReport[];
9
+ /**
10
+ * One report of the request's run; the caller keeps it going past the response with `waitUntil`. A request the host
11
+ * dispatched without a runs URL or a token has nowhere to send it, which the throw says.
12
+ */
13
+ export declare const sendRunReport: (host: HostRequestState, report: RunReport) => Promise<void>;
@@ -0,0 +1,71 @@
1
+ // What a request reports of its own run: what ran, the platform calls it made and its outbound fetches with what its
2
+ // own AI keys used. On the app token to the platform's runs service, which stamps the org, app and request from the
3
+ // token, never from the report. `local` keeps none: only the platform writes a run's row, and a dev token names no
4
+ // request of its own.
5
+ import { sendOnToken } from './transport.js';
6
+ // Half of what the runs service reads in one send; each record is capped far below it.
7
+ const MAX_SEND_BYTES = 512 * 1024;
8
+ const RUNS_TIMEOUT_MS = 10_000;
9
+ const encoder = new TextEncoder();
10
+ const emptySend = () => ({ runs: [], calls: [], fetches: [] });
11
+ const asReport = ({ runs, calls, fetches }) => ({
12
+ runs,
13
+ ...(calls.length > 0 && { calls }),
14
+ ...(fetches.length > 0 && { fetches }),
15
+ });
16
+ /** The report in as few sends as fit under the runs service's limit, each record whole. */
17
+ export const reportSends = (report) => {
18
+ const sends = [];
19
+ let send = emptySend();
20
+ let bytes = 0;
21
+ const place = (record, add) => {
22
+ const size = encoder.encode(JSON.stringify(record)).byteLength;
23
+ if (bytes > 0 && bytes + size > MAX_SEND_BYTES) {
24
+ sends.push(asReport(send));
25
+ send = emptySend();
26
+ bytes = 0;
27
+ }
28
+ add(send);
29
+ bytes += size;
30
+ };
31
+ for (const run of report.runs)
32
+ place(run, into => into.runs.push(run));
33
+ for (const call of report.calls ?? [])
34
+ place(call, into => into.calls.push(call));
35
+ for (const fetched of report.fetches ?? [])
36
+ place(fetched, into => into.fetches.push(fetched));
37
+ if (bytes > 0)
38
+ sends.push(asReport(send));
39
+ return sends;
40
+ };
41
+ const toRunsService = async (host, runs, token, report) => {
42
+ const answers = await Promise.all(reportSends(report).map(send => sendOnToken(token, `${runs}/ingest`, {
43
+ method: 'POST',
44
+ body: JSON.stringify({
45
+ kind: 'events',
46
+ ...send,
47
+ // Names the integration call events its fetches become.
48
+ ...(send.fetches?.length &&
49
+ host.connectionServices && { services: host.connectionServices }),
50
+ }),
51
+ timeoutMs: RUNS_TIMEOUT_MS,
52
+ })));
53
+ const refused = answers.find(answer => !answer.ok);
54
+ await Promise.all(answers.map(answer => answer.body?.cancel()));
55
+ if (refused)
56
+ throw new Error(`the runs service answered ${refused.status}`);
57
+ };
58
+ /**
59
+ * One report of the request's run; the caller keeps it going past the response with `waitUntil`. A request the host
60
+ * dispatched without a runs URL or a token has nowhere to send it, which the throw says.
61
+ */
62
+ export const sendRunReport = async (host, report) => {
63
+ const { provider } = host;
64
+ if (!provider || provider.kind === 'local')
65
+ return;
66
+ const runs = provider.urls?.runs;
67
+ const token = runs ? await provider.token() : undefined;
68
+ if (!runs || !token)
69
+ throw new Error("This request has no runs URL or app token to send its run's detail with");
70
+ return toRunsService(host, runs, token, report);
71
+ };
@@ -0,0 +1,28 @@
1
+ import type { HostRequestState, PlatformCallResult, PlatformUrls } from '../types.js';
2
+ export type DirectAccess = {
3
+ token: string;
4
+ urls: PlatformUrls;
5
+ };
6
+ export declare class PlatformError extends Error {
7
+ readonly route: string;
8
+ readonly status: number;
9
+ constructor(route: string, status: number);
10
+ }
11
+ /** Thrown for a platform call on a request that has no token or no platform URLs. */
12
+ export declare class NoPlatformError extends Error {
13
+ constructor();
14
+ }
15
+ /** What a demo's call is refused with when it would act on the author's live app. */
16
+ export declare const DEMO_REFUSED: PlatformCallResult;
17
+ /** The request's token and where to send it, renewed first if it's about to expire; undefined without either. */
18
+ export declare const directAccess: (host: HostRequestState) => Promise<DirectAccess | undefined>;
19
+ /** As `directAccess`, failing loudly without a token or URLs. */
20
+ export declare const requireAccess: (host: HostRequestState) => Promise<DirectAccess>;
21
+ /** One request to the platform as JSON, on the token. */
22
+ export declare const sendOnToken: (token: string, url: string, init: {
23
+ method: string;
24
+ body?: string;
25
+ timeoutMs?: number;
26
+ }) => Promise<Response>;
27
+ export declare const platformJson: <T>(access: DirectAccess, method: string, url: string, route: string, body?: unknown) => Promise<T>;
28
+ export declare const backendJson: <T>(access: DirectAccess, method: string, path: string, body?: unknown) => Promise<T>;