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,216 @@
1
+ import { buildSdkNameMappingsForBase } from './sqlNameMappings.js';
2
+ import { transformFieldNamesToIds, transformFieldsToFieldIds, transformFiltersToFieldIds, transformLinkedRecordFields, transformMatchOnFields, transformRecordToSdkNames, transformSortToFieldIds, } from './transformations.js';
3
+ import { ZITE_PLATFORM_FAULT_FLAG, } from './types.js';
4
+ export const DEMO_UNAVAILABLE_MESSAGE = 'This action is not available in demo mode';
5
+ // An allowlist, so a database method added later is refused until it's listed.
6
+ export const DEMO_READ_DATABASE_METHODS = new Set([
7
+ 'findOne',
8
+ 'findAll',
9
+ 'executeSql',
10
+ 'findAllUsers',
11
+ ]);
12
+ const STATUS_TO_ZITE_ERROR_CODE = {
13
+ 400: 'BAD_REQUEST',
14
+ 401: 'UNAUTHORIZED',
15
+ 403: 'FORBIDDEN',
16
+ 404: 'NOT_FOUND',
17
+ 409: 'CONFLICT',
18
+ 429: 'RATE_LIMITED',
19
+ };
20
+ // A 4xx answers with its status as a coded ZiteError; a 5xx stays as thrown, flagged as ours, not the app's.
21
+ export function asZiteClientError(error) {
22
+ const status = error?.statusCode;
23
+ if (typeof status !== 'number' || status < 400)
24
+ return error;
25
+ if (status >= 500) {
26
+ if (error && typeof error === 'object')
27
+ error[ZITE_PLATFORM_FAULT_FLAG] = true;
28
+ return error;
29
+ }
30
+ const tagged = new Error(error instanceof Error ? error.message : String(error));
31
+ tagged.name = 'ZiteError';
32
+ tagged.code =
33
+ STATUS_TO_ZITE_ERROR_CODE[status] ?? 'BAD_REQUEST';
34
+ tagged.statusCode = status;
35
+ tagged.cause = error;
36
+ if (error instanceof Error)
37
+ tagged.stack = error.stack;
38
+ return tagged;
39
+ }
40
+ /** One `zite.*` data call, as classic's dispatch runs it. */
41
+ export async function executeDatabasesCall(context, methodName, params) {
42
+ try {
43
+ return await runDatabasesCall(context, methodName, params ?? {});
44
+ }
45
+ catch (error) {
46
+ throw asZiteClientError(error);
47
+ }
48
+ }
49
+ async function runDatabasesCall(context, methodName, params) {
50
+ const { baseRunner: sdk, baseId, nameMappings, tables } = context;
51
+ if (context.readOnly && !DEMO_READ_DATABASE_METHODS.has(methodName)) {
52
+ throw Object.assign(new Error(DEMO_UNAVAILABLE_MESSAGE), {
53
+ statusCode: 403,
54
+ });
55
+ }
56
+ if (methodName === 'findAllUsers') {
57
+ return sdk.auth.findAll({
58
+ baseId,
59
+ appIds: params.appIds,
60
+ filters: params.filters,
61
+ filter: params.filter,
62
+ offset: params.offset,
63
+ sort: params.sort,
64
+ limit: params.limit,
65
+ });
66
+ }
67
+ if (methodName === 'updateUserProfile') {
68
+ const userId = params.userId ?? params.id;
69
+ const profile = params.profile ?? params.data ?? params.record ?? params;
70
+ if (!userId || !profile || typeof profile !== 'object') {
71
+ throw new Error('updateUserProfile requires a user id and profile data');
72
+ }
73
+ if ('email' in profile) {
74
+ throw new Error('A Zite user email address cannot be updated');
75
+ }
76
+ return sdk.auth.update({
77
+ baseId,
78
+ userId,
79
+ profile: {
80
+ firstName: profile.firstName,
81
+ lastName: profile.lastName,
82
+ image: profile.image,
83
+ },
84
+ });
85
+ }
86
+ if (methodName === 'executeSql') {
87
+ const query = params?.query ?? params?.sql;
88
+ if (typeof query !== 'string' || query.trim() === '') {
89
+ throw new Error('executeSql requires a non-empty `query` parameter');
90
+ }
91
+ return await sdk.sql.execute({
92
+ baseId,
93
+ sql: query,
94
+ params: params.params,
95
+ statementTimeoutMs: params.statementTimeoutMs,
96
+ nameMappings: nameMappings && tables
97
+ ? buildSdkNameMappingsForBase({
98
+ metadata: { tables },
99
+ settingsNameMappings: nameMappings,
100
+ })
101
+ : undefined,
102
+ });
103
+ }
104
+ const tableId = params.tableId;
105
+ if (!tableId) {
106
+ throw new Error('Databases calls require tableId in params');
107
+ }
108
+ const fieldMappings = nameMappings?.tables?.[tableId]?.fields;
109
+ const table = tables?.find(t => t.id === tableId);
110
+ switch (methodName) {
111
+ case 'findOne': {
112
+ const { id: recordId, filters, fields } = params;
113
+ const transformedFields = transformFieldsToFieldIds(fields, table, fieldMappings);
114
+ if (recordId) {
115
+ const record = await sdk.records.get({
116
+ baseId,
117
+ tableId,
118
+ recordId,
119
+ fields: transformedFields,
120
+ });
121
+ return transformRecordToSdkNames(record, fieldMappings);
122
+ }
123
+ const result = await sdk.records.findAll({
124
+ baseId,
125
+ tableId,
126
+ filters: filters
127
+ ? transformFiltersToFieldIds(filters, fieldMappings)
128
+ : undefined,
129
+ limit: 1,
130
+ fields: transformedFields,
131
+ });
132
+ if (result.records.length === 0)
133
+ return undefined;
134
+ return transformRecordToSdkNames(result.records[0], fieldMappings);
135
+ }
136
+ case 'findAll': {
137
+ const { filters, sort, limit, offset, fields } = params;
138
+ const result = await sdk.records.findAll({
139
+ baseId,
140
+ tableId,
141
+ filters: filters
142
+ ? transformFiltersToFieldIds(filters, fieldMappings)
143
+ : undefined,
144
+ sort: transformSortToFieldIds(sort, table, fieldMappings),
145
+ limit: limit || 500,
146
+ offset,
147
+ fields: transformFieldsToFieldIds(fields, table, fieldMappings),
148
+ });
149
+ return {
150
+ records: result.records
151
+ .map(r => transformRecordToSdkNames(r, fieldMappings))
152
+ .filter((r) => r !== undefined),
153
+ hasMore: result.hasMore,
154
+ };
155
+ }
156
+ case 'create': {
157
+ const { record: recordData } = params;
158
+ if (!recordData)
159
+ throw new Error('Create requires record data');
160
+ const record = await sdk.records.create({
161
+ baseId,
162
+ tableId,
163
+ record: transformLinkedRecordFields(transformFieldNamesToIds(recordData, table, fieldMappings), table),
164
+ });
165
+ const transformed = transformRecordToSdkNames(record, fieldMappings);
166
+ if (!transformed)
167
+ throw new Error('Failed to create record');
168
+ return transformed;
169
+ }
170
+ case 'update': {
171
+ const { id: recordId, record: recordData } = params;
172
+ if (!recordId || !recordData)
173
+ throw new Error('Update requires id and record data');
174
+ const record = await sdk.records.update({
175
+ baseId,
176
+ tableId,
177
+ recordId,
178
+ record: transformLinkedRecordFields(transformFieldNamesToIds(recordData, table, fieldMappings), table),
179
+ });
180
+ const transformed = transformRecordToSdkNames(record, fieldMappings);
181
+ if (!transformed)
182
+ throw new Error('Failed to update record');
183
+ // Both flat and `fields`, for compatibility.
184
+ return { ...transformed, fields: transformed };
185
+ }
186
+ case 'delete': {
187
+ const { id: recordId } = params;
188
+ if (!recordId)
189
+ throw new Error('Delete requires id parameter');
190
+ await sdk.records.delete({ baseId, tableId, recordId });
191
+ return { success: true, id: recordId };
192
+ }
193
+ case 'bulkCreate': {
194
+ const { records: recordsData, matchOn } = params;
195
+ if (!recordsData || recordsData.length === 0)
196
+ return { records: [] };
197
+ const result = await sdk.records.bulkCreate({
198
+ baseId,
199
+ tableId,
200
+ records: recordsData.map((r) => transformLinkedRecordFields(transformFieldNamesToIds(r, table, fieldMappings), table)),
201
+ matchOn: transformMatchOnFields(matchOn, fieldMappings),
202
+ });
203
+ const records = result.records
204
+ .map(r => transformRecordToSdkNames(r, fieldMappings))
205
+ .filter((r) => r !== undefined)
206
+ .map(record => {
207
+ // Both flat and nested fields, for backwards compatibility.
208
+ const { id, ...fields } = record;
209
+ return { id, ...fields, fields };
210
+ });
211
+ return { success: true, records };
212
+ }
213
+ default:
214
+ throw new Error(`Unknown databases method: ${methodName}`);
215
+ }
216
+ }
@@ -0,0 +1,7 @@
1
+ import type { HostRequestState } from '../../types.js';
2
+ /** The app's own data dispatch's requests, to base-runner on the token, which says the base, mode and user. */
3
+ export declare const dataFetch: (host: HostRequestState) => ({ method, path, body, }: {
4
+ method: string;
5
+ path: string;
6
+ body?: string;
7
+ }) => Promise<Response>;
@@ -0,0 +1,9 @@
1
+ import { requireAccess, sendOnToken } from '../transport.js';
2
+ /** The app's own data dispatch's requests, to base-runner on the token, which says the base, mode and user. */
3
+ export const dataFetch = (host) => async ({ method, path, body, }) => {
4
+ const access = await requireAccess(host);
5
+ return sendOnToken(access.token, `${access.urls.baseRunner}${path}`, {
6
+ method,
7
+ body,
8
+ });
9
+ };
@@ -0,0 +1,27 @@
1
+ import type { BaseTable, DataNameMappings } from './types.js';
2
+ import { type SchemaNames } from '../../../sync/sdkNames.js';
3
+ import type { HostMode } from '../../types.js';
4
+ /** What generated `zite.*` calls go out under. */
5
+ export declare const DATA_INTEGRATION_ID = "databases";
6
+ /** Sends one base-runner request on the app's token. */
7
+ export type DataTransport = {
8
+ dataFetch(request: {
9
+ method: string;
10
+ path: string;
11
+ body?: string;
12
+ }): Promise<Response>;
13
+ };
14
+ /** The build's base, and the SDK names it was built with. */
15
+ export type DataTarget = {
16
+ baseId: string | null;
17
+ names: SchemaNames | null;
18
+ };
19
+ /**
20
+ * The build's names for the base's tables as they are now: the ones it was built with, locked, and for anything added
21
+ * since, the name `zitejs generate` would give it. Worked out once per read of the tables.
22
+ */
23
+ export declare const nameMappingsFor: (live: readonly BaseTable[], names: SchemaNames | null) => DataNameMappings;
24
+ /** One `zite.*` call, translated here and sent to base-runner on the app token. */
25
+ export declare function runDataCall(session: DataTransport, target: DataTarget, mode: HostMode, methodName: string, sent: unknown): Promise<unknown>;
26
+ /** For tests: forget what this isolate learned. */
27
+ export declare const resetDataDispatch: () => void;
@@ -0,0 +1,75 @@
1
+ import { createBaseRunner } from './baseRunner.js';
2
+ import { asZiteClientError, executeDatabasesCall } from './dispatch.js';
3
+ import { nameMappingsOf } from './names.js';
4
+ import { allocateLiveNames } from '../../../sync/sdkNames.js';
5
+ /** What generated `zite.*` calls go out under. */
6
+ export const DATA_INTEGRATION_ID = 'databases';
7
+ // Schema changes aren't redeployed, so a new table or field reaches calls within this, as on the host.
8
+ const TABLES_REUSE_MS = 60_000;
9
+ // One build per script, so per isolate: its base's tables. Only answers are kept, never a pending call: one request's
10
+ // I/O mustn't hold up another's.
11
+ let tables;
12
+ const tablesOf = async (baseRunner, baseId) => {
13
+ if (tables?.baseId === baseId && Date.now() - tables.at < TABLES_REUSE_MS)
14
+ return tables.tables;
15
+ const base = await baseRunner.bases.get({ baseId });
16
+ tables = { baseId, tables: base.tables, at: Date.now() };
17
+ return base.tables;
18
+ };
19
+ const completed = new WeakMap();
20
+ /**
21
+ * The build's names for the base's tables as they are now: the ones it was built with, locked, and for anything added
22
+ * since, the name `zitejs generate` would give it. Worked out once per read of the tables.
23
+ */
24
+ export const nameMappingsFor = (live, names) => {
25
+ const held = completed.get(live);
26
+ if (held?.names === names)
27
+ return held.mappings;
28
+ const mappings = nameMappingsOf(allocateLiveNames(live, names ?? undefined).names);
29
+ completed.set(live, { names, mappings });
30
+ return mappings;
31
+ };
32
+ /**
33
+ * The table id classic's generated client sends: its SDK name mapped through the
34
+ * build's name mappings, which on classic the client does from the run's config.
35
+ */
36
+ const tableIdOf = (nameMappings, sent) => {
37
+ for (const [id, table] of Object.entries(nameMappings.tables)) {
38
+ if (table.mapping?.sdkName === sent)
39
+ return id;
40
+ }
41
+ return sent;
42
+ };
43
+ /** One `zite.*` call, translated here and sent to base-runner on the app token. */
44
+ export async function runDataCall(session, target, mode, methodName, sent) {
45
+ if (!target.baseId)
46
+ throw asZiteClientError(Object.assign(new Error('This app has no database'), { statusCode: 404 }));
47
+ const baseRunner = createBaseRunner(request => session.dataFetch(request));
48
+ let baseTables;
49
+ try {
50
+ baseTables = await tablesOf(baseRunner, target.baseId);
51
+ }
52
+ catch (error) {
53
+ throw asZiteClientError(error);
54
+ }
55
+ const nameMappings = nameMappingsFor(baseTables, target.names);
56
+ const params = sent &&
57
+ typeof sent === 'object' &&
58
+ typeof sent.tableId === 'string'
59
+ ? {
60
+ ...sent,
61
+ tableId: tableIdOf(nameMappings, sent.tableId),
62
+ }
63
+ : sent;
64
+ return executeDatabasesCall({
65
+ baseRunner,
66
+ baseId: target.baseId,
67
+ nameMappings,
68
+ tables: baseTables,
69
+ readOnly: mode === 'demo',
70
+ }, methodName, params);
71
+ }
72
+ /** For tests: forget what this isolate learned. */
73
+ export const resetDataDispatch = () => {
74
+ tables = undefined;
75
+ };
@@ -0,0 +1,7 @@
1
+ import { type SchemaNames } from '../../../sync/sdkNames.js';
2
+ import type { DataNameMappings } from './types.js';
3
+ /**
4
+ * Names as the platform's `nameMappings` keep them: each table under the class name its generated client sends
5
+ * (`createTableClient('Orders')`), each field under its own.
6
+ */
7
+ export declare const nameMappingsOf: (names: SchemaNames) => DataNameMappings;
@@ -0,0 +1,18 @@
1
+ import { toPascalCase } from '../../../sync/sdkNames.js';
2
+ /**
3
+ * Names as the platform's `nameMappings` keep them: each table under the class name its generated client sends
4
+ * (`createTableClient('Orders')`), each field under its own.
5
+ */
6
+ export const nameMappingsOf = (names) => ({
7
+ mapping: { sdkName: 'Database' },
8
+ tables: Object.fromEntries(names.tables.map(table => [
9
+ table.id,
10
+ {
11
+ mapping: { sdkName: toPascalCase(table.sdkName) },
12
+ fields: Object.fromEntries(table.fields.map(field => [
13
+ field.id,
14
+ { mapping: { sdkName: field.sdkName } },
15
+ ])),
16
+ },
17
+ ])),
18
+ });
@@ -0,0 +1,58 @@
1
+ import type { NameMappings } from './types.js';
2
+ /**
3
+ * Settings shape this helper reads — a subset of zite.lock's `nameMappings`
4
+ * carrying table and field SDK names keyed by tableId / fieldId.
5
+ */
6
+ export interface SdkNameMappingsSourceSettings {
7
+ tables: Record<string, {
8
+ mapping: {
9
+ sdkName: string;
10
+ };
11
+ fields: Record<string, {
12
+ mapping: {
13
+ sdkName: string;
14
+ };
15
+ }>;
16
+ }>;
17
+ }
18
+ /**
19
+ * Minimum metadata shape this helper reads — tables, fields, and the
20
+ * `linked_record` edges between them. `template` is optional + loose-typed to
21
+ * accept both BaseMetadata and the runtime's SimpleTableDefinition shape.
22
+ *
23
+ * `deletedAt` accepts `Date` as well as the wire's ISO string so backend
24
+ * callers (whose metadata types carry model-shaped dates) can pass their
25
+ * tables straight through — only its truthiness is read.
26
+ */
27
+ export interface SdkNameMappingsSourceMetadata {
28
+ tables: ReadonlyArray<{
29
+ id: string;
30
+ name: string;
31
+ deletedAt?: string | Date | null;
32
+ fields: ReadonlyArray<{
33
+ id: string;
34
+ name: string;
35
+ type: string;
36
+ deletedAt?: string | Date | null;
37
+ template?: {
38
+ tableId?: string;
39
+ isInverse?: boolean;
40
+ } & Record<string, unknown>;
41
+ }>;
42
+ }>;
43
+ }
44
+ /**
45
+ * Build the complete `NameMappings` wire payload for a base in SDK namespace.
46
+ * Applies the link-table conventions (alphabetical PascalCase concat for the
47
+ * name; `<tableCamel>Id` for column aliases) so base-runner does no
48
+ * derivations of its own.
49
+ *
50
+ * Dedupe rules mirror base-runner's `linkTablesByHumanName` keys:
51
+ * - one entry per ordered pair of tables (forward + inverse collapse to one)
52
+ * - forward direction wins for source/target orientation when both observed
53
+ * - multiple `linked_record` fields between the same pair share one entry
54
+ */
55
+ export declare const buildSdkNameMappingsForBase: ({ metadata, settingsNameMappings, }: {
56
+ metadata: SdkNameMappingsSourceMetadata;
57
+ settingsNameMappings: SdkNameMappingsSourceSettings;
58
+ }) => NameMappings;
@@ -0,0 +1,92 @@
1
+ // SDK-name `NameMappings` builder for the SQL endpoint. Lives next to the
2
+ // other SDK-name-aware transformations in this package (e.g.
3
+ // `transformRecordToSdkNames`) so cloudflare-lambda can import it without
4
+ // taking a runtime dep on `@fillout/zite`. Pure data transformation — walks
5
+ // BaseMetadata + the zite.lock-style nameMappings and applies the link-table
6
+ // conventions to produce a complete wire payload.
7
+ const getLinkTableSdkName = (a, b) => {
8
+ const [first, second] = [a, b].sort();
9
+ return `${first}${second}`;
10
+ };
11
+ const getLinkColumnSdkAlias = (sdkTableName, side, isSelfReference) => {
12
+ const camel = sdkTableName.charAt(0).toLowerCase() + sdkTableName.slice(1);
13
+ if (isSelfReference) {
14
+ return `${side}${camel.charAt(0).toUpperCase()}${camel.slice(1)}Id`;
15
+ }
16
+ return `${camel}Id`;
17
+ };
18
+ /**
19
+ * Build the complete `NameMappings` wire payload for a base in SDK namespace.
20
+ * Applies the link-table conventions (alphabetical PascalCase concat for the
21
+ * name; `<tableCamel>Id` for column aliases) so base-runner does no
22
+ * derivations of its own.
23
+ *
24
+ * Dedupe rules mirror base-runner's `linkTablesByHumanName` keys:
25
+ * - one entry per ordered pair of tables (forward + inverse collapse to one)
26
+ * - forward direction wins for source/target orientation when both observed
27
+ * - multiple `linked_record` fields between the same pair share one entry
28
+ */
29
+ export const buildSdkNameMappingsForBase = ({ metadata, settingsNameMappings, }) => {
30
+ const tablesById = new Map();
31
+ for (const t of metadata.tables) {
32
+ if (!t.deletedAt)
33
+ tablesById.set(t.id, t);
34
+ }
35
+ const tables = {};
36
+ for (const table of metadata.tables) {
37
+ if (table.deletedAt)
38
+ continue;
39
+ const tableMapping = settingsNameMappings.tables[table.id];
40
+ if (!tableMapping)
41
+ continue;
42
+ const fields = {};
43
+ for (const field of table.fields) {
44
+ if (field.deletedAt)
45
+ continue;
46
+ const sdkName = tableMapping.fields[field.id]?.mapping.sdkName;
47
+ if (sdkName)
48
+ fields[field.name] = sdkName;
49
+ }
50
+ tables[table.name] = {
51
+ displayName: tableMapping.mapping.sdkName,
52
+ fields,
53
+ };
54
+ }
55
+ const linkTables = {};
56
+ for (const source of metadata.tables) {
57
+ if (source.deletedAt)
58
+ continue;
59
+ for (const field of source.fields) {
60
+ if (field.deletedAt)
61
+ continue;
62
+ if (field.type !== 'linked_record')
63
+ continue;
64
+ // Only forward fields drive the entry. Inverse fields are auto-generated
65
+ // mirrors of a forward field on the other side — using them would flip
66
+ // the source/target orientation. Multiple forward fields between the
67
+ // same pair (e.g. Orders.customer + Orders.shippingAddress → Customers)
68
+ // produce identical entries, so the repeated write is idempotent.
69
+ if (field.template?.isInverse === true)
70
+ continue;
71
+ const targetTableId = field.template?.tableId;
72
+ if (!targetTableId)
73
+ continue;
74
+ const target = tablesById.get(targetTableId);
75
+ if (!target)
76
+ continue;
77
+ const sourceSdkName = settingsNameMappings.tables[source.id]?.mapping.sdkName;
78
+ const targetSdkName = settingsNameMappings.tables[target.id]?.mapping.sdkName;
79
+ if (!sourceSdkName || !targetSdkName)
80
+ continue;
81
+ const [humanFirst, humanSecond] = [source.name, target.name].sort();
82
+ const humanLinkName = `${humanFirst}__${humanSecond}`;
83
+ const isSelfReference = source.id === target.id;
84
+ linkTables[humanLinkName] = {
85
+ displayName: getLinkTableSdkName(sourceSdkName, targetSdkName),
86
+ sourceIdColumnAlias: getLinkColumnSdkAlias(sourceSdkName, 'source', isSelfReference),
87
+ targetIdColumnAlias: getLinkColumnSdkAlias(targetSdkName, 'target', isSelfReference),
88
+ };
89
+ }
90
+ }
91
+ return { tables, linkTables };
92
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Database Record Transformation Utilities
3
+ *
4
+ * Shared transformation functions for converting between:
5
+ * - SDK field names ↔ database field IDs
6
+ * - LLM-friendly formats ↔ database formats
7
+ *
8
+ * Used by both workflow-runner and cloudflare-lambda.
9
+ */
10
+ import type { SimpleTableDefinition, FieldMappings, DatabaseRecord } from './types.js';
11
+ /**
12
+ * Build reverse lookup map: sdkName → fieldId
13
+ */
14
+ export declare function buildSdkNameToFieldIdMap(fieldMappings: FieldMappings | undefined): Record<string, string>;
15
+ /**
16
+ * Transform SDK field names to database field IDs in filters
17
+ */
18
+ export declare function transformFiltersToFieldIds(filters: Record<string, unknown>, fieldMappings: FieldMappings | undefined): Record<string, unknown>;
19
+ /**
20
+ * Transform record data to use field IDs instead of field names.
21
+ *
22
+ * LLMs often use human-readable field names, but the database expects field IDs.
23
+ * Uses a three-step fallback:
24
+ * 1. Check if key is already a valid field ID
25
+ * 2. Match by field name (case-insensitive)
26
+ * 3. Match by SDK name from field mappings
27
+ *
28
+ * @param recordData - The record data with potentially mixed keys
29
+ * @param table - Table definition for field name lookups (optional)
30
+ * @param fieldMappings - SDK name mappings (optional)
31
+ */
32
+ export declare function transformFieldNamesToIds(recordData: Record<string, unknown>, table: SimpleTableDefinition | undefined, fieldMappings: FieldMappings | undefined): Record<string, unknown>;
33
+ /**
34
+ * Simple transformation using only field mappings (no table definition).
35
+ * Used when table metadata is not available.
36
+ */
37
+ export declare function transformRecordToFieldIds(recordData: Record<string, unknown>, fieldMappings: FieldMappings | undefined): Record<string, unknown>;
38
+ /**
39
+ * Transform linked record fields to ensure they are arrays.
40
+ *
41
+ * Handles common LLM mistakes:
42
+ * - Passing a string instead of an array of record IDs
43
+ * - Passing null/undefined instead of an empty array
44
+ * - Passing literal strings like "null" or "undefined"
45
+ *
46
+ * @param recordData - Record data (should already have field IDs as keys)
47
+ * @param table - Table definition for field type lookups
48
+ */
49
+ export declare function transformLinkedRecordFields(recordData: Record<string, unknown>, table: SimpleTableDefinition | undefined): Record<string, unknown>;
50
+ /**
51
+ * Transform database record to use SDK field names
52
+ *
53
+ * @param record - Raw database record with field IDs
54
+ * @param fieldMappings - SDK name mappings
55
+ */
56
+ export declare function transformRecordToSdkNames(record: {
57
+ id: string;
58
+ data: Record<string, unknown>;
59
+ } | undefined, fieldMappings: FieldMappings | undefined): DatabaseRecord | undefined;
60
+ /**
61
+ * Transform an array of SDK field names to field IDs.
62
+ *
63
+ * Used for the `fields` parameter in findOne/findAll to select which fields to return.
64
+ * Uses the same three-step fallback as transformFieldNamesToIds:
65
+ * 1. Check if name is already a valid field ID
66
+ * 2. Match by field name (case-insensitive)
67
+ * 3. Match by SDK name from field mappings
68
+ *
69
+ * @param fields - Array of SDK field names (e.g. ['customerName', 'email'])
70
+ * @param table - Table definition for field name lookups (optional)
71
+ * @param fieldMappings - SDK name mappings (optional)
72
+ * @returns Array of field IDs, or undefined if input is undefined
73
+ */
74
+ export declare function transformFieldsToFieldIds(fields: string[] | undefined, table: SimpleTableDefinition | undefined, fieldMappings: FieldMappings | undefined): string[] | undefined;
75
+ /**
76
+ * Resolve the field references in a sort spec to field IDs.
77
+ *
78
+ * Sort arrives from app code using SDK names (`closeDate`), but base-runner
79
+ * resolves sort fields by field ID or display name only, and silently skips one
80
+ * it cannot match. Running the references through the same resolution order as
81
+ * `fields` is what makes a sort on a multi-word field ("Close date" ->
82
+ * `closeDate`) actually apply instead of being dropped without an error.
83
+ *
84
+ * System sort fields (`id`, `createdAt`, `updatedAt`) have no mapping and fall
85
+ * through unchanged, which is what base-runner expects.
86
+ */
87
+ export declare function transformSortToFieldIds(sort: string | Array<{
88
+ field: string;
89
+ direction?: 'asc' | 'desc';
90
+ }> | undefined, table: SimpleTableDefinition | undefined, fieldMappings: FieldMappings | undefined): Array<{
91
+ field: string;
92
+ direction: 'asc' | 'desc';
93
+ }> | undefined;
94
+ /**
95
+ * Transform matchOn field names to field IDs
96
+ */
97
+ export declare function transformMatchOnFields(matchOn: string[] | undefined, fieldMappings: FieldMappings | undefined): string[] | undefined;