zitejs 0.9.152 → 0.9.154

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 (395) hide show
  1. package/dist/cjs/auth/actions.d.ts +28 -0
  2. package/dist/cjs/auth/actions.js +93 -0
  3. package/dist/cjs/auth/client.d.ts +357 -0
  4. package/dist/cjs/auth/client.js +66 -0
  5. package/dist/cjs/auth/config.js +9 -3
  6. package/dist/cjs/auth/index.d.ts +2 -249
  7. package/dist/cjs/auth/index.js +11 -108
  8. package/dist/cjs/auth/index.test.js +60 -0
  9. package/dist/cjs/auth/previewClaim.d.ts +7 -0
  10. package/dist/cjs/auth/previewClaim.js +16 -0
  11. package/dist/cjs/auth/profileUpdates.d.ts +9 -0
  12. package/dist/cjs/auth/profileUpdates.js +11 -0
  13. package/dist/cjs/backend/index.d.ts +6 -6
  14. package/dist/cjs/backend/index.js +13 -13
  15. package/dist/cjs/backend/index.test.js +102 -102
  16. package/dist/cjs/bundle/index.js +29 -16
  17. package/dist/cjs/caller/index.js +43 -43
  18. package/dist/cjs/check/index.d.ts +44 -1
  19. package/dist/cjs/check/index.js +198 -61
  20. package/dist/cjs/check/start/routeTree.d.ts +8 -0
  21. package/dist/cjs/check/start/routeTree.js +118 -0
  22. package/dist/cjs/check/start/tsgo.d.ts +2 -0
  23. package/dist/cjs/check/start/tsgo.js +35 -0
  24. package/dist/cjs/cli.js +19 -6
  25. package/dist/cjs/client/index.d.ts +2 -2
  26. package/dist/cjs/client/index.js +25 -25
  27. package/dist/cjs/dev/index.js +81 -53
  28. package/dist/cjs/dev/signin.d.ts +16 -0
  29. package/dist/cjs/dev/signin.js +84 -0
  30. package/dist/cjs/index.d.ts +5 -5
  31. package/dist/cjs/integrations/client.d.ts +3 -3
  32. package/dist/cjs/integrations/client.js +5 -4
  33. package/dist/cjs/integrations/client.test-d.js +15 -15
  34. package/dist/cjs/integrations/index.d.ts +2 -2
  35. package/dist/cjs/integrations/rules.d.ts +1 -0
  36. package/dist/cjs/integrations/rules.js +44 -41
  37. package/dist/cjs/integrations/rules.test.js +60 -54
  38. package/dist/cjs/internal/appMode.d.ts +14 -0
  39. package/dist/cjs/internal/appMode.js +19 -0
  40. package/dist/cjs/internal/env.js +3 -2
  41. package/dist/cjs/internal/platformFetch.d.ts +2 -0
  42. package/dist/cjs/internal/platformFetch.js +14 -0
  43. package/dist/cjs/internal/reservedIds.d.ts +8 -0
  44. package/dist/cjs/internal/reservedIds.js +14 -0
  45. package/dist/cjs/internal/serviceUrls.d.ts +5 -0
  46. package/dist/cjs/internal/serviceUrls.js +14 -0
  47. package/dist/cjs/pdf/index.js +2 -1
  48. package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
  49. package/dist/cjs/runtime/index.d.ts +69 -21
  50. package/dist/cjs/runtime/index.js +32 -26
  51. package/dist/cjs/runtime/index.test.js +34 -34
  52. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +35 -18
  53. package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
  54. package/dist/cjs/sourceRoots.js +15 -15
  55. package/dist/cjs/sourceRoots.test.js +29 -27
  56. package/dist/cjs/start/build/entries.d.ts +25 -0
  57. package/dist/cjs/start/build/entries.js +121 -0
  58. package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
  59. package/dist/cjs/start/build/placeholders/devApp.js +6 -0
  60. package/dist/cjs/start/describe/describeBuilt.d.ts +5 -0
  61. package/dist/cjs/start/describe/describeBuilt.js +144 -0
  62. package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
  63. package/dist/cjs/start/platform/aiUsage.js +215 -0
  64. package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
  65. package/dist/cjs/start/platform/airtable/cache.js +93 -0
  66. package/dist/cjs/start/protocol.d.ts +19 -0
  67. package/dist/cjs/start/protocol.js +33 -0
  68. package/dist/cjs/start/serve/local/provider.d.ts +25 -0
  69. package/dist/cjs/start/serve/local/provider.js +196 -0
  70. package/dist/cjs/start/serve/provider.d.ts +19 -0
  71. package/dist/cjs/start/serve/provider.js +86 -0
  72. package/dist/cjs/start/types.d.ts +373 -0
  73. package/dist/cjs/start/types.js +2 -0
  74. package/dist/cjs/steps/index.d.ts +8 -8
  75. package/dist/cjs/steps/index.js +53 -53
  76. package/dist/cjs/steps/index.test.js +218 -218
  77. package/dist/cjs/sync/index.d.ts +1 -1
  78. package/dist/cjs/sync/index.js +28 -27
  79. package/dist/cjs/sync/lib.d.ts +15 -8
  80. package/dist/cjs/sync/lib.js +652 -661
  81. package/dist/cjs/sync/lib.test.js +81 -14
  82. package/dist/cjs/sync/sdkNames.d.ts +67 -9
  83. package/dist/cjs/sync/sdkNames.js +97 -31
  84. package/dist/cjs/sync/sdkNames.test.js +189 -113
  85. package/dist/cjs/types/fields.d.ts +1 -1
  86. package/dist/cjs/types/fields.js +105 -97
  87. package/dist/cjs/types/index.d.ts +2 -2
  88. package/dist/cjs/types/tables.d.ts +1 -1
  89. package/dist/cjs/upload/index.js +89 -24
  90. package/dist/cjs/upload/index.test.js +104 -1
  91. package/dist/cjs/vite/domTagNames.js +252 -252
  92. package/dist/cjs/vite/index.d.ts +1 -1
  93. package/dist/cjs/vite/index.js +51 -42
  94. package/dist/cjs/vite/index.test.js +10 -2
  95. package/dist/esm/auth/actions.d.ts +28 -0
  96. package/dist/esm/auth/actions.js +55 -0
  97. package/dist/esm/auth/client.d.ts +357 -0
  98. package/dist/esm/auth/client.js +62 -0
  99. package/dist/esm/auth/config.js +9 -3
  100. package/dist/esm/auth/index.d.ts +2 -249
  101. package/dist/esm/auth/index.js +2 -103
  102. package/dist/esm/auth/index.test.js +60 -0
  103. package/dist/esm/auth/previewClaim.d.ts +7 -0
  104. package/dist/esm/auth/previewClaim.js +12 -0
  105. package/dist/esm/auth/profileUpdates.d.ts +9 -0
  106. package/dist/esm/auth/profileUpdates.js +6 -0
  107. package/dist/esm/backend/index.d.ts +6 -6
  108. package/dist/esm/backend/index.js +13 -13
  109. package/dist/esm/backend/index.test.js +106 -106
  110. package/dist/esm/bundle/index.js +29 -16
  111. package/dist/esm/caller/index.js +44 -44
  112. package/dist/esm/check/index.d.ts +44 -1
  113. package/dist/esm/check/index.js +194 -61
  114. package/dist/esm/check/start/routeTree.d.ts +8 -0
  115. package/dist/esm/check/start/routeTree.js +77 -0
  116. package/dist/esm/check/start/tsgo.d.ts +2 -0
  117. package/dist/esm/check/start/tsgo.js +29 -0
  118. package/dist/esm/cli.js +19 -6
  119. package/dist/esm/client/index.d.ts +2 -2
  120. package/dist/esm/client/index.js +25 -25
  121. package/dist/esm/dev/index.js +88 -60
  122. package/dist/esm/dev/signin.d.ts +16 -0
  123. package/dist/esm/dev/signin.js +80 -0
  124. package/dist/esm/index.d.ts +5 -5
  125. package/dist/esm/index.js +3 -3
  126. package/dist/esm/integrations/client.d.ts +3 -3
  127. package/dist/esm/integrations/client.js +6 -5
  128. package/dist/esm/integrations/client.test-d.js +19 -19
  129. package/dist/esm/integrations/index.d.ts +2 -2
  130. package/dist/esm/integrations/index.js +1 -1
  131. package/dist/esm/integrations/rules.d.ts +1 -0
  132. package/dist/esm/integrations/rules.js +44 -41
  133. package/dist/esm/integrations/rules.test.js +62 -56
  134. package/dist/esm/internal/appMode.d.ts +14 -0
  135. package/dist/esm/internal/appMode.js +13 -0
  136. package/dist/esm/internal/env.js +3 -2
  137. package/dist/esm/internal/platformFetch.d.ts +2 -0
  138. package/dist/esm/internal/platformFetch.js +9 -0
  139. package/dist/esm/internal/reservedIds.d.ts +8 -0
  140. package/dist/esm/internal/reservedIds.js +10 -0
  141. package/dist/esm/internal/serviceUrls.d.ts +5 -0
  142. package/dist/esm/internal/serviceUrls.js +10 -0
  143. package/dist/esm/pdf/index.js +2 -1
  144. package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
  145. package/dist/esm/runtime/index.d.ts +69 -21
  146. package/dist/esm/runtime/index.js +35 -29
  147. package/dist/esm/runtime/index.test.js +36 -36
  148. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +36 -19
  149. package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
  150. package/dist/esm/signin/conformance.d.ts +100 -0
  151. package/dist/esm/signin/conformance.js +616 -0
  152. package/dist/esm/signin/cookies.d.ts +28 -0
  153. package/dist/esm/signin/cookies.js +67 -0
  154. package/dist/esm/signin/encoding.d.ts +1 -0
  155. package/dist/esm/signin/encoding.js +12 -0
  156. package/dist/esm/signin/endpoints.d.ts +12 -0
  157. package/dist/esm/signin/endpoints.js +32 -0
  158. package/dist/esm/signin/http.d.ts +25 -0
  159. package/dist/esm/signin/http.js +106 -0
  160. package/dist/esm/signin/index.d.ts +8 -0
  161. package/dist/esm/signin/index.js +9 -0
  162. package/dist/esm/signin/keys.d.ts +35 -0
  163. package/dist/esm/signin/keys.js +230 -0
  164. package/dist/esm/signin/paths.d.ts +2 -0
  165. package/dist/esm/signin/paths.js +5 -0
  166. package/dist/esm/signin/seal.d.ts +19 -0
  167. package/dist/esm/signin/seal.js +47 -0
  168. package/dist/esm/signin/signin.d.ts +60 -0
  169. package/dist/esm/signin/signin.js +447 -0
  170. package/dist/esm/signin/transport.d.ts +112 -0
  171. package/dist/esm/signin/transport.js +1 -0
  172. package/dist/esm/signin/verifier.d.ts +2 -0
  173. package/dist/esm/signin/verifier.js +4 -0
  174. package/dist/esm/signin/verify.d.ts +83 -0
  175. package/dist/esm/signin/verify.js +142 -0
  176. package/dist/esm/sourceRoots.js +17 -17
  177. package/dist/esm/sourceRoots.test.js +34 -32
  178. package/dist/esm/start/access.d.ts +19 -0
  179. package/dist/esm/start/access.js +43 -0
  180. package/dist/esm/start/auth.d.ts +28 -0
  181. package/dist/esm/start/auth.js +33 -0
  182. package/dist/esm/start/automations/quiet.d.ts +2 -0
  183. package/dist/esm/start/automations/quiet.js +36 -0
  184. package/dist/esm/start/automations/registration.d.ts +13 -0
  185. package/dist/esm/start/automations/registration.js +25 -0
  186. package/dist/esm/start/automations/steps.d.ts +29 -0
  187. package/dist/esm/start/automations/steps.js +95 -0
  188. package/dist/esm/start/automations/workflow.d.ts +83 -0
  189. package/dist/esm/start/automations/workflow.js +36 -0
  190. package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
  191. package/dist/esm/start/automations/workflow.test-d.js +130 -0
  192. package/dist/esm/start/automations/workflowRun.d.ts +130 -0
  193. package/dist/esm/start/automations/workflowRun.js +185 -0
  194. package/dist/esm/start/barrel.test-d.d.ts +10 -0
  195. package/dist/esm/start/barrel.test-d.js +6 -0
  196. package/dist/esm/start/build/entries.d.ts +25 -0
  197. package/dist/esm/start/build/entries.js +109 -0
  198. package/dist/esm/start/build/placeholders/authHooksModule.d.ts +1 -0
  199. package/dist/esm/start/build/placeholders/authHooksModule.js +3 -0
  200. package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
  201. package/dist/esm/start/build/placeholders/devApp.js +3 -0
  202. package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
  203. package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
  204. package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
  205. package/dist/esm/start/build/placeholders/siteHead.js +3 -0
  206. package/dist/esm/start/build/placeholders/workflowModules.d.ts +1 -0
  207. package/dist/esm/start/build/placeholders/workflowModules.js +3 -0
  208. package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
  209. package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
  210. package/dist/esm/start/build/registrationHash.d.ts +11 -0
  211. package/dist/esm/start/build/registrationHash.js +88 -0
  212. package/dist/esm/start/build/sdk/axios.d.ts +76 -0
  213. package/dist/esm/start/build/sdk/axios.js +253 -0
  214. package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
  215. package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
  216. package/dist/esm/start/build/sdk/undici.d.ts +34 -0
  217. package/dist/esm/start/build/sdk/undici.js +18 -0
  218. package/dist/esm/start/build/sdkPatches.d.ts +22 -0
  219. package/dist/esm/start/build/sdkPatches.js +430 -0
  220. package/dist/esm/start/build/siteHead.d.ts +26 -0
  221. package/dist/esm/start/build/siteHead.js +88 -0
  222. package/dist/esm/start/build/vite.d.ts +50 -0
  223. package/dist/esm/start/build/vite.js +487 -0
  224. package/dist/esm/start/classicOnly.d.ts +1 -0
  225. package/dist/esm/start/classicOnly.js +4 -0
  226. package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
  227. package/dist/esm/start/clientErrorMessage.test.js +105 -0
  228. package/dist/esm/start/describe/describe.d.ts +120 -0
  229. package/dist/esm/start/describe/describe.js +372 -0
  230. package/dist/esm/start/describe/describeBuilt.d.ts +5 -0
  231. package/dist/esm/start/describe/describeBuilt.js +102 -0
  232. package/dist/esm/start/describe/descriptions.d.ts +4 -0
  233. package/dist/esm/start/describe/descriptions.js +54 -0
  234. package/dist/esm/start/errors.d.ts +62 -0
  235. package/dist/esm/start/errors.js +163 -0
  236. package/dist/esm/start/errors.test.d.ts +1 -0
  237. package/dist/esm/start/errors.test.js +54 -0
  238. package/dist/esm/start/factories.d.ts +14 -0
  239. package/dist/esm/start/factories.js +23 -0
  240. package/dist/esm/start/factories.test-d.d.ts +2 -0
  241. package/dist/esm/start/factories.test-d.js +60 -0
  242. package/dist/esm/start/failures.d.ts +7 -0
  243. package/dist/esm/start/failures.js +62 -0
  244. package/dist/esm/start/fnFactory.d.ts +16 -0
  245. package/dist/esm/start/fnFactory.js +1 -0
  246. package/dist/esm/start/host.d.ts +3 -0
  247. package/dist/esm/start/host.js +4 -0
  248. package/dist/esm/start/index.d.ts +10 -0
  249. package/dist/esm/start/index.js +7 -0
  250. package/dist/esm/start/login.d.ts +5 -0
  251. package/dist/esm/start/login.js +29 -0
  252. package/dist/esm/start/middlewareKind.d.ts +13 -0
  253. package/dist/esm/start/middlewareKind.js +9 -0
  254. package/dist/esm/start/platform/aiUsage.d.ts +29 -0
  255. package/dist/esm/start/platform/aiUsage.js +210 -0
  256. package/dist/esm/start/platform/airtable/arrayFields.d.ts +10 -0
  257. package/dist/esm/start/platform/airtable/arrayFields.js +30 -0
  258. package/dist/esm/start/platform/airtable/built.d.ts +2 -0
  259. package/dist/esm/start/platform/airtable/built.js +3 -0
  260. package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
  261. package/dist/esm/start/platform/airtable/cache.js +89 -0
  262. package/dist/esm/start/platform/airtable/dispatch.d.ts +57 -0
  263. package/dist/esm/start/platform/airtable/dispatch.js +541 -0
  264. package/dist/esm/start/platform/airtable/formulas.d.ts +70 -0
  265. package/dist/esm/start/platform/airtable/formulas.js +261 -0
  266. package/dist/esm/start/platform/airtable/index.d.ts +6 -0
  267. package/dist/esm/start/platform/airtable/index.js +51 -0
  268. package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
  269. package/dist/esm/start/platform/airtable/settings.js +138 -0
  270. package/dist/esm/start/platform/analytics.d.ts +3 -0
  271. package/dist/esm/start/platform/analytics.js +59 -0
  272. package/dist/esm/start/platform/calls.d.ts +5 -0
  273. package/dist/esm/start/platform/calls.js +104 -0
  274. package/dist/esm/start/platform/caps.d.ts +9 -0
  275. package/dist/esm/start/platform/caps.js +35 -0
  276. package/dist/esm/start/platform/connections.d.ts +25 -0
  277. package/dist/esm/start/platform/connections.js +198 -0
  278. package/dist/esm/start/platform/data/baseRunner.d.ts +97 -0
  279. package/dist/esm/start/platform/data/baseRunner.js +117 -0
  280. package/dist/esm/start/platform/data/dispatch.d.ts +17 -0
  281. package/dist/esm/start/platform/data/dispatch.js +216 -0
  282. package/dist/esm/start/platform/data/fetch.d.ts +7 -0
  283. package/dist/esm/start/platform/data/fetch.js +9 -0
  284. package/dist/esm/start/platform/data/index.d.ts +27 -0
  285. package/dist/esm/start/platform/data/index.js +75 -0
  286. package/dist/esm/start/platform/data/names.d.ts +7 -0
  287. package/dist/esm/start/platform/data/names.js +18 -0
  288. package/dist/esm/start/platform/data/sqlNameMappings.d.ts +58 -0
  289. package/dist/esm/start/platform/data/sqlNameMappings.js +92 -0
  290. package/dist/esm/start/platform/data/transformations.d.ts +97 -0
  291. package/dist/esm/start/platform/data/transformations.js +262 -0
  292. package/dist/esm/start/platform/data/types.d.ts +94 -0
  293. package/dist/esm/start/platform/data/types.js +14 -0
  294. package/dist/esm/start/platform/local.d.ts +6 -0
  295. package/dist/esm/start/platform/local.js +18 -0
  296. package/dist/esm/start/platform/meta.d.ts +3 -0
  297. package/dist/esm/start/platform/meta.js +33 -0
  298. package/dist/esm/start/platform/outbound.d.ts +17 -0
  299. package/dist/esm/start/platform/outbound.js +510 -0
  300. package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
  301. package/dist/esm/start/platform/redactSecrets.js +156 -0
  302. package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
  303. package/dist/esm/start/platform/redactSecrets.test.js +151 -0
  304. package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
  305. package/dist/esm/start/platform/requestSecrets.js +41 -0
  306. package/dist/esm/start/platform/runLog.d.ts +40 -0
  307. package/dist/esm/start/platform/runLog.js +149 -0
  308. package/dist/esm/start/platform/services.d.ts +7 -0
  309. package/dist/esm/start/platform/services.js +46 -0
  310. package/dist/esm/start/platform/steps.d.ts +9 -0
  311. package/dist/esm/start/platform/steps.js +60 -0
  312. package/dist/esm/start/platform/telemetry.d.ts +13 -0
  313. package/dist/esm/start/platform/telemetry.js +71 -0
  314. package/dist/esm/start/platform/transport.d.ts +28 -0
  315. package/dist/esm/start/platform/transport.js +59 -0
  316. package/dist/esm/start/platformHead.d.ts +23 -0
  317. package/dist/esm/start/platformHead.js +133 -0
  318. package/dist/esm/start/previewClaim.d.ts +6 -0
  319. package/dist/esm/start/previewClaim.js +24 -0
  320. package/dist/esm/start/protocol.d.ts +19 -0
  321. package/dist/esm/start/protocol.js +27 -0
  322. package/dist/esm/start/roles.d.ts +12 -0
  323. package/dist/esm/start/roles.js +27 -0
  324. package/dist/esm/start/router.d.ts +44 -0
  325. package/dist/esm/start/router.js +280 -0
  326. package/dist/esm/start/serve/authHooks.d.ts +7 -0
  327. package/dist/esm/start/serve/authHooks.js +18 -0
  328. package/dist/esm/start/serve/demo.d.ts +9 -0
  329. package/dist/esm/start/serve/demo.js +24 -0
  330. package/dist/esm/start/serve/fetch.d.ts +1 -0
  331. package/dist/esm/start/serve/fetch.js +6 -0
  332. package/dist/esm/start/serve/instance.d.ts +12 -0
  333. package/dist/esm/start/serve/instance.js +134 -0
  334. package/dist/esm/start/serve/invoke.d.ts +13 -0
  335. package/dist/esm/start/serve/invoke.js +126 -0
  336. package/dist/esm/start/serve/local/load.d.ts +8 -0
  337. package/dist/esm/start/serve/local/load.js +44 -0
  338. package/dist/esm/start/serve/local/provider.d.ts +25 -0
  339. package/dist/esm/start/serve/local/provider.js +188 -0
  340. package/dist/esm/start/serve/local/signIn.d.ts +28 -0
  341. package/dist/esm/start/serve/local/signIn.js +123 -0
  342. package/dist/esm/start/serve/pageHead.d.ts +20 -0
  343. package/dist/esm/start/serve/pageHead.js +34 -0
  344. package/dist/esm/start/serve/provider.d.ts +19 -0
  345. package/dist/esm/start/serve/provider.js +78 -0
  346. package/dist/esm/start/serve/requestEnv.d.ts +2 -0
  347. package/dist/esm/start/serve/requestEnv.js +84 -0
  348. package/dist/esm/start/serve/scope.d.ts +18 -0
  349. package/dist/esm/start/serve/scope.js +67 -0
  350. package/dist/esm/start/serve/server.d.ts +56 -0
  351. package/dist/esm/start/serve/server.js +297 -0
  352. package/dist/esm/start/serve/uploads.d.ts +2 -0
  353. package/dist/esm/start/serve/uploads.js +49 -0
  354. package/dist/esm/start/serve/worker.d.ts +6 -0
  355. package/dist/esm/start/serve/worker.js +12 -0
  356. package/dist/esm/start/types.d.ts +373 -0
  357. package/dist/esm/start/types.js +1 -0
  358. package/dist/esm/start/version.d.ts +1 -0
  359. package/dist/esm/start/version.js +2 -0
  360. package/dist/esm/steps/index.d.ts +8 -8
  361. package/dist/esm/steps/index.js +54 -54
  362. package/dist/esm/steps/index.test.js +220 -220
  363. package/dist/esm/sync/index.d.ts +1 -1
  364. package/dist/esm/sync/index.js +32 -31
  365. package/dist/esm/sync/lib.d.ts +15 -8
  366. package/dist/esm/sync/lib.js +656 -665
  367. package/dist/esm/sync/lib.test.js +81 -14
  368. package/dist/esm/sync/sdkNames.d.ts +67 -9
  369. package/dist/esm/sync/sdkNames.js +94 -30
  370. package/dist/esm/sync/sdkNames.test.js +192 -116
  371. package/dist/esm/types/fields.d.ts +1 -1
  372. package/dist/esm/types/fields.js +106 -98
  373. package/dist/esm/types/index.d.ts +2 -2
  374. package/dist/esm/types/index.js +2 -2
  375. package/dist/esm/types/tables.d.ts +1 -1
  376. package/dist/esm/types/tables.js +2 -2
  377. package/dist/esm/upload/index.js +89 -24
  378. package/dist/esm/upload/index.test.js +104 -1
  379. package/dist/esm/vite/domTagNames.js +252 -252
  380. package/dist/esm/vite/index.d.ts +1 -1
  381. package/dist/esm/vite/index.js +56 -47
  382. package/dist/esm/vite/index.test.js +10 -2
  383. package/package.json +129 -16
  384. package/dist/cjs/auth-server/index.d.ts +0 -369
  385. package/dist/cjs/auth-server/index.js +0 -119
  386. package/dist/cjs/meta/index.d.ts +0 -14
  387. package/dist/cjs/meta/index.js +0 -12
  388. package/dist/cjs/notifications/index.d.ts +0 -25
  389. package/dist/cjs/notifications/index.js +0 -12
  390. package/dist/esm/auth-server/index.d.ts +0 -369
  391. package/dist/esm/auth-server/index.js +0 -116
  392. package/dist/esm/meta/index.d.ts +0 -14
  393. package/dist/esm/meta/index.js +0 -8
  394. package/dist/esm/notifications/index.d.ts +0 -25
  395. package/dist/esm/notifications/index.js +0 -8
@@ -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,487 @@
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\/backend(\/|$)/,
60
+ fix: "it's classic's server module: import ZiteError and the rest from zitejs/start",
61
+ },
62
+ {
63
+ pattern: /^react-router(-dom)?(\/|$)/,
64
+ fix: 'use @tanstack/react-router instead: file routes in src/routes, and its Link and useNavigate',
65
+ },
66
+ {
67
+ pattern: /^cloudflare:workers$/,
68
+ fix: 'read process.env inside a handler instead',
69
+ },
70
+ {
71
+ pattern: /^zitejs\/signin(\/|$)/,
72
+ 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",
73
+ },
74
+ ];
75
+ /** @internal */
76
+ export const REFUSED_IMPORTS = REFUSED.map(({ pattern }) => pattern);
77
+ 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";
78
+ /**
79
+ * @internal Zite's own message for a refused import, naming the fix; undefined leaves TanStack's, whose suggestions
80
+ * would send an agent to a raw createServerFn or a `.client.ts` file.
81
+ */
82
+ export const refusedImportMessage = (violation, root) => {
83
+ const fix = (violation.type === 'specifier'
84
+ ? REFUSED.find(({ pattern }) => pattern.test(violation.specifier))?.fix
85
+ : undefined) ??
86
+ (violation.envType === 'client' ? SERVER_CODE_FIX : undefined);
87
+ if (!fix)
88
+ return undefined;
89
+ const rel = (file) => path.isAbsolute(file)
90
+ ? path.relative(root, file).split(path.sep).join('/')
91
+ : file;
92
+ const loc = violation.importerLoc;
93
+ const file = rel(loc?.file ?? violation.importer);
94
+ const where = loc ? `${file}:${loc.line}:${loc.column}` : file;
95
+ return [
96
+ `[zite] ${where} imports "${rel(violation.specifier)}": ${fix}.`,
97
+ ...(violation.snippet ? ['', ...violation.snippet.lines] : []),
98
+ ].join('\n');
99
+ };
100
+ /** @internal The workspace's zite.schema.json as a server build carries it; null without one, a throw for one it can't read. */
101
+ export const workspaceSchemaNamesOf = (appDir) => {
102
+ const file = path.join(appDir, WORKSPACE_SCHEMA_FILE);
103
+ if (!existsSync(file))
104
+ return null;
105
+ try {
106
+ return schemaNamesOf(JSON.parse(readFileSync(file, 'utf-8')));
107
+ }
108
+ catch (error) {
109
+ throw new Error(`[zite] the workspace's zite.schema.json can't be read: ${error instanceof Error ? error.message : String(error)}`);
110
+ }
111
+ };
112
+ // 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.
113
+ const readJson = (file, narrow) => {
114
+ let json;
115
+ try {
116
+ json = JSON.parse(readFileSync(file, 'utf-8'));
117
+ }
118
+ catch {
119
+ return undefined;
120
+ }
121
+ return narrow(json);
122
+ };
123
+ /** @internal The app's Airtable integrations, from its own and its workspace's zite.config.json and zite.lock. */
124
+ export const builtAirtableSettingsOf = (appDir) => airtableSettingsFrom({
125
+ appConfig: readJson(path.join(appDir, APP_CONFIG_FILE), configFileOf),
126
+ appLock: readJson(path.join(appDir, APP_LOCK_FILE), lockFileOf),
127
+ workspaceConfig: readJson(path.join(appDir, WORKSPACE_CONFIG_FILE), configFileOf),
128
+ workspaceLock: readJson(path.join(appDir, WORKSPACE_LOCK_FILE), lockFileOf),
129
+ hasSchema: existsSync(path.join(appDir, WORKSPACE_SCHEMA_FILE)),
130
+ });
131
+ /** @internal A workspace's zite.schema.json as the platform's `nameMappings`: the SDK names `.zite/db.ts` was generated with. */
132
+ export const workspaceNameMappingsOf = (raw) => nameMappingsOf(schemaNamesOf(raw));
133
+ /**
134
+ * @internal The sign-in settings `zitejs dev` wrote for the app, for the module `local` mounts; null without them, or
135
+ * when the app's env sets `ZITE_DEV_USER`, whose stand-in wins.
136
+ */
137
+ export const devSignInOf = (appDir, appEnv) => {
138
+ if (appEnv.ZITE_DEV_USER)
139
+ return null;
140
+ let written;
141
+ try {
142
+ written = parseEnv(readFileSync(path.join(appDir, DEV_ENV_FILE), 'utf-8'));
143
+ }
144
+ catch {
145
+ return null;
146
+ }
147
+ const kept = Object.fromEntries(DEV_SIGNIN_KEYS.flatMap(key => (written[key] ? [[key, written[key]]] : [])));
148
+ return kept.ZITE_SIGNIN ? kept : null;
149
+ };
150
+ /** @internal The app's id in its zite.config.json, which `local` mints dev tokens for; null without one. */
151
+ export const devAppIdOf = (appDir) => {
152
+ try {
153
+ const { id } = JSON.parse(readFileSync(path.join(appDir, APP_CONFIG_FILE), 'utf-8'));
154
+ return typeof id === 'string' && id ? id : null;
155
+ }
156
+ catch {
157
+ return null;
158
+ }
159
+ };
160
+ // Platform-pinned Worker settings. The deploy uses its own fixed template, so
161
+ // these only have to match it; apps don't carry a wrangler config.
162
+ const WORKER_COMPATIBILITY_DATE = '2026-09-25';
163
+ const WORKER_COMPATIBILITY_FLAGS = ['nodejs_compat'];
164
+ // Resolved from the app at build time; zitejs doesn't depend on it.
165
+ const loadCloudflare = async (main) => {
166
+ const { cloudflare } = (await import('@cloudflare/vite-plugin'));
167
+ return cloudflare({
168
+ viteEnvironment: { name: 'ssr' },
169
+ config: {
170
+ name: 'zite-app',
171
+ main,
172
+ compatibility_date: WORKER_COMPATIBILITY_DATE,
173
+ compatibility_flags: WORKER_COMPATIBILITY_FLAGS,
174
+ },
175
+ });
176
+ };
177
+ /** The one plugin a Zite app's `vite.config.ts` uses. */
178
+ export function zite(options = {}) {
179
+ const serverEntry = options.serverEntry ?? START_SERVER_ENTRY;
180
+ // Platform-owned, so they're rewritten whenever they differ. Sandboxes run the
181
+ // image's zitejs for `generate`, which may predate Start; the plugin can't.
182
+ const appDir = process.cwd();
183
+ if (!options.serverEntry) {
184
+ writeIfChanged(appDir, START_SERVER_ENTRY, renderStartServerEntry(options.cloudflare === false ? 'node' : 'cloudflare'));
185
+ }
186
+ writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)));
187
+ // Every server function TanStack's compiler found, from its own hook, by id.
188
+ const ids = new Map();
189
+ const compileZitejs = {
190
+ name: 'zite:compile-zitejs',
191
+ // The factories must go through TanStack's compiler in both environments.
192
+ // The peer dependency gets zitejs crawled already; this keeps it true if an
193
+ // install drops that. A Node build bundles everything, so externalized
194
+ // libraries can't load the root's React 18 renderer.
195
+ config: (config, { command, mode }) => {
196
+ const root = path.resolve(config.root ?? '.');
197
+ // The `local` provider reads process.env. In workerd, Cloudflare's plugin sets it from the app's .env; on Node, this does.
198
+ if (command === 'serve' && options.cloudflare === false) {
199
+ Object.assign(process.env, loadEnv(mode, root, [
200
+ 'ZITE_DEV_',
201
+ 'ZITE_URLS',
202
+ 'ZITE_SIGNIN',
203
+ 'ZITE_AUTH_SECRET',
204
+ ]));
205
+ }
206
+ const src = `${path.join(root, 'src')}/`;
207
+ return {
208
+ ssr: { noExternal: options.cloudflare === false ? true : ['zitejs'] },
209
+ optimizeDeps: { exclude: ['zitejs'] },
210
+ resolve: {
211
+ // `@/` as in classic apps and shadcn, `~/` as in TanStack's templates.
212
+ alias: [
213
+ { find: /^@\//, replacement: src },
214
+ { find: /^~\//, replacement: src },
215
+ // The workspace SDKs `zitejs generate` writes, as classic apps map them.
216
+ {
217
+ find: /^zitejs\/db$/,
218
+ replacement: path.join(root, '../../.zite/db.ts'),
219
+ },
220
+ {
221
+ find: /^zitejs\/integrations$/,
222
+ replacement: path.join(root, '.zite/integrations/index.ts'),
223
+ },
224
+ {
225
+ find: /^zitejs\/email$/,
226
+ replacement: path.join(root, '.zite/integrations/email.ts'),
227
+ },
228
+ {
229
+ find: /^zitejs\/meta$/,
230
+ replacement: path.join(root, '.zite/meta.ts'),
231
+ },
232
+ // Classic's actions run on better-auth's client; Start's call the sign-in module's routes.
233
+ { find: /^zitejs\/auth$/, replacement: 'zitejs/start/auth' },
234
+ ],
235
+ // Shared workspace libraries resolve from the root, where classic apps
236
+ // keep React 18; recharts 2 needs the app's react-is 19 or drops series.
237
+ dedupe: ['react-is'],
238
+ },
239
+ };
240
+ },
241
+ // Each new isolate loads the whole server bundle, so its size is cold-start
242
+ // time; Vite leaves SSR output unminified. Under `vite dev`, Cloudflare's
243
+ // plugin would pre-bundle zitejs's server entry, past the modules below
244
+ // that fill zitejs's registries and workspace names.
245
+ configEnvironment: (name, config, { command }) => name !== 'ssr'
246
+ ? undefined
247
+ : {
248
+ ...(options.cloudflare !== false && {
249
+ build: {
250
+ ...(config.build?.minify === undefined && { minify: true }),
251
+ // V8 keeps a module with any character past Latin-1 as two bytes a character, and every byte of
252
+ // script is isolate heap. Escaped, the measured server bundles took 13-17% less.
253
+ rolldownOptions: { output: { charset: 'ascii' } },
254
+ },
255
+ }),
256
+ ...(command === 'serve' && {
257
+ optimizeDeps: { exclude: ['zitejs'] },
258
+ }),
259
+ },
260
+ };
261
+ // Each server function's `description` option, by name, and each route's file, by route id: for the editor.
262
+ const descriptions = new Map();
263
+ const routeFiles = new Map();
264
+ const srcDir = `${path.join(appDir, 'src')}${path.sep}`;
265
+ const functionIds = {
266
+ name: 'zite:function-ids',
267
+ apply: 'build',
268
+ transform(code, id) {
269
+ if (this.environment?.config.consumer !== 'server' ||
270
+ !id.startsWith(srcDir))
271
+ return;
272
+ const file = id.split('?')[0];
273
+ const routeId = FILE_ROUTE_ID.exec(code)?.[2];
274
+ if (routeId && !id.includes('?'))
275
+ routeFiles.set(routeId, path.relative(appDir, file).split(path.sep).join('/'));
276
+ if (code.includes('description')) {
277
+ try {
278
+ for (const [name, text] of factoryDescriptions(this.parse(code)))
279
+ descriptions.set(name, text);
280
+ }
281
+ catch {
282
+ // An unreadable module shows no descriptions.
283
+ }
284
+ }
285
+ },
286
+ generateBundle(_, bundle) {
287
+ const described = Object.fromEntries([...descriptions].filter(([name]) => ids.has(name)));
288
+ // Every module the workflow registry imports, hashed over its graph: describe gives each provider trigger its module's.
289
+ const server = this.environment?.config.consumer === 'server';
290
+ const registry = server
291
+ ? [...this.getModuleIds()].find(id => WORKFLOW_REGISTRY.test(id.split('?')[0]))
292
+ : undefined;
293
+ const registered = registry
294
+ ? (this.getModuleInfo(registry)?.dynamicallyImportedIds ?? [])
295
+ : [];
296
+ const hashes = registrationHashes(appDir, registered, id => this.getModuleInfo(id));
297
+ const facts = {
298
+ internal: readJson(path.join(appDir, APP_CONFIG_FILE), json => json?.accessMode) === 'internal',
299
+ automation: sourceRootOf(appDir) === 'automations',
300
+ };
301
+ for (const chunk of Object.values(bundle)) {
302
+ if (chunk.type !== 'chunk')
303
+ continue;
304
+ if (chunk.code.includes(FN_IDS_TOKEN))
305
+ chunk.code = chunk.code.replace(FN_IDS_TOKEN, () => asciiOnly([...ids.keys()].join(',')));
306
+ chunk.code = chunk.code
307
+ .replace(FN_DESCRIPTIONS_LITERAL, () => splicedLiteral(described))
308
+ .replace(ROUTE_FILES_LITERAL, () => splicedLiteral(Object.fromEntries(routeFiles)))
309
+ .replace(REGISTRATION_HASHES_LITERAL, () => splicedLiteral(hashes))
310
+ .replace(APP_FACTS_LITERAL, () => splicedLiteral(facts));
311
+ }
312
+ },
313
+ };
314
+ const workflowRegistry = {
315
+ name: 'zite:workflow-registry',
316
+ load: id => WORKFLOW_REGISTRY.test(id.split('?')[0])
317
+ ? renderWorkflowModules(appDir, workflowFiles(appDir))
318
+ : undefined,
319
+ };
320
+ const authHooksRegistry = {
321
+ name: 'zite:auth-hooks',
322
+ load: id => {
323
+ if (!AUTH_HOOKS_REGISTRY.test(id.split('?')[0]))
324
+ return undefined;
325
+ const file = path.join(appDir, AUTH_HOOKS_FILE);
326
+ return existsSync(file)
327
+ ? `export const authHooksModule = () => import(${JSON.stringify(file)});\n`
328
+ : 'export const authHooksModule = null;\n';
329
+ },
330
+ };
331
+ // The names the build's `zitejs/db` was generated with, from the same commit's schema. Only the server's: a browser
332
+ // never translates a data call, and its bundle carries no table or field id.
333
+ let serving = false;
334
+ const workspaceSchema = {
335
+ name: 'zite:workspace-schema',
336
+ configResolved(config) {
337
+ serving = config.command === 'serve';
338
+ },
339
+ load(id) {
340
+ if (!WORKSPACE_SCHEMA_MODULE.test(id.split('?')[0]))
341
+ return undefined;
342
+ this.addWatchFile(path.join(appDir, WORKSPACE_SCHEMA_FILE));
343
+ let names = null;
344
+ try {
345
+ if (this.environment?.config.consumer === 'server')
346
+ names = workspaceSchemaNamesOf(appDir);
347
+ }
348
+ catch (error) {
349
+ // A build fails rather than ship names its client wasn't written against; `vite dev` carries on mid-edit.
350
+ if (!serving)
351
+ throw error;
352
+ }
353
+ return `export const workspaceSchemaNames = ${JSON.stringify(names)};\n`;
354
+ },
355
+ };
356
+ // The integrations the app runs itself, from the same commit's config, and only on the server, which calls them.
357
+ const airtableSettings = {
358
+ name: 'zite:airtable-settings',
359
+ load(id) {
360
+ if (!AIRTABLE_SETTINGS_MODULE.test(id.split('?')[0]))
361
+ return undefined;
362
+ for (const file of [
363
+ APP_CONFIG_FILE,
364
+ APP_LOCK_FILE,
365
+ WORKSPACE_CONFIG_FILE,
366
+ WORKSPACE_LOCK_FILE,
367
+ ])
368
+ this.addWatchFile(path.join(appDir, file));
369
+ const settings = this.environment?.config.consumer === 'server'
370
+ ? builtAirtableSettingsOf(appDir)
371
+ : null;
372
+ return `export const builtAirtableSettings = ${JSON.stringify(settings)};\n`;
373
+ },
374
+ };
375
+ // The app's Settings for its pages off Zite, where no host sends them. Only the server renders a page's head.
376
+ const siteHead = {
377
+ name: 'zite:site-head',
378
+ load(id) {
379
+ if (!SITE_HEAD_MODULE.test(id.split('?')[0]))
380
+ return undefined;
381
+ this.addWatchFile(path.join(appDir, APP_CONFIG_FILE));
382
+ const head = this.environment?.config.consumer === 'server'
383
+ ? (readJson(path.join(appDir, APP_CONFIG_FILE), siteHeadOf) ?? null)
384
+ : null;
385
+ return `export const builtSiteHead = ${JSON.stringify(head)};\n`;
386
+ },
387
+ };
388
+ // Under `vite dev` only: a published build is never `local`'s to mint for.
389
+ const devApp = {
390
+ name: 'zite:dev-app',
391
+ apply: 'serve',
392
+ load(id) {
393
+ if (!DEV_APP_MODULE.test(id.split('?')[0]))
394
+ return undefined;
395
+ this.addWatchFile(path.join(appDir, APP_CONFIG_FILE));
396
+ return `export const devAppId = ${JSON.stringify(devAppIdOf(appDir))};\n`;
397
+ },
398
+ };
399
+ // Under `vite dev` only, and only to the server: the secret seals the session cookie, and never reaches a browser.
400
+ let devEnv = {};
401
+ const devSignIn = {
402
+ name: 'zite:dev-signin',
403
+ apply: 'serve',
404
+ configResolved(config) {
405
+ const envDir = typeof config.envDir === 'string' ? config.envDir : config.root;
406
+ devEnv = {
407
+ ...loadEnv(config.mode, envDir, ['ZITE_DEV_USER']),
408
+ ...process.env,
409
+ };
410
+ },
411
+ load(id) {
412
+ if (!DEV_SIGNIN_MODULE.test(id.split('?')[0]))
413
+ return undefined;
414
+ this.addWatchFile(path.join(appDir, DEV_ENV_FILE));
415
+ const settings = this.environment?.config.consumer === 'server'
416
+ ? devSignInOf(appDir, devEnv)
417
+ : null;
418
+ return `export const devSignIn = ${JSON.stringify(settings)};\n`;
419
+ },
420
+ };
421
+ return [
422
+ // First, so ids name lines in the source, before TanStack splits a route's component out of it.
423
+ ziteId(),
424
+ tanstackStart({
425
+ // TanStack resolves these from `src/`.
426
+ server: { entry: `../${serverEntry.replace(/\.ts$/, '')}` },
427
+ start: { entry: `../${START_INSTANCE_ENTRY.replace(/\.ts$/, '')}` },
428
+ serverFns: {
429
+ generateFunctionId: ({ filename, functionName }) => {
430
+ const id = functionName.replace(/_createServerFn_handler$/, '');
431
+ if (/(^|\/)node_modules\//.test(filename)) {
432
+ throw new Error(`[zite] ${filename} defines server function ${id}; dependencies can't ship server functions`);
433
+ }
434
+ const existing = ids.get(id);
435
+ if (existing && existing !== filename) {
436
+ throw new Error(`[zite] server function name ${id} is used in both ${existing} and ${filename}`);
437
+ }
438
+ ids.set(id, filename);
439
+ return id;
440
+ },
441
+ },
442
+ importProtection: {
443
+ behavior: 'error',
444
+ // Thrown, it replaces TanStack's text; TanStack's schema types the violation unknown.
445
+ onViolation: violation => {
446
+ const message = refusedImportMessage(violation, appDir);
447
+ if (message)
448
+ throw new Error(message);
449
+ },
450
+ client: {
451
+ // Appended to TanStack's own.
452
+ specifiers: [
453
+ ...REFUSED_IMPORTS,
454
+ 'zitejs/start/fetch',
455
+ 'zitejs/start/server',
456
+ 'zitejs/start/worker',
457
+ 'zitejs/start/describe',
458
+ 'zitejs/runtime',
459
+ ],
460
+ // Replaces TanStack's list, so its `**/*.server.*` is restated. File
461
+ // patterns also catch `zitejs/db`, `zitejs/integrations` and `zitejs/meta`,
462
+ // which the aliases above rewrite before specifiers are matched.
463
+ files: [
464
+ '**/*.server.*',
465
+ '**/.zite/db.ts',
466
+ '**/.zite/integrations/**',
467
+ '**/.zite/meta.ts',
468
+ ],
469
+ },
470
+ // Replaces TanStack's empty list; its `**/*.client.*` files stay.
471
+ server: { specifiers: REFUSED_IMPORTS },
472
+ },
473
+ }),
474
+ options.cloudflare !== false ? loadCloudflare(serverEntry) : null,
475
+ options.cloudflare !== false ? sdkPatches() : null,
476
+ viteReact(),
477
+ compileZitejs,
478
+ functionIds,
479
+ workflowRegistry,
480
+ authHooksRegistry,
481
+ workspaceSchema,
482
+ airtableSettings,
483
+ siteHead,
484
+ devApp,
485
+ devSignIn,
486
+ ];
487
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ // zitejs/backend, zitejs/backend/base and zitejs/caller as a Start app's types see them, under the `zite-start`
2
+ // condition: classic's server modules, with nothing in them for a Start app. ZiteError and the rest come from
3
+ // zitejs/start, and server functions are called directly.
4
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,105 @@
1
+ // Classic's cases (restly packages/endpoint-setup/src/endpointErrors.test.ts), for the port in errors.ts.
2
+ import { describe, it, expect } from 'vitest';
3
+ import { toClientErrorMessage } from './errors.js';
4
+ describe('toClientErrorMessage', () => {
5
+ describe('live mode', () => {
6
+ it('preserves a signal the app throws for its own frontend to parse', () => {
7
+ // The regression case: apps throw structured messages as control flow
8
+ // and parse them client-side. Blanking this breaks the app silently.
9
+ expect(toClientErrorMessage('CLOTHES_CHANGE_PENDING:recAbc,recDef', 'live')).toBe('CLOTHES_CHANGE_PENDING:recAbc,recDef');
10
+ });
11
+ it('preserves user-facing copy the app author wrote', () => {
12
+ const message = 'Registration is missing child information. Please contact team@example.org';
13
+ expect(toClientErrorMessage(message, 'live')).toBe(message);
14
+ });
15
+ it('preserves incidental errors, which are no worse than a generic string', () => {
16
+ expect(toClientErrorMessage('window is not defined', 'live')).toBe('window is not defined');
17
+ });
18
+ it('replaces private-range IP addresses', () => {
19
+ expect(toClientErrorMessage('connect ECONNREFUSED 10.205.134.213:2507', 'live')).toBe('A service this app depends on is temporarily unavailable. Please try again.');
20
+ });
21
+ it('replaces internal service hostnames', () => {
22
+ expect(toClientErrorMessage('ConnectTimeoutError (attempted address: zite-shard-restly-server:2500, timeout: 10000ms)', 'live')).toBe('A service this app depends on is temporarily unavailable. Please try again.');
23
+ });
24
+ it('replaces internal service hostnames with no port, as DNS failures report them', () => {
25
+ expect(toClientErrorMessage('getaddrinfo ENOTFOUND workflow-runner', 'live')).toBe('A service this app depends on is temporarily unavailable. Please try again.');
26
+ });
27
+ it('replaces a portless hostname carrying a pod suffix', () => {
28
+ expect(toClientErrorMessage('getaddrinfo EAI_AGAIN workflow-runner-3l4c', 'live')).toBe('A service this app depends on is temporarily unavailable. Please try again.');
29
+ });
30
+ it('does not match a service name embedded in a longer token', () => {
31
+ // "app-runner" sits inside this, but it is the app's own resource name.
32
+ const message = 'Deployment my-app-runner-config failed';
33
+ expect(toClientErrorMessage(message, 'live')).toBe(message);
34
+ });
35
+ it("replaces Zite's AI billing notice, which is addressed to the app owner", () => {
36
+ expect(toClientErrorMessage('402 AI is paused: your organization is over its AI credit limit. To resume, increase your credits (upgrade your plan) or connect your own AI provider key (BYOK).', 'live')).toBe('AI features are temporarily unavailable. Please contact the app owner.');
37
+ });
38
+ it("replaces an upstream provider's billing state", () => {
39
+ expect(toClientErrorMessage('429 You have no credits remaining. Add credits to continue using the API at https://platform.openai.com/settings/organization/billing/.', 'live')).toBe('AI features are temporarily unavailable. Please contact the app owner.');
40
+ });
41
+ it("does not swallow an app's own copy about credits or quotas", () => {
42
+ // Narrowness check: the billing patterns key on our prefix and on the
43
+ // provider's URLs, so an app writing about its users' credit stays intact.
44
+ const message = 'You have exceeded your credit limit for this month.';
45
+ expect(toClientErrorMessage(message, 'live')).toBe(message);
46
+ });
47
+ it('does not treat a public IP as internal', () => {
48
+ const message = 'Request to 203.0.113.10:443 failed';
49
+ expect(toClientErrorMessage(message, 'live')).toBe(message);
50
+ });
51
+ it('replaces link-local addresses, which reach cloud metadata services', () => {
52
+ expect(toClientErrorMessage('connect ETIMEDOUT 169.254.169.254:80', 'live')).toBe('A service this app depends on is temporarily unavailable. Please try again.');
53
+ });
54
+ it('replaces IPv6 loopback, unique-local and link-local addresses', () => {
55
+ const unavailable = 'A service this app depends on is temporarily unavailable. Please try again.';
56
+ expect(toClientErrorMessage('connect ECONNREFUSED ::1', 'live')).toBe(unavailable);
57
+ expect(toClientErrorMessage('no route to fd12:3456:789a::1', 'live')).toBe(unavailable);
58
+ // fe80::/10 — the IPv6 counterpart to 169.254, and it turns up in the
59
+ // same container-networking failures.
60
+ expect(toClientErrorMessage('connect ETIMEDOUT fe80::1', 'live')).toBe(unavailable);
61
+ expect(toClientErrorMessage('no route to feba:1234::abcd', 'live')).toBe(unavailable);
62
+ });
63
+ it('replaces a bare localhost reference', () => {
64
+ expect(toClientErrorMessage('connect ECONNREFUSED localhost:2506', 'live')).toBe('A service this app depends on is temporarily unavailable. Please try again.');
65
+ });
66
+ });
67
+ describe('live mode — credentials', () => {
68
+ it('redacts a secret but keeps the rest of the message', () => {
69
+ // The whole point of redacting in place: the sentence around the
70
+ // credential is the app author's and still has to reach the user.
71
+ expect(toClientErrorMessage('Could not reach the roster database: postgres://svc:hunter2@db.example.com/prod', 'live')).toBe('Could not reach the roster database: postgres://svc:REDACTED@db.example.com/prod');
72
+ });
73
+ it('redacts a provider key inside otherwise user-facing copy', () => {
74
+ expect(toClientErrorMessage('Payment provider rejected the request (sk_live_abcdefghijklmnop1234)', 'live')).toBe('Payment provider rejected the request (REDACTED)');
75
+ });
76
+ it('still replaces the message when infrastructure detail survives redaction', () => {
77
+ // Both concerns in one message: the secret goes, and the internal
78
+ // hostname then triggers wholesale replacement.
79
+ expect(toClientErrorMessage('connect ECONNREFUSED base-runner:2500 using api_key=abc123def456', 'live')).toBe('A service this app depends on is temporarily unavailable. Please try again.');
80
+ });
81
+ });
82
+ describe('userFacingMessage', () => {
83
+ it('prefers the author-written message over the technical one', () => {
84
+ expect(toClientErrorMessage('Airtable findAll failed for tblIx0DJvbXjjfA42 after 3 retries', 'live', 'We could not load this week’s roster. Please try again shortly.')).toBe('We could not load this week’s roster. Please try again shortly.');
85
+ });
86
+ it('keeps the technical message in preview so the developer can debug', () => {
87
+ expect(toClientErrorMessage('Airtable findAll failed for tblIx0DJvbXjjfA42 after 3 retries', 'preview', 'We could not load this week’s roster.')).toBe('Airtable findAll failed for tblIx0DJvbXjjfA42 after 3 retries');
88
+ });
89
+ it('falls back to the thrown message when the author set none', () => {
90
+ expect(toClientErrorMessage('CLOTHES_CHANGE_PENDING:recAbc', 'live', undefined)).toBe('CLOTHES_CHANGE_PENDING:recAbc');
91
+ });
92
+ it('ignores an empty userFacingMessage rather than blanking the response', () => {
93
+ expect(toClientErrorMessage('Week #11 is now full', 'live', '')).toBe('Week #11 is now full');
94
+ });
95
+ });
96
+ describe('preview mode', () => {
97
+ it('passes infrastructure detail through so the developer can debug', () => {
98
+ const message = 'connect ECONNREFUSED 10.205.134.213:2507';
99
+ expect(toClientErrorMessage(message, 'preview')).toBe(message);
100
+ });
101
+ });
102
+ it('treats an unspecified mode as live', () => {
103
+ expect(toClientErrorMessage('connect ECONNREFUSED 10.205.134.213:2507', undefined)).toBe('A service this app depends on is temporarily unavailable. Please try again.');
104
+ });
105
+ });