@elementumai/edk 0.9.2 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/README.md +34 -26
  2. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
  3. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
  4. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
  5. package/dist-sdk/pull/util.d.ts +1 -1
  6. package/dist-sdk/pull/util.js +3 -3
  7. package/dist-sdk/src/catalog/factories.d.ts +49 -10
  8. package/dist-sdk/src/catalog/factories.js +94 -13
  9. package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
  10. package/dist-sdk/src/catalog/from-authoring.js +7 -7
  11. package/dist-sdk/src/catalog/index.d.ts +2 -2
  12. package/dist-sdk/src/catalog/index.js +1 -1
  13. package/dist-sdk/src/catalog/org.js +62 -4
  14. package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
  15. package/dist-sdk/src/catalog/render-helpers.js +1 -1
  16. package/dist-sdk/src/catalog/render.d.ts +1 -0
  17. package/dist-sdk/src/catalog/render.js +2 -2
  18. package/dist-sdk/src/catalog/token.js +11 -4
  19. package/dist-sdk/src/catalog/types.d.ts +33 -4
  20. package/dist-sdk/src/catalog/types.js +5 -0
  21. package/dist-sdk/src/core/index.d.ts +10 -10
  22. package/dist-sdk/src/core/index.js +9 -9
  23. package/dist-sdk/src/core/render-tree.d.ts +1 -1
  24. package/dist-sdk/src/core/render-tree.js +1 -2
  25. package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
  26. package/dist-sdk/src/core/types/ai-provider.js +1 -1
  27. package/dist-sdk/src/core/types/app.d.ts +66 -30
  28. package/dist-sdk/src/core/types/app.js +2 -2
  29. package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
  30. package/dist-sdk/src/core/types/aspect-category.js +4 -4
  31. package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
  32. package/dist-sdk/src/core/types/cloud-link.js +3 -3
  33. package/dist-sdk/src/core/types/display-block.d.ts +2 -2
  34. package/dist-sdk/src/core/types/display-block.js +2 -2
  35. package/dist-sdk/src/core/types/group.d.ts +1 -1
  36. package/dist-sdk/src/core/types/group.js +1 -1
  37. package/dist-sdk/src/core/types/user.d.ts +1 -1
  38. package/dist-sdk/src/core/types/user.js +1 -1
  39. package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
  40. package/dist-sdk/src/engine/build/context.d.ts +20 -13
  41. package/dist-sdk/src/engine/entity.d.ts +1 -1
  42. package/dist-sdk/src/engine/pull/context.d.ts +34 -0
  43. package/dist-sdk/src/engine/pull/context.js +14 -0
  44. package/dist-sdk/src/engine/pull/org.d.ts +9 -0
  45. package/dist-sdk/src/engine/pull/org.js +33 -0
  46. package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
  47. package/dist-sdk/src/engine/pull/ref-only.js +204 -0
  48. package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
  49. package/dist-sdk/src/engine/tf/expr.js +18 -13
  50. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  51. package/dist-sdk/src/engine/tf/index.js +1 -1
  52. package/dist-sdk/src/engine/tf/model.d.ts +8 -1
  53. package/dist-sdk/src/engine/tf/model.js +4 -0
  54. package/dist-sdk/src/engine/tf/parse.js +13 -2
  55. package/dist-sdk/src/engine/tf/render.js +4 -0
  56. package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
  57. package/dist-sdk/src/entities/access-policy/build.js +1 -1
  58. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
  59. package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
  60. package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
  61. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
  62. package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
  63. package/dist-sdk/src/entities/agent/build.d.ts +3 -3
  64. package/dist-sdk/src/entities/agent/build.js +5 -5
  65. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
  66. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
  67. package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
  68. package/dist-sdk/src/entities/agent/from-tf.js +12 -4
  69. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  70. package/dist-sdk/src/entities/agent/index.js +1 -1
  71. package/dist-sdk/src/entities/agent/module.js +2 -0
  72. package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
  73. package/dist-sdk/src/entities/agent/to-tf.js +56 -8
  74. package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
  75. package/dist-sdk/src/entities/agent/tools.js +21 -7
  76. package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
  77. package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
  78. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
  79. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
  80. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
  81. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
  82. package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
  83. package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
  84. package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
  85. package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
  86. package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
  87. package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
  88. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
  89. package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
  90. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
  91. package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
  92. package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
  93. package/dist-sdk/src/entities/agent-tool/types.js +10 -37
  94. package/dist-sdk/src/entities/app/build.d.ts +97 -42
  95. package/dist-sdk/src/entities/app/build.js +25 -14
  96. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
  97. package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
  98. package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
  99. package/dist-sdk/src/entities/app/index.d.ts +11 -8
  100. package/dist-sdk/src/entities/app/index.js +10 -7
  101. package/dist-sdk/src/entities/app/module.js +2 -2
  102. package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
  103. package/dist-sdk/src/entities/app/to-tf.js +22 -6
  104. package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
  105. package/dist-sdk/src/entities/approval-chain/build.js +5 -5
  106. package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
  107. package/dist-sdk/src/entities/approval-chain/index.js +1 -1
  108. package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
  109. package/dist-sdk/src/entities/automation/build.d.ts +172 -94
  110. package/dist-sdk/src/entities/automation/build.js +159 -68
  111. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
  112. package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
  113. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
  114. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
  115. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
  116. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
  117. package/dist-sdk/src/entities/automation/from-tf.js +510 -80
  118. package/dist-sdk/src/entities/automation/index.d.ts +9 -12
  119. package/dist-sdk/src/entities/automation/index.js +11 -13
  120. package/dist-sdk/src/entities/automation/module.js +74 -6
  121. package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
  122. package/dist-sdk/src/entities/automation/operators.js +10 -37
  123. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
  124. package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
  125. package/dist-sdk/src/entities/automation/script-code.js +13 -22
  126. package/dist-sdk/src/entities/automation/serialize.js +1 -1
  127. package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
  128. package/dist-sdk/src/entities/automation/tasks.js +64 -11
  129. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
  130. package/dist-sdk/src/entities/automation/to-tf.js +342 -71
  131. package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
  132. package/dist-sdk/src/entities/automation/triggers.js +7 -1
  133. package/dist-sdk/src/entities/automation/types.d.ts +3 -2
  134. package/dist-sdk/src/entities/automation/types.js +3 -2
  135. package/dist-sdk/src/entities/chart/build.d.ts +95 -0
  136. package/dist-sdk/src/entities/chart/build.js +42 -0
  137. package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
  138. package/dist-sdk/src/entities/chart/from-tf.js +269 -0
  139. package/dist-sdk/src/entities/chart/index.d.ts +4 -0
  140. package/dist-sdk/src/entities/chart/index.js +3 -0
  141. package/dist-sdk/src/entities/chart/module.d.ts +3 -0
  142. package/dist-sdk/src/entities/chart/module.js +61 -0
  143. package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
  144. package/dist-sdk/src/entities/chart/printer.js +104 -0
  145. package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
  146. package/dist-sdk/src/entities/chart/to-tf.js +150 -0
  147. package/dist-sdk/src/entities/chart/types.d.ts +53 -0
  148. package/dist-sdk/src/entities/chart/types.js +22 -0
  149. package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
  150. package/dist-sdk/src/entities/dashboard/build.js +16 -1
  151. package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
  152. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
  153. package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
  154. package/dist-sdk/src/entities/datamine/module.js +1 -1
  155. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
  156. package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
  157. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
  158. package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
  159. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
  160. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
  161. package/dist-sdk/src/entities/element/build.d.ts +25 -32
  162. package/dist-sdk/src/entities/element/build.js +15 -32
  163. package/dist-sdk/src/entities/element/index.d.ts +7 -5
  164. package/dist-sdk/src/entities/element/index.js +7 -4
  165. package/dist-sdk/src/entities/element/module.js +7 -3
  166. package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
  167. package/dist-sdk/src/entities/element/to-tf.js +7 -3
  168. package/dist-sdk/src/entities/field/build.d.ts +51 -24
  169. package/dist-sdk/src/entities/field/build.js +31 -6
  170. package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
  171. package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
  172. package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
  173. package/dist-sdk/src/entities/field/calc/date.js +120 -29
  174. package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
  175. package/dist-sdk/src/entities/field/calc/index.js +82 -139
  176. package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
  177. package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
  178. package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
  179. package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
  180. package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
  181. package/dist-sdk/src/entities/field/calc/text.js +43 -31
  182. package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
  183. package/dist-sdk/src/entities/field/calc/types.js +1 -22
  184. package/dist-sdk/src/entities/field/calc.d.ts +71 -48
  185. package/dist-sdk/src/entities/field/calc.js +5 -15
  186. package/dist-sdk/src/entities/field/calculation-types.js +10 -3
  187. package/dist-sdk/src/entities/field/from-tf.js +156 -10
  188. package/dist-sdk/src/entities/field/locals.d.ts +11 -3
  189. package/dist-sdk/src/entities/field/locals.js +15 -2
  190. package/dist-sdk/src/entities/field/module.js +23 -6
  191. package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
  192. package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
  193. package/dist-sdk/src/entities/field/to-tf.js +293 -35
  194. package/dist-sdk/src/entities/field/types.d.ts +1 -1
  195. package/dist-sdk/src/entities/field/types.js +7 -1
  196. package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
  197. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
  198. package/dist-sdk/src/entities/org/cloud-link.js +4 -5
  199. package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
  200. package/dist-sdk/src/entities/org/email-alias.js +12 -0
  201. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  202. package/dist-sdk/src/entities/org/index.js +1 -0
  203. package/dist-sdk/src/entities/org/phone-provider.js +4 -7
  204. package/dist-sdk/src/entities/organization/build.d.ts +214 -2
  205. package/dist-sdk/src/entities/organization/build.js +145 -4
  206. package/dist-sdk/src/entities/organization/index.d.ts +1 -1
  207. package/dist-sdk/src/entities/organization/index.js +1 -1
  208. package/dist-sdk/src/entities/organization/module.js +4 -1
  209. package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
  210. package/dist-sdk/src/entities/organization/to-tf.js +118 -1
  211. package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
  212. package/dist-sdk/src/entities/phone-service/build.js +2 -2
  213. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
  214. package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
  215. package/dist-sdk/src/entities/phone-service/index.js +1 -1
  216. package/dist-sdk/src/entities/phone-service/types.js +1 -1
  217. package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
  218. package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
  219. package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
  220. package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
  221. package/dist-sdk/src/entities/search-table/build.js +13 -13
  222. package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
  223. package/dist-sdk/src/entities/search-table/index.js +2 -2
  224. package/dist-sdk/src/entities/search-table/printer.js +5 -5
  225. package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
  226. package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
  227. package/dist-sdk/src/entities/shared/context.d.ts +25 -24
  228. package/dist-sdk/src/entities/shared/context.js +36 -35
  229. package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
  230. package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
  231. package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
  232. package/dist-sdk/src/entities/shared/filters/index.js +11 -4
  233. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
  234. package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
  235. package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
  236. package/dist-sdk/src/entities/shared/ref.js +8 -3
  237. package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
  238. package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
  239. package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
  240. package/dist-sdk/src/entities/skill/build.d.ts +2 -2
  241. package/dist-sdk/src/entities/skill/build.js +3 -3
  242. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  243. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
  244. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  245. package/dist-sdk/src/entities/skill/index.js +1 -1
  246. package/dist-sdk/src/entities/skill/module.js +2 -2
  247. package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
  248. package/dist-sdk/src/entities/skill/to-tf.js +2 -2
  249. package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
  250. package/dist-sdk/src/entities/skill/tools.js +4 -3
  251. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
  252. package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
  253. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
  254. package/dist-sdk/src/entities/table/build.d.ts +1 -1
  255. package/dist-sdk/src/entities/table/build.js +9 -9
  256. package/dist-sdk/src/entities/table/catalog-render.js +9 -1
  257. package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
  258. package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
  259. package/dist-sdk/src/entities/table/fields/types.js +1 -1
  260. package/dist-sdk/src/entities/table/index.d.ts +2 -2
  261. package/dist-sdk/src/entities/table/index.js +3 -3
  262. package/dist-sdk/src/entities/table/module.js +1 -1
  263. package/dist-sdk/src/entities/table/to-tf.js +22 -30
  264. package/dist-sdk/src/entities/task/build.d.ts +1 -1
  265. package/dist-sdk/src/entities/task/build.js +5 -5
  266. package/dist-sdk/src/entities/task/index.d.ts +1 -1
  267. package/dist-sdk/src/entities/task/index.js +1 -1
  268. package/dist-sdk/src/entities/view/build.d.ts +46 -0
  269. package/dist-sdk/src/entities/view/build.js +19 -0
  270. package/dist-sdk/src/entities/view/from-tf.js +68 -18
  271. package/dist-sdk/src/entities/view/module.d.ts +6 -13
  272. package/dist-sdk/src/entities/view/module.js +7 -14
  273. package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
  274. package/dist-sdk/src/entities/view/sharing.js +6 -0
  275. package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
  276. package/dist-sdk/src/entities/view/to-tf.js +61 -26
  277. package/dist-sdk/src/entities/view/types.js +3 -0
  278. package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
  279. package/dist-sdk/src/entities/visual-flow/build.js +8 -8
  280. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  281. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  282. package/dist-sdk/src/entities/visual-flow/module.js +1 -1
  283. package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
  284. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
  285. package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
  286. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  287. package/dist-sdk/src/entities/widget/to-tf.js +9 -7
  288. package/dist-sdk/src/graph/index.d.ts +5 -1
  289. package/dist-sdk/src/graph/index.js +4 -1
  290. package/dist-sdk/src/graph/modules.js +6 -1
  291. package/dist-sdk/src/graph/types.d.ts +52 -1
  292. package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
  293. package/dist-sdk/src/internal/safe-identifier.js +13 -0
  294. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  295. package/dist-sdk/src/internal/sdk-package.js +1 -0
  296. package/package.json +12 -3
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Skill emission: `skillToTf` consumes the discovered `DeployableEntity`
3
- * (the `defineSkill` def() payload) and emits `elementum_agentic_skill` +
3
+ * (the `skill` def() payload) and emits `elementum_agentic_skill` +
4
4
  * one tool resource per implemented tool (the tool pass delegates to
5
5
  * `entities/skill-tool/to-tf.ts`). Mirrors `entities/agent/to-tf.ts`.
6
6
  *
@@ -99,7 +99,7 @@ export function skillToTf(entity, ctx) {
99
99
  const payload = entity.payload;
100
100
  const elementum = payload?.skill;
101
101
  if (payload === null || typeof payload !== "object" || elementum === undefined) {
102
- throw new EntityTfError(`skill "${entity.refName}" has no skill payload — was it built with defineSkill?`);
102
+ throw new EntityTfError(`skill "${entity.refName}" has no skill payload — was it built with skill?`);
103
103
  }
104
104
  const tfLabel = appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(entity.refName));
105
105
  const name = elementum.name ?? "";
@@ -60,6 +60,7 @@ export interface SkillRecordRawIdField {
60
60
  readonly name: string;
61
61
  readonly description: string;
62
62
  readonly required: boolean;
63
+ readonly defaultValue?: string;
63
64
  }
64
65
  export type SkillRecordFieldInput<Target extends ToolTarget = ToolTarget> = SkillRecordField<Target> | SkillRecordRawIdField;
65
66
  interface CommonToolOptions {
@@ -80,7 +81,7 @@ export type AutomationToolV2<A extends AutomationCatalogRef = AutomationCatalogR
80
81
  export declare function skillAutomation<A extends AutomationCatalogRef>(opts: AutomationToolV2<A>): SkillTool;
81
82
  export type SkillSearchRecordsToolOptions<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
82
83
  readonly queryDescription: string;
83
- readonly fields: readonly SkillSearchFieldInput<Target>[];
84
+ readonly fields?: readonly SkillSearchFieldInput<Target>[];
84
85
  /** Maximum number of records the search returns. */
85
86
  readonly limit?: number;
86
87
  };
@@ -99,11 +100,11 @@ export type SkillSearchTableToolV2<Target extends ElementCatalogRef = ElementCat
99
100
  };
100
101
  export declare function skillSearchTable<Target extends ElementCatalogRef>(opts: SkillSearchTableToolV2<Target>): SkillTool;
101
102
  export type SkillCreateRecordToolV2<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
102
- readonly fields: readonly SkillRecordFieldInput<Target>[];
103
+ readonly fields?: readonly SkillRecordFieldInput<Target>[];
103
104
  };
104
105
  export declare function skillCreateRecord<Target extends ToolTarget>(opts: SkillCreateRecordToolV2<Target>): SkillTool;
105
106
  export type SkillUpdateRecordToolV2<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
106
- readonly fields: readonly SkillRecordFieldInput<Target>[];
107
+ readonly fields?: readonly SkillRecordFieldInput<Target>[];
107
108
  readonly handleDescription: string;
108
109
  };
109
110
  export declare function skillUpdateRecord<Target extends ToolTarget>(opts: SkillUpdateRecordToolV2<Target>): SkillTool;
@@ -52,6 +52,7 @@ function recordFieldToken(f) {
52
52
  name: f.name,
53
53
  description: f.description,
54
54
  required: f.required,
55
+ ...(f.defaultValue !== undefined ? { defaultValue: f.defaultValue } : {}),
55
56
  };
56
57
  }
57
58
  return {
@@ -96,7 +97,7 @@ export function skillSearchRecords(opts) {
96
97
  ...common(opts),
97
98
  aspectId: targetOf(opts),
98
99
  queryDescription: opts.queryDescription,
99
- fields: opts.fields.map(searchFieldToken),
100
+ ...(opts.fields !== undefined ? { fields: opts.fields.map(searchFieldToken) } : {}),
100
101
  ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
101
102
  },
102
103
  });
@@ -118,7 +119,7 @@ export function skillCreateRecord(opts) {
118
119
  createRecord: {
119
120
  ...common(opts),
120
121
  aspectId: targetOf(opts),
121
- fields: opts.fields.map(recordFieldToken),
122
+ fields: (opts.fields ?? []).map(recordFieldToken),
122
123
  },
123
124
  });
124
125
  }
@@ -127,7 +128,7 @@ export function skillUpdateRecord(opts) {
127
128
  updateRecord: {
128
129
  ...common(opts),
129
130
  aspectId: targetOf(opts),
130
- fields: opts.fields.map(recordFieldToken),
131
+ fields: (opts.fields ?? []).map(recordFieldToken),
131
132
  handleDescription: opts.handleDescription,
132
133
  },
133
134
  });
@@ -20,6 +20,7 @@ export interface NormalizedSkillToolField {
20
20
  readonly name?: string;
21
21
  readonly description?: string;
22
22
  readonly required?: boolean;
23
+ readonly defaultValue?: string;
23
24
  }
24
25
  export type NormalizedSkillToolTarget = {
25
26
  readonly kind: "self";
@@ -62,6 +63,18 @@ export interface NormalizedSkillTool {
62
63
  readonly description?: string;
63
64
  }[];
64
65
  readonly runAs?: AgentToolRunAs;
66
+ /**
67
+ * Names of the target automation's REQUIRED onDemand trigger parameters
68
+ * that this tool's own `inputs` (above) has no mapping for — the platform
69
+ * doesn't enforce that binding at tool-creation time, so a live tool can
70
+ * genuinely have none (edk#483: a Deloitte "sentiment-analysis" skill hit
71
+ * this). `AutomationToolV2` requires every such parameter to be mapped, so
72
+ * the printer needs this to know a type-only escape hatch is required —
73
+ * but the escape hatch must NOT be confused with authored data: unlike
74
+ * `inputs`, this is never fed into `skillToTf`/round-tripped to HCL. See
75
+ * `printTool`'s handling of `typeKey === "automation"`.
76
+ */
77
+ readonly missingRequiredInputs?: readonly string[];
65
78
  }
66
79
  export interface SkillToolOwner {
67
80
  /** The owning app's resource type + tfLabel. */
@@ -146,6 +146,45 @@ export function skillToolFromTf(block, owner, ctx) {
146
146
  ...(typeof rec["required"] === "boolean" && { required: rec["required"] }),
147
147
  });
148
148
  }
149
+ // The tool's own `inputs` attribute can be genuinely absent even when the
150
+ // target automation's onDemand trigger declares required parameters —
151
+ // the platform doesn't enforce that binding at tool-creation time (a
152
+ // live Deloitte "sentiment-analysis" skill hit this: a `run_automation`
153
+ // tool with zero `inputs` targeting an automation whose trigger requires
154
+ // one). `AutomationToolV2` (entities/agent/tools.ts) requires every such
155
+ // parameter to be mapped, so printing nothing here would emit a
156
+ // `skillAutomation({...})` call that can't compile (edk#483). This must
157
+ // NOT be "fixed" by inventing an `inputs` entry that isn't really on the
158
+ // platform — `elementum build` re-serializes whatever `inputs` prints
159
+ // straight back to HCL, so a fabricated entry becomes a genuine plan
160
+ // diff proposing to write fake data onto a live tool (caught live: a
161
+ // rebuilt `run_automation` tool proposed adding an `inputs` block with a
162
+ // literal "TODO: ..." description). Only RECORD which required
163
+ // parameters are unmapped; `printTool` (print-skill-v2.ts) decides how
164
+ // to keep the generated file compiling without asserting any of this as
165
+ // real authored data.
166
+ const mappedParams = new Set(inputs.map((i) => i.parameterName));
167
+ // Found by following the trigger's OWN `automation` reference (mirrors
168
+ // `automationFromTfDocument`'s `references(block.attrs.automation, ...)`
169
+ // in entities/automation/from-tf.ts) rather than guessing that the
170
+ // trigger shares its automation's Terraform label — that label equality
171
+ // holds by observed export convention, not by contract, and a silent
172
+ // miss here would reproduce the exact tsc-failing call this fix is for,
173
+ // with no diagnostic to explain why.
174
+ const trigger = ctx.resourcesOfType?.("elementum_on_demand_trigger").find((block) => {
175
+ const ref = block.attrs["automation"];
176
+ return isTfExpr(ref) && ref.$expr === "resource-attr" && ref.type === "elementum_automation" && ref.label === automationLabel;
177
+ });
178
+ const missingRequiredInputs = [];
179
+ for (const item of Array.isArray(trigger?.attrs["parameters"]) ? trigger.attrs["parameters"] : []) {
180
+ if (typeof item !== "object" || item === null || Array.isArray(item) || isTfExpr(item))
181
+ continue;
182
+ const rec = item;
183
+ if (rec["required"] !== true || typeof rec["name"] !== "string" || mappedParams.has(rec["name"]))
184
+ continue;
185
+ ctx.diagnostics.push(`${where}: target automation's onDemand trigger requires "${rec["name"]}", but this tool has no input mapping for it — printed source will need a human-authored inputs entry before this tool can be adopted`);
186
+ missingRequiredInputs.push(rec["name"]);
187
+ }
149
188
  const outputs = [];
150
189
  for (const item of Array.isArray(attrs["outputs"]) ? attrs["outputs"] : []) {
151
190
  if (typeof item !== "object" || item === null || Array.isArray(item) || isTfExpr(item))
@@ -167,6 +206,7 @@ export function skillToolFromTf(block, owner, ctx) {
167
206
  automationKey: scopedLabelToBagKey(owner.ownerTfLabel, automationLabel),
168
207
  ...(inputs.length > 0 && { inputs }),
169
208
  ...(outputs.length > 0 && { outputs }),
209
+ ...(missingRequiredInputs.length > 0 && { missingRequiredInputs }),
170
210
  };
171
211
  }
172
212
  let searchTableKey;
@@ -267,6 +307,8 @@ export function skillToolFromTf(block, owner, ctx) {
267
307
  // authored source.
268
308
  ...((subType.typeKey === "createRecord" || subType.typeKey === "updateRecord") &&
269
309
  typeof rec["required"] === "boolean" && { required: rec["required"] }),
310
+ ...((subType.typeKey === "createRecord" || subType.typeKey === "updateRecord") &&
311
+ typeof rec["default_value"] === "string" && { defaultValue: rec["default_value"] }),
270
312
  });
271
313
  }
272
314
  if (fields.length === 0)
@@ -258,9 +258,9 @@ export function skillToolToTf(entry, ctx) {
258
258
  if (inner.limit !== undefined)
259
259
  attrs["result_limit"] = inner.limit;
260
260
  }
261
- if (inner.fields !== undefined && inner.fields.length > 0) {
261
+ if (inner.fields !== undefined || typeKey === "createRecord" || typeKey === "updateRecord") {
262
262
  const fieldValues = [];
263
- for (const f of inner.fields) {
263
+ for (const f of inner.fields ?? []) {
264
264
  // A raw-id fallback field (board issue #169) is echoed straight
265
265
  // through — ei never resolves it to a reference either, so there's
266
266
  // nothing to re-derive.
@@ -285,13 +285,13 @@ export function skillToolToTf(entry, ctx) {
285
285
  // hcl_skill.go was fabricating it from Go's zero-value default
286
286
  // rather than an actually-discovered value; fixed 2026-08-11.)
287
287
  ...(typeKey !== "searchAspect" && typeKey !== "searchTable" && { required: f.required ?? false }),
288
+ ...(f.defaultValue !== undefined && { default_value: f.defaultValue }),
288
289
  });
289
- if (f.defaultValue !== undefined) {
290
- ctx.diagnostics.push(`${where}: field default values are not supported on the terraform path yet; dropped`);
291
- }
292
290
  }
293
- if (fieldValues.length > 0)
291
+ const requiresExplicitEmptyFields = (typeKey === "createRecord" || typeKey === "updateRecord") && (inner.fields?.length ?? 0) === 0;
292
+ if (fieldValues.length > 0 || requiresExplicitEmptyFields) {
294
293
  attrs["fields"] = fieldValues;
294
+ }
295
295
  }
296
296
  const block = { kind: "resource", type: subType.resourceType, label: tfLabel, attrs };
297
297
  return { block, address: `${subType.resourceType}.${tfLabel}` };
@@ -102,7 +102,7 @@ export interface TableConfigured<Columns extends Readonly<Record<string, TableCo
102
102
  def(refName: string): DeployableEntity;
103
103
  }
104
104
  /** Build a v2 table entity. The returned object is also a configured entity for file-name ref injection. */
105
- export declare function defineTable<const Columns extends Readonly<Record<string, TableColumn>> = Record<never, never>, const Datamines extends Readonly<Record<string, TableDatamine<Extract<keyof Columns, string>>>> = Record<never, never>>(opts: DefineTableV2Options<Columns, Datamines>): TableConfigured<Columns, Datamines>;
105
+ export declare function table<const Columns extends Readonly<Record<string, TableColumn>> = Record<never, never>, const Datamines extends Readonly<Record<string, TableDatamine<Extract<keyof Columns, string>>>> = Record<never, never>>(opts: DefineTableV2Options<Columns, Datamines>): TableConfigured<Columns, Datamines>;
106
106
  export declare function tablePayloadToReadOnlyUpdateRequest(payload: unknown): TableUpdateRequest;
107
107
  export declare function tablePayloadToCreateRequest(payload: unknown): TableCreateRequest;
108
108
  export declare function fieldNameOf(input: TableFieldCreateInput): string | undefined;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * v2 table authoring — `defineTable`.
2
+ * v2 table authoring — `table`.
3
3
  *
4
4
  * Tables are org-owned. Authoring files keep cross-entity references symbolic
5
5
  * (`source`, join sources, table columns, cloud links) and keep field identity
@@ -37,12 +37,12 @@ function payloadFor(opts, refName) {
37
37
  const handle = opts.handle ?? refName;
38
38
  const name = opts.name ?? handle;
39
39
  if (!name || name.trim() === "") {
40
- throw new EdkValidationError("defineTable requires a non-empty name or file/ref name.");
40
+ throw new EdkValidationError("table requires a non-empty name or file/ref name.");
41
41
  }
42
42
  // The configured factory is created before file discovery supplies its
43
43
  // refName. Validate once a real authored/discovered handle exists.
44
44
  if (handle !== "" && (handle.length < 2 || handle.length > 15)) {
45
- throw new EdkValidationError("defineTable handle must be between 2 and 15 characters.");
45
+ throw new EdkValidationError("table handle must be between 2 and 15 characters.");
46
46
  }
47
47
  const categoryId = opts.category;
48
48
  const joins = opts.joins?.map(serializeJoin);
@@ -74,7 +74,7 @@ function entityFor(opts, refName) {
74
74
  };
75
75
  }
76
76
  /** Build a v2 table entity. The returned object is also a configured entity for file-name ref injection. */
77
- export function defineTable(opts) {
77
+ export function table(opts) {
78
78
  const initialRefName = opts.handle ?? "";
79
79
  const initial = entityFor(opts, initialRefName);
80
80
  return {
@@ -100,7 +100,7 @@ export function defineTable(opts) {
100
100
  }
101
101
  function requireString(value, name) {
102
102
  if (typeof value !== "string" || value.trim() === "") {
103
- throw new EdkValidationError(`defineTable: ${name} is required.`);
103
+ throw new EdkValidationError(`table: ${name} is required.`);
104
104
  }
105
105
  return value;
106
106
  }
@@ -124,10 +124,10 @@ function dataViewOf(payload) {
124
124
  if (views === undefined)
125
125
  return undefined;
126
126
  if (!Array.isArray(views)) {
127
- throw new EdkValidationError("defineTable: `views` must be an array.");
127
+ throw new EdkValidationError("table: `views` must be an array.");
128
128
  }
129
129
  if (views.length > 1) {
130
- throw new EdkValidationError("defineTable currently supports at most one view; the platform exposes a single dataView.");
130
+ throw new EdkValidationError("table currently supports at most one view; the platform exposes a single dataView.");
131
131
  }
132
132
  return views[0];
133
133
  }
@@ -288,7 +288,7 @@ function columnStateFor(key, tableColumns) {
288
288
  const byKey = tableColumns?.[key];
289
289
  if (byKey !== undefined)
290
290
  return byKey;
291
- throw new EdkValidationError(`defineTable: cannot update/delete column "${key}" because no table column id is recorded in state.`);
291
+ throw new EdkValidationError(`table: cannot update/delete column "${key}" because no table column id is recorded in state.`);
292
292
  }
293
293
  function columnIdFor(key, tableColumns) {
294
294
  return columnStateFor(key, tableColumns).id;
@@ -296,7 +296,7 @@ function columnIdFor(key, tableColumns) {
296
296
  function deletionColumnIdFor(key, tableColumns) {
297
297
  const column = columnStateFor(key, tableColumns);
298
298
  if (isHandleTableColumn(column)) {
299
- throw new EdkValidationError(`defineTable: cannot delete HANDLE column "${key}" because it is used as the table id.`);
299
+ throw new EdkValidationError(`table: cannot delete HANDLE column "${key}" because it is used as the table id.`);
300
300
  }
301
301
  return column.id;
302
302
  }
@@ -5,7 +5,15 @@ import { asNamedRef, safeCatalogKey, } from "../../catalog/render-helpers.js";
5
5
  export function renderTableCatalogEntry(args) {
6
6
  const named = asNamedRef(args.ref);
7
7
  const ref = args.ref;
8
- const parts = [`name: ${JSON.stringify(ref.name)}`];
8
+ // A table catalog is exported directly from its per-table module, not
9
+ // nested inside orgCatalog's `tables` bag where stampTableRefs could inject
10
+ // the bag key. Preserve that stable authored identity explicitly; otherwise
11
+ // tableRef falls back to the display name and downstream typed references
12
+ // derive an invalid Terraform lookup label from it.
13
+ const parts = [
14
+ `refName: ${JSON.stringify(args.keyName)}`,
15
+ `name: ${JSON.stringify(ref.name)}`,
16
+ ];
9
17
  const extraFactories = [];
10
18
  const columns = Object.entries(ref.columns ?? {}).sort(([a], [b]) => a.localeCompare(b));
11
19
  if (columns.length > 0) {
@@ -5,13 +5,13 @@ export function normalizeTable(wire, missing) {
5
5
  const columns = withTableKeys(wire.fields ?? [], (field) => field.name, "field")
6
6
  .flatMap(({ key, item }) => normalizeField(item, key, missing) ?? []);
7
7
  if (wire.groupBy != null) {
8
- // `defineTable` has no `groupBy` authoring surface yet — record the gap
8
+ // `table` has no `groupBy` authoring surface yet — record the gap
9
9
  // instead of silently dropping it so re-applying a pulled table doesn't
10
10
  // quietly clear an existing groupBy configuration.
11
11
  missing.record({
12
12
  category: "fieldRef",
13
13
  id: wire.id,
14
- reason: `Table "${wire.name}" has a groupBy configured on the platform, but defineTable's ` +
14
+ reason: `Table "${wire.name}" has a groupBy configured on the platform, but table's ` +
15
15
  `authoring surface has no groupBy option yet. The generated source omits it.`,
16
16
  context: "table groupBy",
17
17
  });
@@ -49,14 +49,14 @@ function normalizeField(wire, key, missing) {
49
49
  def = normalizeReferenceField(wire, sourceFieldId);
50
50
  }
51
51
  else if (typename === "TableFieldPicklist" || typename === "TableFieldMultiPicklist") {
52
- // `defineTable`'s column authoring has no picklist slot — the create/update
52
+ // `table`'s column authoring has no picklist slot — the create/update
53
53
  // wire input only discriminates cloud/calculation/reference. Round-tripping
54
54
  // one as a plain reference field would silently misrepresent it, so record
55
55
  // the gap instead of guessing (see the `main`-branch precedent this restores).
56
56
  missing.record({
57
57
  category: "fieldRef",
58
58
  id: wire.id,
59
- reason: `Field "${wire.name}" is a ${typename} on the platform, but defineTable's ` +
59
+ reason: `Field "${wire.name}" is a ${typename} on the platform, but table's ` +
60
60
  `column authoring has no picklist slot yet. Skipping; edit picklist fields on ` +
61
61
  `the platform UI and re-pull.`,
62
62
  context: `table field "${wire.name}"`,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * `TableFieldDef` — the discriminated union of field shapes accepted
3
- * by `defineTable({ fields: [...] })`. Each variant is produced by a
3
+ * by `table({ fields: [...] })`. Each variant is produced by a
4
4
  * dedicated factory in this directory so authors never construct one
5
5
  * directly. The serializer routes on `kind` and emits the
6
6
  * `TableFieldCreateInput` wire shape.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * `TableFieldDef` — the discriminated union of field shapes accepted
3
- * by `defineTable({ fields: [...] })`. Each variant is produced by a
3
+ * by `table({ fields: [...] })`. Each variant is produced by a
4
4
  * dedicated factory in this directory so authors never construct one
5
5
  * directly. The serializer routes on `kind` and emits the
6
6
  * `TableFieldCreateInput` wire shape.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * v2 table authoring — `defineTable`. Org-owned top-level entity.
2
+ * v2 table authoring — `table`. Org-owned top-level entity.
3
3
  * Standalone from v1's `src/tables`.
4
4
  */
5
- export { defineTable, bigQueryTableMapping, databricksTableMapping, snowflakeTableMapping, snowflakeTableView, tablePayloadToCreateRequest, tablePayloadToReadOnlyUpdateRequest, tablePayloadToUpdateRequest, type DefineTableV2Options, type TableAuthoringPayload, type TableConfigured, type TableView, } from "./build.js";
5
+ export { table, bigQueryTableMapping, databricksTableMapping, snowflakeTableMapping, snowflakeTableView, tablePayloadToCreateRequest, tablePayloadToReadOnlyUpdateRequest, tablePayloadToUpdateRequest, type DefineTableV2Options, type TableAuthoringPayload, type TableConfigured, type TableView, } from "./build.js";
6
6
  export { type TableDatamine, type DatamineSchedule, type DatamineTimeUnit } from "../datamine/build.js";
7
7
  export { calculationColumn, bigQueryColumn, serializeTableField, snowflakeColumn, sourceColumn, tableAggregation, tableColumnTag, tableColumnType, tableExpansion, type CalculationColumnOptions, type SourceColumnOptions, type TableAggregation, type TableColumn, type TableColumnTag, type TableColumnType, type TableCalculationField, type TableCloudField, type TableField, type TableExpansion, type TableReferenceField, } from "./fields.js";
8
8
  export { serializeJoin, tableJoin, tableJoinType, type TableJoinFieldPair, type TableJoin, type TableJoinOptions, type TableJoinType, } from "./joins.js";
@@ -1,12 +1,12 @@
1
1
  /**
2
- * v2 table authoring — `defineTable`. Org-owned top-level entity.
2
+ * v2 table authoring — `table`. Org-owned top-level entity.
3
3
  * Standalone from v1's `src/tables`.
4
4
  */
5
- export { defineTable, bigQueryTableMapping, databricksTableMapping, snowflakeTableMapping, snowflakeTableView, tablePayloadToCreateRequest, tablePayloadToReadOnlyUpdateRequest, tablePayloadToUpdateRequest, } from "./build.js";
5
+ export { table, bigQueryTableMapping, databricksTableMapping, snowflakeTableMapping, snowflakeTableView, tablePayloadToCreateRequest, tablePayloadToReadOnlyUpdateRequest, tablePayloadToUpdateRequest, } from "./build.js";
6
6
  export { calculationColumn, bigQueryColumn, serializeTableField, snowflakeColumn, sourceColumn, tableAggregation, tableColumnTag, tableColumnType, tableExpansion, } from "./fields.js";
7
7
  export { serializeJoin, tableJoin, tableJoinType, } from "./joins.js";
8
8
  export * as filter from "../shared/filters/index.js";
9
- // `defineTable.fromJSON` has no callable to attach to (the builder returns a
9
+ // `table.fromJSON` has no callable to attach to (the builder returns a
10
10
  // configured object), so the table pull orchestrator
11
11
  // ships as a standalone named export — mirroring the other materialize-backed
12
12
  // entities (agents, skills, aspects, automations).
@@ -16,7 +16,7 @@ export const tableModule = {
16
16
  resource: { shape: "single", resourceType: TABLE_RESOURCE_TYPE, adoptable: true },
17
17
  // Cross-table relationships already emit name-keyed data lookups through
18
18
  // OrgRefLookup.rawLookup; register that real build surface in the graph.
19
- data: { participates: true, resourceType: "elementum_table", lookupAttr: "name", referencedByBuild: true },
19
+ data: { participates: true, resourceType: "elementum_table", lookupAttr: "name", referencedByBuild: true, referenceLookups: [{ strategy: "rootName" }] },
20
20
  lifecycle: { participates: true, extractStreamRoot: extract, toTf: (entity, ctx) => tableToTf(entity, { orgRefs: ctx.orgRefs, diagnostics: ctx.diagnostics, workspaceAspects: ctx.workspaceAspects }) },
21
21
  canvas: { participates: true, label: "Tables", glyph: "▤", component: "generic" },
22
22
  catalog: {
@@ -5,6 +5,7 @@ import { CATEGORY_ORG_BAG } from "../org/category.js";
5
5
  import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
6
6
  import { tableDataminesToTf, } from "../datamine/to-tf.js";
7
7
  import { fieldRefToTfValue } from "../field/to-tf.js";
8
+ import { resolveForeignRef } from "../shared/foreign-ref.js";
8
9
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
9
10
  import { TABLE_RESOURCE_TYPE } from "./module.js";
10
11
  function tableColumnName(column) {
@@ -18,32 +19,28 @@ function tableColumnName(column) {
18
19
  }
19
20
  return undefined;
20
21
  }
21
- function aspectId(ref, orgRefs, workspaceAspects) {
22
+ function aspectId(ref, orgRefs, workspaceAspects, diagnostics, where = "table aspect reference") {
22
23
  if (typeof ref === "string")
23
24
  return ref;
24
25
  const name = ref.name ?? ref.refName ?? "";
25
- const label = sanitizeName(name);
26
26
  if (ref.__kind === "table") {
27
- orgRefs.rawLookup("elementum_table", label, name);
28
- return expr.dataAttr("elementum_table", label, ["id"]);
27
+ return resolveForeignRef("table", { name }, orgRefs, diagnostics, where).value;
29
28
  }
30
29
  if (ref.__kind === "element") {
31
30
  const local = workspaceAspects?.get(workspaceAspectKey("element", ref.refName ?? ""));
32
31
  if (local !== undefined)
33
32
  return expr.resourceAttr("elementum_element", local.tfLabel, ["id"]);
34
- orgRefs.foreignElement(label, name);
35
- return expr.dataAttr("elementum_element", label, ["id"]);
33
+ return resolveForeignRef("element", { name, namespace: ref.namespace }, orgRefs, diagnostics, where).value;
36
34
  }
37
35
  if (ref.__kind === "app") {
38
36
  const local = workspaceAspects?.get(workspaceAspectKey("app", ref.refName ?? ""));
39
37
  if (local !== undefined)
40
38
  return expr.resourceAttr("elementum_app", local.tfLabel, ["id"]);
41
- orgRefs.foreignApp(label, name);
42
- return expr.dataAttr("elementum_app", label, ["id"]);
39
+ return resolveForeignRef("app", { name, namespace: ref.namespace }, orgRefs, diagnostics, where).value;
43
40
  }
44
- throw new EntityTfError(`defineTable source must be an app, element, table, or raw id`);
41
+ throw new EntityTfError(`table source must be an app, element, table, or raw id`);
45
42
  }
46
- function fieldId(value, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspects) {
43
+ function fieldId(value, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspects, diagnostics) {
47
44
  if (typeof value === "string")
48
45
  return value;
49
46
  if (value !== null &&
@@ -56,7 +53,7 @@ function fieldId(value, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspe
56
53
  const key = ref.refName ?? "";
57
54
  const name = ownColumnNames[key];
58
55
  if (name === undefined) {
59
- throw new EntityTfError(`defineTable filter references unknown column key ${JSON.stringify(key)}`);
56
+ throw new EntityTfError(`table filter references unknown column key ${JSON.stringify(key)}`);
60
57
  }
61
58
  return expr.resourceAttr(TABLE_RESOURCE_TYPE, ownLabel, [
62
59
  "field_ids",
@@ -81,22 +78,17 @@ function fieldId(value, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspe
81
78
  return resolved;
82
79
  }
83
80
  const parentName = ref.parentName ?? parent;
84
- const parentLabel = sanitizeName(parentName);
85
- if (kind === "element")
86
- orgRefs.foreignElement(parentLabel, parentName);
87
- else
88
- orgRefs.foreignApp(parentLabel, parentName);
81
+ const owner = resolveForeignRef(kind, { name: parentName }, orgRefs, diagnostics, "table field owner");
89
82
  const label = sanitizeName(`${parent}_${ref.refName ?? ref.name ?? "field"}`);
90
- const parentType = kind === "element" ? "elementum_element" : "elementum_app";
91
- orgRefs.foreignField("elementum_field", label, expr.dataAttr(parentType, parentLabel, ["id"]), ref.name ?? ref.refName ?? "");
83
+ orgRefs.foreignField("elementum_field", label, owner.value, ref.name ?? ref.refName ?? "");
92
84
  return expr.dataAttr("elementum_field", label, ["id"]);
93
85
  }
94
- throw new EntityTfError(`defineTable field reference has an unsupported shape`);
86
+ throw new EntityTfError(`table field reference has an unsupported shape`);
95
87
  }
96
- function tableFilterToTf(filter, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspects) {
88
+ function tableFilterToTf(filter, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspects, diagnostics) {
97
89
  return serializeFilterToTf(filter, {
98
- field: (field) => fieldId(field, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspects),
99
- aspect: (aspect) => aspectId(aspect, orgRefs, workspaceAspects),
90
+ field: (field) => fieldId(field, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspects, diagnostics),
91
+ aspect: (aspect) => aspectId(aspect, orgRefs, workspaceAspects, diagnostics, "table filter aspect"),
100
92
  reference: () => { throw new EntityTfError("table filters do not support reference values"); },
101
93
  });
102
94
  }
@@ -122,7 +114,7 @@ export function tableToTf(entity, ctx) {
122
114
  "id",
123
115
  ]);
124
116
  if (p.source !== undefined)
125
- attrs["source_id"] = aspectId(p.source, ctx.orgRefs, ctx.workspaceAspects);
117
+ attrs["source_id"] = aspectId(p.source, ctx.orgRefs, ctx.workspaceAspects, ctx.diagnostics, "table source");
126
118
  for (const key of ["description", "icon", "color"])
127
119
  if (p[key] !== undefined)
128
120
  attrs[key] = p[key];
@@ -175,7 +167,7 @@ export function tableToTf(entity, ctx) {
175
167
  const c = column.reference;
176
168
  const result = {
177
169
  name: c.name,
178
- reference_field_id: fieldId(c.field, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects),
170
+ reference_field_id: fieldId(c.field, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects, ctx.diagnostics),
179
171
  ...(Array.isArray(c.tags) && { tags: c.tags }),
180
172
  };
181
173
  if (typeof c.aggregation === "string")
@@ -188,17 +180,17 @@ export function tableToTf(entity, ctx) {
188
180
  if (p.joins !== undefined)
189
181
  attrs["joins"] = p.joins.map((join) => ({
190
182
  type: join.type,
191
- source_id: aspectId(join.source, ctx.orgRefs, ctx.workspaceAspects),
183
+ source_id: aspectId(join.source, ctx.orgRefs, ctx.workspaceAspects, ctx.diagnostics, "table join source"),
192
184
  join_on: (join.joinOn ?? []).map((pair) => ({
193
- left_field_id: fieldId(pair.leftFieldId, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects),
194
- right_field_id: fieldId(pair.rightFieldId, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects),
185
+ left_field_id: fieldId(pair.leftFieldId, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects, ctx.diagnostics),
186
+ right_field_id: fieldId(pair.rightFieldId, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects, ctx.diagnostics),
195
187
  })),
196
188
  ...(join.filter !== undefined && {
197
- filter: tableFilterToTf(join.filter, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects),
189
+ filter: tableFilterToTf(join.filter, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects, ctx.diagnostics),
198
190
  }),
199
191
  }));
200
192
  if (p.filter !== undefined) {
201
- attrs["filter"] = tableFilterToTf(p.filter, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects);
193
+ attrs["filter"] = tableFilterToTf(p.filter, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects, ctx.diagnostics);
202
194
  }
203
195
  if (typeof p.limit === "number")
204
196
  attrs["limit"] = p.limit;
@@ -223,7 +215,7 @@ export function tableToTf(entity, ctx) {
223
215
  tableTfLabel: label,
224
216
  columnNames,
225
217
  diagnostics: ctx.diagnostics,
226
- filterToTf: (filter) => tableFilterToTf(filter, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects),
218
+ filterToTf: (filter) => tableFilterToTf(filter, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects, ctx.diagnostics),
227
219
  }),
228
220
  ],
229
221
  };
@@ -39,5 +39,5 @@ export interface DefineTaskOptions extends EntityDeployOptions {
39
39
  export interface TaskConfigured {
40
40
  def(refName: string): DeployableEntity;
41
41
  }
42
- export declare function defineTask(opts: DefineTaskOptions): TaskConfigured;
42
+ export declare function task(opts: DefineTaskOptions): TaskConfigured;
43
43
  export {};
@@ -1,14 +1,14 @@
1
1
  import { slimTokens } from "../../catalog/index.js";
2
2
  export const taskStatusTag = { closed: "CLOSED" };
3
- export function defineTask(opts) {
3
+ export function task(opts) {
4
4
  if (opts.name.trim() === "")
5
- throw new Error("defineTask requires a non-empty name.");
5
+ throw new Error("task requires a non-empty name.");
6
6
  if (opts.handle !== undefined && !/^[A-Za-z]+$/.test(opts.handle))
7
- throw new Error(`defineTask ${JSON.stringify(opts.name)}: handle must contain only letters.`);
7
+ throw new Error(`task ${JSON.stringify(opts.name)}: handle must contain only letters.`);
8
8
  if (opts.namespace !== undefined && !/^[A-Za-z]+$/.test(opts.namespace))
9
- throw new Error(`defineTask ${JSON.stringify(opts.name)}: namespace must contain only letters.`);
9
+ throw new Error(`task ${JSON.stringify(opts.name)}: namespace must contain only letters.`);
10
10
  if (opts.category.refName.trim() === "")
11
- throw new Error(`defineTask ${JSON.stringify(opts.name)}: category ref is required.`);
11
+ throw new Error(`task ${JSON.stringify(opts.name)}: category ref is required.`);
12
12
  return { def(refName) {
13
13
  const handle = opts.handle ?? refName.replace(/[^A-Za-z]/g, "").toUpperCase();
14
14
  const namespace = opts.namespace ?? refName.replace(/[^A-Za-z]/g, "").toLowerCase();
@@ -1 +1 @@
1
- export { defineTask, taskStatusTag, type DefineTaskOptions, type TaskConfigured, type TaskStatusOption, type TaskStatusTag } from "./build.js";
1
+ export { task, taskStatusTag, type DefineTaskOptions, type TaskConfigured, type TaskStatusOption, type TaskStatusTag } from "./build.js";
@@ -1 +1 @@
1
- export { defineTask, taskStatusTag } from "./build.js";
1
+ export { task, taskStatusTag } from "./build.js";
@@ -0,0 +1,46 @@
1
+ import type { FieldRef } from "../../catalog/types.js";
2
+ import type { UnsafePlatformId } from "../../core/platform-id.js";
3
+ import type { SystemFieldKey } from "../../core/system-fields.js";
4
+ /** Sort directions accepted by every managed-view resource. */
5
+ export declare const managedViewSortDirection: {
6
+ readonly ascending: "ASC";
7
+ readonly descending: "DESC";
8
+ };
9
+ export type ManagedViewSortDirection = (typeof managedViewSortDirection)[keyof typeof managedViewSortDirection];
10
+ /** Optional aggregations accepted by a managed-view sort order. */
11
+ export declare const managedViewSortAggregation: {
12
+ readonly average: "AVERAGE";
13
+ readonly count: "COUNT";
14
+ readonly maximum: "MAX";
15
+ readonly minimum: "MIN";
16
+ readonly sum: "SUM";
17
+ };
18
+ export type ManagedViewSortAggregation = (typeof managedViewSortAggregation)[keyof typeof managedViewSortAggregation];
19
+ /** A custom/system field to order by, or an explicit non-portable id escape hatch. */
20
+ export type ManagedViewSortField = FieldRef | SystemFieldKey | UnsafePlatformId;
21
+ /** One order in the platform's managed-view Sort contract. */
22
+ export interface ManagedViewSortOrder {
23
+ readonly field: ManagedViewSortField;
24
+ readonly aggregation?: ManagedViewSortAggregation | null;
25
+ readonly direction: ManagedViewSortDirection;
26
+ }
27
+ /** The provider's JSON-encoded managed-view Sort contract. */
28
+ export interface ManagedViewSort {
29
+ readonly orders: readonly ManagedViewSortOrder[];
30
+ }
31
+ /** Pull-time projection after Terraform field references become source bag keys. */
32
+ export interface NormalizedManagedViewSortOrder {
33
+ readonly field: string;
34
+ readonly aggregation?: ManagedViewSortAggregation | null;
35
+ readonly direction: ManagedViewSortDirection;
36
+ }
37
+ export interface NormalizedManagedViewSort {
38
+ readonly orders: readonly NormalizedManagedViewSortOrder[];
39
+ }
40
+ /** Row-density values accepted by a managed list view. */
41
+ export declare const listViewDensity: {
42
+ readonly comfortable: "COMFORTABLE";
43
+ readonly compact: "COMPACT";
44
+ readonly standard: "STANDARD";
45
+ };
46
+ export type ListViewDensity = (typeof listViewDensity)[keyof typeof listViewDensity];