@elementumai/edk 0.8.2-alpha.6 → 0.9.2

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 (372) hide show
  1. package/README.md +18 -14
  2. package/dist-sdk/elementum-entity-client/clients/agents/models/agent-tool.d.ts +3 -3
  3. package/dist-sdk/elementum-entity-client/clients/aspects/models/index.d.ts +1 -1
  4. package/dist-sdk/elementum-entity-client/clients/aspects/models/picklist-config.d.ts +3 -11
  5. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +2 -10
  6. package/dist-sdk/elementum-entity-client/clients/skills/models/skill-tool.d.ts +1 -1
  7. package/dist-sdk/fs/entity.d.ts +2 -2
  8. package/dist-sdk/fs/entity.js +1 -1
  9. package/dist-sdk/pull/missing-report.d.ts +81 -0
  10. package/dist-sdk/pull/missing-report.js +52 -0
  11. package/dist-sdk/src/catalog/factories.d.ts +53 -19
  12. package/dist-sdk/src/catalog/factories.js +51 -12
  13. package/dist-sdk/src/catalog/from-authoring.js +13 -3
  14. package/dist-sdk/src/catalog/index.d.ts +2 -2
  15. package/dist-sdk/src/catalog/index.js +1 -1
  16. package/dist-sdk/src/catalog/org.js +1 -0
  17. package/dist-sdk/src/catalog/render.js +6 -0
  18. package/dist-sdk/src/catalog/token.js +7 -0
  19. package/dist-sdk/src/catalog/types.d.ts +34 -23
  20. package/dist-sdk/src/catalog/types.js +7 -4
  21. package/dist-sdk/src/core/app-to-ui.d.ts +6 -6
  22. package/dist-sdk/src/core/app-to-ui.js +7 -9
  23. package/dist-sdk/src/core/index.d.ts +1 -0
  24. package/dist-sdk/src/core/index.js +1 -0
  25. package/dist-sdk/src/core/platform-id.d.ts +11 -0
  26. package/dist-sdk/src/core/platform-id.js +8 -0
  27. package/dist-sdk/src/{entities/flow/activities/render-catalog.d.ts → core/render-tree.d.ts} +2 -2
  28. package/dist-sdk/src/{entities/flow/activities/render-catalog.js → core/render-tree.js} +6 -8
  29. package/dist-sdk/src/core/types/app.d.ts +13 -23
  30. package/dist-sdk/src/core/types/app.js +0 -1
  31. package/dist-sdk/src/engine/build/context.d.ts +3 -3
  32. package/dist-sdk/src/engine/pull/attrs.d.ts +4 -0
  33. package/dist-sdk/src/engine/pull/attrs.js +17 -0
  34. package/dist-sdk/src/engine/pull/context.d.ts +39 -0
  35. package/dist-sdk/src/engine/pull/org.d.ts +1 -0
  36. package/dist-sdk/src/engine/pull/org.js +2 -0
  37. package/dist-sdk/src/engine/tf/expr.d.ts +1 -1
  38. package/dist-sdk/src/engine/tf/expr.js +10 -3
  39. package/dist-sdk/src/engine/workspace/authoring-layout.js +4 -2
  40. package/dist-sdk/src/entities/access-policy/build.d.ts +4 -13
  41. package/dist-sdk/src/entities/access-policy/build.js +1 -1
  42. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +12 -38
  43. package/dist-sdk/src/entities/access-policy/from-tf.js +16 -74
  44. package/dist-sdk/src/entities/access-policy/principal.d.ts +29 -0
  45. package/dist-sdk/src/entities/access-policy/principal.js +13 -0
  46. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +20 -5
  47. package/dist-sdk/src/entities/access-policy/to-tf.js +26 -54
  48. package/dist-sdk/src/entities/agent/build.d.ts +39 -8
  49. package/dist-sdk/src/entities/agent/build.js +36 -15
  50. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +5 -0
  51. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +121 -36
  52. package/dist-sdk/src/entities/agent/from-tf.js +5 -8
  53. package/dist-sdk/src/entities/agent/index.d.ts +5 -2
  54. package/dist-sdk/src/entities/agent/index.js +4 -2
  55. package/dist-sdk/src/entities/agent/module.js +5 -2
  56. package/dist-sdk/src/entities/agent/run-as.d.ts +16 -0
  57. package/dist-sdk/src/entities/agent/run-as.js +1 -0
  58. package/dist-sdk/src/entities/agent/to-tf.d.ts +2 -1
  59. package/dist-sdk/src/entities/agent/to-tf.js +2 -1
  60. package/dist-sdk/src/entities/agent/tools.d.ts +60 -48
  61. package/dist-sdk/src/entities/agent/tools.js +44 -38
  62. package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +1 -1
  63. package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +4 -4
  64. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +17 -8
  65. package/dist-sdk/src/entities/agent-tool/from-tf.js +127 -37
  66. package/dist-sdk/src/entities/agent-tool/module.js +6 -0
  67. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +5 -5
  68. package/dist-sdk/src/entities/agent-tool/to-tf.js +93 -20
  69. package/dist-sdk/src/entities/agent-tool/types.d.ts +4 -5
  70. package/dist-sdk/src/entities/agent-tool/types.js +36 -8
  71. package/dist-sdk/src/entities/app/build.d.ts +137 -25
  72. package/dist-sdk/src/entities/app/build.js +104 -53
  73. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +173 -1
  74. package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +59 -0
  75. package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +68 -0
  76. package/dist-sdk/src/entities/app/display-blocks.d.ts +2 -1
  77. package/dist-sdk/src/entities/app/display-blocks.js +1 -1
  78. package/dist-sdk/src/entities/app/from-tf.d.ts +11 -1
  79. package/dist-sdk/src/entities/app/from-tf.js +30 -2
  80. package/dist-sdk/src/entities/app/index.d.ts +13 -4
  81. package/dist-sdk/src/entities/app/index.js +8 -1
  82. package/dist-sdk/src/entities/app/module.js +27 -2
  83. package/dist-sdk/src/entities/app/to-tf.js +75 -1
  84. package/dist-sdk/src/entities/approval-chain/build.d.ts +31 -16
  85. package/dist-sdk/src/entities/approval-chain/build.js +49 -49
  86. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +17 -0
  87. package/dist-sdk/src/entities/approval-chain/from-tf.js +57 -0
  88. package/dist-sdk/src/entities/approval-chain/index.d.ts +2 -3
  89. package/dist-sdk/src/entities/approval-chain/index.js +2 -3
  90. package/dist-sdk/src/entities/approval-chain/module.d.ts +3 -0
  91. package/dist-sdk/src/entities/approval-chain/module.js +51 -0
  92. package/dist-sdk/src/entities/approval-chain/printer.d.ts +2 -0
  93. package/dist-sdk/src/entities/approval-chain/printer.js +21 -0
  94. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +9 -0
  95. package/dist-sdk/src/entities/approval-chain/to-tf.js +43 -0
  96. package/dist-sdk/src/entities/automation/build.d.ts +10 -6
  97. package/dist-sdk/src/entities/automation/build.js +5 -4
  98. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +10 -8
  99. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +51 -114
  100. package/dist-sdk/src/entities/automation/filter.d.ts +1 -115
  101. package/dist-sdk/src/entities/automation/filter.js +1 -197
  102. package/dist-sdk/src/entities/automation/from-tf.d.ts +4 -0
  103. package/dist-sdk/src/entities/automation/from-tf.js +202 -119
  104. package/dist-sdk/src/entities/automation/index.d.ts +4 -2
  105. package/dist-sdk/src/entities/automation/index.js +3 -1
  106. package/dist-sdk/src/entities/automation/module.js +10 -4
  107. package/dist-sdk/src/entities/automation/script-code.js +94 -6
  108. package/dist-sdk/src/entities/automation/tasks.d.ts +20 -19
  109. package/dist-sdk/src/entities/automation/tasks.js +2 -2
  110. package/dist-sdk/src/entities/automation/to-tf.d.ts +34 -2
  111. package/dist-sdk/src/entities/automation/to-tf.js +273 -98
  112. package/dist-sdk/src/entities/automation/triggers.d.ts +18 -17
  113. package/dist-sdk/src/entities/automation/triggers.js +1 -1
  114. package/dist-sdk/src/entities/dashboard/build.d.ts +17 -0
  115. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +12 -0
  116. package/dist-sdk/src/entities/dashboard/from-tf.js +95 -0
  117. package/dist-sdk/src/entities/dashboard/module.d.ts +3 -0
  118. package/dist-sdk/src/entities/dashboard/module.js +16 -0
  119. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +30 -0
  120. package/dist-sdk/src/entities/dashboard/to-tf.js +94 -0
  121. package/dist-sdk/src/entities/dashboard-widget/module.d.ts +3 -0
  122. package/dist-sdk/src/entities/dashboard-widget/module.js +10 -0
  123. package/dist-sdk/src/entities/data-lookup/module.d.ts +3 -0
  124. package/dist-sdk/src/entities/data-lookup/module.js +22 -0
  125. package/dist-sdk/src/entities/datamine/build.d.ts +22 -0
  126. package/dist-sdk/src/entities/datamine/build.js +1 -0
  127. package/dist-sdk/src/entities/datamine/from-tf.d.ts +17 -0
  128. package/dist-sdk/src/entities/datamine/from-tf.js +98 -0
  129. package/dist-sdk/src/entities/datamine/module.d.ts +3 -0
  130. package/dist-sdk/src/entities/datamine/module.js +23 -0
  131. package/dist-sdk/src/entities/datamine/to-tf.d.ts +11 -0
  132. package/dist-sdk/src/entities/datamine/to-tf.js +53 -0
  133. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +303 -0
  134. package/dist-sdk/src/entities/dynamic-layout/build.js +4 -0
  135. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
  136. package/dist-sdk/src/entities/dynamic-layout/dialect.js +9 -0
  137. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +10 -0
  138. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +233 -0
  139. package/dist-sdk/src/entities/dynamic-layout/module.d.ts +3 -0
  140. package/dist-sdk/src/entities/dynamic-layout/module.js +13 -0
  141. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +26 -0
  142. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +267 -0
  143. package/dist-sdk/src/entities/element/build.d.ts +31 -14
  144. package/dist-sdk/src/entities/element/build.js +12 -4
  145. package/dist-sdk/src/entities/element/from-tf.d.ts +9 -1
  146. package/dist-sdk/src/entities/element/from-tf.js +31 -2
  147. package/dist-sdk/src/entities/element/index.d.ts +8 -3
  148. package/dist-sdk/src/entities/element/index.js +4 -1
  149. package/dist-sdk/src/entities/element/module.js +19 -2
  150. package/dist-sdk/src/entities/element/to-tf.js +57 -1
  151. package/dist-sdk/src/entities/field/build.d.ts +4 -3
  152. package/dist-sdk/src/entities/field/calculation-types.d.ts +6 -0
  153. package/dist-sdk/src/entities/field/calculation-types.js +42 -0
  154. package/dist-sdk/src/entities/field/from-tf.js +90 -11
  155. package/dist-sdk/src/entities/field/module.d.ts +1 -0
  156. package/dist-sdk/src/entities/field/module.js +5 -2
  157. package/dist-sdk/src/entities/field/record-shape.d.ts +1 -1
  158. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  159. package/dist-sdk/src/entities/field/to-tf.js +22 -6
  160. package/dist-sdk/src/entities/field/types.js +3 -0
  161. package/dist-sdk/src/entities/file-reader/build.d.ts +66 -19
  162. package/dist-sdk/src/entities/file-reader/build.js +49 -4
  163. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +1 -0
  164. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +11 -9
  165. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +1 -1
  166. package/dist-sdk/src/entities/file-reader/from-tf.js +31 -2
  167. package/dist-sdk/src/entities/file-reader/index.d.ts +3 -3
  168. package/dist-sdk/src/entities/file-reader/index.js +3 -3
  169. package/dist-sdk/src/entities/file-reader/module.js +6 -5
  170. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +1 -1
  171. package/dist-sdk/src/entities/file-reader/to-tf.js +5 -2
  172. package/dist-sdk/src/entities/file-reader/types.d.ts +3 -4
  173. package/dist-sdk/src/entities/file-reader/types.js +4 -5
  174. package/dist-sdk/src/entities/org/category.js +4 -5
  175. package/dist-sdk/src/entities/org/group.js +4 -5
  176. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  177. package/dist-sdk/src/entities/org/index.js +1 -0
  178. package/dist-sdk/src/entities/org/phone-provider.d.ts +4 -0
  179. package/dist-sdk/src/entities/org/phone-provider.js +33 -0
  180. package/dist-sdk/src/entities/org/role.d.ts +3 -3
  181. package/dist-sdk/src/entities/org/role.js +9 -6
  182. package/dist-sdk/src/entities/organization/build.d.ts +29 -0
  183. package/dist-sdk/src/entities/organization/build.js +24 -0
  184. package/dist-sdk/src/entities/organization/index.d.ts +2 -0
  185. package/dist-sdk/src/entities/organization/index.js +2 -0
  186. package/dist-sdk/src/entities/organization/module.d.ts +2 -0
  187. package/dist-sdk/src/entities/organization/module.js +18 -0
  188. package/dist-sdk/src/entities/organization/to-tf.d.ts +6 -0
  189. package/dist-sdk/src/entities/organization/to-tf.js +37 -0
  190. package/dist-sdk/src/entities/phone-service/build.d.ts +17 -0
  191. package/dist-sdk/src/entities/phone-service/build.js +31 -0
  192. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.d.ts +4 -0
  193. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +54 -0
  194. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +25 -0
  195. package/dist-sdk/src/entities/phone-service/from-tf.js +75 -0
  196. package/dist-sdk/src/entities/phone-service/index.d.ts +2 -0
  197. package/dist-sdk/src/entities/phone-service/index.js +2 -0
  198. package/dist-sdk/src/entities/phone-service/module.d.ts +3 -0
  199. package/dist-sdk/src/entities/phone-service/module.js +55 -0
  200. package/dist-sdk/src/entities/phone-service/to-tf.d.ts +12 -0
  201. package/dist-sdk/src/entities/phone-service/to-tf.js +54 -0
  202. package/dist-sdk/src/entities/phone-service/types.d.ts +35 -0
  203. package/dist-sdk/src/entities/phone-service/types.js +22 -0
  204. package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +11 -0
  205. package/dist-sdk/src/entities/record-create-form/from-tf.js +74 -0
  206. package/dist-sdk/src/entities/record-create-form/module.d.ts +11 -0
  207. package/dist-sdk/src/entities/record-create-form/module.js +24 -0
  208. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +33 -0
  209. package/dist-sdk/src/entities/record-create-form/to-tf.js +80 -0
  210. package/dist-sdk/src/entities/relationship/build.d.ts +16 -0
  211. package/dist-sdk/src/entities/relationship/build.js +1 -0
  212. package/dist-sdk/src/entities/relationship/from-tf.d.ts +12 -0
  213. package/dist-sdk/src/entities/relationship/from-tf.js +109 -0
  214. package/dist-sdk/src/entities/relationship/module.d.ts +3 -0
  215. package/dist-sdk/src/entities/relationship/module.js +16 -0
  216. package/dist-sdk/src/entities/relationship/to-tf.d.ts +31 -0
  217. package/dist-sdk/src/entities/relationship/to-tf.js +153 -0
  218. package/dist-sdk/src/entities/role/build.d.ts +65 -0
  219. package/dist-sdk/src/entities/role/build.js +33 -0
  220. package/dist-sdk/src/entities/role/from-tf.d.ts +13 -0
  221. package/dist-sdk/src/entities/role/from-tf.js +138 -0
  222. package/dist-sdk/src/entities/role/to-tf.d.ts +13 -0
  223. package/dist-sdk/src/entities/role/to-tf.js +69 -0
  224. package/dist-sdk/src/entities/search-table/build.d.ts +67 -28
  225. package/dist-sdk/src/entities/search-table/build.js +110 -56
  226. package/dist-sdk/src/entities/search-table/from-tf.d.ts +37 -0
  227. package/dist-sdk/src/entities/search-table/from-tf.js +113 -0
  228. package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
  229. package/dist-sdk/src/entities/search-table/index.js +2 -2
  230. package/dist-sdk/src/entities/search-table/module.js +88 -10
  231. package/dist-sdk/src/entities/search-table/printer.d.ts +2 -0
  232. package/dist-sdk/src/entities/search-table/printer.js +52 -0
  233. package/dist-sdk/src/entities/search-table/to-tf.d.ts +14 -0
  234. package/dist-sdk/src/entities/search-table/to-tf.js +104 -0
  235. package/dist-sdk/src/entities/search-table/types.d.ts +8 -0
  236. package/dist-sdk/src/entities/search-table/types.js +21 -0
  237. package/dist-sdk/src/entities/service-account/build.d.ts +32 -0
  238. package/dist-sdk/src/entities/service-account/build.js +9 -0
  239. package/dist-sdk/src/entities/service-account/from-tf.d.ts +10 -0
  240. package/dist-sdk/src/entities/service-account/from-tf.js +109 -0
  241. package/dist-sdk/src/entities/service-account/module.d.ts +4 -0
  242. package/dist-sdk/src/entities/service-account/module.js +21 -0
  243. package/dist-sdk/src/entities/service-account/ref.d.ts +11 -0
  244. package/dist-sdk/src/entities/service-account/ref.js +5 -0
  245. package/dist-sdk/src/entities/service-account/to-tf.d.ts +11 -0
  246. package/dist-sdk/src/entities/service-account/to-tf.js +72 -0
  247. package/dist-sdk/src/entities/shared/connector-from-tf.d.ts +14 -0
  248. package/dist-sdk/src/entities/shared/connector-from-tf.js +14 -0
  249. package/dist-sdk/src/entities/shared/filters/ast.d.ts +21 -79
  250. package/dist-sdk/src/entities/shared/filters/ast.js +5 -2
  251. package/dist-sdk/src/entities/shared/filters/index.d.ts +94 -206
  252. package/dist-sdk/src/entities/shared/filters/index.js +189 -341
  253. package/dist-sdk/src/entities/shared/filters/print.d.ts +11 -0
  254. package/dist-sdk/src/entities/shared/filters/print.js +122 -0
  255. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +170 -0
  256. package/dist-sdk/src/entities/shared/filters/tf-codec.js +527 -0
  257. package/dist-sdk/src/entities/shared/filters/types.d.ts +66 -69
  258. package/dist-sdk/src/entities/shared/filters/types.js +2 -3
  259. package/dist-sdk/src/entities/skill/build.d.ts +2 -2
  260. package/dist-sdk/src/entities/skill/build.js +4 -3
  261. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +10 -0
  262. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +74 -32
  263. package/dist-sdk/src/entities/skill/index.d.ts +2 -1
  264. package/dist-sdk/src/entities/skill/index.js +2 -1
  265. package/dist-sdk/src/entities/skill/module.js +6 -0
  266. package/dist-sdk/src/entities/skill/to-tf.d.ts +5 -1
  267. package/dist-sdk/src/entities/skill/to-tf.js +18 -0
  268. package/dist-sdk/src/entities/skill/tools.d.ts +46 -31
  269. package/dist-sdk/src/entities/skill/tools.js +33 -20
  270. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -1
  271. package/dist-sdk/src/entities/skill-tool/from-tf.js +76 -8
  272. package/dist-sdk/src/entities/skill-tool/module.js +9 -0
  273. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
  274. package/dist-sdk/src/entities/skill-tool/to-tf.js +94 -42
  275. package/dist-sdk/src/entities/skill-tool/types.js +18 -1
  276. package/dist-sdk/src/entities/table/build.d.ts +64 -23
  277. package/dist-sdk/src/entities/table/build.js +33 -18
  278. package/dist-sdk/src/entities/table/catalog-render.js +6 -0
  279. package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +99 -0
  280. package/dist-sdk/src/entities/table/deserializer/normalize.js +192 -0
  281. package/dist-sdk/src/entities/table/fields/types.d.ts +86 -0
  282. package/dist-sdk/src/entities/table/fields/types.js +12 -0
  283. package/dist-sdk/src/entities/table/fields.d.ts +107 -47
  284. package/dist-sdk/src/entities/table/fields.js +76 -55
  285. package/dist-sdk/src/entities/table/from-tf.d.ts +4 -0
  286. package/dist-sdk/src/entities/table/from-tf.js +261 -0
  287. package/dist-sdk/src/entities/table/index.d.ts +7 -5
  288. package/dist-sdk/src/entities/table/index.js +7 -7
  289. package/dist-sdk/src/entities/table/joins.d.ts +22 -9
  290. package/dist-sdk/src/entities/table/joins.js +8 -16
  291. package/dist-sdk/src/entities/table/module.d.ts +2 -1
  292. package/dist-sdk/src/entities/table/module.js +13 -6
  293. package/dist-sdk/src/entities/table/to-tf.d.ts +10 -0
  294. package/dist-sdk/src/entities/table/to-tf.js +230 -0
  295. package/dist-sdk/src/entities/task/build.d.ts +43 -0
  296. package/dist-sdk/src/entities/task/build.js +17 -0
  297. package/dist-sdk/src/entities/task/from-tf.d.ts +28 -0
  298. package/dist-sdk/src/entities/task/from-tf.js +38 -0
  299. package/dist-sdk/src/entities/task/index.d.ts +1 -0
  300. package/dist-sdk/src/entities/task/index.js +1 -0
  301. package/dist-sdk/src/entities/task/module.d.ts +3 -0
  302. package/dist-sdk/src/entities/task/module.js +12 -0
  303. package/dist-sdk/src/entities/task/to-tf.d.ts +9 -0
  304. package/dist-sdk/src/entities/task/to-tf.js +49 -0
  305. package/dist-sdk/src/entities/view/from-tf.d.ts +7 -2
  306. package/dist-sdk/src/entities/view/from-tf.js +209 -25
  307. package/dist-sdk/src/entities/view/module.js +5 -1
  308. package/dist-sdk/src/entities/view/to-tf.d.ts +49 -7
  309. package/dist-sdk/src/entities/view/to-tf.js +155 -18
  310. package/dist-sdk/src/entities/view/types.d.ts +8 -0
  311. package/dist-sdk/src/entities/view/types.js +43 -0
  312. package/dist-sdk/src/entities/visual-flow/build.d.ts +87 -0
  313. package/dist-sdk/src/entities/visual-flow/build.js +72 -0
  314. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +49 -0
  315. package/dist-sdk/src/entities/visual-flow/from-tf.js +124 -0
  316. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -0
  317. package/dist-sdk/src/entities/visual-flow/index.js +1 -0
  318. package/dist-sdk/src/entities/visual-flow/module.d.ts +3 -0
  319. package/dist-sdk/src/entities/visual-flow/module.js +41 -0
  320. package/dist-sdk/src/entities/visual-flow/printer.d.ts +8 -0
  321. package/dist-sdk/src/entities/visual-flow/printer.js +92 -0
  322. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +14 -0
  323. package/dist-sdk/src/entities/visual-flow/to-tf.js +101 -0
  324. package/dist-sdk/src/entities/widget/build.d.ts +55 -0
  325. package/dist-sdk/src/entities/widget/build.js +1 -0
  326. package/dist-sdk/src/entities/widget/from-tf.d.ts +11 -0
  327. package/dist-sdk/src/entities/widget/from-tf.js +209 -0
  328. package/dist-sdk/src/entities/widget/module.d.ts +3 -0
  329. package/dist-sdk/src/entities/widget/module.js +16 -0
  330. package/dist-sdk/src/entities/widget/to-tf.d.ts +44 -0
  331. package/dist-sdk/src/entities/widget/to-tf.js +204 -0
  332. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +1 -1
  333. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -1
  334. package/dist-sdk/src/graph/index.d.ts +7 -0
  335. package/dist-sdk/src/graph/index.js +4 -18
  336. package/dist-sdk/src/graph/modules.js +30 -1
  337. package/dist-sdk/src/graph/types.d.ts +55 -7
  338. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  339. package/dist-sdk/src/internal/sdk-package.js +4 -2
  340. package/package.json +30 -15
  341. package/dist-sdk/src/entities/access-policy/filter.d.ts +0 -61
  342. package/dist-sdk/src/entities/access-policy/filter.js +0 -83
  343. package/dist-sdk/src/entities/approval-chain/steps.d.ts +0 -24
  344. package/dist-sdk/src/entities/approval-chain/steps.js +0 -20
  345. package/dist-sdk/src/entities/flow/activities/agent.d.ts +0 -15
  346. package/dist-sdk/src/entities/flow/activities/agent.js +0 -29
  347. package/dist-sdk/src/entities/flow/activities/approval.d.ts +0 -9
  348. package/dist-sdk/src/entities/flow/activities/approval.js +0 -18
  349. package/dist-sdk/src/entities/flow/activities/automation.d.ts +0 -12
  350. package/dist-sdk/src/entities/flow/activities/automation.js +0 -22
  351. package/dist-sdk/src/entities/flow/activities/ctx.d.ts +0 -34
  352. package/dist-sdk/src/entities/flow/activities/ctx.js +0 -38
  353. package/dist-sdk/src/entities/flow/activities/form.d.ts +0 -22
  354. package/dist-sdk/src/entities/flow/activities/form.js +0 -36
  355. package/dist-sdk/src/entities/flow/activities/index.d.ts +0 -14
  356. package/dist-sdk/src/entities/flow/activities/index.js +0 -13
  357. package/dist-sdk/src/entities/flow/activities/input-refs.d.ts +0 -39
  358. package/dist-sdk/src/entities/flow/activities/input-refs.js +0 -19
  359. package/dist-sdk/src/entities/flow/activities/prompt-template.d.ts +0 -13
  360. package/dist-sdk/src/entities/flow/activities/prompt-template.js +0 -34
  361. package/dist-sdk/src/entities/flow/activities/types.d.ts +0 -33
  362. package/dist-sdk/src/entities/flow/build.d.ts +0 -38
  363. package/dist-sdk/src/entities/flow/build.js +0 -115
  364. package/dist-sdk/src/entities/flow/index.d.ts +0 -8
  365. package/dist-sdk/src/entities/flow/index.js +0 -7
  366. package/dist-sdk/src/entities/flow/serialize.d.ts +0 -51
  367. package/dist-sdk/src/entities/flow/serialize.js +0 -94
  368. package/dist-sdk/src/entities/flow/util.d.ts +0 -27
  369. package/dist-sdk/src/entities/flow/util.js +0 -38
  370. package/dist-sdk/src/entities/table/filter.d.ts +0 -41
  371. package/dist-sdk/src/entities/table/filter.js +0 -89
  372. /package/dist-sdk/src/entities/{flow/activities/types.js → dashboard/build.js} +0 -0
@@ -1,12 +1,26 @@
1
1
  import { EntityTfError } from "../../engine/entity.js";
2
2
  import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
3
- import { appResourceLabelPrefix, appScopedResourceLabel, expr, isTfExpr, isUuid, sanitizeName, snakeSlug, tsLabelToTfLabel, } from "../../engine/tf/index.js";
3
+ import { appResourceLabelPrefix, appScopedResourceLabel, expr, isTfExpr, isUuid, sanitizeName, scopedResourceLabel, snakeSlug, tsLabelToTfLabel, } from "../../engine/tf/index.js";
4
+ import { workspaceAspectKey } from "../../engine/build/context.js";
5
+ import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
6
+ import { fieldRefToTfValue } from "../field/to-tf.js";
7
+ import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
8
+ import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
4
9
  import { CONNECTOR_ORG_BAG } from "../org/connector.js";
5
10
  import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY } from "../file-reader/types.js";
6
11
  import { AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE } from "./types.js";
7
12
  function scopedLabel(appTfLabel, label) {
8
13
  return appScopedResourceLabel(appTfLabel, label);
9
14
  }
15
+ /** Stable, non-cryptographic suffix for collision-resistant Terraform labels. */
16
+ function labelHash(value) {
17
+ let hash = 0x811c9dc5;
18
+ for (let i = 0; i < value.length; i += 1) {
19
+ hash ^= value.charCodeAt(i);
20
+ hash = Math.imul(hash, 0x01000193);
21
+ }
22
+ return (hash >>> 0).toString(36);
23
+ }
10
24
  function scopedOptionLocalName(localName, owner) {
11
25
  for (const suffix of ["_options_by_label", "_option_ids_by_label"]) {
12
26
  if (!localName.endsWith(suffix))
@@ -123,6 +137,8 @@ const CONFIG_ATTRS = {
123
137
  responseType: "response_type",
124
138
  continueOnError: "continue_on_error",
125
139
  searchTableId: "search_table_id",
140
+ phoneService: "phone_service_id",
141
+ query: "query",
126
142
  textToSummarize: "text_to_summarize",
127
143
  textToClassify: "text_to_classify",
128
144
  fieldType: "field_type",
@@ -163,7 +179,12 @@ function onlyEntry(value, subject) {
163
179
  return entries[0];
164
180
  }
165
181
  function token(value) {
166
- if (!isObject(value) || typeof value.__kind !== "string" || typeof value.refName !== "string")
182
+ if (!isObject(value) || typeof value.__kind !== "string")
183
+ return undefined;
184
+ // User refs are keyed by email and intentionally have no catalog refName.
185
+ if (value.__kind === "user" && typeof value.email === "string")
186
+ return value;
187
+ if (typeof value.refName !== "string")
167
188
  return undefined;
168
189
  return value;
169
190
  }
@@ -188,7 +209,15 @@ function addressExpr(address, path = ["id"]) {
188
209
  * its own foreign-field label: an app and an element can share a refName,
189
210
  * and `elementum_field` is one shared data-source type for both.
190
211
  */
191
- function crossAppFieldToTf(value, ctx, dataBlocks) {
212
+ /**
213
+ * Validates and derives the shared naming for a cross-app/element field
214
+ * token — the `data.elementum_field` label {@link crossAppFieldToTf} emits,
215
+ * and the matching `<fieldLabel>_options_by_label` local a foreign PICKLIST
216
+ * field's option-label lookup (in {@link picklistFilterValueToTf}) resolves
217
+ * against. Kept as one function so the two call sites can never drift apart
218
+ * on how the label is built.
219
+ */
220
+ function foreignFieldNaming(value) {
192
221
  const parent = value.parent;
193
222
  if (parent === undefined)
194
223
  throw new EntityTfError(`field ref "${value.refName}" has no parent`);
@@ -208,8 +237,50 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
208
237
  const fieldName = value.name ?? value.refName;
209
238
  const ownerType = value.parentKind === "element" ? "elementum_element" : "elementum_app";
210
239
  const ownerLabel = tsLabelToTfLabel(parent);
211
- const objectId = expr.dataAttr(ownerType, ownerLabel, ["id"]);
212
240
  const fieldLabel = `${value.parentKind}_${ownerLabel}_${tsLabelToTfLabel(value.refName)}`;
241
+ return { fieldName, ownerType, ownerLabel, ownerParentName: value.parentName, fieldLabel };
242
+ }
243
+ /**
244
+ * Registers the `<fieldLabel>_options_by_label` local — a for-expression
245
+ * over the `data.elementum_field` block's `options` — into the shared
246
+ * `locals.tf` attrs, when the build wired one up ({@link
247
+ * AutomationToTfContext.localsAttrs}). Cross-app counterpart to
248
+ * `field/locals.ts`'s same-app `appendFieldLocals`; unconditional per field
249
+ * (options empty for non-picklist/calculated fields), matching that
250
+ * same-app precedent of always emitting the local whether or not any
251
+ * automation ends up looking a label up through it.
252
+ */
253
+ function registerForeignOptionsByLabelLocal(fieldLabel, ctx) {
254
+ if (ctx.localsAttrs === undefined)
255
+ return;
256
+ const localName = `${fieldLabel}_options_by_label`;
257
+ if (localName in ctx.localsAttrs)
258
+ return;
259
+ ctx.localsAttrs[localName] = expr.forObject("opt", expr.dataAttr("elementum_field", fieldLabel, ["options"]), expr.scopedAttr("opt", ["label"]), expr.scopedAttr("opt", ["id"]));
260
+ }
261
+ function crossAppFieldToTf(value, ctx, dataBlocks) {
262
+ // A field owned by a SIBLING app/element built in this same workspace
263
+ // resolves to a direct resource address, same as the `case "app"/"element"`
264
+ // branch in `tokenToTf` — never a `data.elementum_field` lookup, which can
265
+ // only find something already live on the platform (see
266
+ // `ToTfContext.workspaceAspects`'s doc comment).
267
+ if (value.parent !== undefined && value.parentKind !== undefined) {
268
+ const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(value.parentKind, value.parent));
269
+ // A table sibling cannot own a FIELD ref (tables expose columns, not
270
+ // fields, and `parentKind` is only ever app/element here), so it is
271
+ // filtered out rather than cast away — the map holds tables too, because a
272
+ // table-owned search table has to be distinguishable from an element-owned
273
+ // one.
274
+ if (sibling !== undefined && sibling.kind !== "table") {
275
+ const fieldValue = fieldRefToTfValue(value.fieldType ?? "", value.refName, sibling.tfLabel, sibling.kind);
276
+ if (fieldValue === undefined) {
277
+ throw new EntityTfError(`field ref "${value.refName}" on sibling ${sibling.kind} "${value.parent}" has no terraform field resource mapping (fieldType ${JSON.stringify(value.fieldType ?? "")})`);
278
+ }
279
+ return fieldValue;
280
+ }
281
+ }
282
+ const { fieldName, ownerType, ownerLabel, ownerParentName, fieldLabel } = foreignFieldNaming(value);
283
+ const objectId = expr.dataAttr(ownerType, ownerLabel, ["id"]);
213
284
  // Route through the build-wide `orgRefs` registry (same one `agent-tool`/
214
285
  // `agent`/`skill`/`field` use) instead of this call's own local
215
286
  // `dataBlocks` map, so two DIFFERENT automation files referencing the same
@@ -220,10 +291,10 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
220
291
  // callers that don't supply `orgRefs` (unit tests).
221
292
  if (ctx.orgRefs !== undefined) {
222
293
  if (value.parentKind === "element") {
223
- ctx.orgRefs.foreignElement(ownerLabel, value.parentName);
294
+ ctx.orgRefs.foreignElement(ownerLabel, ownerParentName);
224
295
  }
225
296
  else {
226
- ctx.orgRefs.foreignApp(ownerLabel, value.parentName);
297
+ ctx.orgRefs.foreignApp(ownerLabel, ownerParentName);
227
298
  }
228
299
  ctx.orgRefs.foreignField("elementum_field", fieldLabel, objectId, fieldName);
229
300
  }
@@ -232,7 +303,7 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
232
303
  kind: "data",
233
304
  type: ownerType,
234
305
  label: ownerLabel,
235
- attrs: { name: value.parentName },
306
+ attrs: { name: ownerParentName },
236
307
  });
237
308
  dataBlocks.set(`elementum_field.${fieldLabel}`, {
238
309
  kind: "data",
@@ -241,15 +312,40 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
241
312
  attrs: { object_id: objectId, name: fieldName },
242
313
  });
243
314
  }
315
+ registerForeignOptionsByLabelLocal(fieldLabel, ctx);
244
316
  return expr.dataAttr("elementum_field", fieldLabel, ["id"]);
245
317
  }
246
318
  function tokenToTf(value, ctx, dataBlocks) {
247
319
  switch (value.__kind) {
320
+ case "user": {
321
+ if (typeof value.email !== "string" || value.email === "") {
322
+ throw new EntityTfError("userRef requires an email lookup");
323
+ }
324
+ const normalizedEmail = value.email.toLowerCase();
325
+ const label = `${sanitizeName(value.email.split("@")[0] ?? value.email).slice(0, 50)}_${labelHash(normalizedEmail)}`;
326
+ if (ctx.orgRefs !== undefined) {
327
+ ctx.orgRefs.rawLookup("elementum_user", label, value.email);
328
+ }
329
+ else {
330
+ dataBlocks.set(`elementum_user.${label}`, {
331
+ kind: "data",
332
+ type: "elementum_user",
333
+ label,
334
+ attrs: { email: value.email },
335
+ });
336
+ }
337
+ return expr.dataAttr("elementum_user", label, ["id"]);
338
+ }
248
339
  case "userField":
249
340
  return value.refName;
250
341
  case "app":
251
342
  case "element":
252
343
  if (value.refName !== ctx.appRefName) {
344
+ const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(value.__kind, value.refName));
345
+ if (sibling !== undefined) {
346
+ const siblingType = sibling.kind === "element" ? "elementum_element" : "elementum_app";
347
+ return expr.resourceAttr(siblingType, sibling.tfLabel, ["id"]);
348
+ }
253
349
  if (!value.name)
254
350
  throw new EntityTfError(`cross-aspect ref "${value.refName}" has no lookup name`);
255
351
  const type = value.__kind === "element" ? "elementum_element" : "elementum_app";
@@ -318,8 +414,71 @@ function tokenToTf(value, ctx, dataBlocks) {
318
414
  return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
319
415
  case "agent":
320
416
  return expr.resourceAttr("elementum_agent", scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
321
- case "searchTable":
322
- return expr.resourceAttr("elementum_ai_search_table", scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
417
+ case "phone-service":
418
+ if (value.parent !== undefined && value.parent !== ctx.appRefName) {
419
+ throw new EntityTfError(`cross-app phone service ref "${value.parent}.${value.refName}" is not supported`);
420
+ }
421
+ return expr.resourceAttr("elementum_phone_service", scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
422
+ case "datamine":
423
+ if (value.parent === undefined || value.parent === "") {
424
+ throw new EntityTfError(`datamine ref "${value.refName}" is missing its owning table`);
425
+ }
426
+ return expr.resourceAttr("elementum_datamine", `${tsLabelToTfLabel(value.parent)}_${tsLabelToTfLabel(value.refName)}`, ["id"]);
427
+ case "searchTable": {
428
+ // Ownership + variant contract:
429
+ // snowflake / linked -> owned by an ELEMENT
430
+ // table -> owned by a TABLE
431
+ // never app-owned -> an app's backing Snowflake table is hybrid, and
432
+ // Cortex cannot index one ("AI Search Tables
433
+ // cannot be created on hybrid tables (target
434
+ // object has storageType HYBRID)").
435
+ //
436
+ // This previously scoped every search table to `ctx.appTfLabel`, which is
437
+ // therefore never a valid target. With an element owner it emitted a
438
+ // reference to a resource that is never written — with ZERO diagnostics —
439
+ // and failed only at `tofu plan` ("Reference to undeclared resource"),
440
+ // saying nothing about ownership. The sibling cases in this switch
441
+ // (automation / phone-service / datamine) all throw; this was silent.
442
+ //
443
+ // The VARIANT picks the resource type and the owner kind only has to
444
+ // agree with it. Deriving the type from the owner instead emits
445
+ // `elementum_ai_search_table` for a LINKED table — whose resource is
446
+ // `elementum_linked_ai_search_table` — recreating the very dangling
447
+ // reference this case exists to prevent, and lets an element win over a
448
+ // table when the two share a refName.
449
+ const owner = value.parent;
450
+ if (owner === undefined) {
451
+ throw new EntityTfError(`search table "${value.refName}" carries no owning aspect — a search table is owned by an element or a table`);
452
+ }
453
+ const aspects = ctx.workspaceAspects;
454
+ if (aspects === undefined) {
455
+ throw new EntityTfError(`search table "${owner}.${value.refName}" cannot be resolved without workspace ownership context`);
456
+ }
457
+ const variant = value.__variant ?? "snowflake";
458
+ const element = aspects.get(workspaceAspectKey("element", owner));
459
+ const table = aspects.get(workspaceAspectKey("table", owner));
460
+ if (variant === "table") {
461
+ if (table === undefined) {
462
+ throw new EntityTfError(`search table "${owner}.${value.refName}" is table-owned, but "${owner}" is not a table in this build` +
463
+ `${element !== undefined ? ` (it is an element — use defineSearchTable, not defineTableSearchTable)` : ""}`);
464
+ }
465
+ // Label shape mirrors search-table/to-tf.ts's own table branch.
466
+ return expr.resourceAttr(SEARCH_TABLE_RESOURCE_TYPES.table, `tables_${table.tfLabel}_${tsLabelToTfLabel(value.refName)}`, ["id"]);
467
+ }
468
+ if (element !== undefined) {
469
+ return expr.resourceAttr(SEARCH_TABLE_RESOURCE_TYPES[variant], scopedResourceLabel(element.tfLabel, tsLabelToTfLabel(value.refName), "element"), ["id"]);
470
+ }
471
+ if (table !== undefined) {
472
+ throw new EntityTfError(`search table "${owner}.${value.refName}" is a ${variant} search table owned by table "${owner}" — ` +
473
+ `a table's search table is created with defineTableSearchTable`);
474
+ }
475
+ if (aspects.get(workspaceAspectKey("app", owner)) !== undefined) {
476
+ throw new EntityTfError(`search table "${owner}.${value.refName}" is owned by app "${owner}" — a search table is owned by an ` +
477
+ `element or a table, never an app`);
478
+ }
479
+ throw new EntityTfError(`search table "${owner}.${value.refName}" is owned by an aspect that is not part of this build — ` +
480
+ `a foreign search-table reference has no data-source lookup yet`);
481
+ }
323
482
  case "approvalChain":
324
483
  return value.unresolvedId !== undefined
325
484
  ? value.unresolvedId
@@ -332,7 +491,7 @@ function tokenToTf(value, ctx, dataBlocks) {
332
491
  // reference to a resource block that's never written, failing only at
333
492
  // `tofu plan`/`apply` instead of at build.
334
493
  if (subType === undefined || subType.implemented !== true) {
335
- throw new EntityTfError(`file reader token "${value.refName}" has no recognized readerType ("${value.readerType}") — was it built with defineFileReader?`);
494
+ throw new EntityTfError(`file reader token "${value.refName}" has no recognized readerType ("${value.readerType}") — was it built with a file-reader factory?`);
336
495
  }
337
496
  return expr.resourceAttr(subType.resourceType, scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
338
497
  }
@@ -467,6 +626,8 @@ function valueToTf(value, refs) {
467
626
  return value.map((item) => valueToTf(item, refs));
468
627
  if (!isObject(value))
469
628
  throw new EntityTfError(`unsupported automation value ${String(value)}`);
629
+ if (value.__unsafe === "platformId" && typeof value.value === "string")
630
+ return value.value;
470
631
  if ("value" in value && Object.keys(value).length === 1)
471
632
  return valueToTf(value.value, refs);
472
633
  if (isObject(value.variableReference) && typeof value.variableReference.id === "string") {
@@ -552,6 +713,22 @@ function filterReferenceToTf(value, refs) {
552
713
  const fieldKey = parts[1];
553
714
  const address = refs.owner.fieldAddresses.get(fieldKey);
554
715
  const suffix = parts.slice(2).join(".");
716
+ // A bare reference to a PICKLIST field (STATUS/STAGE included —
717
+ // `serializeSystemFields` wire-wraps both as a picklist too) has no
718
+ // valid suffix-less wire form — confirmed live via the platform's
719
+ // own switch-case editor, which always sends an explicit `.id`
720
+ // (compare by the chosen option's real id) or `.label` (compare by
721
+ // display text, unvalidated) and never a bare `record.<fieldId>`.
722
+ // Force the author to say which one they mean rather than guessing:
723
+ // a silent default reads as correct right up until the platform
724
+ // evaluates the two conventions differently, and there is no
725
+ // apply-time signal to catch that (the wire string is opaque to
726
+ // the provider).
727
+ if (suffix.length === 0 && refs.owner.fieldMetadata.get(fieldKey)?.fieldType === "PICKLIST") {
728
+ throw new EntityTfError(`filter reference to picklist field "${fieldKey}" is ambiguous — write ".id" ` +
729
+ `(ctx.trigger.record.${fieldKey}.id, compare by the option's id) or ".label" ` +
730
+ `(ctx.trigger.record.${fieldKey}.label, compare by display text) explicitly.`);
731
+ }
555
732
  if (address !== undefined) {
556
733
  return expr.template([
557
734
  "trigger.record.",
@@ -629,16 +806,39 @@ function picklistFilterValueToTf(value, field, refs) {
629
806
  return undefined;
630
807
  throw new EntityTfError(`automation filter for picklist field "${field.name ?? field.refName}" uses unknown option ${JSON.stringify(value)}; expected one of: ${field.options.map((option) => JSON.stringify(option)).join(", ")}`);
631
808
  }
809
+ if (field.parent !== undefined && field.parentKind !== undefined) {
810
+ // A field owned by a SIBLING app/element built in this same workspace
811
+ // has its options-by-label local sourced from ITS OWN resource's
812
+ // `options` attribute (the sibling's own `appendFieldLocals`/
813
+ // `app/locals.ts` contribution) — the same naming a same-app field
814
+ // gets below, just scoped to the sibling's tfLabel instead of the
815
+ // automation's own app. Never the foreign `data.elementum_field`-backed
816
+ // local: that local is only ever registered for a genuinely foreign
817
+ // field (see `crossAppFieldToTf`'s sibling short-circuit).
818
+ const sibling = refs.owner.workspaceAspects?.get(workspaceAspectKey(field.parentKind, field.parent));
819
+ // Table siblings excluded for the same reason as in `crossAppFieldToTf`: a
820
+ // picklist field's owner is an app or an element, never a table.
821
+ if (sibling !== undefined && sibling.kind !== "table") {
822
+ const localName = field.tags?.includes("STATUS")
823
+ ? `${sibling.tfLabel}_status_options_by_label`
824
+ : field.tags?.includes("STAGE")
825
+ ? `${sibling.tfLabel}_stage_options_by_label`
826
+ : `${scopedResourceLabel(sibling.tfLabel, tsLabelToTfLabel(field.refName), sibling.kind)}_options_by_label`;
827
+ return expr.local(localName, [{ index: value }]);
828
+ }
829
+ }
632
830
  if (field.parent !== undefined && (field.parent !== refs.owner.appRefName || field.parentKind === "element")) {
633
- // The options-by-label local only exists for a field owned by THIS
634
- // automation's own app — `appendFieldLocals` (field/locals.ts) only
635
- // walks the current stream root's own field resources, and there is no
636
- // `data.elementum_field`-style lookup for a foreign aspect's option
637
- // label → id mapping. Building the same local reference here would
638
- // point at a local that plan/apply can never resolve ("reference to
639
- // undeclared local value") instead of failing at build time, where the
640
- // problem is actually diagnosable.
641
- throw new EntityTfError(`automation filter for picklist field "${field.name ?? field.refName}" belongs to a foreign ${field.parentKind ?? "app"} ("${field.parent}") — filtering a foreign picklist field by option label is not supported on the terraform path yet; filter by option id instead`);
831
+ // A foreign field's options-by-label local is sourced from
832
+ // `data.elementum_field.<label>.options` (issue #353) rather than an
833
+ // owned resource's `options` attribute — `crossAppFieldToTf` registers
834
+ // both the data block and the matching local; reuse the SAME naming
835
+ // (`foreignFieldNaming`) so this reference always lines up with
836
+ // whatever label that registration used, then make sure the data block
837
+ // (and local) actually gets registered even when nothing else in this
838
+ // payload resolves the field's id.
839
+ const naming = foreignFieldNaming(field);
840
+ crossAppFieldToTf(field, refs.owner, refs.dataBlocks);
841
+ return expr.local(naming.fieldLabel + "_options_by_label", [{ index: value }]);
642
842
  }
643
843
  const localName = field.tags?.includes("STATUS")
644
844
  ? `${refs.owner.appTfLabel}_status_options_by_label`
@@ -647,31 +847,6 @@ function picklistFilterValueToTf(value, field, refs) {
647
847
  : `${scopedLabel(refs.owner.appTfLabel, tsLabelToTfLabel(field.refName))}_options_by_label`;
648
848
  return expr.local(localName, [{ index: value }]);
649
849
  }
650
- function filterValueToTf(value, refs, field) {
651
- if (!isObject(value) || typeof value.type !== "string")
652
- return valueToTf(value, refs);
653
- const type = value.type.toLowerCase();
654
- const result = { type };
655
- if (value.realType !== undefined)
656
- result.real_type = String(value.realType).toLowerCase();
657
- if (type === "current_user" && typeof value.currentUserType === "string") {
658
- result.current_user_type = value.currentUserType;
659
- }
660
- if (value.value !== undefined) {
661
- // The provider's `filter.value` schema splits "static" from "dynamic"
662
- // across two distinct attributes — `value` vs `value_reference` — same
663
- // split `left_value` already respects just above. A reference-typed
664
- // value belongs under `value_reference`; the provider rejects it under
665
- // `value` ("value_reference is required for reference type").
666
- if (type === "reference") {
667
- result.value_reference = filterReferenceToTf(value.value, refs);
668
- }
669
- else {
670
- result.value = picklistFilterValueToTf(value.value, field, refs) ?? valueToTf(value.value, refs);
671
- }
672
- }
673
- return result;
674
- }
675
850
  function fieldFromFilterLeftValue(value, refs) {
676
851
  if (!isObject(value) || !isObject(value.value) || value.value.type?.toString().toUpperCase() !== "TRIGGER") {
677
852
  return undefined;
@@ -683,62 +858,27 @@ function fieldFromFilterLeftValue(value, refs) {
683
858
  if (path[0] !== "record" || path.length < 2)
684
859
  return undefined;
685
860
  const refName = path[1];
861
+ // Option-id resolution (picklistFilterValueToTf) only applies to the
862
+ // ".id" convention `filterReferenceToTf` now requires for a picklist
863
+ // field — an explicit ".label" (or any other drill-down suffix, e.g. a
864
+ // USER field's ".email") compares raw text/whatever that sub-property
865
+ // actually is, and must NOT have its value silently rewritten through
866
+ // the options-by-label local.
867
+ const suffix = path.slice(2).join(".");
868
+ if (suffix !== "" && suffix !== "id")
869
+ return undefined;
686
870
  const metadata = refs.owner.fieldMetadata.get(refName);
687
871
  if (metadata === undefined)
688
872
  return undefined;
689
873
  return { __kind: "field", refName, ...metadata };
690
874
  }
691
875
  function filterToTf(value, refs) {
692
- if (!isObject(value) || typeof value.type !== "string")
693
- throw new EntityTfError("invalid automation filter");
694
- const result = { type: value.type.toLowerCase() };
695
- const field = token(value.field) ?? fieldFromFilterLeftValue(value.leftValue, refs);
696
- for (const [key, child] of Object.entries(value)) {
697
- if (key === "type")
698
- continue;
699
- if (key === "field") {
700
- result.field_id = valueToTf(child, refs);
701
- continue;
702
- }
703
- if (key === "leftValue") {
704
- if (!isObject(child))
705
- throw new EntityTfError("invalid filter leftValue");
706
- result.left_value = {
707
- value_reference: filterReferenceToTf(child.value, refs),
708
- ...(child.realType !== undefined ? { real_type: String(child.realType).toLowerCase() } : {}),
709
- };
710
- continue;
711
- }
712
- if (key === "children") {
713
- if (!Array.isArray(child))
714
- throw new EntityTfError("filter children must be an array");
715
- result.children = child.map((item) => filterToTf(item, refs));
716
- continue;
717
- }
718
- if (key === "value") {
719
- result.value = filterValueToTf(child, refs, field);
720
- continue;
721
- }
722
- if (key === "values") {
723
- if (!Array.isArray(child))
724
- throw new EntityTfError("filter values must be an array");
725
- result.values = child.map((item) => filterValueToTf(item, refs, field));
726
- continue;
727
- }
728
- if (key === "mode") {
729
- if (typeof child !== "string")
730
- throw new EntityTfError("filter mode must be a string");
731
- result.mode = child.toLowerCase();
732
- continue;
733
- }
734
- result[snake(key)] = valueToTf(child, refs);
735
- }
736
- // The platform silently defaults an unset LIKE mode to "legacy" and always
737
- // echoes it back on export — emit it explicitly so build and export stay
738
- // byte-fidelity equal instead of one omitting an attribute the other sets.
739
- if (result.type === "like" && result.mode === undefined)
740
- result.mode = "legacy";
741
- return result;
876
+ return serializeFilterToTf(value, {
877
+ field: (field) => valueToTf(field, refs),
878
+ fieldFromLeftValue: (left) => fieldFromFilterLeftValue(left, refs),
879
+ reference: (reference) => filterReferenceToTf(reference, refs),
880
+ literal: (literal, field) => picklistFilterValueToTf(literal, token(field), refs) ?? valueToTf(literal, refs),
881
+ });
742
882
  }
743
883
  function configAttrs(kind, config, refs) {
744
884
  const attrs = {};
@@ -888,9 +1028,18 @@ function configAttrs(kind, config, refs) {
888
1028
  attrs.fields = raw.map((field) => {
889
1029
  if (!isObject(field))
890
1030
  throw new EntityTfError("workflow field must be an object");
1031
+ const fieldToken = isObject(field.aspectFieldId) && typeof field.aspectFieldId.__kind === "string"
1032
+ ? field.aspectFieldId
1033
+ : undefined;
1034
+ const staticValue = isObject(field.valueReference) && "value" in field.valueReference
1035
+ ? field.valueReference.value
1036
+ : undefined;
1037
+ const optionValue = staticValue !== undefined
1038
+ ? picklistFilterValueToTf(staticValue, fieldToken, refs)
1039
+ : undefined;
891
1040
  return {
892
1041
  field_id: valueToTf(field.aspectFieldId, refs),
893
- value: valueToTf(field.valueReference, refs),
1042
+ value: optionValue ?? valueToTf(field.valueReference, refs),
894
1043
  };
895
1044
  });
896
1045
  continue;
@@ -1072,6 +1221,8 @@ export function automationToTf(entity, ctx) {
1072
1221
  fieldNames: ctx.fieldNames ?? new Map(),
1073
1222
  fieldMetadata: ctx.fieldMetadata ?? new Map(),
1074
1223
  orgRefs: ctx.orgRefs,
1224
+ localsAttrs: ctx.localsAttrs,
1225
+ workspaceAspects: ctx.workspaceAspects,
1075
1226
  };
1076
1227
  if (entity.kind !== "automation")
1077
1228
  throw new EntityTfError(`automationToTf expects kind "automation"; got "${entity.kind}"`);
@@ -1093,8 +1244,28 @@ export function automationToTf(entity, ctx) {
1093
1244
  name: payload.name ?? "",
1094
1245
  ...(payload.description !== undefined ? { description: payload.description } : {}),
1095
1246
  ...(payload.triggersOtherAutomations !== undefined ? { triggers_other_automations: payload.triggersOtherAutomations } : {}),
1247
+ ...(payload.status === "INACTIVE" ? { status: "INACTIVE" } : {}),
1096
1248
  },
1097
1249
  };
1250
+ if (payload.serviceAccount !== undefined) {
1251
+ if (payload.serviceAccount.appRefName !== owner.appRefName) {
1252
+ throw new EntityTfError(`automation "${entity.refName}" service account belongs to app "${payload.serviceAccount.appRefName}", not "${owner.appRefName}"`);
1253
+ }
1254
+ const local = Object.entries(ctx.serviceAccounts ?? {}).find(([, account]) => `${account.firstName} ${account.lastName}` === payload.serviceAccount.name);
1255
+ if (local !== undefined) {
1256
+ automation.attrs.service_account_id = expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, appScopedResourceLabel(owner.appTfLabel, tsLabelToTfLabel(local[0])), ["id"]);
1257
+ }
1258
+ else if (owner.orgRefs !== undefined) {
1259
+ const lookupLabel = sanitizeName(payload.serviceAccount.name);
1260
+ owner.orgRefs.rawLookup(SERVICE_ACCOUNT_RESOURCE_TYPE, lookupLabel, payload.serviceAccount.name, {
1261
+ app_id: expr.resourceAttr("elementum_app", owner.appTfLabel, ["id"]),
1262
+ });
1263
+ automation.attrs.service_account_id = expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, lookupLabel, ["id"]);
1264
+ }
1265
+ else {
1266
+ throw new EntityTfError(`automation "${entity.refName}" cannot resolve service account "${payload.serviceAccount.name}"`);
1267
+ }
1268
+ }
1098
1269
  const [triggerKey, triggerConfig] = onlyEntry(payload.trigger, `automation "${entity.refName}" trigger`);
1099
1270
  const triggerType = TRIGGER_RESOURCES[triggerKey];
1100
1271
  if (triggerType === undefined)
@@ -1216,8 +1387,12 @@ export function automationToTf(entity, ctx) {
1216
1387
  if (target === undefined || target.__kind !== "automation")
1217
1388
  throw new EntityTfError(`runAutomation task "${refKey}" has an unresolved target`);
1218
1389
  const targetLabel = scopedLabel(owner.appTfLabel, tsLabelToTfLabel(target.refName));
1219
- block.attrs.depends_on = [expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, targetLabel)];
1220
- runAutomationPublishes.add(targetLabel);
1390
+ // A publish resource only exists for ACTIVE automations. Depending on
1391
+ // a draft/inactive target's publish address produces invalid HCL.
1392
+ if (ctx.activeAutomationRefNames?.has(target.refName) === true) {
1393
+ block.attrs.depends_on = [expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, targetLabel)];
1394
+ runAutomationPublishes.add(targetLabel);
1395
+ }
1221
1396
  }
1222
1397
  blocks.push(block);
1223
1398
  const address = expr.resourceAttr(resourceType, tfLabel);
@@ -1297,7 +1472,7 @@ export function automationToTf(entity, ctx) {
1297
1472
  if (fileReaderDeps.length > 0) {
1298
1473
  automation.attrs.depends_on = fileReaderDeps;
1299
1474
  }
1300
- {
1475
+ if (payload.status === "ACTIVE") {
1301
1476
  const outputValues = payload.outputProperties?.outputs ?? [];
1302
1477
  const publish = {
1303
1478
  kind: "resource",
@@ -8,7 +8,8 @@
8
8
  * it's reference-model-agnostic (typed params, no id resolution), so there's
9
9
  * nothing to retarget; it relocates to a shared home at the cutover.
10
10
  */
11
- import type { AspectRef, FieldRef } from "../../catalog/index.js";
11
+ import type { AppOrElementRef, DatamineRef, FieldRef } from "../../catalog/index.js";
12
+ import type { UnsafePlatformId } from "../../core/platform-id.js";
12
13
  import type { RecordShape } from "../field/record-shape.js";
13
14
  import { type InferTriggerType, type OnDemandTriggerOptions, type TriggerInputFieldDef, type TriggerInputSchema } from "../../core/triggers/on-demand.js";
14
15
  import type { TriggerFieldTypeAlias } from "../shared/types/field-types.js";
@@ -20,23 +21,23 @@ import { type TriggerChain } from "./build.js";
20
21
  * typed per-field via `RecordShape`; otherwise it falls back to loose
21
22
  * `Record<string, unknown>` (see `RecordShape`'s doc comment).
22
23
  */
23
- export interface RecordTriggerOutput<A extends AspectRef = AspectRef> {
24
+ export interface RecordTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
24
25
  readonly record: RecordShape<A>;
25
26
  /** Raw ids of the fields that changed to fire this trigger (record-update only; empty on create). */
26
27
  readonly changedFieldIds: readonly string[];
27
28
  }
28
- export interface RecordTriggerOptions<A extends AspectRef = AspectRef> {
29
+ export interface RecordTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
29
30
  readonly app: A;
30
31
  /** Restrict to fire only when one of these fields changes. */
31
32
  readonly changedFields?: readonly FieldRef[];
32
33
  readonly thinkUi?: boolean;
33
34
  /** Pre-built wire `Filter` (may embed `FieldRef` tokens — resolved at deploy). */
34
- readonly filter?: Record<string, unknown>;
35
+ readonly filter?: Filter;
35
36
  }
36
37
  /** Fires when a record is created on the given aspect. */
37
- export declare function recordCreated<A extends AspectRef>(opts: RecordTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
38
+ export declare function recordCreated<A extends AppOrElementRef>(opts: RecordTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
38
39
  /** Fires when a record is updated on the given aspect. */
39
- export declare function recordUpdated<A extends AspectRef>(opts: RecordTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
40
+ export declare function recordUpdated<A extends AppOrElementRef>(opts: RecordTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
40
41
  export type ScheduleFrequency = "HOURLY" | "DAILY" | "WEEKLY" | "MONTHLY";
41
42
  export type Weekday = "MONDAY" | "TUESDAY" | "WEDNESDAY" | "THURSDAY" | "FRIDAY" | "SATURDAY" | "SUNDAY";
42
43
  export interface ScheduleTriggerOptions {
@@ -99,7 +100,7 @@ export declare function webHook(opts?: WebhookTriggerOptions): TriggerChain<Webh
99
100
  export declare function webhook(opts?: WebhookTriggerOptions): TriggerChain<WebhookTriggerOutput>;
100
101
  export type TemporalUnit = "MINUTES" | "HOURS" | "DAYS";
101
102
  export interface TemporalTriggerOptions {
102
- readonly app: AspectRef;
103
+ readonly app: AppOrElementRef;
103
104
  readonly field: FieldRef;
104
105
  readonly temporalUnit: TemporalUnit;
105
106
  readonly value: number;
@@ -108,26 +109,26 @@ export interface TemporalTriggerOptions {
108
109
  export declare function temporal(opts: TemporalTriggerOptions): TriggerChain<RecordTriggerOutput>;
109
110
  export type approvalProcessStatusUpdatedStatus = "ACTIVE" | "STEP_APPROVED" | "CANCELLED" | "DENIED" | "APPROVED";
110
111
  export interface approvalProcessStatusUpdatedTriggerOptions {
111
- readonly app: AspectRef;
112
+ readonly app: AppOrElementRef;
112
113
  readonly approvalChain: string;
113
114
  readonly status: approvalProcessStatusUpdatedStatus;
114
115
  }
115
116
  /** Fires when an approval chain on a record changes to the configured status. */
116
117
  export declare function approvalProcessStatusUpdated(opts: approvalProcessStatusUpdatedTriggerOptions): TriggerChain<RecordTriggerOutput>;
117
- export interface AttachmentTriggerOptions<A extends AspectRef = AspectRef> {
118
+ export interface AttachmentTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
118
119
  readonly app: A;
119
120
  readonly filter?: Filter;
120
121
  readonly thinkUi?: boolean;
121
122
  }
122
- export interface AttachmentTriggerOutput<A extends AspectRef = AspectRef> {
123
+ export interface AttachmentTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
123
124
  readonly record: RecordShape<A>;
124
125
  /** Attachment sub-fields (name/url/mediaType/…) aren't typed yet — follow-up. */
125
126
  readonly attachment: Record<string, unknown>;
126
127
  }
127
128
  /** Fires when an attachment is added to a record on the given aspect. */
128
- export declare function attachment<A extends AspectRef>(opts: AttachmentTriggerOptions<A>): TriggerChain<AttachmentTriggerOutput<A>>;
129
+ export declare function attachment<A extends AppOrElementRef>(opts: AttachmentTriggerOptions<A>): TriggerChain<AttachmentTriggerOutput<A>>;
129
130
  export interface DataMineTriggerOptions {
130
- readonly datamineId: string;
131
+ readonly datamine: DatamineRef | UnsafePlatformId;
131
132
  readonly fireOnAlert?: boolean;
132
133
  readonly fireOnRecovery?: boolean;
133
134
  }
@@ -149,22 +150,22 @@ export interface EmailReceivedTriggerOutput {
149
150
  }
150
151
  /** Fires when an email is received by the platform email alias. */
151
152
  export declare function emailReceived(opts: EmailReceivedTriggerOptions): TriggerChain<EmailReceivedTriggerOutput>;
152
- export interface CommentAddedTriggerOptions<A extends AspectRef = AspectRef> {
153
+ export interface CommentAddedTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
153
154
  readonly app: A;
154
155
  /** Conversation type the comment was added to (e.g. `"INTERNAL"`). */
155
156
  readonly conversationType: string;
156
157
  readonly filter?: Filter;
157
158
  }
158
- export interface CommentAddedTriggerOutput<A extends AspectRef = AspectRef> {
159
+ export interface CommentAddedTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
159
160
  readonly record: RecordShape<A>;
160
161
  /** Comment sub-fields aren't typed yet — follow-up. */
161
162
  readonly comment: Record<string, unknown>;
162
163
  }
163
164
  /** Fires when a comment is added to a record on the given aspect. */
164
- export declare function commentAdded<A extends AspectRef>(opts: CommentAddedTriggerOptions<A>): TriggerChain<CommentAddedTriggerOutput<A>>;
165
+ export declare function commentAdded<A extends AppOrElementRef>(opts: CommentAddedTriggerOptions<A>): TriggerChain<CommentAddedTriggerOutput<A>>;
165
166
  export type ConversationEndConversationType = "A2A" | "VOICE" | "EMAIL" | "SLACK" | "TEAMS";
166
167
  export interface ConversationEndTriggerOptions {
167
- readonly app: AspectRef;
168
+ readonly app: AppOrElementRef;
168
169
  readonly conversationType: ConversationEndConversationType;
169
170
  }
170
171
  export interface ConversationEndTriggerOutput {
@@ -195,7 +196,7 @@ export interface SlackMessageTriggerOutput {
195
196
  /** Fires when a Slack message is received. */
196
197
  export declare function slackMessage(): TriggerChain<SlackMessageTriggerOutput>;
197
198
  export interface SurveyResponseCreateTriggerOptions {
198
- readonly app: AspectRef;
199
+ readonly app: AppOrElementRef;
199
200
  /** Raw survey template id until surveys are catalog-modeled. */
200
201
  readonly survey: string;
201
202
  }