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,261 @@
1
+ import { z } from 'zod';
2
+ import { airtableEqualsFormula } from './arrayFields.js';
3
+ // =============================================================================
4
+ // Condition Operators
5
+ // =============================================================================
6
+ /**
7
+ * Supported filter operators for Airtable queries
8
+ */
9
+ export const WhereConditionOperators = z.enum([
10
+ 'contains',
11
+ 'not',
12
+ 'in',
13
+ 'notIn',
14
+ 'lt',
15
+ 'lte',
16
+ 'gt',
17
+ 'gte',
18
+ 'ilike',
19
+ ]);
20
+ const WHERE_CONDITION_OPERATORS = WhereConditionOperators.options;
21
+ /**
22
+ * Check if a key is a condition operator
23
+ */
24
+ export const isConditionOperator = (key) => WHERE_CONDITION_OPERATORS.includes(key);
25
+ /**
26
+ * Check if a value is a nested condition object (e.g., { contains: 'value' })
27
+ */
28
+ export const isNestedCondition = (value) => {
29
+ if (value === null || typeof value !== 'object')
30
+ return false;
31
+ if (Array.isArray(value))
32
+ return false;
33
+ // Check if any keys are condition operators
34
+ return Object.keys(value).some(key => isConditionOperator(key));
35
+ };
36
+ // =============================================================================
37
+ // Formula Helpers
38
+ // =============================================================================
39
+ /** Regex to validate Airtable record IDs */
40
+ const AIRTABLE_RECORD_ID_REGEX = /^rec[a-zA-Z0-9]{14}$/;
41
+ /** SDK field name for record ID */
42
+ const SDK_ID_FIELD = 'id';
43
+ /**
44
+ * Check if a string is a valid Airtable record ID
45
+ */
46
+ export const isValidRecordId = (value) => typeof value === 'string' && AIRTABLE_RECORD_ID_REGEX.test(value);
47
+ /**
48
+ * Escape a string value for an Airtable formula. Backslashes go first: a
49
+ * caller's trailing backslash would otherwise escape the closing quote and let
50
+ * the rest of the value into the formula.
51
+ */
52
+ const escapeFormulaString = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
53
+ // Record ids go into the formula unquoted, so only well-formed ones may: any
54
+ // other value matches no record anyway.
55
+ export const isRecordId = (value) => typeof value === 'string' && isValidRecordId(value);
56
+ const anyRecordIdOf = (recordIds) => recordIds.length
57
+ ? `OR(${recordIds.map(id => `RECORD_ID() = '${id}'`).join(', ')})`
58
+ : 'FALSE()';
59
+ // A linked record's id comes as a one-item list.
60
+ const singleValue = (value) => Array.isArray(value) && value.length === 1 ? value[0] : value;
61
+ /**
62
+ * Format a value for use in Airtable formulas. A lookup's value, or a linked
63
+ * record's primary value, comes as a one-item list, at any depth.
64
+ */
65
+ const getAirtableFilterValue = (value) => {
66
+ if (Array.isArray(value) && value.length === 1) {
67
+ return getAirtableFilterValue(value[0]);
68
+ }
69
+ if (value instanceof Date) {
70
+ if (!Number.isFinite(value.getTime())) {
71
+ throw new Error('Invalid Date passed to Airtable filter formula. Use a valid Date or ISO date string.');
72
+ }
73
+ return `"${value.toISOString()}"`;
74
+ }
75
+ if (typeof value === 'string') {
76
+ return `"${escapeFormulaString(value)}"`;
77
+ }
78
+ if (typeof value === 'boolean') {
79
+ return value ? 'TRUE()' : 'FALSE()';
80
+ }
81
+ if (value === undefined || value === null) {
82
+ return 'BLANK()';
83
+ }
84
+ if ((typeof value === 'number' && Number.isFinite(value)) ||
85
+ typeof value === 'bigint') {
86
+ return String(value);
87
+ }
88
+ // Anything else would be pasted into the formula as is.
89
+ const what = Array.isArray(value)
90
+ ? 'a list'
91
+ : typeof value === 'number'
92
+ ? "a number that isn't finite"
93
+ : typeof value;
94
+ throw new Error(`Can't filter an Airtable field by ${what} here: pass a string, number, boolean, date or null.`);
95
+ };
96
+ /**
97
+ * Convert filters to Airtable filterByFormula string.
98
+ *
99
+ * Supports operators: contains, not, in, notIn, lt, lte, gt, gte, ilike
100
+ *
101
+ * @example
102
+ * // Equality
103
+ * { name: 'John' } -> {Name}="John"
104
+ *
105
+ * @example
106
+ * // Contains
107
+ * { name: { contains: 'john' } } -> SEARCH("john", {Name}) != ""
108
+ *
109
+ * @example
110
+ * // Multiple conditions
111
+ * { status: 'active', age: { gte: 18 } } -> AND({Status}="active", {Age}>=18)
112
+ */
113
+ export const filtersToFormula = async ({ filters, tableSchema, getPrimaryFieldForRecord, }) => {
114
+ if (!filters || Object.keys(filters).length === 0)
115
+ return undefined;
116
+ const conditions = [];
117
+ for (const [field, condition] of Object.entries(filters)) {
118
+ let value = condition;
119
+ let operator = 'equals';
120
+ if (isNestedCondition(condition)) {
121
+ operator = Object.keys(condition).find(isConditionOperator);
122
+ value = condition[operator];
123
+ }
124
+ // Special case for id field - use RECORD_ID()
125
+ if (field === SDK_ID_FIELD || field === 'id') {
126
+ const recordIds = (Array.isArray(value) ? value : [value]).map(singleValue);
127
+ if (operator === 'equals') {
128
+ const [recordId] = recordIds;
129
+ conditions.push(isRecordId(recordId) ? `RECORD_ID() = '${recordId}'` : 'FALSE()');
130
+ }
131
+ else {
132
+ const recordIdClause = anyRecordIdOf(recordIds.filter(isRecordId));
133
+ if (operator === 'notIn' || operator === 'not') {
134
+ conditions.push(`NOT(${recordIdClause})`);
135
+ continue;
136
+ }
137
+ conditions.push(recordIdClause);
138
+ }
139
+ continue;
140
+ }
141
+ // Find the actual field in the schema
142
+ const fieldInfo = tableSchema?.fields.find(f => f.id === field || f.name === field);
143
+ // Skip undefined conditions
144
+ if (condition === undefined)
145
+ continue;
146
+ // Use field name from schema if available, otherwise use the key as-is,
147
+ // which then can't close the braces it's pasted between.
148
+ if (!fieldInfo && /[{}]/.test(field)) {
149
+ throw new Error(`Can't filter by "${field}": an Airtable field name can't contain { or }.`);
150
+ }
151
+ const fieldName = `{${fieldInfo?.name || field}}`;
152
+ // Pre-process linked record values
153
+ if (fieldInfo?.type === 'multipleRecordLinks' && getPrimaryFieldForRecord) {
154
+ const linkedRecordOptions = fieldInfo.options;
155
+ let linkedRecords = [];
156
+ if (value !== undefined) {
157
+ if (!Array.isArray(value)) {
158
+ if (value !== '') {
159
+ linkedRecords = [String(value)];
160
+ }
161
+ }
162
+ else {
163
+ linkedRecords = value;
164
+ }
165
+ }
166
+ // Resolve record IDs to primary field values
167
+ if (linkedRecordOptions?.linkedTableId) {
168
+ value = (await Promise.all(linkedRecords.map(async (recordValue) => {
169
+ const recordId = singleValue(recordValue);
170
+ if (isValidRecordId(recordId)) {
171
+ const primaryColumn = await getPrimaryFieldForRecord(linkedRecordOptions.linkedTableId, recordId);
172
+ if (primaryColumn) {
173
+ return primaryColumn;
174
+ }
175
+ }
176
+ return recordValue;
177
+ }))).flat();
178
+ }
179
+ }
180
+ // Handle checkbox fields with string values
181
+ if (fieldInfo?.type === 'checkbox' &&
182
+ (operator === 'equals' || operator === 'not') &&
183
+ typeof value === 'string') {
184
+ const TRUE_VALUES = ['true', 'yes', 'y', 'TRUE'];
185
+ value = TRUE_VALUES.includes(value.toLowerCase()) ? true : false;
186
+ }
187
+ // Skip undefined values
188
+ if (value === undefined)
189
+ continue;
190
+ const textFieldRef = `ARRAYJOIN(${fieldName})`;
191
+ const equalsClause = (v) => fieldInfo
192
+ ? airtableEqualsFormula({
193
+ field: fieldInfo,
194
+ fieldName,
195
+ value: getAirtableFilterValue(v),
196
+ })
197
+ : `${fieldName}=${getAirtableFilterValue(v)}`;
198
+ // Build condition based on operator
199
+ switch (operator) {
200
+ case 'equals':
201
+ if (Array.isArray(value)) {
202
+ const andClauses = value.map(equalsClause);
203
+ conditions.push(`AND(${andClauses.join(',')})`);
204
+ }
205
+ else {
206
+ conditions.push(equalsClause(value));
207
+ }
208
+ break;
209
+ case 'contains':
210
+ if (Array.isArray(value)) {
211
+ const andClauses = value.map(v => `SEARCH(${getAirtableFilterValue(v)}, ${textFieldRef}) != ""`);
212
+ conditions.push(`AND(${andClauses.join(',')})`);
213
+ }
214
+ else {
215
+ conditions.push(`SEARCH(${getAirtableFilterValue(value)}, ${textFieldRef}) != ""`);
216
+ }
217
+ break;
218
+ case 'not':
219
+ if (Array.isArray(value) && value.length === 0) {
220
+ break;
221
+ }
222
+ conditions.push(`NOT(${Array.isArray(value)
223
+ ? `OR(${value.map(equalsClause).join(',')})`
224
+ : equalsClause(value)})`);
225
+ break;
226
+ // One value stands for a list of it, as on the id path: skipping it would match every record.
227
+ case 'in': {
228
+ const orClauses = (Array.isArray(value) ? value : [value]).map(equalsClause);
229
+ conditions.push(`OR(${orClauses.join(',')})`);
230
+ break;
231
+ }
232
+ case 'notIn': {
233
+ const orClauses = (Array.isArray(value) ? value : [value]).map(equalsClause);
234
+ if (orClauses.length > 0) {
235
+ conditions.push(`NOT(OR(${orClauses.join(',')}))`);
236
+ }
237
+ break;
238
+ }
239
+ case 'lt':
240
+ conditions.push(`${fieldName}<${getAirtableFilterValue(value)}`);
241
+ break;
242
+ case 'lte':
243
+ conditions.push(`${fieldName}<=${getAirtableFilterValue(value)}`);
244
+ break;
245
+ case 'gt':
246
+ conditions.push(`${fieldName}>${getAirtableFilterValue(value)}`);
247
+ break;
248
+ case 'gte':
249
+ conditions.push(`${fieldName}>=${getAirtableFilterValue(value)}`);
250
+ break;
251
+ case 'ilike':
252
+ conditions.push(`LOWER(${textFieldRef}) = LOWER(${getAirtableFilterValue(value)})`);
253
+ break;
254
+ }
255
+ }
256
+ if (conditions.length === 0)
257
+ return undefined;
258
+ if (conditions.length === 1)
259
+ return conditions[0];
260
+ return `AND(${conditions.join(',')})`;
261
+ };
@@ -0,0 +1,6 @@
1
+ import { type AirtableSettings } from './dispatch.js';
2
+ import type { HostRequestState, PlatformCallResult } from '../../types.js';
3
+ /** The build's Airtable integration `integrationId`, or undefined when it isn't one. */
4
+ export declare const airtableSettingsOf: (integrationId: string) => AirtableSettings | undefined;
5
+ /** One generated Airtable table call, run here with the connection's token, which the outbound fetch refreshes on a 401. */
6
+ export declare function runAirtableCall(host: HostRequestState, connectionOf: () => Promise<PlatformCallResult>, integrationId: string, settings: AirtableSettings, methodName: string, params: unknown): Promise<unknown>;
@@ -0,0 +1,51 @@
1
+ import { builtAirtableSettings } from './built.js';
2
+ import { createAirtableCache } from './cache.js';
3
+ import { executeAirtableCall } from './dispatch.js';
4
+ import { ZiteError, isZiteErrorCode } from '../../errors.js';
5
+ import { rememberConnection } from '../outbound.js';
6
+ const AIRTABLE_API = 'https://api.airtable.com';
7
+ /** The build's Airtable integration `integrationId`, or undefined when it isn't one. */
8
+ export const airtableSettingsOf = (integrationId) => builtAirtableSettings && Object.hasOwn(builtAirtableSettings, integrationId)
9
+ ? builtAirtableSettings[integrationId]
10
+ : undefined;
11
+ /** One generated Airtable table call, run here with the connection's token, which the outbound fetch refreshes on a 401. */
12
+ export async function runAirtableCall(host, connectionOf, integrationId, settings, methodName, params) {
13
+ // As classic: a demo reaches no connected account.
14
+ if (host.mode === 'demo')
15
+ throw new ZiteError('FORBIDDEN', 'This action is not available in demo mode');
16
+ const connection = await connectionOf();
17
+ if ('error' in connection) {
18
+ const { code, message, userFacingMessage } = connection.error;
19
+ throw new ZiteError({
20
+ code: isZiteErrorCode(code) ? code : 'INTERNAL_ERROR',
21
+ message,
22
+ userFacingMessage,
23
+ });
24
+ }
25
+ const token = connection.value
26
+ ?.accessToken;
27
+ if (typeof token !== 'string') {
28
+ throw new ZiteError('INTERNAL_ERROR', `The ${integrationId} connection has no token`);
29
+ }
30
+ rememberConnection(host, integrationId, connection.value);
31
+ host.airtableReads ??= new Map();
32
+ const caches = (host.airtableCaches ??= new Map());
33
+ let cache = caches.get(token);
34
+ if (!cache) {
35
+ cache = createAirtableCache({ token, waitUntil: host.waitUntil });
36
+ caches.set(token, cache);
37
+ }
38
+ return executeAirtableCall({
39
+ settings,
40
+ reads: host.airtableReads,
41
+ cache: await cache,
42
+ fetch: (path, init) => fetch(`${AIRTABLE_API}${path}`, {
43
+ method: init.method,
44
+ headers: {
45
+ authorization: `Bearer ${token}`,
46
+ 'content-type': 'application/json',
47
+ },
48
+ body: init.body === undefined ? undefined : JSON.stringify(init.body),
49
+ }),
50
+ }, methodName, params);
51
+ }
@@ -0,0 +1,37 @@
1
+ import type { AirtableLockTable } from '../../../sync/lib.js';
2
+ import type { AirtableNameMappings } from './dispatch.js';
3
+ /** An Airtable integration as the build declares it, in the platform's shape. */
4
+ export type BuiltAirtableSettings = {
5
+ serviceType: 'airtable';
6
+ baseId: string;
7
+ nameMappings: AirtableNameMappings | null;
8
+ };
9
+ /** A zite.config.json, as far as the build reads it: each entry is checked where it's used. */
10
+ export type ConfigFile = {
11
+ integrations?: Record<string, unknown>;
12
+ integrationSettings?: Record<string, unknown>;
13
+ };
14
+ /** What an Airtable integration's zite.lock entry maps: its base, and each table's and field's id by SDK name. */
15
+ type AirtableIdMappings = {
16
+ base: string;
17
+ tables: AirtableLockTable[];
18
+ };
19
+ /** A zite.lock's Airtable integrations, by name. */
20
+ export type LockFile = {
21
+ airtable: Record<string, AirtableIdMappings>;
22
+ };
23
+ export type AirtableSources = {
24
+ appConfig?: ConfigFile;
25
+ appLock?: LockFile;
26
+ workspaceConfig?: ConfigFile;
27
+ workspaceLock?: LockFile;
28
+ /** With zite.schema.json the workspace database is the schema's, and an app's own `databases` entry is dropped. */
29
+ hasSchema: boolean;
30
+ };
31
+ /** A zite.config.json's JSON as the build reads it; undefined when it isn't one. */
32
+ export declare const configFileOf: (json: unknown) => ConfigFile | undefined;
33
+ /** A zite.lock's JSON as the build reads it: the Airtable entries the platform writes, and nothing else. */
34
+ export declare const lockFileOf: (json: unknown) => LockFile | undefined;
35
+ /** Each Airtable integration the build can call, by name, as the platform's `startIntegrationSettings` answers. */
36
+ export declare const airtableSettingsFrom: ({ appConfig, appLock, workspaceConfig, workspaceLock, hasSchema, }: AirtableSources) => Record<string, BuiltAirtableSettings>;
37
+ export {};
@@ -0,0 +1,138 @@
1
+ // A build's Airtable integrations, from the repo files the platform derives them from (restly's
2
+ // `getEffectiveAppIntegrations`, through `startIntegrationSettings`): the app's own entries, then the workspace's it
3
+ // has settings for, each read against the app's zite.lock. Keep the two in step.
4
+ import { z } from 'zod';
5
+ import { isCredentialServiceType, NON_CREDENTIAL_SERVICE_TYPES, normalizeIntegrationServiceType, } from '../../../integrations/rules.js';
6
+ const record = z.record(z.string(), z.unknown());
7
+ const configFile = z.object({
8
+ integrations: record.optional().catch(undefined),
9
+ integrationSettings: record.optional().catch(undefined),
10
+ });
11
+ const idMappings = z.object({
12
+ base: z.string(),
13
+ tables: z.array(z.object({
14
+ id: z.string(),
15
+ sdkName: z.string(),
16
+ name: z.string().optional(),
17
+ primaryFieldId: z.string(),
18
+ fields: z.array(z.object({
19
+ id: z.string(),
20
+ sdkName: z.string(),
21
+ type: z.string(),
22
+ name: z.string(),
23
+ config: record.optional(),
24
+ })),
25
+ })),
26
+ });
27
+ /** A zite.config.json's JSON as the build reads it; undefined when it isn't one. */
28
+ export const configFileOf = (json) => {
29
+ const parsed = configFile.safeParse(json);
30
+ return parsed.success ? parsed.data : undefined;
31
+ };
32
+ /** A zite.lock's JSON as the build reads it: the Airtable entries the platform writes, and nothing else. */
33
+ export const lockFileOf = (json) => {
34
+ const parsed = z.object({ integrations: record }).safeParse(json);
35
+ if (!parsed.success)
36
+ return undefined;
37
+ const airtable = {};
38
+ for (const [name, entry] of Object.entries(parsed.data.integrations)) {
39
+ const mapped = z.object({ idMappings }).safeParse(entry);
40
+ if (mapped.success)
41
+ airtable[name] = mapped.data.idMappings;
42
+ }
43
+ return { airtable };
44
+ };
45
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
46
+ const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
47
+ // Airtable base ids look like `appXYZ…`; anything else is a display name, which only the lock resolves.
48
+ const isAirtableBaseId = (value) => /^app[A-Za-z0-9]{14}$/.test(String(value));
49
+ /** An Airtable entry with its base and the lock's mappings; a base that isn't text names none the platform can use. */
50
+ const convert = (name, base, lock) => {
51
+ const mappings = lock?.airtable[name];
52
+ const locked = mappings && (!isAirtableBaseId(base) || mappings.base === base)
53
+ ? mappings
54
+ : undefined;
55
+ const given = base ?? '';
56
+ const baseId = locked?.base ?? (typeof given === 'string' ? given : undefined);
57
+ const tables = Object.fromEntries((locked?.tables ?? []).map(table => [
58
+ table.id,
59
+ {
60
+ mapping: { sdkName: table.sdkName },
61
+ primaryFieldId: table.primaryFieldId,
62
+ fields: Object.fromEntries(table.fields.map(field => [
63
+ field.id,
64
+ {
65
+ mapping: { sdkName: field.sdkName },
66
+ fieldType: field.type,
67
+ fieldName: field.name,
68
+ ...(field.config ? { fieldOptions: field.config } : {}),
69
+ },
70
+ ])),
71
+ },
72
+ ]));
73
+ return {
74
+ baseId,
75
+ nameMappings: {
76
+ bases: {
77
+ [String(baseId)]: {
78
+ mapping: { sdkName: typeof base === 'string' ? base : '' },
79
+ tables,
80
+ },
81
+ },
82
+ },
83
+ };
84
+ };
85
+ const isAirtable = (entry) => isRecord(entry) && entry.type === 'airtable';
86
+ const isServiceType = (type) => {
87
+ const normalized = typeof type === 'string'
88
+ ? normalizeIntegrationServiceType(type)
89
+ : undefined;
90
+ return (normalized !== undefined &&
91
+ (isCredentialServiceType(normalized) ||
92
+ NON_CREDENTIAL_SERVICE_TYPES.includes(normalized)));
93
+ };
94
+ const isOptionalString = (value) => value === undefined || value === null || typeof value === 'string';
95
+ /**
96
+ * Whether the platform's conversion of an entry gets past what any type checks (`convertConfigToIntegrationTemplate`
97
+ * throws on an unknown or missing type, a connectionId that isn't a string, and an email sender that isn't one).
98
+ * The platform skips an entry it can't read, whatever its type.
99
+ */
100
+ const platformReads = (entry) => isRecord(entry) &&
101
+ isServiceType(entry.type) &&
102
+ (!entry.connectionId || typeof entry.connectionId === 'string') &&
103
+ (normalizeIntegrationServiceType(String(entry.type)) !== 'email' ||
104
+ (isOptionalString(entry.fromName) && isOptionalString(entry.fromEmail)));
105
+ /** Each Airtable integration the build can call, by name, as the platform's `startIntegrationSettings` answers. */
106
+ export const airtableSettingsFrom = ({ appConfig, appLock, workspaceConfig, workspaceLock, hasSchema, }) => {
107
+ // The app's own entries, each shadowing the workspace's of its name: only those the platform could read.
108
+ const own = new Set();
109
+ const effective = [];
110
+ for (const [name, entry] of Object.entries(appConfig?.integrations ?? {})) {
111
+ if (!platformReads(entry) || (hasSchema && entry.type === 'databases'))
112
+ continue;
113
+ if (isAirtable(entry))
114
+ effective.push([name, convert(name, entry.base, appLock)]);
115
+ own.add(name);
116
+ }
117
+ const settings = appConfig?.integrationSettings;
118
+ for (const [name, entry] of Object.entries(workspaceConfig?.integrations ?? {})) {
119
+ // A workspace Airtable is the app's only once the app names it in its settings.
120
+ if (!isAirtable(entry) ||
121
+ !platformReads(entry) ||
122
+ own.has(name) ||
123
+ !settings ||
124
+ !hasOwn(settings, name))
125
+ continue;
126
+ const workspace = convert(name, entry.base, workspaceLock);
127
+ const appSettings = settings[name];
128
+ const base = isRecord(appSettings) && hasOwn(appSettings, 'base')
129
+ ? appSettings.base
130
+ : workspace.baseId;
131
+ const applied = appSettings ? convert(name, base, appLock) : workspace;
132
+ if (applied.baseId)
133
+ effective.push([name, applied]);
134
+ }
135
+ return Object.fromEntries(effective.flatMap(([name, { baseId, nameMappings }]) => baseId === undefined
136
+ ? []
137
+ : [[name, { serviceType: 'airtable', baseId, nameMappings }]]));
138
+ };
@@ -0,0 +1,3 @@
1
+ import type { HostRequestState } from '../types.js';
2
+ /** A beacon from the runtime: a batch of events, or one. Only a live page's reach the platform. */
3
+ export declare const takeAnalytics: (request: Request, host: HostRequestState) => Promise<Response>;
@@ -0,0 +1,59 @@
1
+ // The runtime's page analytics, taken on the app's own origin and handed to the platform's runs service on the
2
+ // request's token. The service checks the events and stamps the org and app from the token, never from the page.
3
+ import { textUpTo } from './caps.js';
4
+ import { directAccess, sendOnToken } from './transport.js';
5
+ const MAX_ANALYTICS_BYTES = 256 * 1024;
6
+ const RUNS_TIMEOUT_MS = 5_000;
7
+ const accepted = () => Response.json({ accepted: true }, { status: 202 });
8
+ const parsed = (raw) => {
9
+ if (raw === undefined)
10
+ return undefined;
11
+ try {
12
+ return JSON.parse(raw);
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ };
18
+ // Workers sets the visitor's country on the request; Node has none.
19
+ const countryOf = (request) => {
20
+ const country = request.headers.get('cf-ipcountry') ??
21
+ request.cf?.country;
22
+ return typeof country === 'string' ? country : undefined;
23
+ };
24
+ /** A beacon from the runtime: a batch of events, or one. Only a live page's reach the platform. */
25
+ export const takeAnalytics = async (request, host) => {
26
+ if (request.method !== 'POST')
27
+ return new Response('Method not allowed', { status: 405 });
28
+ if (host.mode !== 'live')
29
+ return accepted();
30
+ const access = await directAccess(host);
31
+ if (!access?.urls.runs)
32
+ return accepted();
33
+ const body = parsed(await textUpTo(request, MAX_ANALYTICS_BYTES));
34
+ if (body === undefined)
35
+ return Response.json({ error: 'Invalid analytics payload' }, { status: 400 });
36
+ const events = body && typeof body === 'object' && 'events' in body ? body.events : [body];
37
+ try {
38
+ const answer = await sendOnToken(access.token, `${access.urls.runs}/ingest`, {
39
+ method: 'POST',
40
+ body: JSON.stringify({
41
+ kind: 'analytics',
42
+ events,
43
+ userAgent: request.headers.get('user-agent') ?? '',
44
+ country: countryOf(request),
45
+ }),
46
+ timeoutMs: RUNS_TIMEOUT_MS,
47
+ });
48
+ if (!answer.ok && answer.status !== 400)
49
+ console.error(`[zite] page analytics not kept: the runs service answered ${answer.status}`);
50
+ return new Response(answer.body, {
51
+ status: answer.status,
52
+ headers: { 'content-type': 'application/json' },
53
+ });
54
+ }
55
+ catch (error) {
56
+ console.error('[zite] page analytics not kept', error);
57
+ return accepted();
58
+ }
59
+ };
@@ -0,0 +1,5 @@
1
+ import type { HostRequestState, PlatformCallInput } from '../types.js';
2
+ /** One call the app's SDK made, under the access it ran with: its value, or a throw the app may catch. */
3
+ export declare const callPlatform: (host: HostRequestState, input: PlatformCallInput) => Promise<unknown>;
4
+ /** For tests: forget what this isolate learned. */
5
+ export declare const resetLocalConnections: () => void;
@@ -0,0 +1,104 @@
1
+ // Every platform call an app's SDK makes, by integration id: the data and the ids the platform answers itself, then an
2
+ // Airtable integration the build declares, then email under its integration's own name. Server-only.
3
+ import { RESERVED_INTEGRATION_IDS } from '../../internal/reservedIds.js';
4
+ import { isZiteErrorCode, ZiteError } from '../errors.js';
5
+ import { workspaceSchemaNames } from '../build/placeholders/workspaceSchema.js';
6
+ import { airtableSettingsOf, runAirtableCall } from './airtable/index.js';
7
+ import { integrationsGet, resetConnections } from './connections.js';
8
+ import { DATA_INTEGRATION_ID, runDataCall } from './data/index.js';
9
+ import { dataFetch } from './data/fetch.js';
10
+ import { resetLocal } from './local.js';
11
+ import { metaCall } from './meta.js';
12
+ import { rememberConnection, withGatewayUrl, withRefreshedTokens, } from './outbound.js';
13
+ import { recordCall, somethingWentWrong } from './runLog.js';
14
+ import { serviceCall } from './services.js';
15
+ import { NoPlatformError, requireAccess } from './transport.js';
16
+ const failedWith = ({ code, message, userFacingMessage, }) => new ZiteError({
17
+ code: isZiteErrorCode(code) ? code : 'INTERNAL_ERROR',
18
+ message,
19
+ userFacingMessage,
20
+ });
21
+ // Errors come back as values, so the one the app sees keeps its code; one of ours is logged and said no more of.
22
+ const answered = async (host, input, run) => {
23
+ let result;
24
+ try {
25
+ result = await run();
26
+ }
27
+ catch (error) {
28
+ if (error instanceof NoPlatformError)
29
+ throw error;
30
+ result = somethingWentWrong(host, input, error);
31
+ }
32
+ if ('value' in result)
33
+ return result.value;
34
+ throw failedWith(result.error);
35
+ };
36
+ const notServed = async ({ className, methodName, }) => {
37
+ throw new ZiteError('NOT_FOUND', `${className}.${methodName} isn't served yet`);
38
+ };
39
+ const data = async (host, input) => {
40
+ await requireAccess(host);
41
+ const target = {
42
+ baseId: (await host.provider?.context())?.baseId ?? null,
43
+ names: workspaceSchemaNames,
44
+ };
45
+ return recordCall(host, input, input.params, () => runDataCall({ dataFetch: dataFetch(host) }, target, host.mode, input.methodName, input.params));
46
+ };
47
+ // Its values then name the calls made with them.
48
+ const connections = async (host, input) => {
49
+ const value = withGatewayUrl(host, withRefreshedTokens(await answered(host, input, () => integrationsGet(host, input))));
50
+ rememberConnection(host, String(input.params?.name ?? ''), value);
51
+ return value;
52
+ };
53
+ const service = (name) => (host, input) => answered(host, input, () => serviceCall(host, input, name));
54
+ const HANDLERS = {
55
+ [DATA_INTEGRATION_ID]: data,
56
+ [RESERVED_INTEGRATION_IDS.connections]: connections,
57
+ [RESERVED_INTEGRATION_IDS.meta]: (host, input) => answered(host, input, () => metaCall(host, input)),
58
+ [RESERVED_INTEGRATION_IDS.pdf]: (host, input) => input.methodName === 'renderHtml'
59
+ ? service('pdf')(host, input)
60
+ : notServed(input),
61
+ [RESERVED_INTEGRATION_IDS.schedules]: service('schedules'),
62
+ };
63
+ const airtable = (host, input, settings) => {
64
+ const connection = {
65
+ integrationId: RESERVED_INTEGRATION_IDS.connections,
66
+ className: 'Connections',
67
+ methodName: 'get',
68
+ params: { name: input.integrationId },
69
+ access: input.access,
70
+ };
71
+ const connectionOf = async () => {
72
+ try {
73
+ return await integrationsGet(host, connection);
74
+ }
75
+ catch (error) {
76
+ if (error instanceof NoPlatformError)
77
+ throw error;
78
+ return somethingWentWrong(host, connection, error);
79
+ }
80
+ };
81
+ return recordCall(host, input, input.params, () => runAirtableCall(host, connectionOf, input.integrationId, settings, input.methodName, input.params));
82
+ };
83
+ // Classic's workflow-runner serves only send too, and answers the rest with this message.
84
+ const email = async (host, input) => {
85
+ if (input.methodName !== 'send')
86
+ throw new ZiteError('BAD_REQUEST', `Unknown email method: ${input.methodName}`);
87
+ return service('email')(host, input);
88
+ };
89
+ /** One call the app's SDK made, under the access it ran with: its value, or a throw the app may catch. */
90
+ export const callPlatform = (host, input) => {
91
+ if (Object.hasOwn(HANDLERS, input.integrationId))
92
+ return HANDLERS[input.integrationId](host, input);
93
+ const settings = airtableSettingsOf(input.integrationId);
94
+ if (settings)
95
+ return airtable(host, input, settings);
96
+ if (input.className === 'Email')
97
+ return email(host, input);
98
+ return notServed(input);
99
+ };
100
+ /** For tests: forget what this isolate learned. */
101
+ export const resetLocalConnections = () => {
102
+ resetConnections();
103
+ resetLocal();
104
+ };