@elementumai/edk 0.8.2-alpha.6 → 0.9.5

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 (481) hide show
  1. package/README.md +49 -37
  2. package/dist-sdk/elementum-entity-client/clients/agents/models/agent-tool.d.ts +3 -3
  3. package/dist-sdk/elementum-entity-client/clients/aspects/models/index.d.ts +1 -1
  4. package/dist-sdk/elementum-entity-client/clients/aspects/models/picklist-config.d.ts +3 -11
  5. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +3 -11
  6. package/dist-sdk/elementum-entity-client/clients/skills/models/skill-tool.d.ts +1 -1
  7. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
  8. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
  9. package/dist-sdk/fs/entity.d.ts +2 -2
  10. package/dist-sdk/fs/entity.js +1 -1
  11. package/dist-sdk/pull/missing-report.d.ts +81 -0
  12. package/dist-sdk/pull/missing-report.js +52 -0
  13. package/dist-sdk/pull/util.d.ts +1 -1
  14. package/dist-sdk/pull/util.js +3 -3
  15. package/dist-sdk/src/catalog/factories.d.ts +96 -23
  16. package/dist-sdk/src/catalog/factories.js +141 -21
  17. package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
  18. package/dist-sdk/src/catalog/from-authoring.js +20 -10
  19. package/dist-sdk/src/catalog/index.d.ts +2 -2
  20. package/dist-sdk/src/catalog/index.js +1 -1
  21. package/dist-sdk/src/catalog/org.js +63 -4
  22. package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
  23. package/dist-sdk/src/catalog/render-helpers.js +1 -1
  24. package/dist-sdk/src/catalog/render.d.ts +1 -0
  25. package/dist-sdk/src/catalog/render.js +8 -2
  26. package/dist-sdk/src/catalog/token.js +18 -4
  27. package/dist-sdk/src/catalog/types.d.ts +64 -24
  28. package/dist-sdk/src/catalog/types.js +12 -4
  29. package/dist-sdk/src/core/app-to-ui.d.ts +6 -6
  30. package/dist-sdk/src/core/app-to-ui.js +7 -9
  31. package/dist-sdk/src/core/index.d.ts +11 -10
  32. package/dist-sdk/src/core/index.js +10 -9
  33. package/dist-sdk/src/core/platform-id.d.ts +11 -0
  34. package/dist-sdk/src/core/platform-id.js +8 -0
  35. package/dist-sdk/src/{entities/flow/activities/render-catalog.d.ts → core/render-tree.d.ts} +3 -3
  36. package/dist-sdk/src/{entities/flow/activities/render-catalog.js → core/render-tree.js} +7 -10
  37. package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
  38. package/dist-sdk/src/core/types/ai-provider.js +1 -1
  39. package/dist-sdk/src/core/types/app.d.ts +78 -52
  40. package/dist-sdk/src/core/types/app.js +2 -3
  41. package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
  42. package/dist-sdk/src/core/types/aspect-category.js +4 -4
  43. package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
  44. package/dist-sdk/src/core/types/cloud-link.js +3 -3
  45. package/dist-sdk/src/core/types/display-block.d.ts +2 -2
  46. package/dist-sdk/src/core/types/display-block.js +2 -2
  47. package/dist-sdk/src/core/types/group.d.ts +1 -1
  48. package/dist-sdk/src/core/types/group.js +1 -1
  49. package/dist-sdk/src/core/types/user.d.ts +1 -1
  50. package/dist-sdk/src/core/types/user.js +1 -1
  51. package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
  52. package/dist-sdk/src/engine/build/context.d.ts +23 -16
  53. package/dist-sdk/src/engine/entity.d.ts +1 -1
  54. package/dist-sdk/src/engine/pull/attrs.d.ts +4 -0
  55. package/dist-sdk/src/engine/pull/attrs.js +17 -0
  56. package/dist-sdk/src/engine/pull/context.d.ts +73 -0
  57. package/dist-sdk/src/engine/pull/context.js +14 -0
  58. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  59. package/dist-sdk/src/engine/pull/org.js +35 -0
  60. package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
  61. package/dist-sdk/src/engine/pull/ref-only.js +204 -0
  62. package/dist-sdk/src/engine/tf/expr.d.ts +7 -3
  63. package/dist-sdk/src/engine/tf/expr.js +27 -15
  64. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  65. package/dist-sdk/src/engine/tf/index.js +1 -1
  66. package/dist-sdk/src/engine/tf/model.d.ts +8 -1
  67. package/dist-sdk/src/engine/tf/model.js +4 -0
  68. package/dist-sdk/src/engine/tf/parse.js +13 -2
  69. package/dist-sdk/src/engine/tf/render.js +4 -0
  70. package/dist-sdk/src/engine/workspace/authoring-layout.js +4 -2
  71. package/dist-sdk/src/entities/access-policy/build.d.ts +6 -16
  72. package/dist-sdk/src/entities/access-policy/build.js +2 -2
  73. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +14 -40
  74. package/dist-sdk/src/entities/access-policy/from-tf.js +26 -85
  75. package/dist-sdk/src/entities/access-policy/principal.d.ts +39 -0
  76. package/dist-sdk/src/entities/access-policy/principal.js +13 -0
  77. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +33 -6
  78. package/dist-sdk/src/entities/access-policy/to-tf.js +62 -60
  79. package/dist-sdk/src/entities/agent/build.d.ts +42 -11
  80. package/dist-sdk/src/entities/agent/build.js +40 -19
  81. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +11 -1
  82. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +180 -45
  83. package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
  84. package/dist-sdk/src/entities/agent/from-tf.js +17 -12
  85. package/dist-sdk/src/entities/agent/index.d.ts +5 -2
  86. package/dist-sdk/src/entities/agent/index.js +4 -2
  87. package/dist-sdk/src/entities/agent/module.js +7 -2
  88. package/dist-sdk/src/entities/agent/run-as.d.ts +16 -0
  89. package/dist-sdk/src/entities/agent/run-as.js +1 -0
  90. package/dist-sdk/src/entities/agent/to-tf.d.ts +6 -2
  91. package/dist-sdk/src/entities/agent/to-tf.js +58 -9
  92. package/dist-sdk/src/entities/agent/tools.d.ts +97 -70
  93. package/dist-sdk/src/entities/agent/tools.js +63 -43
  94. package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +1 -1
  95. package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +4 -4
  96. package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
  97. package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
  98. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
  99. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
  100. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
  101. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
  102. package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
  103. package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
  104. package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
  105. package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
  106. package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
  107. package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
  108. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +25 -15
  109. package/dist-sdk/src/entities/agent-tool/from-tf.js +175 -43
  110. package/dist-sdk/src/entities/agent-tool/module.js +6 -0
  111. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +15 -7
  112. package/dist-sdk/src/entities/agent-tool/to-tf.js +169 -48
  113. package/dist-sdk/src/entities/agent-tool/types.d.ts +4 -6
  114. package/dist-sdk/src/entities/agent-tool/types.js +30 -29
  115. package/dist-sdk/src/entities/app/build.d.ts +214 -47
  116. package/dist-sdk/src/entities/app/build.js +128 -66
  117. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +188 -8
  118. package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +59 -0
  119. package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +70 -0
  120. package/dist-sdk/src/entities/app/display-blocks.d.ts +2 -1
  121. package/dist-sdk/src/entities/app/display-blocks.js +1 -1
  122. package/dist-sdk/src/entities/app/from-tf.d.ts +11 -1
  123. package/dist-sdk/src/entities/app/from-tf.js +30 -2
  124. package/dist-sdk/src/entities/app/index.d.ts +20 -8
  125. package/dist-sdk/src/entities/app/index.js +16 -6
  126. package/dist-sdk/src/entities/app/module.js +29 -4
  127. package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
  128. package/dist-sdk/src/entities/app/to-tf.js +97 -7
  129. package/dist-sdk/src/entities/approval-chain/build.d.ts +31 -16
  130. package/dist-sdk/src/entities/approval-chain/build.js +49 -49
  131. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +17 -0
  132. package/dist-sdk/src/entities/approval-chain/from-tf.js +57 -0
  133. package/dist-sdk/src/entities/approval-chain/index.d.ts +2 -3
  134. package/dist-sdk/src/entities/approval-chain/index.js +2 -3
  135. package/dist-sdk/src/entities/approval-chain/module.d.ts +3 -0
  136. package/dist-sdk/src/entities/approval-chain/module.js +51 -0
  137. package/dist-sdk/src/entities/approval-chain/printer.d.ts +2 -0
  138. package/dist-sdk/src/entities/approval-chain/printer.js +21 -0
  139. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +9 -0
  140. package/dist-sdk/src/entities/approval-chain/to-tf.js +43 -0
  141. package/dist-sdk/src/entities/automation/build.d.ts +177 -95
  142. package/dist-sdk/src/entities/automation/build.js +164 -72
  143. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
  144. package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
  145. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +18 -9
  146. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
  147. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +214 -311
  148. package/dist-sdk/src/entities/automation/filter.d.ts +1 -115
  149. package/dist-sdk/src/entities/automation/filter.js +1 -197
  150. package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -0
  151. package/dist-sdk/src/entities/automation/from-tf.js +695 -182
  152. package/dist-sdk/src/entities/automation/index.d.ts +9 -10
  153. package/dist-sdk/src/entities/automation/index.js +11 -11
  154. package/dist-sdk/src/entities/automation/module.js +82 -8
  155. package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
  156. package/dist-sdk/src/entities/automation/operators.js +10 -37
  157. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
  158. package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
  159. package/dist-sdk/src/entities/automation/script-code.js +107 -28
  160. package/dist-sdk/src/entities/automation/serialize.js +1 -1
  161. package/dist-sdk/src/entities/automation/tasks.d.ts +167 -102
  162. package/dist-sdk/src/entities/automation/tasks.js +66 -13
  163. package/dist-sdk/src/entities/automation/to-tf.d.ts +44 -3
  164. package/dist-sdk/src/entities/automation/to-tf.js +607 -161
  165. package/dist-sdk/src/entities/automation/triggers.d.ts +33 -25
  166. package/dist-sdk/src/entities/automation/triggers.js +8 -2
  167. package/dist-sdk/src/entities/automation/types.d.ts +3 -2
  168. package/dist-sdk/src/entities/automation/types.js +3 -2
  169. package/dist-sdk/src/entities/chart/build.d.ts +95 -0
  170. package/dist-sdk/src/entities/chart/build.js +42 -0
  171. package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
  172. package/dist-sdk/src/entities/chart/from-tf.js +269 -0
  173. package/dist-sdk/src/entities/chart/index.d.ts +4 -0
  174. package/dist-sdk/src/entities/chart/index.js +3 -0
  175. package/dist-sdk/src/entities/chart/module.d.ts +3 -0
  176. package/dist-sdk/src/entities/chart/module.js +61 -0
  177. package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
  178. package/dist-sdk/src/entities/chart/printer.js +104 -0
  179. package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
  180. package/dist-sdk/src/entities/chart/to-tf.js +150 -0
  181. package/dist-sdk/src/entities/chart/types.d.ts +53 -0
  182. package/dist-sdk/src/entities/chart/types.js +22 -0
  183. package/dist-sdk/src/entities/dashboard/build.d.ts +44 -0
  184. package/dist-sdk/src/entities/dashboard/build.js +16 -0
  185. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +12 -0
  186. package/dist-sdk/src/entities/dashboard/from-tf.js +113 -0
  187. package/dist-sdk/src/entities/dashboard/module.d.ts +3 -0
  188. package/dist-sdk/src/entities/dashboard/module.js +16 -0
  189. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +43 -0
  190. package/dist-sdk/src/entities/dashboard/to-tf.js +121 -0
  191. package/dist-sdk/src/entities/dashboard-widget/module.d.ts +3 -0
  192. package/dist-sdk/src/entities/dashboard-widget/module.js +10 -0
  193. package/dist-sdk/src/entities/data-lookup/module.d.ts +3 -0
  194. package/dist-sdk/src/entities/data-lookup/module.js +22 -0
  195. package/dist-sdk/src/entities/datamine/build.d.ts +22 -0
  196. package/dist-sdk/src/entities/datamine/from-tf.d.ts +17 -0
  197. package/dist-sdk/src/entities/datamine/from-tf.js +98 -0
  198. package/dist-sdk/src/entities/datamine/module.d.ts +3 -0
  199. package/dist-sdk/src/entities/datamine/module.js +23 -0
  200. package/dist-sdk/src/entities/datamine/to-tf.d.ts +11 -0
  201. package/dist-sdk/src/entities/datamine/to-tf.js +53 -0
  202. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +304 -0
  203. package/dist-sdk/src/entities/dynamic-layout/build.js +4 -0
  204. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +4 -0
  205. package/dist-sdk/src/entities/dynamic-layout/dialect.js +47 -0
  206. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +10 -0
  207. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +239 -0
  208. package/dist-sdk/src/entities/dynamic-layout/module.d.ts +3 -0
  209. package/dist-sdk/src/entities/dynamic-layout/module.js +13 -0
  210. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +26 -0
  211. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +267 -0
  212. package/dist-sdk/src/entities/element/build.d.ts +48 -38
  213. package/dist-sdk/src/entities/element/build.js +24 -33
  214. package/dist-sdk/src/entities/element/from-tf.d.ts +9 -1
  215. package/dist-sdk/src/entities/element/from-tf.js +31 -2
  216. package/dist-sdk/src/entities/element/index.d.ts +14 -7
  217. package/dist-sdk/src/entities/element/index.js +11 -5
  218. package/dist-sdk/src/entities/element/module.js +26 -5
  219. package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
  220. package/dist-sdk/src/entities/element/to-tf.js +64 -4
  221. package/dist-sdk/src/entities/field/build.d.ts +55 -27
  222. package/dist-sdk/src/entities/field/build.js +31 -6
  223. package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
  224. package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
  225. package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
  226. package/dist-sdk/src/entities/field/calc/date.js +120 -29
  227. package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
  228. package/dist-sdk/src/entities/field/calc/index.js +82 -139
  229. package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
  230. package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
  231. package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
  232. package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
  233. package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
  234. package/dist-sdk/src/entities/field/calc/text.js +43 -31
  235. package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
  236. package/dist-sdk/src/entities/field/calc/types.js +1 -22
  237. package/dist-sdk/src/entities/field/calc.d.ts +71 -48
  238. package/dist-sdk/src/entities/field/calc.js +5 -15
  239. package/dist-sdk/src/entities/field/calculation-types.d.ts +6 -0
  240. package/dist-sdk/src/entities/field/calculation-types.js +49 -0
  241. package/dist-sdk/src/entities/field/from-tf.js +238 -13
  242. package/dist-sdk/src/entities/field/locals.d.ts +11 -3
  243. package/dist-sdk/src/entities/field/locals.js +15 -2
  244. package/dist-sdk/src/entities/field/module.d.ts +1 -0
  245. package/dist-sdk/src/entities/field/module.js +27 -7
  246. package/dist-sdk/src/entities/field/record-shape.d.ts +25 -11
  247. package/dist-sdk/src/entities/field/to-tf.d.ts +41 -2
  248. package/dist-sdk/src/entities/field/to-tf.js +314 -40
  249. package/dist-sdk/src/entities/field/types.d.ts +1 -1
  250. package/dist-sdk/src/entities/field/types.js +10 -1
  251. package/dist-sdk/src/entities/file-reader/build.d.ts +71 -19
  252. package/dist-sdk/src/entities/file-reader/build.js +49 -4
  253. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +1 -0
  254. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +12 -10
  255. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +1 -1
  256. package/dist-sdk/src/entities/file-reader/from-tf.js +31 -2
  257. package/dist-sdk/src/entities/file-reader/index.d.ts +3 -3
  258. package/dist-sdk/src/entities/file-reader/index.js +3 -3
  259. package/dist-sdk/src/entities/file-reader/module.js +6 -5
  260. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +1 -1
  261. package/dist-sdk/src/entities/file-reader/to-tf.js +5 -2
  262. package/dist-sdk/src/entities/file-reader/types.d.ts +3 -4
  263. package/dist-sdk/src/entities/file-reader/types.js +4 -5
  264. package/dist-sdk/src/entities/org/category.js +4 -5
  265. package/dist-sdk/src/entities/org/cloud-link.js +4 -5
  266. package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
  267. package/dist-sdk/src/entities/org/email-alias.js +12 -0
  268. package/dist-sdk/src/entities/org/group.js +4 -5
  269. package/dist-sdk/src/entities/org/index.d.ts +2 -0
  270. package/dist-sdk/src/entities/org/index.js +2 -0
  271. package/dist-sdk/src/entities/org/phone-provider.d.ts +4 -0
  272. package/dist-sdk/src/entities/org/phone-provider.js +30 -0
  273. package/dist-sdk/src/entities/org/role.d.ts +3 -3
  274. package/dist-sdk/src/entities/org/role.js +9 -6
  275. package/dist-sdk/src/entities/organization/build.d.ts +241 -0
  276. package/dist-sdk/src/entities/organization/build.js +165 -0
  277. package/dist-sdk/src/entities/organization/index.d.ts +2 -0
  278. package/dist-sdk/src/entities/organization/index.js +2 -0
  279. package/dist-sdk/src/entities/organization/module.d.ts +2 -0
  280. package/dist-sdk/src/entities/organization/module.js +21 -0
  281. package/dist-sdk/src/entities/organization/to-tf.d.ts +7 -0
  282. package/dist-sdk/src/entities/organization/to-tf.js +154 -0
  283. package/dist-sdk/src/entities/phone-service/build.d.ts +17 -0
  284. package/dist-sdk/src/entities/phone-service/build.js +31 -0
  285. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.d.ts +4 -0
  286. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +56 -0
  287. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +25 -0
  288. package/dist-sdk/src/entities/phone-service/from-tf.js +75 -0
  289. package/dist-sdk/src/entities/phone-service/index.d.ts +2 -0
  290. package/dist-sdk/src/entities/phone-service/index.js +2 -0
  291. package/dist-sdk/src/entities/phone-service/module.d.ts +3 -0
  292. package/dist-sdk/src/entities/phone-service/module.js +55 -0
  293. package/dist-sdk/src/entities/phone-service/to-tf.d.ts +12 -0
  294. package/dist-sdk/src/entities/phone-service/to-tf.js +54 -0
  295. package/dist-sdk/src/entities/phone-service/types.d.ts +35 -0
  296. package/dist-sdk/src/entities/phone-service/types.js +22 -0
  297. package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +11 -0
  298. package/dist-sdk/src/entities/record-create-form/from-tf.js +74 -0
  299. package/dist-sdk/src/entities/record-create-form/module.d.ts +11 -0
  300. package/dist-sdk/src/entities/record-create-form/module.js +24 -0
  301. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +33 -0
  302. package/dist-sdk/src/entities/record-create-form/to-tf.js +88 -0
  303. package/dist-sdk/src/entities/relationship/build.d.ts +16 -0
  304. package/dist-sdk/src/entities/relationship/build.js +1 -0
  305. package/dist-sdk/src/entities/relationship/from-tf.d.ts +12 -0
  306. package/dist-sdk/src/entities/relationship/from-tf.js +109 -0
  307. package/dist-sdk/src/entities/relationship/module.d.ts +3 -0
  308. package/dist-sdk/src/entities/relationship/module.js +16 -0
  309. package/dist-sdk/src/entities/relationship/to-tf.d.ts +32 -0
  310. package/dist-sdk/src/entities/relationship/to-tf.js +145 -0
  311. package/dist-sdk/src/entities/role/build.d.ts +65 -0
  312. package/dist-sdk/src/entities/role/build.js +33 -0
  313. package/dist-sdk/src/entities/role/from-tf.d.ts +13 -0
  314. package/dist-sdk/src/entities/role/from-tf.js +138 -0
  315. package/dist-sdk/src/entities/role/to-tf.d.ts +13 -0
  316. package/dist-sdk/src/entities/role/to-tf.js +69 -0
  317. package/dist-sdk/src/entities/search-table/build.d.ts +67 -28
  318. package/dist-sdk/src/entities/search-table/build.js +110 -56
  319. package/dist-sdk/src/entities/search-table/from-tf.d.ts +37 -0
  320. package/dist-sdk/src/entities/search-table/from-tf.js +113 -0
  321. package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
  322. package/dist-sdk/src/entities/search-table/index.js +2 -2
  323. package/dist-sdk/src/entities/search-table/module.js +88 -10
  324. package/dist-sdk/src/entities/search-table/printer.d.ts +2 -0
  325. package/dist-sdk/src/entities/search-table/printer.js +52 -0
  326. package/dist-sdk/src/entities/search-table/to-tf.d.ts +14 -0
  327. package/dist-sdk/src/entities/search-table/to-tf.js +104 -0
  328. package/dist-sdk/src/entities/search-table/types.d.ts +8 -0
  329. package/dist-sdk/src/entities/search-table/types.js +21 -0
  330. package/dist-sdk/src/entities/service-account/build.d.ts +32 -0
  331. package/dist-sdk/src/entities/service-account/build.js +9 -0
  332. package/dist-sdk/src/entities/service-account/from-tf.d.ts +10 -0
  333. package/dist-sdk/src/entities/service-account/from-tf.js +109 -0
  334. package/dist-sdk/src/entities/service-account/module.d.ts +4 -0
  335. package/dist-sdk/src/entities/service-account/module.js +21 -0
  336. package/dist-sdk/src/entities/service-account/ref.d.ts +11 -0
  337. package/dist-sdk/src/entities/service-account/ref.js +5 -0
  338. package/dist-sdk/src/entities/service-account/to-tf.d.ts +32 -0
  339. package/dist-sdk/src/entities/service-account/to-tf.js +103 -0
  340. package/dist-sdk/src/entities/shared/connector-from-tf.d.ts +14 -0
  341. package/dist-sdk/src/entities/shared/connector-from-tf.js +14 -0
  342. package/dist-sdk/src/entities/shared/context.d.ts +25 -24
  343. package/dist-sdk/src/entities/shared/context.js +36 -35
  344. package/dist-sdk/src/entities/shared/filters/ast.d.ts +30 -81
  345. package/dist-sdk/src/entities/shared/filters/ast.js +6 -2
  346. package/dist-sdk/src/entities/shared/filters/index.d.ts +95 -206
  347. package/dist-sdk/src/entities/shared/filters/index.js +196 -341
  348. package/dist-sdk/src/entities/shared/filters/print.d.ts +11 -0
  349. package/dist-sdk/src/entities/shared/filters/print.js +122 -0
  350. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +170 -0
  351. package/dist-sdk/src/entities/shared/filters/tf-codec.js +527 -0
  352. package/dist-sdk/src/entities/shared/filters/types.d.ts +66 -69
  353. package/dist-sdk/src/entities/shared/filters/types.js +2 -3
  354. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
  355. package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
  356. package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
  357. package/dist-sdk/src/entities/shared/ref.js +8 -3
  358. package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
  359. package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
  360. package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
  361. package/dist-sdk/src/entities/skill/build.d.ts +4 -4
  362. package/dist-sdk/src/entities/skill/build.js +6 -5
  363. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +11 -1
  364. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +100 -39
  365. package/dist-sdk/src/entities/skill/index.d.ts +3 -2
  366. package/dist-sdk/src/entities/skill/index.js +3 -2
  367. package/dist-sdk/src/entities/skill/module.js +8 -2
  368. package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -2
  369. package/dist-sdk/src/entities/skill/to-tf.js +20 -2
  370. package/dist-sdk/src/entities/skill/tools.d.ts +47 -31
  371. package/dist-sdk/src/entities/skill/tools.js +37 -23
  372. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +17 -1
  373. package/dist-sdk/src/entities/skill-tool/from-tf.js +118 -8
  374. package/dist-sdk/src/entities/skill-tool/module.js +9 -0
  375. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
  376. package/dist-sdk/src/entities/skill-tool/to-tf.js +100 -48
  377. package/dist-sdk/src/entities/skill-tool/types.js +18 -1
  378. package/dist-sdk/src/entities/table/build.d.ts +64 -23
  379. package/dist-sdk/src/entities/table/build.js +41 -26
  380. package/dist-sdk/src/entities/table/catalog-render.js +15 -1
  381. package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +99 -0
  382. package/dist-sdk/src/entities/table/deserializer/normalize.js +192 -0
  383. package/dist-sdk/src/entities/table/fields/types.d.ts +86 -0
  384. package/dist-sdk/src/entities/table/fields/types.js +12 -0
  385. package/dist-sdk/src/entities/table/fields.d.ts +107 -47
  386. package/dist-sdk/src/entities/table/fields.js +76 -55
  387. package/dist-sdk/src/entities/table/from-tf.d.ts +4 -0
  388. package/dist-sdk/src/entities/table/from-tf.js +261 -0
  389. package/dist-sdk/src/entities/table/index.d.ts +7 -5
  390. package/dist-sdk/src/entities/table/index.js +7 -7
  391. package/dist-sdk/src/entities/table/joins.d.ts +22 -9
  392. package/dist-sdk/src/entities/table/joins.js +8 -16
  393. package/dist-sdk/src/entities/table/module.d.ts +2 -1
  394. package/dist-sdk/src/entities/table/module.js +13 -6
  395. package/dist-sdk/src/entities/table/to-tf.d.ts +10 -0
  396. package/dist-sdk/src/entities/table/to-tf.js +222 -0
  397. package/dist-sdk/src/entities/task/build.d.ts +43 -0
  398. package/dist-sdk/src/entities/task/build.js +17 -0
  399. package/dist-sdk/src/entities/task/from-tf.d.ts +28 -0
  400. package/dist-sdk/src/entities/task/from-tf.js +38 -0
  401. package/dist-sdk/src/entities/task/index.d.ts +1 -0
  402. package/dist-sdk/src/entities/task/index.js +1 -0
  403. package/dist-sdk/src/entities/task/module.d.ts +3 -0
  404. package/dist-sdk/src/entities/task/module.js +12 -0
  405. package/dist-sdk/src/entities/task/to-tf.d.ts +9 -0
  406. package/dist-sdk/src/entities/task/to-tf.js +49 -0
  407. package/dist-sdk/src/entities/view/build.d.ts +46 -0
  408. package/dist-sdk/src/entities/view/build.js +19 -0
  409. package/dist-sdk/src/entities/view/from-tf.d.ts +7 -2
  410. package/dist-sdk/src/entities/view/from-tf.js +264 -30
  411. package/dist-sdk/src/entities/view/module.d.ts +6 -13
  412. package/dist-sdk/src/entities/view/module.js +12 -15
  413. package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
  414. package/dist-sdk/src/entities/view/sharing.js +6 -0
  415. package/dist-sdk/src/entities/view/to-tf.d.ts +56 -12
  416. package/dist-sdk/src/entities/view/to-tf.js +192 -20
  417. package/dist-sdk/src/entities/view/types.d.ts +8 -0
  418. package/dist-sdk/src/entities/view/types.js +46 -0
  419. package/dist-sdk/src/entities/visual-flow/build.d.ts +87 -0
  420. package/dist-sdk/src/entities/visual-flow/build.js +72 -0
  421. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +49 -0
  422. package/dist-sdk/src/entities/visual-flow/from-tf.js +124 -0
  423. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -0
  424. package/dist-sdk/src/entities/visual-flow/index.js +1 -0
  425. package/dist-sdk/src/entities/visual-flow/module.d.ts +3 -0
  426. package/dist-sdk/src/entities/visual-flow/module.js +41 -0
  427. package/dist-sdk/src/entities/visual-flow/printer.d.ts +8 -0
  428. package/dist-sdk/src/entities/visual-flow/printer.js +92 -0
  429. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +15 -0
  430. package/dist-sdk/src/entities/visual-flow/to-tf.js +97 -0
  431. package/dist-sdk/src/entities/widget/build.d.ts +55 -0
  432. package/dist-sdk/src/entities/widget/build.js +1 -0
  433. package/dist-sdk/src/entities/widget/from-tf.d.ts +11 -0
  434. package/dist-sdk/src/entities/widget/from-tf.js +209 -0
  435. package/dist-sdk/src/entities/widget/module.d.ts +3 -0
  436. package/dist-sdk/src/entities/widget/module.js +16 -0
  437. package/dist-sdk/src/entities/widget/to-tf.d.ts +45 -0
  438. package/dist-sdk/src/entities/widget/to-tf.js +206 -0
  439. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +1 -1
  440. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -1
  441. package/dist-sdk/src/graph/index.d.ts +12 -1
  442. package/dist-sdk/src/graph/index.js +8 -19
  443. package/dist-sdk/src/graph/modules.js +35 -1
  444. package/dist-sdk/src/graph/types.d.ts +106 -7
  445. package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
  446. package/dist-sdk/src/internal/safe-identifier.js +13 -0
  447. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  448. package/dist-sdk/src/internal/sdk-package.js +5 -2
  449. package/package.json +39 -15
  450. package/dist-sdk/src/entities/access-policy/filter.d.ts +0 -61
  451. package/dist-sdk/src/entities/access-policy/filter.js +0 -83
  452. package/dist-sdk/src/entities/approval-chain/steps.d.ts +0 -24
  453. package/dist-sdk/src/entities/approval-chain/steps.js +0 -20
  454. package/dist-sdk/src/entities/flow/activities/agent.d.ts +0 -15
  455. package/dist-sdk/src/entities/flow/activities/agent.js +0 -29
  456. package/dist-sdk/src/entities/flow/activities/approval.d.ts +0 -9
  457. package/dist-sdk/src/entities/flow/activities/approval.js +0 -18
  458. package/dist-sdk/src/entities/flow/activities/automation.d.ts +0 -12
  459. package/dist-sdk/src/entities/flow/activities/automation.js +0 -22
  460. package/dist-sdk/src/entities/flow/activities/ctx.d.ts +0 -34
  461. package/dist-sdk/src/entities/flow/activities/ctx.js +0 -38
  462. package/dist-sdk/src/entities/flow/activities/form.d.ts +0 -22
  463. package/dist-sdk/src/entities/flow/activities/form.js +0 -36
  464. package/dist-sdk/src/entities/flow/activities/index.d.ts +0 -14
  465. package/dist-sdk/src/entities/flow/activities/index.js +0 -13
  466. package/dist-sdk/src/entities/flow/activities/input-refs.d.ts +0 -39
  467. package/dist-sdk/src/entities/flow/activities/input-refs.js +0 -19
  468. package/dist-sdk/src/entities/flow/activities/prompt-template.d.ts +0 -13
  469. package/dist-sdk/src/entities/flow/activities/prompt-template.js +0 -34
  470. package/dist-sdk/src/entities/flow/activities/types.d.ts +0 -33
  471. package/dist-sdk/src/entities/flow/build.d.ts +0 -38
  472. package/dist-sdk/src/entities/flow/build.js +0 -115
  473. package/dist-sdk/src/entities/flow/index.d.ts +0 -8
  474. package/dist-sdk/src/entities/flow/index.js +0 -7
  475. package/dist-sdk/src/entities/flow/serialize.d.ts +0 -51
  476. package/dist-sdk/src/entities/flow/serialize.js +0 -94
  477. package/dist-sdk/src/entities/flow/util.d.ts +0 -27
  478. package/dist-sdk/src/entities/flow/util.js +0 -38
  479. package/dist-sdk/src/entities/table/filter.d.ts +0 -41
  480. package/dist-sdk/src/entities/table/filter.js +0 -89
  481. /package/dist-sdk/src/entities/{flow/activities/types.js → datamine/build.js} +0 -0
@@ -20,6 +20,7 @@
20
20
  * both these and the bare keywords; the function form is the
21
21
  * canonical shape per the Java test).
22
22
  */
23
+ import { isRef } from "../../shared/ref.js";
23
24
  import { isUuid } from "../../../../pull/util.js";
24
25
  // ---------------------------------------------------------------------------
25
26
  // Node construction
@@ -28,10 +29,12 @@ import { isUuid } from "../../../../pull/util.js";
28
29
  * Build an `Expr<T>` node from its type brand and a serializer
29
30
  * closure. Internal — public builders compose this.
30
31
  */
31
- export function makeExpr(type, serialize) {
32
+ export function makeExpr(type, serialize, metadata) {
32
33
  return {
33
34
  __calc: true,
34
35
  __exprType: type,
36
+ __exprCardinality: metadata?.cardinality ?? "single",
37
+ __exprContext: metadata?.context ?? "standalone",
35
38
  toCalcString: serialize,
36
39
  };
37
40
  }
@@ -39,12 +42,20 @@ export function makeExpr(type, serialize) {
39
42
  * True if `value` is already an `Expr<T>` (built by a prior `calc.*`
40
43
  * call or a pulled-expression marker). Discriminator-checked.
41
44
  */
42
- function isExpr(value) {
45
+ export function isExpr(value) {
43
46
  return (typeof value === "object" &&
44
47
  value !== null &&
45
48
  "__calc" in value &&
46
49
  value.__calc === true);
47
50
  }
51
+ /** Aggregate runtime context metadata for a composed expression. */
52
+ export function expressionContext(expressions) {
53
+ return expressions.some((expression) => expression.__exprContext === "record") ? "record" : "standalone";
54
+ }
55
+ /** Build a scalar parent node while preserving record-context metadata. */
56
+ export function makeComposedExpr(type, expressions, serialize) {
57
+ return makeExpr(type, serialize, { context: expressionContext(expressions) });
58
+ }
48
59
  /**
49
60
  * True if `value` looks like an `AppField`. Structural check — looks
50
61
  * for the `type` + `id` + `name` triplet every variant carries.
@@ -56,6 +67,14 @@ function isAppField(value) {
56
67
  "id" in value &&
57
68
  "name" in value);
58
69
  }
70
+ function isFieldRef(value) {
71
+ return (typeof value === "object" &&
72
+ value !== null &&
73
+ "__kind" in value &&
74
+ value.__kind === "field" &&
75
+ "fieldType" in value &&
76
+ "name" in value);
77
+ }
59
78
  // ---------------------------------------------------------------------------
60
79
  // Field-ref serialization
61
80
  // ---------------------------------------------------------------------------
@@ -87,14 +106,14 @@ function appFieldExprType(field) {
87
106
  case "NUMBER": return "number";
88
107
  case "DECIMAL": return "decimal";
89
108
  case "TEXT":
90
- case "RICH_TEXT":
91
- case "HTML":
92
- case "HANDLE": return "text";
109
+ case "RICH_TEXT": return "text";
110
+ case "HTML": return "html";
111
+ case "HANDLE": return "handle";
93
112
  case "BOOLEAN": return "bool";
94
113
  case "DATE": return "date";
95
114
  case "DATETIME": return "datetime";
96
- case "PICKLIST":
97
- case "MULTI_PICKLIST": return "picklist";
115
+ case "PICKLIST": return "picklist";
116
+ case "MULTI_PICKLIST": return "multiPicklist";
98
117
  case "USER":
99
118
  case "USER_ID": return "user";
100
119
  case "GROUP":
@@ -118,6 +137,44 @@ function appFieldExprType(field) {
118
137
  }
119
138
  }
120
139
  }
140
+ function catalogFieldExprType(field) {
141
+ switch (field.fieldType) {
142
+ case "NUMBER": return "number";
143
+ case "DECIMAL": return "decimal";
144
+ case "TEXT":
145
+ case "RICH_TEXT": return "text";
146
+ case "HANDLE": return "handle";
147
+ case "HTML": return "html";
148
+ case "BOOLEAN": return "bool";
149
+ case "DATE": return "date";
150
+ case "DATETIME": return "datetime";
151
+ case "PICKLIST": return "picklist";
152
+ case "MULTI_PICKLIST": return "multiPicklist";
153
+ case "USER":
154
+ case "USER_ID": return "user";
155
+ case "GROUP":
156
+ case "GROUP_ID": return "group";
157
+ case "ATTACHMENT":
158
+ case "ATTACHMENT_ID": return "attachment";
159
+ case "JSON": return "json";
160
+ default:
161
+ throw new Error(`calc: unsupported catalog field type "${field.fieldType}" on "${field.name}".`);
162
+ }
163
+ }
164
+ let activeWorkflowRefRenderer;
165
+ /** Install the automation calculation parameter collector for one render. */
166
+ export function withWorkflowRefRenderer(renderer, render) {
167
+ if (activeWorkflowRefRenderer !== undefined) {
168
+ throw new Error("nested calculation expression rendering is not supported.");
169
+ }
170
+ activeWorkflowRefRenderer = renderer;
171
+ try {
172
+ return render();
173
+ }
174
+ finally {
175
+ activeWorkflowRefRenderer = undefined;
176
+ }
177
+ }
121
178
  // ---------------------------------------------------------------------------
122
179
  // Literal serialization
123
180
  // ---------------------------------------------------------------------------
@@ -152,10 +209,24 @@ export function coerce(value) {
152
209
  if (isExpr(value)) {
153
210
  return value;
154
211
  }
212
+ if (isFieldRef(value)) {
213
+ const field = value;
214
+ const exprType = catalogFieldExprType(field);
215
+ return makeExpr(exprType, () => `"${field.name.replace(/"/g, '""')}"`, { context: "record" });
216
+ }
155
217
  if (isAppField(value)) {
156
218
  const field = value;
157
219
  const exprType = appFieldExprType(field);
158
- return makeExpr(exprType, () => emitFieldRef(field));
220
+ return makeExpr(exprType, () => emitFieldRef(field), { context: "record" });
221
+ }
222
+ if (isRef(value)) {
223
+ const ref = value;
224
+ return makeExpr("text", () => {
225
+ if (activeWorkflowRefRenderer === undefined) {
226
+ throw new Error("workflow refs can only be rendered by calculation(); pass this expression directly to a calculation value.");
227
+ }
228
+ return activeWorkflowRefRenderer(ref);
229
+ });
159
230
  }
160
231
  if (typeof value === "number") {
161
232
  // Integer → number, fractional → decimal. The runtime split
@@ -7,67 +7,67 @@
7
7
  * wire form, and brands the result.
8
8
  *
9
9
  * Type rules baked in:
10
- * - `concat` accepts any expression — the server stringifies non-text
11
- * arguments as part of the concatenation (matches the Java test's
12
- * `CONCAT("Partner", "Closed on")` case where a datetime concatenates
13
- * into a text result).
10
+ * - `concat` accepts the scalar families Knowhere can stringify directly:
11
+ * date, datetime, decimal, number, boolean, and text.
14
12
  * - `len` accepts text only (server rejects numeric).
15
13
  * - `regexMatch` returns bool; the rest return text.
16
14
  * - Argument naming favors readability over wire-form parity
17
15
  * (`needle` / `haystack` for FIND/SEARCH; `pattern` for regex).
18
16
  */
19
- import type { Expr, ExprLike, ExprType } from "./types.js";
17
+ import type { ComposedExpr, ExprLike, ExprType } from "./types.js";
18
+ /** Types Knowhere currently permits as direct CONCAT arguments. */
19
+ export type ConcatExprType = "datetime" | "date" | "decimal" | "number" | "bool" | "text";
20
20
  /**
21
21
  * Concatenate two or more expressions into a single text value.
22
22
  * Non-text expressions are stringified by the server. At least two
23
23
  * args are required — wire `CONCAT` rejects a single-arg call.
24
24
  */
25
- export declare function concat(a: ExprLike<ExprType>, b: ExprLike<ExprType>, ...rest: ExprLike<ExprType>[]): Expr<"text">;
25
+ export declare function concat<const A extends ExprLike<ConcatExprType>, const B extends ExprLike<ConcatExprType>, const Rest extends readonly ExprLike<ConcatExprType>[]>(a: A, b: B, ...rest: Rest): ComposedExpr<"text", [A, B, ...Rest]>;
26
26
  /**
27
27
  * Coerce any expression to text. Wire `TEXT(value)`. Useful for
28
28
  * embedding non-text values inside a string-shaped expression where
29
29
  * the server's implicit promotion isn't enough.
30
30
  */
31
- export declare function toText<T extends ExprType>(value: ExprLike<T>): Expr<"text">;
31
+ export declare function toText<T extends ExprType, const Value extends ExprLike<T>>(value: Value): ComposedExpr<"text", [Value]>;
32
32
  /** Character length of a text expression. Returns NUMBER. */
33
- export declare function len(value: ExprLike<"text">): Expr<"number">;
33
+ export declare function len<const Value extends ExprLike<"text">>(value: Value): ComposedExpr<"number", [Value]>;
34
34
  /** Strip leading/trailing whitespace. */
35
- export declare function trim(value: ExprLike<"text">): Expr<"text">;
35
+ export declare function trim<const Value extends ExprLike<"text">>(value: Value): ComposedExpr<"text", [Value]>;
36
36
  /** Upper-case. */
37
- export declare function upper(value: ExprLike<"text">): Expr<"text">;
37
+ export declare function upper<const Value extends ExprLike<"text">>(value: Value): ComposedExpr<"text", [Value]>;
38
38
  /** Lower-case. */
39
- export declare function lower(value: ExprLike<"text">): Expr<"text">;
39
+ export declare function lower<const Value extends ExprLike<"text">>(value: Value): ComposedExpr<"text", [Value]>;
40
40
  /**
41
41
  * Leftmost `n` characters of a text expression. `n` defaults to 1 on
42
42
  * the server when omitted. Wire emits `LEFT(text)` or `LEFT(text, n)`.
43
43
  */
44
- export declare function left(value: ExprLike<"text">, n?: ExprLike<"number">): Expr<"text">;
44
+ export declare function left<const Value extends ExprLike<"text">, const N extends ExprLike<"number"> | undefined = undefined>(value: Value, n?: N): ComposedExpr<"text", [Value, N]>;
45
45
  /**
46
46
  * Rightmost `n` characters of a text expression. `n` defaults to 1 on
47
47
  * the server when omitted.
48
48
  */
49
- export declare function right(value: ExprLike<"text">, n?: ExprLike<"number">): Expr<"text">;
49
+ export declare function right<const Value extends ExprLike<"text">, const N extends ExprLike<"number"> | undefined = undefined>(value: Value, n?: N): ComposedExpr<"text", [Value, N]>;
50
50
  /**
51
51
  * Substring from `start` (1-indexed) for `length` characters. Wire
52
52
  * emits `MID(text, start, length)`.
53
53
  */
54
- export declare function mid(value: ExprLike<"text">, start: ExprLike<"number">, length: ExprLike<"number">): Expr<"text">;
54
+ export declare function mid<const Value extends ExprLike<"text">, const Start extends ExprLike<"number">, const Length extends ExprLike<"number">>(value: Value, start: Start, length: Length): ComposedExpr<"text", [Value, Start, Length]>;
55
55
  /**
56
56
  * Replace every occurrence of `find` with `replace` in `value`. Wire
57
57
  * emits `SUBSTITUTE(value, find, replace)`. For pattern-based
58
58
  * replacement use `regexReplace`.
59
59
  */
60
- export declare function substitute(value: ExprLike<"text">, find: ExprLike<"text">, replace: ExprLike<"text">): Expr<"text">;
60
+ export declare function substitute<const Value extends ExprLike<"text">, const Find extends ExprLike<"text">, const Replace extends ExprLike<"text">>(value: Value, find: Find, replace: Replace): ComposedExpr<"text", [Value, Find, Replace]>;
61
61
  /**
62
62
  * Case-sensitive index of `needle` within `haystack` (1-indexed).
63
63
  * `start` is the 1-indexed position to begin searching from. Wire:
64
64
  * `FIND(needle, haystack)` / `FIND(needle, haystack, start)`.
65
65
  */
66
- export declare function find(needle: ExprLike<"text">, haystack: ExprLike<"text">, start?: ExprLike<"number">): Expr<"number">;
66
+ export declare function find<const Needle extends ExprLike<"text">, const Haystack extends ExprLike<"text">, const Start extends ExprLike<"number"> | undefined = undefined>(needle: Needle, haystack: Haystack, start?: Start): ComposedExpr<"number", [Needle, Haystack, Start]>;
67
67
  /**
68
68
  * Case-INsensitive variant of `find`. Wire: `SEARCH(...)`.
69
69
  */
70
- export declare function search(needle: ExprLike<"text">, haystack: ExprLike<"text">, start?: ExprLike<"number">): Expr<"number">;
70
+ export declare function search<const Needle extends ExprLike<"text">, const Haystack extends ExprLike<"text">, const Start extends ExprLike<"number"> | undefined = undefined>(needle: Needle, haystack: Haystack, start?: Start): ComposedExpr<"number", [Needle, Haystack, Start]>;
71
71
  /**
72
72
  * Split a text expression by a separator. Wire `SPLIT(text, sep)`.
73
73
  * The server returns a text array internally; in expression context
@@ -76,25 +76,34 @@ export declare function search(needle: ExprLike<"text">, haystack: ExprLike<"tex
76
76
  * JS keyword `split` in `calc.split` — `splitText` reads cleanly in
77
77
  * the calc namespace.
78
78
  */
79
- export declare function splitText(value: ExprLike<"text">, separator: ExprLike<"text">): Expr<"text">;
79
+ /** @deprecated Prefer {@link split}. */
80
+ export declare function splitText<const Value extends ExprLike<"text">, const Separator extends ExprLike<"text">>(value: Value, separator: Separator): ComposedExpr<"text", [Value, Separator], "multiple">;
81
+ /** Canonical concise name for the multi-valued SPLIT function. */
82
+ export declare const split: typeof splitText;
80
83
  /**
81
84
  * Regex match test. Wire `REGEXMATCH(text, pattern)` or
82
85
  * `REGEXMATCH(text, pattern, TRUE)` for case-insensitive matching.
83
86
  * The `ignoreCase` flag is a bool literal on the wire — TS accepts a
84
87
  * raw boolean here so the agent doesn't have to wrap it.
85
88
  */
86
- export declare function regexMatch(value: ExprLike<"text">, pattern: ExprLike<"text">, ignoreCase?: boolean): Expr<"bool">;
89
+ export declare function regexMatch<const Value extends ExprLike<"text">, const Pattern extends ExprLike<"text">>(value: Value, pattern: Pattern, options?: boolean | {
90
+ readonly ignoreCase?: boolean;
91
+ }): ComposedExpr<"bool", [Value, Pattern]>;
87
92
  /**
88
93
  * Regex search-and-replace. Wire `REGEXREPLACE(text, pattern, repl)`
89
94
  * or `REGEXREPLACE(text, pattern, repl, TRUE)` for case-insensitive.
90
95
  */
91
- export declare function regexReplace(value: ExprLike<"text">, pattern: ExprLike<"text">, replacement: ExprLike<"text">, ignoreCase?: boolean): Expr<"text">;
96
+ export declare function regexReplace<const Value extends ExprLike<"text">, const Pattern extends ExprLike<"text">, const Replacement extends ExprLike<"text">>(value: Value, pattern: Pattern, replacement: Replacement, options?: boolean | {
97
+ readonly ignoreCase?: boolean;
98
+ }): ComposedExpr<"text", [Value, Pattern, Replacement]>;
92
99
  /**
93
100
  * Regex extract — returns the first matching substring (or capture
94
101
  * group) as text. Wire `REGEXEXTRACT(text, pattern)`.
95
102
  */
96
- export declare function regexExtract(value: ExprLike<"text">, pattern: ExprLike<"text">): Expr<"text">;
103
+ export declare function regexExtract<const Value extends ExprLike<"text">, const Pattern extends ExprLike<"text">>(value: Value, pattern: Pattern): ComposedExpr<"text", [Value, Pattern]>;
97
104
  /** Escape a text value for embedding in a JSON string literal. */
98
- export declare function jsonEscape(value: ExprLike<"text">): Expr<"text">;
105
+ export declare function jsonEscape<const Value extends ExprLike<"text">>(value: Value): ComposedExpr<"text", [Value]>;
99
106
  /** Reverse the effect of `jsonEscape` — decode a JSON-escaped string. */
100
- export declare function jsonUnescape(value: ExprLike<"text">): Expr<"text">;
107
+ export declare function jsonUnescape<const Value extends ExprLike<"text">>(value: Value): ComposedExpr<"text", [Value]>;
108
+ /** Repeat text a whole-number count of times. Wire `REPT(text, count)`. */
109
+ export declare function repeat<const Value extends ExprLike<"text">, const Count extends ExprLike<"number">>(value: Value, count: Count): ComposedExpr<"text", [Value, Count]>;
@@ -7,16 +7,14 @@
7
7
  * wire form, and brands the result.
8
8
  *
9
9
  * Type rules baked in:
10
- * - `concat` accepts any expression — the server stringifies non-text
11
- * arguments as part of the concatenation (matches the Java test's
12
- * `CONCAT("Partner", "Closed on")` case where a datetime concatenates
13
- * into a text result).
10
+ * - `concat` accepts the scalar families Knowhere can stringify directly:
11
+ * date, datetime, decimal, number, boolean, and text.
14
12
  * - `len` accepts text only (server rejects numeric).
15
13
  * - `regexMatch` returns bool; the rest return text.
16
14
  * - Argument naming favors readability over wire-form parity
17
15
  * (`needle` / `haystack` for FIND/SEARCH; `pattern` for regex).
18
16
  */
19
- import { coerce, makeExpr } from "./runtime.js";
17
+ import { coerce, expressionContext, makeComposedExpr, makeExpr } from "./runtime.js";
20
18
  // ---------------------------------------------------------------------------
21
19
  // CONCAT / TEXT — assembling text values
22
20
  // ---------------------------------------------------------------------------
@@ -27,7 +25,7 @@ import { coerce, makeExpr } from "./runtime.js";
27
25
  */
28
26
  export function concat(a, b, ...rest) {
29
27
  const exprs = [a, b, ...rest].map((v) => coerce(v));
30
- return makeExpr("text", () => `CONCAT(${exprs.map((e) => e.toCalcString()).join(", ")})`);
28
+ return makeComposedExpr("text", exprs, () => `CONCAT(${exprs.map((e) => e.toCalcString()).join(", ")})`);
31
29
  }
32
30
  /**
33
31
  * Coerce any expression to text. Wire `TEXT(value)`. Useful for
@@ -36,7 +34,7 @@ export function concat(a, b, ...rest) {
36
34
  */
37
35
  export function toText(value) {
38
36
  const e = coerce(value);
39
- return makeExpr("text", () => `TEXT(${e.toCalcString()})`);
37
+ return makeComposedExpr("text", [e], () => `TEXT(${e.toCalcString()})`);
40
38
  }
41
39
  // ---------------------------------------------------------------------------
42
40
  // LEN / TRIM / case
@@ -44,22 +42,22 @@ export function toText(value) {
44
42
  /** Character length of a text expression. Returns NUMBER. */
45
43
  export function len(value) {
46
44
  const e = coerce(value);
47
- return makeExpr("number", () => `LEN(${e.toCalcString()})`);
45
+ return makeComposedExpr("number", [e], () => `LEN(${e.toCalcString()})`);
48
46
  }
49
47
  /** Strip leading/trailing whitespace. */
50
48
  export function trim(value) {
51
49
  const e = coerce(value);
52
- return makeExpr("text", () => `TRIM(${e.toCalcString()})`);
50
+ return makeComposedExpr("text", [e], () => `TRIM(${e.toCalcString()})`);
53
51
  }
54
52
  /** Upper-case. */
55
53
  export function upper(value) {
56
54
  const e = coerce(value);
57
- return makeExpr("text", () => `UPPER(${e.toCalcString()})`);
55
+ return makeComposedExpr("text", [e], () => `UPPER(${e.toCalcString()})`);
58
56
  }
59
57
  /** Lower-case. */
60
58
  export function lower(value) {
61
59
  const e = coerce(value);
62
- return makeExpr("text", () => `LOWER(${e.toCalcString()})`);
60
+ return makeComposedExpr("text", [e], () => `LOWER(${e.toCalcString()})`);
63
61
  }
64
62
  // ---------------------------------------------------------------------------
65
63
  // LEFT / RIGHT / MID — substring helpers
@@ -71,10 +69,10 @@ export function lower(value) {
71
69
  export function left(value, n) {
72
70
  const e = coerce(value);
73
71
  if (n === undefined) {
74
- return makeExpr("text", () => `LEFT(${e.toCalcString()})`);
72
+ return makeComposedExpr("text", [e], () => `LEFT(${e.toCalcString()})`);
75
73
  }
76
74
  const ne = coerce(n);
77
- return makeExpr("text", () => `LEFT(${e.toCalcString()}, ${ne.toCalcString()})`);
75
+ return makeComposedExpr("text", [e, ne], () => `LEFT(${e.toCalcString()}, ${ne.toCalcString()})`);
78
76
  }
79
77
  /**
80
78
  * Rightmost `n` characters of a text expression. `n` defaults to 1 on
@@ -83,10 +81,10 @@ export function left(value, n) {
83
81
  export function right(value, n) {
84
82
  const e = coerce(value);
85
83
  if (n === undefined) {
86
- return makeExpr("text", () => `RIGHT(${e.toCalcString()})`);
84
+ return makeComposedExpr("text", [e], () => `RIGHT(${e.toCalcString()})`);
87
85
  }
88
86
  const ne = coerce(n);
89
- return makeExpr("text", () => `RIGHT(${e.toCalcString()}, ${ne.toCalcString()})`);
87
+ return makeComposedExpr("text", [e, ne], () => `RIGHT(${e.toCalcString()}, ${ne.toCalcString()})`);
90
88
  }
91
89
  /**
92
90
  * Substring from `start` (1-indexed) for `length` characters. Wire
@@ -96,7 +94,7 @@ export function mid(value, start, length) {
96
94
  const e = coerce(value);
97
95
  const se = coerce(start);
98
96
  const le = coerce(length);
99
- return makeExpr("text", () => `MID(${e.toCalcString()}, ${se.toCalcString()}, ${le.toCalcString()})`);
97
+ return makeComposedExpr("text", [e, se, le], () => `MID(${e.toCalcString()}, ${se.toCalcString()}, ${le.toCalcString()})`);
100
98
  }
101
99
  /**
102
100
  * Replace every occurrence of `find` with `replace` in `value`. Wire
@@ -107,7 +105,7 @@ export function substitute(value, find, replace) {
107
105
  const v = coerce(value);
108
106
  const f = coerce(find);
109
107
  const r = coerce(replace);
110
- return makeExpr("text", () => `SUBSTITUTE(${v.toCalcString()}, ${f.toCalcString()}, ${r.toCalcString()})`);
108
+ return makeComposedExpr("text", [v, f, r], () => `SUBSTITUTE(${v.toCalcString()}, ${f.toCalcString()}, ${r.toCalcString()})`);
111
109
  }
112
110
  // ---------------------------------------------------------------------------
113
111
  // FIND / SEARCH — substring location
@@ -121,10 +119,10 @@ export function find(needle, haystack, start) {
121
119
  const n = coerce(needle);
122
120
  const h = coerce(haystack);
123
121
  if (start === undefined) {
124
- return makeExpr("number", () => `FIND(${n.toCalcString()}, ${h.toCalcString()})`);
122
+ return makeComposedExpr("number", [n, h], () => `FIND(${n.toCalcString()}, ${h.toCalcString()})`);
125
123
  }
126
124
  const s = coerce(start);
127
- return makeExpr("number", () => `FIND(${n.toCalcString()}, ${h.toCalcString()}, ${s.toCalcString()})`);
125
+ return makeComposedExpr("number", [n, h, s], () => `FIND(${n.toCalcString()}, ${h.toCalcString()}, ${s.toCalcString()})`);
128
126
  }
129
127
  /**
130
128
  * Case-INsensitive variant of `find`. Wire: `SEARCH(...)`.
@@ -133,10 +131,10 @@ export function search(needle, haystack, start) {
133
131
  const n = coerce(needle);
134
132
  const h = coerce(haystack);
135
133
  if (start === undefined) {
136
- return makeExpr("number", () => `SEARCH(${n.toCalcString()}, ${h.toCalcString()})`);
134
+ return makeComposedExpr("number", [n, h], () => `SEARCH(${n.toCalcString()}, ${h.toCalcString()})`);
137
135
  }
138
136
  const s = coerce(start);
139
- return makeExpr("number", () => `SEARCH(${n.toCalcString()}, ${h.toCalcString()}, ${s.toCalcString()})`);
137
+ return makeComposedExpr("number", [n, h, s], () => `SEARCH(${n.toCalcString()}, ${h.toCalcString()}, ${s.toCalcString()})`);
140
138
  }
141
139
  // ---------------------------------------------------------------------------
142
140
  // SPLIT
@@ -149,11 +147,17 @@ export function search(needle, haystack, start) {
149
147
  * JS keyword `split` in `calc.split` — `splitText` reads cleanly in
150
148
  * the calc namespace.
151
149
  */
150
+ /** @deprecated Prefer {@link split}. */
152
151
  export function splitText(value, separator) {
153
152
  const v = coerce(value);
154
153
  const s = coerce(separator);
155
- return makeExpr("text", () => `SPLIT(${v.toCalcString()}, ${s.toCalcString()})`);
154
+ return makeExpr("text", () => `SPLIT(${v.toCalcString()}, ${s.toCalcString()})`, {
155
+ cardinality: "multiple",
156
+ context: expressionContext([v, s]),
157
+ });
156
158
  }
159
+ /** Canonical concise name for the multi-valued SPLIT function. */
160
+ export const split = splitText;
157
161
  // ---------------------------------------------------------------------------
158
162
  // REGEX
159
163
  // ---------------------------------------------------------------------------
@@ -163,26 +167,28 @@ export function splitText(value, separator) {
163
167
  * The `ignoreCase` flag is a bool literal on the wire — TS accepts a
164
168
  * raw boolean here so the agent doesn't have to wrap it.
165
169
  */
166
- export function regexMatch(value, pattern, ignoreCase) {
170
+ export function regexMatch(value, pattern, options) {
167
171
  const v = coerce(value);
168
172
  const p = coerce(pattern);
173
+ const ignoreCase = typeof options === "boolean" ? options : options?.ignoreCase;
169
174
  if (ignoreCase === undefined) {
170
- return makeExpr("bool", () => `REGEXMATCH(${v.toCalcString()}, ${p.toCalcString()})`);
175
+ return makeComposedExpr("bool", [v, p], () => `REGEXMATCH(${v.toCalcString()}, ${p.toCalcString()})`);
171
176
  }
172
- return makeExpr("bool", () => `REGEXMATCH(${v.toCalcString()}, ${p.toCalcString()}, ${ignoreCase ? "TRUE" : "FALSE"})`);
177
+ return makeComposedExpr("bool", [v, p], () => `REGEXMATCH(${v.toCalcString()}, ${p.toCalcString()}, ${ignoreCase ? "TRUE" : "FALSE"})`);
173
178
  }
174
179
  /**
175
180
  * Regex search-and-replace. Wire `REGEXREPLACE(text, pattern, repl)`
176
181
  * or `REGEXREPLACE(text, pattern, repl, TRUE)` for case-insensitive.
177
182
  */
178
- export function regexReplace(value, pattern, replacement, ignoreCase) {
183
+ export function regexReplace(value, pattern, replacement, options) {
179
184
  const v = coerce(value);
180
185
  const p = coerce(pattern);
181
186
  const r = coerce(replacement);
187
+ const ignoreCase = typeof options === "boolean" ? options : options?.ignoreCase;
182
188
  if (ignoreCase === undefined) {
183
- return makeExpr("text", () => `REGEXREPLACE(${v.toCalcString()}, ${p.toCalcString()}, ${r.toCalcString()})`);
189
+ return makeComposedExpr("text", [v, p, r], () => `REGEXREPLACE(${v.toCalcString()}, ${p.toCalcString()}, ${r.toCalcString()})`);
184
190
  }
185
- return makeExpr("text", () => `REGEXREPLACE(${v.toCalcString()}, ${p.toCalcString()}, ${r.toCalcString()}, ${ignoreCase ? "TRUE" : "FALSE"})`);
191
+ return makeComposedExpr("text", [v, p, r], () => `REGEXREPLACE(${v.toCalcString()}, ${p.toCalcString()}, ${r.toCalcString()}, ${ignoreCase ? "TRUE" : "FALSE"})`);
186
192
  }
187
193
  /**
188
194
  * Regex extract — returns the first matching substring (or capture
@@ -191,7 +197,7 @@ export function regexReplace(value, pattern, replacement, ignoreCase) {
191
197
  export function regexExtract(value, pattern) {
192
198
  const v = coerce(value);
193
199
  const p = coerce(pattern);
194
- return makeExpr("text", () => `REGEXEXTRACT(${v.toCalcString()}, ${p.toCalcString()})`);
200
+ return makeComposedExpr("text", [v, p], () => `REGEXEXTRACT(${v.toCalcString()}, ${p.toCalcString()})`);
195
201
  }
196
202
  // ---------------------------------------------------------------------------
197
203
  // JSON escape helpers
@@ -199,10 +205,16 @@ export function regexExtract(value, pattern) {
199
205
  /** Escape a text value for embedding in a JSON string literal. */
200
206
  export function jsonEscape(value) {
201
207
  const e = coerce(value);
202
- return makeExpr("text", () => `JSON_ESCAPE(${e.toCalcString()})`);
208
+ return makeComposedExpr("text", [e], () => `JSON_ESCAPE(${e.toCalcString()})`);
203
209
  }
204
210
  /** Reverse the effect of `jsonEscape` — decode a JSON-escaped string. */
205
211
  export function jsonUnescape(value) {
206
212
  const e = coerce(value);
207
- return makeExpr("text", () => `JSON_UNESCAPE(${e.toCalcString()})`);
213
+ return makeComposedExpr("text", [e], () => `JSON_UNESCAPE(${e.toCalcString()})`);
214
+ }
215
+ /** Repeat text a whole-number count of times. Wire `REPT(text, count)`. */
216
+ export function repeat(value, count) {
217
+ const v = coerce(value);
218
+ const c = coerce(count);
219
+ return makeComposedExpr("text", [v, c], () => `REPT(${v.toCalcString()}, ${c.toCalcString()})`);
208
220
  }
@@ -1,86 +1,41 @@
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. */
2
+ import type { FieldRef } from "../../../catalog/types.js";
23
3
  import type { AppField, AttachmentAppField, BooleanAppField, CalculationExpression, DateAppField, DateTimeAppField, DecimalAppField, FieldScope, GroupAppField, HandleAppField, HtmlAppField, JsonAppField, MultiPicklistAppField, NumberAppField, PicklistAppField, TextAppField, UserAppField } from "../../../core/types/app.js";
24
- /**
25
- * The brands an expression can carry. Mirrors `AspectFieldType` plus
26
- * `decimal` (split from `number` because `/` promotes — see the Java
27
- * test's `Quantity / Threshold → DECIMAL` case) and `uuid` (the
28
- * built-in `UUID()` function's return type).
29
- */
30
- export type ExprType = "number" | "decimal" | "text" | "bool" | "date" | "datetime" | "picklist" | "user" | "group" | "attachment" | "json" | "uuid";
31
- /**
32
- * One node in the calc AST. Extends the `CalculationExpression` brand
33
- * so an `Expr<T>` is assignable directly to a `CalculatedAppField`'s
34
- * `expression` slot. The `__exprType` phantom carries the output type
35
- * the operator/function declared.
36
- */
37
- export interface Expr<T extends ExprType> extends CalculationExpression {
4
+ import type { Ref } from "../../shared/ref.js";
5
+ /** Exact Knowhere/Ultron scalar result families plus UUID's internal type. */
6
+ export type ExprType = "number" | "decimal" | "text" | "handle" | "html" | "bool" | "date" | "datetime" | "picklist" | "multiPicklist" | "user" | "group" | "attachment" | "json" | "uuid";
7
+ export type ExprCardinality = "single" | "multiple";
8
+ export type ExprContext = "standalone" | "record";
9
+ export type CalculationInclude = "auto" | "manual" | "both" | {
10
+ readonly picklist: FieldRef<string, string, "PICKLIST">;
11
+ };
12
+ /** A calculation node's exact result family, cardinality, and context. */
13
+ export interface Expr<T extends ExprType, Cardinality extends ExprCardinality = "single", Context extends ExprContext = "standalone"> extends CalculationExpression {
38
14
  readonly __exprType: T;
15
+ readonly __exprCardinality: Cardinality;
16
+ readonly __exprContext: Context;
39
17
  }
40
- /** Number or decimal. Numeric operators accept either. */
41
- export type NumericExpr = Expr<"number"> | Expr<"decimal">;
42
- /**
43
- * The types `gt`/`lt`/`gte`/`lte` accept. Booleans, picklists, user/
44
- * group/attachment ids, JSON, and UUIDs are not orderable in the calc
45
- * language. `eq` and `ne` widen to any `ExprType` (handled separately).
46
- */
47
- export type ComparableExprType = "number" | "decimal" | "text" | "date" | "datetime";
48
- /**
49
- * Map an `ExprType` to the `AppField` variant(s) whose value is
50
- * assignable as that expression type. Used by `ExprLike<T>` to accept
51
- * field handles in argument position.
52
- *
53
- * Picklist/user/group/attachment fields surface here as their **id**
54
- * brand — text projections require an explicit `calc.label(...)` /
55
- * `calc.email(...)` / `calc.name(...)` call. This is the
56
- * hallucination-control choice: a bare field reference doesn't quietly
57
- * coerce to the server's implicit default sub-select; the author has
58
- * to declare which projection they want.
59
- */
60
- export type AppFieldOfExprType<T extends ExprType, Scope extends FieldScope = FieldScope> = T extends "number" ? NumberAppField<Scope> : T extends "decimal" ? DecimalAppField<Scope> : T extends "text" ? TextAppField<Scope> | HandleAppField<Scope> | HtmlAppField<Scope> : T extends "bool" ? BooleanAppField<Scope> : T extends "date" ? DateAppField<Scope> : T extends "datetime" ? DateTimeAppField<Scope> : T extends "picklist" ? PicklistAppField<Scope> | MultiPicklistAppField<Scope> : T extends "user" ? UserAppField<Scope> : T extends "group" ? GroupAppField<Scope> : T extends "attachment" ? AttachmentAppField<Scope> : T extends "json" ? JsonAppField<Scope> : never;
61
- /**
62
- * Raw TS literals that coerce into the matching `Expr<T>`. Limited to
63
- * the primitive types — `date`, `datetime`, and the reference types
64
- * (picklist/user/group/attachment) require explicit builders so
65
- * intent is unambiguous. A bare `number` literal coerces to
66
- * `Expr<"number"> | Expr<"decimal">` (the builder picks based on
67
- * Number.isInteger at runtime); functions that need a specific
68
- * sub-type use the explicit `calc.num` / `calc.dec` literals.
69
- */
70
- export type LiteralOfExprType<T extends ExprType> = T extends "number" ? number : T extends "decimal" ? number : T extends "text" ? string : T extends "bool" ? boolean : never;
71
- /**
72
- * Argument-position union — every `calc.*` builder accepts these
73
- * shapes interchangeably. Coercion to `Expr<T>` happens at runtime
74
- * inside the builder.
75
- */
76
- export type ExprLike<T extends ExprType> = Expr<T> | AppFieldOfExprType<T> | LiteralOfExprType<T>;
77
- /** Convenience: anything that can be passed where a numeric expr is required. */
18
+ export type AnyExpr = Expr<ExprType, ExprCardinality, ExprContext>;
19
+ export type ScalarExpr<T extends ExprType = ExprType, Context extends ExprContext = ExprContext> = Expr<T, "single", Context>;
20
+ export type NumericExpr<Context extends ExprContext = ExprContext> = Expr<"number", "single", Context> | Expr<"decimal", "single", Context>;
21
+ export type ComparableExprType = "number" | "decimal" | "text" | "handle" | "html" | "date" | "datetime";
22
+ export type AppFieldOfExprType<T extends ExprType, Scope extends FieldScope = FieldScope> = T extends "number" ? NumberAppField<Scope> : T extends "decimal" ? DecimalAppField<Scope> : T extends "text" ? TextAppField<Scope> : T extends "handle" ? HandleAppField<Scope> : T extends "html" ? HtmlAppField<Scope> : T extends "bool" ? BooleanAppField<Scope> : T extends "date" ? DateAppField<Scope> : T extends "datetime" ? DateTimeAppField<Scope> : T extends "picklist" ? PicklistAppField<Scope> : T extends "multiPicklist" ? MultiPicklistAppField<Scope> : T extends "user" ? UserAppField<Scope> : T extends "group" ? GroupAppField<Scope> : T extends "attachment" ? AttachmentAppField<Scope> : T extends "json" ? JsonAppField<Scope> : never;
23
+ type FieldTypeForExprType<T extends ExprType> = T extends "number" ? "NUMBER" : T extends "decimal" ? "DECIMAL" : T extends "text" ? "TEXT" | "RICH_TEXT" : T extends "handle" ? "HANDLE" : T extends "html" ? "HTML" : T extends "bool" ? "BOOLEAN" : T extends "date" ? "DATE" : T extends "datetime" ? "DATETIME" : T extends "picklist" ? "PICKLIST" : T extends "multiPicklist" ? "MULTI_PICKLIST" : T extends "user" ? "USER" | "USER_ID" : T extends "group" ? "GROUP" | "GROUP_ID" : T extends "attachment" ? "ATTACHMENT" | "ATTACHMENT_ID" : T extends "json" ? "JSON" : never;
24
+ export type FieldRefOfExprType<T extends ExprType> = FieldRef<string, string, FieldTypeForExprType<T>>;
25
+ export type FieldRefExprType<F extends FieldRef> = F["fieldType"] extends "NUMBER" ? "number" : F["fieldType"] extends "DECIMAL" ? "decimal" : F["fieldType"] extends "BOOLEAN" ? "bool" : F["fieldType"] extends "DATE" ? "date" : F["fieldType"] extends "DATETIME" ? "datetime" : F["fieldType"] extends "PICKLIST" ? "picklist" : F["fieldType"] extends "MULTI_PICKLIST" ? "multiPicklist" : F["fieldType"] extends "USER" | "USER_ID" ? "user" : F["fieldType"] extends "GROUP" | "GROUP_ID" ? "group" : F["fieldType"] extends "ATTACHMENT" | "ATTACHMENT_ID" ? "attachment" : F["fieldType"] extends "JSON" ? "json" : F["fieldType"] extends "HANDLE" ? "handle" : F["fieldType"] extends "HTML" ? "html" : F["fieldType"] extends "TEXT" | "RICH_TEXT" ? "text" : ExprType;
26
+ export type LiteralOfExprType<T extends ExprType> = T extends "number" | "decimal" ? number : T extends "text" ? string : T extends "bool" ? boolean : never;
27
+ /** Inputs accepted by calc builders, including direct catalog/workflow refs. */
28
+ export type ExprLike<T extends ExprType> = ScalarExpr<T> | AppFieldOfExprType<T> | FieldRefOfExprType<T> | Ref<unknown, T> | LiteralOfExprType<T>;
78
29
  export type NumericLike = ExprLike<"number"> | ExprLike<"decimal">;
79
- /** Convenience: anything that can be passed where a boolean expr is required. */
80
30
  export type BoolLike = ExprLike<"bool">;
81
- /**
82
- * Compile-time helper: narrow an `AppField` to its `ExprType` brand.
83
- * Used internally by `coerce()` so the runtime branch picks the right
84
- * factory based on the field's `type` discriminator.
85
- */
86
- export type AppFieldExprType<F extends AppField<FieldScope>> = F extends NumberAppField<FieldScope> ? "number" : F extends DecimalAppField<FieldScope> ? "decimal" : F extends TextAppField<FieldScope> | HandleAppField<FieldScope> | HtmlAppField<FieldScope> ? "text" : F extends BooleanAppField<FieldScope> ? "bool" : F extends DateAppField<FieldScope> ? "date" : F extends DateTimeAppField<FieldScope> ? "datetime" : F extends PicklistAppField<FieldScope> | MultiPicklistAppField<FieldScope> ? "picklist" : F extends UserAppField<FieldScope> ? "user" : F extends GroupAppField<FieldScope> ? "group" : F extends AttachmentAppField<FieldScope> ? "attachment" : F extends JsonAppField<FieldScope> ? "json" : never;
31
+ export type AppFieldExprType<F extends AppField<FieldScope>> = F extends NumberAppField<FieldScope> ? "number" : F extends DecimalAppField<FieldScope> ? "decimal" : F extends TextAppField<FieldScope> ? "text" : F extends HandleAppField<FieldScope> ? "handle" : F extends HtmlAppField<FieldScope> ? "html" : F extends BooleanAppField<FieldScope> ? "bool" : F extends DateAppField<FieldScope> ? "date" : F extends DateTimeAppField<FieldScope> ? "datetime" : F extends PicklistAppField<FieldScope> ? "picklist" : F extends MultiPicklistAppField<FieldScope> ? "multiPicklist" : F extends UserAppField<FieldScope> ? "user" : F extends GroupAppField<FieldScope> ? "group" : F extends AttachmentAppField<FieldScope> ? "attachment" : F extends JsonAppField<FieldScope> ? "json" : never;
32
+ export type ExprTypeOf<Value> = Value extends Expr<infer T, ExprCardinality, ExprContext> ? T : Value extends FieldRef ? FieldRefExprType<Value> : Value extends Ref<unknown, infer T extends ExprType> ? T : Value extends AppField<FieldScope> ? AppFieldExprType<Value> : Value extends boolean ? "bool" : Value extends string ? "text" : Value extends number ? NumberLiteralExprType<Value> : never;
33
+ export type ExprContextOf<Value> = Value extends Expr<ExprType, ExprCardinality, infer Context> ? Context : Value extends FieldRef | AppField<FieldScope> ? "record" : "standalone";
34
+ export type MergeContext<A extends ExprContext, B extends ExprContext> = "record" extends A | B ? "record" : "standalone";
35
+ export type ContextOfValues<Values extends readonly unknown[]> = Values extends readonly [infer Head, ...infer Rest] ? MergeContext<ExprContextOf<Head>, ContextOfValues<Rest>> : "standalone";
36
+ export type ComposedExpr<T extends ExprType, Values extends readonly unknown[], Cardinality extends ExprCardinality = "single"> = Expr<T, Cardinality, ContextOfValues<Values>>;
37
+ export type NumberLiteralExprType<N extends number> = number extends N ? "number" | "decimal" : `${N}` extends `${string}.${string}` ? "decimal" : "number";
38
+ export type NumericExprTypeOf<Value> = Extract<ExprTypeOf<Value>, "number" | "decimal">;
39
+ export type NumericPromotion<A, B> = "decimal" extends NumericExprTypeOf<A> | NumericExprTypeOf<B> ? "decimal" : "number";
40
+ export type DateMathPromotion<A, B> = ExprTypeOf<A> extends "datetime" ? "datetime" : ExprTypeOf<A> extends "date" ? "decimal" extends NumericExprTypeOf<B> ? "datetime" : "date" : NumericPromotion<A, B>;
41
+ export {};