@elementumai/edk 0.9.2 → 0.9.6

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 (296) hide show
  1. package/README.md +34 -26
  2. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
  3. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
  4. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
  5. package/dist-sdk/pull/util.d.ts +1 -1
  6. package/dist-sdk/pull/util.js +3 -3
  7. package/dist-sdk/src/catalog/factories.d.ts +49 -10
  8. package/dist-sdk/src/catalog/factories.js +94 -13
  9. package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
  10. package/dist-sdk/src/catalog/from-authoring.js +7 -7
  11. package/dist-sdk/src/catalog/index.d.ts +2 -2
  12. package/dist-sdk/src/catalog/index.js +1 -1
  13. package/dist-sdk/src/catalog/org.js +62 -4
  14. package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
  15. package/dist-sdk/src/catalog/render-helpers.js +1 -1
  16. package/dist-sdk/src/catalog/render.d.ts +1 -0
  17. package/dist-sdk/src/catalog/render.js +2 -2
  18. package/dist-sdk/src/catalog/token.js +11 -4
  19. package/dist-sdk/src/catalog/types.d.ts +33 -4
  20. package/dist-sdk/src/catalog/types.js +5 -0
  21. package/dist-sdk/src/core/index.d.ts +10 -10
  22. package/dist-sdk/src/core/index.js +9 -9
  23. package/dist-sdk/src/core/render-tree.d.ts +1 -1
  24. package/dist-sdk/src/core/render-tree.js +1 -2
  25. package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
  26. package/dist-sdk/src/core/types/ai-provider.js +1 -1
  27. package/dist-sdk/src/core/types/app.d.ts +66 -30
  28. package/dist-sdk/src/core/types/app.js +2 -2
  29. package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
  30. package/dist-sdk/src/core/types/aspect-category.js +4 -4
  31. package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
  32. package/dist-sdk/src/core/types/cloud-link.js +3 -3
  33. package/dist-sdk/src/core/types/display-block.d.ts +2 -2
  34. package/dist-sdk/src/core/types/display-block.js +2 -2
  35. package/dist-sdk/src/core/types/group.d.ts +1 -1
  36. package/dist-sdk/src/core/types/group.js +1 -1
  37. package/dist-sdk/src/core/types/user.d.ts +1 -1
  38. package/dist-sdk/src/core/types/user.js +1 -1
  39. package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
  40. package/dist-sdk/src/engine/build/context.d.ts +20 -13
  41. package/dist-sdk/src/engine/entity.d.ts +1 -1
  42. package/dist-sdk/src/engine/pull/context.d.ts +34 -0
  43. package/dist-sdk/src/engine/pull/context.js +14 -0
  44. package/dist-sdk/src/engine/pull/org.d.ts +9 -0
  45. package/dist-sdk/src/engine/pull/org.js +33 -0
  46. package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
  47. package/dist-sdk/src/engine/pull/ref-only.js +204 -0
  48. package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
  49. package/dist-sdk/src/engine/tf/expr.js +18 -13
  50. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  51. package/dist-sdk/src/engine/tf/index.js +1 -1
  52. package/dist-sdk/src/engine/tf/model.d.ts +8 -1
  53. package/dist-sdk/src/engine/tf/model.js +4 -0
  54. package/dist-sdk/src/engine/tf/parse.js +13 -2
  55. package/dist-sdk/src/engine/tf/render.js +4 -0
  56. package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
  57. package/dist-sdk/src/entities/access-policy/build.js +1 -1
  58. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
  59. package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
  60. package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
  61. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
  62. package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
  63. package/dist-sdk/src/entities/agent/build.d.ts +3 -3
  64. package/dist-sdk/src/entities/agent/build.js +5 -5
  65. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
  66. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
  67. package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
  68. package/dist-sdk/src/entities/agent/from-tf.js +12 -4
  69. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  70. package/dist-sdk/src/entities/agent/index.js +1 -1
  71. package/dist-sdk/src/entities/agent/module.js +2 -0
  72. package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
  73. package/dist-sdk/src/entities/agent/to-tf.js +56 -8
  74. package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
  75. package/dist-sdk/src/entities/agent/tools.js +21 -7
  76. package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
  77. package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
  78. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
  79. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
  80. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
  81. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
  82. package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
  83. package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
  84. package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
  85. package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
  86. package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
  87. package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
  88. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
  89. package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
  90. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
  91. package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
  92. package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
  93. package/dist-sdk/src/entities/agent-tool/types.js +10 -37
  94. package/dist-sdk/src/entities/app/build.d.ts +97 -42
  95. package/dist-sdk/src/entities/app/build.js +25 -14
  96. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
  97. package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
  98. package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
  99. package/dist-sdk/src/entities/app/index.d.ts +11 -8
  100. package/dist-sdk/src/entities/app/index.js +10 -7
  101. package/dist-sdk/src/entities/app/module.js +2 -2
  102. package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
  103. package/dist-sdk/src/entities/app/to-tf.js +22 -6
  104. package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
  105. package/dist-sdk/src/entities/approval-chain/build.js +5 -5
  106. package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
  107. package/dist-sdk/src/entities/approval-chain/index.js +1 -1
  108. package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
  109. package/dist-sdk/src/entities/automation/build.d.ts +172 -94
  110. package/dist-sdk/src/entities/automation/build.js +159 -68
  111. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
  112. package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
  113. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
  114. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
  115. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
  116. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
  117. package/dist-sdk/src/entities/automation/from-tf.js +510 -80
  118. package/dist-sdk/src/entities/automation/index.d.ts +9 -12
  119. package/dist-sdk/src/entities/automation/index.js +11 -13
  120. package/dist-sdk/src/entities/automation/module.js +74 -6
  121. package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
  122. package/dist-sdk/src/entities/automation/operators.js +10 -37
  123. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
  124. package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
  125. package/dist-sdk/src/entities/automation/script-code.js +13 -22
  126. package/dist-sdk/src/entities/automation/serialize.js +1 -1
  127. package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
  128. package/dist-sdk/src/entities/automation/tasks.js +64 -11
  129. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
  130. package/dist-sdk/src/entities/automation/to-tf.js +342 -71
  131. package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
  132. package/dist-sdk/src/entities/automation/triggers.js +7 -1
  133. package/dist-sdk/src/entities/automation/types.d.ts +3 -2
  134. package/dist-sdk/src/entities/automation/types.js +3 -2
  135. package/dist-sdk/src/entities/chart/build.d.ts +95 -0
  136. package/dist-sdk/src/entities/chart/build.js +42 -0
  137. package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
  138. package/dist-sdk/src/entities/chart/from-tf.js +269 -0
  139. package/dist-sdk/src/entities/chart/index.d.ts +4 -0
  140. package/dist-sdk/src/entities/chart/index.js +3 -0
  141. package/dist-sdk/src/entities/chart/module.d.ts +3 -0
  142. package/dist-sdk/src/entities/chart/module.js +61 -0
  143. package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
  144. package/dist-sdk/src/entities/chart/printer.js +104 -0
  145. package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
  146. package/dist-sdk/src/entities/chart/to-tf.js +150 -0
  147. package/dist-sdk/src/entities/chart/types.d.ts +53 -0
  148. package/dist-sdk/src/entities/chart/types.js +22 -0
  149. package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
  150. package/dist-sdk/src/entities/dashboard/build.js +16 -1
  151. package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
  152. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
  153. package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
  154. package/dist-sdk/src/entities/datamine/module.js +1 -1
  155. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
  156. package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
  157. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
  158. package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
  159. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
  160. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
  161. package/dist-sdk/src/entities/element/build.d.ts +25 -32
  162. package/dist-sdk/src/entities/element/build.js +15 -32
  163. package/dist-sdk/src/entities/element/index.d.ts +7 -5
  164. package/dist-sdk/src/entities/element/index.js +7 -4
  165. package/dist-sdk/src/entities/element/module.js +7 -3
  166. package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
  167. package/dist-sdk/src/entities/element/to-tf.js +7 -3
  168. package/dist-sdk/src/entities/field/build.d.ts +51 -24
  169. package/dist-sdk/src/entities/field/build.js +31 -6
  170. package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
  171. package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
  172. package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
  173. package/dist-sdk/src/entities/field/calc/date.js +120 -29
  174. package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
  175. package/dist-sdk/src/entities/field/calc/index.js +82 -139
  176. package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
  177. package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
  178. package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
  179. package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
  180. package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
  181. package/dist-sdk/src/entities/field/calc/text.js +43 -31
  182. package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
  183. package/dist-sdk/src/entities/field/calc/types.js +1 -22
  184. package/dist-sdk/src/entities/field/calc.d.ts +71 -48
  185. package/dist-sdk/src/entities/field/calc.js +5 -15
  186. package/dist-sdk/src/entities/field/calculation-types.js +10 -3
  187. package/dist-sdk/src/entities/field/from-tf.js +156 -10
  188. package/dist-sdk/src/entities/field/locals.d.ts +11 -3
  189. package/dist-sdk/src/entities/field/locals.js +15 -2
  190. package/dist-sdk/src/entities/field/module.js +23 -6
  191. package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
  192. package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
  193. package/dist-sdk/src/entities/field/to-tf.js +293 -35
  194. package/dist-sdk/src/entities/field/types.d.ts +1 -1
  195. package/dist-sdk/src/entities/field/types.js +7 -1
  196. package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
  197. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
  198. package/dist-sdk/src/entities/org/cloud-link.js +4 -5
  199. package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
  200. package/dist-sdk/src/entities/org/email-alias.js +12 -0
  201. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  202. package/dist-sdk/src/entities/org/index.js +1 -0
  203. package/dist-sdk/src/entities/org/phone-provider.js +4 -7
  204. package/dist-sdk/src/entities/organization/build.d.ts +214 -2
  205. package/dist-sdk/src/entities/organization/build.js +145 -4
  206. package/dist-sdk/src/entities/organization/index.d.ts +1 -1
  207. package/dist-sdk/src/entities/organization/index.js +1 -1
  208. package/dist-sdk/src/entities/organization/module.js +4 -1
  209. package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
  210. package/dist-sdk/src/entities/organization/to-tf.js +118 -1
  211. package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
  212. package/dist-sdk/src/entities/phone-service/build.js +2 -2
  213. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
  214. package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
  215. package/dist-sdk/src/entities/phone-service/index.js +1 -1
  216. package/dist-sdk/src/entities/phone-service/types.js +1 -1
  217. package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
  218. package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
  219. package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
  220. package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
  221. package/dist-sdk/src/entities/search-table/build.js +13 -13
  222. package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
  223. package/dist-sdk/src/entities/search-table/index.js +2 -2
  224. package/dist-sdk/src/entities/search-table/printer.js +5 -5
  225. package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
  226. package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
  227. package/dist-sdk/src/entities/shared/context.d.ts +25 -24
  228. package/dist-sdk/src/entities/shared/context.js +36 -35
  229. package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
  230. package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
  231. package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
  232. package/dist-sdk/src/entities/shared/filters/index.js +11 -4
  233. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
  234. package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
  235. package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
  236. package/dist-sdk/src/entities/shared/ref.js +8 -3
  237. package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
  238. package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
  239. package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
  240. package/dist-sdk/src/entities/skill/build.d.ts +2 -2
  241. package/dist-sdk/src/entities/skill/build.js +3 -3
  242. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  243. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
  244. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  245. package/dist-sdk/src/entities/skill/index.js +1 -1
  246. package/dist-sdk/src/entities/skill/module.js +2 -2
  247. package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
  248. package/dist-sdk/src/entities/skill/to-tf.js +2 -2
  249. package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
  250. package/dist-sdk/src/entities/skill/tools.js +4 -3
  251. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
  252. package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
  253. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
  254. package/dist-sdk/src/entities/table/build.d.ts +1 -1
  255. package/dist-sdk/src/entities/table/build.js +9 -9
  256. package/dist-sdk/src/entities/table/catalog-render.js +9 -1
  257. package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
  258. package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
  259. package/dist-sdk/src/entities/table/fields/types.js +1 -1
  260. package/dist-sdk/src/entities/table/index.d.ts +2 -2
  261. package/dist-sdk/src/entities/table/index.js +3 -3
  262. package/dist-sdk/src/entities/table/module.js +1 -1
  263. package/dist-sdk/src/entities/table/to-tf.js +22 -30
  264. package/dist-sdk/src/entities/task/build.d.ts +1 -1
  265. package/dist-sdk/src/entities/task/build.js +5 -5
  266. package/dist-sdk/src/entities/task/index.d.ts +1 -1
  267. package/dist-sdk/src/entities/task/index.js +1 -1
  268. package/dist-sdk/src/entities/view/build.d.ts +46 -0
  269. package/dist-sdk/src/entities/view/build.js +19 -0
  270. package/dist-sdk/src/entities/view/from-tf.js +68 -18
  271. package/dist-sdk/src/entities/view/module.d.ts +6 -13
  272. package/dist-sdk/src/entities/view/module.js +7 -14
  273. package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
  274. package/dist-sdk/src/entities/view/sharing.js +6 -0
  275. package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
  276. package/dist-sdk/src/entities/view/to-tf.js +61 -26
  277. package/dist-sdk/src/entities/view/types.js +3 -0
  278. package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
  279. package/dist-sdk/src/entities/visual-flow/build.js +8 -8
  280. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  281. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  282. package/dist-sdk/src/entities/visual-flow/module.js +1 -1
  283. package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
  284. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
  285. package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
  286. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  287. package/dist-sdk/src/entities/widget/to-tf.js +9 -7
  288. package/dist-sdk/src/graph/index.d.ts +5 -1
  289. package/dist-sdk/src/graph/index.js +4 -1
  290. package/dist-sdk/src/graph/modules.js +6 -1
  291. package/dist-sdk/src/graph/types.d.ts +52 -1
  292. package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
  293. package/dist-sdk/src/internal/safe-identifier.js +13 -0
  294. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  295. package/dist-sdk/src/internal/sdk-package.js +1 -0
  296. package/package.json +12 -3
@@ -1,23 +1,2 @@
1
- /**
2
- * Type system for the calculated-field DSL.
3
- *
4
- * Every node the `calc.*` builder produces is an `Expr<T>` — a
5
- * `CalculationExpression` (the brand `CalculatedAppField.expression`
6
- * accepts) augmented with a phantom `__exprType` literal carrying the
7
- * type the expression evaluates to. The phantom drives compile-time
8
- * argument checking for operators, comparisons, sub-selects, and
9
- * `if`/`coalesce` shape rules — bad types fail `tsc --noEmit` before
10
- * the agent ever calls `.deploy()`.
11
- *
12
- * `ExprLike<T>` is the argument-position union: every builder accepts
13
- * either an `Expr<T>`, a typed `AppField` whose type maps to `T`, or
14
- * (for the primitive types) a raw TS literal. Coercion happens inside
15
- * the builder via `coerce()` in `runtime.ts`.
16
- *
17
- * The 12 `ExprType` brands track the GraphQL `AspectFieldType` enum
18
- * plus `decimal` (split from `number`) and `uuid` (the `UUID()`
19
- * built-in's return type — used in tier 2). `text` collapses
20
- * HTML/RICH_TEXT/HANDLE since they're indistinguishable inside an
21
- * expression.
22
- */
1
+ /** Static type system for Elementum calculated expressions. */
23
2
  export {};
@@ -1,16 +1,17 @@
1
- import type { Expr, ExprType } from "./calc/types.js";
1
+ import type { Expr, ExprType, FieldRefExprType } from "./calc/types.js";
2
2
  import type { FieldRef } from "../../catalog/index.js";
3
3
  /**
4
4
  * Reference an app field inside a calc expression (e.g. `calc.gt(calc.field(
5
5
  * app.fields.quantity), calc.num(0))`). Emits the field name — the platform
6
6
  * resolves calc field refs by name on compose.
7
7
  *
8
- * The expr type defaults to the one implied by the field's `fieldType`, but is
9
- * generic so it composes with strictly-typed operators when annotated
10
- * (`calc.field<"number">(ref)`) — TS can't infer the literal type from the
11
- * runtime `fieldType`.
8
+ * The expr type is inferred from the catalog ref's literal `fieldType`.
9
+ * An explicit generic remains available for loose, string-typed refs.
10
+ * @deprecated Pass catalog field refs directly to calc builders. Retain this
11
+ * helper only for explicit disambiguation or compatibility.
12
12
  */
13
- export declare function field<T extends ExprType = ExprType>(ref: FieldRef): Expr<T>;
13
+ export declare function field<const F extends FieldRef>(ref: F): Expr<FieldRefExprType<F>, "single", "record">;
14
+ export declare function field<T extends ExprType>(ref: FieldRef): Expr<T, "single", "record">;
14
15
  /** v2 calc namespace — v1's grammar plus `field()` for v2 field references. */
15
16
  export declare const calc: {
16
17
  field: typeof field;
@@ -18,45 +19,63 @@ export declare const calc: {
18
19
  dec: (value: number) => Expr<"decimal">;
19
20
  text: (value: string) => Expr<"text">;
20
21
  bool: (value: boolean) => Expr<"bool">;
21
- blank: <T extends ExprType>() => Expr<T>;
22
- plus: {
23
- (a: import("./calc/types.js").NumericLike, b: import("./calc/types.js").NumericLike): import("./calc/types.js").NumericExpr;
24
- (a: import("./calc/types.js").ExprLike<"date">, b: import("./calc/types.js").NumericLike): Expr<"date">;
25
- (a: import("./calc/types.js").ExprLike<"datetime">, b: import("./calc/types.js").NumericLike): Expr<"datetime">;
22
+ blank: {
23
+ <T extends ExprType>(type: T): Expr<T>;
24
+ <T extends ExprType>(): Expr<T>;
26
25
  };
27
- minus: {
28
- (a: import("./calc/types.js").NumericLike, b: import("./calc/types.js").NumericLike): import("./calc/types.js").NumericExpr;
29
- (a: import("./calc/types.js").ExprLike<"date">, b: import("./calc/types.js").NumericLike): Expr<"date">;
30
- (a: import("./calc/types.js").ExprLike<"datetime">, b: import("./calc/types.js").NumericLike): Expr<"datetime">;
26
+ raw: <T extends ExprType>(formula: string, resultType: T) => Expr<T>;
27
+ call: <const Parameters extends readonly import("../../catalog/types.js").StoredFunctionScalarType[], const Result extends import("../../catalog/types.js").StoredFunctionScalarType>(udf: import("../../catalog/types.js").StoredFunctionRef<Parameters, Result>, ...args: { readonly [Index in keyof Parameters]: Parameters[Index] extends ExprType ? import("./calc/types.js").ExprLike<Parameters[Index]> : never; }) => Expr<Result, "single", "record">;
28
+ plus: <const A extends import("./calc/types.js").NumericLike | import("./calc/types.js").ExprLike<"date"> | import("./calc/types.js").ExprLike<"datetime">, const B extends import("./calc/types.js").NumericLike>(a: A, b: B) => import("./calc/types.js").ComposedExpr<import("./calc/types.js").DateMathPromotion<A, B>, [A, B]>;
29
+ minus: <const A extends import("./calc/types.js").NumericLike | import("./calc/types.js").ExprLike<"date"> | import("./calc/types.js").ExprLike<"datetime">, const B extends import("./calc/types.js").NumericLike>(a: A, b: B) => import("./calc/types.js").ComposedExpr<import("./calc/types.js").DateMathPromotion<A, B>, [A, B]>;
30
+ times: <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B) => import("./calc/types.js").ComposedExpr<import("./calc/types.js").NumericPromotion<A, B>, [A, B]>;
31
+ dividedBy: <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B) => import("./calc/types.js").ComposedExpr<"decimal", [A, B]>;
32
+ gt: {
33
+ <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
34
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("./calc/types.js").ExprLike<T>, const B extends import("./calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
31
35
  };
32
- times: (a: import("./calc/types.js").NumericLike, b: import("./calc/types.js").NumericLike) => import("./calc/types.js").NumericExpr;
33
- dividedBy: (a: import("./calc/types.js").NumericLike, b: import("./calc/types.js").NumericLike) => import("./calc/types.js").NumericExpr;
34
- gt: <T extends import("./calc/types.js").ComparableExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>) => Expr<"bool">;
35
- lt: <T extends import("./calc/types.js").ComparableExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>) => Expr<"bool">;
36
- gte: <T extends import("./calc/types.js").ComparableExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>) => Expr<"bool">;
37
- lte: <T extends import("./calc/types.js").ComparableExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>) => Expr<"bool">;
38
- eq: <T extends ExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>) => Expr<"bool">;
39
- ne: <T extends ExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>) => Expr<"bool">;
40
- and: (a: import("./calc/types.js").BoolLike, b: import("./calc/types.js").BoolLike, ...rest: import("./calc/types.js").BoolLike[]) => Expr<"bool">;
41
- or: (a: import("./calc/types.js").BoolLike, b: import("./calc/types.js").BoolLike, ...rest: import("./calc/types.js").BoolLike[]) => Expr<"bool">;
42
- not: (value: import("./calc/types.js").BoolLike) => Expr<"bool">;
43
- if: <T extends ExprType>(cond: import("./calc/types.js").BoolLike, thenArm: import("./calc/types.js").ExprLike<T>, elseArm: import("./calc/types.js").ExprLike<T>) => Expr<T>;
44
- ifs: <T extends ExprType>(args_0: import("./calc/types.js").BoolLike, args_1: import("./calc/types.js").ExprLike<T>, ...args: (import("./calc/types.js").BoolLike | import("./calc/types.js").ExprLike<T>)[]) => Expr<T>;
45
- coalesce: <T extends ExprType>(args_0: import("./calc/types.js").ExprLike<T>, args_1: import("./calc/types.js").ExprLike<T>, ...args: import("./calc/types.js").ExprLike<T>[]) => Expr<T>;
46
- nullIf: <T extends ExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>) => Expr<T>;
47
- isBlank: <T extends ExprType>(value: import("./calc/types.js").ExprLike<T>) => Expr<"bool">;
48
- sum: (value: import("./calc/types.js").NumericLike) => import("./calc/types.js").NumericExpr;
49
- count: <T extends ExprType>(value: import("./calc/types.js").ExprLike<T>) => Expr<"number">;
50
- countUnique: <T extends ExprType>(value: import("./calc/types.js").ExprLike<T>) => Expr<"number">;
51
- average: (value: import("./calc/types.js").NumericLike) => Expr<"decimal">;
52
- stdev: (value: import("./calc/types.js").NumericLike) => Expr<"decimal">;
36
+ lt: {
37
+ <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
38
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("./calc/types.js").ExprLike<T>, const B extends import("./calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
39
+ };
40
+ gte: {
41
+ <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
42
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("./calc/types.js").ExprLike<T>, const B extends import("./calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
43
+ };
44
+ lte: {
45
+ <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
46
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("./calc/types.js").ExprLike<T>, const B extends import("./calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
47
+ };
48
+ eq: {
49
+ <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
50
+ <T extends "group" | "bool" | "date" | "datetime" | "handle" | "json" | "text" | "user" | "html" | "attachment" | "picklist" | "multiPicklist" | "uuid", const A extends import("./calc/types.js").ExprLike<T>, const B extends import("./calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
51
+ };
52
+ ne: {
53
+ <const A extends import("./calc/types.js").NumericLike, const B extends import("./calc/types.js").NumericLike>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
54
+ <T extends "group" | "bool" | "date" | "datetime" | "handle" | "json" | "text" | "user" | "html" | "attachment" | "picklist" | "multiPicklist" | "uuid", const A extends import("./calc/types.js").ExprLike<T>, const B extends import("./calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("./calc/types.js").ComposedExpr<"bool", [A, B]>;
55
+ };
56
+ and: <const A extends import("./calc/types.js").BoolLike, const B extends import("./calc/types.js").BoolLike, const Rest extends readonly import("./calc/types.js").BoolLike[]>(a: A, b: B, ...rest: Rest) => import("./calc/types.js").ComposedExpr<"bool", [A, B, ...Rest]>;
57
+ or: <const A extends import("./calc/types.js").BoolLike, const B extends import("./calc/types.js").BoolLike, const Rest extends readonly import("./calc/types.js").BoolLike[]>(a: A, b: B, ...rest: Rest) => import("./calc/types.js").ComposedExpr<"bool", [A, B, ...Rest]>;
58
+ if: {
59
+ <const Condition extends import("./calc/types.js").BoolLike, const Then extends import("./calc/types.js").NumericLike, const Else extends import("./calc/types.js").NumericLike>(cond: Condition, thenArm: Then, elseArm: Else): import("./calc/types.js").ComposedExpr<import("./calc/types.js").NumericPromotion<Then, Else>, [Condition, Then, Else]>;
60
+ <T extends "group" | "bool" | "date" | "datetime" | "handle" | "json" | "text" | "user" | "html" | "attachment" | "picklist" | "multiPicklist" | "uuid", const Condition extends import("./calc/types.js").BoolLike, const Then extends import("./calc/types.js").ExprLike<T>, const Else extends import("./calc/types.js").ExprLike<NoInfer<T>>>(cond: Condition, thenArm: Then, elseArm: Else): import("./calc/types.js").ComposedExpr<T, [Condition, Then, Else]>;
61
+ };
62
+ ifs: <T extends ExprType, const Rest extends readonly unknown[]>(condition: import("./calc/types.js").BoolLike, value: import("./calc/types.js").ExprLike<T>, ...rest: Rest & (Rest extends readonly [] ? readonly [] : Rest extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, ...Rest_1 extends readonly [] ? readonly [] : Rest_1 extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("./calc/types.js").BoolLike, Value & import("./calc/types.js").ExprLike<NoInfer<T>>, .../*elided*/ any] : never] : never] : never] : never] : never] : never] : never] : never] : never] : never] : never)) => import("./calc/types.js").ComposedExpr<T, [typeof condition, typeof value, ...Rest]>;
63
+ isBlank: <T extends ExprType, const Value extends import("./calc/types.js").ExprLike<T>>(value: Value) => import("./calc/types.js").ComposedExpr<"bool", [Value]>;
64
+ sum: {
65
+ <const Value extends import("./calc/types.js").ExprLike<"number">>(value: Value): import("./calc/types.js").ComposedExpr<"number", [Value]>;
66
+ <const Value extends import("./calc/types.js").ExprLike<"decimal">>(value: Value): import("./calc/types.js").ComposedExpr<"decimal", [Value]>;
67
+ };
68
+ count: <T extends ExprType, const Value extends import("./calc/types.js").ExprLike<T>>(value: Value) => import("./calc/types.js").ComposedExpr<"number", [Value]>;
69
+ countUnique: <T extends ExprType, const Value extends import("./calc/types.js").ExprLike<T>>(value: Value) => import("./calc/types.js").ComposedExpr<"number", [Value]>;
70
+ average: <const Value extends import("./calc/types.js").NumericLike>(value: Value) => import("./calc/types.js").ComposedExpr<"decimal", [Value]>;
71
+ stdev: <const Value extends import("./calc/types.js").NumericLike>(value: Value) => import("./calc/types.js").ComposedExpr<"decimal", [Value]>;
53
72
  min: {
54
- <T extends import("./calc/types.js").ComparableExprType>(value: import("./calc/types.js").ExprLike<T>): Expr<T>;
55
- <T extends import("./calc/types.js").ComparableExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>, ...rest: import("./calc/types.js").ExprLike<T>[]): Expr<T>;
73
+ <const Value extends import("./calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">>(value: Value): import("./calc/types.js").ComposedExpr<Extract<import("./calc/types.js").ExprTypeOf<Value>, "number" | "decimal" | "date" | "datetime">, [Value]>;
74
+ <const A extends import("./calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">, const B extends import("./calc/types.js").ExprLike<Extract<import("./calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>, const Rest extends readonly import("./calc/types.js").ExprLike<Extract<import("./calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>[]>(a: A, b: B, ...rest: Rest): import("./calc/types.js").ComposedExpr<Extract<import("./calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">, [A, B, ...Rest]>;
56
75
  };
57
76
  max: {
58
- <T extends import("./calc/types.js").ComparableExprType>(value: import("./calc/types.js").ExprLike<T>): Expr<T>;
59
- <T extends import("./calc/types.js").ComparableExprType>(a: import("./calc/types.js").ExprLike<T>, b: import("./calc/types.js").ExprLike<T>, ...rest: import("./calc/types.js").ExprLike<T>[]): Expr<T>;
77
+ <const Value extends import("./calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">>(value: Value): import("./calc/types.js").ComposedExpr<Extract<import("./calc/types.js").ExprTypeOf<Value>, "number" | "decimal" | "date" | "datetime">, [Value]>;
78
+ <const A extends import("./calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">, const B extends import("./calc/types.js").ExprLike<Extract<import("./calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>, const Rest extends readonly import("./calc/types.js").ExprLike<Extract<import("./calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>[]>(a: A, b: B, ...rest: Rest): import("./calc/types.js").ComposedExpr<Extract<import("./calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">, [A, B, ...Rest]>;
60
79
  };
61
80
  concat: typeof import("./calc/text.js").concat;
62
81
  toText: typeof import("./calc/text.js").toText;
@@ -70,24 +89,26 @@ export declare const calc: {
70
89
  substitute: typeof import("./calc/text.js").substitute;
71
90
  find: typeof import("./calc/text.js").find;
72
91
  search: typeof import("./calc/text.js").search;
92
+ split: typeof import("./calc/text.js").splitText;
73
93
  splitText: typeof import("./calc/text.js").splitText;
74
94
  regexMatch: typeof import("./calc/text.js").regexMatch;
75
95
  regexReplace: typeof import("./calc/text.js").regexReplace;
76
96
  regexExtract: typeof import("./calc/text.js").regexExtract;
77
97
  jsonEscape: typeof import("./calc/text.js").jsonEscape;
78
98
  jsonUnescape: typeof import("./calc/text.js").jsonUnescape;
99
+ repeat: typeof import("./calc/text.js").repeat;
79
100
  round: typeof import("./calc/numeric.js").round;
80
101
  power: typeof import("./calc/numeric.js").power;
81
102
  sqrt: typeof import("./calc/numeric.js").sqrt;
82
- mod: typeof import("./calc/numeric.js").mod;
83
- abs: typeof import("./calc/numeric.js").abs;
84
103
  toNumber: typeof import("./calc/numeric.js").toNumber;
85
104
  uuid: typeof import("./calc/numeric.js").uuid;
86
105
  now: typeof import("./calc/date.js").now;
87
- today: typeof import("./calc/date.js").today;
88
106
  makeDate: typeof import("./calc/date.js").makeDate;
107
+ dateTime: typeof import("./calc/date.js").dateTime;
89
108
  dateValue: typeof import("./calc/date.js").dateValue;
109
+ dateDiff: typeof import("./calc/date.js").dateDiff;
90
110
  dateDif: typeof import("./calc/date.js").dateDif;
111
+ truncateDateTime: typeof import("./calc/date.js").truncateDateTime;
91
112
  dateTimeTrunc: typeof import("./calc/date.js").dateTimeTrunc;
92
113
  weekday: typeof import("./calc/date.js").weekday;
93
114
  year: typeof import("./calc/date.js").year;
@@ -100,9 +121,11 @@ export declare const calc: {
100
121
  sumIf: typeof import("./calc/aggregate.js").sumIf;
101
122
  stringAgg: typeof import("./calc/aggregate.js").stringAgg;
102
123
  stringAggUnique: typeof import("./calc/aggregate.js").stringAggUnique;
103
- label: (field: import("./calc/types.js").ExprLike<"picklist">) => Expr<"text">;
104
- id: <T extends "picklist" | "user" | "group" | "attachment">(field: import("./calc/types.js").ExprLike<T>) => Expr<T>;
105
- email: (field: import("./calc/types.js").ExprLike<"user">) => Expr<"text">;
106
- name: (field: import("./calc/types.js").ExprLike<"group">) => Expr<"text">;
124
+ label: <const Field extends import("./calc/types.js").ExprLike<"picklist">>(field: Field) => import("./calc/types.js").ComposedExpr<"text", [Field]>;
125
+ id: <T extends "picklist" | "user" | "group" | "attachment", const Field extends import("./calc/types.js").ExprLike<T>>(field: Field) => import("./calc/types.js").ComposedExpr<T, [Field]>;
126
+ email: <const Field extends import("./calc/types.js").ExprLike<"user">>(field: Field) => import("./calc/types.js").ComposedExpr<"text", [Field]>;
127
+ name: <const Field extends import("./calc/types.js").ExprLike<"group">>(field: Field) => import("./calc/types.js").ComposedExpr<"text", [Field]>;
107
128
  };
108
- export type { Expr, ExprType } from "./calc/types.js";
129
+ export type { CalculationInclude, Expr, ExprContext, ExprType, FieldRefExprType } from "./calc/types.js";
130
+ export { dateDiffUnit, dateDifUnit, dateTimeTruncPrecision, orderByDirection, predicateOp, weekdayMode, } from "./calc/index.js";
131
+ export type { ConcatExprType, DateDiffUnit, DateDifUnit, DateTimePrecision, DateTimeTruncPrecision, ErgonomicOrderByDirection, ErgonomicPredicate, OrderByDirection, Predicate, PredicateInput, PredicateOp, StringAggOptions, StringAggOrderBy, WeekdayConvention, WeekdayMode, } from "./calc/index.js";
@@ -11,7 +11,7 @@
11
11
  * can't reach) — no deploy-time rewrite needed.
12
12
  *
13
13
  * Lives under `entities/field/` because calculated is a field sub-type
14
- * (authored through `defineApp` fields, hence re-exported from the `/app`
14
+ * (authored through `app` fields, hence re-exported from the `/app`
15
15
  * subpath). The terraform path does not support calculated fields yet —
16
16
  * `fieldToTf` degrades them with a diagnostic.
17
17
  */
@@ -20,14 +20,13 @@ import { makeExpr } from "./calc/runtime.js";
20
20
  const FIELD_TYPE_TO_EXPR = {
21
21
  TEXT: "text",
22
22
  RICH_TEXT: "text",
23
- HTML: "text",
24
23
  NUMBER: "number",
25
24
  DECIMAL: "decimal",
26
25
  BOOLEAN: "bool",
27
26
  DATE: "date",
28
27
  DATETIME: "datetime",
29
28
  PICKLIST: "picklist",
30
- MULTI_PICKLIST: "picklist",
29
+ MULTI_PICKLIST: "multiPicklist",
31
30
  USER: "user",
32
31
  USER_ID: "user",
33
32
  GROUP: "group",
@@ -36,19 +35,10 @@ const FIELD_TYPE_TO_EXPR = {
36
35
  ATTACHMENT_ID: "attachment",
37
36
  JSON: "json",
38
37
  };
39
- /**
40
- * Reference an app field inside a calc expression (e.g. `calc.gt(calc.field(
41
- * app.fields.quantity), calc.num(0))`). Emits the field name — the platform
42
- * resolves calc field refs by name on compose.
43
- *
44
- * The expr type defaults to the one implied by the field's `fieldType`, but is
45
- * generic so it composes with strictly-typed operators when annotated
46
- * (`calc.field<"number">(ref)`) — TS can't infer the literal type from the
47
- * runtime `fieldType`.
48
- */
49
38
  export function field(ref) {
50
- const exprType = (FIELD_TYPE_TO_EXPR[ref.fieldType] ?? "text");
51
- return makeExpr(exprType, () => `"${ref.name.replace(/"/g, '""')}"`);
39
+ const exprType = FIELD_TYPE_TO_EXPR[ref.fieldType] ?? "text";
40
+ return makeExpr(exprType, () => `"${ref.name.replace(/"/g, '""')}"`, { context: "record" });
52
41
  }
53
42
  /** v2 calc namespace — v1's grammar plus `field()` for v2 field references. */
54
43
  export const calc = { ...baseCalc, field };
44
+ export { dateDiffUnit, dateDifUnit, dateTimeTruncPrecision, orderByDirection, predicateOp, weekdayMode, } from "./calc/index.js";
@@ -1,3 +1,8 @@
1
+ // These are the raw `elementum_calculated_field.calculation_type` WIRE
2
+ // values ei exports — not the authoring-vocabulary names. "HTML" stays here
3
+ // unchanged (the platform's wire type for a rich-text calculated field is
4
+ // still literally "HTML"); `calculationAuthoringType` is where it's
5
+ // translated to the authoring type "RICH_TEXT" for printed source.
1
6
  export const CALCULATION_RESULT_TYPES = [
2
7
  "ATTACHMENT_ID",
3
8
  "BOOLEAN",
@@ -23,6 +28,8 @@ export function calculationAuthoringType(type) {
23
28
  case "ATTACHMENT_ID": return "ATTACHMENT";
24
29
  case "GROUP_ID": return "GROUP";
25
30
  case "USER_ID": return "USER";
31
+ // Wire value is unchanged ("HTML"); the authoring vocabulary is "RICH_TEXT".
32
+ case "HTML": return "RICH_TEXT";
26
33
  default: return type;
27
34
  }
28
35
  }
@@ -31,10 +38,10 @@ export function calculationExprType(type) {
31
38
  case "ATTACHMENT_ID": return "attachment";
32
39
  case "BOOLEAN": return "bool";
33
40
  case "GROUP_ID": return "group";
34
- case "HANDLE":
35
- case "HTML":
41
+ case "HANDLE": return "handle";
42
+ case "HTML": return "html";
36
43
  case "TEXT": return "text";
37
- case "MULTI_PICKLIST":
44
+ case "MULTI_PICKLIST": return "multiPicklist";
38
45
  case "PICKLIST": return "picklist";
39
46
  case "USER_ID": return "user";
40
47
  default: return type.toLowerCase();
@@ -9,6 +9,7 @@ import { EntityTfError } from "../../engine/entity.js";
9
9
  import { SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
10
10
  import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pull/context.js";
11
11
  import { bareChildResourceLabel, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
12
+ import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
12
13
  import { __pulledExpression } from "../app/deserializer/pulled-expression.js";
13
14
  import { optionsFromTf } from "./options.js";
14
15
  import { isCalculationResultType } from "./calculation-types.js";
@@ -56,27 +57,126 @@ function resolveRelatedObject(v, ctx) {
56
57
  if (v === undefined || !isTfExpr(v) || v.$expr !== "data-attr")
57
58
  return undefined;
58
59
  if (v.type === "elementum_app") {
59
- const name = ctx.dataName("elementum_app", v.label);
60
+ const attrs = ctx.dataAttrs?.("elementum_app", v.label);
61
+ const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
62
+ const name = ctx.dataName("elementum_app", v.label) ?? (typeof attrs?.name === "string" ? attrs.name : undefined);
63
+ const refName = namespace !== undefined ? ctx.foreignAppRefNamespaces?.get(namespace) : name !== undefined ? ctx.foreignAppRefNames?.get(name) : undefined;
64
+ if (refName !== undefined)
65
+ return { __kind: "app", refName, name: name ?? refName, ...(namespace !== undefined ? { namespace } : {}) };
60
66
  if (name === undefined)
61
67
  return undefined;
62
- const refName = ctx.foreignAppRefNames?.get(name);
63
- if (refName !== undefined)
64
- return { __kind: "app", refName, name };
65
68
  ctx.unresolvedForeignRefs?.apps.add(name);
66
69
  return undefined;
67
70
  }
68
71
  if (v.type === "elementum_element") {
69
- const name = ctx.dataName("elementum_element", v.label);
72
+ const attrs = ctx.dataAttrs?.("elementum_element", v.label);
73
+ const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
74
+ const name = ctx.dataName("elementum_element", v.label) ?? (typeof attrs?.name === "string" ? attrs.name : undefined);
75
+ const refName = namespace !== undefined ? ctx.foreignElementRefNamespaces?.get(namespace) : name !== undefined ? ctx.foreignElementRefNames?.get(name) : undefined;
76
+ if (refName !== undefined)
77
+ return { __kind: "element", refName, name: name ?? refName, ...(namespace !== undefined ? { namespace } : {}) };
70
78
  if (name === undefined)
71
79
  return undefined;
72
- const refName = ctx.foreignElementRefNames?.get(name);
73
- if (refName !== undefined)
74
- return { __kind: "element", refName, name };
75
80
  ctx.unresolvedForeignRefs?.elements.add(name);
76
81
  return undefined;
77
82
  }
78
83
  return undefined;
79
84
  }
85
+ function resolveRelatedField(v, ctx) {
86
+ const raw = resolveRelatedId(v, ctx);
87
+ if (raw !== undefined)
88
+ return raw;
89
+ if (v === undefined || !isTfExpr(v) || v.$expr !== "data-attr" || v.path.join(".") !== "id")
90
+ return undefined;
91
+ return ctx.foreignFieldRefsByDataAddress?.get(`${v.type}.${v.label}`);
92
+ }
93
+ /**
94
+ * A dynamic picklist filter's field reference → `RefExpr`. Every field a
95
+ * `dynamic_config.filter` names belongs to `relatedAspectId`'s target. A
96
+ * ref-only dependency data address resolves to its generated catalog member;
97
+ * a preserved raw id remains an explicit unresolved/unsafe fallback.
98
+ */
99
+ function dynamicPicklistFilterFieldRef(value, ctx) {
100
+ const resolved = resolveRelatedField(value, ctx);
101
+ if (typeof resolved === "string")
102
+ return { kind: "unresolved", uuid: resolved, hint: "field" };
103
+ if (resolved !== undefined) {
104
+ return { kind: "field", appHandle: resolved.ownerRefName, fieldKey: resolved.fieldKey };
105
+ }
106
+ throw new EntityTfError("dynamic picklist filter field reference cannot be reconstructed");
107
+ }
108
+ /**
109
+ * `dynamic_config` → `AppField.config` (picklist/multiPicklist only). Mirrors
110
+ * `related_object_id`/`related_label_field_id` resolution exactly (both are
111
+ * required by the wire schema, so either failing to resolve drops the whole
112
+ * config — same convention as RELATION's own required pair). `parent_field_id`
113
+ * is same-aspect (see `fieldKeyFromTfRef`'s use here vs. `resolveRelatedId`
114
+ * for the cross-aspect id's above); its own failure to resolve degrades that
115
+ * ONE optional attribute rather than the whole field.
116
+ */
117
+ function dynamicConfigFromTf(value, owner, ctx, where) {
118
+ if (value === undefined)
119
+ return undefined;
120
+ if (typeof value !== "object" || value === null || isTfExpr(value) || Array.isArray(value)) {
121
+ ctx.diagnostics.push(`${where}: dynamic_config has an unexpected shape; dropped`);
122
+ return undefined;
123
+ }
124
+ const attrs = value;
125
+ const relatedAspectId = resolveRelatedObject(attrs["related_aspect_id"], ctx);
126
+ const relatedLabelFieldId = resolveRelatedField(attrs["related_label_field_id"], ctx);
127
+ if (relatedAspectId === undefined || relatedLabelFieldId === undefined) {
128
+ const missing = [
129
+ relatedAspectId === undefined && "related_aspect_id",
130
+ relatedLabelFieldId === undefined && "related_label_field_id",
131
+ ].filter((v) => v !== false);
132
+ ctx.diagnostics.push(`${where}: dynamic_config.${missing.join(" and ")} does not resolve to a catalog reference or raw platform id; dropped`);
133
+ return undefined;
134
+ }
135
+ let parentFieldId;
136
+ if (attrs["parent_field_id"] !== undefined) {
137
+ parentFieldId = fieldKeyFromTfRef(attrs["parent_field_id"], owner.label, owner.scope ?? "app");
138
+ if (parentFieldId === undefined) {
139
+ ctx.diagnostics.push(`${where}: dynamic_config.parent_field_id could not be resolved to a same-aspect field; dropped`);
140
+ }
141
+ }
142
+ const autoRelate = typeof attrs["auto_relate"] === "boolean" ? attrs["auto_relate"] : undefined;
143
+ const valuesRenderType = typeof attrs["values_render_type"] === "string" ? attrs["values_render_type"] : undefined;
144
+ let filter;
145
+ if (attrs["filter"] !== undefined) {
146
+ try {
147
+ filter = deserializeFilterFromTf(attrs["filter"], {
148
+ field: (v) => dynamicPicklistFilterFieldRef(v, ctx),
149
+ reference: () => {
150
+ throw new EntityTfError("dynamic picklist filter does not support value references");
151
+ },
152
+ });
153
+ }
154
+ catch (e) {
155
+ ctx.diagnostics.push(`${where}: dynamic_config.filter ${e instanceof Error ? e.message : String(e)}; dropped`);
156
+ }
157
+ }
158
+ let sort;
159
+ if (attrs["sort"] !== undefined) {
160
+ const sortValue = attrs["sort"];
161
+ if (isTfExpr(sortValue) && sortValue.$expr === "jsonencode" && typeof sortValue.value === "object" && sortValue.value !== null && !Array.isArray(sortValue.value)) {
162
+ sort = sortValue.value;
163
+ }
164
+ else {
165
+ ctx.diagnostics.push(`${where}: dynamic_config.sort is not a jsonencode(...) object; dropped`);
166
+ }
167
+ }
168
+ return {
169
+ dynamic: {
170
+ relatedAspectId,
171
+ relatedLabelFieldId,
172
+ ...(parentFieldId !== undefined && { parentFieldId }),
173
+ ...(autoRelate !== undefined && { autoRelate }),
174
+ ...(valuesRenderType !== undefined && { valuesRenderType }),
175
+ ...(filter !== undefined && { filter }),
176
+ ...(sort !== undefined && { sort }),
177
+ },
178
+ };
179
+ }
80
180
  /**
81
181
  * One field block → its normalized entry; undefined = skipped with a
82
182
  * diagnostic (unknown resource type, or a field belonging to a different
@@ -117,7 +217,10 @@ export function fieldFromTf(block, owner, ctx) {
117
217
  ctx.diagnostics.push(`${where}: object_id does not reference ${owner.type}.${owner.label}; skipped`);
118
218
  return undefined;
119
219
  }
120
- const options = subType.hasOptions === true ? optionsFromTf(attrs["options"], `${where} options`, ctx) : undefined;
220
+ const options = subType.hasOptions === true && attrs["dynamic_config"] === undefined
221
+ ? optionsFromTf(attrs["options"], `${where} options`, ctx)
222
+ : undefined;
223
+ const config = subType.hasOptions === true ? dynamicConfigFromTf(attrs["dynamic_config"], owner, ctx, where) : undefined;
121
224
  let decimalPlaces;
122
225
  if (subType.typeKey === "decimal" && attrs["decimal_places"] !== undefined) {
123
226
  if (typeof attrs["decimal_places"] === "number")
@@ -125,6 +228,28 @@ export function fieldFromTf(block, owner, ctx) {
125
228
  else
126
229
  ctx.diagnostics.push(`${where}: decimal_places is not a number; dropped`);
127
230
  }
231
+ let numericFormat;
232
+ if (subType.typeKey === "number" || subType.typeKey === "decimal") {
233
+ const format = {};
234
+ const currency = attrs["currency"];
235
+ if (currency !== undefined) {
236
+ if (typeof currency === "string")
237
+ format["currency"] = currency;
238
+ else
239
+ ctx.diagnostics.push(`${where}: currency is not a string; dropped`);
240
+ }
241
+ for (const key of ["percentage", "delimiter"]) {
242
+ const value = attrs[key];
243
+ if (value === undefined)
244
+ continue;
245
+ if (typeof value === "boolean")
246
+ format[key] = value;
247
+ else
248
+ ctx.diagnostics.push(`${where}: ${key} is not a boolean; dropped`);
249
+ }
250
+ if (Object.keys(format).length > 0)
251
+ numericFormat = format;
252
+ }
128
253
  // related_object_id/related_label_field_id are raw platform ids on the
129
254
  // wire when ei's beautifier finds nothing to resolve them against - a
130
255
  // non-recursive export never discovers the related aspect's own identity,
@@ -156,7 +281,7 @@ export function fieldFromTf(block, owner, ctx) {
156
281
  let autoRelate;
157
282
  if (subType.hasRelation === true) {
158
283
  relatedObject = resolveRelatedObject(attrs["related_object_id"], ctx);
159
- relatedLabelField = resolveRelatedId(attrs["related_label_field_id"], ctx);
284
+ relatedLabelField = resolveRelatedField(attrs["related_label_field_id"], ctx);
160
285
  if (typeof attrs["auto_relate"] === "boolean")
161
286
  autoRelate = attrs["auto_relate"];
162
287
  if (relatedObject === undefined || relatedLabelField === undefined) {
@@ -207,9 +332,28 @@ export function fieldFromTf(block, owner, ctx) {
207
332
  ctx.diagnostics.push(`${where}: calculation_type is missing or unsupported; skipped rather than guessing the typed result`);
208
333
  return undefined;
209
334
  }
335
+ let calculationInclude;
336
+ if (subType.typeKey === "calculated") {
337
+ const includeType = optionalString(attrs, "include_type", where, ctx);
338
+ if (includeType === "MANUAL")
339
+ calculationInclude = "manual";
340
+ else if (includeType === "BOTH")
341
+ calculationInclude = "both";
342
+ else if (includeType === "PICKLIST") {
343
+ const picklistFieldId = resolveRelatedId(attrs["picklist_field_id"], ctx);
344
+ if (picklistFieldId !== undefined)
345
+ calculationInclude = { picklistFieldId };
346
+ else
347
+ ctx.diagnostics.push(`${where}: PICKLIST inclusion has an unresolvable picklist_field_id; defaulted to AUTO`);
348
+ }
349
+ else if (includeType !== undefined && includeType !== "AUTO") {
350
+ ctx.diagnostics.push(`${where}: unsupported include_type ${JSON.stringify(includeType)}; defaulted to AUTO`);
351
+ }
352
+ }
210
353
  return {
211
354
  key: scopedLabelToBagKey(owner.label, fieldLabel, scope),
212
355
  ...(isCalculationResultType(calculationType) && { calculationType }),
356
+ ...(calculationInclude !== undefined && { calculationInclude }),
213
357
  field: {
214
358
  id: ctx.importId(`${block.type}.${fieldLabel}`) ?? "",
215
359
  name: fieldName,
@@ -229,10 +373,12 @@ export function fieldFromTf(block, owner, ctx) {
229
373
  : attrs["default_value"] !== undefined &&
230
374
  !isTfExpr(attrs["default_value"]) && { defaultValue: attrs["default_value"] }),
231
375
  ...(options !== undefined && { options }),
376
+ ...(config !== undefined && { config }),
232
377
  ...(tags !== undefined && tags.length > 0 && { tags }),
233
378
  ...(relatedObject !== undefined && { relatedObject }),
234
379
  ...(relatedLabelField !== undefined && { relatedLabelField }),
235
380
  ...(autoRelate !== undefined && { autoRelate }),
381
+ ...(numericFormat !== undefined && { numericFormat }),
236
382
  ...(decimalPlaces !== undefined && { decimalPlaces }),
237
383
  },
238
384
  };
@@ -3,6 +3,14 @@
3
3
  * `<fieldLabel>_options_by_label` for-expression per option-carrying field
4
4
  * resource (bare field label — ei does not namespace-prefix these).
5
5
  */
6
- import { type TfValue } from "../../engine/tf/index.js";
7
- /** Append one app's field-level lookup locals, keyed by the emitted field addresses. */
8
- export declare function appendFieldLocals(attrs: Record<string, TfValue>, fieldAddresses: ReadonlyMap<string, string>): void;
6
+ import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
7
+ /**
8
+ * Append one app's field-level lookup locals, keyed by the emitted field
9
+ * addresses. Skips any dropdown field whose values come from `dynamic_config`
10
+ * (issue #406) instead of a static `options` list — that attribute is null
11
+ * in state for such a field, and a `for opt in ...options` local over a
12
+ * null value fails the plan outright. Read directly off `blocks`' own attrs
13
+ * rather than a separately-threaded address set, since the emitted field
14
+ * blocks (already produced by `toTf`) carry this directly.
15
+ */
16
+ export declare function appendFieldLocals(attrs: Record<string, TfValue>, fieldAddresses: ReadonlyMap<string, string>, blocks?: readonly TfBlock[]): void;
@@ -11,14 +11,27 @@ import { expr } from "../../engine/tf/index.js";
11
11
  // dialect is ei's actual output, not its intent (integration-harness build-vs-export
12
12
  // finding, 2026-07-23).
13
13
  const OPTION_LOOKUP_FIELD_RESOURCE_TYPES = new Set(["elementum_dropdown_field"]);
14
- /** Append one app's field-level lookup locals, keyed by the emitted field addresses. */
15
- export function appendFieldLocals(attrs, fieldAddresses) {
14
+ /**
15
+ * Append one app's field-level lookup locals, keyed by the emitted field
16
+ * addresses. Skips any dropdown field whose values come from `dynamic_config`
17
+ * (issue #406) instead of a static `options` list — that attribute is null
18
+ * in state for such a field, and a `for opt in ...options` local over a
19
+ * null value fails the plan outright. Read directly off `blocks`' own attrs
20
+ * rather than a separately-threaded address set, since the emitted field
21
+ * blocks (already produced by `toTf`) carry this directly.
22
+ */
23
+ export function appendFieldLocals(attrs, fieldAddresses, blocks) {
24
+ const dynamicAddresses = new Set((blocks ?? [])
25
+ .filter((block) => block.attrs["dynamic_config"] !== undefined)
26
+ .map((block) => `${block.type}.${block.label}`));
16
27
  for (const address of [...fieldAddresses.values()].sort()) {
17
28
  const dot = address.indexOf(".");
18
29
  const type = address.slice(0, dot);
19
30
  const label = address.slice(dot + 1);
20
31
  if (!OPTION_LOOKUP_FIELD_RESOURCE_TYPES.has(type))
21
32
  continue;
33
+ if (dynamicAddresses.has(address))
34
+ continue;
22
35
  attrs[`${label}_options_by_label`] = expr.forObject("opt", expr.resourceAttr(type, label, ["options"]), expr.scopedAttr("opt", ["label"]), expr.scopedAttr("opt", ["id"]));
23
36
  }
24
37
  }