@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
@@ -17,6 +17,23 @@ import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, tsLabe
17
17
  import { EntityTfError } from "../../engine/entity.js";
18
18
  import { fieldRefToTfValue } from "../field/to-tf.js";
19
19
  import { TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
20
+ function serviceAccountIdValue(token, where, ctx) {
21
+ if (token.__kind !== "serviceAccount" || token.name === undefined || token.name === "") {
22
+ ctx.diagnostics.push(`${where}: serviceAccount must be a serviceAccountRef({ app, name }); dropped`);
23
+ return undefined;
24
+ }
25
+ if (token.appRefName !== ctx.appRefName) {
26
+ ctx.diagnostics.push(`${where}: service account "${token.name}" belongs to app "${token.appRefName ?? ""}", not owning app "${ctx.appRefName}"; dropped`);
27
+ return undefined;
28
+ }
29
+ const tfLabel = appScopedResourceLabel(ctx.appTfLabel, sanitizeName(token.name));
30
+ if (ctx.serviceAccountRef === undefined) {
31
+ ctx.diagnostics.push(`${where}: build context cannot materialize a service-account lookup; dropped`);
32
+ return undefined;
33
+ }
34
+ return ctx.serviceAccountRef(tfLabel, token.name) ??
35
+ expr.dataAttr("elementum_service_account", tfLabel, ["id"]);
36
+ }
20
37
  /** authoring app/element token → its resolved target (workspace resource or foreign data ref). */
21
38
  function resolveTarget(token, ctx) {
22
39
  const refName = token.refName ?? "";
@@ -41,15 +58,15 @@ function resolveTarget(token, ctx) {
41
58
  }
42
59
  // ei derives foreign-app/foreign-element data labels from the display NAME.
43
60
  const name = token.name ?? refName;
44
- const tfLabel = sanitizeName(name);
61
+ const tfLabel = sanitizeName(token.namespace ?? name);
45
62
  // Board issue #42: an aspect token can be an element, not just an app —
46
63
  // must emit `data.elementum_element`, never `data.elementum_app`, or the
47
64
  // provider looks up the wrong resource type entirely.
48
65
  if (kind === "element") {
49
- ctx.foreignElementRef(tfLabel, name);
66
+ ctx.foreignElementRef(tfLabel, name, token.namespace);
50
67
  return { value: expr.dataAttr("elementum_element", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
51
68
  }
52
- ctx.foreignAppRef(tfLabel, name);
69
+ ctx.foreignAppRef(tfLabel, name, token.namespace);
53
70
  return { value: expr.dataAttr("elementum_app", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
54
71
  }
55
72
  /**
@@ -60,7 +77,7 @@ function resolveTarget(token, ctx) {
60
77
  * from some unrelated third aspect silently pair with this target's id;
61
78
  * see `resolveFieldForTarget`) + the field's display name. Same pattern as
62
79
  * `automation/to-tf.ts`'s `crossAppFieldToTf` and `field/to-tf.ts`'s
63
- * `resolveRelatedLabelField`.
80
+ * `resolveFieldOnObject`.
64
81
  */
65
82
  function foreignTargetFieldRefValue(token, refName, target, ctx) {
66
83
  const fieldName = token.name ?? refName;
@@ -151,12 +168,6 @@ export function toolToTf(entry, ctx) {
151
168
  ctx.diagnostics.push(`agent tool entry "${typeKey}" has a non-object body; dropped`);
152
169
  return undefined;
153
170
  }
154
- // Tool-name validity is enforced in the authoring builders (entities/agent/
155
- // tools.ts), not here — from-tf/to-tf must round-trip whatever the platform
156
- // holds, including a hyphenated name deployed outside EDK.
157
- if (inner.runAs !== undefined) {
158
- ctx.diagnostics.push(`agent tool "${name}": runAs is not supported on the terraform path yet; dropped`);
159
- }
160
171
  const where = `agent tool "${name}"`;
161
172
  const agentTfLabel = appScopedResourceLabel(ctx.appTfLabel, ctx.agentBareTfLabel);
162
173
  const tfLabel = appScopedResourceLabel(ctx.appTfLabel, sanitizeName(`${ctx.agentBareTfLabel}_${name}`));
@@ -168,6 +179,23 @@ export function toolToTf(entry, ctx) {
168
179
  };
169
180
  if (inner.startMessage !== undefined)
170
181
  attrs["start_message"] = inner.startMessage;
182
+ const runAs = inner.runAs;
183
+ if (runAs?.["currentUser"] === true) {
184
+ attrs["run_as"] = "current_user";
185
+ }
186
+ else if (runAs?.["publisher"] === true) {
187
+ attrs["run_as"] = "publisher";
188
+ }
189
+ else if (runAs?.["serviceAccount"] !== undefined) {
190
+ const serviceAccountId = serviceAccountIdValue(runAs["serviceAccount"], where, ctx);
191
+ if (serviceAccountId !== undefined) {
192
+ attrs["run_as"] = "service_account";
193
+ attrs["service_account_id"] = serviceAccountId;
194
+ }
195
+ }
196
+ else if (runAs !== undefined) {
197
+ ctx.diagnostics.push(`${where}: runAs ${JSON.stringify(runAs)} is not supported; dropped`);
198
+ }
171
199
  if (typeKey === "executeWorkflow") {
172
200
  const auto = inner.automationId;
173
201
  // Identity is the token's refName (the bag key — its tfLabel image IS the
@@ -183,15 +211,28 @@ export function toolToTf(entry, ctx) {
183
211
  return undefined;
184
212
  }
185
213
  if (auto.parent !== undefined && auto.parent !== ctx.appRefName) {
186
- ctx.diagnostics.push(`${where}: automation "${auto.refName ?? auto.name}" belongs to app "${auto.parent}" — cross-app run-automation tools are not supported on the terraform path yet; dropped`);
187
- return undefined;
214
+ if (auto.parentKind === undefined || auto.parentName === undefined) {
215
+ ctx.diagnostics.push(`${where}: foreign automation has incomplete owner identity; dropped`);
216
+ return undefined;
217
+ }
218
+ const dataLabel = `${auto.parentKind}_${tsLabelToTfLabel(auto.parent)}_${autoTfLabel}`;
219
+ if (ctx.foreignAutomationRef === undefined) {
220
+ ctx.diagnostics.push(`${where}: foreign automation lookup registry is unavailable; dropped`);
221
+ return undefined;
222
+ }
223
+ ctx.foreignAutomationRef(dataLabel, auto.name ?? auto.refName ?? "", {
224
+ kind: auto.parentKind,
225
+ refName: auto.parent,
226
+ name: auto.parentName,
227
+ ...(auto.parentNamespace !== undefined ? { namespace: auto.parentNamespace } : {}),
228
+ });
229
+ attrs["automation_id"] = expr.dataAttr("elementum_automation", dataLabel, ["id"]);
230
+ }
231
+ else {
232
+ // The automation and workflow-publish resources carry the same platform
233
+ // id. Reference the publish block so Terraform sequences publication.
234
+ attrs["automation_id"] = expr.resourceAttr("elementum_workflow_publish", appScopedResourceLabel(ctx.appTfLabel, autoTfLabel), ["id"]);
188
235
  }
189
- // The automation and workflow-publish resources carry the same platform
190
- // id. Reference the publish block so Terraform cannot create the tool
191
- // until the provider has published the workflow whose bindings it reads.
192
- // ei export normalizes this back to elementum_automation.<label>.id; the
193
- // live round-trip comparator treats only those two references as equal.
194
- attrs["automation_id"] = expr.resourceAttr("elementum_workflow_publish", appScopedResourceLabel(ctx.appTfLabel, autoTfLabel), ["id"]);
195
236
  if (inner.inputs !== undefined && inner.inputs.length > 0) {
196
237
  attrs["inputs"] = inner.inputs.map((i) => ({
197
238
  parameter_name: i.triggerParameterId?.name ?? "",
@@ -335,26 +376,28 @@ export function toolToTf(entry, ctx) {
335
376
  // after the first (confirmed live 2026-08-05). Pin it, like
336
377
  // executeWorkflow's `timeout`, so config and state agree.
337
378
  required: f.required ?? false,
379
+ ...(f.defaultValue !== undefined && { default_value: f.defaultValue }),
338
380
  });
339
- if (f.defaultValue !== undefined) {
340
- ctx.diagnostics.push(`${where}: field default values are not supported on the terraform path yet; dropped`);
341
- }
342
381
  }
343
382
  if (fieldValues.length > 0)
344
383
  attrs["fields"] = fieldValues;
345
384
  }
346
- // searchTable's own field shapes: field_id is always a raw platform id
347
- // (see SearchTableFieldWire/ReturnFieldWire's comments) - no
348
- // fieldRefValue resolution, unlike the shared `fields` block above.
385
+ // Search-table fields use the same target-owned FieldRef resolution as
386
+ // other agent tools while preserving their distinct provider dialect.
349
387
  if (inner.searchTableFields !== undefined && inner.searchTableFields.length > 0) {
350
388
  const values = [];
351
389
  for (const f of inner.searchTableFields) {
352
- if (f.fieldId === undefined || f.fieldId === "") {
390
+ const ref = typeof f.fieldId === "string"
391
+ ? f.fieldId
392
+ : f.fieldId === undefined
393
+ ? undefined
394
+ : fieldRefValue(f.fieldId, where, ctx, target);
395
+ if (ref === undefined || ref === "") {
353
396
  ctx.diagnostics.push(`${where}: fields item has no fieldId; dropped`);
354
397
  continue;
355
398
  }
356
399
  values.push({
357
- field_id: f.fieldId,
400
+ field_id: ref,
358
401
  ...(f.name !== undefined && { name: f.name }),
359
402
  ...(f.description !== undefined && { description: f.description }),
360
403
  });
@@ -365,12 +408,17 @@ export function toolToTf(entry, ctx) {
365
408
  if (inner.returnFields !== undefined && inner.returnFields.length > 0) {
366
409
  const returnFieldValues = [];
367
410
  for (const f of inner.returnFields) {
368
- if (f.fieldId === undefined || f.fieldId === "") {
411
+ const ref = typeof f.fieldId === "string"
412
+ ? f.fieldId
413
+ : f.fieldId === undefined
414
+ ? undefined
415
+ : fieldRefValue(f.fieldId, where, ctx, target);
416
+ if (ref === undefined || ref === "") {
369
417
  ctx.diagnostics.push(`${where}: return_fields item has no fieldId; dropped`);
370
418
  continue;
371
419
  }
372
420
  returnFieldValues.push({
373
- field_id: f.fieldId,
421
+ field_id: ref,
374
422
  ...(f.name !== undefined && { name: f.name }),
375
423
  ...(f.displayName !== undefined && { display_name: f.displayName }),
376
424
  });
@@ -38,5 +38,4 @@ export declare const ALL_TOOL_RESOURCE_TYPES: readonly string[];
38
38
  * still be pullable.
39
39
  */
40
40
  export declare function isValidToolName(name: string): boolean;
41
- /** Attributes `toolFromTf` understands per implemented sub-type — growth is reported loudly. */
42
41
  export declare const KNOWN_TOOL_ATTRS: Readonly<Record<string, ReadonlySet<string>>>;
@@ -42,25 +42,18 @@ export function isValidToolName(name) {
42
42
  return /^[A-Za-z0-9_]{1,64}$/.test(name) && !name.includes("__");
43
43
  }
44
44
  /** Attributes `toolFromTf` understands per implemented sub-type — growth is reported loudly. */
45
+ const COMMON_TOOL_ATTRS = ["agent_id", "app_id", "name", "description", "start_message", "run_as", "service_account_id"];
45
46
  export const KNOWN_TOOL_ATTRS = {
46
- createRecord: new Set(["agent_id", "app_id", "name", "description", "start_message", "target_id", "fields"]),
47
+ createRecord: new Set([...COMMON_TOOL_ATTRS, "target_id", "fields"]),
47
48
  executeWorkflow: new Set([
48
- "agent_id",
49
- "app_id",
50
- "name",
51
- "description",
52
- "start_message",
49
+ ...COMMON_TOOL_ATTRS,
53
50
  "automation_id",
54
51
  "inputs",
55
52
  "outputs",
56
53
  "timeout",
57
54
  ]),
58
55
  searchAspect: new Set([
59
- "agent_id",
60
- "app_id",
61
- "name",
62
- "description",
63
- "start_message",
56
+ ...COMMON_TOOL_ATTRS,
64
57
  "target_id",
65
58
  "query_description",
66
59
  "result_limit",
@@ -68,11 +61,7 @@ export const KNOWN_TOOL_ATTRS = {
68
61
  "filter_variables",
69
62
  ]),
70
63
  updateRecord: new Set([
71
- "agent_id",
72
- "app_id",
73
- "name",
74
- "description",
75
- "start_message",
64
+ ...COMMON_TOOL_ATTRS,
76
65
  "target_id",
77
66
  "handle_description",
78
67
  "fields",
@@ -86,11 +75,7 @@ export const KNOWN_TOOL_ATTRS = {
86
75
  // since re-emitting the wrong one on an already-migrated tool would plan
87
76
  // a spurious diff on every apply.
88
77
  searchTable: new Set([
89
- "agent_id",
90
- "app_id",
91
- "name",
92
- "description",
93
- "start_message",
78
+ ...COMMON_TOOL_ATTRS,
94
79
  "target_id",
95
80
  "search_table_id",
96
81
  "query_description",
@@ -99,30 +84,18 @@ export const KNOWN_TOOL_ATTRS = {
99
84
  "return_fields",
100
85
  ]),
101
86
  relateRecord: new Set([
102
- "agent_id",
103
- "app_id",
104
- "name",
105
- "description",
106
- "start_message",
87
+ ...COMMON_TOOL_ATTRS,
107
88
  "target_id",
108
89
  "related_target_id",
109
90
  ]),
110
91
  runAgent: new Set([
111
- "agent_id",
112
- "app_id",
113
- "name",
114
- "description",
115
- "start_message",
92
+ ...COMMON_TOOL_ATTRS,
116
93
  "target_agent_id",
117
94
  "worker_task_prompt",
118
95
  ]),
119
- selectBotRoute: new Set(["agent_id", "app_id", "name", "description", "start_message", "bot_id"]),
96
+ selectBotRoute: new Set([...COMMON_TOOL_ATTRS, "bot_id"]),
120
97
  mcp: new Set([
121
- "agent_id",
122
- "app_id",
123
- "name",
124
- "description",
125
- "start_message",
98
+ ...COMMON_TOOL_ATTRS,
126
99
  "server_url",
127
100
  "mcp_tool_name",
128
101
  "headers",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * v2 app/element authoring — `defineApp`. Parallel to v1 `src/aspects`,
2
+ * v2 app/element authoring — `app`. Parallel to v1 `src/aspects`,
3
3
  * standalone from it.
4
4
  *
5
5
  * Produces a `DeployableEntity` of kind `app`/`element` with `parent: "org"` (apps are
@@ -12,12 +12,15 @@
12
12
  * dependent picklists, display blocks, and field-id reconciliation for updates
13
13
  * follow the same pattern and land as expansion.
14
14
  */
15
- import { type AgentRef, type AppOrElementRef, type AutomationCatalogRef, type CatalogRef, type CloudLinkRef, type FieldRef } from "../../catalog/index.js";
15
+ import { type AgentRef, type AppOrElementRef, type AutomationCatalogRef, type CatalogRef, type ChartRef, type CloudLinkRef, type DashboardRef, type FieldRef } from "../../catalog/index.js";
16
16
  import type { WorkflowFieldType } from "../shared/types/field-types.js";
17
17
  import { type SystemFieldKey } from "../../core/system-fields.js";
18
18
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
19
19
  import type { AspectFieldInput } from "../../../elementum-entity-client/clients/aspects/models/field-types.js";
20
- import type { AccessPolicyGroupRef, AccessPolicyOptions, AccessPolicyUserRef } from "../access-policy/build.js";
20
+ import type { AspectFieldQrFormat, AspectNumericFieldFormat } from "../../../elementum-entity-client/clients/aspects/models/format.js";
21
+ import type { AccessPolicyOptions } from "../access-policy/build.js";
22
+ import type { ManagedViewSharing } from "../view/sharing.js";
23
+ import type { ListViewDensity, ManagedViewSort } from "../view/build.js";
21
24
  import type { AppDynamicLayout } from "../dynamic-layout/build.js";
22
25
  import type { AppRelationship } from "../relationship/build.js";
23
26
  import type { AppWidget } from "../widget/build.js";
@@ -26,8 +29,19 @@ import type { AppRole } from "../role/build.js";
26
29
  import type { AppServiceAccount } from "../service-account/build.js";
27
30
  import type { Filter } from "../shared/filters/types.js";
28
31
  import { type DisplayBlock } from "./display-blocks.js";
29
- import type { Expr, ExprType } from "../field/calc.js";
32
+ import type { CalculationInclude, Expr, ExprContext, ExprType } from "../field/calc.js";
30
33
  import type { UnsafePlatformId } from "../../core/platform-id.js";
34
+ /**
35
+ * One entry of a dynamic picklist's `sort.orders` — `field` is a token on
36
+ * the related aspect (same convention as `relatedLabelFieldId`), resolved
37
+ * at plan/apply the same way filter fields are. Everything else is the
38
+ * platform's own opaque sort payload.
39
+ */
40
+ export interface AppPicklistDynamicSortOrder {
41
+ readonly field: FieldRef | UnsafePlatformId;
42
+ readonly direction?: "ASC" | "DESC";
43
+ readonly aggregation?: unknown;
44
+ }
31
45
  /**
32
46
  * Authoring-time picklist config. Wire `PicklistConfigInput` uses bare id
33
47
  * strings; here `relatedAspectId` / `relatedLabelFieldId` / `parentFieldId`
@@ -37,6 +51,12 @@ import type { UnsafePlatformId } from "../../core/platform-id.js";
37
51
  * `relatedAspectId`. `relatedLabelFieldId` may still need a raw field id
38
52
  * when the related aspect isn't the entity being deployed (field tokens
39
53
  * resolve against the current app's state only).
54
+ *
55
+ * `sort` is the platform's own JSON sort payload — opaque EXCEPT for the
56
+ * one known `{ orders: [...] }` shape, whose `field` is a typed ref
57
+ * resolved like any other field token (issue #484: a bare field name/id
58
+ * there can't survive a fresh deploy, and any other JSON shape the platform
59
+ * doesn't recognize trips its post-apply consistency check).
40
60
  */
41
61
  export interface AppPicklistDynamicConfig {
42
62
  readonly relatedAspectId: AppOrElementRef | UnsafePlatformId;
@@ -45,7 +65,11 @@ export interface AppPicklistDynamicConfig {
45
65
  readonly autoRelate?: boolean;
46
66
  readonly valuesRenderType?: string;
47
67
  readonly filter?: Filter;
48
- readonly sort?: Readonly<Record<string, unknown>>;
68
+ readonly sort?: {
69
+ readonly orders: readonly AppPicklistDynamicSortOrder[];
70
+ } | (Readonly<Record<string, unknown>> & {
71
+ readonly orders?: never;
72
+ });
49
73
  }
50
74
  export interface AppPicklistConfig {
51
75
  readonly static?: {
@@ -56,7 +80,7 @@ export interface AppPicklistConfig {
56
80
  readonly dynamic?: AppPicklistDynamicConfig;
57
81
  }
58
82
  /**
59
- * A field authored on a v2 app or element — shared with `defineElement`
83
+ * A field authored on a v2 app or element — shared with `element`
60
84
  * (`src/elements/build.ts`), which imports this type and {@link serializeField}
61
85
  * directly from here rather than duplicating them: fields are the one
62
86
  * authoring concept genuinely identical between an app and an element (both
@@ -95,16 +119,17 @@ export interface AppField {
95
119
  */
96
120
  readonly config?: AppPicklistConfig;
97
121
  /** Numeric format (`NUMBER` / `DECIMAL`) — pure config, no refs. */
98
- readonly numericFormat?: Record<string, unknown>;
122
+ readonly numericFormat?: AspectNumericFieldFormat;
99
123
  /** `DECIMAL` only — display/storage precision (`elementum_decimal_field.decimal_places`). */
100
124
  readonly decimalPlaces?: number;
101
125
  /** QR format (`TEXT` / `HANDLE`) — pure config, no refs. */
102
- readonly qrFormat?: Record<string, unknown>;
126
+ readonly qrFormat?: AspectFieldQrFormat;
103
127
  /**
104
128
  * A calculated-field expression (from the `calc.*` builder). When set, the
105
129
  * field serializes as a calculated field; `type` is the declared output type.
106
130
  */
107
- readonly expression?: Expr<ExprType>;
131
+ readonly expression?: Expr<ExprType, "single", ExprContext>;
132
+ readonly include?: CalculationInclude;
108
133
  /**
109
134
  * `RELATION` only — the related object/field
110
135
  * (`elementum_relation_field.related_object_id`/`related_label_field_id`).
@@ -134,7 +159,7 @@ export interface PicklistOption {
134
159
  }
135
160
  /** The platform's option-tag vocabulary (drives status semantics/urgency). */
136
161
  export type PicklistOptionTag = "CLOSED" | "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
137
- /** The aspect category (created upsert-by-name if missing) — shared with `defineElement`. */
162
+ /** The aspect category (created upsert-by-name if missing) — shared with `element`. */
138
163
  export interface AppCategory {
139
164
  readonly name: string;
140
165
  readonly icon?: string;
@@ -194,7 +219,7 @@ export interface AppSystemFields {
194
219
  * A field reference inside a layout section or list view: either a custom
195
220
  * field's typed token (`catalog.<app>.fields.<key>`) or a bare system-field
196
221
  * key (`"title"`, `"status"`, …) — system fields have no catalog token on a
197
- * pulled app (`readonlyFields` is an explicit author opt-in `defineApp`
222
+ * pulled app (`readonlyFields` is an explicit author opt-in `app`
198
223
  * doesn't emit), so the canonical key string is the only stable way to name
199
224
  * one here, same as `systemFields: {}` is already keyed.
200
225
  */
@@ -218,6 +243,8 @@ export interface AppLayoutSection {
218
243
  readonly icon?: string;
219
244
  /** `"group"` only. */
220
245
  readonly color?: string;
246
+ /** `"group"` only — maximum columns used to arrange the group's fields. */
247
+ readonly maxColumns?: number;
221
248
  /** `"group"` only — the fields shown in this group, in order. */
222
249
  readonly fields?: readonly AppViewFieldRef[];
223
250
  }
@@ -226,11 +253,11 @@ export interface AppLayout {
226
253
  readonly sections: readonly AppLayoutSection[];
227
254
  }
228
255
  /** A saved list view (`elementum_list_view`). */
229
- export interface AppListView {
256
+ export interface AppListView extends ManagedViewSharing {
230
257
  readonly name: string;
231
258
  readonly columns: readonly AppViewFieldRef[];
232
259
  readonly allowRecordCreation?: boolean;
233
- readonly density?: string;
260
+ readonly density?: ListViewDensity;
234
261
  readonly rows?: number;
235
262
  /**
236
263
  * Provider filter tree. The shared `filter` helpers produce compatible
@@ -238,34 +265,30 @@ export interface AppListView {
238
265
  * Terraform generation. Pulled provider-native filters also round-trip.
239
266
  */
240
267
  readonly filter?: Filter;
241
- /** Opaque JSON pass-through — see `filter`. */
242
- readonly sort?: unknown;
268
+ /** Ordered, typed field sorts using the platform's managed-view Sort contract. */
269
+ readonly sort?: ManagedViewSort;
243
270
  }
244
271
  /** An agent-powered record view (`elementum_agent_view`). */
245
- export interface AppAgentView {
272
+ export interface AppAgentView extends ManagedViewSharing {
246
273
  readonly name: string;
247
274
  readonly agent: AgentRef;
248
275
  readonly allowRecordCreation?: boolean;
249
276
  /** Provider-native filter object; pulled values round-trip verbatim. */
250
277
  readonly filter?: Filter;
251
- /** JSON sort payload; pulled values round-trip verbatim. */
252
- readonly sort?: unknown;
253
- readonly userIds?: readonly AccessPolicyUserRef[];
254
- readonly groupIds?: readonly AccessPolicyGroupRef[];
278
+ /** Ordered, typed field sorts using the platform's managed-view Sort contract. */
279
+ readonly sort?: ManagedViewSort;
255
280
  readonly displayOrder?: number;
256
281
  }
257
282
  /** A calendar view positioned by a date/datetime field (`elementum_calendar_view`). */
258
- export interface AppCalendarView {
283
+ export interface AppCalendarView extends ManagedViewSharing {
259
284
  readonly name: string;
260
285
  readonly columns?: readonly AppViewFieldRef[];
261
286
  readonly displayByField?: AppViewFieldRef;
262
287
  readonly allowRecordCreation?: boolean;
263
288
  /** Provider-native filter object; pulled values round-trip verbatim. */
264
289
  readonly filter?: Filter;
265
- /** JSON sort payload; pulled values round-trip verbatim. */
266
- readonly sort?: unknown;
267
- readonly userIds?: readonly AccessPolicyUserRef[];
268
- readonly groupIds?: readonly AccessPolicyGroupRef[];
290
+ /** Ordered, typed field sorts using the platform's managed-view Sort contract. */
291
+ readonly sort?: ManagedViewSort;
269
292
  }
270
293
  /** A kanban view grouped by a field (`elementum_kanban_view`). */
271
294
  export interface AppKanbanView extends AppCalendarView {
@@ -279,17 +302,15 @@ export interface AppDashboard {
279
302
  readonly tags?: readonly string[];
280
303
  readonly widgets?: Readonly<Record<string, DashboardWidget>>;
281
304
  }
282
- export type { DashboardRecordsWidget, DashboardWidget, DashboardWidgetSize } from "../dashboard/build.js";
305
+ export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardRecordsWidget, type DashboardWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
283
306
  /** A managed view that embeds a dashboard from this definition's `dashboards` bag. */
284
- export interface AppDashboardView {
307
+ export interface AppDashboardView extends ManagedViewSharing {
285
308
  readonly name: string;
286
309
  /** Stable key from the sibling `dashboards` bag. */
287
- readonly dashboard: string;
310
+ readonly dashboard: DashboardRef;
288
311
  readonly allowRecordCreation?: boolean;
289
312
  readonly filter?: Filter;
290
- readonly sort?: unknown;
291
- readonly userIds?: readonly AccessPolicyUserRef[];
292
- readonly groupIds?: readonly AccessPolicyGroupRef[];
313
+ readonly sort?: ManagedViewSort;
293
314
  }
294
315
  /** One group in the immutable new-record form (`elementum_record_create_form`). */
295
316
  export interface AppRecordCreateFormSection {
@@ -399,7 +420,7 @@ export interface AppV2Options<F extends Record<string, AppField> = Record<string
399
420
  }
400
421
  /**
401
422
  * Serialize an authored field to its `AspectFieldInput` wire shape — shared
402
- * with `defineElement`. `refName` is the field's bag key in `defineApp`'s
423
+ * with `element`. `refName` is the field's bag key in `app`'s
403
424
  * `fields: {}` (e.g. `severity`) — carried as the internal `__refName` marker,
404
425
  * a client-side-only bookkeeping value `applyV2`'s field reconciliation
405
426
  * (`src/deploy/apply/apply.ts`, `reconcileFields`) reads to match this field
@@ -429,7 +450,7 @@ export declare function serializeSystemFields(overrides: AppSystemFields | undef
429
450
  /**
430
451
  * Per-field `FieldRef`s for an authored `fields:` bag, keyed exactly like it,
431
452
  * each carrying its own literal `fieldType` (not the widened
432
- * `WorkflowFieldType` union) — this is what lets `defineApp(...).ref()` serve
453
+ * `WorkflowFieldType` union) — this is what lets `app(...).ref()` serve
433
454
  * as the catalog's live source for fields (`src/catalog/render.ts`'s
434
455
  * `ownFile`) without losing the per-field type precision `RecordShape`
435
456
  * (`entities/field/record-shape.ts`) needs to discriminate value types.
@@ -437,19 +458,51 @@ export declare function serializeSystemFields(overrides: AppSystemFields | undef
437
458
  export type AppFieldRefs<F extends Record<string, AppField>, Parent extends string = string> = {
438
459
  readonly [K in keyof F]: FieldRef<Parent, Extract<K, string>, F[K]["type"]>;
439
460
  };
461
+ /**
462
+ * The platform field type each auto-provisioned system field carries —
463
+ * mirrors {@link SYSTEM_FIELD_TAG_TO_TYPE}'s values but keyed by
464
+ * {@link SystemFieldKey} instead of tag, since that's what {@link
465
+ * SystemFieldRefs} needs to stamp per-key. Fixed by the platform's per-tag
466
+ * config (`AppSystemFieldOverride` has no authoring slot for `type`), so a
467
+ * literal map here can't drift from a real override the way a computed type
468
+ * could.
469
+ */
470
+ type SystemFieldTypeByKey = {
471
+ readonly id: "HANDLE";
472
+ readonly title: "TEXT";
473
+ readonly status: "PICKLIST";
474
+ readonly stage: "PICKLIST";
475
+ readonly createdAt: "DATETIME";
476
+ readonly createdBy: "USER";
477
+ readonly updatedAt: "DATETIME";
478
+ readonly updatedBy: "USER";
479
+ readonly closedAt: "DATETIME";
480
+ readonly closedBy: "USER";
481
+ };
482
+ /**
483
+ * Per-system-field `FieldRef`s, each carrying its own literal `fieldType` —
484
+ * the system-field counterpart of {@link AppFieldRefs}. A plain `Record<
485
+ * SystemFieldKey, FieldRef<RefName>>` would leave `FieldType` on its `string`
486
+ * default (only `Parent` gets filled positionally), collapsing every system
487
+ * field's `RecordShape` value to the generic `"text"` case and losing e.g.
488
+ * `ctx.trigger.record.status.label` or `.createdBy.email`.
489
+ */
490
+ export type SystemFieldRefs<Parent extends string = string> = {
491
+ readonly [K in SystemFieldKey]: FieldRef<Parent, K, SystemFieldTypeByKey[K]>;
492
+ };
440
493
  /**
441
494
  * An app's reference surface: identity plus its fields (the only bag other
442
495
  * entities may point at). Generic over the authored `fields:` bag (`F`) and
443
496
  * `readonlyFields:` bag (`R`) so `app.ref(name).fields.priority.fieldType`
444
497
  * narrows to its literal (e.g. `"PICKLIST"`); the platform-owned system
445
- * fields round out the bag via `Record<SystemFieldKey, FieldRef>` — a finite
446
- * union of literal keys, deliberately NOT a wide `Record<string, FieldRef>`.
498
+ * fields round out the bag via {@link SystemFieldRefs} — a finite union of
499
+ * literal keys, deliberately NOT a wide `Record<string, FieldRef>`.
447
500
  *
448
501
  * That distinction is load-bearing, not style: a wide `string`-keyed index
449
502
  * signature anywhere in this intersection poisons `RecordShape`
450
503
  * (`entities/field/record-shape.ts`) when `DeepRef`
451
504
  * (`entities/shared/context.ts`) re-maps its keys a second time for
452
- * `ctx.trigger.record`/`ctx.tasks.<t>.record` drilling — every field
505
+ * `ctx.trigger.record`/`ctx.actions.<t>.record` drilling — every field
453
506
  * collapses to `Ref<string>`, losing e.g. a picklist's `.id`/`.label`. Found
454
507
  * and verified via isolated repro before this fix landed; `R`'s default is
455
508
  * `Record<never, never>` (a literal empty object, no index signature) for
@@ -459,7 +512,7 @@ export type AppFieldRefs<F extends Record<string, AppField>, Parent extends stri
459
512
  export type AppRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string> = Extract<AppOrElementRef<RefName>, {
460
513
  readonly __kind: "app";
461
514
  }> & {
462
- readonly fields: AppFieldRefs<F, RefName> & Record<SystemFieldKey, FieldRef<RefName>> & R;
515
+ readonly fields: AppFieldRefs<F, RefName> & SystemFieldRefs<RefName> & R;
463
516
  };
464
517
  /**
465
518
  * The app reference available while configuring options that point back into
@@ -469,17 +522,19 @@ export type AppRef<F extends Record<string, AppField> = Record<string, AppField>
469
522
  export type AppSelfRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string> = AppRef<F, R, RefName> & {
470
523
  agent<const Name extends string>(refName: Name, name?: string): CatalogRef<"agent", Name, RefName>;
471
524
  automation<const Name extends string>(refName: Name, name?: string): AutomationCatalogRef & CatalogRef<"automation", Name, RefName>;
525
+ chart<const Name extends string>(refName: Name, name?: string): ChartRef<RefName, Name>;
526
+ dashboard<const Name extends string>(refName: Name, name?: string): DashboardRef<RefName, Name>;
472
527
  };
473
528
  /** Reference-bearing app options that can safely be authored from `withRefs`. */
474
529
  export type AppReferenceConfiguration = Pick<AppV2Options, "layouts" | "listViews" | "calendarViews" | "kanbanViews" | "dashboards" | "widgets" | "dashboardViews" | "agentViews" | "recordCreateForm" | "dynamicLayouts" | "relationships" | "viewOrder" | "accessPolicies">;
475
530
  /**
476
- * The configured result of `defineApp` — its reference surface (`ref()`) and
531
+ * The configured result of `app` — its reference surface (`ref()`) and
477
532
  * its deployable entity (`def()`). Both take `refName` as a **call-time
478
533
  * argument**, not a constructor option: the ref name is never stored data
479
534
  * (see `src/catalog/from-authoring.ts`) — it's recoverable from the file's
480
535
  * name alone, which is exactly what every caller (catalog generation,
481
536
  * plan/apply discovery) already knows when it calls these. Stating it again
482
- * inside `defineApp({...})` would be the same redundant property the rest of
537
+ * inside `app({...})` would be the same redundant property the rest of
483
538
  * the system avoids, just one level up.
484
539
  */
485
540
  export interface AppConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> {
@@ -492,11 +547,11 @@ export interface AppConfigured<F extends Record<string, AppField> = Record<strin
492
547
  * Build a v2 app entity: org-owned, compose-body payload. Exposes
493
548
  * `.ref(refName)` and `.def(refName)`.
494
549
  *
495
- * Elements author through `defineElement` (`@elementumai/edk/elements`,
550
+ * Elements author through `element` (`@elementumai/edk/elements`,
496
551
  * `src/elements/build.ts`) instead — a dedicated builder/printer, since a
497
552
  * *linked* element's cloud mapping (Cloud Link + Database + Schema + Table,
498
553
  * vs. a *standard* element's Elementum-managed table) has no equivalent on an
499
- * app. `defineApp`'s `type` no longer accepts `"ELEMENT"`.
554
+ * app. `app`'s `type` no longer accepts `"ELEMENT"`.
500
555
  */
501
556
  /**
502
557
  * The GraphQL API constrains an aspect handle to letters only, either case, no
@@ -505,4 +560,4 @@ export interface AppConfigured<F extends Record<string, AppField> = Record<strin
505
560
  */
506
561
  export declare const APP_HANDLE_RE: RegExp;
507
562
  export declare function picklistOptionLabels(options: readonly (string | PicklistOption)[]): readonly string[];
508
- export declare function defineApp<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>>(opts: AppV2Options<F, R>): AppConfigured<F, R>;
563
+ export declare function app<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>>(opts: AppV2Options<F, R>): AppConfigured<F, R>;