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
@@ -0,0 +1,88 @@
1
+ // The app's Settings off Zite, baked into the server build from its zite.config.json: what the platform sends each
2
+ // request on Zite (restly's startPagePlan and createZiteWebManifest), less the fallbacks only it knows, the app's name,
3
+ // screenshot and brand kit. Keep the two in step.
4
+ import { z } from 'zod';
5
+ const DEFAULT_PWA_BACKGROUND_COLOR = '#ffffff';
6
+ const HEX_COLOR = /^#[0-9A-Fa-f]{6}$/;
7
+ const MAX_SHORT_NAME_LENGTH = 12;
8
+ const text = z.string().optional().catch(undefined);
9
+ const settings = z.object({
10
+ seoSettings: z
11
+ .object({
12
+ title: text,
13
+ description: text,
14
+ thumbnailUrl: text,
15
+ faviconUrl: text,
16
+ })
17
+ .optional()
18
+ .catch(undefined),
19
+ pwaSettings: z
20
+ .object({
21
+ enabled: z.boolean().optional().catch(undefined),
22
+ title: text,
23
+ backgroundColor: text,
24
+ icons: z
25
+ .object({ icon192Url: text, icon512Url: text, appleTouchIconUrl: text })
26
+ .optional()
27
+ .catch(undefined),
28
+ })
29
+ .optional()
30
+ .catch(undefined),
31
+ });
32
+ /** An installable app's manifest: one whose settings name all three icons and that isn't switched off. */
33
+ export const webManifestOf = (pwa, title) => {
34
+ const icons = pwa?.icons;
35
+ if (!pwa ||
36
+ pwa.enabled === false ||
37
+ !icons?.icon192Url ||
38
+ !icons.icon512Url ||
39
+ !icons.appleTouchIconUrl)
40
+ return undefined;
41
+ const name = pwa.title?.trim() || title?.trim() || 'Zite App';
42
+ const background = pwa.backgroundColor && HEX_COLOR.test(pwa.backgroundColor)
43
+ ? pwa.backgroundColor
44
+ : DEFAULT_PWA_BACKGROUND_COLOR;
45
+ return {
46
+ name,
47
+ short_name: name.length <= MAX_SHORT_NAME_LENGTH
48
+ ? name
49
+ : name.slice(0, MAX_SHORT_NAME_LENGTH).trim(),
50
+ start_url: '/',
51
+ scope: '/',
52
+ display: 'standalone',
53
+ background_color: background,
54
+ theme_color: background,
55
+ icons: [
56
+ {
57
+ src: icons.icon192Url,
58
+ sizes: '192x192',
59
+ type: 'image/png',
60
+ purpose: 'any',
61
+ },
62
+ {
63
+ src: icons.icon512Url,
64
+ sizes: '512x512',
65
+ type: 'image/png',
66
+ purpose: 'any',
67
+ },
68
+ ],
69
+ };
70
+ };
71
+ /** What an app's zite.config.json sets of its pages' heads; nothing it leaves out. */
72
+ export const siteHeadOf = (config) => {
73
+ const parsed = settings.safeParse(config);
74
+ const { seoSettings: seo, pwaSettings: pwa } = parsed.success
75
+ ? parsed.data
76
+ : {};
77
+ const manifest = webManifestOf(pwa, seo?.title);
78
+ return {
79
+ ...(seo?.title && { title: seo.title }),
80
+ ...(seo?.description && { description: seo.description }),
81
+ ...(seo?.thumbnailUrl && { image: seo.thumbnailUrl }),
82
+ ...(seo?.faviconUrl && { icon: seo.faviconUrl }),
83
+ ...(manifest && {
84
+ manifest,
85
+ appleTouchIcon: pwa?.icons?.appleTouchIconUrl,
86
+ }),
87
+ };
88
+ };
@@ -0,0 +1,50 @@
1
+ import { type PluginOption } from 'vite';
2
+ import type { ZiteSchema } from '../../sync/lib.js';
3
+ import { type SchemaNames } from '../../sync/sdkNames.js';
4
+ import { type BuiltAirtableSettings } from '../platform/airtable/settings.js';
5
+ import type { DataNameMappings } from '../platform/data/types.js';
6
+ /** @internal A value as the string literal the build splices in for it. */
7
+ export declare const splicedLiteral: (value: unknown) => string;
8
+ /** @internal */
9
+ export declare const REFUSED_IMPORTS: RegExp[];
10
+ /** @internal What TanStack's import protection hands `onViolation`. */
11
+ export type ImportViolation = {
12
+ envType: 'client' | 'server';
13
+ type: 'specifier' | 'file' | 'marker';
14
+ specifier: string;
15
+ importer: string;
16
+ importerLoc?: {
17
+ file?: string;
18
+ line: number;
19
+ column: number;
20
+ };
21
+ snippet?: {
22
+ lines: string[];
23
+ };
24
+ };
25
+ /**
26
+ * @internal Zite's own message for a refused import, naming the fix; undefined leaves TanStack's, whose suggestions
27
+ * would send an agent to a raw createServerFn or a `.client.ts` file.
28
+ */
29
+ export declare const refusedImportMessage: (violation: ImportViolation, root: string) => string | undefined;
30
+ /** @internal The workspace's zite.schema.json as a server build carries it; null without one, a throw for one it can't read. */
31
+ export declare const workspaceSchemaNamesOf: (appDir: string) => SchemaNames | null;
32
+ /** @internal The app's Airtable integrations, from its own and its workspace's zite.config.json and zite.lock. */
33
+ export declare const builtAirtableSettingsOf: (appDir: string) => Record<string, BuiltAirtableSettings>;
34
+ /** @internal A workspace's zite.schema.json as the platform's `nameMappings`: the SDK names `.zite/db.ts` was generated with. */
35
+ export declare const workspaceNameMappingsOf: (raw: ZiteSchema) => DataNameMappings;
36
+ /**
37
+ * @internal The sign-in settings `zitejs dev` wrote for the app, for the module `local` mounts; null without them, or
38
+ * when the app's env sets `ZITE_DEV_USER`, whose stand-in wins.
39
+ */
40
+ export declare const devSignInOf: (appDir: string, appEnv: Record<string, string | undefined>) => Record<string, string> | null;
41
+ /** @internal The app's id in its zite.config.json, which `local` mints dev tokens for; null without one. */
42
+ export declare const devAppIdOf: (appDir: string) => string | null;
43
+ export type ZiteOptions = {
44
+ /** A server entry the caller owns, relative to the app root. By default zite() writes the platform's. */
45
+ serverEntry?: string;
46
+ /** Build for Cloudflare Workers, the target the platform deploys. Defaults to true; false builds for Node. */
47
+ cloudflare?: boolean;
48
+ };
49
+ /** The one plugin a Zite app's `vite.config.ts` uses. */
50
+ export declare function zite(options?: ZiteOptions): PluginOption[];
@@ -0,0 +1,491 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { loadEnv } from 'vite';
4
+ import { parse as parseEnv } from 'dotenv';
5
+ import { tanstackStart } from '@tanstack/react-start/plugin/vite';
6
+ import viteReact from '@vitejs/plugin-react';
7
+ import { ziteId } from '../../vite/index.js';
8
+ import { schemaNamesOf } from '../../sync/sdkNames.js';
9
+ import { nameMappingsOf } from '../platform/data/names.js';
10
+ import { airtableSettingsFrom, configFileOf, lockFileOf, } from '../platform/airtable/settings.js';
11
+ import { factoryDescriptions } from '../describe/descriptions.js';
12
+ import { sourceRootOf } from '../../sourceRoots.js';
13
+ import { registrationHashes } from './registrationHash.js';
14
+ import { sdkPatches } from './sdkPatches.js';
15
+ import { siteHeadOf } from './siteHead.js';
16
+ import { hasAppStart, renderStartInstance, renderStartServerEntry, renderWorkflowModules, START_INSTANCE_ENTRY, START_SERVER_ENTRY, workflowFiles, writeIfChanged, } from './entries.js';
17
+ // Must match the literals in ../serve/server.ts and ../describe/describe.ts, which the build rewrites.
18
+ const FN_IDS_TOKEN = '__ZITE_FN_IDS__';
19
+ const FN_DESCRIPTIONS_LITERAL = /(["'`])__ZITE_FN_DESCRIPTIONS__\1/;
20
+ const ROUTE_FILES_LITERAL = /(["'`])__ZITE_ROUTE_FILES__\1/;
21
+ const REGISTRATION_HASHES_LITERAL = /(["'`])__ZITE_REGISTRATION_HASHES__\1/;
22
+ const APP_FACTS_LITERAL = /(["'`])__ZITE_APP_FACTS__\1/;
23
+ // Spliced in after Rolldown's `charset: 'ascii'` has run, so it escapes what it splices the same way.
24
+ const asciiOnly = (code) => code.replace(/[\u0080-\uffff]/g, char => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
25
+ /** @internal A value as the string literal the build splices in for it. */
26
+ export const splicedLiteral = (value) => asciiOnly(JSON.stringify(JSON.stringify(value)));
27
+ // TanStack's generator writes each route file's id into its createFileRoute call and keeps it in step.
28
+ const FILE_ROUTE_ID = /\bcreateFileRoute\(\s*(["'`])([^"'`]+)\1\s*\)/;
29
+ // zitejs's empty registry, which the build replaces with the app's.
30
+ const WORKFLOW_REGISTRY = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]build[\\/]placeholders[\\/]workflowModules\.js$/;
31
+ // zitejs's null auth-hooks module, which the build points at the app's `zite.auth.ts`.
32
+ const AUTH_HOOKS_REGISTRY = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]build[\\/]placeholders[\\/]authHooksModule\.js$/;
33
+ const AUTH_HOOKS_FILE = 'zite.auth.ts';
34
+ // zitejs's null workspace names, which a server build and `vite dev` fill from the workspace root, where `zitejs/db`
35
+ // comes from too.
36
+ const WORKSPACE_SCHEMA_MODULE = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]build[\\/]placeholders[\\/]workspaceSchema\.js$/;
37
+ const WORKSPACE_SCHEMA_FILE = '../../zite.schema.json';
38
+ // zitejs's null Airtable settings, which a server build and `vite dev` fill from the app's and the workspace's config.
39
+ const AIRTABLE_SETTINGS_MODULE = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]platform[\\/]airtable[\\/]built\.js$/;
40
+ const APP_LOCK_FILE = 'zite.lock';
41
+ const WORKSPACE_CONFIG_FILE = '../../zite.config.json';
42
+ const WORKSPACE_LOCK_FILE = '../../zite.lock';
43
+ // zitejs's null Settings, which a server build and `vite dev` fill from the app's zite.config.json.
44
+ const SITE_HEAD_MODULE = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]build[\\/]placeholders[\\/]siteHead\.js$/;
45
+ // zitejs's null app id, which `vite dev` fills from the app's zite.config.json.
46
+ const DEV_APP_MODULE = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]build[\\/]placeholders[\\/]devApp\.js$/;
47
+ // zitejs's null sign-in settings, which `vite dev` fills from the `.zite/dev.env` that `zitejs dev` writes.
48
+ const DEV_SIGNIN_MODULE = /[\\/]zitejs[\\/]dist[\\/]esm[\\/]start[\\/]build[\\/]placeholders[\\/]devSignIn\.js$/;
49
+ const DEV_ENV_FILE = '.zite/dev.env';
50
+ const DEV_SIGNIN_KEYS = ['ZITE_SIGNIN', 'ZITE_AUTH_SECRET'];
51
+ const APP_CONFIG_FILE = 'zite.config.json';
52
+ // What no module in a Start app's `src/` may import, in the browser or on the server, and what to write instead.
53
+ const REFUSED = [
54
+ {
55
+ pattern: /^zitejs\/(api|caller)(\/|$)/,
56
+ fix: "it's classic's: a Start app calls its own server functions directly, from a loader or an event handler",
57
+ },
58
+ {
59
+ pattern: /^zitejs\/query(\/|$)/,
60
+ fix: "it's classic's: a Start app's router already provides its query client",
61
+ },
62
+ {
63
+ pattern: /^zitejs\/backend(\/|$)/,
64
+ fix: "it's classic's server module: import ZiteError and the rest from zitejs/start",
65
+ },
66
+ {
67
+ pattern: /^react-router(-dom)?(\/|$)/,
68
+ fix: 'use @tanstack/react-router instead: file routes in src/routes, and its Link and useNavigate',
69
+ },
70
+ {
71
+ pattern: /^cloudflare:workers$/,
72
+ fix: 'read process.env inside a handler instead',
73
+ },
74
+ {
75
+ pattern: /^zitejs\/signin(\/|$)/,
76
+ fix: "it's the platform's sign-in, which runs for the app: use loginWithRedirect or logout from zitejs/auth, or loginHref from zitejs/start",
77
+ },
78
+ ];
79
+ /** @internal */
80
+ export const REFUSED_IMPORTS = REFUSED.map(({ pattern }) => pattern);
81
+ const SERVER_CODE_FIX = "that's server code, which the browser can't load: call a signedInFn or publicFn from the page's loader instead";
82
+ /**
83
+ * @internal Zite's own message for a refused import, naming the fix; undefined leaves TanStack's, whose suggestions
84
+ * would send an agent to a raw createServerFn or a `.client.ts` file.
85
+ */
86
+ export const refusedImportMessage = (violation, root) => {
87
+ const fix = (violation.type === 'specifier'
88
+ ? REFUSED.find(({ pattern }) => pattern.test(violation.specifier))?.fix
89
+ : undefined) ??
90
+ (violation.envType === 'client' ? SERVER_CODE_FIX : undefined);
91
+ if (!fix)
92
+ return undefined;
93
+ const rel = (file) => path.isAbsolute(file)
94
+ ? path.relative(root, file).split(path.sep).join('/')
95
+ : file;
96
+ const loc = violation.importerLoc;
97
+ const file = rel(loc?.file ?? violation.importer);
98
+ const where = loc ? `${file}:${loc.line}:${loc.column}` : file;
99
+ return [
100
+ `[zite] ${where} imports "${rel(violation.specifier)}": ${fix}.`,
101
+ ...(violation.snippet ? ['', ...violation.snippet.lines] : []),
102
+ ].join('\n');
103
+ };
104
+ /** @internal The workspace's zite.schema.json as a server build carries it; null without one, a throw for one it can't read. */
105
+ export const workspaceSchemaNamesOf = (appDir) => {
106
+ const file = path.join(appDir, WORKSPACE_SCHEMA_FILE);
107
+ if (!existsSync(file))
108
+ return null;
109
+ try {
110
+ return schemaNamesOf(JSON.parse(readFileSync(file, 'utf-8')));
111
+ }
112
+ catch (error) {
113
+ throw new Error(`[zite] the workspace's zite.schema.json can't be read: ${error instanceof Error ? error.message : String(error)}`);
114
+ }
115
+ };
116
+ // As the platform reads them: a file that isn't there or isn't JSON is none, and one of another shape is narrowed here.
117
+ const readJson = (file, narrow) => {
118
+ let json;
119
+ try {
120
+ json = JSON.parse(readFileSync(file, 'utf-8'));
121
+ }
122
+ catch {
123
+ return undefined;
124
+ }
125
+ return narrow(json);
126
+ };
127
+ /** @internal The app's Airtable integrations, from its own and its workspace's zite.config.json and zite.lock. */
128
+ export const builtAirtableSettingsOf = (appDir) => airtableSettingsFrom({
129
+ appConfig: readJson(path.join(appDir, APP_CONFIG_FILE), configFileOf),
130
+ appLock: readJson(path.join(appDir, APP_LOCK_FILE), lockFileOf),
131
+ workspaceConfig: readJson(path.join(appDir, WORKSPACE_CONFIG_FILE), configFileOf),
132
+ workspaceLock: readJson(path.join(appDir, WORKSPACE_LOCK_FILE), lockFileOf),
133
+ hasSchema: existsSync(path.join(appDir, WORKSPACE_SCHEMA_FILE)),
134
+ });
135
+ /** @internal A workspace's zite.schema.json as the platform's `nameMappings`: the SDK names `.zite/db.ts` was generated with. */
136
+ export const workspaceNameMappingsOf = (raw) => nameMappingsOf(schemaNamesOf(raw));
137
+ /**
138
+ * @internal The sign-in settings `zitejs dev` wrote for the app, for the module `local` mounts; null without them, or
139
+ * when the app's env sets `ZITE_DEV_USER`, whose stand-in wins.
140
+ */
141
+ export const devSignInOf = (appDir, appEnv) => {
142
+ if (appEnv.ZITE_DEV_USER)
143
+ return null;
144
+ let written;
145
+ try {
146
+ written = parseEnv(readFileSync(path.join(appDir, DEV_ENV_FILE), 'utf-8'));
147
+ }
148
+ catch {
149
+ return null;
150
+ }
151
+ const kept = Object.fromEntries(DEV_SIGNIN_KEYS.flatMap(key => (written[key] ? [[key, written[key]]] : [])));
152
+ return kept.ZITE_SIGNIN ? kept : null;
153
+ };
154
+ /** @internal The app's id in its zite.config.json, which `local` mints dev tokens for; null without one. */
155
+ export const devAppIdOf = (appDir) => {
156
+ try {
157
+ const { id } = JSON.parse(readFileSync(path.join(appDir, APP_CONFIG_FILE), 'utf-8'));
158
+ return typeof id === 'string' && id ? id : null;
159
+ }
160
+ catch {
161
+ return null;
162
+ }
163
+ };
164
+ // Platform-pinned Worker settings. The deploy uses its own fixed template, so
165
+ // these only have to match it; apps don't carry a wrangler config.
166
+ const WORKER_COMPATIBILITY_DATE = '2026-09-25';
167
+ const WORKER_COMPATIBILITY_FLAGS = ['nodejs_compat'];
168
+ // Resolved from the app at build time; zitejs doesn't depend on it.
169
+ const loadCloudflare = async (main) => {
170
+ const { cloudflare } = (await import('@cloudflare/vite-plugin'));
171
+ return cloudflare({
172
+ viteEnvironment: { name: 'ssr' },
173
+ config: {
174
+ name: 'zite-app',
175
+ main,
176
+ compatibility_date: WORKER_COMPATIBILITY_DATE,
177
+ compatibility_flags: WORKER_COMPATIBILITY_FLAGS,
178
+ },
179
+ });
180
+ };
181
+ /** The one plugin a Zite app's `vite.config.ts` uses. */
182
+ export function zite(options = {}) {
183
+ const serverEntry = options.serverEntry ?? START_SERVER_ENTRY;
184
+ // Platform-owned, so they're rewritten whenever they differ. Sandboxes run the
185
+ // image's zitejs for `generate`, which may predate Start; the plugin can't.
186
+ const appDir = process.cwd();
187
+ if (!options.serverEntry) {
188
+ writeIfChanged(appDir, START_SERVER_ENTRY, renderStartServerEntry(options.cloudflare === false ? 'node' : 'cloudflare'));
189
+ }
190
+ writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)));
191
+ // Every server function TanStack's compiler found, from its own hook, by id.
192
+ const ids = new Map();
193
+ const compileZitejs = {
194
+ name: 'zite:compile-zitejs',
195
+ // The factories must go through TanStack's compiler in both environments.
196
+ // The peer dependency gets zitejs crawled already; this keeps it true if an
197
+ // install drops that. A Node build bundles everything, so externalized
198
+ // libraries can't load the root's React 18 renderer.
199
+ config: (config, { command, mode }) => {
200
+ const root = path.resolve(config.root ?? '.');
201
+ // The `local` provider reads process.env. In workerd, Cloudflare's plugin sets it from the app's .env; on Node, this does.
202
+ if (command === 'serve' && options.cloudflare === false) {
203
+ Object.assign(process.env, loadEnv(mode, root, [
204
+ 'ZITE_DEV_',
205
+ 'ZITE_URLS',
206
+ 'ZITE_SIGNIN',
207
+ 'ZITE_AUTH_SECRET',
208
+ ]));
209
+ }
210
+ const src = `${path.join(root, 'src')}/`;
211
+ return {
212
+ ssr: { noExternal: options.cloudflare === false ? true : ['zitejs'] },
213
+ optimizeDeps: { exclude: ['zitejs'] },
214
+ resolve: {
215
+ // `@/` as in classic apps and shadcn, `~/` as in TanStack's templates.
216
+ alias: [
217
+ { find: /^@\//, replacement: src },
218
+ { find: /^~\//, replacement: src },
219
+ // The workspace SDKs `zitejs generate` writes, as classic apps map them.
220
+ {
221
+ find: /^zitejs\/db$/,
222
+ replacement: path.join(root, '../../.zite/db.ts'),
223
+ },
224
+ {
225
+ find: /^zitejs\/integrations$/,
226
+ replacement: path.join(root, '.zite/integrations/index.ts'),
227
+ },
228
+ {
229
+ find: /^zitejs\/email$/,
230
+ replacement: path.join(root, '.zite/integrations/email.ts'),
231
+ },
232
+ {
233
+ find: /^zitejs\/meta$/,
234
+ replacement: path.join(root, '.zite/meta.ts'),
235
+ },
236
+ // Classic's actions run on better-auth's client; Start's call the sign-in module's routes.
237
+ { find: /^zitejs\/auth$/, replacement: 'zitejs/start/auth' },
238
+ ],
239
+ // Shared workspace libraries resolve from the root, where classic apps
240
+ // keep React 18; recharts 2 needs the app's react-is 19 or drops series.
241
+ dedupe: ['react-is'],
242
+ },
243
+ };
244
+ },
245
+ // Each new isolate loads the whole server bundle, so its size is cold-start
246
+ // time; Vite leaves SSR output unminified. Under `vite dev`, Cloudflare's
247
+ // plugin would pre-bundle zitejs's server entry, past the modules below
248
+ // that fill zitejs's registries and workspace names.
249
+ configEnvironment: (name, config, { command }) => name !== 'ssr'
250
+ ? undefined
251
+ : {
252
+ ...(options.cloudflare !== false && {
253
+ build: {
254
+ ...(config.build?.minify === undefined && { minify: true }),
255
+ // V8 keeps a module with any character past Latin-1 as two bytes a character, and every byte of
256
+ // script is isolate heap. Escaped, the measured server bundles took 13-17% less.
257
+ rolldownOptions: { output: { charset: 'ascii' } },
258
+ },
259
+ }),
260
+ ...(command === 'serve' && {
261
+ optimizeDeps: { exclude: ['zitejs'] },
262
+ }),
263
+ },
264
+ };
265
+ // Each server function's `description` option, by name, and each route's file, by route id: for the editor.
266
+ const descriptions = new Map();
267
+ const routeFiles = new Map();
268
+ const srcDir = `${path.join(appDir, 'src')}${path.sep}`;
269
+ const functionIds = {
270
+ name: 'zite:function-ids',
271
+ apply: 'build',
272
+ transform(code, id) {
273
+ if (this.environment?.config.consumer !== 'server' ||
274
+ !id.startsWith(srcDir))
275
+ return;
276
+ const file = id.split('?')[0];
277
+ const routeId = FILE_ROUTE_ID.exec(code)?.[2];
278
+ if (routeId && !id.includes('?'))
279
+ routeFiles.set(routeId, path.relative(appDir, file).split(path.sep).join('/'));
280
+ if (code.includes('description')) {
281
+ try {
282
+ for (const [name, text] of factoryDescriptions(this.parse(code)))
283
+ descriptions.set(name, text);
284
+ }
285
+ catch {
286
+ // An unreadable module shows no descriptions.
287
+ }
288
+ }
289
+ },
290
+ generateBundle(_, bundle) {
291
+ const described = Object.fromEntries([...descriptions].filter(([name]) => ids.has(name)));
292
+ // Every module the workflow registry imports, hashed over its graph: describe gives each provider trigger its module's.
293
+ const server = this.environment?.config.consumer === 'server';
294
+ const registry = server
295
+ ? [...this.getModuleIds()].find(id => WORKFLOW_REGISTRY.test(id.split('?')[0]))
296
+ : undefined;
297
+ const registered = registry
298
+ ? (this.getModuleInfo(registry)?.dynamicallyImportedIds ?? [])
299
+ : [];
300
+ const hashes = registrationHashes(appDir, registered, id => this.getModuleInfo(id));
301
+ const facts = {
302
+ internal: readJson(path.join(appDir, APP_CONFIG_FILE), json => json?.accessMode) === 'internal',
303
+ automation: sourceRootOf(appDir) === 'automations',
304
+ };
305
+ for (const chunk of Object.values(bundle)) {
306
+ if (chunk.type !== 'chunk')
307
+ continue;
308
+ if (chunk.code.includes(FN_IDS_TOKEN))
309
+ chunk.code = chunk.code.replace(FN_IDS_TOKEN, () => asciiOnly([...ids.keys()].join(',')));
310
+ chunk.code = chunk.code
311
+ .replace(FN_DESCRIPTIONS_LITERAL, () => splicedLiteral(described))
312
+ .replace(ROUTE_FILES_LITERAL, () => splicedLiteral(Object.fromEntries(routeFiles)))
313
+ .replace(REGISTRATION_HASHES_LITERAL, () => splicedLiteral(hashes))
314
+ .replace(APP_FACTS_LITERAL, () => splicedLiteral(facts));
315
+ }
316
+ },
317
+ };
318
+ const workflowRegistry = {
319
+ name: 'zite:workflow-registry',
320
+ load: id => WORKFLOW_REGISTRY.test(id.split('?')[0])
321
+ ? renderWorkflowModules(appDir, workflowFiles(appDir))
322
+ : undefined,
323
+ };
324
+ const authHooksRegistry = {
325
+ name: 'zite:auth-hooks',
326
+ load: id => {
327
+ if (!AUTH_HOOKS_REGISTRY.test(id.split('?')[0]))
328
+ return undefined;
329
+ const file = path.join(appDir, AUTH_HOOKS_FILE);
330
+ return existsSync(file)
331
+ ? `export const authHooksModule = () => import(${JSON.stringify(file)});\n`
332
+ : 'export const authHooksModule = null;\n';
333
+ },
334
+ };
335
+ // The names the build's `zitejs/db` was generated with, from the same commit's schema. Only the server's: a browser
336
+ // never translates a data call, and its bundle carries no table or field id.
337
+ let serving = false;
338
+ const workspaceSchema = {
339
+ name: 'zite:workspace-schema',
340
+ configResolved(config) {
341
+ serving = config.command === 'serve';
342
+ },
343
+ load(id) {
344
+ if (!WORKSPACE_SCHEMA_MODULE.test(id.split('?')[0]))
345
+ return undefined;
346
+ this.addWatchFile(path.join(appDir, WORKSPACE_SCHEMA_FILE));
347
+ let names = null;
348
+ try {
349
+ if (this.environment?.config.consumer === 'server')
350
+ names = workspaceSchemaNamesOf(appDir);
351
+ }
352
+ catch (error) {
353
+ // A build fails rather than ship names its client wasn't written against; `vite dev` carries on mid-edit.
354
+ if (!serving)
355
+ throw error;
356
+ }
357
+ return `export const workspaceSchemaNames = ${JSON.stringify(names)};\n`;
358
+ },
359
+ };
360
+ // The integrations the app runs itself, from the same commit's config, and only on the server, which calls them.
361
+ const airtableSettings = {
362
+ name: 'zite:airtable-settings',
363
+ load(id) {
364
+ if (!AIRTABLE_SETTINGS_MODULE.test(id.split('?')[0]))
365
+ return undefined;
366
+ for (const file of [
367
+ APP_CONFIG_FILE,
368
+ APP_LOCK_FILE,
369
+ WORKSPACE_CONFIG_FILE,
370
+ WORKSPACE_LOCK_FILE,
371
+ ])
372
+ this.addWatchFile(path.join(appDir, file));
373
+ const settings = this.environment?.config.consumer === 'server'
374
+ ? builtAirtableSettingsOf(appDir)
375
+ : null;
376
+ return `export const builtAirtableSettings = ${JSON.stringify(settings)};\n`;
377
+ },
378
+ };
379
+ // The app's Settings for its pages off Zite, where no host sends them. Only the server renders a page's head.
380
+ const siteHead = {
381
+ name: 'zite:site-head',
382
+ load(id) {
383
+ if (!SITE_HEAD_MODULE.test(id.split('?')[0]))
384
+ return undefined;
385
+ this.addWatchFile(path.join(appDir, APP_CONFIG_FILE));
386
+ const head = this.environment?.config.consumer === 'server'
387
+ ? (readJson(path.join(appDir, APP_CONFIG_FILE), siteHeadOf) ?? null)
388
+ : null;
389
+ return `export const builtSiteHead = ${JSON.stringify(head)};\n`;
390
+ },
391
+ };
392
+ // Under `vite dev` only: a published build is never `local`'s to mint for.
393
+ const devApp = {
394
+ name: 'zite:dev-app',
395
+ apply: 'serve',
396
+ load(id) {
397
+ if (!DEV_APP_MODULE.test(id.split('?')[0]))
398
+ return undefined;
399
+ this.addWatchFile(path.join(appDir, APP_CONFIG_FILE));
400
+ return `export const devAppId = ${JSON.stringify(devAppIdOf(appDir))};\n`;
401
+ },
402
+ };
403
+ // Under `vite dev` only, and only to the server: the secret seals the session cookie, and never reaches a browser.
404
+ let devEnv = {};
405
+ const devSignIn = {
406
+ name: 'zite:dev-signin',
407
+ apply: 'serve',
408
+ configResolved(config) {
409
+ const envDir = typeof config.envDir === 'string' ? config.envDir : config.root;
410
+ devEnv = {
411
+ ...loadEnv(config.mode, envDir, ['ZITE_DEV_USER']),
412
+ ...process.env,
413
+ };
414
+ },
415
+ load(id) {
416
+ if (!DEV_SIGNIN_MODULE.test(id.split('?')[0]))
417
+ return undefined;
418
+ this.addWatchFile(path.join(appDir, DEV_ENV_FILE));
419
+ const settings = this.environment?.config.consumer === 'server'
420
+ ? devSignInOf(appDir, devEnv)
421
+ : null;
422
+ return `export const devSignIn = ${JSON.stringify(settings)};\n`;
423
+ },
424
+ };
425
+ return [
426
+ // First, so ids name lines in the source, before TanStack splits a route's component out of it.
427
+ ziteId(),
428
+ tanstackStart({
429
+ // TanStack resolves these from `src/`.
430
+ server: { entry: `../${serverEntry.replace(/\.ts$/, '')}` },
431
+ start: { entry: `../${START_INSTANCE_ENTRY.replace(/\.ts$/, '')}` },
432
+ serverFns: {
433
+ generateFunctionId: ({ filename, functionName }) => {
434
+ const id = functionName.replace(/_createServerFn_handler$/, '');
435
+ if (/(^|\/)node_modules\//.test(filename)) {
436
+ throw new Error(`[zite] ${filename} defines server function ${id}; dependencies can't ship server functions`);
437
+ }
438
+ const existing = ids.get(id);
439
+ if (existing && existing !== filename) {
440
+ throw new Error(`[zite] server function name ${id} is used in both ${existing} and ${filename}`);
441
+ }
442
+ ids.set(id, filename);
443
+ return id;
444
+ },
445
+ },
446
+ importProtection: {
447
+ behavior: 'error',
448
+ // Thrown, it replaces TanStack's text; TanStack's schema types the violation unknown.
449
+ onViolation: violation => {
450
+ const message = refusedImportMessage(violation, appDir);
451
+ if (message)
452
+ throw new Error(message);
453
+ },
454
+ client: {
455
+ // Appended to TanStack's own.
456
+ specifiers: [
457
+ ...REFUSED_IMPORTS,
458
+ 'zitejs/start/fetch',
459
+ 'zitejs/start/server',
460
+ 'zitejs/start/worker',
461
+ 'zitejs/start/describe',
462
+ 'zitejs/runtime',
463
+ ],
464
+ // Replaces TanStack's list, so its `**/*.server.*` is restated. File
465
+ // patterns also catch `zitejs/db`, `zitejs/integrations` and `zitejs/meta`,
466
+ // which the aliases above rewrite before specifiers are matched.
467
+ files: [
468
+ '**/*.server.*',
469
+ '**/.zite/db.ts',
470
+ '**/.zite/integrations/**',
471
+ '**/.zite/meta.ts',
472
+ ],
473
+ },
474
+ // Replaces TanStack's empty list; its `**/*.client.*` files stay.
475
+ server: { specifiers: REFUSED_IMPORTS },
476
+ },
477
+ }),
478
+ options.cloudflare !== false ? loadCloudflare(serverEntry) : null,
479
+ options.cloudflare !== false ? sdkPatches() : null,
480
+ viteReact(),
481
+ compileZitejs,
482
+ functionIds,
483
+ workflowRegistry,
484
+ authHooksRegistry,
485
+ workspaceSchema,
486
+ airtableSettings,
487
+ siteHead,
488
+ devApp,
489
+ devSignIn,
490
+ ];
491
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ // zitejs/backend, zitejs/backend/base, zitejs/caller and zitejs/query as a Start app's types see them, under the
2
+ // `zite-start` condition: classic's modules, with nothing in them for a Start app. ZiteError and the rest come from
3
+ // zitejs/start, server functions are called directly, and the router provides the query client.
4
+ export {};