zitejs 0.10.0-start.9 → 0.10.1-device.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 (448) hide show
  1. package/dist/cjs/auth/actions.d.ts +28 -0
  2. package/dist/cjs/auth/actions.js +95 -0
  3. package/dist/cjs/auth/client.d.ts +357 -0
  4. package/dist/cjs/auth/client.js +71 -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/auth/useAuth.test.js +1 -0
  14. package/dist/cjs/backend/index.d.ts +15 -9
  15. package/dist/cjs/backend/index.js +13 -13
  16. package/dist/cjs/backend/index.test.js +102 -102
  17. package/dist/cjs/bundle/index.d.ts +8 -0
  18. package/dist/cjs/bundle/index.js +38 -24
  19. package/dist/cjs/caller/index.js +37 -48
  20. package/dist/cjs/check/index.d.ts +20 -9
  21. package/dist/cjs/check/index.js +113 -88
  22. package/dist/cjs/check/start/routeTree.d.ts +8 -0
  23. package/dist/cjs/check/start/routeTree.js +118 -0
  24. package/dist/cjs/check/start/tsgo.d.ts +2 -0
  25. package/dist/cjs/check/start/tsgo.js +35 -0
  26. package/dist/cjs/cli.js +10 -4
  27. package/dist/cjs/client/index.d.ts +26 -2
  28. package/dist/cjs/client/index.js +25 -25
  29. package/dist/cjs/dev/index.js +79 -54
  30. package/dist/cjs/dev/signin.d.ts +16 -0
  31. package/dist/cjs/dev/signin.js +84 -0
  32. package/dist/cjs/index.d.ts +5 -5
  33. package/dist/cjs/integrations/client.d.ts +3 -3
  34. package/dist/cjs/integrations/client.js +5 -4
  35. package/dist/cjs/integrations/client.test-d.js +15 -15
  36. package/dist/cjs/integrations/index.d.ts +2 -2
  37. package/dist/cjs/integrations/rules.d.ts +1 -0
  38. package/dist/cjs/integrations/rules.js +48 -43
  39. package/dist/cjs/integrations/rules.test.js +60 -54
  40. package/dist/cjs/internal/appMode.d.ts +14 -0
  41. package/dist/cjs/internal/appMode.js +19 -0
  42. package/dist/cjs/internal/browserMode.d.ts +2 -0
  43. package/dist/cjs/internal/browserMode.js +18 -0
  44. package/dist/cjs/internal/deviceCache.d.ts +11 -0
  45. package/dist/cjs/internal/deviceCache.js +29 -0
  46. package/dist/cjs/internal/env.js +3 -2
  47. package/dist/cjs/internal/platformFetch.d.ts +2 -0
  48. package/dist/cjs/internal/platformFetch.js +14 -0
  49. package/dist/cjs/internal/reservedIds.d.ts +8 -0
  50. package/dist/cjs/internal/reservedIds.js +14 -0
  51. package/dist/cjs/internal/serviceUrls.d.ts +5 -0
  52. package/dist/cjs/internal/serviceUrls.js +14 -0
  53. package/dist/cjs/pdf/index.js +2 -1
  54. package/dist/cjs/query/deviceCache.d.ts +14 -0
  55. package/dist/cjs/query/deviceCache.js +304 -0
  56. package/dist/cjs/query/index.d.ts +19 -0
  57. package/dist/cjs/query/index.js +369 -0
  58. package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
  59. package/dist/cjs/runtime/index.d.ts +126 -39
  60. package/dist/cjs/runtime/index.js +32 -26
  61. package/dist/cjs/runtime/index.test.js +34 -34
  62. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +50 -0
  63. package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
  64. package/dist/cjs/sourceRoots.js +15 -15
  65. package/dist/cjs/sourceRoots.test.js +29 -27
  66. package/dist/cjs/start/{entries.d.ts → build/entries.d.ts} +9 -4
  67. package/dist/cjs/start/{entries.js → build/entries.js} +38 -21
  68. package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
  69. package/dist/cjs/start/build/placeholders/devApp.js +6 -0
  70. package/dist/cjs/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
  71. package/dist/cjs/start/{describeBuilt.js → describe/describeBuilt.js} +55 -17
  72. package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
  73. package/dist/cjs/start/platform/aiUsage.js +215 -0
  74. package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
  75. package/dist/cjs/start/platform/airtable/cache.js +93 -0
  76. package/dist/cjs/start/protocol.d.ts +19 -0
  77. package/dist/cjs/start/protocol.js +33 -0
  78. package/dist/cjs/start/serve/local/provider.d.ts +25 -0
  79. package/dist/cjs/start/serve/local/provider.js +196 -0
  80. package/dist/cjs/start/serve/provider.d.ts +19 -0
  81. package/dist/cjs/start/serve/provider.js +86 -0
  82. package/dist/cjs/start/types.d.ts +373 -0
  83. package/dist/cjs/start/types.js +2 -0
  84. package/dist/cjs/steps/index.d.ts +78 -0
  85. package/dist/cjs/steps/index.js +507 -0
  86. package/dist/cjs/steps/index.test.js +635 -0
  87. package/dist/cjs/sync/index.d.ts +1 -1
  88. package/dist/cjs/sync/index.js +28 -27
  89. package/dist/cjs/sync/lib.d.ts +15 -8
  90. package/dist/cjs/sync/lib.js +655 -655
  91. package/dist/cjs/sync/lib.test.js +177 -46
  92. package/dist/cjs/sync/sdkNames.d.ts +67 -9
  93. package/dist/cjs/sync/sdkNames.js +97 -31
  94. package/dist/cjs/sync/sdkNames.test.js +189 -113
  95. package/dist/cjs/types/fields.d.ts +9 -2
  96. package/dist/cjs/types/fields.js +110 -96
  97. package/dist/cjs/types/index.d.ts +2 -2
  98. package/dist/cjs/types/tables.d.ts +17 -1
  99. package/dist/cjs/upload/index.js +89 -24
  100. package/dist/cjs/upload/index.test.js +104 -1
  101. package/dist/cjs/vite/domTagNames.js +252 -252
  102. package/dist/cjs/vite/index.d.ts +1 -1
  103. package/dist/cjs/vite/index.js +87 -42
  104. package/dist/cjs/vite/index.test.js +36 -0
  105. package/dist/esm/auth/actions.d.ts +28 -0
  106. package/dist/esm/auth/actions.js +57 -0
  107. package/dist/esm/auth/client.d.ts +357 -0
  108. package/dist/esm/auth/client.js +67 -0
  109. package/dist/esm/auth/config.js +9 -3
  110. package/dist/esm/auth/index.d.ts +2 -249
  111. package/dist/esm/auth/index.js +2 -103
  112. package/dist/esm/auth/index.test.js +60 -0
  113. package/dist/esm/auth/previewClaim.d.ts +7 -0
  114. package/dist/esm/auth/previewClaim.js +12 -0
  115. package/dist/esm/auth/profileUpdates.d.ts +9 -0
  116. package/dist/esm/auth/profileUpdates.js +6 -0
  117. package/dist/esm/auth/useAuth.test.js +1 -0
  118. package/dist/esm/backend/index.d.ts +15 -9
  119. package/dist/esm/backend/index.js +13 -13
  120. package/dist/esm/backend/index.test.js +106 -106
  121. package/dist/esm/bundle/index.d.ts +8 -0
  122. package/dist/esm/bundle/index.js +37 -24
  123. package/dist/esm/caller/index.js +37 -48
  124. package/dist/esm/check/index.d.ts +20 -9
  125. package/dist/esm/check/index.js +117 -93
  126. package/dist/esm/check/start/routeTree.d.ts +8 -0
  127. package/dist/esm/check/start/routeTree.js +77 -0
  128. package/dist/esm/check/start/tsgo.d.ts +2 -0
  129. package/dist/esm/check/start/tsgo.js +29 -0
  130. package/dist/esm/cli.js +10 -4
  131. package/dist/esm/client/index.d.ts +26 -2
  132. package/dist/esm/client/index.js +25 -25
  133. package/dist/esm/dev/index.js +86 -61
  134. package/dist/esm/dev/signin.d.ts +16 -0
  135. package/dist/esm/dev/signin.js +80 -0
  136. package/dist/esm/index.d.ts +5 -5
  137. package/dist/esm/index.js +3 -3
  138. package/dist/esm/integrations/client.d.ts +3 -3
  139. package/dist/esm/integrations/client.js +6 -5
  140. package/dist/esm/integrations/client.test-d.js +19 -19
  141. package/dist/esm/integrations/index.d.ts +2 -2
  142. package/dist/esm/integrations/index.js +1 -1
  143. package/dist/esm/integrations/rules.d.ts +1 -0
  144. package/dist/esm/integrations/rules.js +48 -43
  145. package/dist/esm/integrations/rules.test.js +62 -56
  146. package/dist/esm/internal/appMode.d.ts +14 -0
  147. package/dist/esm/internal/appMode.js +13 -0
  148. package/dist/esm/internal/browserMode.d.ts +2 -0
  149. package/dist/esm/internal/browserMode.js +15 -0
  150. package/dist/esm/internal/deviceCache.d.ts +11 -0
  151. package/dist/esm/internal/deviceCache.js +24 -0
  152. package/dist/esm/internal/env.js +3 -2
  153. package/dist/esm/internal/platformFetch.d.ts +2 -0
  154. package/dist/esm/internal/platformFetch.js +9 -0
  155. package/dist/esm/internal/reservedIds.d.ts +8 -0
  156. package/dist/esm/internal/reservedIds.js +10 -0
  157. package/dist/esm/internal/serviceUrls.d.ts +5 -0
  158. package/dist/esm/internal/serviceUrls.js +10 -0
  159. package/dist/esm/pdf/index.js +2 -1
  160. package/dist/esm/query/deviceCache.d.ts +14 -0
  161. package/dist/esm/query/deviceCache.js +301 -0
  162. package/dist/esm/query/index.d.ts +19 -0
  163. package/dist/esm/query/index.js +366 -0
  164. package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
  165. package/dist/esm/runtime/index.d.ts +126 -39
  166. package/dist/esm/runtime/index.js +35 -29
  167. package/dist/esm/runtime/index.test.js +36 -36
  168. package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
  169. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +48 -0
  170. package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
  171. package/dist/esm/signin/conformance.d.ts +100 -0
  172. package/dist/esm/signin/conformance.js +616 -0
  173. package/dist/esm/signin/cookies.d.ts +28 -0
  174. package/dist/esm/signin/cookies.js +67 -0
  175. package/dist/esm/signin/encoding.d.ts +1 -0
  176. package/dist/esm/signin/encoding.js +12 -0
  177. package/dist/esm/signin/endpoints.d.ts +12 -0
  178. package/dist/esm/signin/endpoints.js +32 -0
  179. package/dist/esm/signin/http.d.ts +25 -0
  180. package/dist/esm/signin/http.js +106 -0
  181. package/dist/esm/signin/index.d.ts +8 -0
  182. package/dist/esm/signin/index.js +9 -0
  183. package/dist/esm/signin/keys.d.ts +35 -0
  184. package/dist/esm/signin/keys.js +230 -0
  185. package/dist/esm/signin/paths.d.ts +2 -0
  186. package/dist/esm/signin/paths.js +5 -0
  187. package/dist/esm/signin/seal.d.ts +19 -0
  188. package/dist/esm/signin/seal.js +47 -0
  189. package/dist/esm/signin/signin.d.ts +60 -0
  190. package/dist/esm/signin/signin.js +447 -0
  191. package/dist/esm/signin/transport.d.ts +112 -0
  192. package/dist/esm/signin/transport.js +1 -0
  193. package/dist/esm/signin/verifier.d.ts +2 -0
  194. package/dist/esm/signin/verifier.js +4 -0
  195. package/dist/esm/signin/verify.d.ts +83 -0
  196. package/dist/esm/signin/verify.js +142 -0
  197. package/dist/esm/sourceRoots.js +17 -17
  198. package/dist/esm/sourceRoots.test.js +34 -32
  199. package/dist/esm/start/access.d.ts +19 -0
  200. package/dist/esm/start/access.js +43 -0
  201. package/dist/esm/start/auth.d.ts +28 -0
  202. package/dist/esm/start/auth.js +33 -0
  203. package/dist/esm/start/automations/quiet.d.ts +2 -0
  204. package/dist/esm/start/automations/quiet.js +36 -0
  205. package/dist/esm/start/{registration.d.ts → automations/registration.d.ts} +1 -1
  206. package/dist/esm/start/{registration.js → automations/registration.js} +11 -7
  207. package/dist/esm/start/automations/steps.d.ts +29 -0
  208. package/dist/esm/start/automations/steps.js +95 -0
  209. package/dist/esm/start/automations/workflow.d.ts +83 -0
  210. package/dist/esm/start/automations/workflow.js +36 -0
  211. package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
  212. package/dist/esm/start/automations/workflow.test-d.js +130 -0
  213. package/dist/esm/start/automations/workflowRun.d.ts +130 -0
  214. package/dist/esm/start/automations/workflowRun.js +185 -0
  215. package/dist/esm/start/barrel.test-d.d.ts +10 -0
  216. package/dist/esm/start/barrel.test-d.js +6 -0
  217. package/dist/esm/start/{entries.d.ts → build/entries.d.ts} +9 -4
  218. package/dist/esm/start/{entries.js → build/entries.js} +38 -22
  219. package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
  220. package/dist/esm/start/build/placeholders/devApp.js +3 -0
  221. package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
  222. package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
  223. package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
  224. package/dist/esm/start/build/placeholders/siteHead.js +3 -0
  225. package/dist/esm/start/{workflowModules.js → build/placeholders/workflowModules.js} +1 -1
  226. package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
  227. package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
  228. package/dist/esm/start/build/registrationHash.d.ts +11 -0
  229. package/dist/esm/start/build/registrationHash.js +88 -0
  230. package/dist/esm/start/build/sdk/axios.d.ts +76 -0
  231. package/dist/esm/start/build/sdk/axios.js +253 -0
  232. package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
  233. package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
  234. package/dist/esm/start/build/sdk/undici.d.ts +34 -0
  235. package/dist/esm/start/build/sdk/undici.js +18 -0
  236. package/dist/esm/start/build/sdkPatches.d.ts +22 -0
  237. package/dist/esm/start/build/sdkPatches.js +430 -0
  238. package/dist/esm/start/build/siteHead.d.ts +26 -0
  239. package/dist/esm/start/build/siteHead.js +88 -0
  240. package/dist/esm/start/build/vite.d.ts +50 -0
  241. package/dist/esm/start/build/vite.js +491 -0
  242. package/dist/esm/start/classicOnly.d.ts +1 -0
  243. package/dist/esm/start/classicOnly.js +4 -0
  244. package/dist/esm/start/{describe.d.ts → describe/describe.d.ts} +44 -9
  245. package/dist/esm/start/describe/describe.js +372 -0
  246. package/dist/esm/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
  247. package/dist/esm/start/describe/describeBuilt.js +102 -0
  248. package/dist/esm/start/{descriptions.js → describe/descriptions.js} +17 -10
  249. package/dist/esm/start/errors.d.ts +15 -4
  250. package/dist/esm/start/errors.js +87 -28
  251. package/dist/esm/start/errors.test.js +47 -16
  252. package/dist/esm/start/factories.d.ts +14 -0
  253. package/dist/esm/start/factories.js +23 -0
  254. package/dist/esm/start/factories.test-d.d.ts +2 -1
  255. package/dist/esm/start/factories.test-d.js +52 -12
  256. package/dist/esm/start/failures.d.ts +7 -0
  257. package/dist/esm/start/failures.js +62 -0
  258. package/dist/esm/start/fnFactory.d.ts +16 -0
  259. package/dist/esm/start/fnFactory.js +1 -0
  260. package/dist/esm/start/host.d.ts +2 -2
  261. package/dist/esm/start/host.js +3 -3
  262. package/dist/esm/start/index.d.ts +10 -66
  263. package/dist/esm/start/index.js +7 -146
  264. package/dist/esm/start/login.d.ts +5 -0
  265. package/dist/esm/start/login.js +29 -0
  266. package/dist/esm/start/middlewareKind.d.ts +13 -0
  267. package/dist/esm/start/middlewareKind.js +9 -0
  268. package/dist/esm/start/platform/aiUsage.d.ts +29 -0
  269. package/dist/esm/start/platform/aiUsage.js +210 -0
  270. package/dist/esm/start/platform/airtable/built.d.ts +2 -0
  271. package/dist/esm/start/platform/airtable/built.js +3 -0
  272. package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
  273. package/dist/esm/start/platform/airtable/cache.js +89 -0
  274. package/dist/esm/start/{airtable → platform/airtable}/dispatch.d.ts +5 -2
  275. package/dist/esm/start/{airtable → platform/airtable}/dispatch.js +195 -119
  276. package/dist/esm/start/{airtable → platform/airtable}/formulas.d.ts +2 -1
  277. package/dist/esm/start/{airtable → platform/airtable}/formulas.js +51 -25
  278. package/dist/esm/start/platform/airtable/index.d.ts +6 -0
  279. package/dist/esm/start/platform/airtable/index.js +51 -0
  280. package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
  281. package/dist/esm/start/platform/airtable/settings.js +138 -0
  282. package/dist/esm/start/platform/analytics.d.ts +3 -0
  283. package/dist/esm/start/platform/analytics.js +59 -0
  284. package/dist/esm/start/platform/calls.d.ts +5 -0
  285. package/dist/esm/start/platform/calls.js +104 -0
  286. package/dist/esm/start/platform/caps.d.ts +9 -0
  287. package/dist/esm/start/platform/caps.js +35 -0
  288. package/dist/esm/start/platform/connections.d.ts +25 -0
  289. package/dist/esm/start/platform/connections.js +198 -0
  290. package/dist/esm/start/{data → platform/data}/baseRunner.d.ts +11 -6
  291. package/dist/esm/start/platform/data/baseRunner.js +117 -0
  292. package/dist/esm/start/{data → platform/data}/dispatch.d.ts +3 -2
  293. package/dist/esm/start/{data → platform/data}/dispatch.js +69 -51
  294. package/dist/esm/start/platform/data/fetch.d.ts +7 -0
  295. package/dist/esm/start/platform/data/fetch.js +9 -0
  296. package/dist/esm/start/platform/data/index.d.ts +27 -0
  297. package/dist/esm/start/platform/data/index.js +75 -0
  298. package/dist/esm/start/platform/data/names.d.ts +7 -0
  299. package/dist/esm/start/platform/data/names.js +18 -0
  300. package/dist/esm/start/{data → platform/data}/transformations.d.ts +0 -31
  301. package/dist/esm/start/{data → platform/data}/transformations.js +0 -56
  302. package/dist/esm/start/{data → platform/data}/types.d.ts +4 -1
  303. package/dist/esm/start/{data → platform/data}/types.js +2 -2
  304. package/dist/esm/start/platform/local.d.ts +6 -0
  305. package/dist/esm/start/platform/local.js +18 -0
  306. package/dist/esm/start/platform/meta.d.ts +3 -0
  307. package/dist/esm/start/platform/meta.js +33 -0
  308. package/dist/esm/start/platform/outbound.d.ts +17 -0
  309. package/dist/esm/start/platform/outbound.js +510 -0
  310. package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
  311. package/dist/esm/start/{redactSecrets.js → platform/redactSecrets.js} +32 -7
  312. package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
  313. package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
  314. package/dist/esm/start/platform/requestSecrets.js +41 -0
  315. package/dist/esm/start/platform/runLog.d.ts +40 -0
  316. package/dist/esm/start/platform/runLog.js +149 -0
  317. package/dist/esm/start/platform/services.d.ts +7 -0
  318. package/dist/esm/start/platform/services.js +46 -0
  319. package/dist/esm/start/platform/steps.d.ts +9 -0
  320. package/dist/esm/start/platform/steps.js +60 -0
  321. package/dist/esm/start/platform/telemetry.d.ts +13 -0
  322. package/dist/esm/start/platform/telemetry.js +71 -0
  323. package/dist/esm/start/platform/transport.d.ts +28 -0
  324. package/dist/esm/start/platform/transport.js +59 -0
  325. package/dist/esm/start/platformHead.d.ts +23 -0
  326. package/dist/esm/start/platformHead.js +133 -0
  327. package/dist/esm/start/previewClaim.d.ts +3 -7
  328. package/dist/esm/start/previewClaim.js +9 -17
  329. package/dist/esm/start/protocol.d.ts +19 -0
  330. package/dist/esm/start/protocol.js +27 -0
  331. package/dist/esm/start/roles.d.ts +12 -0
  332. package/dist/esm/start/roles.js +27 -0
  333. package/dist/esm/start/router.d.ts +27 -4
  334. package/dist/esm/start/router.js +221 -22
  335. package/dist/esm/start/serve/authHooks.js +18 -0
  336. package/dist/esm/start/serve/demo.d.ts +9 -0
  337. package/dist/esm/start/serve/demo.js +24 -0
  338. package/dist/esm/start/serve/fetch.d.ts +1 -0
  339. package/dist/esm/start/serve/fetch.js +6 -0
  340. package/dist/esm/start/{instance.d.ts → serve/instance.d.ts} +6 -5
  341. package/dist/esm/start/serve/instance.js +134 -0
  342. package/dist/esm/start/serve/invoke.d.ts +13 -0
  343. package/dist/esm/start/serve/invoke.js +126 -0
  344. package/dist/esm/start/serve/local/load.d.ts +8 -0
  345. package/dist/esm/start/serve/local/load.js +44 -0
  346. package/dist/esm/start/serve/local/provider.d.ts +25 -0
  347. package/dist/esm/start/serve/local/provider.js +188 -0
  348. package/dist/esm/start/serve/local/signIn.d.ts +28 -0
  349. package/dist/esm/start/serve/local/signIn.js +123 -0
  350. package/dist/esm/start/serve/pageHead.d.ts +20 -0
  351. package/dist/esm/start/serve/pageHead.js +34 -0
  352. package/dist/esm/start/serve/provider.d.ts +19 -0
  353. package/dist/esm/start/serve/provider.js +78 -0
  354. package/dist/esm/start/serve/requestEnv.d.ts +2 -0
  355. package/dist/esm/start/serve/requestEnv.js +84 -0
  356. package/dist/esm/start/serve/scope.d.ts +18 -0
  357. package/dist/esm/start/serve/scope.js +67 -0
  358. package/dist/esm/start/serve/server.d.ts +56 -0
  359. package/dist/esm/start/serve/server.js +297 -0
  360. package/dist/esm/start/serve/uploads.d.ts +2 -0
  361. package/dist/esm/start/serve/uploads.js +49 -0
  362. package/dist/esm/start/serve/worker.d.ts +6 -0
  363. package/dist/esm/start/serve/worker.js +12 -0
  364. package/dist/esm/start/types.d.ts +270 -56
  365. package/dist/esm/start/version.d.ts +1 -1
  366. package/dist/esm/start/version.js +1 -1
  367. package/dist/esm/steps/index.d.ts +78 -0
  368. package/dist/esm/steps/index.js +502 -0
  369. package/dist/esm/steps/index.test.d.ts +1 -0
  370. package/dist/esm/steps/index.test.js +633 -0
  371. package/dist/esm/sync/index.d.ts +1 -1
  372. package/dist/esm/sync/index.js +32 -31
  373. package/dist/esm/sync/lib.d.ts +15 -8
  374. package/dist/esm/sync/lib.js +659 -659
  375. package/dist/esm/sync/lib.test.js +177 -46
  376. package/dist/esm/sync/sdkNames.d.ts +67 -9
  377. package/dist/esm/sync/sdkNames.js +94 -30
  378. package/dist/esm/sync/sdkNames.test.js +192 -116
  379. package/dist/esm/types/fields.d.ts +9 -2
  380. package/dist/esm/types/fields.js +110 -96
  381. package/dist/esm/types/index.d.ts +2 -2
  382. package/dist/esm/types/index.js +2 -2
  383. package/dist/esm/types/tables.d.ts +17 -1
  384. package/dist/esm/types/tables.js +2 -2
  385. package/dist/esm/upload/index.js +89 -24
  386. package/dist/esm/upload/index.test.js +104 -1
  387. package/dist/esm/vite/domTagNames.js +252 -252
  388. package/dist/esm/vite/index.d.ts +1 -1
  389. package/dist/esm/vite/index.js +92 -47
  390. package/dist/esm/vite/index.test.js +36 -0
  391. package/package.json +106 -38
  392. package/dist/cjs/auth-server/index.d.ts +0 -369
  393. package/dist/cjs/auth-server/index.js +0 -119
  394. package/dist/cjs/check/start/describeRules.d.ts +0 -35
  395. package/dist/cjs/check/start/describeRules.js +0 -89
  396. package/dist/cjs/check/start/problem.d.ts +0 -11
  397. package/dist/cjs/check/start/problem.js +0 -5
  398. package/dist/cjs/check/start/sourceRules.d.ts +0 -3
  399. package/dist/cjs/check/start/sourceRules.js +0 -441
  400. package/dist/cjs/start/problems.d.ts +0 -19
  401. package/dist/cjs/start/problems.js +0 -11
  402. package/dist/esm/auth-server/index.d.ts +0 -369
  403. package/dist/esm/auth-server/index.js +0 -116
  404. package/dist/esm/check/start/describeRules.d.ts +0 -35
  405. package/dist/esm/check/start/describeRules.js +0 -86
  406. package/dist/esm/check/start/problem.d.ts +0 -11
  407. package/dist/esm/check/start/problem.js +0 -1
  408. package/dist/esm/check/start/sourceRules.d.ts +0 -3
  409. package/dist/esm/check/start/sourceRules.js +0 -438
  410. package/dist/esm/start/airtable/index.d.ts +0 -11
  411. package/dist/esm/start/airtable/index.js +0 -70
  412. package/dist/esm/start/authHooks.js +0 -10
  413. package/dist/esm/start/data/baseRunner.js +0 -83
  414. package/dist/esm/start/data/index.d.ts +0 -18
  415. package/dist/esm/start/data/index.js +0 -76
  416. package/dist/esm/start/describe.js +0 -204
  417. package/dist/esm/start/describeBuilt.js +0 -66
  418. package/dist/esm/start/instance.js +0 -80
  419. package/dist/esm/start/problems.d.ts +0 -19
  420. package/dist/esm/start/problems.js +0 -8
  421. package/dist/esm/start/redactSecrets.d.ts +0 -7
  422. package/dist/esm/start/runLog.d.ts +0 -8
  423. package/dist/esm/start/runLog.js +0 -76
  424. package/dist/esm/start/scope.d.ts +0 -15
  425. package/dist/esm/start/scope.js +0 -58
  426. package/dist/esm/start/server.d.ts +0 -55
  427. package/dist/esm/start/server.js +0 -317
  428. package/dist/esm/start/vite.d.ts +0 -9
  429. package/dist/esm/start/vite.js +0 -173
  430. package/dist/esm/start/worker.d.ts +0 -11
  431. package/dist/esm/start/worker.js +0 -20
  432. package/dist/esm/start/workflow.d.ts +0 -53
  433. package/dist/esm/start/workflow.js +0 -13
  434. package/dist/esm/start/workflow.test-d.js +0 -44
  435. package/dist/esm/start/workflowRun.d.ts +0 -80
  436. package/dist/esm/start/workflowRun.js +0 -108
  437. /package/dist/{esm/start/redactSecrets.test.d.ts → cjs/runtime/sendEmailParamsTypes.test-d.d.ts} +0 -0
  438. /package/dist/{esm/start/workflow.test-d.d.ts → cjs/steps/index.test.d.ts} +0 -0
  439. /package/dist/esm/start/{authHooksModule.d.ts → build/placeholders/authHooksModule.d.ts} +0 -0
  440. /package/dist/esm/start/{authHooksModule.js → build/placeholders/authHooksModule.js} +0 -0
  441. /package/dist/esm/start/{workflowModules.d.ts → build/placeholders/workflowModules.d.ts} +0 -0
  442. /package/dist/esm/start/{descriptions.d.ts → describe/descriptions.d.ts} +0 -0
  443. /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.d.ts +0 -0
  444. /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.js +0 -0
  445. /package/dist/esm/start/{data → platform/data}/sqlNameMappings.d.ts +0 -0
  446. /package/dist/esm/start/{data → platform/data}/sqlNameMappings.js +0 -0
  447. /package/dist/esm/start/{redactSecrets.test.js → platform/redactSecrets.test.js} +0 -0
  448. /package/dist/esm/start/{authHooks.d.ts → serve/authHooks.d.ts} +0 -0
@@ -1,55 +0,0 @@
1
- import type { HostProps, PlatformBinding, RenderWatch, ZiteRequestContext } from "./types.js";
2
- export { runWithHost } from "./scope.js";
3
- export { describeApp } from "./describe.js";
4
- export type { HostProps, PlatformBinding, PlatformCallInput, PlatformCallResult, PlatformSession, RenderWatch, RunRecord } from "./types.js";
5
- /**
6
- * Routes every zitejs data, integration and email call to this request's
7
- * platform, on one session, and only inside an access scope. The access kind
8
- * travels with the call so the platform can record what a page read and narrow
9
- * anonymous reads.
10
- */
11
- export declare function installPlatformTransport(): void;
12
- /** What the host dispatched this request with. Headers are ignored: props are the only thing it alone can set. */
13
- export declare function hostContextFromProps(request: Request, props: HostProps): ZiteRequestContext;
14
- /**
15
- * A request the host didn't dispatch: the host's warm-up, `zitejs describe` under `vite preview`, and tests. Only the
16
- * host can set props, so without them a build answers warm and describe and nobody is signed in. An entry that passes
17
- * its own platform (tests, local dev) owns its requests and may say who is calling in `x-zite-*` headers.
18
- */
19
- export declare function hostContextFromRequest(request: Request, platform?: PlatformBinding): ZiteRequestContext;
20
- /** Every server function TanStack compiled, written in by `zite()` at build. Empty in dev, where TanStack doesn't call its id hook. */
21
- export declare const builtFunctionIds: () => string[];
22
- /** Each server function's `description` option, written in by `zite()` at build. */
23
- export declare const builtFunctionDescriptions: () => Record<string, string>;
24
- /** Each route's file, by route id, written in by `zite()` at build. */
25
- export declare const builtRouteFiles: () => Record<string, string>;
26
- type Fetch = (request: Request, ...rest: unknown[]) => Promise<Response> | Response;
27
- type WorkerContext = {
28
- waitUntil(promise: Promise<unknown>): void;
29
- };
30
- /** On describe's answer: the zitejs this build's server code was bundled from. */
31
- export declare const RUNTIME_VERSION_HEADER = "x-zitejs-version";
32
- export type ZiteServerOptions = {
33
- handler: {
34
- fetch: Fetch;
35
- };
36
- getRouter: () => unknown;
37
- platform?: PlatformBinding;
38
- };
39
- type HostedContext = WorkerContext & {
40
- props?: Partial<HostProps>;
41
- };
42
- export type ZiteHandlers = {
43
- fetch: Fetch;
44
- /** A page the host may cache: as `fetch`, with every read and outbound fetch reported to `watch`. */
45
- render(request: Request, ctx: HostedContext, watch: RenderWatch): Promise<Response>;
46
- };
47
- /**
48
- * The handlers of a Start app's server entry. A request the host dispatched
49
- * carries its identity and platform in props; anything else (describe under
50
- * `vite preview`, tests) reads `x-zite-*` headers and uses `platform` if one
51
- * is given.
52
- */
53
- export declare function createZiteHandlers(options: ZiteServerOptions): ZiteHandlers;
54
- /** The fetch handler alone, for entries that take no RPC. */
55
- export declare function createZiteFetch(options: ZiteServerOptions): Fetch;
@@ -1,317 +0,0 @@
1
- import { asZiteError, isZiteErrorCode, ZiteError, ZITE_ERROR_STATUS } from "./errors.js";
2
- import { describeApp } from "./describe.js";
3
- import { runRegistration } from "./registration.js";
4
- import { isAuthHookName, loadAuthHooks } from "./authHooks.js";
5
- import { errorOf, preview } from "./runLog.js";
6
- import { DATA_INTEGRATION_ID, dataContextOf, runDataCall } from "./data/index.js";
7
- import { airtableSettingsOf, runAirtableCall } from "./airtable/index.js";
8
- import { getHost, requireScope, runInScope, runWithHost } from "./scope.js";
9
- import { ZITEJS_VERSION } from "./version.js";
10
- import { loadWorkflows, loggedInput, runWorkflow } from "./workflowRun.js";
11
- export { runWithHost } from "./scope.js";
12
- export { describeApp } from "./describe.js";
13
- /**
14
- * Routes every zitejs data, integration and email call to this request's
15
- * platform, on one session, and only inside an access scope. The access kind
16
- * travels with the call so the platform can record what a page read and narrow
17
- * anonymous reads.
18
- */
19
- export function installPlatformTransport() {
20
- const sdkCall = async (integrationId, className, methodName, params) => {
21
- const scope = requireScope(`${className}.${methodName}`);
22
- const host = getHost();
23
- // Fails closed: no platform means no platform access, never a fallback.
24
- if (!host?.platform)
25
- throw new Error("The Zite platform binding is missing");
26
- host.session ??= Promise.resolve(host.watch ? host.platform.session(host.watch) : host.platform.session());
27
- const session = await host.session;
28
- if (integrationId === DATA_INTEGRATION_ID) {
29
- const found = await dataContextOf(session);
30
- if (found) {
31
- return recordCall(host, { integrationId, className, methodName, params }, () => runDataCall(session, found, host.mode, methodName, params));
32
- }
33
- }
34
- else if (!integrationId.startsWith("__")) {
35
- const airtable = await airtableSettingsOf(session, integrationId);
36
- if (airtable) {
37
- return recordCall(host, { integrationId, className, methodName, params }, () => runAirtableCall(host, session, integrationId, airtable, methodName, params, scope.kind));
38
- }
39
- }
40
- const result = await session.call({ integrationId, className, methodName, params, access: scope.kind });
41
- if ("value" in result)
42
- return result.value;
43
- const { code, message, userFacingMessage } = result.error;
44
- throw new ZiteError({ code: isZiteErrorCode(code) ? code : "INTERNAL_ERROR", message, userFacingMessage });
45
- };
46
- globalThis.__wrapSdkCall = sdkCall;
47
- watchOutboundFetches();
48
- }
49
- /** A data call the app made itself, recorded as the host recorded the ones it made. */
50
- const recordCall = async (host, call, run) => {
51
- const at = Date.now();
52
- const record = {
53
- integrationId: call.integrationId,
54
- className: call.className,
55
- methodName: call.methodName,
56
- at,
57
- inputs: preview(call.params),
58
- };
59
- try {
60
- const value = await run();
61
- (host.calls ??= []).push({ ...record, durationMs: Date.now() - at, outputs: preview(value) });
62
- return value;
63
- }
64
- catch (error) {
65
- const { code, message } = errorOf(error);
66
- (host.calls ??= []).push({ ...record, durationMs: Date.now() - at, error: { code, message } });
67
- throw error;
68
- }
69
- };
70
- let fetchesWatched = false;
71
- const fetchedHost = (input) => {
72
- try {
73
- return new URL(input instanceof Request ? input.url : input).host;
74
- }
75
- catch {
76
- return "?";
77
- }
78
- };
79
- // A page that fetched depends on more than the reads the host saw, so the host
80
- // must hear of it before the fetch goes out. Next patches fetch for the same reason.
81
- const watchOutboundFetches = () => {
82
- if (fetchesWatched)
83
- return;
84
- fetchesWatched = true;
85
- const nativeFetch = globalThis.fetch.bind(globalThis);
86
- globalThis.fetch = async (input, init) => {
87
- const watch = getHost()?.watch;
88
- if (watch)
89
- await watch.uncacheable(`fetch ${fetchedHost(input)}`);
90
- return nativeFetch(input, init);
91
- };
92
- };
93
- const decodeUser = (value) => JSON.parse(new TextDecoder().decode(Uint8Array.from(atob(value.replace(/-/g, "+").replace(/_/g, "/")), (c) => c.charCodeAt(0))));
94
- const INVOKE_KINDS = new Set(["webhook", "describe", "workflow", "register", "warm", "authHook"]);
95
- // What a request without props may ask for: neither runs app code on anyone's behalf.
96
- const UNHOSTED_INVOKE_KINDS = new Set(["warm", "describe"]);
97
- /** What the host dispatched this request with. Headers are ignored: props are the only thing it alone can set. */
98
- export function hostContextFromProps(request, props) {
99
- return {
100
- requestId: props.requestId,
101
- url: request.url,
102
- user: props.user,
103
- mode: props.mode,
104
- invoke: props.invoke,
105
- appUrl: props.appUrl,
106
- baseId: props.baseId,
107
- previewClaim: props.previewClaim,
108
- env: props.env,
109
- runs: [],
110
- platform: props.platform,
111
- };
112
- }
113
- // Classic sets these per run. Node and workerd both refuse getters on process.env, so each request writes what the
114
- // host sent, which is the same for every request a build serves: the live URL even on a demo.
115
- // The connection vars the last request set, so one gone since (an integration removed) doesn't linger.
116
- let connectionEnvKeys = new Set();
117
- const setRequestEnv = ({ appUrl, baseId, env: connectionEnv }) => {
118
- const env = globalThis.process?.env;
119
- if (!env)
120
- return;
121
- if (appUrl)
122
- env.ZITE_APP_URL = appUrl;
123
- if (baseId)
124
- env.ZITE_BASE_ID = baseId;
125
- if (!connectionEnv)
126
- return;
127
- for (const key of connectionEnvKeys)
128
- if (!Object.hasOwn(connectionEnv, key))
129
- delete env[key];
130
- for (const [key, value] of Object.entries(connectionEnv)) {
131
- if (key.startsWith("ZITE_"))
132
- env[key] = value;
133
- }
134
- connectionEnvKeys = new Set(Object.keys(connectionEnv));
135
- };
136
- /**
137
- * A request the host didn't dispatch: the host's warm-up, `zitejs describe` under `vite preview`, and tests. Only the
138
- * host can set props, so without them a build answers warm and describe and nobody is signed in. An entry that passes
139
- * its own platform (tests, local dev) owns its requests and may say who is calling in `x-zite-*` headers.
140
- */
141
- export function hostContextFromRequest(request, platform) {
142
- const { headers } = request;
143
- const trusted = platform !== undefined;
144
- const user = trusted ? headers.get("x-zite-user") : null;
145
- const [kind, name = ""] = headers.get("x-zite-invoke")?.split(":") ?? [];
146
- const kinds = trusted ? INVOKE_KINDS : UNHOSTED_INVOKE_KINDS;
147
- return {
148
- requestId: (trusted && headers.get("x-zite-request-id")) || crypto.randomUUID(),
149
- url: request.url,
150
- user: user ? decodeUser(user) : null,
151
- mode: "live",
152
- invoke: kinds.has(kind) ? { kind: kind, name } : null,
153
- runs: [],
154
- platform,
155
- };
156
- }
157
- /** Every server function TanStack compiled, written in by `zite()` at build. Empty in dev, where TanStack doesn't call its id hook. */
158
- export const builtFunctionIds = () => "__ZITE_FN_IDS__".split(",").filter((id) => id && !id.startsWith("__ZITE"));
159
- const parseBuiltJson = (json) => {
160
- try {
161
- return JSON.parse(json);
162
- }
163
- catch {
164
- return {};
165
- }
166
- };
167
- /** Each server function's `description` option, written in by `zite()` at build. */
168
- export const builtFunctionDescriptions = () => parseBuiltJson("__ZITE_FN_DESCRIPTIONS__");
169
- /** Each route's file, by route id, written in by `zite()` at build. */
170
- export const builtRouteFiles = () => parseBuiltJson("__ZITE_ROUTE_FILES__");
171
- // Server functions also run while a streamed page renders, so the run log is
172
- // complete only once the body has been read to the end.
173
- const onBodyEnd = (response, done) => {
174
- if (!response.body) {
175
- done();
176
- return response;
177
- }
178
- return new Response(response.body.pipeThrough(new TransformStream({ flush: done })), response);
179
- };
180
- const INVOKE_PATH = "/_zite/invoke";
181
- /** On describe's answer: the zitejs this build's server code was bundled from. */
182
- export const RUNTIME_VERSION_HEADER = "x-zitejs-version";
183
- // The host sends `{ input }`; a platform-fired run's input carries the runner's
184
- // `__cron`, `__poll` or `__webhook` state, exactly as for classic endpoints.
185
- async function invokeWorkflow(request, host, workflows) {
186
- if (request.method !== "POST" || new URL(request.url).pathname !== INVOKE_PATH)
187
- return new Response("Not found", { status: 404 });
188
- const name = host.invoke?.name;
189
- const found = workflows.find((w) => w.id === name);
190
- if (!found)
191
- return Response.json({ ok: false, error: { code: "NOT_FOUND", message: `No workflow named ${name}` } }, { status: 404 });
192
- const input = (await request.json().catch(() => ({})))?.input;
193
- const startedAt = Date.now();
194
- const result = await runWorkflow(found.workflow, input);
195
- host.runs.push({
196
- fn: `workflow:${found.id}`,
197
- name: found.id,
198
- nested: false,
199
- startedAt,
200
- durationMs: Date.now() - startedAt,
201
- input: preview(loggedInput(input)),
202
- ...(result.ok ? { output: preview(result.output) } : { error: result.error }),
203
- });
204
- return Response.json(result, { status: result.ok ? 200 : 500 });
205
- }
206
- // The host sends `{ op, input }`: `subscribe` with the platform's notification
207
- // URL and secret, or `unsubscribe` with what `subscribe` returned.
208
- async function invokeRegistration(request, host, workflows) {
209
- if (request.method !== "POST" || new URL(request.url).pathname !== INVOKE_PATH)
210
- return new Response("Not found", { status: 404 });
211
- const name = host.invoke?.name ?? "";
212
- const body = (await request.json().catch(() => null));
213
- const result = await runRegistration(workflows, name, body?.op, body?.input);
214
- if (!result) {
215
- return Response.json({ ok: false, error: { code: "NOT_FOUND", message: `${name} has no ${String(body?.op)}` } }, { status: 404 });
216
- }
217
- return Response.json(result, { status: result.ok ? 200 : 500 });
218
- }
219
- // The host sends `{ input }`, the same fields classic hooks get. A hook runs as
220
- // a workflow does: no user, and the app's data and integrations through its platform.
221
- async function invokeAuthHook(request, host) {
222
- if (request.method !== "POST" || new URL(request.url).pathname !== INVOKE_PATH)
223
- return new Response("Not found", { status: 404 });
224
- const name = host.invoke?.name ?? "";
225
- const hook = isAuthHookName(name) ? (await loadAuthHooks())[name] : undefined;
226
- if (!hook) {
227
- return Response.json({ ok: false, error: { code: "NOT_FOUND", message: `No auth hook named ${name}` } }, { status: 404 });
228
- }
229
- const input = (await request.json().catch(() => ({})))?.input ?? {};
230
- const startedAt = Date.now();
231
- try {
232
- const output = await runInScope({ kind: "workflow", user: null }, () => hook(input));
233
- host.runs.push({ fn: `authHook:${name}`, name, nested: false, startedAt, durationMs: Date.now() - startedAt, input: preview(input), output: preview(output) });
234
- return Response.json({ ok: true, output: output ?? null });
235
- }
236
- catch (error) {
237
- const failed = errorOf(error);
238
- host.runs.push({ fn: `authHook:${name}`, name, nested: false, startedAt, durationMs: Date.now() - startedAt, input: preview(input), error: failed });
239
- return Response.json({ ok: false, error: failed }, { status: 500 });
240
- }
241
- }
242
- // TanStack renders any loader error as a 500. A page refused with a ZiteError
243
- // (a missing role, a record that isn't there) answers with that error's status.
244
- const pageStatus = (host) => {
245
- const matches = host.router?.state?.matches;
246
- const failed = asZiteError(matches?.find((match) => match.status === "error")?.error);
247
- return failed ? ZITE_ERROR_STATUS[failed.code] : undefined;
248
- };
249
- /**
250
- * The handlers of a Start app's server entry. A request the host dispatched
251
- * carries its identity and platform in props; anything else (describe under
252
- * `vite preview`, tests) reads `x-zite-*` headers and uses `platform` if one
253
- * is given.
254
- */
255
- export function createZiteHandlers(options) {
256
- installPlatformTransport();
257
- // Loaded on first use, so a page request never pays for importing workflow modules.
258
- let workflows;
259
- const loadedWorkflows = () => (workflows ??= loadWorkflows());
260
- const serve = async (request, ctx, watch) => {
261
- const host = ctx?.props?.platform
262
- ? hostContextFromProps(request, ctx.props)
263
- : hostContextFromRequest(request, options.platform);
264
- if (watch)
265
- host.watch = watch;
266
- setRequestEnv(host);
267
- // Starting this isolate was the point: the platform warms a build before its
268
- // first visitors, and no app code runs.
269
- if (host.invoke?.kind === "warm")
270
- return new Response(null, { status: 204 });
271
- if (host.invoke?.kind === "describe") {
272
- return Response.json(await describeApp({
273
- fnIds: builtFunctionIds(),
274
- descriptions: builtFunctionDescriptions(),
275
- routeFiles: builtRouteFiles(),
276
- getRouter: options.getRouter,
277
- request,
278
- workflows: await loadedWorkflows(),
279
- }), { headers: { [RUNTIME_VERSION_HEADER]: ZITEJS_VERSION } });
280
- }
281
- let response = await runWithHost(host, async () => host.invoke?.kind === "workflow"
282
- ? invokeWorkflow(request, host, await loadedWorkflows())
283
- : host.invoke?.kind === "register"
284
- ? invokeRegistration(request, host, await loadedWorkflows())
285
- : host.invoke?.kind === "authHook"
286
- ? invokeAuthHook(request, host)
287
- : options.handler.fetch(request));
288
- const status = response.status === 500 ? pageStatus(host) : undefined;
289
- if (status)
290
- response = new Response(response.body, { status, headers: response.headers });
291
- return onBodyEnd(response, () => {
292
- const { platform } = host;
293
- if ((!host.runs.length && !host.calls?.length && !host.pending?.length) || !platform)
294
- return;
295
- // On the request's session when it has one: one call, not another binding round trip.
296
- const flushed = (async () => {
297
- await Promise.all(host.pending ?? []);
298
- if (!host.runs.length && !host.calls?.length)
299
- return;
300
- const batch = { runs: host.runs, ...(host.calls?.length && { calls: host.calls }) };
301
- const session = host.session ? await host.session : undefined;
302
- await (session?.runs ? session.runs(batch) : platform.runs(batch));
303
- })().catch((error) => {
304
- console.error("[zite] couldn't record runs", error);
305
- });
306
- ctx?.waitUntil(flushed);
307
- });
308
- };
309
- return {
310
- fetch: (request, ...rest) => serve(request, rest[1]),
311
- render: (request, ctx, watch) => serve(request, ctx, watch),
312
- };
313
- }
314
- /** The fetch handler alone, for entries that take no RPC. */
315
- export function createZiteFetch(options) {
316
- return createZiteHandlers(options).fetch;
317
- }
@@ -1,9 +0,0 @@
1
- import type { PluginOption } from "vite";
2
- export type ZiteOptions = {
3
- /** A server entry the caller owns, relative to the app root. By default zite() writes the platform's. */
4
- serverEntry?: string;
5
- /** Build for Cloudflare Workers, the target the platform deploys. Defaults to true; false builds for Node. */
6
- cloudflare?: boolean;
7
- };
8
- /** The one plugin a Zite app's `vite.config.ts` uses. */
9
- export declare function zite(options?: ZiteOptions): PluginOption[];
@@ -1,173 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import path from "node:path";
3
- import { tanstackStart } from "@tanstack/react-start/plugin/vite";
4
- import viteReact from "@vitejs/plugin-react";
5
- import { ziteId } from "../vite/index.js";
6
- import { factoryDescriptions } from "./descriptions.js";
7
- import { hasAppStart, renderStartInstance, renderStartServerEntry, renderWorkflowModules, START_INSTANCE_ENTRY, START_SERVER_ENTRY, workflowFiles, writeIfChanged, } from "./entries.js";
8
- // Must match the literals in ./server.ts, which the build rewrites.
9
- const FN_IDS_TOKEN = "__ZITE_FN_IDS__";
10
- const FN_DESCRIPTIONS_LITERAL = /(["'`])__ZITE_FN_DESCRIPTIONS__\1/;
11
- const ROUTE_FILES_LITERAL = /(["'`])__ZITE_ROUTE_FILES__\1/;
12
- // TanStack's generator writes each route file's id into its createFileRoute call and keeps it in step.
13
- const FILE_ROUTE_ID = /\bcreateFileRoute\(\s*(["'`])([^"'`]+)\1\s*\)/;
14
- // zitejs's empty registry, which the build replaces with the app's.
15
- const WORKFLOW_REGISTRY = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]workflowModules\.js$/;
16
- // zitejs's null auth-hooks module, which the build points at the app's `zite.auth.ts`.
17
- const AUTH_HOOKS_REGISTRY = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]authHooksModule\.js$/;
18
- const AUTH_HOOKS_FILE = "zite.auth.ts";
19
- // Platform-pinned Worker settings. The deploy uses its own fixed template, so
20
- // these only have to match it; apps don't carry a wrangler config.
21
- const WORKER_COMPATIBILITY_DATE = "2026-09-25";
22
- const WORKER_COMPATIBILITY_FLAGS = ["nodejs_compat"];
23
- // Resolved from the app at build time; zitejs doesn't depend on it.
24
- const loadCloudflare = async (main) => {
25
- const { cloudflare } = (await import("@cloudflare/vite-plugin"));
26
- return cloudflare({
27
- viteEnvironment: { name: "ssr" },
28
- config: {
29
- name: "zite-app",
30
- main,
31
- compatibility_date: WORKER_COMPATIBILITY_DATE,
32
- compatibility_flags: WORKER_COMPATIBILITY_FLAGS,
33
- },
34
- });
35
- };
36
- /** The one plugin a Zite app's `vite.config.ts` uses. */
37
- export function zite(options = {}) {
38
- const serverEntry = options.serverEntry ?? START_SERVER_ENTRY;
39
- // Platform-owned, so they're rewritten whenever they differ. Sandboxes run the
40
- // image's zitejs for `generate`, which may predate Start; the plugin can't.
41
- const appDir = process.cwd();
42
- if (!options.serverEntry) {
43
- writeIfChanged(appDir, START_SERVER_ENTRY, renderStartServerEntry(options.cloudflare === false ? "node" : "cloudflare"));
44
- }
45
- writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)));
46
- // Every server function TanStack's compiler found, from its own hook, by id.
47
- const ids = new Map();
48
- const compileZitejs = {
49
- name: "zite:compile-zitejs",
50
- // The factories must go through TanStack's compiler in both environments.
51
- // The peer dependency gets zitejs crawled already; this keeps it true if an
52
- // install drops that. A Node build bundles everything, so externalized
53
- // libraries can't load the root's React 18 renderer.
54
- config: (config) => {
55
- const root = path.resolve(config.root ?? ".");
56
- const src = `${path.join(root, "src")}/`;
57
- return {
58
- ssr: { noExternal: options.cloudflare === false ? true : ["zitejs"] },
59
- optimizeDeps: { exclude: ["zitejs"] },
60
- resolve: {
61
- // `@/` as in classic apps and shadcn, `~/` as in TanStack's templates.
62
- alias: [
63
- { find: /^@\//, replacement: src },
64
- { find: /^~\//, replacement: src },
65
- // The workspace SDKs `zitejs generate` writes, as classic apps map them.
66
- { find: /^zitejs\/db$/, replacement: path.join(root, "../../.zite/db.ts") },
67
- { find: /^zitejs\/integrations$/, replacement: path.join(root, ".zite/integrations/index.ts") },
68
- { find: /^zitejs\/email$/, replacement: path.join(root, ".zite/integrations/email.ts") },
69
- { find: /^zitejs\/meta$/, replacement: path.join(root, ".zite/meta.ts") },
70
- ],
71
- // Shared workspace libraries resolve from the root, where classic apps
72
- // keep React 18; recharts 2 needs the app's react-is 19 or drops series.
73
- dedupe: ["react-is"],
74
- },
75
- };
76
- },
77
- // Each new isolate loads the whole server bundle, so its size is cold-start
78
- // time; Vite leaves SSR output unminified.
79
- configEnvironment: (name, config) => name === "ssr" && options.cloudflare !== false && config.build?.minify === undefined ? { build: { minify: true } } : undefined,
80
- };
81
- // Each server function's `description` option, by name, and each route's file, by route id: for the editor.
82
- const descriptions = new Map();
83
- const routeFiles = new Map();
84
- const srcDir = `${path.join(appDir, "src")}${path.sep}`;
85
- const functionIds = {
86
- name: "zite:function-ids",
87
- apply: "build",
88
- transform(code, id) {
89
- if (this.environment?.config.consumer !== "server" || !id.startsWith(srcDir))
90
- return;
91
- const file = id.split("?")[0];
92
- const routeId = FILE_ROUTE_ID.exec(code)?.[2];
93
- if (routeId && !id.includes("?"))
94
- routeFiles.set(routeId, path.relative(appDir, file).split(path.sep).join("/"));
95
- if (!code.includes("description"))
96
- return;
97
- try {
98
- for (const [name, text] of factoryDescriptions(this.parse(code)))
99
- descriptions.set(name, text);
100
- }
101
- catch {
102
- // Display-only: an unreadable module just shows no descriptions.
103
- }
104
- },
105
- generateBundle(_, bundle) {
106
- const described = Object.fromEntries([...descriptions].filter(([name]) => ids.has(name)));
107
- for (const chunk of Object.values(bundle)) {
108
- if (chunk.type !== "chunk")
109
- continue;
110
- if (chunk.code.includes(FN_IDS_TOKEN))
111
- chunk.code = chunk.code.replace(FN_IDS_TOKEN, [...ids.keys()].join(","));
112
- chunk.code = chunk.code
113
- .replace(FN_DESCRIPTIONS_LITERAL, () => JSON.stringify(JSON.stringify(described)))
114
- .replace(ROUTE_FILES_LITERAL, () => JSON.stringify(JSON.stringify(Object.fromEntries(routeFiles))));
115
- }
116
- },
117
- };
118
- const workflowRegistry = {
119
- name: "zite:workflow-registry",
120
- load: (id) => (WORKFLOW_REGISTRY.test(id.split("?")[0]) ? renderWorkflowModules(appDir, workflowFiles(appDir)) : undefined),
121
- };
122
- const authHooksRegistry = {
123
- name: "zite:auth-hooks",
124
- load: (id) => {
125
- if (!AUTH_HOOKS_REGISTRY.test(id.split("?")[0]))
126
- return undefined;
127
- const file = path.join(appDir, AUTH_HOOKS_FILE);
128
- return existsSync(file)
129
- ? `export const authHooksModule = () => import(${JSON.stringify(file)});\n`
130
- : "export const authHooksModule = null;\n";
131
- },
132
- };
133
- return [
134
- // First, so ids name lines in the source, before TanStack splits a route's component out of it.
135
- ziteId(),
136
- tanstackStart({
137
- // TanStack resolves these from `src/`.
138
- server: { entry: `../${serverEntry.replace(/\.ts$/, "")}` },
139
- start: { entry: `../${START_INSTANCE_ENTRY.replace(/\.ts$/, "")}` },
140
- serverFns: {
141
- generateFunctionId: ({ filename, functionName }) => {
142
- const id = functionName.replace(/_createServerFn_handler$/, "");
143
- if (/(^|\/)node_modules\//.test(filename)) {
144
- throw new Error(`[zite] ${filename} defines server function ${id}; dependencies can't ship server functions`);
145
- }
146
- const existing = ids.get(id);
147
- if (existing && existing !== filename) {
148
- throw new Error(`[zite] server function name ${id} is used in both ${existing} and ${filename}`);
149
- }
150
- ids.set(id, filename);
151
- return id;
152
- },
153
- },
154
- importProtection: {
155
- behavior: "error",
156
- client: {
157
- // Appended to TanStack's own.
158
- specifiers: ["zitejs/start/server", "zitejs/start/worker", "zitejs/start/describe", "zitejs/runtime"],
159
- // Replaces TanStack's list, so its `**/*.server.*` is restated. File
160
- // patterns also catch `zitejs/db` and `zitejs/integrations`, which the
161
- // aliases above rewrite before specifiers are matched.
162
- files: ["**/*.server.*", "**/.zite/db.ts", "**/.zite/integrations/**"],
163
- },
164
- },
165
- }),
166
- options.cloudflare !== false ? loadCloudflare(serverEntry) : null,
167
- viteReact(),
168
- compileZitejs,
169
- functionIds,
170
- workflowRegistry,
171
- authHooksRegistry,
172
- ];
173
- }
@@ -1,11 +0,0 @@
1
- import { type ZiteServerOptions } from "./server.js";
2
- import type { RenderWatch } from "./types.js";
3
- export type ZiteWorker = new (ctx: unknown, env: unknown) => {
4
- fetch(request: Request): Promise<Response>;
5
- render(request: Request, watch: RenderWatch): Promise<Response>;
6
- };
7
- /**
8
- * A Start app's Worker. The host sends most requests to `fetch`, and a page it
9
- * may cache to `render` over RPC, with a watch for what the page depends on.
10
- */
11
- export declare function createZiteWorker(options: ZiteServerOptions): ZiteWorker;
@@ -1,20 +0,0 @@
1
- // For the generated server entry of a Workers build only. Apps never import this.
2
- import { WorkerEntrypoint } from "cloudflare:workers";
3
- import { createZiteHandlers } from "./server.js";
4
- /**
5
- * A Start app's Worker. The host sends most requests to `fetch`, and a page it
6
- * may cache to `render` over RPC, with a watch for what the page depends on.
7
- */
8
- export function createZiteWorker(options) {
9
- const handlers = createZiteHandlers(options);
10
- return class extends WorkerEntrypoint {
11
- async fetch(request) {
12
- return handlers.fetch(request, this.env, this.ctx);
13
- }
14
- // An argument's stubs are disposed when the call returns, and a streamed
15
- // page can still read after that.
16
- async render(request, watch) {
17
- return handlers.render(request, this.ctx, watch.dup?.() ?? watch);
18
- }
19
- };
20
- }
@@ -1,53 +0,0 @@
1
- import type { ZiteTrigger, ZiteTriggerContext, ZiteTriggerSubscribe, ZiteTriggerUnsubscribe } from "../backend/index.js";
2
- import type { ZiteSchedule } from "../schedules/index.js";
3
- declare const WORKFLOW: unique symbol;
4
- type ProviderTriggerBase = Extract<ZiteTrigger, {
5
- every?: never;
6
- events?: never;
7
- }>;
8
- /**
9
- * A provider trigger, registered with the provider by its `subscribe` when the
10
- * app is published and taken down by its `unsubscribe` when it no longer is.
11
- * Both run on the platform with only the trigger's own connection.
12
- */
13
- export type StartProviderTrigger = ProviderTriggerBase & {
14
- subscribe: ZiteTriggerSubscribe;
15
- unsubscribe?: ZiteTriggerUnsubscribe;
16
- };
17
- export type StartTrigger = Exclude<ZiteTrigger, ProviderTriggerBase> | StartProviderTrigger;
18
- export type WorkflowConfig = {
19
- /** What this workflow does, in a sentence. Shown in the editor. */
20
- description?: string;
21
- } & ({
22
- schedule: ZiteSchedule;
23
- trigger?: never;
24
- } | {
25
- trigger: StartTrigger;
26
- schedule?: never;
27
- } | {
28
- schedule?: never;
29
- trigger?: never;
30
- });
31
- /** What a workflow's handler gets. A trigger adds `trigger`, typed by the kind it declares. */
32
- export type WorkflowArgs<TConfig extends WorkflowConfig> = {
33
- input: unknown;
34
- } & (TConfig extends {
35
- trigger: infer T;
36
- } ? {
37
- trigger: ZiteTriggerContext<T>;
38
- } : unknown);
39
- export type Workflow<TConfig extends WorkflowConfig = WorkflowConfig> = {
40
- readonly [WORKFLOW]: true;
41
- readonly config: TConfig;
42
- readonly handler: (args: WorkflowArgs<TConfig>) => unknown;
43
- };
44
- /**
45
- * Scheduled or triggered work, in a `*.server.ts` file:
46
- * `export const nightly = createWorkflow({ schedule }).handler(async () => { ... })`.
47
- * Only the platform runs it. It has no user and no URL, and reads data like a server function does.
48
- */
49
- export declare function createWorkflow<const TConfig extends WorkflowConfig>(config: TConfig): {
50
- handler: (fn: (args: WorkflowArgs<TConfig>) => unknown) => Workflow<TConfig>;
51
- };
52
- export declare const isWorkflow: (value: unknown) => value is Workflow;
53
- export {};
@@ -1,13 +0,0 @@
1
- // Shared across copies of zitejs in one bundle, like the access scope.
2
- const WORKFLOW = Symbol.for("zitejs:workflow");
3
- /**
4
- * Scheduled or triggered work, in a `*.server.ts` file:
5
- * `export const nightly = createWorkflow({ schedule }).handler(async () => { ... })`.
6
- * Only the platform runs it. It has no user and no URL, and reads data like a server function does.
7
- */
8
- export function createWorkflow(config) {
9
- return {
10
- handler: (fn) => ({ [WORKFLOW]: true, config, handler: fn }),
11
- };
12
- }
13
- export const isWorkflow = (value) => typeof value === "object" && value !== null && value[WORKFLOW] === true;