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,62 @@
1
+ import type { HostMode } from './types.js';
2
+ declare const STATUS: {
3
+ readonly BAD_REQUEST: 400;
4
+ readonly UNAUTHORIZED: 401;
5
+ readonly FORBIDDEN: 403;
6
+ readonly NOT_FOUND: 404;
7
+ readonly CONFLICT: 409;
8
+ readonly RATE_LIMITED: 429;
9
+ readonly INTERNAL_ERROR: 500;
10
+ };
11
+ export type ZiteErrorCode = keyof typeof STATUS;
12
+ /** @internal The HTTP status each code answers with. */
13
+ export declare const ZITE_ERROR_STATUS: Readonly<Record<ZiteErrorCode, number>>;
14
+ export declare const isZiteErrorCode: (code: unknown) => code is ZiteErrorCode;
15
+ export type ZiteErrorOptions = {
16
+ code: ZiteErrorCode;
17
+ message: string;
18
+ userFacingMessage?: string;
19
+ };
20
+ /**
21
+ * Fail with a status: `throw new ZiteError('FORBIDDEN', 'Only the owner can edit this')`. On the live app,
22
+ * `userFacingMessage` is what users read in place of `message`, which stays for logs and the editor.
23
+ */
24
+ export declare class ZiteError extends Error {
25
+ readonly code: ZiteErrorCode;
26
+ readonly userFacingMessage?: string;
27
+ constructor(code: ZiteErrorCode, message?: string);
28
+ constructor(options: ZiteErrorOptions);
29
+ /** Classic's order, which code written for `zitejs/backend` uses. */
30
+ constructor(message: string, code?: ZiteErrorCode);
31
+ }
32
+ /**
33
+ * A ZiteError from any copy of zitejs as this one's. Integration SDKs and code written for classic throw
34
+ * `zitejs/backend`'s class, which `instanceof` doesn't recognise.
35
+ */
36
+ export declare const asZiteError: (error: unknown) => ZiteError | undefined;
37
+ /**
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
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.
41
+ */
42
+ export declare function toClientErrorMessage(errorMessage: string, mode: HostMode | undefined, userFacingMessage?: string): string;
43
+ /** The message a server function fails with when it needs a session; the platform's client middleware sends the user to sign in. */
44
+ export declare const SIGN_IN_REQUIRED = "ZITE_SIGN_IN_REQUIRED";
45
+ export declare const isSignInRequired: (error: unknown) => boolean;
46
+ /** @internal Signed out: the visitor's state, not a bug in the app's code. */
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;
55
+ /** A thrown value as the browser receives it: its code, and only the message `toClientErrorMessage` allows. */
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;
62
+ export {};
@@ -0,0 +1,163 @@
1
+ import { isNotFound } from '@tanstack/react-router';
2
+ import { currentHost } from './host.js';
3
+ import { redactKnown, replaceKnown } from './platform/redactSecrets.js';
4
+ import { requestSecrets } from './platform/requestSecrets.js';
5
+ const STATUS = {
6
+ BAD_REQUEST: 400,
7
+ UNAUTHORIZED: 401,
8
+ FORBIDDEN: 403,
9
+ NOT_FOUND: 404,
10
+ CONFLICT: 409,
11
+ RATE_LIMITED: 429,
12
+ INTERNAL_ERROR: 500,
13
+ };
14
+ /** @internal The HTTP status each code answers with. */
15
+ export const ZITE_ERROR_STATUS = STATUS;
16
+ export const isZiteErrorCode = (code) => typeof code === 'string' &&
17
+ Object.prototype.hasOwnProperty.call(STATUS, code);
18
+ /**
19
+ * Fail with a status: `throw new ZiteError('FORBIDDEN', 'Only the owner can edit this')`. On the live app,
20
+ * `userFacingMessage` is what users read in place of `message`, which stays for logs and the editor.
21
+ */
22
+ export class ZiteError extends Error {
23
+ code;
24
+ userFacingMessage;
25
+ constructor(first, second) {
26
+ const options = typeof first === 'object'
27
+ ? first
28
+ : isZiteErrorCode(first)
29
+ ? { code: first, message: second ?? first }
30
+ : {
31
+ code: isZiteErrorCode(second) ? second : 'INTERNAL_ERROR',
32
+ message: first,
33
+ };
34
+ super(options.message);
35
+ this.name = 'ZiteError';
36
+ this.code = options.code;
37
+ if (options.userFacingMessage)
38
+ this.userFacingMessage = options.userFacingMessage;
39
+ }
40
+ }
41
+ /**
42
+ * A ZiteError from any copy of zitejs as this one's. Integration SDKs and code written for classic throw
43
+ * `zitejs/backend`'s class, which `instanceof` doesn't recognise.
44
+ */
45
+ export const asZiteError = (error) => {
46
+ if (error instanceof ZiteError)
47
+ return error;
48
+ if (!(error instanceof Error) || error.name !== 'ZiteError')
49
+ return undefined;
50
+ const { code, userFacingMessage } = error;
51
+ if (!isZiteErrorCode(code))
52
+ return undefined;
53
+ return new ZiteError({
54
+ code,
55
+ message: error.message,
56
+ ...(typeof userFacingMessage === 'string' && { userFacingMessage }),
57
+ });
58
+ };
59
+ // Ported from restly's packages/endpoint-setup/src/endpointErrors.ts; keep the two in step. The fences are consumed
60
+ // characters rather than lookbehinds, which older Safari can't parse: this module ships to the browser.
61
+ const INTERNAL_SERVICE_NAMES = [
62
+ 'zite-shard-restly-server',
63
+ 'restly-server',
64
+ 'workflow-runner',
65
+ 'base-runner',
66
+ 'app-runner',
67
+ 'utility-service',
68
+ ];
69
+ const PRIVATE_IPV4 = String.raw `\b(?:10|127)\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b|\b192\.168\.\d{1,3}\.\d{1,3}\b|\b169\.254\.\d{1,3}\.\d{1,3}\b`;
70
+ const PRIVATE_IPV6 = String.raw `(?:^|[^\w:])(?:::1|(?:f[cd][0-9a-f]{2}|fe[89ab][0-9a-f]):[0-9a-f:]+)(?![\w:])`;
71
+ const INTERNAL_HOSTNAME = String.raw `(?:^|[^\w.-])(?:${INTERNAL_SERVICE_NAMES.join('|')}|localhost)(?:-\w+)*(?::\d+)?(?![\w.-])`;
72
+ const UNAVAILABLE = 'A service this app depends on is temporarily unavailable. Please try again.';
73
+ const AI_UNAVAILABLE = 'AI features are temporarily unavailable. Please contact the app owner.';
74
+ const INFRASTRUCTURE_PATTERNS = [
75
+ {
76
+ pattern: new RegExp(`${PRIVATE_IPV4}|${PRIVATE_IPV6}|${INTERNAL_HOSTNAME}`, 'i'),
77
+ replacement: UNAVAILABLE,
78
+ },
79
+ {
80
+ pattern: /AI is paused: your organization is over its AI credit limit/i,
81
+ replacement: AI_UNAVAILABLE,
82
+ },
83
+ {
84
+ pattern: /platform\.openai\.com\/(?:settings\/organization\/billing|docs\/guides\/error-codes)/i,
85
+ replacement: AI_UNAVAILABLE,
86
+ },
87
+ ];
88
+ /**
89
+ * What a failure may say to the app's users, as on classic. The message is the app author's, so it passes, with
90
+ * credentials redacted in place: the request's own secrets wherever they appear, and whatever the patterns find. One
91
+ * naming our infrastructure or billing is replaced whole. Preview is the editor, which reads it unchanged.
92
+ */
93
+ export function toClientErrorMessage(errorMessage, mode, userFacingMessage) {
94
+ if (mode === 'preview')
95
+ return errorMessage;
96
+ const secrets = requestSecrets(currentHost());
97
+ if (userFacingMessage)
98
+ return replaceKnown(userFacingMessage, secrets);
99
+ const redacted = redactKnown(errorMessage, secrets);
100
+ for (const { pattern, replacement } of INFRASTRUCTURE_PATTERNS) {
101
+ if (pattern.test(redacted))
102
+ return replacement;
103
+ }
104
+ return redacted;
105
+ }
106
+ /** The message a server function fails with when it needs a session; the platform's client middleware sends the user to sign in. */
107
+ export const SIGN_IN_REQUIRED = 'ZITE_SIGN_IN_REQUIRED';
108
+ export const isSignInRequired = (error) => error instanceof Error && error.message === SIGN_IN_REQUIRED;
109
+ /** @internal Signed out: the visitor's state, not a bug in the app's code. */
110
+ export const isSignInError = (error) => isSignInRequired(error) || asZiteError(error)?.code === 'UNAUTHORIZED';
111
+ const thrownText = (value) => {
112
+ if (typeof value === 'string')
113
+ return value;
114
+ try {
115
+ return JSON.stringify(value) ?? String(value);
116
+ }
117
+ catch {
118
+ return String(value);
119
+ }
120
+ };
121
+ /**
122
+ * @internal A thrown string or object as an INTERNAL_ERROR: only an Error goes through the zite-error adapter, which
123
+ * redacts it on its way to the browser. A Response, a redirect among them, and a notFound are TanStack's to handle.
124
+ */
125
+ export const errorFromThrown = (value) => value instanceof Error || value instanceof Response || isNotFound(value)
126
+ ? value
127
+ : new ZiteError('INTERNAL_ERROR', thrownText(value));
128
+ /** @internal A result whose promises reject as `errorFromThrown` would throw: they cross to the browser as thrown. */
129
+ export const withThrownRejections = (value, cross = error => error) => {
130
+ if (!value ||
131
+ typeof value !== 'object' ||
132
+ Object.getPrototypeOf(value) !== Object.prototype)
133
+ return value;
134
+ const promised = Object.entries(value).filter(([, item]) => item instanceof Promise);
135
+ if (!promised.length)
136
+ return value;
137
+ const out = {
138
+ ...value,
139
+ };
140
+ for (const [key, item] of promised) {
141
+ out[key] = item.catch((error) => {
142
+ throw cross(errorFromThrown(error));
143
+ });
144
+ }
145
+ return out;
146
+ };
147
+ /** A thrown value as the browser receives it: its code, and only the message `toClientErrorMessage` allows. */
148
+ export const toClientError = (error) => {
149
+ const zite = asZiteError(error);
150
+ const message = error instanceof Error ? error.message : String(error);
151
+ return new ZiteError(zite?.code ?? 'INTERNAL_ERROR', toClientErrorMessage(message, currentHost()?.mode, zite?.userFacingMessage));
152
+ };
153
+ /**
154
+ * @internal An error as the browser would receive it, for a caller on the server that nothing serializes it for.
155
+ * Its message is already the one to show, so the adapter sends it as it is, and crossing it again changes nothing.
156
+ */
157
+ export const asCrossed = (error) => {
158
+ const { code, message } = toClientError(error);
159
+ const crossed = new ZiteError({ code, message, userFacingMessage: message });
160
+ if (currentHost()?.mode === 'preview')
161
+ crossed.stack = error.stack;
162
+ return crossed;
163
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,54 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { asZiteError, ZiteError } from './errors.js';
3
+ describe('ZiteError', () => {
4
+ it("takes Start's order, classic's order and classic's options", () => {
5
+ expect(new ZiteError('FORBIDDEN', 'Owners only')).toMatchObject({
6
+ code: 'FORBIDDEN',
7
+ message: 'Owners only',
8
+ });
9
+ expect(new ZiteError('NOT_FOUND')).toMatchObject({
10
+ code: 'NOT_FOUND',
11
+ message: 'NOT_FOUND',
12
+ });
13
+ expect(new ZiteError('Owners only', 'FORBIDDEN')).toMatchObject({
14
+ code: 'FORBIDDEN',
15
+ message: 'Owners only',
16
+ });
17
+ expect(new ZiteError('Something broke')).toMatchObject({
18
+ code: 'INTERNAL_ERROR',
19
+ message: 'Something broke',
20
+ });
21
+ expect(new ZiteError({
22
+ code: 'CONFLICT',
23
+ message: 'Row 3 changed',
24
+ userFacingMessage: 'Someone else edited this.',
25
+ })).toMatchObject({
26
+ code: 'CONFLICT',
27
+ message: 'Row 3 changed',
28
+ userFacingMessage: 'Someone else edited this.',
29
+ });
30
+ });
31
+ });
32
+ describe('asZiteError', () => {
33
+ it("recognises another copy's ZiteError by name and code", () => {
34
+ const classic = Object.assign(new Error('No such deal'), {
35
+ name: 'ZiteError',
36
+ code: 'NOT_FOUND',
37
+ userFacingMessage: 'Gone.',
38
+ });
39
+ expect(asZiteError(classic)).toMatchObject({
40
+ code: 'NOT_FOUND',
41
+ message: 'No such deal',
42
+ userFacingMessage: 'Gone.',
43
+ });
44
+ });
45
+ it('refuses anything else', () => {
46
+ expect(asZiteError(new Error('plain'))).toBeUndefined();
47
+ expect(asZiteError(Object.assign(new Error('x'), { name: 'ZiteError', code: 'toString' }))).toBeUndefined();
48
+ expect(asZiteError({
49
+ name: 'ZiteError',
50
+ code: 'NOT_FOUND',
51
+ message: 'not an Error',
52
+ })).toBeUndefined();
53
+ });
54
+ });
@@ -0,0 +1,14 @@
1
+ import { anyone, signedIn } from './access.js';
2
+ import type { ZiteFnFactory } from './fnFactory.js';
3
+ declare module '@tanstack/react-router' {
4
+ interface StaticDataRouteOption {
5
+ /** What an API route does, in a sentence. Shown in the editor. */
6
+ description?: string;
7
+ }
8
+ }
9
+ declare const compiled: import("@tanstack/react-start").FunctionMiddlewareAfterClient<{}, unknown, undefined, undefined, undefined>;
10
+ /** A server function only signed-in users can call. */
11
+ export declare const signedInFn: ZiteFnFactory<readonly [typeof compiled, typeof signedIn]>;
12
+ /** A server function anyone can call (external apps only). */
13
+ export declare const publicFn: ZiteFnFactory<readonly [typeof compiled, typeof anyone]>;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ import { createMiddleware, createServerFn } from '@tanstack/react-start';
2
+ import { anyone, signedIn } from './access.js';
3
+ import { tag } from './middlewareKind.js';
4
+ // TanStack's compiler tags every server function it compiles with an id. A
5
+ // builder it didn't compile (an object property, one returned from a helper)
6
+ // has none and would run its handler wherever it was called, so it fails here.
7
+ const compiled = tag(createMiddleware({ type: 'function' }).client(({ next, serverFnMeta }) => {
8
+ if (!serverFnMeta?.id) {
9
+ throw new Error('This server function was not compiled by TanStack Start. Assign signedInFn(...)/publicFn(...)' +
10
+ ".handler(...) directly to its own top-level const, not an object property or a helper's return value.");
11
+ }
12
+ return next();
13
+ }), { kind: 'factory' });
14
+ /** A server function only signed-in users can call. */
15
+ export const signedInFn = createServerFn().middleware([
16
+ compiled,
17
+ signedIn,
18
+ ]);
19
+ /** A server function anyone can call (external apps only). */
20
+ export const publicFn = createServerFn().middleware([
21
+ compiled,
22
+ anyone,
23
+ ]);
@@ -0,0 +1,2 @@
1
+ import type { ZiteRequestContext } from './index.js';
2
+ export type Unexported = ZiteRequestContext;
@@ -0,0 +1,60 @@
1
+ import { createServerFn } from '@tanstack/react-start';
2
+ import { describe, expectTypeOf, it } from 'vitest';
3
+ import { hasRole, publicFn, role, signedInFn } from './index.js';
4
+ describe('server function factories', () => {
5
+ it('take a method and a description', () => {
6
+ signedInFn({
7
+ method: 'GET',
8
+ description: "The signed-in user's orders",
9
+ }).handler(async () => []);
10
+ publicFn({ method: 'POST', description: 'Joins the waitlist' }).handler(async () => null);
11
+ });
12
+ it('refuse options without a description', () => {
13
+ // @ts-expect-error the editor shows what each function does
14
+ signedInFn({ method: 'GET' });
15
+ // @ts-expect-error the editor shows what each function does
16
+ publicFn({ method: 'POST' });
17
+ });
18
+ it("leave TanStack's own createServerFn as it is, for describe to refuse", () => {
19
+ createServerFn({ method: 'GET' }).handler(async () => null);
20
+ });
21
+ it('refuse options without a method, and a function built without options', () => {
22
+ // @ts-expect-error TanStack would make it a GET without saying so
23
+ signedInFn({ description: "The signed-in user's orders" });
24
+ // @ts-expect-error nor without options at all
25
+ signedInFn.handler(async () => []);
26
+ // @ts-expect-error nor through a validator first
27
+ publicFn.validator((input) => input);
28
+ });
29
+ it('type the handler by the method it was given', () => {
30
+ signedInFn({ method: 'POST', description: 'Archives an order' })
31
+ .validator((input) => input)
32
+ .handler(async ({ method, data }) => {
33
+ expectTypeOf(method).toEqualTypeOf();
34
+ expectTypeOf(data).toEqualTypeOf();
35
+ });
36
+ });
37
+ it("carry the requirement through an app's own factory", () => {
38
+ const managerFn = signedInFn.middleware([role('manager')]);
39
+ managerFn({ method: 'POST', description: 'Reassigns a deal' }).handler(async () => null);
40
+ // @ts-expect-error the editor shows what each function does
41
+ managerFn({ method: 'POST' });
42
+ // @ts-expect-error and the method comes first here too
43
+ managerFn.handler(async () => null);
44
+ });
45
+ });
46
+ describe('hasRole', () => {
47
+ it("takes the user, none, or a context carrying one, as classic's does", () => {
48
+ publicFn({ method: 'GET', description: 'Reads the role' }).handler(async ({ context }) => {
49
+ expectTypeOf(hasRole(context.user, 'admin')).toEqualTypeOf();
50
+ expectTypeOf(hasRole(context, 'admin')).toEqualTypeOf();
51
+ });
52
+ signedInFn({ method: 'GET', description: 'Reads the role' }).handler(async ({ context }) => hasRole(context.user, 'admin'));
53
+ hasRole(null, 'admin');
54
+ hasRole(undefined, 'admin');
55
+ // @ts-expect-error a role by its id
56
+ hasRole(null, 3);
57
+ // @ts-expect-error a user, or a context carrying one
58
+ hasRole({ id: 'u_1' }, 'admin');
59
+ });
60
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal TanStack answers a failed server function 200, with the error in the body. A nested call's failure is
3
+ * the caller's to handle, and so is one made while a page renders: its loader may catch it, and one that doesn't
4
+ * gets the error's status from the server entry. Redirects and notFound aren't Errors.
5
+ */
6
+ export declare const setFailedStatus: (error: unknown) => void;
7
+ export declare const withStatus: <T>(isServerFn: boolean, fn: () => Promise<T>) => Promise<T | Response>;
@@ -0,0 +1,62 @@
1
+ import { setResponseStatus } from '@tanstack/react-start/server';
2
+ import { getStartContext } from '@tanstack/start-storage-context';
3
+ import { asZiteError, errorFromThrown, toClientErrorMessage, ZiteError, ZITE_ERROR_STATUS, } from './errors.js';
4
+ import { getHost, inScope } from './serve/scope.js';
5
+ // TanStack fails a validator with a plain Error whose message is the issues as JSON.
6
+ const validationIssues = (error) => {
7
+ if (!(error instanceof Error) || error.constructor !== Error)
8
+ return undefined;
9
+ try {
10
+ const issues = JSON.parse(error.message);
11
+ return Array.isArray(issues) &&
12
+ issues.length > 0 &&
13
+ issues.every(issue => typeof issue?.message === 'string')
14
+ ? issues
15
+ : undefined;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ };
21
+ const invalidInput = (issues) => {
22
+ if (getHost()?.mode !== 'preview')
23
+ return new ZiteError('BAD_REQUEST', 'Invalid input');
24
+ const describe = ({ message, path = [] }) => {
25
+ const at = path
26
+ .map(segment => String(typeof segment === 'object' ? segment.key : segment))
27
+ .join('.');
28
+ return at ? `${at}: ${message}` : message;
29
+ };
30
+ return new ZiteError('BAD_REQUEST', issues.map(describe).join('; '));
31
+ };
32
+ /**
33
+ * @internal TanStack answers a failed server function 200, with the error in the body. A nested call's failure is
34
+ * the caller's to handle, and so is one made while a page renders: its loader may catch it, and one that doesn't
35
+ * gets the error's status from the server entry. Redirects and notFound aren't Errors.
36
+ */
37
+ export const setFailedStatus = (error) => {
38
+ if (!(error instanceof Error) ||
39
+ inScope() ||
40
+ getStartContext({ throwIfNotFound: false })?.handlerType !== 'serverFn')
41
+ return;
42
+ setResponseStatus(ZITE_ERROR_STATUS[asZiteError(error)?.code ?? 'INTERNAL_ERROR']);
43
+ };
44
+ // Server functions report a status through TanStack's error envelope; server routes need a Response.
45
+ export const withStatus = async (isServerFn, fn) => {
46
+ try {
47
+ return await fn();
48
+ }
49
+ catch (thrown) {
50
+ const caught = errorFromThrown(thrown);
51
+ const issues = validationIssues(caught);
52
+ const error = issues ? invalidInput(issues) : asZiteError(caught);
53
+ if (!isServerFn) {
54
+ if (!error)
55
+ throw caught;
56
+ const message = toClientErrorMessage(error.message, getHost()?.mode, error.userFacingMessage);
57
+ return new Response(message, { status: ZITE_ERROR_STATUS[error.code] });
58
+ }
59
+ setFailedStatus(error ?? caught);
60
+ throw error ?? caught;
61
+ }
62
+ };
@@ -0,0 +1,16 @@
1
+ import type { AnyFunctionMiddleware, AnyRequestMiddleware, Method, Register, ServerFnBuilder, ServerFnOptions, ServerFnStrict } from '@tanstack/react-start';
2
+ declare const withMiddleware: <TMiddlewares, TMethod extends Method, TStrict extends ServerFnStrict>(builder: ServerFnBuilder<Register, TMethod, TStrict>) => ReturnType<typeof builder.middleware<TMiddlewares>>;
3
+ type ServerFnAfter<TMiddlewares, TMethod extends Method, TStrict extends ServerFnStrict> = ReturnType<typeof withMiddleware<TMiddlewares, TMethod, TStrict>>;
4
+ /**
5
+ * `signedInFn`, `publicFn` and an app's factories built from them: called with a method and a description before
6
+ * anything else, since TanStack would quietly make a function without a method a GET.
7
+ */
8
+ export type ZiteFnFactory<TMiddlewares extends ReadonlyArray<unknown>> = {
9
+ <TMethod extends Method, TStrict extends ServerFnStrict = true>(options: ServerFnOptions<TMethod, TStrict> & {
10
+ method: TMethod;
11
+ /** What this function does, in a sentence. Shown in the editor. */
12
+ description: string;
13
+ }): ServerFnAfter<TMiddlewares, TMethod, TStrict>;
14
+ middleware: <const TNew extends ReadonlyArray<AnyFunctionMiddleware | AnyRequestMiddleware>>(middlewares: TNew) => ZiteFnFactory<readonly [...TMiddlewares, ...TNew]>;
15
+ };
16
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { HostRequestState } from './types.js';
2
+ export declare const HOST_STORE_KEY: unique symbol;
3
+ export declare const currentHost: () => HostRequestState | undefined;
@@ -0,0 +1,4 @@
1
+ // Isomorphic, so it can't import the server-only store: it reads the request's host through the global key
2
+ // ./serve/scope.ts registers it under. In the browser there is none.
3
+ export const HOST_STORE_KEY = Symbol.for('zitejs:host-context');
4
+ export const currentHost = () => globalThis[HOST_STORE_KEY]?.getStore();
@@ -0,0 +1,10 @@
1
+ export type { Role, User } from './types.js';
2
+ export { isSignInRequired, SIGN_IN_REQUIRED, ZiteError, type ZiteErrorCode, type ZiteErrorOptions, } from './errors.js';
3
+ export { createZiteRouter, type ZiteRouterContext } from './router.js';
4
+ export { createAutomation, createProviderTrigger, type ProviderTriggerConfig, type StartProviderTrigger, type StartTrigger, type Automation, type AutomationArgs, type AutomationConfig, } from './automations/workflow.js';
5
+ export type { ZiteSchedule } from '../schedules/index.js';
6
+ export type { ZiteTrigger, ZiteTriggerSubscribe, ZiteTriggerSubscribeInput, ZiteTriggerSubscribeResult, ZiteTriggerUnsubscribe, ZiteTriggerUnsubscribeInput, } from '../backend/index.js';
7
+ export { anyone, signedIn, webhook } from './access.js';
8
+ export { publicFn, signedInFn } from './factories.js';
9
+ export { loginHref } from './login.js';
10
+ export { hasRole, role } from './roles.js';
@@ -0,0 +1,7 @@
1
+ export { isSignInRequired, SIGN_IN_REQUIRED, ZiteError, } from './errors.js';
2
+ export { createZiteRouter } from './router.js';
3
+ export { createAutomation, createProviderTrigger, } from './automations/workflow.js';
4
+ export { anyone, signedIn, webhook } from './access.js';
5
+ export { publicFn, signedInFn } from './factories.js';
6
+ export { loginHref } from './login.js';
7
+ export { hasRole, role } from './roles.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The platform's sign-in page, returning to `redirectTo` (default: the current
3
+ * page). For guards: `throw redirect({ href: loginHref(), reloadDocument: true })`.
4
+ */
5
+ export declare function loginHref(redirectTo?: string): string;
@@ -0,0 +1,29 @@
1
+ import { USAGE_TOKEN_QUERY_PARAM } from '../auth/constants.js';
2
+ import { currentHost } from './host.js';
3
+ import { PREVIEW_CLAIM_PARAM, previewClaim } from './previewClaim.js';
4
+ /**
5
+ * The platform's sign-in page, returning to `redirectTo` (default: the current
6
+ * page). For guards: `throw redirect({ href: loginHref(), reloadDocument: true })`.
7
+ */
8
+ export function loginHref(redirectTo) {
9
+ const current = typeof window !== 'undefined' ? window.location.href : currentHost()?.url;
10
+ // Absolute on purpose: better-auth drops a relative callback with an encoded
11
+ // space, fragment or non-ASCII path, and never checks an absolute one.
12
+ const target = current ? new URL(redirectTo ?? current, current) : undefined;
13
+ const params = new URLSearchParams();
14
+ if (target && !(target.pathname === '/' && !target.search && !target.hash))
15
+ params.set('redirectUrl', target.toString());
16
+ else if (!target && redirectTo)
17
+ params.set('redirectUrl', redirectTo);
18
+ // The editor preview's sign-in page needs the preview's token, and its claim where the frame dropped the cookie.
19
+ const usageToken = current
20
+ ? new URL(current).searchParams.get(USAGE_TOKEN_QUERY_PARAM)
21
+ : null;
22
+ if (usageToken)
23
+ params.set(USAGE_TOKEN_QUERY_PARAM, usageToken);
24
+ const claim = previewClaim();
25
+ if (claim)
26
+ params.set(PREVIEW_CLAIM_PARAM, claim);
27
+ const query = params.toString();
28
+ return query ? `/auth/login?${query}` : '/auth/login';
29
+ }
@@ -0,0 +1,13 @@
1
+ /** What a zitejs middleware means, for describe. Keyed by identity, so composing or re-exporting keeps it. */
2
+ export type ZiteMiddlewareKind = {
3
+ kind: 'signedIn' | 'anyone' | 'factory';
4
+ } | {
5
+ kind: 'webhook';
6
+ paused?: true;
7
+ } | {
8
+ kind: 'role';
9
+ role: string;
10
+ };
11
+ export declare const tag: <T extends object>(middleware: T, kind: ZiteMiddlewareKind) => T;
12
+ /** @internal */
13
+ export declare const ziteMiddlewareKind: (middleware: unknown) => ZiteMiddlewareKind | undefined;
@@ -0,0 +1,9 @@
1
+ const kinds = new WeakMap();
2
+ export const tag = (middleware, kind) => {
3
+ kinds.set(middleware, kind);
4
+ return middleware;
5
+ };
6
+ /** @internal */
7
+ export const ziteMiddlewareKind = (middleware) => typeof middleware === 'object' && middleware !== null
8
+ ? kinds.get(middleware)
9
+ : undefined;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What a call on an org's own AI key used, read from the provider's answer as
3
+ * classic's runtime reads it. For analytics only: the org pays the provider.
4
+ * OpenAI, Anthropic and Gemini; the host meters Zite's own key itself.
5
+ */
6
+ export type AiProvider = 'openai' | 'anthropic' | 'gemini';
7
+ export type AiUsageRecord = {
8
+ provider: AiProvider;
9
+ model?: string;
10
+ inputTokens?: number;
11
+ outputTokens?: number;
12
+ cachedReadInputTokens?: number;
13
+ cacheCreationInputTokens?: number;
14
+ isStreaming?: true;
15
+ };
16
+ export declare const AI_USAGE_HOSTS: Record<string, AiProvider>;
17
+ /** As classic: an OpenAI chat stream reports its usage only when asked to. The body to send instead, if any. */
18
+ export declare const withStreamUsage: (url: URL, method: string, body: unknown) => string | undefined;
19
+ /**
20
+ * The response to hand the app, and its usage once read; a stream is split so the app reads one copy as it arrives.
21
+ * `request` is what the app sent, which names Gemini's model and holds what its embeddings are estimated from.
22
+ */
23
+ export declare const meterAiResponse: (provider: AiProvider, response: Response, request: {
24
+ url: URL;
25
+ body: unknown;
26
+ }) => {
27
+ response: Response;
28
+ usage: Promise<AiUsageRecord | undefined>;
29
+ };