zitejs 0.10.0-start.9 → 0.10.1-device.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (448) hide show
  1. package/dist/cjs/auth/actions.d.ts +28 -0
  2. package/dist/cjs/auth/actions.js +95 -0
  3. package/dist/cjs/auth/client.d.ts +357 -0
  4. package/dist/cjs/auth/client.js +71 -0
  5. package/dist/cjs/auth/config.js +9 -3
  6. package/dist/cjs/auth/index.d.ts +2 -249
  7. package/dist/cjs/auth/index.js +11 -108
  8. package/dist/cjs/auth/index.test.js +60 -0
  9. package/dist/cjs/auth/previewClaim.d.ts +7 -0
  10. package/dist/cjs/auth/previewClaim.js +16 -0
  11. package/dist/cjs/auth/profileUpdates.d.ts +9 -0
  12. package/dist/cjs/auth/profileUpdates.js +11 -0
  13. package/dist/cjs/auth/useAuth.test.js +1 -0
  14. package/dist/cjs/backend/index.d.ts +15 -9
  15. package/dist/cjs/backend/index.js +13 -13
  16. package/dist/cjs/backend/index.test.js +102 -102
  17. package/dist/cjs/bundle/index.d.ts +8 -0
  18. package/dist/cjs/bundle/index.js +38 -24
  19. package/dist/cjs/caller/index.js +37 -48
  20. package/dist/cjs/check/index.d.ts +20 -9
  21. package/dist/cjs/check/index.js +113 -88
  22. package/dist/cjs/check/start/routeTree.d.ts +8 -0
  23. package/dist/cjs/check/start/routeTree.js +118 -0
  24. package/dist/cjs/check/start/tsgo.d.ts +2 -0
  25. package/dist/cjs/check/start/tsgo.js +35 -0
  26. package/dist/cjs/cli.js +10 -4
  27. package/dist/cjs/client/index.d.ts +26 -2
  28. package/dist/cjs/client/index.js +25 -25
  29. package/dist/cjs/dev/index.js +79 -54
  30. package/dist/cjs/dev/signin.d.ts +16 -0
  31. package/dist/cjs/dev/signin.js +84 -0
  32. package/dist/cjs/index.d.ts +5 -5
  33. package/dist/cjs/integrations/client.d.ts +3 -3
  34. package/dist/cjs/integrations/client.js +5 -4
  35. package/dist/cjs/integrations/client.test-d.js +15 -15
  36. package/dist/cjs/integrations/index.d.ts +2 -2
  37. package/dist/cjs/integrations/rules.d.ts +1 -0
  38. package/dist/cjs/integrations/rules.js +48 -43
  39. package/dist/cjs/integrations/rules.test.js +60 -54
  40. package/dist/cjs/internal/appMode.d.ts +14 -0
  41. package/dist/cjs/internal/appMode.js +19 -0
  42. package/dist/cjs/internal/browserMode.d.ts +2 -0
  43. package/dist/cjs/internal/browserMode.js +18 -0
  44. package/dist/cjs/internal/deviceCache.d.ts +11 -0
  45. package/dist/cjs/internal/deviceCache.js +29 -0
  46. package/dist/cjs/internal/env.js +3 -2
  47. package/dist/cjs/internal/platformFetch.d.ts +2 -0
  48. package/dist/cjs/internal/platformFetch.js +14 -0
  49. package/dist/cjs/internal/reservedIds.d.ts +8 -0
  50. package/dist/cjs/internal/reservedIds.js +14 -0
  51. package/dist/cjs/internal/serviceUrls.d.ts +5 -0
  52. package/dist/cjs/internal/serviceUrls.js +14 -0
  53. package/dist/cjs/pdf/index.js +2 -1
  54. package/dist/cjs/query/deviceCache.d.ts +14 -0
  55. package/dist/cjs/query/deviceCache.js +304 -0
  56. package/dist/cjs/query/index.d.ts +19 -0
  57. package/dist/cjs/query/index.js +369 -0
  58. package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
  59. package/dist/cjs/runtime/index.d.ts +126 -39
  60. package/dist/cjs/runtime/index.js +32 -26
  61. package/dist/cjs/runtime/index.test.js +34 -34
  62. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +50 -0
  63. package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
  64. package/dist/cjs/sourceRoots.js +15 -15
  65. package/dist/cjs/sourceRoots.test.js +29 -27
  66. package/dist/cjs/start/{entries.d.ts → build/entries.d.ts} +9 -4
  67. package/dist/cjs/start/{entries.js → build/entries.js} +38 -21
  68. package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
  69. package/dist/cjs/start/build/placeholders/devApp.js +6 -0
  70. package/dist/cjs/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
  71. package/dist/cjs/start/{describeBuilt.js → describe/describeBuilt.js} +55 -17
  72. package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
  73. package/dist/cjs/start/platform/aiUsage.js +215 -0
  74. package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
  75. package/dist/cjs/start/platform/airtable/cache.js +93 -0
  76. package/dist/cjs/start/protocol.d.ts +19 -0
  77. package/dist/cjs/start/protocol.js +33 -0
  78. package/dist/cjs/start/serve/local/provider.d.ts +25 -0
  79. package/dist/cjs/start/serve/local/provider.js +196 -0
  80. package/dist/cjs/start/serve/provider.d.ts +19 -0
  81. package/dist/cjs/start/serve/provider.js +86 -0
  82. package/dist/cjs/start/types.d.ts +373 -0
  83. package/dist/cjs/start/types.js +2 -0
  84. package/dist/cjs/steps/index.d.ts +78 -0
  85. package/dist/cjs/steps/index.js +507 -0
  86. package/dist/cjs/steps/index.test.js +635 -0
  87. package/dist/cjs/sync/index.d.ts +1 -1
  88. package/dist/cjs/sync/index.js +28 -27
  89. package/dist/cjs/sync/lib.d.ts +15 -8
  90. package/dist/cjs/sync/lib.js +655 -655
  91. package/dist/cjs/sync/lib.test.js +177 -46
  92. package/dist/cjs/sync/sdkNames.d.ts +67 -9
  93. package/dist/cjs/sync/sdkNames.js +97 -31
  94. package/dist/cjs/sync/sdkNames.test.js +189 -113
  95. package/dist/cjs/types/fields.d.ts +9 -2
  96. package/dist/cjs/types/fields.js +110 -96
  97. package/dist/cjs/types/index.d.ts +2 -2
  98. package/dist/cjs/types/tables.d.ts +17 -1
  99. package/dist/cjs/upload/index.js +89 -24
  100. package/dist/cjs/upload/index.test.js +104 -1
  101. package/dist/cjs/vite/domTagNames.js +252 -252
  102. package/dist/cjs/vite/index.d.ts +1 -1
  103. package/dist/cjs/vite/index.js +87 -42
  104. package/dist/cjs/vite/index.test.js +36 -0
  105. package/dist/esm/auth/actions.d.ts +28 -0
  106. package/dist/esm/auth/actions.js +57 -0
  107. package/dist/esm/auth/client.d.ts +357 -0
  108. package/dist/esm/auth/client.js +67 -0
  109. package/dist/esm/auth/config.js +9 -3
  110. package/dist/esm/auth/index.d.ts +2 -249
  111. package/dist/esm/auth/index.js +2 -103
  112. package/dist/esm/auth/index.test.js +60 -0
  113. package/dist/esm/auth/previewClaim.d.ts +7 -0
  114. package/dist/esm/auth/previewClaim.js +12 -0
  115. package/dist/esm/auth/profileUpdates.d.ts +9 -0
  116. package/dist/esm/auth/profileUpdates.js +6 -0
  117. package/dist/esm/auth/useAuth.test.js +1 -0
  118. package/dist/esm/backend/index.d.ts +15 -9
  119. package/dist/esm/backend/index.js +13 -13
  120. package/dist/esm/backend/index.test.js +106 -106
  121. package/dist/esm/bundle/index.d.ts +8 -0
  122. package/dist/esm/bundle/index.js +37 -24
  123. package/dist/esm/caller/index.js +37 -48
  124. package/dist/esm/check/index.d.ts +20 -9
  125. package/dist/esm/check/index.js +117 -93
  126. package/dist/esm/check/start/routeTree.d.ts +8 -0
  127. package/dist/esm/check/start/routeTree.js +77 -0
  128. package/dist/esm/check/start/tsgo.d.ts +2 -0
  129. package/dist/esm/check/start/tsgo.js +29 -0
  130. package/dist/esm/cli.js +10 -4
  131. package/dist/esm/client/index.d.ts +26 -2
  132. package/dist/esm/client/index.js +25 -25
  133. package/dist/esm/dev/index.js +86 -61
  134. package/dist/esm/dev/signin.d.ts +16 -0
  135. package/dist/esm/dev/signin.js +80 -0
  136. package/dist/esm/index.d.ts +5 -5
  137. package/dist/esm/index.js +3 -3
  138. package/dist/esm/integrations/client.d.ts +3 -3
  139. package/dist/esm/integrations/client.js +6 -5
  140. package/dist/esm/integrations/client.test-d.js +19 -19
  141. package/dist/esm/integrations/index.d.ts +2 -2
  142. package/dist/esm/integrations/index.js +1 -1
  143. package/dist/esm/integrations/rules.d.ts +1 -0
  144. package/dist/esm/integrations/rules.js +48 -43
  145. package/dist/esm/integrations/rules.test.js +62 -56
  146. package/dist/esm/internal/appMode.d.ts +14 -0
  147. package/dist/esm/internal/appMode.js +13 -0
  148. package/dist/esm/internal/browserMode.d.ts +2 -0
  149. package/dist/esm/internal/browserMode.js +15 -0
  150. package/dist/esm/internal/deviceCache.d.ts +11 -0
  151. package/dist/esm/internal/deviceCache.js +24 -0
  152. package/dist/esm/internal/env.js +3 -2
  153. package/dist/esm/internal/platformFetch.d.ts +2 -0
  154. package/dist/esm/internal/platformFetch.js +9 -0
  155. package/dist/esm/internal/reservedIds.d.ts +8 -0
  156. package/dist/esm/internal/reservedIds.js +10 -0
  157. package/dist/esm/internal/serviceUrls.d.ts +5 -0
  158. package/dist/esm/internal/serviceUrls.js +10 -0
  159. package/dist/esm/pdf/index.js +2 -1
  160. package/dist/esm/query/deviceCache.d.ts +14 -0
  161. package/dist/esm/query/deviceCache.js +301 -0
  162. package/dist/esm/query/index.d.ts +19 -0
  163. package/dist/esm/query/index.js +366 -0
  164. package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
  165. package/dist/esm/runtime/index.d.ts +126 -39
  166. package/dist/esm/runtime/index.js +35 -29
  167. package/dist/esm/runtime/index.test.js +36 -36
  168. package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
  169. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +48 -0
  170. package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
  171. package/dist/esm/signin/conformance.d.ts +100 -0
  172. package/dist/esm/signin/conformance.js +616 -0
  173. package/dist/esm/signin/cookies.d.ts +28 -0
  174. package/dist/esm/signin/cookies.js +67 -0
  175. package/dist/esm/signin/encoding.d.ts +1 -0
  176. package/dist/esm/signin/encoding.js +12 -0
  177. package/dist/esm/signin/endpoints.d.ts +12 -0
  178. package/dist/esm/signin/endpoints.js +32 -0
  179. package/dist/esm/signin/http.d.ts +25 -0
  180. package/dist/esm/signin/http.js +106 -0
  181. package/dist/esm/signin/index.d.ts +8 -0
  182. package/dist/esm/signin/index.js +9 -0
  183. package/dist/esm/signin/keys.d.ts +35 -0
  184. package/dist/esm/signin/keys.js +230 -0
  185. package/dist/esm/signin/paths.d.ts +2 -0
  186. package/dist/esm/signin/paths.js +5 -0
  187. package/dist/esm/signin/seal.d.ts +19 -0
  188. package/dist/esm/signin/seal.js +47 -0
  189. package/dist/esm/signin/signin.d.ts +60 -0
  190. package/dist/esm/signin/signin.js +447 -0
  191. package/dist/esm/signin/transport.d.ts +112 -0
  192. package/dist/esm/signin/transport.js +1 -0
  193. package/dist/esm/signin/verifier.d.ts +2 -0
  194. package/dist/esm/signin/verifier.js +4 -0
  195. package/dist/esm/signin/verify.d.ts +83 -0
  196. package/dist/esm/signin/verify.js +142 -0
  197. package/dist/esm/sourceRoots.js +17 -17
  198. package/dist/esm/sourceRoots.test.js +34 -32
  199. package/dist/esm/start/access.d.ts +19 -0
  200. package/dist/esm/start/access.js +43 -0
  201. package/dist/esm/start/auth.d.ts +28 -0
  202. package/dist/esm/start/auth.js +33 -0
  203. package/dist/esm/start/automations/quiet.d.ts +2 -0
  204. package/dist/esm/start/automations/quiet.js +36 -0
  205. package/dist/esm/start/{registration.d.ts → automations/registration.d.ts} +1 -1
  206. package/dist/esm/start/{registration.js → automations/registration.js} +11 -7
  207. package/dist/esm/start/automations/steps.d.ts +29 -0
  208. package/dist/esm/start/automations/steps.js +95 -0
  209. package/dist/esm/start/automations/workflow.d.ts +83 -0
  210. package/dist/esm/start/automations/workflow.js +36 -0
  211. package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
  212. package/dist/esm/start/automations/workflow.test-d.js +130 -0
  213. package/dist/esm/start/automations/workflowRun.d.ts +130 -0
  214. package/dist/esm/start/automations/workflowRun.js +185 -0
  215. package/dist/esm/start/barrel.test-d.d.ts +10 -0
  216. package/dist/esm/start/barrel.test-d.js +6 -0
  217. package/dist/esm/start/{entries.d.ts → build/entries.d.ts} +9 -4
  218. package/dist/esm/start/{entries.js → build/entries.js} +38 -22
  219. package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
  220. package/dist/esm/start/build/placeholders/devApp.js +3 -0
  221. package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
  222. package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
  223. package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
  224. package/dist/esm/start/build/placeholders/siteHead.js +3 -0
  225. package/dist/esm/start/{workflowModules.js → build/placeholders/workflowModules.js} +1 -1
  226. package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
  227. package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
  228. package/dist/esm/start/build/registrationHash.d.ts +11 -0
  229. package/dist/esm/start/build/registrationHash.js +88 -0
  230. package/dist/esm/start/build/sdk/axios.d.ts +76 -0
  231. package/dist/esm/start/build/sdk/axios.js +253 -0
  232. package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
  233. package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
  234. package/dist/esm/start/build/sdk/undici.d.ts +34 -0
  235. package/dist/esm/start/build/sdk/undici.js +18 -0
  236. package/dist/esm/start/build/sdkPatches.d.ts +22 -0
  237. package/dist/esm/start/build/sdkPatches.js +430 -0
  238. package/dist/esm/start/build/siteHead.d.ts +26 -0
  239. package/dist/esm/start/build/siteHead.js +88 -0
  240. package/dist/esm/start/build/vite.d.ts +50 -0
  241. package/dist/esm/start/build/vite.js +491 -0
  242. package/dist/esm/start/classicOnly.d.ts +1 -0
  243. package/dist/esm/start/classicOnly.js +4 -0
  244. package/dist/esm/start/{describe.d.ts → describe/describe.d.ts} +44 -9
  245. package/dist/esm/start/describe/describe.js +372 -0
  246. package/dist/esm/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
  247. package/dist/esm/start/describe/describeBuilt.js +102 -0
  248. package/dist/esm/start/{descriptions.js → describe/descriptions.js} +17 -10
  249. package/dist/esm/start/errors.d.ts +15 -4
  250. package/dist/esm/start/errors.js +87 -28
  251. package/dist/esm/start/errors.test.js +47 -16
  252. package/dist/esm/start/factories.d.ts +14 -0
  253. package/dist/esm/start/factories.js +23 -0
  254. package/dist/esm/start/factories.test-d.d.ts +2 -1
  255. package/dist/esm/start/factories.test-d.js +52 -12
  256. package/dist/esm/start/failures.d.ts +7 -0
  257. package/dist/esm/start/failures.js +62 -0
  258. package/dist/esm/start/fnFactory.d.ts +16 -0
  259. package/dist/esm/start/fnFactory.js +1 -0
  260. package/dist/esm/start/host.d.ts +2 -2
  261. package/dist/esm/start/host.js +3 -3
  262. package/dist/esm/start/index.d.ts +10 -66
  263. package/dist/esm/start/index.js +7 -146
  264. package/dist/esm/start/login.d.ts +5 -0
  265. package/dist/esm/start/login.js +29 -0
  266. package/dist/esm/start/middlewareKind.d.ts +13 -0
  267. package/dist/esm/start/middlewareKind.js +9 -0
  268. package/dist/esm/start/platform/aiUsage.d.ts +29 -0
  269. package/dist/esm/start/platform/aiUsage.js +210 -0
  270. package/dist/esm/start/platform/airtable/built.d.ts +2 -0
  271. package/dist/esm/start/platform/airtable/built.js +3 -0
  272. package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
  273. package/dist/esm/start/platform/airtable/cache.js +89 -0
  274. package/dist/esm/start/{airtable → platform/airtable}/dispatch.d.ts +5 -2
  275. package/dist/esm/start/{airtable → platform/airtable}/dispatch.js +195 -119
  276. package/dist/esm/start/{airtable → platform/airtable}/formulas.d.ts +2 -1
  277. package/dist/esm/start/{airtable → platform/airtable}/formulas.js +51 -25
  278. package/dist/esm/start/platform/airtable/index.d.ts +6 -0
  279. package/dist/esm/start/platform/airtable/index.js +51 -0
  280. package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
  281. package/dist/esm/start/platform/airtable/settings.js +138 -0
  282. package/dist/esm/start/platform/analytics.d.ts +3 -0
  283. package/dist/esm/start/platform/analytics.js +59 -0
  284. package/dist/esm/start/platform/calls.d.ts +5 -0
  285. package/dist/esm/start/platform/calls.js +104 -0
  286. package/dist/esm/start/platform/caps.d.ts +9 -0
  287. package/dist/esm/start/platform/caps.js +35 -0
  288. package/dist/esm/start/platform/connections.d.ts +25 -0
  289. package/dist/esm/start/platform/connections.js +198 -0
  290. package/dist/esm/start/{data → platform/data}/baseRunner.d.ts +11 -6
  291. package/dist/esm/start/platform/data/baseRunner.js +117 -0
  292. package/dist/esm/start/{data → platform/data}/dispatch.d.ts +3 -2
  293. package/dist/esm/start/{data → platform/data}/dispatch.js +69 -51
  294. package/dist/esm/start/platform/data/fetch.d.ts +7 -0
  295. package/dist/esm/start/platform/data/fetch.js +9 -0
  296. package/dist/esm/start/platform/data/index.d.ts +27 -0
  297. package/dist/esm/start/platform/data/index.js +75 -0
  298. package/dist/esm/start/platform/data/names.d.ts +7 -0
  299. package/dist/esm/start/platform/data/names.js +18 -0
  300. package/dist/esm/start/{data → platform/data}/transformations.d.ts +0 -31
  301. package/dist/esm/start/{data → platform/data}/transformations.js +0 -56
  302. package/dist/esm/start/{data → platform/data}/types.d.ts +4 -1
  303. package/dist/esm/start/{data → platform/data}/types.js +2 -2
  304. package/dist/esm/start/platform/local.d.ts +6 -0
  305. package/dist/esm/start/platform/local.js +18 -0
  306. package/dist/esm/start/platform/meta.d.ts +3 -0
  307. package/dist/esm/start/platform/meta.js +33 -0
  308. package/dist/esm/start/platform/outbound.d.ts +17 -0
  309. package/dist/esm/start/platform/outbound.js +510 -0
  310. package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
  311. package/dist/esm/start/{redactSecrets.js → platform/redactSecrets.js} +32 -7
  312. package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
  313. package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
  314. package/dist/esm/start/platform/requestSecrets.js +41 -0
  315. package/dist/esm/start/platform/runLog.d.ts +40 -0
  316. package/dist/esm/start/platform/runLog.js +149 -0
  317. package/dist/esm/start/platform/services.d.ts +7 -0
  318. package/dist/esm/start/platform/services.js +46 -0
  319. package/dist/esm/start/platform/steps.d.ts +9 -0
  320. package/dist/esm/start/platform/steps.js +60 -0
  321. package/dist/esm/start/platform/telemetry.d.ts +13 -0
  322. package/dist/esm/start/platform/telemetry.js +71 -0
  323. package/dist/esm/start/platform/transport.d.ts +28 -0
  324. package/dist/esm/start/platform/transport.js +59 -0
  325. package/dist/esm/start/platformHead.d.ts +23 -0
  326. package/dist/esm/start/platformHead.js +133 -0
  327. package/dist/esm/start/previewClaim.d.ts +3 -7
  328. package/dist/esm/start/previewClaim.js +9 -17
  329. package/dist/esm/start/protocol.d.ts +19 -0
  330. package/dist/esm/start/protocol.js +27 -0
  331. package/dist/esm/start/roles.d.ts +12 -0
  332. package/dist/esm/start/roles.js +27 -0
  333. package/dist/esm/start/router.d.ts +27 -4
  334. package/dist/esm/start/router.js +221 -22
  335. package/dist/esm/start/serve/authHooks.js +18 -0
  336. package/dist/esm/start/serve/demo.d.ts +9 -0
  337. package/dist/esm/start/serve/demo.js +24 -0
  338. package/dist/esm/start/serve/fetch.d.ts +1 -0
  339. package/dist/esm/start/serve/fetch.js +6 -0
  340. package/dist/esm/start/{instance.d.ts → serve/instance.d.ts} +6 -5
  341. package/dist/esm/start/serve/instance.js +134 -0
  342. package/dist/esm/start/serve/invoke.d.ts +13 -0
  343. package/dist/esm/start/serve/invoke.js +126 -0
  344. package/dist/esm/start/serve/local/load.d.ts +8 -0
  345. package/dist/esm/start/serve/local/load.js +44 -0
  346. package/dist/esm/start/serve/local/provider.d.ts +25 -0
  347. package/dist/esm/start/serve/local/provider.js +188 -0
  348. package/dist/esm/start/serve/local/signIn.d.ts +28 -0
  349. package/dist/esm/start/serve/local/signIn.js +123 -0
  350. package/dist/esm/start/serve/pageHead.d.ts +20 -0
  351. package/dist/esm/start/serve/pageHead.js +34 -0
  352. package/dist/esm/start/serve/provider.d.ts +19 -0
  353. package/dist/esm/start/serve/provider.js +78 -0
  354. package/dist/esm/start/serve/requestEnv.d.ts +2 -0
  355. package/dist/esm/start/serve/requestEnv.js +84 -0
  356. package/dist/esm/start/serve/scope.d.ts +18 -0
  357. package/dist/esm/start/serve/scope.js +67 -0
  358. package/dist/esm/start/serve/server.d.ts +56 -0
  359. package/dist/esm/start/serve/server.js +297 -0
  360. package/dist/esm/start/serve/uploads.d.ts +2 -0
  361. package/dist/esm/start/serve/uploads.js +49 -0
  362. package/dist/esm/start/serve/worker.d.ts +6 -0
  363. package/dist/esm/start/serve/worker.js +12 -0
  364. package/dist/esm/start/types.d.ts +270 -56
  365. package/dist/esm/start/version.d.ts +1 -1
  366. package/dist/esm/start/version.js +1 -1
  367. package/dist/esm/steps/index.d.ts +78 -0
  368. package/dist/esm/steps/index.js +502 -0
  369. package/dist/esm/steps/index.test.d.ts +1 -0
  370. package/dist/esm/steps/index.test.js +633 -0
  371. package/dist/esm/sync/index.d.ts +1 -1
  372. package/dist/esm/sync/index.js +32 -31
  373. package/dist/esm/sync/lib.d.ts +15 -8
  374. package/dist/esm/sync/lib.js +659 -659
  375. package/dist/esm/sync/lib.test.js +177 -46
  376. package/dist/esm/sync/sdkNames.d.ts +67 -9
  377. package/dist/esm/sync/sdkNames.js +94 -30
  378. package/dist/esm/sync/sdkNames.test.js +192 -116
  379. package/dist/esm/types/fields.d.ts +9 -2
  380. package/dist/esm/types/fields.js +110 -96
  381. package/dist/esm/types/index.d.ts +2 -2
  382. package/dist/esm/types/index.js +2 -2
  383. package/dist/esm/types/tables.d.ts +17 -1
  384. package/dist/esm/types/tables.js +2 -2
  385. package/dist/esm/upload/index.js +89 -24
  386. package/dist/esm/upload/index.test.js +104 -1
  387. package/dist/esm/vite/domTagNames.js +252 -252
  388. package/dist/esm/vite/index.d.ts +1 -1
  389. package/dist/esm/vite/index.js +92 -47
  390. package/dist/esm/vite/index.test.js +36 -0
  391. package/package.json +106 -38
  392. package/dist/cjs/auth-server/index.d.ts +0 -369
  393. package/dist/cjs/auth-server/index.js +0 -119
  394. package/dist/cjs/check/start/describeRules.d.ts +0 -35
  395. package/dist/cjs/check/start/describeRules.js +0 -89
  396. package/dist/cjs/check/start/problem.d.ts +0 -11
  397. package/dist/cjs/check/start/problem.js +0 -5
  398. package/dist/cjs/check/start/sourceRules.d.ts +0 -3
  399. package/dist/cjs/check/start/sourceRules.js +0 -441
  400. package/dist/cjs/start/problems.d.ts +0 -19
  401. package/dist/cjs/start/problems.js +0 -11
  402. package/dist/esm/auth-server/index.d.ts +0 -369
  403. package/dist/esm/auth-server/index.js +0 -116
  404. package/dist/esm/check/start/describeRules.d.ts +0 -35
  405. package/dist/esm/check/start/describeRules.js +0 -86
  406. package/dist/esm/check/start/problem.d.ts +0 -11
  407. package/dist/esm/check/start/problem.js +0 -1
  408. package/dist/esm/check/start/sourceRules.d.ts +0 -3
  409. package/dist/esm/check/start/sourceRules.js +0 -438
  410. package/dist/esm/start/airtable/index.d.ts +0 -11
  411. package/dist/esm/start/airtable/index.js +0 -70
  412. package/dist/esm/start/authHooks.js +0 -10
  413. package/dist/esm/start/data/baseRunner.js +0 -83
  414. package/dist/esm/start/data/index.d.ts +0 -18
  415. package/dist/esm/start/data/index.js +0 -76
  416. package/dist/esm/start/describe.js +0 -204
  417. package/dist/esm/start/describeBuilt.js +0 -66
  418. package/dist/esm/start/instance.js +0 -80
  419. package/dist/esm/start/problems.d.ts +0 -19
  420. package/dist/esm/start/problems.js +0 -8
  421. package/dist/esm/start/redactSecrets.d.ts +0 -7
  422. package/dist/esm/start/runLog.d.ts +0 -8
  423. package/dist/esm/start/runLog.js +0 -76
  424. package/dist/esm/start/scope.d.ts +0 -15
  425. package/dist/esm/start/scope.js +0 -58
  426. package/dist/esm/start/server.d.ts +0 -55
  427. package/dist/esm/start/server.js +0 -317
  428. package/dist/esm/start/vite.d.ts +0 -9
  429. package/dist/esm/start/vite.js +0 -173
  430. package/dist/esm/start/worker.d.ts +0 -11
  431. package/dist/esm/start/worker.js +0 -20
  432. package/dist/esm/start/workflow.d.ts +0 -53
  433. package/dist/esm/start/workflow.js +0 -13
  434. package/dist/esm/start/workflow.test-d.js +0 -44
  435. package/dist/esm/start/workflowRun.d.ts +0 -80
  436. package/dist/esm/start/workflowRun.js +0 -108
  437. /package/dist/{esm/start/redactSecrets.test.d.ts → cjs/runtime/sendEmailParamsTypes.test-d.d.ts} +0 -0
  438. /package/dist/{esm/start/workflow.test-d.d.ts → cjs/steps/index.test.d.ts} +0 -0
  439. /package/dist/esm/start/{authHooksModule.d.ts → build/placeholders/authHooksModule.d.ts} +0 -0
  440. /package/dist/esm/start/{authHooksModule.js → build/placeholders/authHooksModule.js} +0 -0
  441. /package/dist/esm/start/{workflowModules.d.ts → build/placeholders/workflowModules.d.ts} +0 -0
  442. /package/dist/esm/start/{descriptions.d.ts → describe/descriptions.d.ts} +0 -0
  443. /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.d.ts +0 -0
  444. /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.js +0 -0
  445. /package/dist/esm/start/{data → platform/data}/sqlNameMappings.d.ts +0 -0
  446. /package/dist/esm/start/{data → platform/data}/sqlNameMappings.js +0 -0
  447. /package/dist/esm/start/{redactSecrets.test.js → platform/redactSecrets.test.js} +0 -0
  448. /package/dist/esm/start/{authHooks.d.ts → serve/authHooks.d.ts} +0 -0
@@ -1,9 +1,9 @@
1
- import type { ZiteTrigger } from "../backend/index.js";
2
- import { type AuthHookName } from "./authHooks.js";
3
- import type { LoadedWorkflow } from "./workflowRun.js";
4
- import type { WorkflowConfig } from "./workflow.js";
1
+ import type { ZiteTrigger } from '../../backend/index.js';
2
+ import { type AuthHookName } from '../serve/authHooks.js';
3
+ import { type LoadedTrigger, type LoadedWorkflow } from '../automations/workflowRun.js';
4
+ import { type AutomationConfig } from '../automations/workflow.js';
5
5
  export type Access = {
6
- kind: "signedIn" | "anyone" | "webhook" | "none";
6
+ kind: 'signedIn' | 'anyone' | 'webhook' | 'none';
7
7
  roles: string[];
8
8
  paused?: true;
9
9
  };
@@ -36,13 +36,17 @@ export type DescribedWorkflow = {
36
36
  id: string;
37
37
  file: string;
38
38
  description?: string;
39
- schedule?: WorkflowConfig["schedule"];
39
+ schedule?: AutomationConfig['schedule'];
40
40
  /** As declared, without a provider trigger's `subscribe` and `unsubscribe`. */
41
41
  trigger?: ZiteTrigger;
42
- /** A provider trigger's: whether it can be taken down, and a hash of both functions' code, so publish registers it again when they change. */
42
+ /**
43
+ * A provider trigger's: whether it can be taken down, its module, and a hash of everything that module runs, so
44
+ * publish registers it again when that changes.
45
+ */
43
46
  registration?: {
44
47
  unsubscribe: boolean;
45
48
  hash: string;
49
+ module: string;
46
50
  };
47
51
  problems: string[];
48
52
  };
@@ -53,7 +57,18 @@ export type Description = {
53
57
  workflows: DescribedWorkflow[];
54
58
  /** The hooks the app's `zite.auth.ts` defines. */
55
59
  authHooks: AuthHookName[];
60
+ /** What's wrong with the app as a whole, beside any one function, route or workflow. */
61
+ problems: string[];
62
+ };
63
+ /** What the build knows of the app beside its code: its access mode, and whether it's a standalone automation. */
64
+ export type AppFacts = {
65
+ internal: boolean;
66
+ automation: boolean;
56
67
  };
68
+ /** Written in by `zite()` at build; both false where it didn't build the app. */
69
+ export declare const builtAppFacts: () => AppFacts;
70
+ /** @internal What the app's access mode and a function's own input say of it. */
71
+ export declare const functionRules: ({ access, input }: DescribedFunction, facts: AppFacts) => string[];
57
72
  export declare function describeFunction(id: string, request: Request): Promise<DescribedFunction>;
58
73
  type RouteLike = {
59
74
  id: string;
@@ -72,14 +87,34 @@ type RouteLike = {
72
87
  };
73
88
  };
74
89
  export declare function describePages(routesById: Record<string, RouteLike>, files?: Record<string, string>): DescribedPage[];
75
- export declare function describeRoutes(routesById: Record<string, RouteLike>, files?: Record<string, string>): DescribedRoute[];
76
- export declare function describeWorkflows(workflows: LoadedWorkflow[]): DescribedWorkflow[];
90
+ export declare function describeRoutes(routesById: Record<string, RouteLike>, files?: Record<string, string>, facts?: AppFacts): DescribedRoute[];
91
+ /**
92
+ * A workflow's id is its export name: what the host invokes it by and the editor shows. `hashes` are the registration
93
+ * hashes zite() wrote in by module; `triggers`, every provider trigger the app's modules export, which places each
94
+ * automation's trigger in its module.
95
+ */
96
+ export declare function describeWorkflows(workflows: LoadedWorkflow[], { hashes, unfinished, triggers, }?: {
97
+ hashes?: Record<string, string>;
98
+ unfinished?: Array<{
99
+ id: string;
100
+ file: string;
101
+ }>;
102
+ triggers?: LoadedTrigger[];
103
+ }): DescribedWorkflow[];
77
104
  export declare function describeApp(opts: {
78
105
  fnIds: string[];
79
106
  descriptions?: Record<string, string>;
80
107
  routeFiles?: Record<string, string>;
108
+ /** By module, as the workflow registry names it. */
109
+ registrationHashes?: Record<string, string>;
81
110
  getRouter: () => unknown;
82
111
  request: Request;
83
112
  workflows?: LoadedWorkflow[];
113
+ unfinishedWorkflows?: Array<{
114
+ id: string;
115
+ file: string;
116
+ }>;
117
+ triggers?: LoadedTrigger[];
118
+ facts?: AppFacts;
84
119
  }): Promise<Description>;
85
120
  export {};
@@ -0,0 +1,372 @@
1
+ // Describes a built app by loading it, not by reading its source: each server
2
+ // function's real middleware chain, each server route's, and input schemas.
3
+ import { createMiddleware, flattenMiddlewares } from '@tanstack/react-start';
4
+ import { createSsrRpc } from '@tanstack/react-start/ssr-rpc';
5
+ import { runWithStartContext } from '@tanstack/start-storage-context';
6
+ import { z } from 'zod';
7
+ import { ziteMiddlewareKind, } from '../middlewareKind.js';
8
+ import { isZiteRouter } from '../router.js';
9
+ import { loadAuthHooks } from '../serve/authHooks.js';
10
+ import { loadProviderTriggers, } from '../automations/workflowRun.js';
11
+ import { isProviderTrigger, } from '../automations/workflow.js';
12
+ /** Written in by `zite()` at build; both false where it didn't build the app. */
13
+ export const builtAppFacts = () => {
14
+ try {
15
+ const facts = JSON.parse('__ZITE_APP_FACTS__');
16
+ return {
17
+ internal: facts.internal === true,
18
+ automation: facts.automation === true,
19
+ };
20
+ }
21
+ catch {
22
+ return { internal: false, automation: false };
23
+ }
24
+ };
25
+ // The host, TanStack and Cloudflare answer these before the app does.
26
+ const RESERVED_PATHS = [
27
+ /^\/_zite/,
28
+ /^\/__zite/,
29
+ /^\/_serverFn(\/|$)/,
30
+ /^\/cdn-cgi(\/|$)/,
31
+ /^\/auth(\/|$)/,
32
+ /^\/api\/auth(\/|$)/,
33
+ /^\/manifest\.webmanifest$/,
34
+ ];
35
+ const RESERVED_PATH = 'reserved-path: the platform answers this path before the app does; give the route another';
36
+ const WEBHOOK_PATH_PARAM = "webhook-path-param: a webhook route's path can't have parameters, because its URL is registered once; put the value in the body or query";
37
+ const OWNER_INPUTS = ['userId', 'ownerId'];
38
+ const inputProperties = (input) => {
39
+ const properties = input
40
+ ?.properties;
41
+ return properties && typeof properties === 'object'
42
+ ? Object.keys(properties)
43
+ : [];
44
+ };
45
+ /** @internal What the app's access mode and a function's own input say of it. */
46
+ export const functionRules = ({ access, input }, facts) => {
47
+ // A role may act for other users, which is what its middleware is for.
48
+ const owner = access.kind === 'signedIn' && access.roles.length === 0
49
+ ? inputProperties(input).find(key => OWNER_INPUTS.includes(key))
50
+ : undefined;
51
+ return [
52
+ ...(facts.internal && access.kind === 'anyone'
53
+ ? [
54
+ 'public-in-internal: anyone can call it, and this internal app signs everyone in; make it a signedInFn',
55
+ ]
56
+ : []),
57
+ ...(owner
58
+ ? [
59
+ `owner-from-input: it takes ${owner} as input, which any caller can set; use context.user.id, or if a role may act for other users, add role(id) to its middleware`,
60
+ ]
61
+ : []),
62
+ ];
63
+ };
64
+ const accessOf = (chain, problems) => {
65
+ const kinds = chain
66
+ .map(ziteMiddlewareKind)
67
+ .filter((k) => !!k);
68
+ const roles = kinds.flatMap(k => (k.kind === 'role' ? [k.role] : []));
69
+ const base = [
70
+ ...new Set(kinds.flatMap(k => k.kind === 'signedIn' || k.kind === 'anyone' || k.kind === 'webhook'
71
+ ? [k.kind]
72
+ : [])),
73
+ ];
74
+ if (base.length === 0) {
75
+ problems.push('access-missing: no signedIn, anyone or webhook middleware in its chain');
76
+ return { kind: 'none', roles };
77
+ }
78
+ if (base.length > 1)
79
+ problems.push(`access-conflict: ${base.join(' + ')}`);
80
+ const kind = base.includes('webhook')
81
+ ? 'webhook'
82
+ : base.includes('signedIn')
83
+ ? 'signedIn'
84
+ : 'anyone';
85
+ const paused = kinds.some(k => k.kind === 'webhook' && k.paused === true);
86
+ return paused ? { kind, roles, paused } : { kind, roles };
87
+ };
88
+ const jsonSchemaOf = (validator) => {
89
+ if (validator && typeof validator === 'object' && '_zod' in validator) {
90
+ try {
91
+ return z.toJSONSchema(validator);
92
+ }
93
+ catch {
94
+ return { unrepresentable: true };
95
+ }
96
+ }
97
+ return validator ? { opaque: true } : undefined;
98
+ };
99
+ // Describe walks functions one at a time, so one probe slot is enough.
100
+ let probe = null;
101
+ // The only global function middleware while describing: it records what it was
102
+ // handed and ends the call, so no app middleware or handler runs.
103
+ const describeProbe = createMiddleware({ type: 'function' }).server(({ serverFnMeta, method }) => {
104
+ if (probe)
105
+ Object.assign(probe, { meta: serverFnMeta, method, reached: true });
106
+ return 'zite:describe';
107
+ });
108
+ const SERVER_ONLY = "server-only: nothing in the browser calls it, and a server function that only other server functions call can't run. " +
109
+ 'Move the shared logic into a *.server.ts helper and call that.';
110
+ export async function describeFunction(id, request) {
111
+ let probeFailed;
112
+ let own;
113
+ probe = { reached: false };
114
+ // TanStack appends the function's own chain to the global middleware with
115
+ // `concat`. Recording what it appends gives the exact chain it would have run.
116
+ const functionMiddleware = Object.assign([describeProbe], {
117
+ concat: (chain) => {
118
+ own = chain;
119
+ return [describeProbe, ...chain];
120
+ },
121
+ });
122
+ const startContext = {
123
+ request,
124
+ startOptions: { functionMiddleware },
125
+ contextAfterGlobalMiddlewares: {},
126
+ handlerType: 'serverFn',
127
+ getRouter: () => {
128
+ throw new Error('describe has no router');
129
+ },
130
+ };
131
+ try {
132
+ await runWithStartContext(startContext, () => createSsrRpc(id)({ data: undefined, context: {} }));
133
+ }
134
+ catch (error) {
135
+ const message = error instanceof Error ? error.message : String(error);
136
+ // TanStack registers only functions something can call through it. One that
137
+ // only other server functions call isn't registered, and calling it fails.
138
+ if (message === `Server function info not found for ${id}`) {
139
+ probe = null;
140
+ return {
141
+ id,
142
+ access: { kind: 'none', roles: [] },
143
+ problems: [SERVER_ONLY],
144
+ };
145
+ }
146
+ probeFailed = `probe-failed: ${message}`;
147
+ }
148
+ const state = probe;
149
+ probe = null;
150
+ const problems = [];
151
+ // Fails closed: if TanStack stops appending, or the probe never runs, every
152
+ // function reports a problem and the build stops.
153
+ if (!state.reached || own === undefined)
154
+ problems.push('probe-not-first: chain could not be read');
155
+ const chain = flattenMiddlewares((own ?? [])).filter(m => m !== describeProbe);
156
+ if (!chain.some(m => ziteMiddlewareKind(m)?.kind === 'factory')) {
157
+ problems.push('raw-server-fn: write signedInFn({ method, description }) or publicFn({ method, description }) from zitejs/start instead of createServerFn');
158
+ }
159
+ // TanStack keeps the validator under `inputValidator` up to 1.168 and `validator` from 1.169 (Start 1.0).
160
+ const handlerStep = chain.at(-1);
161
+ const access = accessOf(chain, problems);
162
+ return {
163
+ id,
164
+ name: state.meta?.name,
165
+ file: state.meta?.filename,
166
+ method: state.method,
167
+ access,
168
+ input: jsonSchemaOf(handlerStep?.options?.validator ?? handlerStep?.options?.inputValidator),
169
+ // A chain the probe never read says nothing of the function: only why it failed does.
170
+ problems: probeFailed ? [probeFailed] : problems,
171
+ };
172
+ }
173
+ const ROOT_ROUTE_ID = '__root__';
174
+ // Pathless layouts have no path of their own, and a file with only server handlers is an API route.
175
+ export function describePages(routesById, files = {}) {
176
+ return Object.values(routesById).flatMap(route => {
177
+ const options = route.options ?? {};
178
+ if (route.id === ROOT_ROUTE_ID || options.path === undefined)
179
+ return [];
180
+ if (options.server?.handlers && !options.component)
181
+ return [];
182
+ const file = files[route.id];
183
+ return [{ id: route.id, path: route.fullPath, ...(file && { file }) }];
184
+ });
185
+ }
186
+ export function describeRoutes(routesById, files = {}, facts = { internal: false, automation: false }) {
187
+ const out = [];
188
+ for (const route of Object.values(routesById)) {
189
+ const server = route.options?.server;
190
+ if (!server?.handlers)
191
+ continue;
192
+ const problems = [];
193
+ const ancestry = [];
194
+ for (let r = route; r; r = r.parentRoute)
195
+ ancestry.unshift(r);
196
+ const routeMiddleware = ancestry.flatMap(r => r.options?.server?.middleware ?? []);
197
+ const handlers = (typeof server.handlers === 'function'
198
+ ? server.handlers({ createHandlers: d => d })
199
+ : server.handlers);
200
+ const methods = {};
201
+ for (const [method, handler] of Object.entries(handlers)) {
202
+ const own = typeof handler === 'function'
203
+ ? []
204
+ : (handler.middleware ?? []);
205
+ const chain = flattenMiddlewares([
206
+ ...routeMiddleware,
207
+ ...own,
208
+ ]);
209
+ const methodProblems = [];
210
+ methods[method] = accessOf(chain, methodProblems);
211
+ problems.push(...methodProblems.map(p => `${method}: ${p}`));
212
+ }
213
+ const file = files[route.id];
214
+ const description = route.options?.staticData?.description;
215
+ const described = typeof description === 'string' && description ? description : undefined;
216
+ if (!described)
217
+ problems.push('description-missing: add staticData: { description } for the editor');
218
+ if (RESERVED_PATHS.some(reserved => reserved.test(route.fullPath)))
219
+ problems.push(RESERVED_PATH);
220
+ if (route.fullPath.includes('$') &&
221
+ Object.values(methods).some(access => access.kind === 'webhook'))
222
+ problems.push(WEBHOOK_PATH_PARAM);
223
+ const open = Object.entries(methods).flatMap(([method, access]) => access.kind === 'anyone' ? [method] : []);
224
+ if (facts.internal && open.length > 0) {
225
+ problems.push(`public-in-internal: anyone can call ${open.join(', ')}, and this internal app signs everyone in; use signedIn`);
226
+ }
227
+ out.push({
228
+ path: route.fullPath,
229
+ ...(file && { file }),
230
+ ...(described && { description: described }),
231
+ methods,
232
+ problems,
233
+ });
234
+ }
235
+ return out;
236
+ }
237
+ const HANDLER_MISSING = 'workflow-handler-missing: give createAutomation its function with .handler(async (args) => { ... }), not in its config';
238
+ const TRIGGER_INLINE = 'trigger-inline: define the provider trigger with createProviderTrigger in a module of its own, export it, and pass it as trigger';
239
+ // A build zite() didn't hash: publish registers its triggers again every time rather than miss a change.
240
+ const unhashed = () => `unhashed:${crypto.randomUUID()}`;
241
+ /**
242
+ * A workflow's id is its export name: what the host invokes it by and the editor shows. `hashes` are the registration
243
+ * hashes zite() wrote in by module; `triggers`, every provider trigger the app's modules export, which places each
244
+ * automation's trigger in its module.
245
+ */
246
+ export function describeWorkflows(workflows, { hashes = {}, unfinished = [], triggers = [], } = {}) {
247
+ const described = workflows.map(({ id, file, workflow }) => {
248
+ const problems = [];
249
+ if (id === 'default')
250
+ problems.push('workflow-default-export: export it by name, which becomes its id');
251
+ const elsewhere = workflows.find(other => other.id === id && other.file !== file);
252
+ if (elsewhere)
253
+ problems.push(`duplicate-workflow: ${id} is also exported from ${elsewhere.file}`);
254
+ const { description, schedule, trigger } = workflow.config;
255
+ if (schedule)
256
+ return { id, file, description, schedule, problems };
257
+ if (!trigger ||
258
+ trigger.every !== undefined ||
259
+ trigger.events !== undefined) {
260
+ return { id, file, description, trigger, problems };
261
+ }
262
+ const { subscribe, unsubscribe, ...declared } = trigger;
263
+ const refused = (problem) => ({
264
+ id,
265
+ file,
266
+ description,
267
+ trigger: declared,
268
+ problems: [...problems, problem],
269
+ });
270
+ // The types refuse these, but a build doesn't typecheck.
271
+ if ('table' in declared || 'form' in declared)
272
+ return refused("trigger-unsupported: a Start automation can't take a database or form trigger yet");
273
+ if (!isProviderTrigger(trigger))
274
+ return refused(TRIGGER_INLINE);
275
+ const [module] = [
276
+ ...new Set(triggers.filter(t => t.trigger === trigger).map(t => t.file)),
277
+ ].sort();
278
+ if (!module)
279
+ return refused(TRIGGER_INLINE);
280
+ const beside = [
281
+ ...workflows
282
+ .filter(other => other.file === module)
283
+ .map(other => other.id),
284
+ ...triggers
285
+ .filter(other => other.file === module && other.trigger !== trigger)
286
+ .map(other => other.id),
287
+ ];
288
+ if (beside.length > 0) {
289
+ return refused(`trigger-module: ${module} also exports ${beside.join(', ')}; give the provider trigger a module of its own, so a change to the rest doesn't register it again`);
290
+ }
291
+ if (typeof subscribe !== 'function') {
292
+ return refused('workflow-trigger-unregistered: a provider trigger needs `subscribe` to register it with the provider');
293
+ }
294
+ const registration = {
295
+ unsubscribe: typeof unsubscribe === 'function',
296
+ hash: hashes[module] ?? unhashed(),
297
+ module,
298
+ };
299
+ return {
300
+ id,
301
+ file,
302
+ description,
303
+ trigger: declared,
304
+ registration,
305
+ problems,
306
+ };
307
+ });
308
+ return [
309
+ ...described,
310
+ ...unfinished.map(({ id, file }) => ({
311
+ id,
312
+ file,
313
+ problems: [HANDLER_MISSING],
314
+ })),
315
+ ];
316
+ }
317
+ const ONE_TRIGGER = (labels) => `one-trigger: an automation has one trigger, and this one has ${labels.length} (${labels.join(', ')}); a second trigger is a second automation`;
318
+ /** A standalone automation is one workflow on one trigger, as classic's is: each one past the first is refused. */
319
+ const oneTrigger = (workflows, routes) => {
320
+ const webhooks = routes.filter(route => Object.values(route.methods).some(access => access.kind === 'webhook'));
321
+ const labels = [
322
+ ...workflows.map(w => w.id),
323
+ ...webhooks.map(route => `the webhook at ${route.path}`),
324
+ ];
325
+ if (labels.length < 2)
326
+ return;
327
+ for (const extra of [...workflows, ...webhooks].slice(1))
328
+ extra.problems.push(ONE_TRIGGER(labels));
329
+ };
330
+ const ROUTER_FILE = 'router-file: export getRouter from src/router.tsx, built with createZiteRouter from zitejs/start, which gives pages the signed-in user';
331
+ const SHARED_ROUTER = "router-file: getRouter returns the same router every time, which shows every visitor the first one's user and data; call createZiteRouter inside getRouter";
332
+ export async function describeApp(opts) {
333
+ const facts = opts.facts ?? builtAppFacts();
334
+ const functions = [];
335
+ for (const id of opts.fnIds) {
336
+ const described = await describeFunction(id, opts.request);
337
+ const description = opts.descriptions?.[id];
338
+ described.problems.push(...functionRules(described, facts));
339
+ functions.push(description ? { ...described, description } : described);
340
+ }
341
+ const router = await opts.getRouter();
342
+ const problems = [];
343
+ if (!isZiteRouter(router))
344
+ problems.push(ROUTER_FILE);
345
+ // A router built once at import is the same object on every call.
346
+ else if ((await opts.getRouter()) === router)
347
+ problems.push(SHARED_ROUTER);
348
+ const { routesById } = router;
349
+ const routes = describeRoutes(routesById, opts.routeFiles, facts);
350
+ const pages = describePages(routesById, opts.routeFiles);
351
+ for (const page of pages) {
352
+ if (!routes.some(route => route.path === page.path) &&
353
+ RESERVED_PATHS.some(reserved => reserved.test(page.path))) {
354
+ problems.push(`${page.path}: ${RESERVED_PATH}`);
355
+ }
356
+ }
357
+ const workflows = describeWorkflows(opts.workflows ?? [], {
358
+ hashes: opts.registrationHashes,
359
+ unfinished: opts.unfinishedWorkflows,
360
+ triggers: opts.triggers ?? (await loadProviderTriggers()),
361
+ });
362
+ if (facts.automation)
363
+ oneTrigger(workflows, routes);
364
+ return {
365
+ functions,
366
+ routes,
367
+ pages,
368
+ workflows,
369
+ authHooks: Object.keys(await loadAuthHooks()),
370
+ problems,
371
+ };
372
+ }
@@ -1,3 +1,5 @@
1
1
  /** Describes a built Start app from its `dist/server`: a Workers build in workerd, a Node build in-process. */
2
2
  export declare function describeBuiltApp(appDir: string): Promise<unknown>;
3
+ /** @internal Each problem in a description, after what it's about: the app, or a function, route or automation. */
4
+ export declare const describedProblems: (description: unknown) => string[];
3
5
  export declare function runDescribe(): Promise<void>;
@@ -0,0 +1,102 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { createServer } from 'node:net';
4
+ import path from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+ // Only the host can set x-zite-* in production: the front strips them from public traffic.
7
+ const DESCRIBE_HEADERS = { 'x-zite-invoke': 'describe' };
8
+ // Not "localhost": it can resolve to ::1 for vite's listen and to 127.0.0.1 for fetch.
9
+ const HOST = '127.0.0.1';
10
+ const freePort = () => new Promise((resolve, reject) => {
11
+ const server = createServer();
12
+ server.once('error', reject);
13
+ server.listen(0, HOST, () => {
14
+ const { port } = server.address();
15
+ server.close(() => resolve(port));
16
+ });
17
+ });
18
+ // A Workers build runs where it will run: workerd, through the app's own
19
+ // `vite preview`, so it uses the same Cloudflare plugin and config as the build.
20
+ async function describeInWorkerd(appDir) {
21
+ const port = await freePort();
22
+ // Its own process group, so stopping it also stops vite and workerd under npx.
23
+ const preview = spawn('npx', [
24
+ '--no-install',
25
+ 'vite',
26
+ 'preview',
27
+ '--host',
28
+ HOST,
29
+ '--port',
30
+ String(port),
31
+ '--strictPort',
32
+ ], {
33
+ cwd: appDir,
34
+ stdio: ['ignore', 'ignore', 'pipe'],
35
+ detached: true,
36
+ });
37
+ let stderr = '';
38
+ preview.stderr.on('data', chunk => (stderr += chunk));
39
+ try {
40
+ const deadline = Date.now() + 60_000;
41
+ while (true) {
42
+ try {
43
+ const response = await fetch(`http://${HOST}:${port}/`, {
44
+ headers: DESCRIBE_HEADERS,
45
+ });
46
+ // Right after start, preview can answer before the Worker does; only the
47
+ // app's own describe answer is JSON.
48
+ if (response.ok &&
49
+ response.headers.get('content-type')?.includes('application/json')) {
50
+ return await response.json();
51
+ }
52
+ }
53
+ catch { }
54
+ if (preview.exitCode !== null || Date.now() > deadline) {
55
+ throw new Error(`vite preview didn't serve the app: ${stderr.trim().slice(-500)}`);
56
+ }
57
+ await new Promise(resolve => setTimeout(resolve, 250));
58
+ }
59
+ }
60
+ finally {
61
+ try {
62
+ process.kill(-preview.pid, 'SIGTERM');
63
+ }
64
+ catch { }
65
+ }
66
+ }
67
+ /** Describes a built Start app from its `dist/server`: a Workers build in workerd, a Node build in-process. */
68
+ export async function describeBuiltApp(appDir) {
69
+ const serverDir = path.join(appDir, 'dist/server');
70
+ if (existsSync(path.join(serverDir, 'wrangler.json')))
71
+ return describeInWorkerd(appDir);
72
+ const { default: server } = await import(pathToFileURL(path.join(serverDir, 'server.js')).href);
73
+ return (await server.fetch(new Request('http://describe.local/', { headers: DESCRIBE_HEADERS }))).json();
74
+ }
75
+ const listed = (value) => Array.isArray(value)
76
+ ? value.filter(item => item && typeof item === 'object')
77
+ : [];
78
+ /** @internal Each problem in a description, after what it's about: the app, or a function, route or automation. */
79
+ export const describedProblems = (description) => {
80
+ const of = description;
81
+ const lines = (label, problems) => Array.isArray(problems)
82
+ ? problems.map(problem => `${label}: ${String(problem)}`)
83
+ : [];
84
+ const where = (name, file) => typeof file === 'string' ? `${String(name)} (${file})` : String(name);
85
+ return [
86
+ ...lines('app', of?.problems),
87
+ ...listed(of?.functions).flatMap(fn => lines(`function ${where(fn.name ?? fn.id, fn.file)}`, fn.problems)),
88
+ ...listed(of?.routes).flatMap(route => lines(`route ${where(route.path, route.file)}`, route.problems)),
89
+ ...listed(of?.workflows).flatMap(workflow => lines(`automation ${where(workflow.id, workflow.file)}`, workflow.problems)),
90
+ ];
91
+ };
92
+ // The JSON on stdout is the platform's, which reads a nonzero exit as no description at all; stderr is for whoever
93
+ // runs it by hand.
94
+ export async function runDescribe() {
95
+ const appDir = path.resolve(process.argv[3] ?? '.');
96
+ const description = await describeBuiltApp(appDir);
97
+ process.stdout.write(`${JSON.stringify(description, null, 2)}\n`);
98
+ const problems = describedProblems(description);
99
+ if (problems.length > 0) {
100
+ process.stderr.write(`zitejs describe: ${problems.length} problem${problems.length === 1 ? '' : 's'}\n${problems.map(line => ` - ${line}`).join('\n')}\n`);
101
+ }
102
+ }
@@ -1,31 +1,36 @@
1
1
  const stringValue = (node) => {
2
- if (node?.type === "Literal" && typeof node.value === "string")
2
+ if (node?.type === 'Literal' && typeof node.value === 'string')
3
3
  return node.value;
4
4
  const quasis = node?.quasis;
5
- if (node?.type === "TemplateLiteral" && node.expressions.length === 0)
5
+ if (node?.type === 'TemplateLiteral' &&
6
+ node.expressions.length === 0)
6
7
  return quasis?.[0]?.value.cooked;
7
8
  return undefined;
8
9
  };
9
10
  const descriptionProperty = (node) => {
10
11
  for (const property of node.properties) {
11
12
  const key = property.key;
12
- const named = key?.type === "Identifier" ? key.name : key?.type === "Literal" ? key.value : undefined;
13
- if (property.type === "Property" && named === "description")
13
+ const named = key?.type === 'Identifier'
14
+ ? key.name
15
+ : key?.type === 'Literal'
16
+ ? key.value
17
+ : undefined;
18
+ if (property.type === 'Property' && named === 'description')
14
19
  return stringValue(property.value);
15
20
  }
16
21
  return undefined;
17
22
  };
18
23
  // Walks a builder chain, `signedInFn({ description }).validator(…).handler(…)`, to an object option.
19
24
  const descriptionIn = (node) => {
20
- if (node?.type === "CallExpression") {
25
+ if (node?.type === 'CallExpression') {
21
26
  for (const arg of node.arguments) {
22
- const found = arg.type === "ObjectExpression" ? descriptionProperty(arg) : undefined;
27
+ const found = arg.type === 'ObjectExpression' ? descriptionProperty(arg) : undefined;
23
28
  if (found !== undefined)
24
29
  return found;
25
30
  }
26
31
  return descriptionIn(node.callee);
27
32
  }
28
- if (node?.type === "MemberExpression")
33
+ if (node?.type === 'MemberExpression')
29
34
  return descriptionIn(node.object);
30
35
  return undefined;
31
36
  };
@@ -33,13 +38,15 @@ const descriptionIn = (node) => {
33
38
  export function factoryDescriptions(program) {
34
39
  const found = new Map();
35
40
  for (const statement of program.body) {
36
- const declaration = (statement.type === "ExportNamedDeclaration" ? statement.declaration : statement);
37
- if (declaration?.type !== "VariableDeclaration")
41
+ const declaration = (statement.type === 'ExportNamedDeclaration'
42
+ ? statement.declaration
43
+ : statement);
44
+ if (declaration?.type !== 'VariableDeclaration')
38
45
  continue;
39
46
  for (const declarator of declaration.declarations) {
40
47
  const id = declarator.id;
41
48
  const description = descriptionIn(declarator.init);
42
- if (id.type === "Identifier" && description)
49
+ if (id.type === 'Identifier' && description)
43
50
  found.set(id.name, description);
44
51
  }
45
52
  }
@@ -1,7 +1,6 @@
1
- import type { HostMode } from "./types.js";
1
+ import type { HostMode } from './types.js';
2
2
  declare const STATUS: {
3
3
  readonly BAD_REQUEST: 400;
4
- readonly INVALID_INPUT: 400;
5
4
  readonly UNAUTHORIZED: 401;
6
5
  readonly FORBIDDEN: 403;
7
6
  readonly NOT_FOUND: 404;
@@ -37,8 +36,8 @@ export declare class ZiteError extends Error {
37
36
  export declare const asZiteError: (error: unknown) => ZiteError | undefined;
38
37
  /**
39
38
  * What a failure may say to the app's users, as on classic. The message is the app author's, so it passes, with
40
- * credentials redacted in place; one naming our infrastructure or billing is replaced whole. Preview is the editor,
41
- * which reads it unchanged.
39
+ * credentials redacted in place: the request's own secrets wherever they appear, and whatever the patterns find. One
40
+ * naming our infrastructure or billing is replaced whole. Preview is the editor, which reads it unchanged.
42
41
  */
43
42
  export declare function toClientErrorMessage(errorMessage: string, mode: HostMode | undefined, userFacingMessage?: string): string;
44
43
  /** The message a server function fails with when it needs a session; the platform's client middleware sends the user to sign in. */
@@ -46,6 +45,18 @@ export declare const SIGN_IN_REQUIRED = "ZITE_SIGN_IN_REQUIRED";
46
45
  export declare const isSignInRequired: (error: unknown) => boolean;
47
46
  /** @internal Signed out: the visitor's state, not a bug in the app's code. */
48
47
  export declare const isSignInError: (error: unknown) => boolean;
48
+ /**
49
+ * @internal A thrown string or object as an INTERNAL_ERROR: only an Error goes through the zite-error adapter, which
50
+ * redacts it on its way to the browser. A Response, a redirect among them, and a notFound are TanStack's to handle.
51
+ */
52
+ export declare const errorFromThrown: (value: unknown) => unknown;
53
+ /** @internal A result whose promises reject as `errorFromThrown` would throw: they cross to the browser as thrown. */
54
+ export declare const withThrownRejections: <T>(value: T, cross?: (error: unknown) => unknown) => T;
49
55
  /** A thrown value as the browser receives it: its code, and only the message `toClientErrorMessage` allows. */
50
56
  export declare const toClientError: (error: unknown) => ZiteError;
57
+ /**
58
+ * @internal An error as the browser would receive it, for a caller on the server that nothing serializes it for.
59
+ * Its message is already the one to show, so the adapter sends it as it is, and crossing it again changes nothing.
60
+ */
61
+ export declare const asCrossed: (error: Error) => ZiteError;
51
62
  export {};