@elementumai/edk 0.9.2 → 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 (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,41 +1,42 @@
1
1
  /**
2
- * v2 automation authoring — an options-shaped `defineAutomation` whose workflow
3
- * body is a typed, chainable `defineWorkflow()`:
2
+ * Automation authoring — an options-shaped `automation` whose body is a
3
+ * typed, chainable `actions()`:
4
4
  *
5
- * defineAutomation({
5
+ * automation({
6
6
  * name: "Escalate",
7
7
  * app: catalog.incidents,
8
- * workflowRevision: "1.0.0",
9
- * status: "DRAFT",
10
- * workflow: defineWorkflow()
8
+ * revision: "1.0.0",
9
+ * status: automationStatus.draft,
10
+ * actions: actions()
11
11
  * .trigger(recordCreated({ app }))
12
- * .task("search", (ctx) => recordSearch({ app, filter: ... }))
13
- * .task("notify", (ctx) => sendEmail({ to: "...", body: ctx.tasks.search.totalCount }))
14
- * .outputs((ctx) => ({ found: ctx.tasks.search.totalCount })), // optional
12
+ * .recordSearch("search", { app, filter: ... })
13
+ * .sendEmail("notify", (ctx) => ({ toAddresses: ["..."], body: ctx.actions.search.totalCount }))
14
+ * .outputs((ctx) => ({ found: ctx.actions.search.totalCount })), // optional
15
15
  * }) // → AutomationConfigured
16
16
  *
17
- * `defineAutomation` is **not** chained — it takes an options object and returns
17
+ * `automation` is **not** chained — it takes an options object and returns
18
18
  * an `AutomationConfigured` with `.ref(refName)` and `.def(refName)`. The chaining
19
- * lives on the `workflow` field, built by `defineWorkflow()`: set a trigger, chain
20
- * `.task(...)`, optionally close with `.outputs(...)`. Assign the chain straight to
21
- * `workflow:` — no terminal `.build()` call.
19
+ * lives on the `actions` field, built by `actions()`: set a trigger,
20
+ * chain direct action methods, and optionally close with `.outputs()`.
22
21
  *
23
- * The typed `ctx` (compile-time-safe `ctx.trigger.x` / `ctx.tasks.y.output`)
22
+ * The typed `ctx` (compile-time-safe `ctx.trigger.x` / `ctx.actions.y.output`)
24
23
  * comes from the **shared core engine** (`core/context` + `core/ref`), which is
25
24
  * reference-model-agnostic — it only models data flow *inside* the automation.
26
25
  * Cross-entity references are `CatalogRef` tokens, resolved at deploy.
27
26
  */
28
27
  import { randomUUID } from "crypto";
29
28
  import { valid as validSemver } from "semver";
30
- import { buildContext } from "../shared/context.js";
31
- import { isRef } from "../shared/ref.js";
32
29
  import { EntityTfError } from "../../engine/entity.js";
33
- import { serializeNode } from "./serialize.js";
34
- import { extractScriptBody, inferOutputSchema, tryExtractFromCurrentSource } from "./script-code.js";
30
+ import { buildContext, createForEachItemProxy } from "../shared/context.js";
31
+ import { isRef } from "../shared/ref.js";
35
32
  import { OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
36
- // Runtime import of the Phase-1 factories the fluent methods sugar over.
37
- // tasks.ts's own import of build.ts is type-only, so there is no runtime cycle.
38
- import { executeScriptTaskDefWithBody, setVariable as setVariableTask } from "./tasks.js";
33
+ import { extractScriptBody, inferOutputSchema, tryExtractFromCurrentSource } from "./script-code.js";
34
+ import { serializeNode } from "./serialize.js";
35
+ // Runtime factory imports stay below the public action-native surface. Their
36
+ // ActionDef return values are an internal serialization detail; authored
37
+ // automations call the direct fluent methods declared on ActionBuilder.
38
+ import * as operatorFactories from "./operators.js";
39
+ import * as actionFactories from "./tasks.js";
39
40
  /** Placeholder `forEachTaskRefKey` the forEach item proxy emits; replaced with the real refKey. */
40
41
  export const FOR_EACH_PLACEHOLDER = "__forEach__";
41
42
  /**
@@ -86,7 +87,7 @@ function replaceForEachPlaceholder(node, refKey) {
86
87
  }
87
88
  }
88
89
  /**
89
- * Map every task's refKey (its `.task(name, …)` name) to its factory key,
90
+ * Map every action's refKey (its fluent method name argument) to its wire key,
90
91
  * descending into operator children — the forward mirror of the deserializer's
91
92
  * `taskTypeByRefKey`. Used to resolve the type of the task a `taskReference`
92
93
  * points at so output-name rewrites apply only to the right task kind.
@@ -133,6 +134,8 @@ const RECORD_BEARING_TASK_KEYS = new Set(["recordSearch", "createRecord", "findR
133
134
  * normalization (`applyOutputNameInverseRewrites` in
134
135
  * `materialize/ref-deserializer.ts` — keep the two in sync):
135
136
  * - recordSearch: `totalCount` → the platform's `Records Size`.
137
+ * - aiSearchTable: `records` → the platform's `All Records` (NOT
138
+ * recordSearch's `All found records` — #398.1).
136
139
  * - aiAgent: `result` / `result.<field>` → the platform's
137
140
  * `ai_agent_task_response` (text) / `ai_agent_task_structured_output.<field>` (json).
138
141
  * - record-bearing tasks: the read path reinjects a `.record` hop on the id
@@ -150,6 +153,9 @@ function rewriteForwardTaskRefName(taskKey, name) {
150
153
  if (taskKey === "recordSearch" && name === "totalCount") {
151
154
  return "Records Size";
152
155
  }
156
+ if (taskKey === "aiSearchTable" && name === "records") {
157
+ return "All Records";
158
+ }
153
159
  if (taskKey === "aiAgent") {
154
160
  const segs = name.split(".");
155
161
  if (segs[0] !== "result")
@@ -234,7 +240,7 @@ function stampAndCollectVariableIds(tasks) {
234
240
  * Replace every `{ __variableParamRef: { variableTaskRefKey, name } }` marker
235
241
  * in the serialized tree with `{ variableReference: { id, name: "variable|<id>" } }`.
236
242
  * Throws when a referenced variable isn't in `idMap` — the variable must be
237
- * created by a `setVariable` task in the same workflow.
243
+ * created by a `setVariable` action in the same automation.
238
244
  */
239
245
  function resolveVariableParamMarkers(node, idMap) {
240
246
  if (node === null || typeof node !== "object")
@@ -250,8 +256,8 @@ function resolveVariableParamMarkers(node, idMap) {
250
256
  const key = `${marker.variableTaskRefKey}::${marker.name}`;
251
257
  const id = idMap.get(key);
252
258
  if (!id) {
253
- throw new Error(`Variable "${marker.name}" not found on task "${marker.variableTaskRefKey}". ` +
254
- `Check that a setVariable task with that refKey creates a variable with that name.`);
259
+ throw new Error(`Variable "${marker.name}" not found on action "${marker.variableTaskRefKey}". ` +
260
+ `Check that a setVariable action with that refKey creates a variable with that name.`);
255
261
  }
256
262
  delete o.__variableParamRef;
257
263
  o.variableReference = { id, name: `variable|${id}` };
@@ -263,26 +269,56 @@ function resolveVariableParamMarkers(node, idMap) {
263
269
  function serializeOutputValue(value) {
264
270
  return isRef(value) ? serializeNode(value) : { value };
265
271
  }
266
- function makeWorkflowBuilder(state) {
267
- const appendTask = (name, def, displayName, hclParent) => makeWorkflowBuilder({ ...state, tasks: [...state.tasks, { name, def, displayName, hclParent }] });
272
+ function makeActionBuilder(state, mode = "root", item) {
273
+ const appendAction = (name, def, displayName, hclParent) => makeActionBuilder({ ...state, tasks: [...state.tasks, { name, def, displayName, hclParent }] }, mode, item);
274
+ const context = () => {
275
+ const base = buildContext(state.tasks.map((entry) => entry.name));
276
+ return (item === undefined ? base : { ...base, item });
277
+ };
278
+ const resolveOptions = (value) => typeof value === "function" ? value(context()) : value;
279
+ const materializeNested = (callback, childItem) => callback(makeActionBuilder({ trigger: state.trigger, tasks: [] }, "nested", childItem)).__children();
280
+ const leafFactories = {
281
+ recordSearch: actionFactories.recordSearch,
282
+ tableRecordsSearch: actionFactories.tableRecordsSearch,
283
+ createRecord: actionFactories.createRecord,
284
+ updateField: actionFactories.updateField,
285
+ findRelatedRecords: actionFactories.findRelatedRecords,
286
+ relateRecords: actionFactories.relateRecords,
287
+ sendEmail: actionFactories.sendEmail,
288
+ postComment: actionFactories.postComment,
289
+ notification: actionFactories.notification,
290
+ aiAgent: actionFactories.aiAgent,
291
+ aiClassify: actionFactories.aiClassify,
292
+ aiSummarize: actionFactories.aiSummarize,
293
+ aiTransform: actionFactories.aiTransform,
294
+ aiSearchTable: actionFactories.aiSearchTable,
295
+ aiFileAnalysis: actionFactories.aiFileAnalysis,
296
+ apiRequest: actionFactories.apiRequest,
297
+ calculation: actionFactories.calculation,
298
+ procedure: actionFactories.procedure,
299
+ runAutomation: actionFactories.runAutomation,
300
+ readFile: actionFactories.readFile,
301
+ approvalChain: actionFactories.approvalChain,
302
+ approvalStatusUpdate: actionFactories.approvalStatusUpdate,
303
+ addWatcher: actionFactories.addWatcher,
304
+ saveAttachment: actionFactories.saveAttachment,
305
+ userSearch: actionFactories.userSearch,
306
+ initiateCall: actionFactories.initiateCall,
307
+ recordFieldLocking: actionFactories.recordFieldLocking,
308
+ };
309
+ const directMethods = Object.fromEntries(Object.entries(leafFactories).map(([method, factory]) => [
310
+ method,
311
+ (name, opts, displayName, hclParent) => appendAction(name, factory(resolveOptions(opts)), displayName, hclParent),
312
+ ]));
268
313
  const builder = {
269
- task(name, fn, displayName, hclParent) {
270
- const ctx = buildContext(state.tasks.map((t) => t.name));
271
- const def = fn(ctx);
272
- if (def.key === "executeScript") {
273
- throw new Error(`Use .executeScript(${JSON.stringify(name)}, { inputs, code }) instead of ` +
274
- `.task(${JSON.stringify(name)}, () => executeScript(...)). ` +
275
- `Nested operator bodies still use childTask(..., executeScript({ code: (input) => ... })).`);
276
- }
277
- return appendTask(name, def, displayName, hclParent);
278
- },
279
- executeScript(name, opts) {
314
+ ...directMethods,
315
+ executeScript(name, opts, displayName, hclParent) {
280
316
  // Resolve the body BYTE-EXACT from the automation file's own
281
317
  // untranspiled source when running under `elementum build`
282
318
  // (tryExtractFromCurrentSource); fall back to the toString()-based
283
319
  // extractScriptBody otherwise (e.g. an automation built directly in a
284
320
  // test, with no tracked source file). Either way the body is computed
285
- // exactly ONCE here and threaded straight into the TaskDef — no
321
+ // exactly ONCE here and threaded straight into the ActionDef — no
286
322
  // separate re-extraction downstream.
287
323
  // Explicit `outputs` always wins; an explicit `null` means "no schema"
288
324
  // and suppresses inference (pulled sources with no platform
@@ -290,28 +326,78 @@ function makeWorkflowBuilder(state) {
290
326
  // drift); omitting `outputs` entirely infers from the body.
291
327
  const body = tryExtractFromCurrentSource(name) ?? extractScriptBody(opts.code);
292
328
  const outputs = opts.outputs === undefined ? inferOutputSchema(body) : (opts.outputs ?? undefined);
293
- const ctx = buildContext(state.tasks.map((t) => t.name));
294
- const def = executeScriptTaskDefWithBody(body, {
295
- ...(opts.inputs !== undefined ? { inputs: opts.inputs(ctx) } : {}),
329
+ const def = actionFactories.executeScriptActionDefWithBody(body, {
330
+ ...(opts.inputs !== undefined ? { inputs: opts.inputs(context()) } : {}),
296
331
  ...(outputs !== undefined ? { outputs } : {}),
297
332
  });
298
- return appendTask(name, def);
333
+ return appendAction(name, def, displayName, hclParent);
334
+ },
335
+ setVariable(name, opts, displayName, hclParent) {
336
+ const resolved = resolveOptions(opts);
337
+ const ergonomic = resolved;
338
+ const def = typeof ergonomic.value === "function"
339
+ ? actionFactories.setVariable({
340
+ create: [{ name, type: ergonomic.type ?? "TEXT", value: ergonomic.value(context()) }],
341
+ })
342
+ : actionFactories.setVariable(resolved);
343
+ return appendAction(name, def, displayName, hclParent);
344
+ },
345
+ forEach(name, opts, displayName, hclParent) {
346
+ const authored = opts;
347
+ const childItem = createForEachItemProxy(FOR_EACH_PLACEHOLDER);
348
+ const children = materializeNested(authored.actions, childItem);
349
+ const def = operatorFactories.forEach(context(), {
350
+ collection: typeof authored.collection === "function" ? authored.collection(context()) : authored.collection,
351
+ actions: () => children,
352
+ });
353
+ return appendAction(name, def, displayName, hclParent);
299
354
  },
300
- setVariable(name, opts) {
301
- const ctx = buildContext(state.tasks.map((t) => t.name));
302
- const def = setVariableTask({
303
- create: [{ name, type: opts.type ?? "TEXT", value: opts.value(ctx) }],
355
+ switch(name, opts, displayName, hclParent) {
356
+ const authored = resolveOptions(opts);
357
+ const authoredDefault = authored.defaultActions;
358
+ const defaultActions = authoredDefault === undefined
359
+ ? undefined
360
+ : typeof authoredDefault === "function"
361
+ ? () => materializeNested(authoredDefault, item)
362
+ : {
363
+ ...authoredDefault,
364
+ actions: () => materializeNested(authoredDefault.actions, item),
365
+ };
366
+ const def = operatorFactories.switchAction(context(), {
367
+ cases: authored.cases.map((branch) => ({
368
+ label: branch.label,
369
+ ...(branch.condition !== undefined ? { condition: branch.condition } : {}),
370
+ actions: () => materializeNested(branch.actions, item),
371
+ })),
372
+ ...(defaultActions !== undefined ? { defaultActions } : {}),
304
373
  });
305
- return appendTask(name, def);
374
+ return appendAction(name, def, displayName, hclParent);
375
+ },
376
+ forkJoin(name, opts, displayName, hclParent) {
377
+ const authored = resolveOptions(opts);
378
+ const def = operatorFactories.forkJoin(context(), {
379
+ branches: authored.branches.map((branch) => ({
380
+ label: branch.label,
381
+ actions: () => materializeNested(branch.actions, item),
382
+ })),
383
+ });
384
+ return appendAction(name, def, displayName, hclParent);
306
385
  },
307
386
  outputs(fn) {
308
- const ctx = buildContext(state.tasks.map((t) => t.name));
309
- const map = fn(ctx);
387
+ const map = fn(context());
310
388
  const outputs = Object.entries(map).map(([name, value]) => ({
311
389
  name,
312
390
  value: serializeOutputValue(value),
313
391
  }));
314
- return makeWorkflowBuilder({ ...state, outputs });
392
+ return makeActionBuilder({ ...state, outputs }, mode, item);
393
+ },
394
+ __children() {
395
+ return state.tasks.map((entry) => ({
396
+ name: entry.name,
397
+ def: entry.def,
398
+ ...(entry.displayName !== undefined ? { displayName: entry.displayName } : {}),
399
+ ...(entry.hclParent !== undefined ? { hclParent: entry.hclParent } : {}),
400
+ }));
315
401
  },
316
402
  __triggerParams() {
317
403
  return state.trigger.__params ?? [];
@@ -358,34 +444,39 @@ function makeWorkflowBuilder(state) {
358
444
  }
359
445
  /** Wrap a TriggerDef so it doubles as the chain start. Used by the trigger factories. */
360
446
  export function chainableTrigger(trigger) {
361
- return { ...trigger, ...makeWorkflowBuilder({ trigger, tasks: [] }) };
447
+ return { ...trigger, ...makeActionBuilder({ trigger, tasks: [] }) };
362
448
  }
363
449
  /**
364
- * Begin a workflow body. Set a trigger, chain `.task(...)`, optionally close
365
- * with `.outputs(...)`, then assign the result to `defineAutomation`'s
366
- * `workflow:` field — no terminal `.build()`.
450
+ * Begin an automation body. Set a trigger, chain direct action methods,
451
+ * optionally close with `.outputs()`, then assign it to `actions:`.
367
452
  */
368
- export function defineWorkflow() {
453
+ export function actions() {
369
454
  return {
370
455
  trigger(trigger) {
371
- return makeWorkflowBuilder({ trigger, tasks: [] });
456
+ return makeActionBuilder({ trigger, tasks: [] });
372
457
  },
373
458
  };
374
459
  }
460
+ /** User-authorable automation lifecycle states. */
461
+ export const automationStatus = {
462
+ draft: "DRAFT",
463
+ inactive: "INACTIVE",
464
+ active: "ACTIVE",
465
+ };
375
466
  /**
376
467
  * Define a v2 automation. Identity comes from the authoring file's `refName`
377
468
  * plus the typed `app` reference; the display `name` lives only in the payload, so renaming an
378
469
  * automation plans as an update rather than a create. Returns an
379
470
  * `AutomationConfigured` with `ref(refName)` and `def(refName)`.
380
471
  */
381
- export function defineAutomation(opts) {
382
- if (validSemver(opts.workflowRevision) === null) {
383
- throw new EntityTfError(`automation "${opts.name}" has invalid workflowRevision ${JSON.stringify(opts.workflowRevision)}; expected a SemVer string such as "1.0.0"`);
472
+ export function automation(opts) {
473
+ if (validSemver(opts.revision) === null) {
474
+ throw new EntityTfError(`automation "${opts.name}" has invalid revision ${JSON.stringify(opts.revision)}; expected a SemVer string such as "1.0.0"`);
384
475
  }
385
476
  return {
386
477
  ref(refName) {
387
- const triggerParams = opts.workflow.__triggerParams();
388
- const outputNames = opts.workflow.__outputNames();
478
+ const triggerParams = opts.actions.__triggerParams();
479
+ const outputNames = opts.actions.__outputNames();
389
480
  // Bag keys are the DECLARED names, verbatim (no canonicalization —
390
481
  // access non-identifier names with brackets: trigger["STUDENT NAME 2"]).
391
482
  // `required: true` is stamped only when true (canonical form) — it is
@@ -415,7 +506,7 @@ export function defineAutomation(opts) {
415
506
  };
416
507
  },
417
508
  def(refName) {
418
- const wf = opts.workflow.__finalize();
509
+ const sequence = opts.actions.__finalize();
419
510
  // `recordFieldContext` is a structural extension, not a declared `DeployableEntity`
420
511
  // property (see `RecordFieldContext`'s doc comment) — assigning to `entity`
421
512
  // first (rather than returning the literal directly) avoids an excess-property
@@ -427,17 +518,17 @@ export function defineAutomation(opts) {
427
518
  refName,
428
519
  payload: {
429
520
  name: opts.name,
430
- workflowRevision: opts.workflowRevision,
521
+ workflowRevision: opts.revision,
431
522
  ...(opts.description !== undefined ? { description: opts.description } : {}),
432
523
  triggersOtherAutomations: opts.triggersOtherAutomations ?? false,
433
524
  status: opts.status ?? "DRAFT",
434
525
  ...(opts.serviceAccount !== undefined ? { serviceAccount: opts.serviceAccount } : {}),
435
- trigger: wf.trigger,
436
- tasks: wf.tasks,
437
- ...(wf.outputProperties ? { outputProperties: wf.outputProperties } : {}),
526
+ trigger: sequence.trigger,
527
+ tasks: sequence.tasks,
528
+ ...(sequence.outputProperties ? { outputProperties: sequence.outputProperties } : {}),
438
529
  },
439
530
  ...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
440
- ...(wf.recordFieldContext !== undefined ? { recordFieldContext: wf.recordFieldContext } : {}),
531
+ ...(sequence.recordFieldContext !== undefined ? { recordFieldContext: sequence.recordFieldContext } : {}),
441
532
  };
442
533
  return entity;
443
534
  },
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Automation calculation expressions.
3
+ *
4
+ * The core calc grammar is shared with calculated fields. Typed workflow refs
5
+ * are accepted directly and rendered as template parameters while preserving
6
+ * their calculation brands. `calc.param(ref)` remains only as an explicit
7
+ * compatibility or disambiguation helper. Mobius validates the formula and
8
+ * remains authoritative for the stored type.
9
+ */
10
+ import type { Ref } from "../shared/ref.js";
11
+ import type { Expr, ExprCardinality, ExprContext, ExprType } from "../field/calc/types.js";
12
+ type ParameterValue = string | number | boolean;
13
+ /** Discoverable calculation brands accepted by calc.param's type option. */
14
+ export declare const calculationParameterType: {
15
+ readonly number: "number";
16
+ readonly decimal: "decimal";
17
+ readonly boolean: "bool";
18
+ readonly text: "text";
19
+ readonly date: "date";
20
+ readonly datetime: "datetime";
21
+ readonly picklist: "picklist";
22
+ readonly user: "user";
23
+ readonly group: "group";
24
+ readonly attachment: "attachment";
25
+ readonly multiPicklist: "multiPicklist";
26
+ readonly handle: "handle";
27
+ readonly html: "html";
28
+ readonly json: "json";
29
+ };
30
+ export type CalculationParameterExprType = (typeof calculationParameterType)[keyof typeof calculationParameterType];
31
+ type ParameterValueForExprType<T extends CalculationParameterExprType> = T extends "number" | "decimal" ? number : T extends "bool" ? boolean : T extends "text" | "date" | "datetime" | "picklist" | "user" | "group" | "attachment" | "handle" | "html" ? string : T extends "multiPicklist" ? readonly string[] : T extends "json" ? JsonValue : unknown;
32
+ /**
33
+ * Explicit calculation type for workflow refs whose TypeScript value shape is
34
+ * ambiguous. DATE, DATETIME, and TEXT all arrive as `Ref<string>`; reference
35
+ * fields can likewise need their product type stated for projection helpers.
36
+ * The option affects static typing only—the backend still derives and validates
37
+ * the real parameter type from the referenced workflow value.
38
+ */
39
+ export interface CalculationParameterOptions<T extends CalculationParameterExprType = CalculationParameterExprType> {
40
+ readonly type: T;
41
+ }
42
+ /** Map a statically-known workflow value to its calculation expression brand. */
43
+ export type ParameterExprType<T> = T extends number ? "number" : T extends boolean ? "bool" : T extends string ? "text" : never;
44
+ export interface RenderedCalculationExpression {
45
+ readonly text: string;
46
+ readonly parameters: readonly {
47
+ readonly name: string;
48
+ readonly value: Ref<unknown, string>;
49
+ }[];
50
+ }
51
+ /**
52
+ * Use a trigger, task, or variable ref as a typed calculation parameter.
53
+ *
54
+ * Compatibility example: calc.plus(calc.param(ctx.trigger.record.quantity), 1)
55
+ * @deprecated Pass typed workflow refs directly; retain this helper only for
56
+ * disambiguation or compatibility with refs lacking calculation metadata.
57
+ */
58
+ export declare function param<T, C extends CalculationParameterExprType>(value: Ref<T, C>): Expr<C>;
59
+ export declare function param<T extends ParameterValue>(value: Ref<T>): Expr<ParameterExprType<T>>;
60
+ export declare function param<T extends CalculationParameterExprType>(value: Ref<ParameterValueForExprType<T>>, options: CalculationParameterOptions<T>): Expr<T>;
61
+ /**
62
+ * Render an Expr while collecting workflow refs as Mobius template parameters.
63
+ * Rendering is synchronous, so the collector is restored in the same stack
64
+ * frame and cannot leak into another authored task.
65
+ */
66
+ export declare function renderCalculationExpression(expression: Expr<ExprType, ExprCardinality, ExprContext>): RenderedCalculationExpression;
67
+ /** Knowhere calculated grammar plus workflow-value parameters. */
68
+ export declare const calc: {
69
+ readonly param: typeof param;
70
+ readonly field: typeof import("../field/calc.js").field;
71
+ readonly num: (value: number) => Expr<"number">;
72
+ readonly dec: (value: number) => Expr<"decimal">;
73
+ readonly text: (value: string) => Expr<"text">;
74
+ readonly bool: (value: boolean) => Expr<"bool">;
75
+ readonly blank: {
76
+ <T extends ExprType>(type: T): Expr<T>;
77
+ <T extends ExprType>(): Expr<T>;
78
+ };
79
+ readonly raw: <T extends ExprType>(formula: string, resultType: T) => Expr<T>;
80
+ readonly 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("../field/calc/types.js").ExprLike<Parameters[Index]> : never; }) => Expr<Result, "single", "record">;
81
+ readonly plus: <const A extends import("../field/calc/types.js").NumericLike | import("../field/calc/types.js").ExprLike<"date"> | import("../field/calc/types.js").ExprLike<"datetime">, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B) => import("../field/calc/types.js").ComposedExpr<import("../field/calc/types.js").DateMathPromotion<A, B>, [A, B]>;
82
+ readonly minus: <const A extends import("../field/calc/types.js").NumericLike | import("../field/calc/types.js").ExprLike<"date"> | import("../field/calc/types.js").ExprLike<"datetime">, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B) => import("../field/calc/types.js").ComposedExpr<import("../field/calc/types.js").DateMathPromotion<A, B>, [A, B]>;
83
+ readonly times: <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B) => import("../field/calc/types.js").ComposedExpr<import("../field/calc/types.js").NumericPromotion<A, B>, [A, B]>;
84
+ readonly dividedBy: <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B) => import("../field/calc/types.js").ComposedExpr<"decimal", [A, B]>;
85
+ readonly gt: {
86
+ <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
87
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("../field/calc/types.js").ExprLike<T>, const B extends import("../field/calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
88
+ };
89
+ readonly lt: {
90
+ <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
91
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("../field/calc/types.js").ExprLike<T>, const B extends import("../field/calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
92
+ };
93
+ readonly gte: {
94
+ <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
95
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("../field/calc/types.js").ExprLike<T>, const B extends import("../field/calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
96
+ };
97
+ readonly lte: {
98
+ <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
99
+ <T extends "date" | "datetime" | "handle" | "text" | "html", const A extends import("../field/calc/types.js").ExprLike<T>, const B extends import("../field/calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
100
+ };
101
+ readonly eq: {
102
+ <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
103
+ <T extends "group" | "bool" | "date" | "datetime" | "handle" | "json" | "text" | "user" | "html" | "attachment" | "picklist" | "multiPicklist" | "uuid", const A extends import("../field/calc/types.js").ExprLike<T>, const B extends import("../field/calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
104
+ };
105
+ readonly ne: {
106
+ <const A extends import("../field/calc/types.js").NumericLike, const B extends import("../field/calc/types.js").NumericLike>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
107
+ <T extends "group" | "bool" | "date" | "datetime" | "handle" | "json" | "text" | "user" | "html" | "attachment" | "picklist" | "multiPicklist" | "uuid", const A extends import("../field/calc/types.js").ExprLike<T>, const B extends import("../field/calc/types.js").ExprLike<NoInfer<T>>>(a: A, b: B): import("../field/calc/types.js").ComposedExpr<"bool", [A, B]>;
108
+ };
109
+ readonly and: <const A extends import("../field/calc/types.js").BoolLike, const B extends import("../field/calc/types.js").BoolLike, const Rest extends readonly import("../field/calc/types.js").BoolLike[]>(a: A, b: B, ...rest: Rest) => import("../field/calc/types.js").ComposedExpr<"bool", [A, B, ...Rest]>;
110
+ readonly or: <const A extends import("../field/calc/types.js").BoolLike, const B extends import("../field/calc/types.js").BoolLike, const Rest extends readonly import("../field/calc/types.js").BoolLike[]>(a: A, b: B, ...rest: Rest) => import("../field/calc/types.js").ComposedExpr<"bool", [A, B, ...Rest]>;
111
+ readonly if: {
112
+ <const Condition extends import("../field/calc/types.js").BoolLike, const Then extends import("../field/calc/types.js").NumericLike, const Else extends import("../field/calc/types.js").NumericLike>(cond: Condition, thenArm: Then, elseArm: Else): import("../field/calc/types.js").ComposedExpr<import("../field/calc/types.js").NumericPromotion<Then, Else>, [Condition, Then, Else]>;
113
+ <T extends "group" | "bool" | "date" | "datetime" | "handle" | "json" | "text" | "user" | "html" | "attachment" | "picklist" | "multiPicklist" | "uuid", const Condition extends import("../field/calc/types.js").BoolLike, const Then extends import("../field/calc/types.js").ExprLike<T>, const Else extends import("../field/calc/types.js").ExprLike<NoInfer<T>>>(cond: Condition, thenArm: Then, elseArm: Else): import("../field/calc/types.js").ComposedExpr<T, [Condition, Then, Else]>;
114
+ };
115
+ readonly ifs: <T extends ExprType, const Rest extends readonly unknown[]>(condition: import("../field/calc/types.js").BoolLike, value: import("../field/calc/types.js").ExprLike<T>, ...rest: Rest & (Rest extends readonly [] ? readonly [] : Rest extends readonly [infer Condition, infer Value, ...infer Rest_1] ? readonly [Condition & import("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/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("../field/calc/types.js").BoolLike, Value & import("../field/calc/types.js").ExprLike<NoInfer<T>>, .../*elided*/ any] : never] : never] : never] : never] : never] : never] : never] : never] : never] : never] : never)) => import("../field/calc/types.js").ComposedExpr<T, [typeof condition, typeof value, ...Rest]>;
116
+ readonly isBlank: <T extends ExprType, const Value extends import("../field/calc/types.js").ExprLike<T>>(value: Value) => import("../field/calc/types.js").ComposedExpr<"bool", [Value]>;
117
+ readonly sum: {
118
+ <const Value extends import("../field/calc/types.js").ExprLike<"number">>(value: Value): import("../field/calc/types.js").ComposedExpr<"number", [Value]>;
119
+ <const Value extends import("../field/calc/types.js").ExprLike<"decimal">>(value: Value): import("../field/calc/types.js").ComposedExpr<"decimal", [Value]>;
120
+ };
121
+ readonly count: <T extends ExprType, const Value extends import("../field/calc/types.js").ExprLike<T>>(value: Value) => import("../field/calc/types.js").ComposedExpr<"number", [Value]>;
122
+ readonly countUnique: <T extends ExprType, const Value extends import("../field/calc/types.js").ExprLike<T>>(value: Value) => import("../field/calc/types.js").ComposedExpr<"number", [Value]>;
123
+ readonly average: <const Value extends import("../field/calc/types.js").NumericLike>(value: Value) => import("../field/calc/types.js").ComposedExpr<"decimal", [Value]>;
124
+ readonly stdev: <const Value extends import("../field/calc/types.js").NumericLike>(value: Value) => import("../field/calc/types.js").ComposedExpr<"decimal", [Value]>;
125
+ readonly min: {
126
+ <const Value extends import("../field/calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">>(value: Value): import("../field/calc/types.js").ComposedExpr<Extract<import("../field/calc/types.js").ExprTypeOf<Value>, "number" | "decimal" | "date" | "datetime">, [Value]>;
127
+ <const A extends import("../field/calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">, const B extends import("../field/calc/types.js").ExprLike<Extract<import("../field/calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>, const Rest extends readonly import("../field/calc/types.js").ExprLike<Extract<import("../field/calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>[]>(a: A, b: B, ...rest: Rest): import("../field/calc/types.js").ComposedExpr<Extract<import("../field/calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">, [A, B, ...Rest]>;
128
+ };
129
+ readonly max: {
130
+ <const Value extends import("../field/calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">>(value: Value): import("../field/calc/types.js").ComposedExpr<Extract<import("../field/calc/types.js").ExprTypeOf<Value>, "number" | "decimal" | "date" | "datetime">, [Value]>;
131
+ <const A extends import("../field/calc/types.js").ExprLike<"number" | "decimal" | "date" | "datetime">, const B extends import("../field/calc/types.js").ExprLike<Extract<import("../field/calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>, const Rest extends readonly import("../field/calc/types.js").ExprLike<Extract<import("../field/calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">>[]>(a: A, b: B, ...rest: Rest): import("../field/calc/types.js").ComposedExpr<Extract<import("../field/calc/types.js").ExprTypeOf<A>, "number" | "decimal" | "date" | "datetime">, [A, B, ...Rest]>;
132
+ };
133
+ readonly concat: typeof import("../field/calc/text.js").concat;
134
+ readonly toText: typeof import("../field/calc/text.js").toText;
135
+ readonly len: typeof import("../field/calc/text.js").len;
136
+ readonly trim: typeof import("../field/calc/text.js").trim;
137
+ readonly upper: typeof import("../field/calc/text.js").upper;
138
+ readonly lower: typeof import("../field/calc/text.js").lower;
139
+ readonly left: typeof import("../field/calc/text.js").left;
140
+ readonly right: typeof import("../field/calc/text.js").right;
141
+ readonly mid: typeof import("../field/calc/text.js").mid;
142
+ readonly substitute: typeof import("../field/calc/text.js").substitute;
143
+ readonly find: typeof import("../field/calc/text.js").find;
144
+ readonly search: typeof import("../field/calc/text.js").search;
145
+ readonly split: typeof import("../field/calc/text.js").splitText;
146
+ readonly splitText: typeof import("../field/calc/text.js").splitText;
147
+ readonly regexMatch: typeof import("../field/calc/text.js").regexMatch;
148
+ readonly regexReplace: typeof import("../field/calc/text.js").regexReplace;
149
+ readonly regexExtract: typeof import("../field/calc/text.js").regexExtract;
150
+ readonly jsonEscape: typeof import("../field/calc/text.js").jsonEscape;
151
+ readonly jsonUnescape: typeof import("../field/calc/text.js").jsonUnescape;
152
+ readonly repeat: typeof import("../field/calc/text.js").repeat;
153
+ readonly round: typeof import("../field/calc/numeric.js").round;
154
+ readonly power: typeof import("../field/calc/numeric.js").power;
155
+ readonly sqrt: typeof import("../field/calc/numeric.js").sqrt;
156
+ readonly toNumber: typeof import("../field/calc/numeric.js").toNumber;
157
+ readonly uuid: typeof import("../field/calc/numeric.js").uuid;
158
+ readonly now: typeof import("../field/calc/date.js").now;
159
+ readonly makeDate: typeof import("../field/calc/date.js").makeDate;
160
+ readonly dateTime: typeof import("../field/calc/date.js").dateTime;
161
+ readonly dateValue: typeof import("../field/calc/date.js").dateValue;
162
+ readonly dateDiff: typeof import("../field/calc/date.js").dateDiff;
163
+ readonly dateDif: typeof import("../field/calc/date.js").dateDif;
164
+ readonly truncateDateTime: typeof import("../field/calc/date.js").truncateDateTime;
165
+ readonly dateTimeTrunc: typeof import("../field/calc/date.js").dateTimeTrunc;
166
+ readonly weekday: typeof import("../field/calc/date.js").weekday;
167
+ readonly year: typeof import("../field/calc/date.js").year;
168
+ readonly month: typeof import("../field/calc/date.js").month;
169
+ readonly day: typeof import("../field/calc/date.js").day;
170
+ readonly hour: typeof import("../field/calc/date.js").hour;
171
+ readonly minute: typeof import("../field/calc/date.js").minute;
172
+ readonly second: typeof import("../field/calc/date.js").second;
173
+ readonly countIf: typeof import("../field/calc/aggregate.js").countIf;
174
+ readonly sumIf: typeof import("../field/calc/aggregate.js").sumIf;
175
+ readonly stringAgg: typeof import("../field/calc/aggregate.js").stringAgg;
176
+ readonly stringAggUnique: typeof import("../field/calc/aggregate.js").stringAggUnique;
177
+ readonly label: <const Field extends import("../field/calc/types.js").ExprLike<"picklist">>(field: Field) => import("../field/calc/types.js").ComposedExpr<"text", [Field]>;
178
+ readonly id: <T extends "picklist" | "user" | "group" | "attachment", const Field extends import("../field/calc/types.js").ExprLike<T>>(field: Field) => import("../field/calc/types.js").ComposedExpr<T, [Field]>;
179
+ readonly email: <const Field extends import("../field/calc/types.js").ExprLike<"user">>(field: Field) => import("../field/calc/types.js").ComposedExpr<"text", [Field]>;
180
+ readonly name: <const Field extends import("../field/calc/types.js").ExprLike<"group">>(field: Field) => import("../field/calc/types.js").ComposedExpr<"text", [Field]>;
181
+ };
182
+ /** Full statically typed automation calculation builder surface. */
183
+ export type CalculationBuilder = typeof calc;
184
+ export type { ConcatExprType, DateDiffUnit, DateDifUnit, DateTimePrecision, DateTimeTruncPrecision, ErgonomicOrderByDirection, ErgonomicPredicate, OrderByDirection, Predicate, PredicateInput, PredicateOp, StringAggOptions, StringAggOrderBy, WeekdayConvention, WeekdayMode, } from "../field/calc/index.js";
185
+ export { dateDiffUnit, dateDifUnit, dateTimeTruncPrecision, orderByDirection, predicateOp, weekdayMode, } from "../field/calc/index.js";
186
+ /** Static TS value produced by one server-validated calculation expression. */
187
+ export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
188
+ readonly [key: string]: JsonValue;
189
+ };
190
+ /** Nullable runtime value produced by a calculation expression. */
191
+ export type CalculationValue<T extends ExprType, Cardinality extends ExprCardinality = "single"> = Cardinality extends "multiple" ? T extends "text" ? readonly string[] | null : T extends "multiPicklist" ? readonly string[] | null : readonly unknown[] | null : T extends "number" | "decimal" ? number | null : T extends "bool" ? boolean | null : T extends "json" ? JsonValue | null : T extends "multiPicklist" ? readonly string[] | null : T extends "text" | "handle" | "html" | "date" | "datetime" | "picklist" | "user" | "group" | "attachment" | "uuid" ? string | null : unknown;
@@ -0,0 +1,57 @@
1
+ import { calc as fieldCalc } from "../field/calc.js";
2
+ import { makeExpr, withWorkflowRefRenderer } from "../field/calc/runtime.js";
3
+ /** Discoverable calculation brands accepted by calc.param's type option. */
4
+ export const calculationParameterType = {
5
+ number: "number",
6
+ decimal: "decimal",
7
+ boolean: "bool",
8
+ text: "text",
9
+ date: "date",
10
+ datetime: "datetime",
11
+ picklist: "picklist",
12
+ user: "user",
13
+ group: "group",
14
+ attachment: "attachment",
15
+ multiPicklist: "multiPicklist",
16
+ handle: "handle",
17
+ html: "html",
18
+ json: "json",
19
+ };
20
+ let activeParameterCollector;
21
+ export function param(value, options) {
22
+ return makeExpr(options?.type ?? "text", () => {
23
+ if (activeParameterCollector === undefined) {
24
+ throw new Error("calc.param() can only be rendered by calculation(); pass the expression directly to a calculation entry.");
25
+ }
26
+ return activeParameterCollector(value);
27
+ });
28
+ }
29
+ /**
30
+ * Render an Expr while collecting workflow refs as Mobius template parameters.
31
+ * Rendering is synchronous, so the collector is restored in the same stack
32
+ * frame and cannot leak into another authored task.
33
+ */
34
+ export function renderCalculationExpression(expression) {
35
+ if (activeParameterCollector !== undefined) {
36
+ throw new Error("nested calculation expression rendering is not supported.");
37
+ }
38
+ const parameters = [];
39
+ const collect = (value) => {
40
+ const name = "p" + String(parameters.length + 1);
41
+ parameters.push({ name, value });
42
+ return "{{{" + name + "}}}";
43
+ };
44
+ activeParameterCollector = collect;
45
+ try {
46
+ return withWorkflowRefRenderer(collect, () => ({
47
+ text: expression.toCalcString(),
48
+ parameters,
49
+ }));
50
+ }
51
+ finally {
52
+ activeParameterCollector = undefined;
53
+ }
54
+ }
55
+ /** Knowhere calculated grammar plus workflow-value parameters. */
56
+ export const calc = { ...fieldCalc, param };
57
+ export { dateDiffUnit, dateDifUnit, dateTimeTruncPrecision, orderByDirection, predicateOp, weekdayMode, } from "../field/calc/index.js";