@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
@@ -0,0 +1,104 @@
1
+ import { quote } from "../../../pull/util.js";
2
+ import { sdkPackageSpecifier } from "../../internal/sdk-package.js";
3
+ import { printFilter } from "../shared/filters/print.js";
4
+ import { chartAggregation, chartColumnValueType, chartJoinType, chartType, } from "./types.js";
5
+ function member(value) { return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value) ? `.${value}` : `[${quote(value)}]`; }
6
+ function constantKey(values, value, domain) {
7
+ const entry = Object.entries(values).find(([, candidate]) => candidate === value);
8
+ if (entry === undefined)
9
+ throw new Error(`chart pull: unsupported ${domain} ${JSON.stringify(value)}`);
10
+ return entry[0];
11
+ }
12
+ function dataExpr(value) {
13
+ return value.kind === "table" ? `catalog.tables${member(value.refName)}` : `catalog${member(value.refName)}`;
14
+ }
15
+ function fieldExpr(value) {
16
+ return value.kind === "tableColumn"
17
+ ? `catalog.tables${member(value.parentRefName)}.columns${member(value.refName)}`
18
+ : `catalog${member(value.parentRefName)}.fields${member(value.refName)}`;
19
+ }
20
+ function printColumn(column) {
21
+ const parts = [];
22
+ if (column.field !== undefined)
23
+ parts.push(`field: ${fieldExpr(column.field)}`);
24
+ if (column.aggregation !== undefined)
25
+ parts.push(`aggregation: chartAggregation.${constantKey(chartAggregation, column.aggregation, "aggregation")}`);
26
+ if (column.name !== undefined)
27
+ parts.push(`name: ${quote(column.name)}`);
28
+ if (column.value !== undefined)
29
+ parts.push(`value: ${quote(column.value)}`);
30
+ if (column.valueType !== undefined)
31
+ parts.push(`valueType: chartColumnValueType.${constantKey(chartColumnValueType, column.valueType, "column value type")}`);
32
+ return `{ ${parts.join(", ")} }`;
33
+ }
34
+ function printSubscription(subscription) {
35
+ const lines = [" chartSubscription({", ` datasource: ${dataExpr(subscription.datasource)},`];
36
+ lines.push(` columns: [${subscription.columns.map(printColumn).join(", ")}],`);
37
+ if (subscription.groupBy !== undefined) {
38
+ lines.push(` groupBy: [${subscription.groupBy.map((group) => `{ field: ${fieldExpr(group.field)} }`).join(", ")}],`);
39
+ }
40
+ if (subscription.joins !== undefined) {
41
+ lines.push(" joins: [");
42
+ for (const join of subscription.joins) {
43
+ const parts = [`from: ${dataExpr(subscription.datasource)}`, `datasource: ${dataExpr(join.datasource)}`];
44
+ parts.push(`leftField: ${fieldExpr(join.leftField)}`);
45
+ parts.push(`rightField: ${fieldExpr(join.rightField)}`);
46
+ if (join.type !== undefined)
47
+ parts.push(`type: chartJoinType.${constantKey(chartJoinType, join.type, "join type")}`);
48
+ lines.push(` chartJoin({ ${parts.join(", ")} }),`);
49
+ }
50
+ lines.push(" ],");
51
+ }
52
+ if (subscription.filter !== undefined) {
53
+ lines.push(` filter: ${printFilter(subscription.filter, {
54
+ field: fieldExpr,
55
+ aspect: () => { throw new Error("chart pull: filter aspect overrides are unsupported"); },
56
+ reference: () => { throw new Error("chart pull: filter references are unsupported"); },
57
+ })},`);
58
+ }
59
+ if (subscription.limit !== undefined)
60
+ lines.push(` limit: ${quote(subscription.limit)},`);
61
+ if (subscription.tags !== undefined)
62
+ lines.push(` tags: ${JSON.stringify(subscription.tags)},`);
63
+ lines.push(" }),");
64
+ return lines;
65
+ }
66
+ export function printChart(chart, opts) {
67
+ const imports = ["chartSubscription", "chartType", "defineChart"];
68
+ if (chart.subscriptions.some((subscription) => subscription.columns.some((column) => column.aggregation !== undefined)))
69
+ imports.push("chartAggregation");
70
+ if (chart.subscriptions.some((subscription) => subscription.columns.some((column) => column.valueType !== undefined)))
71
+ imports.push("chartColumnValueType");
72
+ if (chart.subscriptions.some((subscription) => (subscription.joins?.length ?? 0) > 0))
73
+ imports.push("chartJoin");
74
+ if (chart.subscriptions.some((subscription) => subscription.joins?.some((join) => join.type !== undefined) === true))
75
+ imports.push("chartJoinType");
76
+ if (chart.subscriptions.some((subscription) => subscription.filter !== undefined))
77
+ imports.push("filter");
78
+ const lines = [
79
+ "/** Auto-generated by EDK pull. Hand-edit freely. */",
80
+ `import { ${imports.sort().join(", ")} } from ${quote(sdkPackageSpecifier("charts"))};`,
81
+ 'import catalog from "@catalog";',
82
+ "",
83
+ "const chart = defineChart({",
84
+ ` app: catalog${member(opts.appRefName)},`,
85
+ ` name: ${quote(chart.name)},`,
86
+ ` type: chartType.${constantKey(chartType, chart.type, "type")},`,
87
+ ];
88
+ if (chart.target !== undefined)
89
+ lines.push(` target: ${chart.target},`);
90
+ if (chart.properties !== undefined) {
91
+ const parts = [];
92
+ for (const key of ["beginAtZero", "fill", "horizontal", "legend", "stacked", "target"]) {
93
+ const value = chart.properties[key];
94
+ if (value !== undefined)
95
+ parts.push(`${key}: ${String(value)}`);
96
+ }
97
+ lines.push(` properties: { ${parts.join(", ")} },`);
98
+ }
99
+ lines.push(" subscriptions: [");
100
+ for (const subscription of chart.subscriptions)
101
+ lines.push(...printSubscription(subscription));
102
+ lines.push(" ],", "});", "", "export default chart;", "");
103
+ return lines.join("\n");
104
+ }
@@ -0,0 +1,15 @@
1
+ import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
2
+ import { type DeployableEntity } from "../../engine/entity.js";
3
+ import { type TfBlock } from "../../engine/tf/index.js";
4
+ export interface ChartToTfOptions {
5
+ readonly appRefName: string;
6
+ readonly appTfLabel: string;
7
+ readonly orgRefs: OrgRefLookup;
8
+ readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
9
+ readonly streamRootEntity?: DeployableEntity;
10
+ readonly diagnostics: string[];
11
+ }
12
+ export declare function chartToTf(entity: DeployableEntity, opts: ChartToTfOptions): {
13
+ readonly blocks: readonly TfBlock[];
14
+ readonly address: string;
15
+ };
@@ -0,0 +1,150 @@
1
+ import { workspaceAspectKey, } from "../../engine/build/context.js";
2
+ import { EntityTfError } from "../../engine/entity.js";
3
+ import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
4
+ import { fieldRefToTfValue } from "../field/to-tf.js";
5
+ import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
6
+ import { CHART_RESOURCE_TYPE } from "./types.js";
7
+ const APP_RESOURCE_TYPE = "elementum_app";
8
+ const TABLE_RESOURCE_TYPE = "elementum_table";
9
+ function datasourceId(ref, opts, where) {
10
+ if (ref?.refName === undefined || ref.refName === "" || ref.__kind === undefined) {
11
+ throw new EntityTfError(`${where}: datasource must be a typed app, element, or table ref`);
12
+ }
13
+ if (ref.__kind !== "app" && ref.__kind !== "element" && ref.__kind !== "table") {
14
+ throw new EntityTfError(`${where}: unsupported datasource kind ${JSON.stringify(ref.__kind)}`);
15
+ }
16
+ const local = opts.workspaceAspects?.get(workspaceAspectKey(ref.__kind, ref.refName));
17
+ if (local !== undefined) {
18
+ const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : TABLE_RESOURCE_TYPE;
19
+ return { ref, id: expr.resourceAttr(type, local.tfLabel, ["id"]), tfLabel: local.tfLabel, local: true };
20
+ }
21
+ const name = ref.name ?? ref.refName;
22
+ const label = sanitizeName(name);
23
+ if (ref.__kind === "app")
24
+ opts.orgRefs.foreignApp(label, name);
25
+ else if (ref.__kind === "element")
26
+ opts.orgRefs.foreignElement(label, name);
27
+ else
28
+ opts.orgRefs.rawLookup(TABLE_RESOURCE_TYPE, label, name);
29
+ const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : TABLE_RESOURCE_TYPE;
30
+ return { ref, id: expr.dataAttr(type, label, ["id"]), tfLabel: label, local: false };
31
+ }
32
+ function fieldId(ref, datasource, opts, where) {
33
+ if (ref?.refName === undefined || ref.refName === "")
34
+ throw new EntityTfError(`${where}: field ref is missing its key`);
35
+ if (ref.parent !== undefined && ref.parent !== datasource.ref.refName) {
36
+ throw new EntityTfError(`${where}: field belongs to ${JSON.stringify(ref.parent)}, not datasource ${JSON.stringify(datasource.ref.refName)}`);
37
+ }
38
+ if (ref.__kind === "tableColumn") {
39
+ const fieldName = ref.name ?? ref.refName;
40
+ return datasource.local
41
+ ? expr.resourceAttr(TABLE_RESOURCE_TYPE, datasource.tfLabel, ["field_ids", { index: fieldName }])
42
+ : expr.dataAttr(TABLE_RESOURCE_TYPE, datasource.tfLabel, ["field_ids", { index: fieldName }]);
43
+ }
44
+ if (ref.__kind !== "field")
45
+ throw new EntityTfError(`${where}: expected a field or table-column ref`);
46
+ if (datasource.ref.__kind === "table")
47
+ throw new EntityTfError(`${where}: app/element fields cannot belong to a table datasource`);
48
+ if (datasource.local) {
49
+ const scope = datasource.ref.__kind === "element" ? "element" : "app";
50
+ const direct = fieldRefToTfValue(ref.fieldType ?? "", ref.refName, datasource.tfLabel, scope);
51
+ if (direct !== undefined)
52
+ return direct;
53
+ }
54
+ const label = sanitizeName(`${datasource.ref.__kind}_${datasource.ref.refName}_${ref.refName}`);
55
+ opts.orgRefs.foreignField("elementum_field", label, datasource.id, ref.name ?? ref.refName);
56
+ return expr.dataAttr("elementum_field", label, ["id"]);
57
+ }
58
+ function columnToTf(column, datasource, opts, where) {
59
+ const out = {};
60
+ if (column.field !== undefined)
61
+ out["column_id"] = fieldId(column.field, datasource, opts, `${where}.field`);
62
+ if (column.aggregation !== undefined)
63
+ out["aggregation"] = column.aggregation;
64
+ if (column.name !== undefined)
65
+ out["name"] = column.name;
66
+ if (column.value !== undefined)
67
+ out["value"] = column.value;
68
+ if (column.valueType !== undefined)
69
+ out["value_type"] = column.valueType;
70
+ return out;
71
+ }
72
+ function filterToTf(value, datasource, opts, where) {
73
+ return expr.jsonencode(serializeFilterToTf(value, {
74
+ field: (field) => fieldId(field, datasource, opts, `${where}.field`),
75
+ aspect: () => datasource.id,
76
+ reference: () => { throw new EntityTfError(`${where}: runtime reference values are not supported in chart filters`); },
77
+ }));
78
+ }
79
+ function subscriptionToTf(subscription, opts, where) {
80
+ const datasource = datasourceId(subscription.datasource, opts, `${where}.datasource`);
81
+ const out = {
82
+ datasource_id: datasource.id,
83
+ columns: (subscription.columns ?? []).map((column, index) => columnToTf(column, datasource, opts, `${where}.columns[${index}]`)),
84
+ };
85
+ if (subscription.groupBy !== undefined && subscription.groupBy.length > 0) {
86
+ out["group_bys"] = subscription.groupBy.map((group, index) => ({
87
+ column_id: fieldId(group.field, datasource, opts, `${where}.groupBy[${index}].field`),
88
+ }));
89
+ }
90
+ if (subscription.joins !== undefined && subscription.joins.length > 0) {
91
+ out["joins"] = subscription.joins.map((join, index) => {
92
+ const joined = datasourceId(join.datasource, opts, `${where}.joins[${index}].datasource`);
93
+ return {
94
+ datasource_id: joined.id,
95
+ left_column_id: fieldId(join.leftField, datasource, opts, `${where}.joins[${index}].leftField`),
96
+ right_column_id: fieldId(join.rightField, joined, opts, `${where}.joins[${index}].rightField`),
97
+ ...(join.type !== undefined ? { type: join.type } : {}),
98
+ };
99
+ });
100
+ }
101
+ if (subscription.filter !== undefined)
102
+ out["filter"] = filterToTf(subscription.filter, datasource, opts, `${where}.filter`);
103
+ if (subscription.limit !== undefined)
104
+ out["limit"] = subscription.limit;
105
+ if (subscription.tags !== undefined && subscription.tags.length > 0)
106
+ out["tags"] = [...subscription.tags];
107
+ return out;
108
+ }
109
+ function hasSameAppChartWidget(entity, root) {
110
+ const payload = root.payload;
111
+ if (payload?.dashboards === undefined)
112
+ return false;
113
+ return Object.values(payload.dashboards).some((dashboard) => Object.values(dashboard.widgets ?? {}).some((widget) => {
114
+ if (typeof widget !== "object" || widget === null)
115
+ return false;
116
+ const candidate = widget;
117
+ return candidate.type === "chart" && candidate.chart?.refName === entity.refName && candidate.chart.parent === root.refName;
118
+ }));
119
+ }
120
+ export function chartToTf(entity, opts) {
121
+ if (entity.kind !== "chart")
122
+ throw new EntityTfError(`chartToTf expects kind "chart"; got ${JSON.stringify(entity.kind)}`);
123
+ const chart = entity.payload;
124
+ if (chart === null || chart.app?.refName !== opts.appRefName) {
125
+ throw new EntityTfError(`chart "${entity.refName}" does not reference owning app "${opts.appRefName}"`);
126
+ }
127
+ if (opts.streamRootEntity !== undefined && !hasSameAppChartWidget(entity, opts.streamRootEntity)) {
128
+ throw new EntityTfError(`chart "${entity.refName}" must be referenced by a same-app dashboard chart widget so pull can rediscover its owner`);
129
+ }
130
+ const label = scopedResourceLabel(opts.appTfLabel, tsLabelToTfLabel(entity.refName), "app");
131
+ const attrs = {
132
+ name: chart.name ?? "",
133
+ type: chart.type ?? "",
134
+ subscriptions: (chart.subscriptions ?? []).map((subscription, index) => subscriptionToTf(subscription, opts, `chart ${entity.refName}.subscriptions[${index}]`)),
135
+ };
136
+ if (chart.target !== undefined)
137
+ attrs["target"] = chart.target;
138
+ if (chart.properties !== undefined) {
139
+ attrs["properties"] = {
140
+ ...(chart.properties.beginAtZero !== undefined ? { begin_at_zero: chart.properties.beginAtZero } : {}),
141
+ ...(chart.properties.fill !== undefined ? { fill: chart.properties.fill } : {}),
142
+ ...(chart.properties.horizontal !== undefined ? { horizontal: chart.properties.horizontal } : {}),
143
+ ...(chart.properties.legend !== undefined ? { legend: chart.properties.legend } : {}),
144
+ ...(chart.properties.stacked !== undefined ? { stacked: chart.properties.stacked } : {}),
145
+ ...(chart.properties.target !== undefined ? { target: chart.properties.target } : {}),
146
+ };
147
+ }
148
+ const block = { kind: "resource", type: CHART_RESOURCE_TYPE, label, attrs };
149
+ return { blocks: [block], address: `${CHART_RESOURCE_TYPE}.${label}` };
150
+ }
@@ -0,0 +1,53 @@
1
+ /** Terraform resource type for chart resources. Kept dependency-free to avoid entity-module cycles. */
2
+ export declare const CHART_RESOURCE_TYPE = "elementum_chart";
3
+ declare const chartTypeBrand: unique symbol;
4
+ declare const chartAggregationBrand: unique symbol;
5
+ declare const chartColumnValueTypeBrand: unique symbol;
6
+ declare const chartJoinTypeBrand: unique symbol;
7
+ type Branded<Value extends string, Brand extends symbol> = Value & {
8
+ readonly [Key in Brand]: true;
9
+ };
10
+ type ChartTypeValue = "BAR" | "BUBBLE" | "DOUGHNUT" | "LINE" | "PIE" | "POLAR" | "RADAR" | "SCATTER" | "SINGLEBAR" | "SINGLELINE" | "SINGLEVALUE";
11
+ export type ChartType = Branded<ChartTypeValue, typeof chartTypeBrand>;
12
+ export declare const chartType: {
13
+ readonly bar: ChartType;
14
+ readonly bubble: ChartType;
15
+ readonly doughnut: ChartType;
16
+ readonly line: ChartType;
17
+ readonly pie: ChartType;
18
+ readonly polar: ChartType;
19
+ readonly radar: ChartType;
20
+ readonly scatter: ChartType;
21
+ readonly singleBar: ChartType;
22
+ readonly singleLine: ChartType;
23
+ readonly singleValue: ChartType;
24
+ };
25
+ type ChartAggregationValue = "AVERAGE" | "COUNT" | "MAX" | "MIN" | "SUM";
26
+ export type ChartAggregation = Branded<ChartAggregationValue, typeof chartAggregationBrand>;
27
+ export declare const chartAggregation: {
28
+ readonly average: ChartAggregation;
29
+ readonly count: ChartAggregation;
30
+ readonly max: ChartAggregation;
31
+ readonly min: ChartAggregation;
32
+ readonly sum: ChartAggregation;
33
+ };
34
+ type ChartColumnValueTypeValue = "BOOLEAN" | "DATE" | "DATETIME" | "DECIMAL" | "LONG" | "TEXT" | "UUID";
35
+ export type ChartColumnValueType = Branded<ChartColumnValueTypeValue, typeof chartColumnValueTypeBrand>;
36
+ export declare const chartColumnValueType: {
37
+ readonly boolean: ChartColumnValueType;
38
+ readonly date: ChartColumnValueType;
39
+ readonly dateTime: ChartColumnValueType;
40
+ readonly decimal: ChartColumnValueType;
41
+ readonly long: ChartColumnValueType;
42
+ readonly text: ChartColumnValueType;
43
+ readonly uuid: ChartColumnValueType;
44
+ };
45
+ type ChartJoinTypeValue = "FULL" | "INNER" | "LEFT" | "RIGHT";
46
+ export type ChartJoinType = Branded<ChartJoinTypeValue, typeof chartJoinTypeBrand>;
47
+ export declare const chartJoinType: {
48
+ readonly full: ChartJoinType;
49
+ readonly inner: ChartJoinType;
50
+ readonly left: ChartJoinType;
51
+ readonly right: ChartJoinType;
52
+ };
53
+ export {};
@@ -0,0 +1,22 @@
1
+ /** Terraform resource type for chart resources. Kept dependency-free to avoid entity-module cycles. */
2
+ export const CHART_RESOURCE_TYPE = "elementum_chart";
3
+ export const chartType = {
4
+ bar: "BAR", bubble: "BUBBLE", doughnut: "DOUGHNUT",
5
+ line: "LINE", pie: "PIE", polar: "POLAR",
6
+ radar: "RADAR", scatter: "SCATTER", singleBar: "SINGLEBAR",
7
+ singleLine: "SINGLELINE", singleValue: "SINGLEVALUE",
8
+ };
9
+ export const chartAggregation = {
10
+ average: "AVERAGE", count: "COUNT",
11
+ max: "MAX", min: "MIN", sum: "SUM",
12
+ };
13
+ export const chartColumnValueType = {
14
+ boolean: "BOOLEAN", date: "DATE",
15
+ dateTime: "DATETIME", decimal: "DECIMAL",
16
+ long: "LONG", text: "TEXT",
17
+ uuid: "UUID",
18
+ };
19
+ export const chartJoinType = {
20
+ full: "FULL", inner: "INNER",
21
+ left: "LEFT", right: "RIGHT",
22
+ };
@@ -1,17 +1,44 @@
1
- import type { AppOrElementRef } from "../../catalog/index.js";
1
+ import type { AppCatalogRef, AppOrElementRef, ChartRef, FieldRef } from "../../catalog/index.js";
2
2
  import type { Filter } from "../shared/filters/types.js";
3
- export type DashboardWidgetSize = "EXTRA_SMALL" | "SMALL" | "MEDIUM" | "LARGE" | "EXTRA_LARGE";
3
+ declare const dashboardWidgetSizeBrand: unique symbol;
4
+ declare const dashboardWidgetBrand: unique symbol;
5
+ type DashboardWidgetSizeValue = "EXTRA_SMALL" | "SMALL" | "MEDIUM" | "LARGE" | "EXTRA_LARGE";
6
+ export type DashboardWidgetSize = DashboardWidgetSizeValue & {
7
+ readonly [dashboardWidgetSizeBrand]: true;
8
+ };
9
+ export declare const dashboardWidgetSize: {
10
+ readonly extraSmall: DashboardWidgetSize;
11
+ readonly small: DashboardWidgetSize;
12
+ readonly medium: DashboardWidgetSize;
13
+ readonly large: DashboardWidgetSize;
14
+ readonly extraLarge: DashboardWidgetSize;
15
+ };
4
16
  interface DashboardWidgetBase {
5
17
  readonly name: string;
6
18
  readonly size?: DashboardWidgetSize;
7
19
  readonly color?: string;
8
20
  readonly icon?: string;
9
21
  }
10
- export interface DashboardRecordsWidget extends DashboardWidgetBase {
22
+ export interface DashboardRecordsWidget<Target extends AppOrElementRef = AppOrElementRef> extends DashboardWidgetBase {
23
+ readonly [dashboardWidgetBrand]: "records";
11
24
  readonly type: "records";
12
- readonly target: AppOrElementRef;
13
- readonly filter?: Filter;
14
- readonly sort?: unknown;
25
+ readonly target: Target;
26
+ readonly filter?: Filter<FieldRef<Target["refName"]>, never>;
15
27
  }
16
- export type DashboardWidget = DashboardRecordsWidget;
28
+ export interface DashboardChartWidget<Parent extends string = string> extends DashboardWidgetBase {
29
+ readonly [dashboardWidgetBrand]: "chart";
30
+ readonly type: "chart";
31
+ readonly chart: ChartRef<Parent>;
32
+ }
33
+ /** Build a record-list widget with a typed app/element target. */
34
+ export declare function dashboardRecordsWidget<const Target extends AppOrElementRef>(opts: DashboardWidgetBase & {
35
+ readonly target: Target;
36
+ readonly filter?: Filter<FieldRef<NoInfer<Target>["refName"]>, never>;
37
+ }): DashboardRecordsWidget<Target>;
38
+ /** Build a chart widget and enforce that chart and dashboard share an app owner. */
39
+ export declare function dashboardChartWidget<const Parent extends string>(opts: DashboardWidgetBase & {
40
+ readonly owner: AppCatalogRef<Parent>;
41
+ readonly chart: ChartRef<NoInfer<Parent>>;
42
+ }): DashboardChartWidget<Parent>;
43
+ export type DashboardWidget = DashboardRecordsWidget | DashboardChartWidget;
17
44
  export {};
@@ -1 +1,16 @@
1
- export {};
1
+ export const dashboardWidgetSize = {
2
+ extraSmall: "EXTRA_SMALL",
3
+ small: "SMALL",
4
+ medium: "MEDIUM",
5
+ large: "LARGE",
6
+ extraLarge: "EXTRA_LARGE",
7
+ };
8
+ /** Build a record-list widget with a typed app/element target. */
9
+ export function dashboardRecordsWidget(opts) {
10
+ return { ...opts, type: "records" };
11
+ }
12
+ /** Build a chart widget and enforce that chart and dashboard share an app owner. */
13
+ export function dashboardChartWidget(opts) {
14
+ const { owner: _owner, ...widget } = opts;
15
+ return { ...widget, type: "chart" };
16
+ }
@@ -5,6 +5,8 @@ import { filterFromTf } from "../access-policy/from-tf.js";
5
5
  import { filterWireToTf } from "../shared/filters/tf-codec.js";
6
6
  import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
7
7
  import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
8
+ import { CHART_RESOURCE_TYPE } from "../chart/types.js";
9
+ import { dashboardWidgetSize } from "./build.js";
8
10
  const KNOWN_DASHBOARD_ATTRS = new Set(["name", "owner_id", "owner_type", "favorite", "tags"]);
9
11
  export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
10
12
  const dashboards = [];
@@ -44,14 +46,31 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
44
46
  const key = tfLabelToTsLabel(label.startsWith(`${dashboardLabel}_`) ? label.slice(dashboardLabel.length + 1) : label);
45
47
  const name = optionalString(block.attrs, "name", where, ctx) ?? "";
46
48
  const size = optionalString(block.attrs, "size", where, ctx) ?? "MEDIUM";
49
+ if (!Object.values(dashboardWidgetSize).includes(size)) {
50
+ ctx.diagnostics.push(`${where}.size: unsupported dashboard widget size ${JSON.stringify(size)}; skipped`);
51
+ return [];
52
+ }
47
53
  const color = optionalString(block.attrs, "color", where, ctx);
48
54
  const icon = optionalString(block.attrs, "icon", where, ctx);
49
55
  const aspect = plainObject(block.attrs["aspect_widget"]);
56
+ const style = { key, name, size, ...(color !== undefined && { color }), ...(icon !== undefined && { icon }) };
57
+ const chart = plainObject(block.attrs["chart_widget"]);
58
+ if (chart !== undefined) {
59
+ const chartLabel = resourceRefLabel(chart["chart_id"], CHART_RESOURCE_TYPE);
60
+ if (chartLabel === undefined) {
61
+ ctx.diagnostics.push(`${where}.chart_widget.chart_id: expected a managed chart reference; skipped`);
62
+ return [];
63
+ }
64
+ return [{ ...style, type: "chart", chartKey: scopedLabelToBagKey(owner.ownerTfLabel, chartLabel, owner.scope) }];
65
+ }
50
66
  if (aspect === undefined) {
51
- ctx.diagnostics.push(`${where}: expected an aspect_widget; skipped`);
67
+ ctx.diagnostics.push(`${where}: expected an aspect_widget or chart_widget; skipped`);
68
+ return [];
69
+ }
70
+ if (aspect["sort"] !== undefined) {
71
+ ctx.diagnostics.push(`${where}.aspect_widget.sort: dashboard record sort has no typed public contract; skipped`);
52
72
  return [];
53
73
  }
54
- const style = { key, name, size, ...(color !== undefined && { color }), ...(icon !== undefined && { icon }) };
55
74
  const target = aspectRef(aspect["aspect_id"], owner, ctx);
56
75
  if (target === undefined) {
57
76
  ctx.diagnostics.push(`${where}.aspect_widget.aspect_id: unresolved; skipped`);
@@ -61,13 +80,12 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
61
80
  ...(aspect["filter"] !== undefined && {
62
81
  filter: filterFromTf(filterWireToTf(decodeJson(aspect["filter"])), { ...owner, ownerRefName: owner.ownerRefName ?? owner.ownerTfLabel }, `${where}.aspect_widget.filter`),
63
82
  }),
64
- ...(aspect["sort"] !== undefined && { sort: decodeJson(aspect["sort"]) }),
65
83
  }];
66
84
  });
67
85
  }
68
86
  function aspectRef(value, owner, ctx) {
69
87
  if (typeof value === "string")
70
- return value;
88
+ return undefined;
71
89
  if (resourceRefLabel(value, owner.type) === owner.label)
72
90
  return { kind: owner.scope, key: owner.ownerTfLabel, name: owner.ownerTfLabel };
73
91
  for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
@@ -1,6 +1,6 @@
1
1
  import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
2
2
  import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
3
- import type { DashboardRecordsWidget } from "./build.js";
3
+ import type { Filter } from "../shared/filters/types.js";
4
4
  export interface AppDashboardWire {
5
5
  readonly name?: string;
6
6
  readonly favorite?: boolean;
@@ -11,10 +11,23 @@ interface RefWire {
11
11
  readonly __kind?: string;
12
12
  readonly refName?: string;
13
13
  readonly name?: string;
14
+ readonly parent?: string;
15
+ readonly namespace?: string;
14
16
  }
15
- type DashboardWidgetWire = Omit<DashboardRecordsWidget, "target"> & {
17
+ interface DashboardWidgetWireBase {
18
+ readonly name: string;
19
+ readonly size?: string;
20
+ readonly color?: string;
21
+ readonly icon?: string;
22
+ }
23
+ type DashboardWidgetWire = (DashboardWidgetWireBase & {
24
+ readonly type: "records";
16
25
  readonly target?: RefWire | string;
17
- };
26
+ readonly filter?: Filter;
27
+ }) | (DashboardWidgetWireBase & {
28
+ readonly type: "chart";
29
+ readonly chart?: RefWire | string;
30
+ });
18
31
  export interface DashboardToTfOptions {
19
32
  readonly ownerTfLabel: string;
20
33
  readonly scope: ChildResourceScope;
@@ -3,7 +3,9 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
3
3
  import { filterToTf } from "../access-policy/to-tf.js";
4
4
  import { filterTfToWire } from "../shared/filters/tf-codec.js";
5
5
  import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
6
+ import { resolveForeignRef } from "../shared/foreign-ref.js";
6
7
  import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
8
+ import { CHART_RESOURCE_TYPE } from "../chart/types.js";
7
9
  export function dashboardsToTf(dashboards, opts) {
8
10
  const blocks = [];
9
11
  for (const [key, dashboard] of Object.entries(dashboards ?? {})) {
@@ -57,10 +59,14 @@ export function dashboardsToTf(dashboards, opts) {
57
59
  });
58
60
  body["filter"] = expr.jsonencode(filterTfToWire(hclFilter));
59
61
  }
60
- if (widget.sort !== undefined)
61
- body["sort"] = expr.jsonencode(widget.sort);
62
62
  widgetAttrs["aspect_widget"] = body;
63
63
  }
64
+ else if (widget.type === "chart") {
65
+ const chart = resolveChart(widget.chart, `${where}.chart`, opts);
66
+ if (chart === undefined)
67
+ continue;
68
+ widgetAttrs["chart_widget"] = { chart_id: chart };
69
+ }
64
70
  else {
65
71
  opts.diagnostics.push(`${where}: unsupported widget type; dropped`);
66
72
  continue;
@@ -70,9 +76,35 @@ export function dashboardsToTf(dashboards, opts) {
70
76
  }
71
77
  return blocks;
72
78
  }
79
+ function resolveChart(value, where, opts) {
80
+ if (typeof value === "string") {
81
+ opts.diagnostics.push(`${where}: raw chart ids are not supported in public authoring; dropped`);
82
+ return undefined;
83
+ }
84
+ const refName = value?.refName ?? "";
85
+ if (refName === "") {
86
+ opts.diagnostics.push(`${where}: chart has no refName; dropped`);
87
+ return undefined;
88
+ }
89
+ if (value?.__kind !== "chart") {
90
+ opts.diagnostics.push(`${where}: expected a chart ref; dropped`);
91
+ return undefined;
92
+ }
93
+ if (value.parent === undefined || value.parent === "") {
94
+ opts.diagnostics.push(`${where}: chart ref has no app owner; dropped`);
95
+ return undefined;
96
+ }
97
+ if (value.parent !== opts.ownerRefName) {
98
+ opts.diagnostics.push(`${where}: chart belongs to ${JSON.stringify(value.parent)}, not dashboard owner ${JSON.stringify(opts.ownerRefName)}; dropped`);
99
+ return undefined;
100
+ }
101
+ return expr.resourceAttr(CHART_RESOURCE_TYPE, scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(refName), opts.scope), ["id"]);
102
+ }
73
103
  function resolveAspect(value, where, opts) {
74
- if (typeof value === "string")
75
- return value === "self" ? opts.ownerId : value;
104
+ if (typeof value === "string") {
105
+ opts.diagnostics.push(`${where}: raw aspect ids are not supported in public authoring; dropped`);
106
+ return undefined;
107
+ }
76
108
  const kind = value?.__kind === "element" ? "element" : "app";
77
109
  const refName = value?.refName ?? "";
78
110
  if (kind === opts.scope && refName === (opts.ownerRefName ?? opts.ownerTfLabel))
@@ -85,10 +117,5 @@ function resolveAspect(value, where, opts) {
85
117
  opts.diagnostics.push(`${where}: target has no resolvable name; dropped`);
86
118
  return undefined;
87
119
  }
88
- const label = tsLabelToTfLabel(name);
89
- if (kind === "app")
90
- opts.orgRefs.foreignApp(label, name);
91
- else
92
- opts.orgRefs.foreignElement(label, name);
93
- return expr.dataAttr(kind === "app" ? "elementum_app" : "elementum_element", label, ["id"]);
120
+ return resolveForeignRef(kind, { name, namespace: value?.namespace }, opts.orgRefs, opts.diagnostics, where).value;
94
121
  }
@@ -7,7 +7,7 @@ export const datamineModule = {
7
7
  authoring: { unit: "inline", bag: "datamines" },
8
8
  parents: [{ parent: "table", child: "datamine" }],
9
9
  resource: { shape: "single", resourceType: DATAMINE_RESOURCE_TYPE, adoptable: true },
10
- data: { participates: true, resourceType: DATAMINE_RESOURCE_TYPE, lookupAttr: "name", referencedByBuild: true },
10
+ data: { participates: true, resourceType: DATAMINE_RESOURCE_TYPE, lookupAttr: "name", referencedByBuild: true, referenceLookups: [{ strategy: "owned", ownerKinds: ["table"], memberAttr: "name" }] },
11
11
  lifecycle: NO_LIFECYCLE,
12
12
  canvas: NO_CANVAS,
13
13
  catalog: {
@@ -63,7 +63,8 @@ interface DynamicLayoutComponentCommon<ComponentKey extends string = string, Con
63
63
  readonly saveGroup?: SaveGroupKey;
64
64
  readonly blockId?: string;
65
65
  }
66
- interface DynamicLayoutComponentVariantMap {
66
+ /** @internal Public component variants used to keep the HCL dialect table exhaustive. */
67
+ export interface DynamicLayoutComponentVariantMap {
67
68
  readonly container: {
68
69
  readonly padding?: DynamicLayoutCssLength;
69
70
  readonly gap?: DynamicLayoutCssLength;
@@ -144,7 +145,7 @@ interface DynamicLayoutComponentVariantMap {
144
145
  readonly booleanField: DynamicLayoutFieldComponent;
145
146
  readonly picklistField: DynamicLayoutFieldComponent;
146
147
  readonly multiPicklistField: DynamicLayoutFieldComponent;
147
- readonly htmlField: DynamicLayoutFieldComponent;
148
+ readonly richTextField: DynamicLayoutFieldComponent;
148
149
  readonly attachmentField: DynamicLayoutFieldComponent;
149
150
  readonly groupField: DynamicLayoutFieldComponent;
150
151
  readonly jsonField: DynamicLayoutFieldComponent;
@@ -299,5 +300,5 @@ type DynamicLayoutInput<Components extends Readonly<Record<string, DynamicLayout
299
300
  readonly saveGroups?: SaveGroups;
300
301
  };
301
302
  /** Preserve graph keys so child, condition, save-group, and root references are checked. */
302
- export declare function defineDynamicLayout<const Components extends Readonly<Record<string, DynamicLayoutComponent>>, const Conditions extends Readonly<Record<string, DynamicLayoutCondition>> = Record<never, never>, const SaveGroups extends Readonly<Record<string, DynamicLayoutSaveGroup>> = Record<never, never>>(layout: DynamicLayoutInput<Components, Conditions, SaveGroups>): AppDynamicLayout;
303
+ export declare function dynamicLayout<const Components extends Readonly<Record<string, DynamicLayoutComponent>>, const Conditions extends Readonly<Record<string, DynamicLayoutCondition>> = Record<never, never>, const SaveGroups extends Readonly<Record<string, DynamicLayoutSaveGroup>> = Record<never, never>>(layout: DynamicLayoutInput<Components, Conditions, SaveGroups>): AppDynamicLayout;
303
304
  export {};
@@ -1,4 +1,4 @@
1
1
  /** Preserve graph keys so child, condition, save-group, and root references are checked. */
2
- export function defineDynamicLayout(layout) {
2
+ export function dynamicLayout(layout) {
3
3
  return layout;
4
4
  }
@@ -1,2 +1,4 @@
1
+ export declare const DYNAMIC_LAYOUT_FIELD_COMPONENT_WIRE_KEY_BY_PUBLIC_KEY: ReadonlyMap<string, string>;
1
2
  export declare const DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS: ReadonlySet<string>;
3
+ export declare function dynamicLayoutFieldComponentWireKey(publicKey: string): string;
2
4
  export declare const DYNAMIC_LAYOUT_COMPARISON_KEYS: ReadonlySet<string>;