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,8 +1,9 @@
1
- import { currentHost } from "./host.js";
2
- import { redactSecrets } from "./redactSecrets.js";
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';
3
5
  const STATUS = {
4
6
  BAD_REQUEST: 400,
5
- INVALID_INPUT: 400,
6
7
  UNAUTHORIZED: 401,
7
8
  FORBIDDEN: 403,
8
9
  NOT_FOUND: 404,
@@ -12,7 +13,8 @@ const STATUS = {
12
13
  };
13
14
  /** @internal The HTTP status each code answers with. */
14
15
  export const ZITE_ERROR_STATUS = STATUS;
15
- export const isZiteErrorCode = (code) => typeof code === "string" && Object.prototype.hasOwnProperty.call(STATUS, code);
16
+ export const isZiteErrorCode = (code) => typeof code === 'string' &&
17
+ Object.prototype.hasOwnProperty.call(STATUS, code);
16
18
  /**
17
19
  * Fail with a status: `throw new ZiteError('FORBIDDEN', 'Only the owner can edit this')`. On the live app,
18
20
  * `userFacingMessage` is what users read in place of `message`, which stays for logs and the editor.
@@ -21,13 +23,16 @@ export class ZiteError extends Error {
21
23
  code;
22
24
  userFacingMessage;
23
25
  constructor(first, second) {
24
- const options = typeof first === "object"
26
+ const options = typeof first === 'object'
25
27
  ? first
26
28
  : isZiteErrorCode(first)
27
29
  ? { code: first, message: second ?? first }
28
- : { code: isZiteErrorCode(second) ? second : "INTERNAL_ERROR", message: first };
30
+ : {
31
+ code: isZiteErrorCode(second) ? second : 'INTERNAL_ERROR',
32
+ message: first,
33
+ };
29
34
  super(options.message);
30
- this.name = "ZiteError";
35
+ this.name = 'ZiteError';
31
36
  this.code = options.code;
32
37
  if (options.userFacingMessage)
33
38
  this.userFacingMessage = options.userFacingMessage;
@@ -40,7 +45,7 @@ export class ZiteError extends Error {
40
45
  export const asZiteError = (error) => {
41
46
  if (error instanceof ZiteError)
42
47
  return error;
43
- if (!(error instanceof Error) || error.name !== "ZiteError")
48
+ if (!(error instanceof Error) || error.name !== 'ZiteError')
44
49
  return undefined;
45
50
  const { code, userFacingMessage } = error;
46
51
  if (!isZiteErrorCode(code))
@@ -48,27 +53,33 @@ export const asZiteError = (error) => {
48
53
  return new ZiteError({
49
54
  code,
50
55
  message: error.message,
51
- ...(typeof userFacingMessage === "string" && { userFacingMessage }),
56
+ ...(typeof userFacingMessage === 'string' && { userFacingMessage }),
52
57
  });
53
58
  };
54
59
  // Ported from restly's packages/endpoint-setup/src/endpointErrors.ts; keep the two in step. The fences are consumed
55
60
  // characters rather than lookbehinds, which older Safari can't parse: this module ships to the browser.
56
61
  const INTERNAL_SERVICE_NAMES = [
57
- "zite-shard-restly-server",
58
- "restly-server",
59
- "workflow-runner",
60
- "base-runner",
61
- "app-runner",
62
- "utility-service",
62
+ 'zite-shard-restly-server',
63
+ 'restly-server',
64
+ 'workflow-runner',
65
+ 'base-runner',
66
+ 'app-runner',
67
+ 'utility-service',
63
68
  ];
64
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`;
65
70
  const PRIVATE_IPV6 = String.raw `(?:^|[^\w:])(?:::1|(?:f[cd][0-9a-f]{2}|fe[89ab][0-9a-f]):[0-9a-f:]+)(?![\w:])`;
66
- const INTERNAL_HOSTNAME = String.raw `(?:^|[^\w.-])(?:${INTERNAL_SERVICE_NAMES.join("|")}|localhost)(?:-\w+)*(?::\d+)?(?![\w.-])`;
67
- const UNAVAILABLE = "A service this app depends on is temporarily unavailable. Please try again.";
68
- const AI_UNAVAILABLE = "AI features are temporarily unavailable. Please contact the app owner.";
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.';
69
74
  const INFRASTRUCTURE_PATTERNS = [
70
- { pattern: new RegExp(`${PRIVATE_IPV4}|${PRIVATE_IPV6}|${INTERNAL_HOSTNAME}`, "i"), replacement: UNAVAILABLE },
71
- { pattern: /AI is paused: your organization is over its AI credit limit/i, replacement: AI_UNAVAILABLE },
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
+ },
72
83
  {
73
84
  pattern: /platform\.openai\.com\/(?:settings\/organization\/billing|docs\/guides\/error-codes)/i,
74
85
  replacement: AI_UNAVAILABLE,
@@ -76,15 +87,16 @@ const INFRASTRUCTURE_PATTERNS = [
76
87
  ];
77
88
  /**
78
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
79
- * credentials redacted in place; one naming our infrastructure or billing is replaced whole. Preview is the editor,
80
- * which reads it unchanged.
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.
81
92
  */
82
93
  export function toClientErrorMessage(errorMessage, mode, userFacingMessage) {
83
- if (mode === "preview")
94
+ if (mode === 'preview')
84
95
  return errorMessage;
96
+ const secrets = requestSecrets(currentHost());
85
97
  if (userFacingMessage)
86
- return userFacingMessage;
87
- const redacted = redactSecrets(errorMessage);
98
+ return replaceKnown(userFacingMessage, secrets);
99
+ const redacted = redactKnown(errorMessage, secrets);
88
100
  for (const { pattern, replacement } of INFRASTRUCTURE_PATTERNS) {
89
101
  if (pattern.test(redacted))
90
102
  return replacement;
@@ -92,13 +104,60 @@ export function toClientErrorMessage(errorMessage, mode, userFacingMessage) {
92
104
  return redacted;
93
105
  }
94
106
  /** The message a server function fails with when it needs a session; the platform's client middleware sends the user to sign in. */
95
- export const SIGN_IN_REQUIRED = "ZITE_SIGN_IN_REQUIRED";
107
+ export const SIGN_IN_REQUIRED = 'ZITE_SIGN_IN_REQUIRED';
96
108
  export const isSignInRequired = (error) => error instanceof Error && error.message === SIGN_IN_REQUIRED;
97
109
  /** @internal Signed out: the visitor's state, not a bug in the app's code. */
98
- export const isSignInError = (error) => isSignInRequired(error) || asZiteError(error)?.code === "UNAUTHORIZED";
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
+ };
99
147
  /** A thrown value as the browser receives it: its code, and only the message `toClientErrorMessage` allows. */
100
148
  export const toClientError = (error) => {
101
149
  const zite = asZiteError(error);
102
150
  const message = error instanceof Error ? error.message : String(error);
103
- return new ZiteError(zite?.code ?? "INTERNAL_ERROR", toClientErrorMessage(message, currentHost()?.mode, zite?.userFacingMessage));
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;
104
163
  };
@@ -1,23 +1,54 @@
1
- import { describe, expect, it } from "vitest";
2
- import { asZiteError, ZiteError } from "./errors.js";
3
- describe("ZiteError", () => {
1
+ import { describe, expect, it } from 'vitest';
2
+ import { asZiteError, ZiteError } from './errors.js';
3
+ describe('ZiteError', () => {
4
4
  it("takes Start's order, classic's order and classic's options", () => {
5
- expect(new ZiteError("FORBIDDEN", "Owners only")).toMatchObject({ code: "FORBIDDEN", message: "Owners only" });
6
- expect(new ZiteError("NOT_FOUND")).toMatchObject({ code: "NOT_FOUND", message: "NOT_FOUND" });
7
- expect(new ZiteError("Owners only", "FORBIDDEN")).toMatchObject({ code: "FORBIDDEN", message: "Owners only" });
8
- expect(new ZiteError("Something broke")).toMatchObject({ code: "INTERNAL_ERROR", message: "Something broke" });
9
- expect(new ZiteError({ code: "CONFLICT", message: "Row 3 changed", userFacingMessage: "Someone else edited this." }))
10
- .toMatchObject({ code: "CONFLICT", message: "Row 3 changed", userFacingMessage: "Someone else edited this." });
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
+ });
11
30
  });
12
31
  });
13
- describe("asZiteError", () => {
32
+ describe('asZiteError', () => {
14
33
  it("recognises another copy's ZiteError by name and code", () => {
15
- const classic = Object.assign(new Error("No such deal"), { name: "ZiteError", code: "NOT_FOUND", userFacingMessage: "Gone." });
16
- expect(asZiteError(classic)).toMatchObject({ code: "NOT_FOUND", message: "No such deal", userFacingMessage: "Gone." });
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
+ });
17
44
  });
18
- it("refuses anything else", () => {
19
- expect(asZiteError(new Error("plain"))).toBeUndefined();
20
- expect(asZiteError(Object.assign(new Error("x"), { name: "ZiteError", code: "toString" }))).toBeUndefined();
21
- expect(asZiteError({ name: "ZiteError", code: "NOT_FOUND", message: "not an Error" })).toBeUndefined();
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();
22
53
  });
23
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
+ ]);
@@ -1 +1,2 @@
1
- export {};
1
+ import type { ZiteRequestContext } from './index.js';
2
+ export type Unexported = ZiteRequestContext;
@@ -1,20 +1,60 @@
1
- import { describe, it } from "vitest";
2
- import { publicFn, role, signedInFn } from "./index.js";
3
- describe("server function factories", () => {
4
- it("take a method and a description", () => {
5
- signedInFn({ method: "GET", description: "The signed-in user's orders" }).handler(async () => []);
6
- publicFn({ method: "POST", description: "Joins the waitlist" }).handler(async () => null);
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);
7
11
  });
8
- it("refuse options without a description", () => {
12
+ it('refuse options without a description', () => {
9
13
  // @ts-expect-error the editor shows what each function does
10
- signedInFn({ method: "GET" });
14
+ signedInFn({ method: 'GET' });
11
15
  // @ts-expect-error the editor shows what each function does
12
- publicFn({ method: "POST" });
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
+ });
13
36
  });
14
37
  it("carry the requirement through an app's own factory", () => {
15
- const managerFn = signedInFn.middleware([role("manager")]);
16
- managerFn({ method: "POST", description: "Reassigns a deal" }).handler(async () => null);
38
+ const managerFn = signedInFn.middleware([role('manager')]);
39
+ managerFn({ method: 'POST', description: 'Reassigns a deal' }).handler(async () => null);
17
40
  // @ts-expect-error the editor shows what each function does
18
- managerFn({ method: "POST" });
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');
19
59
  });
20
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 {};
@@ -1,3 +1,3 @@
1
- import type { ZiteRequestContext } from "./types.js";
1
+ import type { HostRequestState } from './types.js';
2
2
  export declare const HOST_STORE_KEY: unique symbol;
3
- export declare const currentHost: () => ZiteRequestContext | undefined;
3
+ export declare const currentHost: () => HostRequestState | undefined;
@@ -1,4 +1,4 @@
1
- // Isomorphic, so it can't import the server-only store: it reads it through the
2
- // global key ./scope.ts registers it under. In the browser there is none.
3
- export const HOST_STORE_KEY = Symbol.for("zitejs:host-context");
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
4
  export const currentHost = () => globalThis[HOST_STORE_KEY]?.getStore();
@@ -1,66 +1,10 @@
1
- import type { User } from "./types.js";
2
- export type { Role, User, ZiteRequestContext } from "./types.js";
3
- export { isSignInRequired, SIGN_IN_REQUIRED, ZiteError, ZITE_ERROR_STATUS, type ZiteErrorCode, type ZiteErrorOptions, } from "./errors.js";
4
- export { createZiteRouter, type ZiteRouterContext } from "./router.js";
5
- export { createWorkflow, type StartProviderTrigger, type StartTrigger, type Workflow, type WorkflowArgs, type WorkflowConfig, } from "./workflow.js";
6
- export type { ZiteSchedule } from "../schedules/index.js";
7
- export type { ZiteTrigger, ZiteTriggerSubscribe, ZiteTriggerSubscribeInput, ZiteTriggerSubscribeResult, ZiteTriggerUnsubscribe, ZiteTriggerUnsubscribeInput, } from "../backend/index.js";
8
- declare module "@tanstack/start-client-core" {
9
- interface ServerFnOptions {
10
- /** What this function does, in a sentence. Shown in the editor. */
11
- description: string;
12
- }
13
- }
14
- declare module "@tanstack/react-router" {
15
- interface StaticDataRouteOption {
16
- /** What an API route does, in a sentence. Shown in the editor. */
17
- description?: string;
18
- }
19
- }
20
- /** By the role's id or its name. */
21
- export declare const hasRole: (user: User, role: string) => boolean;
22
- /**
23
- * The platform's sign-in page, returning to `redirectTo` (default: the current
24
- * page). For guards: `throw redirect({ href: loginHref(), reloadDocument: true })`.
25
- */
26
- export declare function loginHref(redirectTo?: string): string;
27
- /** What a zitejs middleware means, for describe. Keyed by identity, so composing or re-exporting keeps it. */
28
- export type ZiteMiddlewareKind = {
29
- kind: "signedIn" | "anyone" | "factory";
30
- } | {
31
- kind: "webhook";
32
- paused?: true;
33
- } | {
34
- kind: "role";
35
- role: string;
36
- };
37
- /** @internal */
38
- export declare const ziteMiddlewareKind: (middleware: unknown) => ZiteMiddlewareKind | undefined;
39
- /** Only signed-in users. Handlers get `context.user: User`. */
40
- export declare const signedIn: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, {
41
- user: User;
42
- }>;
43
- /** Anyone, signed in or not. Handlers get `context.user: User | null`. */
44
- export declare const anyone: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, {
45
- user: User | null;
46
- }>;
47
- /**
48
- * Webhooks delivered by the platform, which already checked the URL token.
49
- * `webhook.paused` keeps the URL but runs nothing: the platform answers the
50
- * provider 200 and drops the delivery until it's switched back.
51
- */
52
- export declare const webhook: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, undefined> & {
53
- paused: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, undefined>;
54
- };
55
- /** Signed-in users with this role. */
56
- export declare const role: (name: string) => import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, readonly [import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, {
57
- user: User;
58
- }>], undefined>;
59
- declare const compiled: import("@tanstack/react-start").FunctionMiddlewareAfterClient<{}, unknown, undefined, undefined, undefined>;
60
- declare const builder: import("@tanstack/react-start").ServerFnBuilder<import("@tanstack/react-start").Register, import("@tanstack/react-start").Method, true>;
61
- type SignedInFn = ReturnType<typeof builder.middleware<readonly [typeof compiled, typeof signedIn]>>;
62
- type PublicFn = ReturnType<typeof builder.middleware<readonly [typeof compiled, typeof anyone]>>;
63
- /** A server function only signed-in users can call. */
64
- export declare const signedInFn: SignedInFn;
65
- /** A server function anyone can call (external apps only). */
66
- export declare const publicFn: PublicFn;
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';