@elementumai/edk 0.9.19 → 0.10.1

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 (240) hide show
  1. package/README.md +159 -7
  2. package/dist-sdk/src/catalog/factories.d.ts +33 -2
  3. package/dist-sdk/src/catalog/factories.js +40 -1
  4. package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
  5. package/dist-sdk/src/catalog/from-authoring.js +34 -9
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +2 -2
  8. package/dist-sdk/src/catalog/render.js +6 -6
  9. package/dist-sdk/src/catalog/token.js +11 -0
  10. package/dist-sdk/src/catalog/types.d.ts +40 -1
  11. package/dist-sdk/src/catalog/types.js +12 -0
  12. package/dist-sdk/src/core/triggers/on-demand.d.ts +40 -4
  13. package/dist-sdk/src/core/triggers/on-demand.js +17 -2
  14. package/dist-sdk/src/core/types/app.d.ts +2 -2
  15. package/dist-sdk/src/engine/build/context.d.ts +1 -1
  16. package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
  17. package/dist-sdk/src/engine/coverage-gaps.js +156 -0
  18. package/dist-sdk/src/engine/ei/run.d.ts +169 -0
  19. package/dist-sdk/src/engine/ei/run.js +1219 -0
  20. package/dist-sdk/src/engine/logging.d.ts +17 -0
  21. package/dist-sdk/src/engine/logging.js +18 -0
  22. package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
  23. package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
  24. package/dist-sdk/src/engine/pull/context.d.ts +68 -6
  25. package/dist-sdk/src/engine/pull/context.js +40 -1
  26. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
  27. package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
  28. package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
  29. package/dist-sdk/src/engine/pull/ref-only.js +10 -7
  30. package/dist-sdk/src/engine/pull/result-output.d.ts +6 -0
  31. package/dist-sdk/src/engine/pull/result-output.js +113 -3
  32. package/dist-sdk/src/engine/tf/expr.js +1 -1
  33. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  34. package/dist-sdk/src/engine/tf/index.js +1 -1
  35. package/dist-sdk/src/engine/tf/labels.d.ts +28 -5
  36. package/dist-sdk/src/engine/tf/labels.js +54 -3
  37. package/dist-sdk/src/engine/tf/model.d.ts +22 -1
  38. package/dist-sdk/src/engine/tf/parse.js +93 -4
  39. package/dist-sdk/src/engine/tf/render.d.ts +4 -2
  40. package/dist-sdk/src/engine/tf/render.js +41 -7
  41. package/dist-sdk/src/engine/validation.d.ts +44 -0
  42. package/dist-sdk/src/engine/validation.js +95 -0
  43. package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
  44. package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
  45. package/dist-sdk/src/entities/access-policy/to-tf.js +5 -2
  46. package/dist-sdk/src/entities/agent/build.d.ts +4 -16
  47. package/dist-sdk/src/entities/agent/build.js +40 -5
  48. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
  49. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +46 -21
  50. package/dist-sdk/src/entities/agent/from-tf.js +11 -3
  51. package/dist-sdk/src/entities/agent/module.js +2 -0
  52. package/dist-sdk/src/entities/agent/to-tf.js +20 -6
  53. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +10 -1
  54. package/dist-sdk/src/entities/agent-tool/from-tf.js +18 -6
  55. package/dist-sdk/src/entities/agent-tool/module.js +3 -0
  56. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  57. package/dist-sdk/src/entities/agent-tool/to-tf.js +27 -5
  58. package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
  59. package/dist-sdk/src/entities/app/auto-share.js +49 -0
  60. package/dist-sdk/src/entities/app/build.d.ts +105 -22
  61. package/dist-sdk/src/entities/app/build.js +107 -10
  62. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +22 -1
  63. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
  64. package/dist-sdk/src/entities/app/from-tf.js +11 -2
  65. package/dist-sdk/src/entities/app/index.d.ts +7 -6
  66. package/dist-sdk/src/entities/app/index.js +2 -8
  67. package/dist-sdk/src/entities/app/module.js +5 -2
  68. package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
  69. package/dist-sdk/src/entities/app/to-tf.js +40 -13
  70. package/dist-sdk/src/entities/automation/build.d.ts +56 -6
  71. package/dist-sdk/src/entities/automation/build.js +230 -26
  72. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
  73. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +41 -5
  74. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +470 -58
  75. package/dist-sdk/src/entities/automation/from-tf.d.ts +37 -8
  76. package/dist-sdk/src/entities/automation/from-tf.js +791 -131
  77. package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
  78. package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
  79. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  80. package/dist-sdk/src/entities/automation/index.js +1 -1
  81. package/dist-sdk/src/entities/automation/module.d.ts +3 -0
  82. package/dist-sdk/src/entities/automation/module.js +107 -15
  83. package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
  84. package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
  85. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
  86. package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
  87. package/dist-sdk/src/entities/automation/script-code.d.ts +20 -0
  88. package/dist-sdk/src/entities/automation/script-code.js +109 -5
  89. package/dist-sdk/src/entities/automation/system-ref-name.js +4 -0
  90. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +39 -0
  91. package/dist-sdk/src/entities/automation/task-output-labels.js +85 -0
  92. package/dist-sdk/src/entities/automation/tasks.d.ts +116 -22
  93. package/dist-sdk/src/entities/automation/tasks.js +86 -24
  94. package/dist-sdk/src/entities/automation/to-tf.d.ts +24 -3
  95. package/dist-sdk/src/entities/automation/to-tf.js +1082 -132
  96. package/dist-sdk/src/entities/automation/triggers.d.ts +12 -6
  97. package/dist-sdk/src/entities/automation/triggers.js +4 -0
  98. package/dist-sdk/src/entities/automation/types.d.ts +9 -0
  99. package/dist-sdk/src/entities/automation/types.js +19 -0
  100. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
  101. package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
  102. package/dist-sdk/src/entities/chart/from-tf.js +9 -1
  103. package/dist-sdk/src/entities/chart/to-tf.js +10 -3
  104. package/dist-sdk/src/entities/data-lookup/module.js +2 -0
  105. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +24 -31
  106. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  107. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
  108. package/dist-sdk/src/entities/element/build.d.ts +28 -13
  109. package/dist-sdk/src/entities/element/build.js +5 -1
  110. package/dist-sdk/src/entities/element/from-tf.d.ts +11 -0
  111. package/dist-sdk/src/entities/element/from-tf.js +62 -1
  112. package/dist-sdk/src/entities/element/index.d.ts +5 -3
  113. package/dist-sdk/src/entities/element/index.js +1 -0
  114. package/dist-sdk/src/entities/element/module.js +9 -3
  115. package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
  116. package/dist-sdk/src/entities/element/to-tf.js +16 -16
  117. package/dist-sdk/src/entities/field/build.d.ts +17 -3
  118. package/dist-sdk/src/entities/field/build.js +3 -0
  119. package/dist-sdk/src/entities/field/calc.d.ts +7 -7
  120. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -4
  121. package/dist-sdk/src/entities/field/from-tf.js +244 -49
  122. package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
  123. package/dist-sdk/src/entities/field/media-types.js +30 -0
  124. package/dist-sdk/src/entities/field/module.js +2 -0
  125. package/dist-sdk/src/entities/field/options.js +6 -1
  126. package/dist-sdk/src/entities/field/to-tf.d.ts +26 -5
  127. package/dist-sdk/src/entities/field/to-tf.js +137 -15
  128. package/dist-sdk/src/entities/field/types.d.ts +2 -0
  129. package/dist-sdk/src/entities/field/types.js +27 -0
  130. package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
  131. package/dist-sdk/src/entities/file-reader/module.js +1 -0
  132. package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
  133. package/dist-sdk/src/entities/file-reader/types.js +1 -1
  134. package/dist-sdk/src/entities/portal/build.d.ts +26 -0
  135. package/dist-sdk/src/entities/portal/build.js +37 -0
  136. package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
  137. package/dist-sdk/src/entities/portal/from-tf.js +75 -0
  138. package/dist-sdk/src/entities/portal/index.d.ts +1 -0
  139. package/dist-sdk/src/entities/portal/index.js +1 -0
  140. package/dist-sdk/src/entities/portal/module.d.ts +3 -0
  141. package/dist-sdk/src/entities/portal/module.js +28 -0
  142. package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
  143. package/dist-sdk/src/entities/portal/to-tf.js +73 -0
  144. package/dist-sdk/src/entities/portal/types.d.ts +1 -0
  145. package/dist-sdk/src/entities/portal/types.js +1 -0
  146. package/dist-sdk/src/entities/relationship/module.js +2 -0
  147. package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
  148. package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
  149. package/dist-sdk/src/entities/relationship/to-tf.d.ts +2 -0
  150. package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
  151. package/dist-sdk/src/entities/role/from-tf.js +3 -3
  152. package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
  153. package/dist-sdk/src/entities/role/to-tf.js +12 -4
  154. package/dist-sdk/src/entities/search-table/module.js +1 -0
  155. package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
  156. package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
  157. package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
  158. package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
  159. package/dist-sdk/src/entities/service-account/from-tf.js +20 -8
  160. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
  161. package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
  162. package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
  163. package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
  164. package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
  165. package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
  166. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
  167. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
  168. package/dist-sdk/src/entities/shared/filters/ast.d.ts +23 -1
  169. package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
  170. package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
  171. package/dist-sdk/src/entities/shared/filters/index.js +19 -4
  172. package/dist-sdk/src/entities/shared/filters/print.js +24 -3
  173. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -0
  174. package/dist-sdk/src/entities/shared/filters/tf-codec.js +46 -7
  175. package/dist-sdk/src/entities/shared/filters/types.d.ts +15 -2
  176. package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
  177. package/dist-sdk/src/entities/shared/ref.js +5 -7
  178. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
  179. package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
  180. package/dist-sdk/src/entities/shared/types/field-types.d.ts +20 -5
  181. package/dist-sdk/src/entities/shared/types/field-types.js +8 -0
  182. package/dist-sdk/src/entities/skill/access-policy.js +3 -3
  183. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
  184. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +14 -6
  185. package/dist-sdk/src/entities/skill/from-tf.js +70 -15
  186. package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
  187. package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
  188. package/dist-sdk/src/entities/skill/module.js +2 -0
  189. package/dist-sdk/src/entities/skill/to-tf.js +14 -4
  190. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  191. package/dist-sdk/src/entities/skill-tool/from-tf.js +49 -10
  192. package/dist-sdk/src/entities/skill-tool/module.js +3 -0
  193. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -8
  194. package/dist-sdk/src/entities/skill-tool/to-tf.js +49 -14
  195. package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
  196. package/dist-sdk/src/entities/table/catalog.js +66 -0
  197. package/dist-sdk/src/entities/table/module.js +2 -1
  198. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  199. package/dist-sdk/src/entities/task/build.d.ts +8 -0
  200. package/dist-sdk/src/entities/task/build.js +10 -1
  201. package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
  202. package/dist-sdk/src/entities/task/from-tf.js +7 -2
  203. package/dist-sdk/src/entities/task/module.js +2 -2
  204. package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
  205. package/dist-sdk/src/entities/task/to-tf.js +28 -1
  206. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -9
  207. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +71 -18
  208. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +19 -4
  209. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +82 -10
  210. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +53 -23
  211. package/dist-sdk/src/entities/view/agent-view-layout.js +1 -1
  212. package/dist-sdk/src/entities/view/from-tf.d.ts +3 -2
  213. package/dist-sdk/src/entities/view/from-tf.js +133 -13
  214. package/dist-sdk/src/entities/view/module.js +30 -3
  215. package/dist-sdk/src/entities/view/to-tf.d.ts +20 -8
  216. package/dist-sdk/src/entities/view/to-tf.js +86 -18
  217. package/dist-sdk/src/entities/view/types.d.ts +4 -15
  218. package/dist-sdk/src/entities/view/types.js +15 -15
  219. package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
  220. package/dist-sdk/src/entities/visual-flow/build.js +9 -0
  221. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
  222. package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
  223. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  224. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  225. package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
  226. package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
  227. package/dist-sdk/src/entities/widget/build.d.ts +16 -1
  228. package/dist-sdk/src/entities/widget/build.js +11 -1
  229. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  230. package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
  231. package/dist-sdk/src/entities/widget/to-tf.js +41 -14
  232. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +148 -13
  233. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  234. package/dist-sdk/src/graph/index.d.ts +12 -0
  235. package/dist-sdk/src/graph/index.js +21 -0
  236. package/dist-sdk/src/graph/modules.js +2 -0
  237. package/dist-sdk/src/graph/types.d.ts +83 -4
  238. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  239. package/dist-sdk/src/internal/sdk-package.js +1 -0
  240. package/package.json +16 -3
@@ -0,0 +1,73 @@
1
+ import { workspaceAspectKey } from "../../engine/build/context.js";
2
+ import { EntityTfError } from "../../engine/entity.js";
3
+ import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
4
+ import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE, VIEW_DATA_RESOURCE_TYPE, } from "../view/types.js";
5
+ import { PORTAL_RESOURCE_TYPE } from "./types.js";
6
+ const VIEW_RESOURCE_BY_TYPE = {
7
+ list: LIST_VIEW_RESOURCE_TYPE,
8
+ calendar: CALENDAR_VIEW_RESOURCE_TYPE,
9
+ kanban: KANBAN_VIEW_RESOURCE_TYPE,
10
+ dashboard: DASHBOARD_VIEW_RESOURCE_TYPE,
11
+ agent: AGENT_VIEW_RESOURCE_TYPE,
12
+ custom: CUSTOM_VIEW_RESOURCE_TYPE,
13
+ };
14
+ /**
15
+ * A catalog view whose owner is built in this workspace is referenced as a
16
+ * resource, so the portal is created after it. Any other view is looked up by
17
+ * its owner's namespace and its name; without a namespace it can't be found.
18
+ */
19
+ function viewIdOf(view, ctx) {
20
+ const ownerKind = view.parentKind ?? "app";
21
+ const resourceType = view.viewType !== undefined ? VIEW_RESOURCE_BY_TYPE[view.viewType] : undefined;
22
+ const sibling = resourceType !== undefined ? ctx.workspaceAspects?.get(workspaceAspectKey(ownerKind, view.parent)) : undefined;
23
+ if (resourceType !== undefined && sibling !== undefined) {
24
+ if (!isCanonicalTsLabel(view.refName))
25
+ return { problem: `view ${JSON.stringify(view.name)} has no catalog key; use catalog.<app>.views.<view>` };
26
+ return { id: expr.resourceAttr(resourceType, scopedResourceLabel(sibling.tfLabel, tsLabelToTfLabel(view.refName), ownerKind), ["id"]) };
27
+ }
28
+ if (view.parentNamespace === undefined) {
29
+ return { problem: `view ${JSON.stringify(view.name)} names owner ${JSON.stringify(view.parent)}, which is not in this workspace; use viewRef({ name, parentKind, parentNamespace })` };
30
+ }
31
+ const owner = ctx.orgRefs.resolveForeignRoot(ownerKind, {
32
+ name: view.parentName ?? view.parentNamespace,
33
+ namespace: view.parentNamespace,
34
+ tfLabel: sanitizeName(view.parentNamespace),
35
+ });
36
+ const label = `${owner.tfLabel}_${sanitizeName(view.name)}`;
37
+ ctx.orgRefs.rawLookup(VIEW_DATA_RESOURCE_TYPE, label, view.name, { owner_id: expr.dataAttr(owner.resourceType, owner.tfLabel, ["id"]) });
38
+ return { id: expr.dataAttr(VIEW_DATA_RESOURCE_TYPE, label, ["id"]) };
39
+ }
40
+ export function portalToTf(entity, ctx) {
41
+ if (entity.kind !== "portal")
42
+ throw new EntityTfError(`portalToTf expects portal; got ${entity.kind}`);
43
+ const p = entity.payload;
44
+ if (p === null || !p.name || !p.slug)
45
+ throw new EntityTfError(`portal ${entity.refName}: name and slug are required`);
46
+ const attrs = { name: p.name, slug: p.slug };
47
+ if (p.description !== undefined)
48
+ attrs["description"] = p.description;
49
+ if (p.icon !== undefined)
50
+ attrs["icon"] = p.icon;
51
+ if (p.color !== undefined)
52
+ attrs["color"] = p.color;
53
+ // The menu list is the whole desired menu: an item left out would be removed
54
+ // from the portal, so an item that can't be emitted fails the build.
55
+ const items = (p.menu ?? []).map((item) => {
56
+ if (item.view === undefined || item.slug === undefined) {
57
+ throw new EntityTfError(`portal ${JSON.stringify(p.name)}: a menu item has no view or slug`);
58
+ }
59
+ const view = viewIdOf(item.view, ctx);
60
+ if ("problem" in view) {
61
+ throw new EntityTfError(`portal ${JSON.stringify(p.name)}: menu item ${JSON.stringify(item.slug)}: ${view.problem}`);
62
+ }
63
+ return {
64
+ view_id: view.id,
65
+ slug: item.slug,
66
+ ...(item.label !== undefined && { label: item.label }),
67
+ ...(item.home === true && { home: true }),
68
+ };
69
+ });
70
+ if (items.length > 0)
71
+ attrs["menu_item"] = items;
72
+ return { blocks: [{ kind: "resource", type: PORTAL_RESOURCE_TYPE, label: ctx.tfLabel, attrs }] };
73
+ }
@@ -0,0 +1 @@
1
+ export declare const PORTAL_RESOURCE_TYPE = "elementum_portal";
@@ -0,0 +1 @@
1
+ export const PORTAL_RESOURCE_TYPE = "elementum_portal";
@@ -1,4 +1,5 @@
1
1
  import { NO_CANVAS, NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
2
+ import { relationshipPairErrors } from "./pair-check.js";
2
3
  export const RELATIONSHIP_RESOURCE_TYPE = "elementum_relationship";
3
4
  export const relationshipModule = {
4
5
  kind: "relationship",
@@ -13,4 +14,5 @@ export const relationshipModule = {
13
14
  lifecycle: NO_LIFECYCLE,
14
15
  canvas: NO_CANVAS,
15
16
  catalog: NO_CATALOG,
17
+ buildChecks: { validateBuiltBlocks: relationshipPairErrors },
16
18
  };
@@ -0,0 +1,7 @@
1
+ import { type TfBlock } from "../../engine/tf/index.js";
2
+ /**
3
+ * A relationship between two managed roots is two platform records, one per side, whose columns the platform
4
+ * mirrors: changing one side changes the other. Each side lives in its owner's source, so the two must mirror
5
+ * each other or the next plan reverts a one-sided edit. Returns one error per root pair that disagrees.
6
+ */
7
+ export declare function relationshipPairErrors(blocks: readonly TfBlock[]): string[];
@@ -0,0 +1,68 @@
1
+ import { isTfExpr } from "../../engine/tf/index.js";
2
+ import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
3
+ function managedLabel(value) {
4
+ return value !== undefined && isTfExpr(value) && value.$expr === "resource-attr" ? `${value.type}.${value.label}` : undefined;
5
+ }
6
+ function columnLabel(value) {
7
+ return value !== undefined && isTfExpr(value) && (value.$expr === "resource-attr" || value.$expr === "data-attr") ? value.label : JSON.stringify(value);
8
+ }
9
+ function sideOf(block) {
10
+ const owner = managedLabel(block.attrs["object_id"]);
11
+ const target = managedLabel(block.attrs["related_object_id"]);
12
+ if (owner === undefined || target === undefined || owner === target || block.label === undefined)
13
+ return undefined;
14
+ const columns = (Array.isArray(block.attrs["columns"]) ? block.attrs["columns"] : []).map((column) => {
15
+ const attrs = (column ?? {});
16
+ return [columnLabel(attrs["field_id"]), columnLabel(attrs["related_field_id"])];
17
+ });
18
+ return { label: block.label, owner, target, columns };
19
+ }
20
+ /** Columns as one comparable key, oriented from `from`'s side. */
21
+ function joinKey(side, from) {
22
+ const pairs = side.columns.map(([own, related]) => (side.owner === from ? `${own} ↔ ${related}` : `${related} ↔ ${own}`));
23
+ return [...pairs].sort().join(", ");
24
+ }
25
+ function describe(side) {
26
+ return `[${side.columns.map(([own, related]) => `${own} ↔ ${related}`).join(", ")}]`;
27
+ }
28
+ /**
29
+ * A relationship between two managed roots is two platform records, one per side, whose columns the platform
30
+ * mirrors: changing one side changes the other. Each side lives in its owner's source, so the two must mirror
31
+ * each other or the next plan reverts a one-sided edit. Returns one error per root pair that disagrees.
32
+ */
33
+ export function relationshipPairErrors(blocks) {
34
+ const sides = blocks
35
+ .filter((block) => block.kind === "resource" && block.type === RELATIONSHIP_RESOURCE_TYPE)
36
+ .map(sideOf)
37
+ .filter((side) => side !== undefined);
38
+ const byPair = new Map();
39
+ for (const side of sides) {
40
+ const pair = [side.owner, side.target].sort().join(" <> ");
41
+ byPair.set(pair, [...(byPair.get(pair) ?? []), side]);
42
+ }
43
+ const errors = [];
44
+ for (const [pair, pairSides] of byPair) {
45
+ const [first] = pair.split(" <> ");
46
+ const a = pairSides.filter((side) => side.owner === first);
47
+ const b = pairSides.filter((side) => side.owner !== first);
48
+ if (a.length === 0 || b.length === 0)
49
+ continue; // the other side isn't authored here
50
+ const keysA = a.map((side) => joinKey(side, first)).sort();
51
+ const keysB = b.map((side) => joinKey(side, first)).sort();
52
+ if (keysA.join(" | ") === keysB.join(" | "))
53
+ continue;
54
+ if (a.length === 1 && b.length === 1) {
55
+ const [left, right] = [a[0], b[0]];
56
+ const mirrored = `[${left.columns.map(([own, related]) => `${related} ↔ ${own}`).join(", ")}]`;
57
+ errors.push(`relationship ${left.label} joins ${describe(left)} but its counterpart ${right.label} joins ${describe(right)}. ` +
58
+ `The platform mirrors the two sides, so change both: ${right.label} should join ${mirrored} ` +
59
+ `(or ${left.label} should mirror ${right.label}).`);
60
+ }
61
+ else {
62
+ errors.push(`relationships between ${a[0].owner} and ${b[0].owner} don't mirror each other: ` +
63
+ `${a.map((side) => `${side.label} ${describe(side)}`).join("; ")} vs ` +
64
+ `${b.map((side) => `${side.label} ${describe(side)}`).join("; ")}. The platform mirrors the two sides, so change both.`);
65
+ }
66
+ }
67
+ return errors;
68
+ }
@@ -2,6 +2,7 @@ import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/cont
2
2
  import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
3
3
  import { type FilterToTfContext } from "../access-policy/to-tf.js";
4
4
  import type { Filter } from "../shared/filters/types.js";
5
+ import { type FieldOwnership } from "../field/to-tf.js";
5
6
  interface RefWire {
6
7
  readonly __kind?: string;
7
8
  readonly refName?: string;
@@ -29,6 +30,7 @@ export interface RelationshipsToTfOptions {
29
30
  readonly orgRefs: OrgRefLookup;
30
31
  readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
31
32
  readonly diagnostics: string[];
33
+ readonly fieldOwnership?: FieldOwnership;
32
34
  }
33
35
  type TargetResolutionOptions = Omit<RelationshipsToTfOptions, "ownerType">;
34
36
  export declare function relationshipsToTf(relationships: Readonly<Record<string, RelationshipWire>> | undefined, opts: RelationshipsToTfOptions): TfBlock[];
@@ -2,10 +2,11 @@ import { workspaceAspectKey, } from "../../engine/build/context.js";
2
2
  import { expr, isCanonicalTsLabel, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
3
3
  import { filterToTf } from "../access-policy/to-tf.js";
4
4
  import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
5
- import { fieldRefToTfValue } from "../field/to-tf.js";
5
+ import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
6
6
  import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
7
7
  import { autoRelationColumnError } from "./column-contract.js";
8
8
  import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
9
+ import { EntityTfError } from "../../engine/entity.js";
9
10
  export function relationshipsToTf(relationships, opts) {
10
11
  const blocks = [];
11
12
  for (const [key, relationship] of Object.entries(relationships ?? {})) {
@@ -17,6 +18,12 @@ export function relationshipsToTf(relationships, opts) {
17
18
  const target = resolveTarget(relationship.target, where, opts);
18
19
  if (target === undefined)
19
20
  continue;
21
+ // The platform rejects object_id = related_object_id with "Invalid request".
22
+ if (target.kind === (opts.ownerType === "elementum_app" ? "app" : "element") && target.refName === opts.ownerRefName) {
23
+ throw new EntityTfError(`${opts.ownerType === "elementum_app" ? "app" : "element"} "${opts.ownerRefName}" ${where}: a relationship's two sides ` +
24
+ `cannot be the same ${target.kind}; the platform rejects it. ` +
25
+ `Model the link with a reference field on "${opts.ownerRefName}" instead, or relate through a child element.`);
26
+ }
20
27
  const columns = [];
21
28
  let droppedInvalidJoin = false;
22
29
  for (const [index, column] of (relationship.columns ?? []).entries()) {
@@ -85,7 +92,7 @@ function resolveOwnerField(value, where, opts) {
85
92
  opts.diagnostics.push(`${where}: field "${refName}" belongs to a different aspect; dropped`);
86
93
  return undefined;
87
94
  }
88
- const result = fieldRefToTfValue(value?.fieldType ?? "", refName, opts.ownerTfLabel, opts.scope);
95
+ const result = fieldRefToTfValue(value?.fieldType ?? "", refName, opts.ownerTfLabel, opts.scope, opts.fieldOwnership);
89
96
  if (result === undefined)
90
97
  opts.diagnostics.push(`${where}: field "${refName}" has no Terraform mapping; dropped`);
91
98
  return result;
@@ -106,6 +113,7 @@ function resolveTarget(value, where, opts) {
106
113
  refName,
107
114
  tfLabel: opts.ownerTfLabel,
108
115
  managed: true,
116
+ fieldOwnership: opts.fieldOwnership,
109
117
  };
110
118
  }
111
119
  if (kind !== "table") {
@@ -121,6 +129,7 @@ function resolveTarget(value, where, opts) {
121
129
  refName,
122
130
  tfLabel: sibling.tfLabel,
123
131
  managed: true,
132
+ fieldOwnership: authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload),
124
133
  };
125
134
  }
126
135
  }
@@ -184,7 +193,7 @@ function resolveRelatedField(value, target, where, opts) {
184
193
  target.kind !== "table" &&
185
194
  target.kind !== "task" &&
186
195
  target.tfLabel !== undefined) {
187
- const direct = fieldRefToTfValue(value?.fieldType ?? "", refName, target.tfLabel, target.kind);
196
+ const direct = fieldRefToTfValue(value?.fieldType ?? "", refName, target.tfLabel, target.kind, target.fieldOwnership);
188
197
  if (direct !== undefined)
189
198
  return direct;
190
199
  }
@@ -1,5 +1,5 @@
1
- import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
2
- import { scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
1
+ import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
2
+ import { scopedLabelToBagKey } from "../../engine/tf/index.js";
3
3
  import { ROLE_RESOURCE_TYPE } from "../org/role.js";
4
4
  const KNOWN = new Set(["id", "object_id", "name", "description", "auto_share", "user_ids", "group_ids", "service_account_ids", "permissions", "managed", "tags"]);
5
5
  function strings(value, where, ctx) {
@@ -23,7 +23,7 @@ function principal(value, type, where, ctx) {
23
23
  }
24
24
  return { __kind: "user", email: name.trim() };
25
25
  }
26
- return { __kind: "group", refName: tfLabelToTsLabel(label), name };
26
+ return { __kind: "group", refName: groupCatalogKey(ctx, label, name), name };
27
27
  }
28
28
  ctx.diagnostics.push(`${where}: data.${type}.${label} has no lookup value; dropped`);
29
29
  return undefined;
@@ -2,6 +2,7 @@ import type { OrgRefLookup } from "../../engine/build/context.js";
2
2
  import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
3
3
  import type { AppRole } from "./build.js";
4
4
  import type { AppServiceAccount } from "../service-account/build.js";
5
+ import type { ServiceAccountOwningApp } from "../service-account/workspace-owner.js";
5
6
  export declare function rolesToTf(roles: Readonly<Record<string, AppRole>> | undefined, opts: {
6
7
  readonly ownerRefName: string;
7
8
  readonly ownerTfLabel: string;
@@ -10,4 +11,5 @@ export declare function rolesToTf(roles: Readonly<Record<string, AppRole>> | und
10
11
  readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
11
12
  readonly orgRefs: OrgRefLookup;
12
13
  readonly diagnostics: string[];
14
+ readonly resolveServiceAccountApp?: (appRefName: string) => ServiceAccountOwningApp | undefined;
13
15
  }): TfBlock[];
@@ -1,6 +1,7 @@
1
1
  import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
2
2
  import { ROLE_RESOURCE_TYPE } from "../org/role.js";
3
3
  import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
4
+ import { serviceAccountRefToTf } from "../service-account/to-tf.js";
4
5
  function principals(values, type, where, orgRefs, diagnostics) {
5
6
  if (values === undefined || values.length === 0)
6
7
  return undefined;
@@ -41,11 +42,18 @@ export function rolesToTf(roles, opts) {
41
42
  attrs["group_ids"] = groups;
42
43
  if (role.serviceAccounts !== undefined) {
43
44
  attrs["service_account_ids"] = role.serviceAccounts.flatMap((account) => {
44
- if (account.appRefName !== opts.ownerRefName) {
45
- opts.diagnostics.push(`roles.${key}.serviceAccounts: ${JSON.stringify(account.name)} belongs to app ${JSON.stringify(account.appRefName)}, not ${JSON.stringify(opts.ownerRefName)}; dropped`);
46
- return [];
45
+ if (opts.scope !== "app" || account.appRefName !== opts.ownerRefName) {
46
+ // Another app's account (or any account on an element role, which
47
+ // owns none): resolve it under its OWNING app (#1592).
48
+ const owning = opts.resolveServiceAccountApp?.(account.appRefName);
49
+ if (owning === undefined) {
50
+ opts.diagnostics.push(`roles.${key}.serviceAccounts: ${JSON.stringify(account.name)} belongs to app ${JSON.stringify(account.appRefName)}, which is not in this workspace; dropped`);
51
+ return [];
52
+ }
53
+ const value = serviceAccountRefToTf({ __kind: "serviceAccount", appRefName: account.appRefName, name: account.name }, { appRefName: account.appRefName, ...owning, orgRefs: opts.orgRefs }, `roles.${key}.serviceAccounts`, opts.diagnostics);
54
+ return value === undefined ? [] : [value];
47
55
  }
48
- const local = Object.entries(opts.serviceAccounts ?? {}).find(([, candidate]) => `${candidate.firstName} ${candidate.lastName}` === account.name);
56
+ const local = Object.entries(opts.serviceAccounts ?? {}).find(([, candidate]) => `${candidate.firstName} ${candidate.lastName}`.trim() === account.name);
49
57
  if (local !== undefined)
50
58
  return [expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(local[0]), "app"), ["id"])];
51
59
  const label = sanitizeName(account.name);
@@ -115,6 +115,7 @@ export const searchTableModule = {
115
115
  parentScope: ctx.parentScope ?? "app",
116
116
  orgRefs: ctx.orgRefs,
117
117
  diagnostics: ctx.diagnostics,
118
+ fieldAddresses: ctx.fieldAddresses,
118
119
  }),
119
120
  },
120
121
  canvas: { participates: true, label: "Search tables", glyph: "⌕", component: "generic" },
@@ -7,6 +7,7 @@ export interface SearchTableToTfContext {
7
7
  readonly parentScope: ChildResourceScope | "table";
8
8
  readonly orgRefs: OrgRefLookup;
9
9
  readonly diagnostics: string[];
10
+ readonly fieldAddresses?: ReadonlyMap<string, string>;
10
11
  }
11
12
  export declare function searchTableToTf(entity: DeployableEntity, ctx: SearchTableToTfContext): {
12
13
  readonly blocks: readonly TfBlock[];
@@ -10,7 +10,7 @@ function fieldValue(token, ctx, where) {
10
10
  if (token.parent !== undefined && token.parent !== ctx.appRefName) {
11
11
  throw new EntityTfError(`${where}: cross-aspect field token ${token.parent}.${token.refName} is not supported`);
12
12
  }
13
- const value = fieldRefToTfValue(token.fieldType ?? "", token.refName, ctx.appTfLabel, ctx.parentScope);
13
+ const value = fieldRefToTfValue(token.fieldType ?? "", token.refName, ctx.appTfLabel, ctx.parentScope, ctx.fieldAddresses);
14
14
  if (value === undefined)
15
15
  throw new EntityTfError(`${where}: field ${token.refName} has no Terraform resource mapping`);
16
16
  return value;
@@ -1,4 +1,5 @@
1
1
  import type { GroupRef } from "../../catalog/index.js";
2
+ import type { UnsafePlatformId } from "../../core/platform-id.js";
2
3
  import type { RoleUserRef } from "../role/build.js";
3
4
  declare const serviceAccountStatusBrand: unique symbol;
4
5
  export type ServiceAccountStatus = string & {
@@ -14,6 +15,13 @@ export interface ServiceAccountRoleRef {
14
15
  readonly name: string;
15
16
  }
16
17
  export declare function serviceAccountRoleRef(name: string): ServiceAccountRoleRef;
18
+ /**
19
+ * A role named on this app, or a platform id pull could not name.
20
+ * `unsafePlatformId` is the escape for a role that lives on another app,
21
+ * element, or table: the export only has the id, and dropping it would strip
22
+ * the role from the live account on the next apply.
23
+ */
24
+ export type ServiceAccountRole = ServiceAccountRoleRef | UnsafePlatformId;
17
25
  export interface ServiceAccountAccessPolicy {
18
26
  readonly users?: readonly RoleUserRef[];
19
27
  readonly groups?: readonly GroupRef[];
@@ -24,8 +32,13 @@ export interface AppServiceAccount {
24
32
  readonly lastName: string;
25
33
  readonly purpose: string;
26
34
  readonly status?: ServiceAccountStatus;
27
- /** Custom or managed roles, both resolved by name within this app. */
28
- readonly roles?: readonly ServiceAccountRoleRef[];
35
+ /**
36
+ * Roles assigned to this account, in platform order.
37
+ * Name a role on this app with `serviceAccountRoleRef`. Pull keeps a role
38
+ * it cannot name — one owned by another app, element, or table — as
39
+ * `unsafePlatformId(...)`.
40
+ */
41
+ readonly roles?: readonly ServiceAccountRole[];
29
42
  /** Users/groups allowed to select and run as this identity. */
30
43
  readonly accessPolicies?: readonly ServiceAccountAccessPolicy[];
31
44
  }
@@ -1,10 +1,8 @@
1
1
  import { type FromTfContext } from "../../engine/pull/context.js";
2
2
  import { type TfBlock } from "../../engine/tf/index.js";
3
3
  import { type AppServiceAccount } from "./build.js";
4
+ import { type ServiceAccountRoleOwner } from "./role-fidelity.js";
4
5
  export interface NormalizedServiceAccount extends AppServiceAccount {
5
6
  readonly key: string;
6
7
  }
7
- export declare function serviceAccountsFromTf(blocks: readonly TfBlock[], owner: {
8
- readonly label: string;
9
- readonly ownerTfLabel: string;
10
- }, ctx: FromTfContext): NormalizedServiceAccount[];
8
+ export declare function serviceAccountsFromTf(blocks: readonly TfBlock[], owner: ServiceAccountRoleOwner, ctx: FromTfContext): NormalizedServiceAccount[];
@@ -1,7 +1,9 @@
1
- import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
2
- import { scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
1
+ import { unsafePlatformId } from "../../core/platform-id.js";
2
+ import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
3
+ import { scopedLabelToBagKey } from "../../engine/tf/index.js";
3
4
  import { serviceAccountRoleRef, serviceAccountStatus, } from "./build.js";
4
5
  import { SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE, SERVICE_ACCOUNT_RESOURCE_TYPE } from "./module.js";
6
+ import { serviceAccountRoleIdMismatches } from "./role-fidelity.js";
5
7
  const ACCOUNT_ATTRS = new Set(["id", "app_id", "first_name", "last_name", "purpose", "name", "status", "role_ids"]);
6
8
  const POLICY_ATTRS = new Set(["id", "app_id", "service_account_id", "user_ids", "group_ids"]);
7
9
  function principal(value, type, where, ctx) {
@@ -16,7 +18,7 @@ function principal(value, type, where, ctx) {
16
18
  }
17
19
  return { __kind: "user", email: name.trim() };
18
20
  }
19
- return { __kind: "group", refName: tfLabelToTsLabel(label), name };
21
+ return { __kind: "group", refName: groupCatalogKey(ctx, label, name), name };
20
22
  }
21
23
  ctx.diagnostics.push(`${where}: data.${type}.${label} has no lookup value; dropped`);
22
24
  return undefined;
@@ -39,6 +41,10 @@ function principalList(value, type, where, ctx) {
39
41
  : principal(item, "elementum_group", where, ctx)) ?? []);
40
42
  return out.length > 0 ? out : undefined;
41
43
  }
44
+ function keptPlatformId(id, where, ctx) {
45
+ ctx.diagnostics.push(`${where}: role reference has no recoverable name; kept as unsafePlatformId`);
46
+ return unsafePlatformId(id);
47
+ }
42
48
  function roleRefs(value, blocks, where, ctx) {
43
49
  if (value === undefined)
44
50
  return undefined;
@@ -53,23 +59,26 @@ function roleRefs(value, blocks, where, ctx) {
53
59
  const role = blocks.find((candidate) => candidate.type === "elementum_role" && candidate.label === resourceLabel);
54
60
  if (typeof role?.attrs["name"] === "string")
55
61
  out.push(serviceAccountRoleRef(role.attrs["name"]));
56
- else
57
- ctx.diagnostics.push(`${where}: ${resourceLabel} has no recoverable role name; dropped`);
62
+ else {
63
+ const id = typeof role?.attrs["id"] === "string" ? role.attrs["id"] : ctx.importId(`elementum_role.${resourceLabel}`);
64
+ if (typeof id === "string" && id.trim() !== "")
65
+ out.push(keptPlatformId(id, where, ctx));
66
+ }
58
67
  continue;
59
68
  }
60
69
  const dataLabel = dataRefLabel(item, "elementum_role");
61
70
  const name = dataLabel === undefined ? undefined : ctx.dataName("elementum_role", dataLabel);
62
71
  if (name !== undefined)
63
72
  out.push(serviceAccountRoleRef(name));
64
- else
65
- ctx.diagnostics.push(`${where}: role reference has no recoverable name; dropped`);
73
+ else if (typeof item === "string" && item.trim() !== "")
74
+ out.push(keptPlatformId(item, where, ctx));
66
75
  }
67
76
  return out.length > 0 ? out : undefined;
68
77
  }
69
78
  export function serviceAccountsFromTf(blocks, owner, ctx) {
70
79
  const accounts = blocks.filter((block) => block.type === SERVICE_ACCOUNT_RESOURCE_TYPE);
71
80
  const policies = blocks.filter((block) => block.type === SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE);
72
- return accounts.flatMap((block) => {
81
+ const extracted = accounts.flatMap((block) => {
73
82
  const label = block.label ?? "";
74
83
  const where = `${SERVICE_ACCOUNT_RESOURCE_TYPE}.${label || "?"}`;
75
84
  if (label === "" || resourceRefLabel(block.attrs["app_id"], "elementum_app") !== owner.label)
@@ -112,4 +121,7 @@ export function serviceAccountsFromTf(blocks, owner, ctx) {
112
121
  ...(accessPolicies.length > 0 && { accessPolicies }),
113
122
  }];
114
123
  });
124
+ for (const mismatch of serviceAccountRoleIdMismatches(blocks, extracted, owner, ctx))
125
+ ctx.diagnostics.push(mismatch);
126
+ return extracted;
115
127
  }
@@ -0,0 +1,56 @@
1
+ import { type FromTfContext } from "../../engine/pull/context.js";
2
+ import { type TfBlock } from "../../engine/tf/index.js";
3
+ import type { ServiceAccountRole } from "./build.js";
4
+ /**
5
+ * Pull must not report success when a service account's generated roles
6
+ * disagree with the export's `role_ids`. Adoption plans the export, so a
7
+ * clean adopt does not prove the authored source kept every role.
8
+ */
9
+ export declare const SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX = "service-account role_ids mismatch:";
10
+ export interface ServiceAccountRoleOwner {
11
+ readonly label: string;
12
+ readonly ownerTfLabel: string;
13
+ /** Authoring file to edit, relative to the org root when known. */
14
+ readonly sourceFile?: string;
15
+ }
16
+ interface ExtractedServiceAccountRoles {
17
+ readonly key: string;
18
+ readonly roles?: readonly ServiceAccountRole[];
19
+ }
20
+ /**
21
+ * Order-sensitive comparison of each owned service account's export
22
+ * `role_ids` with the roles written into source. Named roles compare by
23
+ * display name; raw ids compare by platform id. A value the printer cannot
24
+ * represent is a disagreement, not a quiet omission.
25
+ */
26
+ export declare function serviceAccountRoleIdMismatches(blocks: readonly TfBlock[], accounts: readonly ExtractedServiceAccountRoles[], owner: ServiceAccountRoleOwner, ctx: FromTfContext): readonly string[];
27
+ /**
28
+ * Role names the service-account rebuild actually emitted.
29
+ * Export labels are a different namespace: a name with no ASCII letters, or
30
+ * two names that sanitize to one label, must be read from these lookups.
31
+ */
32
+ export interface RebuiltServiceAccountRoleLookup {
33
+ /** Managed-role display names in `rawLookup` order, keyed by the data label the rebuild emitted. */
34
+ readonly dataRoleNames: ReadonlyMap<string, readonly string[]>;
35
+ /** Custom-role display names keyed by the resource label the rebuild emitted. */
36
+ readonly resourceRoleNames: ReadonlyMap<string, string>;
37
+ }
38
+ /**
39
+ * Same order-sensitive rule, against service-account blocks rebuilt from
40
+ * the pulled `.ts`. A printer or to-tf that drops or reorders a raw id
41
+ * disagrees here even when extract mirrored the export.
42
+ * When `lookup` is set, rebuilt refs resolve through it. Export refs still
43
+ * use `ctx` and the export blocks.
44
+ */
45
+ export declare function rebuiltServiceAccountRoleIdMismatches(exportBlocks: readonly TfBlock[], rebuiltBlocks: readonly TfBlock[], owner: ServiceAccountRoleOwner, ctx: FromTfContext, lookup?: RebuiltServiceAccountRoleLookup): readonly string[];
46
+ /** Authoring files named by role-mismatch lines, in first-seen order. */
47
+ export declare function serviceAccountRoleMismatchSources(lines: readonly string[]): readonly string[];
48
+ /** Single-root build-vs-export lines that are a service-account `role_ids` disagreement. */
49
+ export declare function serviceAccountRoleRoundTripMismatches(differences: readonly string[], sourceFile: string): readonly string[];
50
+ export declare function serviceAccountRoleGuardBlocksSuccess(diagnostics: readonly string[]): boolean;
51
+ /** Adoption failure fails a pull. Role-id disagreement must too, even when adoption succeeded or was skipped. */
52
+ export declare function serviceAccountPullMustFail(input: {
53
+ readonly adoptionFailed: boolean;
54
+ readonly diagnostics: readonly string[];
55
+ }): boolean;
56
+ export {};