@elementumai/edk 0.9.2 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/README.md +34 -26
  2. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
  3. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
  4. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
  5. package/dist-sdk/pull/util.d.ts +1 -1
  6. package/dist-sdk/pull/util.js +3 -3
  7. package/dist-sdk/src/catalog/factories.d.ts +49 -10
  8. package/dist-sdk/src/catalog/factories.js +94 -13
  9. package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
  10. package/dist-sdk/src/catalog/from-authoring.js +7 -7
  11. package/dist-sdk/src/catalog/index.d.ts +2 -2
  12. package/dist-sdk/src/catalog/index.js +1 -1
  13. package/dist-sdk/src/catalog/org.js +62 -4
  14. package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
  15. package/dist-sdk/src/catalog/render-helpers.js +1 -1
  16. package/dist-sdk/src/catalog/render.d.ts +1 -0
  17. package/dist-sdk/src/catalog/render.js +2 -2
  18. package/dist-sdk/src/catalog/token.js +11 -4
  19. package/dist-sdk/src/catalog/types.d.ts +33 -4
  20. package/dist-sdk/src/catalog/types.js +5 -0
  21. package/dist-sdk/src/core/index.d.ts +10 -10
  22. package/dist-sdk/src/core/index.js +9 -9
  23. package/dist-sdk/src/core/render-tree.d.ts +1 -1
  24. package/dist-sdk/src/core/render-tree.js +1 -2
  25. package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
  26. package/dist-sdk/src/core/types/ai-provider.js +1 -1
  27. package/dist-sdk/src/core/types/app.d.ts +66 -30
  28. package/dist-sdk/src/core/types/app.js +2 -2
  29. package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
  30. package/dist-sdk/src/core/types/aspect-category.js +4 -4
  31. package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
  32. package/dist-sdk/src/core/types/cloud-link.js +3 -3
  33. package/dist-sdk/src/core/types/display-block.d.ts +2 -2
  34. package/dist-sdk/src/core/types/display-block.js +2 -2
  35. package/dist-sdk/src/core/types/group.d.ts +1 -1
  36. package/dist-sdk/src/core/types/group.js +1 -1
  37. package/dist-sdk/src/core/types/user.d.ts +1 -1
  38. package/dist-sdk/src/core/types/user.js +1 -1
  39. package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
  40. package/dist-sdk/src/engine/build/context.d.ts +20 -13
  41. package/dist-sdk/src/engine/entity.d.ts +1 -1
  42. package/dist-sdk/src/engine/pull/context.d.ts +34 -0
  43. package/dist-sdk/src/engine/pull/context.js +14 -0
  44. package/dist-sdk/src/engine/pull/org.d.ts +9 -0
  45. package/dist-sdk/src/engine/pull/org.js +33 -0
  46. package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
  47. package/dist-sdk/src/engine/pull/ref-only.js +204 -0
  48. package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
  49. package/dist-sdk/src/engine/tf/expr.js +18 -13
  50. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  51. package/dist-sdk/src/engine/tf/index.js +1 -1
  52. package/dist-sdk/src/engine/tf/model.d.ts +8 -1
  53. package/dist-sdk/src/engine/tf/model.js +4 -0
  54. package/dist-sdk/src/engine/tf/parse.js +13 -2
  55. package/dist-sdk/src/engine/tf/render.js +4 -0
  56. package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
  57. package/dist-sdk/src/entities/access-policy/build.js +1 -1
  58. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
  59. package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
  60. package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
  61. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
  62. package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
  63. package/dist-sdk/src/entities/agent/build.d.ts +3 -3
  64. package/dist-sdk/src/entities/agent/build.js +5 -5
  65. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
  66. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
  67. package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
  68. package/dist-sdk/src/entities/agent/from-tf.js +12 -4
  69. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  70. package/dist-sdk/src/entities/agent/index.js +1 -1
  71. package/dist-sdk/src/entities/agent/module.js +2 -0
  72. package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
  73. package/dist-sdk/src/entities/agent/to-tf.js +56 -8
  74. package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
  75. package/dist-sdk/src/entities/agent/tools.js +21 -7
  76. package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
  77. package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
  78. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
  79. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
  80. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
  81. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
  82. package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
  83. package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
  84. package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
  85. package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
  86. package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
  87. package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
  88. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
  89. package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
  90. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
  91. package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
  92. package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
  93. package/dist-sdk/src/entities/agent-tool/types.js +10 -37
  94. package/dist-sdk/src/entities/app/build.d.ts +97 -42
  95. package/dist-sdk/src/entities/app/build.js +25 -14
  96. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
  97. package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
  98. package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
  99. package/dist-sdk/src/entities/app/index.d.ts +11 -8
  100. package/dist-sdk/src/entities/app/index.js +10 -7
  101. package/dist-sdk/src/entities/app/module.js +2 -2
  102. package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
  103. package/dist-sdk/src/entities/app/to-tf.js +22 -6
  104. package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
  105. package/dist-sdk/src/entities/approval-chain/build.js +5 -5
  106. package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
  107. package/dist-sdk/src/entities/approval-chain/index.js +1 -1
  108. package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
  109. package/dist-sdk/src/entities/automation/build.d.ts +172 -94
  110. package/dist-sdk/src/entities/automation/build.js +159 -68
  111. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
  112. package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
  113. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
  114. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
  115. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
  116. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
  117. package/dist-sdk/src/entities/automation/from-tf.js +510 -80
  118. package/dist-sdk/src/entities/automation/index.d.ts +9 -12
  119. package/dist-sdk/src/entities/automation/index.js +11 -13
  120. package/dist-sdk/src/entities/automation/module.js +74 -6
  121. package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
  122. package/dist-sdk/src/entities/automation/operators.js +10 -37
  123. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
  124. package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
  125. package/dist-sdk/src/entities/automation/script-code.js +13 -22
  126. package/dist-sdk/src/entities/automation/serialize.js +1 -1
  127. package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
  128. package/dist-sdk/src/entities/automation/tasks.js +64 -11
  129. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
  130. package/dist-sdk/src/entities/automation/to-tf.js +342 -71
  131. package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
  132. package/dist-sdk/src/entities/automation/triggers.js +7 -1
  133. package/dist-sdk/src/entities/automation/types.d.ts +3 -2
  134. package/dist-sdk/src/entities/automation/types.js +3 -2
  135. package/dist-sdk/src/entities/chart/build.d.ts +95 -0
  136. package/dist-sdk/src/entities/chart/build.js +42 -0
  137. package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
  138. package/dist-sdk/src/entities/chart/from-tf.js +269 -0
  139. package/dist-sdk/src/entities/chart/index.d.ts +4 -0
  140. package/dist-sdk/src/entities/chart/index.js +3 -0
  141. package/dist-sdk/src/entities/chart/module.d.ts +3 -0
  142. package/dist-sdk/src/entities/chart/module.js +61 -0
  143. package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
  144. package/dist-sdk/src/entities/chart/printer.js +104 -0
  145. package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
  146. package/dist-sdk/src/entities/chart/to-tf.js +150 -0
  147. package/dist-sdk/src/entities/chart/types.d.ts +53 -0
  148. package/dist-sdk/src/entities/chart/types.js +22 -0
  149. package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
  150. package/dist-sdk/src/entities/dashboard/build.js +16 -1
  151. package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
  152. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
  153. package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
  154. package/dist-sdk/src/entities/datamine/module.js +1 -1
  155. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
  156. package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
  157. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
  158. package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
  159. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
  160. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
  161. package/dist-sdk/src/entities/element/build.d.ts +25 -32
  162. package/dist-sdk/src/entities/element/build.js +15 -32
  163. package/dist-sdk/src/entities/element/index.d.ts +7 -5
  164. package/dist-sdk/src/entities/element/index.js +7 -4
  165. package/dist-sdk/src/entities/element/module.js +7 -3
  166. package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
  167. package/dist-sdk/src/entities/element/to-tf.js +7 -3
  168. package/dist-sdk/src/entities/field/build.d.ts +51 -24
  169. package/dist-sdk/src/entities/field/build.js +31 -6
  170. package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
  171. package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
  172. package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
  173. package/dist-sdk/src/entities/field/calc/date.js +120 -29
  174. package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
  175. package/dist-sdk/src/entities/field/calc/index.js +82 -139
  176. package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
  177. package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
  178. package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
  179. package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
  180. package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
  181. package/dist-sdk/src/entities/field/calc/text.js +43 -31
  182. package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
  183. package/dist-sdk/src/entities/field/calc/types.js +1 -22
  184. package/dist-sdk/src/entities/field/calc.d.ts +71 -48
  185. package/dist-sdk/src/entities/field/calc.js +5 -15
  186. package/dist-sdk/src/entities/field/calculation-types.js +10 -3
  187. package/dist-sdk/src/entities/field/from-tf.js +156 -10
  188. package/dist-sdk/src/entities/field/locals.d.ts +11 -3
  189. package/dist-sdk/src/entities/field/locals.js +15 -2
  190. package/dist-sdk/src/entities/field/module.js +23 -6
  191. package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
  192. package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
  193. package/dist-sdk/src/entities/field/to-tf.js +293 -35
  194. package/dist-sdk/src/entities/field/types.d.ts +1 -1
  195. package/dist-sdk/src/entities/field/types.js +7 -1
  196. package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
  197. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
  198. package/dist-sdk/src/entities/org/cloud-link.js +4 -5
  199. package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
  200. package/dist-sdk/src/entities/org/email-alias.js +12 -0
  201. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  202. package/dist-sdk/src/entities/org/index.js +1 -0
  203. package/dist-sdk/src/entities/org/phone-provider.js +4 -7
  204. package/dist-sdk/src/entities/organization/build.d.ts +214 -2
  205. package/dist-sdk/src/entities/organization/build.js +145 -4
  206. package/dist-sdk/src/entities/organization/index.d.ts +1 -1
  207. package/dist-sdk/src/entities/organization/index.js +1 -1
  208. package/dist-sdk/src/entities/organization/module.js +4 -1
  209. package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
  210. package/dist-sdk/src/entities/organization/to-tf.js +118 -1
  211. package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
  212. package/dist-sdk/src/entities/phone-service/build.js +2 -2
  213. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
  214. package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
  215. package/dist-sdk/src/entities/phone-service/index.js +1 -1
  216. package/dist-sdk/src/entities/phone-service/types.js +1 -1
  217. package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
  218. package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
  219. package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
  220. package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
  221. package/dist-sdk/src/entities/search-table/build.js +13 -13
  222. package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
  223. package/dist-sdk/src/entities/search-table/index.js +2 -2
  224. package/dist-sdk/src/entities/search-table/printer.js +5 -5
  225. package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
  226. package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
  227. package/dist-sdk/src/entities/shared/context.d.ts +25 -24
  228. package/dist-sdk/src/entities/shared/context.js +36 -35
  229. package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
  230. package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
  231. package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
  232. package/dist-sdk/src/entities/shared/filters/index.js +11 -4
  233. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
  234. package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
  235. package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
  236. package/dist-sdk/src/entities/shared/ref.js +8 -3
  237. package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
  238. package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
  239. package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
  240. package/dist-sdk/src/entities/skill/build.d.ts +2 -2
  241. package/dist-sdk/src/entities/skill/build.js +3 -3
  242. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  243. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
  244. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  245. package/dist-sdk/src/entities/skill/index.js +1 -1
  246. package/dist-sdk/src/entities/skill/module.js +2 -2
  247. package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
  248. package/dist-sdk/src/entities/skill/to-tf.js +2 -2
  249. package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
  250. package/dist-sdk/src/entities/skill/tools.js +4 -3
  251. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
  252. package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
  253. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
  254. package/dist-sdk/src/entities/table/build.d.ts +1 -1
  255. package/dist-sdk/src/entities/table/build.js +9 -9
  256. package/dist-sdk/src/entities/table/catalog-render.js +9 -1
  257. package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
  258. package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
  259. package/dist-sdk/src/entities/table/fields/types.js +1 -1
  260. package/dist-sdk/src/entities/table/index.d.ts +2 -2
  261. package/dist-sdk/src/entities/table/index.js +3 -3
  262. package/dist-sdk/src/entities/table/module.js +1 -1
  263. package/dist-sdk/src/entities/table/to-tf.js +22 -30
  264. package/dist-sdk/src/entities/task/build.d.ts +1 -1
  265. package/dist-sdk/src/entities/task/build.js +5 -5
  266. package/dist-sdk/src/entities/task/index.d.ts +1 -1
  267. package/dist-sdk/src/entities/task/index.js +1 -1
  268. package/dist-sdk/src/entities/view/build.d.ts +46 -0
  269. package/dist-sdk/src/entities/view/build.js +19 -0
  270. package/dist-sdk/src/entities/view/from-tf.js +68 -18
  271. package/dist-sdk/src/entities/view/module.d.ts +6 -13
  272. package/dist-sdk/src/entities/view/module.js +7 -14
  273. package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
  274. package/dist-sdk/src/entities/view/sharing.js +6 -0
  275. package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
  276. package/dist-sdk/src/entities/view/to-tf.js +61 -26
  277. package/dist-sdk/src/entities/view/types.js +3 -0
  278. package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
  279. package/dist-sdk/src/entities/visual-flow/build.js +8 -8
  280. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  281. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  282. package/dist-sdk/src/entities/visual-flow/module.js +1 -1
  283. package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
  284. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
  285. package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
  286. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  287. package/dist-sdk/src/entities/widget/to-tf.js +9 -7
  288. package/dist-sdk/src/graph/index.d.ts +5 -1
  289. package/dist-sdk/src/graph/index.js +4 -1
  290. package/dist-sdk/src/graph/modules.js +6 -1
  291. package/dist-sdk/src/graph/types.d.ts +52 -1
  292. package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
  293. package/dist-sdk/src/internal/safe-identifier.js +13 -0
  294. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  295. package/dist-sdk/src/internal/sdk-package.js +1 -0
  296. package/package.json +12 -3
@@ -1,11 +1,13 @@
1
- import { EntityTfError } from "../../engine/entity.js";
2
- import { OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
3
1
  import { USER_FIELD_KEYS } from "../../catalog/types.js";
4
2
  import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS } from "../../core/system-fields.js";
3
+ import { EntityTfError } from "../../engine/entity.js";
5
4
  import { bareChildResourceLabel, childPartFromScopedLabel, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
6
5
  import { IMPLEMENTED_FILE_READER_RESOURCE_TYPES } from "../file-reader/types.js";
7
6
  import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
7
+ import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
8
8
  import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
9
+ import { TABLE_RESOURCE_TYPE } from "../table/module.js";
10
+ import { OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
9
11
  import { ALL_AUTOMATION_TASK_TYPE_SET, AUTOMATION_BRANCH_TYPE_SET, AUTOMATION_RESOURCE_TYPE, AUTOMATION_TRIGGER_TYPE_SET, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
10
12
  const TRIGGER_KINDS = {
11
13
  elementum_record_created_trigger: "recordCreate",
@@ -229,6 +231,54 @@ function pathNames(path) {
229
231
  return WIRE_REF_SEGMENT_TO_TS[name] ?? name;
230
232
  });
231
233
  }
234
+ /**
235
+ * Resolve one platform field ref name (for example `"Facility"` or
236
+ * `"Created By Email"`) to the typed record path exposed by the public
237
+ * automation context. Shared by record-bearing trigger refs and
238
+ * create-record task outputs; both use the same display-name + suffix wire
239
+ * convention.
240
+ */
241
+ function recordFieldRefPath(wireName, ctx) {
242
+ // Case-insensitive: the platform re-cases "By" to "by" when building some
243
+ // compound ref phrases (e.g. field "Created By" -> ref key "Created by
244
+ // Email").
245
+ const wireNameLower = wireName.toLowerCase();
246
+ for (const field of ctx.fieldById.values()) {
247
+ for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
248
+ if (wireNameLower === `${field.name}${suffix}`.toLowerCase()) {
249
+ return ["record", field.key, ...suffixPath];
250
+ }
251
+ }
252
+ }
253
+ // System fields have no `*_field` resource block, so they never appear in
254
+ // fieldById. Match their provider-default display names explicitly.
255
+ for (const key of SYSTEM_FIELD_KEYS) {
256
+ const defaultName = DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key];
257
+ for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
258
+ if (wireNameLower === `${defaultName}${suffix}`.toLowerCase()) {
259
+ return ["record", key, ...suffixPath];
260
+ }
261
+ }
262
+ }
263
+ return undefined;
264
+ }
265
+ const RECORD_BEARING_TRIGGER_TYPES = new Set([
266
+ "elementum_record_created_trigger",
267
+ "elementum_record_updated_trigger",
268
+ "elementum_attachment_added_trigger",
269
+ "elementum_comment_added_trigger",
270
+ "elementum_approval_chain_trigger",
271
+ // On-demand workflows can also be launched with record context. Declared
272
+ // parameters take precedence below so a parameter named like a field does
273
+ // not get misclassified as `ctx.trigger.record.<field>`.
274
+ "elementum_on_demand_trigger",
275
+ ]);
276
+ function isDeclaredOnDemandParameter(trigger, wireName) {
277
+ if (trigger.type !== "elementum_on_demand_trigger")
278
+ return false;
279
+ const parameters = trigger.attrs.parameters;
280
+ return Array.isArray(parameters) && parameters.some((parameter) => isObject(parameter) && parameter.name === wireName);
281
+ }
232
282
  // recordSearch's own output ref names ("Records Size" -> totalCount, "All
233
283
  // found records" -> records) — deliberately NOT in WIRE_REF_SEGMENT_TO_TS,
234
284
  // which triggerRefPath also consults: a record-created/updated trigger's ref
@@ -242,6 +292,13 @@ const RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS = {
242
292
  "Records Size": "totalCount",
243
293
  "All found records": "records",
244
294
  };
295
+ // aiSearchTable's own output ref name — same scoping reason as
296
+ // RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS: "All Records" is a platform-fixed
297
+ // wire key on elementum_ai_search_table_task only. A trigger field could
298
+ // coincidentally share that display name and must not be rewritten here.
299
+ const AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS = {
300
+ "All Records": "records",
301
+ };
245
302
  /**
246
303
  * A webhook trigger's `body`/`headers` refs come back as "Body (Plain
247
304
  * Text)"/"Headers (Content-Type)" - one wire segment naming both the
@@ -256,16 +313,98 @@ const RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS = {
256
313
  * convention.
257
314
  */
258
315
  const WEBHOOK_REF_PATTERN = /^(Body|Headers) \((.+)\)$/;
316
+ function aspectOwnerRefNameFromObjectId(objectId, appRefName, appTfLabel) {
317
+ if (!isTfExpr(objectId))
318
+ return undefined;
319
+ if (objectId.$expr === "data-attr" && (objectId.type === "elementum_app" || objectId.type === "elementum_element") && objectId.path[0] === "id") {
320
+ return tfLabelToTsLabel(objectId.label);
321
+ }
322
+ if (objectId.$expr === "resource-attr" && objectId.type === "elementum_app" && objectId.label === appTfLabel && objectId.path[0] === "id") {
323
+ return appRefName;
324
+ }
325
+ if (objectId.$expr === "resource-attr" && objectId.type === "elementum_element" && objectId.path[0] === "id") {
326
+ return tfLabelToTsLabel(objectId.label);
327
+ }
328
+ return undefined;
329
+ }
330
+ function lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx) {
331
+ const lower = displayName.toLowerCase();
332
+ const foreign = ctx.fieldNamesByOwnerRefName?.get(ownerRefName)?.get(lower);
333
+ if (foreign !== undefined)
334
+ return foreign;
335
+ if (ownerRefName === ctx.appRefName) {
336
+ for (const field of ctx.fieldById.values()) {
337
+ if (field.name.toLowerCase() === lower)
338
+ return field.key;
339
+ }
340
+ }
341
+ for (const key of SYSTEM_FIELD_KEYS) {
342
+ if (DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key].toLowerCase() === lower)
343
+ return key;
344
+ }
345
+ return undefined;
346
+ }
347
+ function taskRecordSearchFieldPath(taskAddress, wireName, ctx) {
348
+ if (ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) === undefined)
349
+ return undefined;
350
+ const ownerRefName = ctx.taskTargetOwnerRefNameByAddress.get(taskAddress);
351
+ const wireNameLower = wireName.toLowerCase();
352
+ for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
353
+ for (const base of suffix === "" ? [wireName] : wireName.endsWith(suffix) ? [wireName.slice(0, -suffix.length)] : []) {
354
+ const fieldKey = lookupFieldKeyByDisplayName(ownerRefName, base, ctx);
355
+ if (fieldKey !== undefined && (suffix === "" || wireNameLower === `${base}${suffix}`.toLowerCase())) {
356
+ return ["record", fieldKey, ...suffixPath];
357
+ }
358
+ }
359
+ }
360
+ return undefined;
361
+ }
362
+ function decodeFieldAssignmentValue(value, ctx) {
363
+ if (typeof value === "string" && /^[a-f0-9-]{36}$/i.test(value)) {
364
+ const label = ctx.picklistOptionLabelById?.get(value);
365
+ if (label !== undefined)
366
+ return { kind: "literal", value: label };
367
+ }
368
+ return decodeValue(value, ctx);
369
+ }
259
370
  function triggerRefPath(path, ctx) {
260
371
  const names = pathNames(path);
261
372
  if (names.length !== 1)
262
373
  return names;
263
374
  const wireName = names[0];
375
+ // Attachment-trigger payload refs ("Attachment" / "Attachment Id") — gated
376
+ // on the trigger type and compared case-sensitively. Field matching below
377
+ // is case-insensitive and uses suffix " ID"; for a coincidental field named
378
+ // "Attachment", refs["Attachment ID"] is the field path
379
+ // (ctx.trigger.record.<key>.id) while refs["Attachment Id"] is the trigger
380
+ // ATTACHMENT_ID payload (ctx.trigger.attachment.id). Those strings collide
381
+ // under .toLowerCase(), so this match must stay exact and must NOT reuse
382
+ // FIELD_REF_SUFFIX_FROM_WIRE.
383
+ if (ctx.trigger.type === "elementum_attachment_added_trigger") {
384
+ if (wireName === "Attachment")
385
+ return ["attachment"];
386
+ if (wireName === "Attachment Id")
387
+ return ["attachment", "id"];
388
+ }
264
389
  if (ctx.trigger.type === "elementum_webhook_trigger") {
265
390
  const webhookMatch = WEBHOOK_REF_PATTERN.exec(wireName);
266
391
  if (webhookMatch)
267
392
  return [webhookMatch[1].toLowerCase(), webhookMatch[2]];
268
393
  }
394
+ if (ctx.trigger.type === "elementum_on_demand_trigger") {
395
+ if (wireName === "Triggered By's Id")
396
+ return ["triggeredBy", "id"];
397
+ if (wireName === "Triggered By's Name")
398
+ return ["triggeredBy", "name"];
399
+ if (wireName === "Triggered By's Email")
400
+ return ["triggeredBy", "email"];
401
+ }
402
+ // An on-demand parameter is an explicitly declared top-level ctx.trigger
403
+ // property. Check this before record-field inference: a perfectly ordinary
404
+ // parameter such as `FACILITY` can collide case-insensitively with the app
405
+ // field display name "Facility".
406
+ if (isDeclaredOnDemandParameter(ctx.trigger, wireName))
407
+ return names;
269
408
  // A trigger's own bare record reference (confirmed live via `ei refs`,
270
409
  // see trigger-record-id.test.ts) — deliberately scoped to triggerRefPath,
271
410
  // not the shared WIRE_REF_SEGMENT_TO_TS table: createRecord/
@@ -277,34 +416,89 @@ function triggerRefPath(path, ctx) {
277
416
  // types).
278
417
  if (wireName === "Record")
279
418
  return ["record"];
280
- // Case-insensitive: the platform re-cases "By" to "by" when building some
281
- // compound ref phrases (e.g. field "Created By" -> ref key "Created by
282
- // Email"), so a case-sensitive compare against the field's own display
283
- // name misses the match entirely.
419
+ if (!RECORD_BEARING_TRIGGER_TYPES.has(ctx.trigger.type ?? ""))
420
+ return names;
421
+ return recordFieldRefPath(wireName, ctx) ?? names;
422
+ }
423
+ /**
424
+ * Resolve a forEach `.inner.refs["<display name>"]` key to the public record
425
+ * bag key used by `ctx.item`. The provider exposes current-item fields by
426
+ * display name (including system fields such as `"ID"`), while the authored
427
+ * TypeScript surface uses stable keys (`id`, custom field bag keys, and typed
428
+ * suffixes such as `.label`).
429
+ */
430
+ function forEachItemRefPath(path, ctx) {
431
+ const names = pathNames(path);
432
+ if (names.length !== 1)
433
+ return names.flatMap((segment) => segment.split("."));
434
+ const wireName = names[0];
435
+ if (wireName === "Record")
436
+ return ["recordId"];
284
437
  const wireNameLower = wireName.toLowerCase();
285
438
  for (const field of ctx.fieldById.values()) {
286
439
  for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
287
440
  if (wireNameLower === `${field.name}${suffix}`.toLowerCase()) {
288
- return ["record", field.key, ...suffixPath];
441
+ return [field.key, ...suffixPath];
289
442
  }
290
443
  }
291
444
  }
292
- // System fields (id/title/status/stage/createdBy/updatedBy/...) have no
293
- // `*_field` resource block of their own - they're elementum_app computed
294
- // attributes, so they never appear in ctx.fieldById. Try their canonical
295
- // bag keys against the provider's default display name too (e.g.
296
- // "Created By" + " Email"). A renamed system field's ref key won't match
297
- // here and falls through to the raw-name fallback below - no worse than
298
- // today, since system fields were never matched at all before this.
299
445
  for (const key of SYSTEM_FIELD_KEYS) {
300
446
  const defaultName = DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key];
301
447
  for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
302
448
  if (wireNameLower === `${defaultName}${suffix}`.toLowerCase()) {
303
- return ["record", key, ...suffixPath];
449
+ return [key, ...suffixPath];
450
+ }
451
+ }
452
+ }
453
+ return names.flatMap((segment) => segment.split("."));
454
+ }
455
+ function resolveTaskRefKey(taskIdOrKey, ctx) {
456
+ if (/^[a-f0-9-]{36}$/.test(taskIdOrKey)) {
457
+ for (const [address, task] of ctx.taskByAddress) {
458
+ if (ctx.resourceImportIds.get(address) === taskIdOrKey) {
459
+ return { refKey: task.refKey, block: task.block };
460
+ }
461
+ }
462
+ }
463
+ for (const [, task] of ctx.taskByAddress) {
464
+ if (task.refKey === taskIdOrKey)
465
+ return { refKey: task.refKey, block: task.block };
466
+ }
467
+ return { refKey: taskIdOrKey };
468
+ }
469
+ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
470
+ const { refKey, block } = resolveTaskRefKey(taskIdOrKey, ctx);
471
+ if (block?.type === "elementum_record_search_task" && pathSegments.length >= 1) {
472
+ const [head, ...tail] = pathSegments;
473
+ if (head === "count") {
474
+ return { kind: "taskRef", task: refKey, path: ["totalCount", ...tail] };
475
+ }
476
+ const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[head];
477
+ if (recordSearchName !== undefined) {
478
+ return { kind: "taskRef", task: refKey, path: [recordSearchName, ...tail] };
479
+ }
480
+ const taskAddress = block.label !== undefined ? `${block.type}.${block.label}` : undefined;
481
+ if (taskAddress !== undefined) {
482
+ const recordFieldPath = taskRecordSearchFieldPath(taskAddress, head, ctx);
483
+ if (recordFieldPath !== undefined) {
484
+ return { kind: "taskRef", task: refKey, path: [...recordFieldPath, ...tail] };
304
485
  }
305
486
  }
306
487
  }
307
- return names;
488
+ if (block?.type === "elementum_ai_search_table_task" && pathSegments.length >= 1) {
489
+ const [head, ...tail] = pathSegments;
490
+ const aiSearchName = AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS[head];
491
+ if (aiSearchName !== undefined) {
492
+ return { kind: "taskRef", task: refKey, path: [aiSearchName, ...tail] };
493
+ }
494
+ }
495
+ const keyPath = pathSegments.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
496
+ const taskKind = block?.type !== undefined ? TASK_FACTORIES[block.type] : undefined;
497
+ const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
498
+ const outputKeyPath = wireOutputKey !== undefined && keyPath[0] === wireOutputKey
499
+ ? ["output", ...keyPath.slice(1)]
500
+ : keyPath;
501
+ return { kind: "taskRef", task: refKey, path: outputKeyPath };
308
502
  }
309
503
  function decodeReferenceString(value, ctx) {
310
504
  const pieces = value.split(".");
@@ -313,6 +507,10 @@ function decodeReferenceString(value, ctx) {
313
507
  if (path[0] === "record" && path.length >= 2 && /^[a-f0-9-]{36}$/.test(path[1])) {
314
508
  const sourceFieldId = path[1];
315
509
  const field = ctx.fieldById.get(sourceFieldId);
510
+ const stateField = ctx.foreignFieldRefsById?.get(sourceFieldId);
511
+ const stateFieldKey = stateField?.ownerRefName === ctx.appRefName
512
+ ? stateField.fieldKey
513
+ : undefined;
316
514
  // Orphaned: the field this filter's value_reference points at no
317
515
  // longer exists in the app export at all (deleted/recreated field,
318
516
  // same drift class as the orphaned picklist option ids and skill_ids
@@ -322,12 +520,16 @@ function decodeReferenceString(value, ctx) {
322
520
  // unresolved-segment escape already degrades a non-identifier path
323
521
  // segment like this one) rather than throwing and losing the whole
324
522
  // automation.
325
- return { kind: "triggerRef", path: ["record", field?.key ?? sourceFieldId, ...path.slice(2)] };
523
+ return {
524
+ kind: "triggerRef",
525
+ path: ["record", field?.key ?? stateFieldKey ?? sourceFieldId, ...path.slice(2)],
526
+ };
326
527
  }
327
528
  return { kind: "triggerRef", path };
328
529
  }
329
- if (pieces[0] === "task" && pieces.length > 2)
330
- return { kind: "taskRef", task: pieces[1], path: pieces.slice(2) };
530
+ if (pieces[0] === "task" && pieces.length > 2) {
531
+ return decodeTaskReferenceFromString(pieces[1], pieces.slice(2), ctx);
532
+ }
331
533
  // Any other/future value_reference shape - confirmed live: conciergeforfield's
332
534
  // cff_find_nearby_accounts_if_user_is_impersonating_a_sales_rep switch_case
333
535
  // references a workflow variable ("variable.<uuid>"); setVariable/variable_task
@@ -424,7 +626,7 @@ function decodeValue(value, ctx) {
424
626
  return {
425
627
  kind: "forEachItemRef",
426
628
  forEachTask: task.refKey,
427
- path: pathNames(value.path.slice(2)).flatMap((segment) => segment.split(".")),
629
+ path: forEachItemRefPath(value.path.slice(2), ctx),
428
630
  };
429
631
  }
430
632
  if (task !== undefined && value.path[0] === "refs") {
@@ -438,18 +640,38 @@ function decodeValue(value, ctx) {
438
640
  // provider's own schema docs (build.ts's rewriteForwardTaskRefName
439
641
  // has the full citation). Previously unhandled here entirely — a
440
642
  // pulled automation referencing this output round-tripped as a raw
441
- // `ctx.tasks.<t>.Record` property access that doesn't exist on
643
+ // `ctx.actions.<t>.Record` property access that doesn't exist on
442
644
  // either task's typed output, failing tsc.
443
645
  if ((task.block.type === "elementum_create_record_task" || task.block.type === "elementum_find_related_records_task") &&
444
646
  rawSegments.length === 1 &&
445
- rawSegments[0] === "Record") {
647
+ (rawSegments[0] === "Record" || rawSegments[0] === "Record ID")) {
446
648
  return { kind: "taskRef", task: task.refKey, path: ["record", "recordId"] };
447
649
  }
650
+ // A create-record task exposes each created record field by its
651
+ // display name (for example refs["Title"] or refs["Facility"]). Its
652
+ // public task output is the typed `.record` object, so restore that
653
+ // missing hop and canonical field key on pull.
654
+ if (task.block.type === "elementum_create_record_task" && rawSegments.length === 1) {
655
+ const recordPath = recordFieldRefPath(rawSegments[0], ctx);
656
+ if (recordPath !== undefined) {
657
+ return { kind: "taskRef", task: task.refKey, path: recordPath };
658
+ }
659
+ }
448
660
  if (task.block.type === "elementum_record_search_task" && rawSegments.length === 1) {
449
661
  const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[rawSegments[0]];
450
662
  if (recordSearchName !== undefined) {
451
663
  return { kind: "taskRef", task: task.refKey, path: [recordSearchName] };
452
664
  }
665
+ const recordFieldPath = taskRecordSearchFieldPath(`${value.type}.${value.label}`, rawSegments[0], ctx);
666
+ if (recordFieldPath !== undefined) {
667
+ return { kind: "taskRef", task: task.refKey, path: recordFieldPath };
668
+ }
669
+ }
670
+ if (task.block.type === "elementum_ai_search_table_task" && rawSegments.length === 1) {
671
+ const aiSearchName = AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS[rawSegments[0]];
672
+ if (aiSearchName !== undefined) {
673
+ return { kind: "taskRef", task: task.refKey, path: [aiSearchName] };
674
+ }
453
675
  }
454
676
  const keyPath = rawSegments.flatMap((segment) => segment.split("."));
455
677
  if (task.block.type === "elementum_variable_task") {
@@ -491,6 +713,9 @@ function decodeValue(value, ctx) {
491
713
  phoneServiceKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
492
714
  };
493
715
  }
716
+ if (value.type === TABLE_RESOURCE_TYPE && value.path[0] === "id") {
717
+ return { kind: "table", tableHandle: tfLabelToTsLabel(value.label) };
718
+ }
494
719
  if (value.type === "elementum_datamine" && value.path[0] === "id") {
495
720
  const datamineBlock = ctx.resourceBlocks.get(`elementum_datamine.${value.label}`);
496
721
  const tableId = datamineBlock?.attrs["table_id"];
@@ -535,12 +760,24 @@ function decodeValue(value, ctx) {
535
760
  }
536
761
  throw new EntityTfError(`unreconstructable resource reference ${value.type}.${value.label}`);
537
762
  }
538
- if (value.$expr === "data-attr" && (value.type === "elementum_app" || value.type === "elementum_element") && value.path[0] === "id") {
763
+ if (value.$expr === "data-attr" && value.type === TABLE_RESOURCE_TYPE && value.path[0] === "id") {
539
764
  const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
540
765
  const name = lookup?.attrs.name;
766
+ return {
767
+ kind: "table",
768
+ tableHandle: tfLabelToTsLabel(value.label),
769
+ ...(typeof name === "string" ? { name } : {}),
770
+ };
771
+ }
772
+ if (value.$expr === "data-attr" && (value.type === "elementum_app" || value.type === "elementum_element") && value.path[0] === "id") {
773
+ const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
774
+ const name = lookup?.attrs.name ?? lookup?.attrs.namespace;
775
+ const mappedHandle = typeof name === "string"
776
+ ? (value.type === "elementum_element" ? ctx.foreignElementRefNames : ctx.foreignAppRefNames)?.get(name)
777
+ : undefined;
541
778
  return {
542
779
  kind: "app",
543
- appHandle: tfLabelToTsLabel(value.label),
780
+ appHandle: mappedHandle ?? tfLabelToTsLabel(value.label),
544
781
  entityType: value.type === "elementum_element" ? "element" : "app",
545
782
  ...(typeof name === "string" ? { name } : {}),
546
783
  };
@@ -558,11 +795,14 @@ function decodeValue(value, ctx) {
558
795
  const entityType = objectId.type === "elementum_element" ? "element" : "app";
559
796
  const ownerLabel = objectId.label;
560
797
  const kindPrefix = `${entityType}_${ownerLabel}_`;
561
- const bareLabel = value.label.startsWith(kindPrefix)
562
- ? value.label.slice(kindPrefix.length)
563
- : value.label.startsWith(`${ownerLabel}_`)
564
- ? value.label.slice(ownerLabel.length + 1)
565
- : value.label;
798
+ const elementumKindPrefix = `elementum_${kindPrefix}`;
799
+ const bareLabel = value.label.startsWith(elementumKindPrefix)
800
+ ? value.label.slice(elementumKindPrefix.length)
801
+ : value.label.startsWith(kindPrefix)
802
+ ? value.label.slice(kindPrefix.length)
803
+ : value.label.startsWith(`${ownerLabel}_`)
804
+ ? value.label.slice(ownerLabel.length + 1)
805
+ : value.label;
566
806
  const ownerName = ctx.dataBlocks.get(`${objectId.type}.${objectId.label}`)?.attrs["name"];
567
807
  const fieldName = fieldBlock?.attrs["name"];
568
808
  return {
@@ -664,6 +904,11 @@ function decodeCustomResponse(value, ctx) {
664
904
  return { ...(success !== undefined ? { success } : {}), ...(failure !== undefined ? { failure } : {}) };
665
905
  }
666
906
  function fieldRef(value, ctx) {
907
+ if (isTfExpr(value) && value.$expr === "data-attr" && value.path.join(".") === "id") {
908
+ const foreign = ctx.foreignFieldRefsByDataAddress?.get(`${value.type}.${value.label}`);
909
+ if (foreign !== undefined)
910
+ return { kind: "field", appHandle: foreign.ownerRefName, fieldKey: foreign.fieldKey };
911
+ }
667
912
  const decoded = decodeValue(value, ctx);
668
913
  if (isObject(decoded) && decoded.kind === "field")
669
914
  return decoded;
@@ -717,23 +962,43 @@ function stageFilterName(value, ctx) {
717
962
  }
718
963
  /**
719
964
  * ei exports `elementum_calculation_task.calculations[].formula` as the calc
720
- * engine's mustache string (`{{trigger name="record.<field-uuid>"}}`), not as
721
- * an HCL `refs["…"]` expression. `decodeValue` would keep that UUID in
722
- * authored source (#312). Rewrite each mustache through the same
723
- * `trigger.record.<id>` resolver used for filters, using import-block field
724
- * ids already in this stream.
965
+ * engine's mustache / short-form string, not as an HCL `refs["…"]`
966
+ * expression. `decodeValue` would keep platform ids in authored source
967
+ * (#312). Rewrite each embedded ref through the same resolvers used for
968
+ * filters, using import-block ids already in this stream.
969
+ *
970
+ * Recognized shapes:
971
+ * - `{{trigger name="record.<field-uuid>"}}`
972
+ * - `{{task name="<wire output>" id="<task-uuid>"}}`
973
+ * - `variable.<variable-uuid>` (calc-engine short form)
725
974
  */
726
975
  function decodeCalculationFormula(value, ctx) {
727
976
  if (typeof value !== "string")
728
977
  return decodeValue(value, ctx);
729
978
  const parts = [];
730
979
  let cursor = 0;
731
- for (const match of value.matchAll(/\{\{trigger name="([^"]+)"\}\}/g)) {
980
+ const pattern = /\{\{(trigger|task)\s+([^}]*)\}\}|variable\.([a-f0-9-]{36})/g;
981
+ for (const match of value.matchAll(pattern)) {
732
982
  const index = match.index ?? 0;
733
983
  if (index > cursor)
734
984
  parts.push(value.slice(cursor, index));
735
- const decoded = decodeReferenceString(`trigger.${match[1]}`, ctx);
736
- parts.push(decoded ?? { kind: "unresolved", uuid: match[1], hint: "calculation-reference" });
985
+ if (match[3] !== undefined) {
986
+ parts.push({ kind: "unresolved", uuid: `variable.${match[3]}`, hint: "variable" });
987
+ cursor = index + match[0].length;
988
+ continue;
989
+ }
990
+ const kind = match[1];
991
+ const attrs = match[2];
992
+ if (kind === "trigger") {
993
+ const name = /name="([^"]*)"/.exec(attrs)?.[1];
994
+ const decoded = name !== undefined ? decodeReferenceString(`trigger.${name}`, ctx) : undefined;
995
+ parts.push(decoded ?? { kind: "unresolved", uuid: name ?? match[0], hint: "calculation-reference" });
996
+ }
997
+ else {
998
+ const name = /name="([^"]*)"/.exec(attrs)?.[1];
999
+ const id = /id="([^"]*)"/.exec(attrs)?.[1];
1000
+ parts.push(decodeCalculationTaskMustache(id, name, ctx));
1001
+ }
737
1002
  cursor = index + match[0].length;
738
1003
  }
739
1004
  if (parts.length === 0)
@@ -744,10 +1009,94 @@ function decodeCalculationFormula(value, ctx) {
744
1009
  return parts[0];
745
1010
  return { kind: "template", parts };
746
1011
  }
1012
+ function decodeCalculationTaskMustache(taskId, wireName, ctx) {
1013
+ if (taskId === undefined || wireName === undefined) {
1014
+ return { kind: "unresolved", uuid: `task:${taskId ?? "?"}:${wireName ?? "?"}`, hint: "calculation-reference" };
1015
+ }
1016
+ let refKey;
1017
+ let taskBlock;
1018
+ for (const [address, task] of ctx.taskByAddress) {
1019
+ if (ctx.resourceImportIds.get(address) === taskId) {
1020
+ refKey = task.refKey;
1021
+ taskBlock = task.block;
1022
+ break;
1023
+ }
1024
+ }
1025
+ if (refKey === undefined) {
1026
+ return { kind: "unresolved", uuid: `task.${taskId}.${wireName}`, hint: "calculation-reference" };
1027
+ }
1028
+ if (taskBlock?.type === "elementum_record_search_task") {
1029
+ const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[wireName];
1030
+ if (recordSearchName !== undefined) {
1031
+ return { kind: "taskRef", task: refKey, path: [recordSearchName] };
1032
+ }
1033
+ const taskAddress = taskBlock.label !== undefined ? `${taskBlock.type}.${taskBlock.label}` : undefined;
1034
+ if (taskAddress !== undefined) {
1035
+ const recordFieldPath = taskRecordSearchFieldPath(taskAddress, wireName, ctx);
1036
+ if (recordFieldPath !== undefined) {
1037
+ return { kind: "taskRef", task: refKey, path: recordFieldPath };
1038
+ }
1039
+ }
1040
+ }
1041
+ if (taskBlock?.type === "elementum_ai_search_table_task") {
1042
+ const aiSearchName = AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS[wireName];
1043
+ if (aiSearchName !== undefined) {
1044
+ return { kind: "taskRef", task: refKey, path: [aiSearchName] };
1045
+ }
1046
+ }
1047
+ const keyPath = wireName.split(".");
1048
+ const taskKind = taskBlock?.type !== undefined ? TASK_FACTORIES[taskBlock.type] : undefined;
1049
+ const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
1050
+ const outputKeyPath = wireOutputKey !== undefined && keyPath[0] === wireOutputKey
1051
+ ? ["output", ...keyPath.slice(1)]
1052
+ : keyPath.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
1053
+ return { kind: "taskRef", task: refKey, path: outputKeyPath };
1054
+ }
1055
+ const PULLED_CALCULATION_RESULT_TYPES = {
1056
+ ATTACHMENT_ID: "attachment",
1057
+ BOOLEAN: "bool",
1058
+ DATE: "date",
1059
+ DATETIME: "datetime",
1060
+ DECIMAL: "decimal",
1061
+ GROUP_ID: "group",
1062
+ HANDLE: "handle",
1063
+ HTML: "html",
1064
+ JSON: "json",
1065
+ MULTI_PICKLIST: "multiPicklist",
1066
+ NUMBER: "number",
1067
+ PICKLIST: "picklist",
1068
+ TEXT: "text",
1069
+ USER_ID: "user",
1070
+ };
1071
+ function pulledRawCalculation(formula, outputType, multiple) {
1072
+ if (typeof formula !== "string" || multiple === true || typeof outputType !== "string")
1073
+ return undefined;
1074
+ const resultType = PULLED_CALCULATION_RESULT_TYPES[outputType];
1075
+ return resultType === undefined ? undefined : { kind: "calculationRaw", text: formula, resultType };
1076
+ }
1077
+ function decodeFilterReferenceEnvelope(value, ctx) {
1078
+ const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
1079
+ if (!isObject(raw))
1080
+ return undefined;
1081
+ const taskRef = raw.taskReference;
1082
+ if (isObject(taskRef) && typeof taskRef.taskId === "string" && typeof taskRef.name === "string") {
1083
+ return decodeTaskReferenceFromString(taskRef.taskId, taskRef.name.split("."), ctx);
1084
+ }
1085
+ const triggerRef = raw.triggerReference;
1086
+ if (isObject(triggerRef) && typeof triggerRef.name === "string") {
1087
+ return decodeReferenceString(`trigger.${triggerRef.name}`, ctx);
1088
+ }
1089
+ const variableRef = raw.variableReference;
1090
+ if (isObject(variableRef) && typeof variableRef.id === "string") {
1091
+ return { kind: "unresolved", uuid: `variable.${variableRef.id}`, hint: "variable" };
1092
+ }
1093
+ return undefined;
1094
+ }
747
1095
  function filterReference(value, ctx) {
748
1096
  return typeof value === "string"
749
1097
  ? decodeReferenceString(value, ctx) ?? { kind: "unresolved", uuid: value, hint: "filter-reference" }
750
- : decodeTemplateTriggerRecordFieldRef(value, ctx)
1098
+ : decodeFilterReferenceEnvelope(value, ctx)
1099
+ ?? decodeTemplateTriggerRecordFieldRef(value, ctx)
751
1100
  ?? decodeValue(value, ctx);
752
1101
  }
753
1102
  function decodeFilter(value, ctx, fieldScope = "app") {
@@ -771,7 +1120,8 @@ function triggerFromBlock(block, ctx) {
771
1120
  const parameters = block.attrs.parameters ?? [];
772
1121
  if (!Array.isArray(parameters))
773
1122
  throw new EntityTfError("on-demand parameters must be an array");
774
- return { kind, inputs: parameters.map((parameter) => {
1123
+ return {
1124
+ kind, inputs: parameters.map((parameter) => {
775
1125
  if (!isObject(parameter) || typeof parameter.name !== "string" || typeof parameter.type !== "string")
776
1126
  throw new EntityTfError("invalid on-demand parameter");
777
1127
  // Inverse of to-tf's "attachment" special case above — the wire has
@@ -781,7 +1131,8 @@ function triggerFromBlock(block, ctx) {
781
1131
  // "attachment" that TriggerFieldTypeAlias doesn't accept.
782
1132
  const type = parameter.type === "attachment" ? "attachmentId" : parameter.type;
783
1133
  return { name: parameter.name, type, ...(parameter.required === true ? { required: true } : {}), ...(parameter.multiple === true ? { multiple: true } : {}), ...(parameter.default_value !== undefined ? { defaultValue: parameter.default_value } : {}), ...(typeof parameter.description === "string" ? { description: parameter.description } : {}) };
784
- }), ...(block.attrs.show_triggered_by === true ? { showTriggeredBy: true } : {}) };
1134
+ }), ...(block.attrs.show_triggered_by === true ? { showTriggeredBy: true } : {})
1135
+ };
785
1136
  }
786
1137
  case "recordCreate":
787
1138
  case "recordUpdate":
@@ -796,9 +1147,13 @@ function triggerFromBlock(block, ctx) {
796
1147
  throw new EntityTfError("conversation trigger requires conversation_type");
797
1148
  return { kind, app, conversationType: block.attrs.conversation_type };
798
1149
  case "webhook":
1150
+ // ei's export only reliably emits `authenticated` when it can (see
1151
+ // cmd/elementum/export/hcl_trigger.go) - a real captured stream can
1152
+ // still omit the key, so default to false rather than requiring it
1153
+ // (edk#557, same asymmetry as approval-chain's approveButton, #325).
799
1154
  return {
800
1155
  kind,
801
- ...(typeof block.attrs.authenticated === "boolean" ? { authenticated: block.attrs.authenticated } : {}),
1156
+ authenticated: typeof block.attrs.authenticated === "boolean" ? block.attrs.authenticated : false,
802
1157
  ...(block.attrs.custom_response !== undefined ? { customResponse: decodeCustomResponse(block.attrs.custom_response, ctx) } : {}),
803
1158
  };
804
1159
  case "approvalProcessStatusUpdated": {
@@ -846,42 +1201,21 @@ function taskArgs(block, factory, ctx) {
846
1201
  if (!Array.isArray(value))
847
1202
  throw new EntityTfError(`${block.type}.${block.label}: fields must be an array`);
848
1203
  const values = {};
849
- const unresolvable = [];
850
1204
  for (const item of value) {
851
1205
  if (!isObject(item) || item.field_id === undefined)
852
1206
  throw new EntityTfError(`${block.type}.${block.label}: invalid field assignment`);
853
1207
  const field = fieldRef(item.field_id, ctx);
854
- // Unlike an orphaned TRIGGER record-path field ref (which degrades
855
- // gracefully - see decodeReferenceString), an unresolved field_id
856
- // here means ei's own export couldn't resolve the field either (most
857
- // commonly: a createRecord/updateField task targets a FOREIGN app via
858
- // object_id, and `--recursive=false` never discovers that app's
859
- // fields at all). ei's raw export still writes a bare field_id string
860
- // plus an unresolved-value placeholder (with its own "Unresolved
861
- // value references" warning) - the live platform's Read() resolves
862
- // the real field fine (it exists), so that placeholder permanently
863
- // mismatches state on every plan. Nothing on the TS side can fix a
864
- // gap in ei's own export scope, so - confirmed live against
865
- // demoapptwo's "Create record app external" automation, whose target
866
- // field lives on a different app - throw (same as any other
867
- // unreconstructable reference) so the automation's full graph is
868
- // excluded from adoption via automationOwnedAddresses, rather than
869
- // permanently failing the adoption gate for the whole app. A
870
- // foreign-target task typically has EVERY field assignment
871
- // unresolvable for the same reason (confirmed live:
872
- // conciergeforfield's cff_analyze_agent_performance_v3 has 13) - collect
873
- // them all before throwing instead of stopping at the first, so the
874
- // message doesn't look like a single-field fluke (#285).
875
- if (field.kind !== "field") {
876
- unresolvable.push(field.kind === "unresolved" ? field.uuid : "unknown");
877
- continue;
878
- }
879
- values[field.fieldKey] = decodeValue(item.value, ctx);
880
- }
881
- if (unresolvable.length > 0) {
882
- throw new EntityTfError(`${block.type}.${block.label}: ${unresolvable.length} field assignment${unresolvable.length === 1 ? "" : "s"} ` +
883
- `reference${unresolvable.length === 1 ? "s" : ""} an unresolvable field (${unresolvable.join(", ")}) — ` +
884
- `likely a foreign object_id target the export didn't recursively discover (--recursive=false)`);
1208
+ // Non-recursive exports preserve a real foreign target as
1209
+ // data.elementum_app/element, but its field assignments are bare ids
1210
+ // because the target's fields were not exported. Keep the automation
1211
+ // extractable and mark only those field keys as unresolved. The
1212
+ // printer makes the non-portability explicit with unsafePlatformId;
1213
+ // `--with-dependencies` pulls the target and the second extraction
1214
+ // pass upgrades these ids through foreignFieldRefsById to typed refs.
1215
+ const fieldKey = field.kind === "field"
1216
+ ? field.fieldKey
1217
+ : `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
1218
+ values[fieldKey] = decodeFieldAssignmentValue(item.value, ctx);
885
1219
  }
886
1220
  args.values = values;
887
1221
  continue;
@@ -931,15 +1265,53 @@ function taskArgs(block, factory, ctx) {
931
1265
  });
932
1266
  continue;
933
1267
  }
1268
+ // `file_reader_id` resolves to a real `documentModel` RefExpr only
1269
+ // through decodeValue's resource-attr branch (an implemented reader
1270
+ // type's own resource block in this export). When ei instead emits a
1271
+ // bare platform id — an unimplemented reader type (ai/xml, per
1272
+ // `IMPLEMENTED_FILE_READER_RESOURCE_TYPES`) or a dangling/foreign file
1273
+ // reader this export never discovered — decodeValue's generic fallback
1274
+ // would otherwise wrap it as a plain `{kind: "literal"}` string, which
1275
+ // the printer emits as a bare string literal where readFile's `fileReader`
1276
+ // option requires a `FileReaderCatalogRef` object, failing tsc on the
1277
+ // generated file (edk#483). Route it through the same `unresolved`
1278
+ // escape hatch already used for other unreconstructable references
1279
+ // (`"<uuid>" as any /* TODO: ... */`) instead.
1280
+ if (attr === "file_reader_id" && factory === "documentModel") {
1281
+ const decoded = decodeValue(value, ctx);
1282
+ args.documentModel =
1283
+ typeof decoded === "object" && decoded !== null && decoded.kind === "documentModel"
1284
+ ? decoded
1285
+ : { kind: "unresolved", uuid: typeof value === "string" ? value : JSON.stringify(value), hint: "file reader" };
1286
+ continue;
1287
+ }
934
1288
  if (attr === "calculations" && factory === "calculation") {
935
1289
  if (!Array.isArray(value))
936
1290
  throw new EntityTfError("calculations must be an array");
937
- args.calculations = value.map((item) => {
1291
+ args.values = Object.fromEntries(value.map((item) => {
938
1292
  if (!isObject(item) || typeof item.variable_name !== "string" || item.formula === undefined) {
939
1293
  throw new EntityTfError(`${block.type}.${block.label}: invalid calculation entry`);
940
1294
  }
941
- return { name: item.variable_name, expression: decodeCalculationFormula(item.formula, ctx) };
942
- });
1295
+ const decodedExpression = decodeCalculationFormula(item.formula, ctx);
1296
+ const expression = isObject(decodedExpression) && decodedExpression.kind === "literal"
1297
+ ? pulledRawCalculation(item.formula, item.output_type, item.multiple) ?? decodedExpression
1298
+ : decodedExpression;
1299
+ const include = item.include_type === "MANUAL" ? "manual"
1300
+ : item.include_type === "BOTH" ? "both"
1301
+ : item.include_type === "PICKLIST" && item.picklist_field_id !== undefined
1302
+ ? { picklist: fieldRef(item.picklist_field_id, ctx) ?? decodeValue(item.picklist_field_id, ctx) }
1303
+ : undefined;
1304
+ if (item.id !== undefined && typeof item.id !== "string") {
1305
+ throw new EntityTfError(`${block.type}.${block.label}: calculation entry id must be a string`);
1306
+ }
1307
+ const advanced = item.id !== undefined || item.record_id !== undefined || include !== undefined;
1308
+ return [item.variable_name, advanced ? {
1309
+ expression,
1310
+ ...(typeof item.id === "string" ? { id: item.id } : {}),
1311
+ ...(item.record_id !== undefined ? { record: decodeValue(item.record_id, ctx) } : {}),
1312
+ ...(include !== undefined ? { include } : {}),
1313
+ } : expression];
1314
+ }));
943
1315
  continue;
944
1316
  }
945
1317
  if (attr === "categories" && factory === "aiClassify") {
@@ -958,6 +1330,15 @@ function taskArgs(block, factory, ctx) {
958
1330
  };
959
1331
  continue;
960
1332
  }
1333
+ if (attr === "table_id" && factory === "tableRecordsSearch") {
1334
+ const foreign = typeof value === "string" ? ctx.foreignTableRefsById?.get(value) : undefined;
1335
+ args.table = foreign !== undefined
1336
+ ? { kind: "table", tableHandle: foreign.tableRefName, name: foreign.name }
1337
+ : typeof value === "string"
1338
+ ? { kind: "unresolved", uuid: value, hint: "table" }
1339
+ : decodeValue(value, ctx);
1340
+ continue;
1341
+ }
961
1342
  if (attr === "list" && factory === "forEach") {
962
1343
  args.collection = decodeValue(value, ctx);
963
1344
  continue;
@@ -1198,8 +1579,31 @@ export function automationOwnedAddresses(doc, automationLabel) {
1198
1579
  }
1199
1580
  return [...owned];
1200
1581
  }
1582
+ /** Bridge metadata for required values that GraphQL could not reconstruct. */
1583
+ function unresolvedAuthoringValues(doc) {
1584
+ const values = [];
1585
+ for (const block of doc.blocks) {
1586
+ if (block.kind !== "locals")
1587
+ continue;
1588
+ for (const [key, payload] of Object.entries(block.attrs)) {
1589
+ if (!key.startsWith("edk_unresolved_authoring_") || typeof payload !== "string")
1590
+ continue;
1591
+ try {
1592
+ const parsed = JSON.parse(payload);
1593
+ if (typeof parsed.resource === "string" && typeof parsed.field === "string" && typeof parsed.reason === "string") {
1594
+ values.push({ resource: parsed.resource, field: parsed.field, reason: parsed.reason });
1595
+ }
1596
+ }
1597
+ catch {
1598
+ // Malformed bridge metadata is ignored here. The ordinary extractor
1599
+ // validation still handles the underlying resource shape.
1600
+ }
1601
+ }
1602
+ }
1603
+ return values;
1604
+ }
1201
1605
  /** Extract one app-owned automation graph from an ei app export. */
1202
- function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById) {
1606
+ function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames) {
1203
1607
  const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
1204
1608
  if (automation === undefined)
1205
1609
  throw new EntityTfError(`automation resource "${automationLabel}" not found`);
@@ -1246,6 +1650,17 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
1246
1650
  }
1247
1651
  const tasks = taskCandidates.filter((block) => owned.has(`${block.type}.${block.label}`));
1248
1652
  const ownedBranches = branches.filter((block) => owned.has(`${block.type}.${block.label}`));
1653
+ // A required value that the bridge could not reconstruct is not a literal
1654
+ // empty string. Exclude the whole automation graph from authoring/adoption,
1655
+ // just as we already do for an unresolvable field_id. Otherwise resolving
1656
+ // the foreign field through a direct catalog accidentally turns the bridge's
1657
+ // `value = ""` placeholder into managed configuration and adoption plans a
1658
+ // live null -> "" update.
1659
+ const unresolved = unresolvedAuthoringValues(doc).find(({ resource }) => owned.has(resource));
1660
+ if (unresolved !== undefined) {
1661
+ throw new EntityTfError(`${unresolved.resource}.${unresolved.field}: ${unresolved.reason}; ` +
1662
+ "the automation is excluded because no safe authored value or UUID fallback is available");
1663
+ }
1249
1664
  tasks.forEach((block) => assertAllowed(block, TASK_ATTRIBUTES));
1250
1665
  ownedBranches.forEach((block) => assertAllowed(block, BRANCH_ATTRIBUTES));
1251
1666
  const publishDependencies = Array.isArray(publish?.attrs.depends_on)
@@ -1288,6 +1703,12 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
1288
1703
  }
1289
1704
  const appTfLabel = app.label;
1290
1705
  const taskByAddress = new Map(tasks.map((block) => [`${block.type}.${block.label}`, { block, refKey: taskRefKey(block, automationLabel, appTfLabel) }]));
1706
+ const taskTargetOwnerRefNameByAddress = new Map();
1707
+ for (const [address, { block }] of taskByAddress) {
1708
+ const ownerRefName = aspectOwnerRefNameFromObjectId(block.attrs.object_id, appRefName, appTfLabel);
1709
+ if (ownerRefName !== undefined)
1710
+ taskTargetOwnerRefNameByAddress.set(address, ownerRefName);
1711
+ }
1291
1712
  const resourceImportIds = new Map();
1292
1713
  for (const block of doc.blocks) {
1293
1714
  if (block.kind !== "import" || typeof block.attrs.id !== "string")
@@ -1329,6 +1750,13 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
1329
1750
  fieldById,
1330
1751
  stagesByKey,
1331
1752
  ...(foreignFieldRefsById !== undefined && { foreignFieldRefsById }),
1753
+ ...(foreignFieldRefsByDataAddress !== undefined && { foreignFieldRefsByDataAddress }),
1754
+ ...(foreignTableRefsById !== undefined && { foreignTableRefsById }),
1755
+ ...(picklistOptionLabelById !== undefined && { picklistOptionLabelById }),
1756
+ ...(fieldNamesByOwnerRefName !== undefined && { fieldNamesByOwnerRefName }),
1757
+ ...(taskTargetOwnerRefNameByAddress.size > 0 && { taskTargetOwnerRefNameByAddress }),
1758
+ ...(foreignAppRefNames !== undefined && { foreignAppRefNames }),
1759
+ ...(foreignElementRefNames !== undefined && { foreignElementRefNames }),
1332
1760
  };
1333
1761
  let serviceAccountName;
1334
1762
  const serviceAccountValue = automation.attrs.service_account_id;
@@ -1437,7 +1865,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
1437
1865
  tfLabel: automationLabel, ast, blocks: [automation, trigger, ...tasks, ...ownedBranches, ...(publish ? [publish] : [])]
1438
1866
  };
1439
1867
  }
1440
- export function automationFromTf(first, second, third, fourth) {
1868
+ export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth) {
1441
1869
  if (Array.isArray(first)) {
1442
1870
  const ctx = second;
1443
1871
  const automationBlock = first.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE);
@@ -1445,7 +1873,9 @@ export function automationFromTf(first, second, third, fourth) {
1445
1873
  return { skippedReason: "automation resource not found" };
1446
1874
  }
1447
1875
  try {
1448
- return { automation: automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle).ast };
1876
+ return {
1877
+ automation: automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames).ast,
1878
+ };
1449
1879
  }
1450
1880
  catch (err) {
1451
1881
  const message = err instanceof Error ? err.message : String(err);
@@ -1453,5 +1883,5 @@ export function automationFromTf(first, second, third, fourth) {
1453
1883
  return { skippedReason: message };
1454
1884
  }
1455
1885
  }
1456
- return automationFromTfDocument(first, second, third ?? "", fourth);
1886
+ return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth);
1457
1887
  }