@elementumai/edk 0.12.0 → 0.13.0
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.
- package/README.md +2 -0
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +2 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +10 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +7 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
- package/dist-sdk/src/engine/pull/stream-root.js +563 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +18 -3
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
- package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
- package/dist-sdk/src/entities/agent/from-tf.js +262 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
- package/dist-sdk/src/entities/agent/to-tf.js +158 -14
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +33 -13
- package/dist-sdk/src/entities/app/build.js +14 -12
- package/dist-sdk/src/entities/app/from-tf.js +24 -9
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
- package/dist-sdk/src/entities/app/stage-keys.js +3 -3
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +20 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +593 -101
- package/dist-sdk/src/entities/automation/index.d.ts +1 -0
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +33 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
- package/dist-sdk/src/entities/automation/tasks.js +34 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/automation/to-tf.js +337 -77
- package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
- package/dist-sdk/src/entities/automation/triggers.js +26 -11
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.js +3 -0
- package/dist-sdk/src/entities/chart/to-tf.js +19 -2
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.js +15 -2
- package/dist-sdk/src/entities/element/module.js +3 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
- package/dist-sdk/src/entities/field/from-tf.js +99 -6
- package/dist-sdk/src/entities/field/module.js +4 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/field/to-tf.js +33 -12
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +4 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
- package/dist-sdk/src/entities/shared/filters/index.js +18 -6
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.js +9 -5
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +2 -1
- package/dist-sdk/src/entities/view/from-tf.js +7 -4
- package/dist-sdk/src/entities/widget/from-tf.js +13 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +5 -0
- package/dist-sdk/src/graph/index.js +7 -0
- package/dist-sdk/src/graph/modules.js +11 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +78 -6
- package/package.json +6 -3
|
@@ -6,7 +6,7 @@ function managedLabel(value) {
|
|
|
6
6
|
function columnLabel(value) {
|
|
7
7
|
return value !== undefined && isTfExpr(value) && (value.$expr === "resource-attr" || value.$expr === "data-attr") ? value.label : JSON.stringify(value);
|
|
8
8
|
}
|
|
9
|
-
function sideOf(block) {
|
|
9
|
+
function sideOf(block, root) {
|
|
10
10
|
const owner = managedLabel(block.attrs["object_id"]);
|
|
11
11
|
const target = managedLabel(block.attrs["related_object_id"]);
|
|
12
12
|
if (owner === undefined || target === undefined || owner === target || block.label === undefined)
|
|
@@ -15,7 +15,7 @@ function sideOf(block) {
|
|
|
15
15
|
const attrs = (column ?? {});
|
|
16
16
|
return [columnLabel(attrs["field_id"]), columnLabel(attrs["related_field_id"])];
|
|
17
17
|
});
|
|
18
|
-
return { label: block.label, owner, target, columns };
|
|
18
|
+
return { label: block.label, owner, target, columns, root, pull: root.pull.group(pairKey(owner, target)) };
|
|
19
19
|
}
|
|
20
20
|
/** Columns as one comparable key, oriented from `from`'s side. */
|
|
21
21
|
function joinKey(side, from) {
|
|
@@ -25,22 +25,99 @@ function joinKey(side, from) {
|
|
|
25
25
|
function describe(side) {
|
|
26
26
|
return `[${side.columns.map(([own, related]) => `${own} ↔ ${related}`).join(", ")}]`;
|
|
27
27
|
}
|
|
28
|
+
function isRelationshipBlock(block) {
|
|
29
|
+
return block.kind === "resource" && block.type === RELATIONSHIP_RESOURCE_TYPE;
|
|
30
|
+
}
|
|
31
|
+
function pairKey(owner, target) {
|
|
32
|
+
return [owner, target].sort().join(" <> ");
|
|
33
|
+
}
|
|
34
|
+
/** The pair a relationship block joins, which build hashes per root against the last pull (edk#2430). */
|
|
35
|
+
export function relationshipPair(block) {
|
|
36
|
+
if (!isRelationshipBlock(block))
|
|
37
|
+
return undefined;
|
|
38
|
+
const owner = managedLabel(block.attrs["object_id"]);
|
|
39
|
+
const target = managedLabel(block.attrs["related_object_id"]);
|
|
40
|
+
return owner === undefined || target === undefined || owner === target ? undefined : pairKey(owner, target);
|
|
41
|
+
}
|
|
42
|
+
const PULLABLE_KINDS = new Set(["app", "element", "task"]);
|
|
43
|
+
function pulledAt(iso) {
|
|
44
|
+
return iso.replace(/\.\d+Z$/, "Z");
|
|
45
|
+
}
|
|
46
|
+
function repull(root) {
|
|
47
|
+
return PULLABLE_KINDS.has(root.kind) ? `\`elementum pull ${root.kind} ${root.tfLabel}\`` : `a fresh pull of ${root.file}`;
|
|
48
|
+
}
|
|
49
|
+
/** One side's relationships against its last pull on this machine, as a clause naming its file. */
|
|
50
|
+
function pullClause(side) {
|
|
51
|
+
const { root, pull: status } = side;
|
|
52
|
+
switch (status.state) {
|
|
53
|
+
case "unchecked":
|
|
54
|
+
return `${root.file} isn't compared with its pull record in this build`;
|
|
55
|
+
case "unreadable":
|
|
56
|
+
return status.what === "record"
|
|
57
|
+
? `${root.file}'s pull record couldn't be read (.edk-state/pulled-roots.json)`
|
|
58
|
+
: `${root.file} couldn't be read to compare with its pull record`;
|
|
59
|
+
case "unrecorded":
|
|
60
|
+
return `${root.file} has no pull record on this machine`;
|
|
61
|
+
case "unchanged":
|
|
62
|
+
return status.fileEdited
|
|
63
|
+
? `${root.file} was edited after its last pull (${pulledAt(status.pulledAt)}) but not its relationships to ${side.target}`
|
|
64
|
+
: `${root.file} still matches its last pull (${pulledAt(status.pulledAt)})`;
|
|
65
|
+
case "edited":
|
|
66
|
+
return `${root.file}'s relationships to ${side.target} were edited after its last pull (${pulledAt(status.pulledAt)})`;
|
|
67
|
+
case "unknown":
|
|
68
|
+
return `${root.file} was edited after its last pull (${pulledAt(status.pulledAt)}), and whether that touched its relationships to ${side.target} isn't known`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function pulledTogether(a, b) {
|
|
72
|
+
return a.pulledAt === b.pulledAt || (a.pullRun !== undefined && a.pullRun === b.pullRun);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Which of the two sides' relationships differ from their last pull on this machine, as far as that is known.
|
|
76
|
+
* Only this pair's relationships count: an edit elsewhere in a file doesn't make its side the stale one (edk#2430).
|
|
77
|
+
*/
|
|
78
|
+
function staleness(leftSide, rightSide) {
|
|
79
|
+
const [left, right] = [leftSide.root, rightSide.root];
|
|
80
|
+
const [a, b] = [leftSide.pull, rightSide.pull];
|
|
81
|
+
if (a.state === "unchecked" || b.state === "unchecked") {
|
|
82
|
+
return "This build doesn't compare files with their pull records, so which side is stale isn't checked.";
|
|
83
|
+
}
|
|
84
|
+
const sides = `${pullClause(leftSide)}; ${pullClause(rightSide)}`;
|
|
85
|
+
// A re-pull rewrites the whole file, so it's only offered for a file with no edits since its pull (edk#2430).
|
|
86
|
+
if ((a.state === "edited" && b.state === "unchanged") || (a.state === "unchanged" && b.state === "edited")) {
|
|
87
|
+
const [edited, untouched] = a.state === "edited" ? [left, right] : [right, left];
|
|
88
|
+
return `${sides}, so the edit is the difference: make the same change in ${untouched.file}, or undo it in ${edited.file} by hand.`;
|
|
89
|
+
}
|
|
90
|
+
if (a.state === "unchanged" && b.state === "unchanged") {
|
|
91
|
+
if (pulledTogether(a, b)) {
|
|
92
|
+
return a.fileEdited || b.fileEdited
|
|
93
|
+
? `${sides}, and the two were pulled together, so the platform returned the two sides this way; compare both with the platform and fix the relationship by hand.`
|
|
94
|
+
: `${sides}, and the two were pulled together, so the platform returned the two sides this way; re-pull both before changing either.`;
|
|
95
|
+
}
|
|
96
|
+
const [older, newer, olderStatus] = a.pulledAt < b.pulledAt ? [left, right, a] : [right, left, b];
|
|
97
|
+
const fix = olderStatus.fileEdited
|
|
98
|
+
? `mirror ${newer.file}'s side into it by hand (a re-pull would also drop its other edits since that pull)`
|
|
99
|
+
: `re-pull it with ${repull(older)} before hand-editing either`;
|
|
100
|
+
return `${sides}, and ${older.file} was pulled before ${newer.file}, so ${older.file} is the likely stale side: ${fix}.`;
|
|
101
|
+
}
|
|
102
|
+
return `${sides}, so which side is stale isn't known; compare both with the platform before changing either.`;
|
|
103
|
+
}
|
|
28
104
|
/**
|
|
29
105
|
* A relationship between two managed roots is two platform records, one per side, whose columns the platform
|
|
30
106
|
* 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
|
|
107
|
+
* each other or the next plan reverts a one-sided edit. Returns one failure per root pair that disagrees,
|
|
108
|
+
* naming both source files and which one differs from its last pull when that is known (edk#2430).
|
|
32
109
|
*/
|
|
33
|
-
export function relationshipPairErrors(
|
|
34
|
-
const sides = blocks
|
|
35
|
-
.filter(
|
|
36
|
-
.map(sideOf)
|
|
37
|
-
.filter((side) => side !== undefined);
|
|
110
|
+
export function relationshipPairErrors(roots) {
|
|
111
|
+
const sides = roots.flatMap((root) => root.blocks
|
|
112
|
+
.filter(isRelationshipBlock)
|
|
113
|
+
.map((block) => sideOf(block, root))
|
|
114
|
+
.filter((side) => side !== undefined));
|
|
38
115
|
const byPair = new Map();
|
|
39
116
|
for (const side of sides) {
|
|
40
|
-
const pair =
|
|
117
|
+
const pair = pairKey(side.owner, side.target);
|
|
41
118
|
byPair.set(pair, [...(byPair.get(pair) ?? []), side]);
|
|
42
119
|
}
|
|
43
|
-
const
|
|
120
|
+
const failures = [];
|
|
44
121
|
for (const [pair, pairSides] of byPair) {
|
|
45
122
|
const [first] = pair.split(" <> ");
|
|
46
123
|
const a = pairSides.filter((side) => side.owner === first);
|
|
@@ -51,18 +128,28 @@ export function relationshipPairErrors(blocks) {
|
|
|
51
128
|
const keysB = b.map((side) => joinKey(side, first)).sort();
|
|
52
129
|
if (keysA.join(" | ") === keysB.join(" | "))
|
|
53
130
|
continue;
|
|
131
|
+
const [left, right] = [a[0], b[0]];
|
|
132
|
+
const address = `${RELATIONSHIP_RESOURCE_TYPE}.${left.label}`;
|
|
133
|
+
const stale = staleness(left, right);
|
|
54
134
|
if (a.length === 1 && b.length === 1) {
|
|
55
|
-
const [left, right] = [a[0], b[0]];
|
|
56
135
|
const mirrored = `[${left.columns.map(([own, related]) => `${related} ↔ ${own}`).join(", ")}]`;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
136
|
+
failures.push({
|
|
137
|
+
address,
|
|
138
|
+
name: left.label,
|
|
139
|
+
message: `relationship ${left.label} (${left.root.file}) joins ${describe(left)} but its counterpart ${right.label} (${right.root.file}) joins ${describe(right)}. ` +
|
|
140
|
+
`The platform mirrors the two sides, so change both: ${right.label} should join ${mirrored} ` +
|
|
141
|
+
`(or ${left.label} should mirror ${right.label}). ${stale}`,
|
|
142
|
+
});
|
|
60
143
|
}
|
|
61
144
|
else {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
145
|
+
failures.push({
|
|
146
|
+
address,
|
|
147
|
+
name: left.label,
|
|
148
|
+
message: `relationships between ${left.owner} (${left.root.file}) and ${right.owner} (${right.root.file}) don't mirror each other: ` +
|
|
149
|
+
`${a.map((side) => `${side.label} ${describe(side)}`).join("; ")} vs ` +
|
|
150
|
+
`${b.map((side) => `${side.label} ${describe(side)}`).join("; ")}. The platform mirrors the two sides, so change both. ${stale}`,
|
|
151
|
+
});
|
|
65
152
|
}
|
|
66
153
|
}
|
|
67
|
-
return
|
|
154
|
+
return failures;
|
|
68
155
|
}
|
|
@@ -4,6 +4,7 @@ import { filterToTf } from "../access-policy/to-tf.js";
|
|
|
4
4
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
5
5
|
import { authoredFieldKeysFromPayload, droppedEntryGap, fieldLookupName, fieldRefToTfValue, skippedResourceGap, unauthoredSiblingFieldRef, UNRESOLVED_FIELD_REF, } from "../field/to-tf.js";
|
|
6
6
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
|
|
7
|
+
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
7
8
|
import { autoRelationColumnError } from "./column-contract.js";
|
|
8
9
|
import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
|
|
9
10
|
import { EntityTfError } from "../../engine/entity.js";
|
|
@@ -120,8 +121,10 @@ function resolveOwnerField(value, where, opts) {
|
|
|
120
121
|
return undefined;
|
|
121
122
|
}
|
|
122
123
|
if (typeof value === "string") {
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
// An element's audit keys build to its platform audit field (#2513); the
|
|
125
|
+
// audit-field guard refuses them on an element without audit fields.
|
|
126
|
+
if (opts.scope === "element" && !ELEMENT_SYSTEM_FIELD_KEYS.includes(value)) {
|
|
127
|
+
opts.diagnostics.push(`${where}: element relationships only support system fields ${ELEMENT_SYSTEM_FIELD_KEYS.map((key) => `"${key}"`).join(", ")}; dropped`);
|
|
125
128
|
return undefined;
|
|
126
129
|
}
|
|
127
130
|
const attr = SYSTEM_FIELD_ID_ATTR_BY_KEY.get(value);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RolePermission } from "./build.js";
|
|
2
|
+
/**
|
|
3
|
+
* Why a role permission's level can't be used with its group, or undefined
|
|
4
|
+
* when it can. CUSTOM, NONE and groups the table doesn't list are left to
|
|
5
|
+
* the provider, as it does.
|
|
6
|
+
*/
|
|
7
|
+
export declare function rolePermissionLevelError(permission: RolePermission): string | undefined;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Which levels each app/element role permission group stores as written
|
|
2
|
+
// (edk#2133). The provider refuses any other level at plan, so the build
|
|
3
|
+
// refuses it first. These are copies of the provider's tables in
|
|
4
|
+
// provider/internal/provider/role_resource.go, where the reasons for each
|
|
5
|
+
// entry are: MAX_LEVEL_BY_GROUP = MaxPermissionLevelByGroup,
|
|
6
|
+
// MIN_LEVEL_BY_GROUP = MinPermissionLevelByGroup and UNSTORED_LEVEL_BY_GROUP
|
|
7
|
+
// = UnstoredPermissionLevelByGroup. The exporter,
|
|
8
|
+
// cmd/elementum/export/hcl_role.go, has its own copies of the max and
|
|
9
|
+
// unstored tables only; the minimum table exists in the provider and here.
|
|
10
|
+
// Change all copies together.
|
|
11
|
+
const LEVEL_RANK = { NONE: 0, VIEW: 1, EDIT: 2, ADMIN: 3 };
|
|
12
|
+
const MAX_LEVEL_BY_GROUP = {
|
|
13
|
+
AGENTS: "ADMIN",
|
|
14
|
+
AI_PROVIDERS: "ADMIN",
|
|
15
|
+
ANALYTICS: "ADMIN",
|
|
16
|
+
APPS: "ADMIN",
|
|
17
|
+
ATTACHMENTS: "EDIT",
|
|
18
|
+
AUTOMATIONS: "ADMIN",
|
|
19
|
+
CONVERSATIONS: "ADMIN",
|
|
20
|
+
RECORDS: "ADMIN",
|
|
21
|
+
RELATIONSHIPS: "ADMIN",
|
|
22
|
+
SERVICES: "ADMIN",
|
|
23
|
+
SLAS: "ADMIN",
|
|
24
|
+
USERS: "ADMIN",
|
|
25
|
+
};
|
|
26
|
+
const MIN_LEVEL_BY_GROUP = {
|
|
27
|
+
AGENTS: "EDIT",
|
|
28
|
+
AI_PROVIDERS: "ADMIN",
|
|
29
|
+
AUTOMATIONS: "EDIT",
|
|
30
|
+
RELATIONSHIPS: "EDIT",
|
|
31
|
+
};
|
|
32
|
+
const UNSTORED_LEVEL_BY_GROUP = {
|
|
33
|
+
ATTACHMENTS: { ADMIN: "EDIT" },
|
|
34
|
+
SLAS: { EDIT: "VIEW" },
|
|
35
|
+
};
|
|
36
|
+
/** An unknown level ranks as NONE, as in the provider's `levelRank[level]` lookup. */
|
|
37
|
+
function rank(level) {
|
|
38
|
+
return LEVEL_RANK[level] ?? 0;
|
|
39
|
+
}
|
|
40
|
+
/** The non-NONE levels a group stores as written, e.g. "VIEW or ADMIN". */
|
|
41
|
+
function supportedLevels(group) {
|
|
42
|
+
const levels = ["VIEW", "EDIT", "ADMIN"].filter((level) => {
|
|
43
|
+
const max = MAX_LEVEL_BY_GROUP[group];
|
|
44
|
+
const min = MIN_LEVEL_BY_GROUP[group];
|
|
45
|
+
if (max !== undefined && rank(level) > rank(max))
|
|
46
|
+
return false;
|
|
47
|
+
if (min !== undefined && rank(level) < rank(min))
|
|
48
|
+
return false;
|
|
49
|
+
return UNSTORED_LEVEL_BY_GROUP[group]?.[level] === undefined;
|
|
50
|
+
});
|
|
51
|
+
return levels.length < 2 ? levels.join("") : `${levels.slice(0, -1).join(", ")} or ${levels[levels.length - 1]}`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Why a role permission's level can't be used with its group, or undefined
|
|
55
|
+
* when it can. CUSTOM, NONE and groups the table doesn't list are left to
|
|
56
|
+
* the provider, as it does.
|
|
57
|
+
*/
|
|
58
|
+
export function rolePermissionLevelError(permission) {
|
|
59
|
+
const group = permission.group;
|
|
60
|
+
const level = permission.level;
|
|
61
|
+
if (level === "CUSTOM" || level === "NONE")
|
|
62
|
+
return undefined;
|
|
63
|
+
const max = MAX_LEVEL_BY_GROUP[group];
|
|
64
|
+
if (max === undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
const storedAs = UNSTORED_LEVEL_BY_GROUP[group]?.[level];
|
|
67
|
+
if (storedAs !== undefined) {
|
|
68
|
+
return `${group} supports ${supportedLevels(group)}; ${level} is stored as ${storedAs}, so the plan would never converge`;
|
|
69
|
+
}
|
|
70
|
+
const min = MIN_LEVEL_BY_GROUP[group];
|
|
71
|
+
if (min !== undefined && rank(level) > rank("NONE") && rank(level) < rank(min)) {
|
|
72
|
+
return `${group} grants nothing below ${min}, so ${level} would be stored as NONE; use NONE or at least ${min} (${group} supports ${supportedLevels(group)})`;
|
|
73
|
+
}
|
|
74
|
+
if (rank(level) > rank(max)) {
|
|
75
|
+
return `${group} goes up to ${max}, not ${level} (${group} supports ${supportedLevels(group)})`;
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
@@ -3,6 +3,8 @@ import { ROLE_RESOURCE_TYPE } from "../org/role.js";
|
|
|
3
3
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
4
4
|
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
5
5
|
import { describeDroppedEntry, finishMemberList } from "../access-policy/member-list.js";
|
|
6
|
+
import { currentValidationMode, recordValidations, ValidationFailureError } from "../../engine/validation.js";
|
|
7
|
+
import { rolePermissionLevelError } from "./permission-levels.js";
|
|
6
8
|
function principals(values, type, where, orgRefs, diagnostics) {
|
|
7
9
|
if (values === undefined)
|
|
8
10
|
return undefined;
|
|
@@ -37,7 +39,9 @@ function principals(values, type, where, orgRefs, diagnostics) {
|
|
|
37
39
|
return finishMemberList(where, out, dropped, diagnostics);
|
|
38
40
|
}
|
|
39
41
|
export function rolesToTf(roles, opts) {
|
|
40
|
-
|
|
42
|
+
const invalidRoles = [];
|
|
43
|
+
const blocks = Object.entries(roles ?? {}).map(([key, role]) => {
|
|
44
|
+
const label = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(key), opts.scope);
|
|
41
45
|
const attrs = { object_id: opts.objectId, name: role.name };
|
|
42
46
|
if (role.description !== undefined)
|
|
43
47
|
attrs["description"] = role.description;
|
|
@@ -79,6 +83,24 @@ export function rolesToTf(roles, opts) {
|
|
|
79
83
|
if (serviceAccountIds !== undefined)
|
|
80
84
|
attrs["service_account_ids"] = serviceAccountIds;
|
|
81
85
|
}
|
|
86
|
+
if (role.permissions !== undefined) {
|
|
87
|
+
// A level the group doesn't store as written fails plan in the
|
|
88
|
+
// provider; fail the build first, one finding per role, so a single
|
|
89
|
+
// build names every bad role (edk#2133).
|
|
90
|
+
const invalid = role.permissions.flatMap((permission) => {
|
|
91
|
+
const error = rolePermissionLevelError(permission);
|
|
92
|
+
return error === undefined ? [] : [`${permission.group} ${permission.level}: ${error}`];
|
|
93
|
+
});
|
|
94
|
+
if (invalid.length > 0) {
|
|
95
|
+
invalidRoles.push({
|
|
96
|
+
severity: "fatal",
|
|
97
|
+
address: `${ROLE_RESOURCE_TYPE}.${label}`,
|
|
98
|
+
name: role.name,
|
|
99
|
+
ownerKind: "role",
|
|
100
|
+
message: `roles.${key}.permissions (${opts.ownerRefName}): ${invalid.length === 1 ? "this permission level is" : "these permission levels are"} not valid for the group, so plan would fail: ${invalid.join(" | ")}`,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
82
104
|
if (role.permissions !== undefined)
|
|
83
105
|
attrs["permissions"] = [...role.permissions].sort((a, b) => a.group.localeCompare(b.group)).map((permission) => ({
|
|
84
106
|
group: permission.group,
|
|
@@ -88,8 +110,16 @@ export function rolesToTf(roles, opts) {
|
|
|
88
110
|
return {
|
|
89
111
|
kind: "resource",
|
|
90
112
|
type: ROLE_RESOURCE_TYPE,
|
|
91
|
-
label
|
|
113
|
+
label,
|
|
92
114
|
attrs,
|
|
93
115
|
};
|
|
94
116
|
});
|
|
117
|
+
if (invalidRoles.length > 0) {
|
|
118
|
+
// In a build or pull session the findings are collected with the rest; outside one, fail closed.
|
|
119
|
+
if (currentValidationMode() !== undefined)
|
|
120
|
+
recordValidations(invalidRoles);
|
|
121
|
+
else
|
|
122
|
+
throw new ValidationFailureError(invalidRoles);
|
|
123
|
+
}
|
|
124
|
+
return blocks;
|
|
95
125
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EntityKindModule } from "../../graph/types.js";
|
|
2
|
-
|
|
2
|
+
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "./resource-type.js";
|
|
3
|
+
export { SERVICE_ACCOUNT_RESOURCE_TYPE };
|
|
3
4
|
export declare const SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE = "elementum_service_account_access_policy";
|
|
4
5
|
export declare const serviceAccountModule: EntityKindModule;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NO_CANVAS, NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
|
|
2
2
|
import { GROUP_RESOURCE_TYPE } from "../org/group.js";
|
|
3
|
-
|
|
3
|
+
import { roleServiceAccountMembershipErrors } from "./role-membership-check.js";
|
|
4
|
+
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "./resource-type.js";
|
|
5
|
+
export { SERVICE_ACCOUNT_RESOURCE_TYPE };
|
|
4
6
|
export const SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE = "elementum_service_account_access_policy";
|
|
5
7
|
export const serviceAccountModule = {
|
|
6
8
|
kind: "service-account",
|
|
@@ -19,6 +21,7 @@ export const serviceAccountModule = {
|
|
|
19
21
|
lifecycle: NO_LIFECYCLE,
|
|
20
22
|
canvas: NO_CANVAS,
|
|
21
23
|
catalog: NO_CATALOG,
|
|
24
|
+
buildChecks: { validateBuiltRoots: roleServiceAccountMembershipErrors },
|
|
22
25
|
roundtrip: {
|
|
23
26
|
referenceAliases: [],
|
|
24
27
|
// Provider set attributes (edk#2437): order carries no meaning.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BuildCheckFailure, BuiltRootSource } from "../../graph/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A role's `service_account_ids` and a service account's `role_ids` write the
|
|
4
|
+
* same membership. When both lists are set and disagree about one role and
|
|
5
|
+
* one account, each apply undoes the other forever (edk#2159), so the build
|
|
6
|
+
* stops and names both. Agreement is left alone: on one app both sides naming
|
|
7
|
+
* each other is a dependency cycle that tofu already reports.
|
|
8
|
+
*
|
|
9
|
+
* A role list never holds a raw id (build resolves every account it names), but
|
|
10
|
+
* an account's `role_ids` can (pull keeps another app's role as
|
|
11
|
+
* `unsafePlatformId`), and this check can't tell which role a raw id is. So a
|
|
12
|
+
* role that lists the account is not reported against an account list holding
|
|
13
|
+
* raw ids, and an account list made only of raw ids never names a role here:
|
|
14
|
+
* it is not compared, including when the role's list leaves that account out.
|
|
15
|
+
*
|
|
16
|
+
* The fix-it text says which property to leave off, chosen by which side
|
|
17
|
+
* claims the membership. Leaving a list off is not the same as `[]` (#2124),
|
|
18
|
+
* and naming the membership on both sides is a dependency cycle on one app.
|
|
19
|
+
*/
|
|
20
|
+
export declare function roleServiceAccountMembershipErrors(roots: readonly BuiltRootSource[]): BuildCheckFailure[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isTfExpr } from "../../engine/tf/index.js";
|
|
2
|
+
import { ROLE_RESOURCE_TYPE, roleModule } from "../org/role.js";
|
|
3
|
+
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "./resource-type.js";
|
|
4
|
+
function sideOf(block, attr, name) {
|
|
5
|
+
const list = block.attrs[attr];
|
|
6
|
+
if (!Array.isArray(list) || block.label === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
const members = new Set();
|
|
9
|
+
let hasRawId = false;
|
|
10
|
+
for (const item of list) {
|
|
11
|
+
if (isTfExpr(item) && item.$expr === "resource-attr")
|
|
12
|
+
members.add(`${item.type}.${item.label}`);
|
|
13
|
+
else if (typeof item === "string")
|
|
14
|
+
hasRawId = true;
|
|
15
|
+
}
|
|
16
|
+
return { address: `${block.type}.${block.label}`, name, members, hasRawId };
|
|
17
|
+
}
|
|
18
|
+
function accountName(block) {
|
|
19
|
+
const first = block.attrs["first_name"];
|
|
20
|
+
const last = block.attrs["last_name"];
|
|
21
|
+
return typeof first === "string" && typeof last === "string" ? `${first} ${last}`.trim() : block.label ?? "?";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A role's `service_account_ids` and a service account's `role_ids` write the
|
|
25
|
+
* same membership. When both lists are set and disagree about one role and
|
|
26
|
+
* one account, each apply undoes the other forever (edk#2159), so the build
|
|
27
|
+
* stops and names both. Agreement is left alone: on one app both sides naming
|
|
28
|
+
* each other is a dependency cycle that tofu already reports.
|
|
29
|
+
*
|
|
30
|
+
* A role list never holds a raw id (build resolves every account it names), but
|
|
31
|
+
* an account's `role_ids` can (pull keeps another app's role as
|
|
32
|
+
* `unsafePlatformId`), and this check can't tell which role a raw id is. So a
|
|
33
|
+
* role that lists the account is not reported against an account list holding
|
|
34
|
+
* raw ids, and an account list made only of raw ids never names a role here:
|
|
35
|
+
* it is not compared, including when the role's list leaves that account out.
|
|
36
|
+
*
|
|
37
|
+
* The fix-it text says which property to leave off, chosen by which side
|
|
38
|
+
* claims the membership. Leaving a list off is not the same as `[]` (#2124),
|
|
39
|
+
* and naming the membership on both sides is a dependency cycle on one app.
|
|
40
|
+
*/
|
|
41
|
+
export function roleServiceAccountMembershipErrors(roots) {
|
|
42
|
+
const blocks = roots.flatMap((root) => root.blocks);
|
|
43
|
+
const roles = blocks
|
|
44
|
+
.filter((block) => block.kind === "resource" && block.type === ROLE_RESOURCE_TYPE)
|
|
45
|
+
.map((block) => sideOf(block, "service_account_ids", typeof block.attrs["name"] === "string" ? block.attrs["name"] : block.label ?? "?"))
|
|
46
|
+
.filter((side) => side !== undefined);
|
|
47
|
+
if (roles.length === 0)
|
|
48
|
+
return [];
|
|
49
|
+
const accounts = blocks
|
|
50
|
+
.filter((block) => block.kind === "resource" && block.type === SERVICE_ACCOUNT_RESOURCE_TYPE)
|
|
51
|
+
.map((block) => sideOf(block, "role_ids", accountName(block)))
|
|
52
|
+
.filter((side) => side !== undefined);
|
|
53
|
+
const errors = [];
|
|
54
|
+
for (const role of roles) {
|
|
55
|
+
for (const account of accounts) {
|
|
56
|
+
const roleSays = role.members.has(account.address);
|
|
57
|
+
const accountSays = account.members.has(role.address);
|
|
58
|
+
if (roleSays === accountSays)
|
|
59
|
+
continue;
|
|
60
|
+
if (roleSays && account.hasRawId)
|
|
61
|
+
continue;
|
|
62
|
+
const disagreement = roleSays
|
|
63
|
+
? `the role's serviceAccounts list names the account, but the account's roles list leaves the role out`
|
|
64
|
+
: `the account's roles list names the role, but the role's serviceAccounts list leaves the account out`;
|
|
65
|
+
const fix = roleSays
|
|
66
|
+
? `If the account should hold the role, leave the roles property off the account (not roles: []) so the role's serviceAccounts decides. ` +
|
|
67
|
+
`If it shouldn't, take the account out of the role's serviceAccounts.`
|
|
68
|
+
: `If the account should hold the role, leave the serviceAccounts property off the role (not serviceAccounts: []) so the account's roles decide. ` +
|
|
69
|
+
`If it shouldn't, take the role out of the account's roles.`;
|
|
70
|
+
errors.push({
|
|
71
|
+
address: role.address,
|
|
72
|
+
name: role.name,
|
|
73
|
+
ownerKind: roleModule.kind,
|
|
74
|
+
message: `role "${role.name}" (${role.address}) and service account "${account.name}" (${account.address}) both set whether the account holds the role, and they disagree: ${disagreement}. ` +
|
|
75
|
+
`Each apply would undo the other. ${fix}`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return errors;
|
|
80
|
+
}
|
|
@@ -5,6 +5,21 @@ import type { FromTfContext } from "../../engine/pull/context.js";
|
|
|
5
5
|
* recursive pull's namespace -> refName and display-name -> refName maps.
|
|
6
6
|
*/
|
|
7
7
|
export declare function dataAspectDisplayName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Workspace catalog key for an app or element the export named by its
|
|
10
|
+
* namespace. Prefer the workspace namespace map (case-insensitive via
|
|
11
|
+
* {@link lookupNamespaceMap}). A known namespace that is not on disk must
|
|
12
|
+
* not fall through to the display-name map — that map is not unique and
|
|
13
|
+
* can silently bind another app (#2667 B1). Without a namespace, a unique
|
|
14
|
+
* display-name or sanitized terraform-label match is still allowed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function catalogRefForAspectOwner(input: {
|
|
17
|
+
readonly namespace?: string;
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
readonly tfLabel?: string;
|
|
20
|
+
readonly refNamesByNamespace?: ReadonlyMap<string, string>;
|
|
21
|
+
readonly refNamesByName?: ReadonlyMap<string, string>;
|
|
22
|
+
}): string | undefined;
|
|
8
23
|
/** Resolve the stable pulled catalog key for the same foreign lookup. */
|
|
9
24
|
export declare function dataAspectRefName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string, displayName?: string): string | undefined;
|
|
10
25
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lookupNamespaceMap } from "../../engine/pull/authored-root.js";
|
|
1
2
|
import { sanitizeName, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Resolve a foreign app/element data lookup to its display name. Ref-only
|
|
@@ -25,6 +26,41 @@ export function dataAspectDisplayName(ctx, kind, label) {
|
|
|
25
26
|
const names = kind === "app" ? ctx.foreignAppRefNames : kind === "element" ? ctx.foreignElementRefNames : undefined;
|
|
26
27
|
return [...(names?.entries() ?? [])].find(([, candidateRefName]) => candidateRefName === refName)?.[0];
|
|
27
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Workspace catalog key for an app or element the export named by its
|
|
31
|
+
* namespace. Prefer the workspace namespace map (case-insensitive via
|
|
32
|
+
* {@link lookupNamespaceMap}). A known namespace that is not on disk must
|
|
33
|
+
* not fall through to the display-name map — that map is not unique and
|
|
34
|
+
* can silently bind another app (#2667 B1). Without a namespace, a unique
|
|
35
|
+
* display-name or sanitized terraform-label match is still allowed.
|
|
36
|
+
*/
|
|
37
|
+
export function catalogRefForAspectOwner(input) {
|
|
38
|
+
const namespace = input.namespace !== undefined && input.namespace !== "" ? input.namespace : undefined;
|
|
39
|
+
if (namespace !== undefined) {
|
|
40
|
+
if (input.refNamesByNamespace !== undefined) {
|
|
41
|
+
const byNamespace = lookupNamespaceMap(input.refNamesByNamespace, namespace);
|
|
42
|
+
if (byNamespace !== undefined)
|
|
43
|
+
return byNamespace;
|
|
44
|
+
throw new Error(`table source namespace ${JSON.stringify(namespace)} is not in this workspace; ` +
|
|
45
|
+
"pull that app or element first so the table can use its refName " +
|
|
46
|
+
"(refusing a display-name guess that could bind a different app)");
|
|
47
|
+
}
|
|
48
|
+
return tfLabelToTsLabel(sanitizeName(namespace));
|
|
49
|
+
}
|
|
50
|
+
if (input.name !== undefined && input.name !== "") {
|
|
51
|
+
const byName = input.refNamesByName?.get(input.name);
|
|
52
|
+
if (byName !== undefined)
|
|
53
|
+
return byName;
|
|
54
|
+
}
|
|
55
|
+
if (input.tfLabel !== undefined && input.refNamesByNamespace !== undefined) {
|
|
56
|
+
const refs = [...new Set([...input.refNamesByNamespace.entries()]
|
|
57
|
+
.filter(([candidate]) => sanitizeName(candidate) === input.tfLabel)
|
|
58
|
+
.map(([, refName]) => refName))];
|
|
59
|
+
if (refs.length === 1)
|
|
60
|
+
return refs[0];
|
|
61
|
+
}
|
|
62
|
+
return input.tfLabel === undefined ? undefined : tfLabelToTsLabel(input.tfLabel);
|
|
63
|
+
}
|
|
28
64
|
/** Resolve the stable pulled catalog key for the same foreign lookup. */
|
|
29
65
|
export function dataAspectRefName(ctx, kind, label, displayName) {
|
|
30
66
|
if (kind === "task")
|
|
@@ -253,6 +253,8 @@ export type RefExpr =
|
|
|
253
253
|
| {
|
|
254
254
|
kind: "triggerRef";
|
|
255
255
|
path: readonly string[];
|
|
256
|
+
/** Pulled record trigger ref name the trigger output type doesn't declare (#2643). */
|
|
257
|
+
undeclaredHead?: true;
|
|
256
258
|
}
|
|
257
259
|
/** Reference to a forEach loop variable: `ctx.actions.<forEachTask>.<path...>`. */
|
|
258
260
|
| {
|