@elementumai/edk 0.9.20 → 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.
- package/README.md +19 -7
- package/dist-sdk/src/catalog/factories.d.ts +10 -2
- package/dist-sdk/src/catalog/factories.js +10 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -2
- package/dist-sdk/src/core/triggers/on-demand.js +7 -0
- package/dist-sdk/src/core/types/app.d.ts +2 -2
- package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
- package/dist-sdk/src/engine/coverage-gaps.js +156 -0
- package/dist-sdk/src/engine/ei/run.d.ts +21 -1
- package/dist-sdk/src/engine/ei/run.js +89 -2
- package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
- package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
- package/dist-sdk/src/engine/pull/context.d.ts +68 -6
- package/dist-sdk/src/engine/pull/context.js +40 -1
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
- package/dist-sdk/src/engine/pull/result-output.js +27 -1
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -5
- package/dist-sdk/src/engine/tf/labels.js +45 -3
- package/dist-sdk/src/engine/tf/parse.js +3 -2
- package/dist-sdk/src/engine/validation.d.ts +5 -0
- package/dist-sdk/src/engine/validation.js +12 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
- package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +42 -19
- package/dist-sdk/src/entities/agent/from-tf.js +11 -3
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.js +14 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.js +11 -5
- package/dist-sdk/src/entities/agent-tool/module.js +3 -0
- package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
- package/dist-sdk/src/entities/app/auto-share.js +49 -0
- package/dist-sdk/src/entities/app/build.d.ts +17 -3
- package/dist-sdk/src/entities/app/build.js +56 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -0
- package/dist-sdk/src/entities/app/index.d.ts +2 -1
- package/dist-sdk/src/entities/app/index.js +1 -8
- package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/app/to-tf.js +21 -2
- package/dist-sdk/src/entities/automation/build.d.ts +10 -2
- package/dist-sdk/src/entities/automation/build.js +104 -17
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +156 -19
- package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
- package/dist-sdk/src/entities/automation/from-tf.js +366 -86
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +3 -0
- package/dist-sdk/src/entities/automation/module.js +70 -7
- package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
- package/dist-sdk/src/entities/automation/script-code.js +23 -5
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
- package/dist-sdk/src/entities/automation/tasks.js +48 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
- package/dist-sdk/src/entities/automation/to-tf.js +606 -62
- package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
- package/dist-sdk/src/entities/automation/types.d.ts +9 -0
- package/dist-sdk/src/entities/automation/types.js +19 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/data-lookup/module.js +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
- package/dist-sdk/src/entities/element/build.d.ts +3 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +8 -14
- package/dist-sdk/src/entities/field/build.d.ts +3 -2
- package/dist-sdk/src/entities/field/calc.d.ts +7 -7
- package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/from-tf.js +205 -48
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/options.js +6 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/to-tf.js +7 -1
- package/dist-sdk/src/entities/field/types.d.ts +2 -0
- package/dist-sdk/src/entities/field/types.js +27 -0
- package/dist-sdk/src/entities/role/from-tf.js +3 -3
- package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/role/to-tf.js +12 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
- package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/index.js +5 -0
- package/dist-sdk/src/entities/shared/filters/print.js +7 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
- package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
- package/dist-sdk/src/entities/shared/ref.js +5 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/access-policy.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
- package/dist-sdk/src/entities/skill/from-tf.js +4 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
- package/dist-sdk/src/entities/skill-tool/module.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
- package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
- package/dist-sdk/src/entities/task/build.d.ts +8 -0
- package/dist-sdk/src/entities/task/build.js +10 -1
- package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/task/from-tf.js +7 -2
- package/dist-sdk/src/entities/task/module.js +2 -2
- package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
- package/dist-sdk/src/entities/task/to-tf.js +28 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -1
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
- package/dist-sdk/src/entities/view/to-tf.js +19 -8
- package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
- package/dist-sdk/src/entities/visual-flow/build.js +9 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +7 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +1 -0
- package/dist-sdk/src/graph/types.d.ts +29 -3
- package/package.json +7 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog-ref lookups that printers can import without loading the kind graph.
|
|
3
|
+
*
|
|
4
|
+
* Skill and agent modules import their printers, and the kind graph imports
|
|
5
|
+
* those modules. The printers must not import `system-field-state`, which
|
|
6
|
+
* imports the graph: that cycle leaves a kind module undefined while
|
|
7
|
+
* `DATA_FACET_MODULES` is built.
|
|
8
|
+
*/
|
|
9
|
+
/** Prefer the authored catalog ref when state only knows the terraform label. */
|
|
10
|
+
export declare function catalogRefForStateName(stateRefName: string, authoredByNamespace: ReadonlyMap<string, string>): string;
|
|
11
|
+
/**
|
|
12
|
+
* Printers emit `catalog.<ref>`. Field-ref identities stay on the terraform
|
|
13
|
+
* label so system-field recovery still matches the export. Map that label
|
|
14
|
+
* through the namespace index only at the emit site (#1427).
|
|
15
|
+
*/
|
|
16
|
+
export declare function catalogRefForFieldOwner(ownerRefName: string, appNamespaces: ReadonlyMap<string, string> | undefined, elementNamespaces: ReadonlyMap<string, string> | undefined): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog-ref lookups that printers can import without loading the kind graph.
|
|
3
|
+
*
|
|
4
|
+
* Skill and agent modules import their printers, and the kind graph imports
|
|
5
|
+
* those modules. The printers must not import `system-field-state`, which
|
|
6
|
+
* imports the graph: that cycle leaves a kind module undefined while
|
|
7
|
+
* `DATA_FACET_MODULES` is built.
|
|
8
|
+
*/
|
|
9
|
+
/** Prefer the authored catalog ref when state only knows the terraform label. */
|
|
10
|
+
export function catalogRefForStateName(stateRefName, authoredByNamespace) {
|
|
11
|
+
return authoredByNamespace.get(stateRefName) ?? stateRefName;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Printers emit `catalog.<ref>`. Field-ref identities stay on the terraform
|
|
15
|
+
* label so system-field recovery still matches the export. Map that label
|
|
16
|
+
* through the namespace index only at the emit site (#1427).
|
|
17
|
+
*/
|
|
18
|
+
export function catalogRefForFieldOwner(ownerRefName, appNamespaces, elementNamespaces) {
|
|
19
|
+
if (appNamespaces?.has(ownerRefName))
|
|
20
|
+
return catalogRefForStateName(ownerRefName, appNamespaces);
|
|
21
|
+
if (elementNamespaces?.has(ownerRefName))
|
|
22
|
+
return catalogRefForStateName(ownerRefName, elementNamespaces);
|
|
23
|
+
return ownerRefName;
|
|
24
|
+
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The shared EXTRACTION toolkit every entity's `from-tf` module uses: the
|
|
3
|
-
* context the pull orchestrators thread through, plus generic TfValue
|
|
4
|
-
* inspectors. Entity-agnostic by definition — nothing in here may name a
|
|
5
|
-
* resource type. (The emission-side twin is src/engine/build/context.ts.)
|
|
6
|
-
*/
|
|
7
1
|
import { type TfValue } from "../tf/index.js";
|
|
8
2
|
/** A `data-attr` reference recorded on a data block in the same stream. */
|
|
9
3
|
export interface DataRef {
|
|
@@ -61,6 +55,20 @@ export interface FromTfContext {
|
|
|
61
55
|
readonly foreignAppRefNamespaces?: ReadonlyMap<string, string>;
|
|
62
56
|
readonly foreignElementRefNamespaces?: ReadonlyMap<string, string>;
|
|
63
57
|
readonly foreignTaskRefNamespaces?: ReadonlyMap<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* The identity a reference to the stream root itself is authored as, for a
|
|
60
|
+
* stream without import ids (clone's `--no-imports` export, edk#1437): a
|
|
61
|
+
* dynamic Dropdown sourced from its own app resolves to this root and its
|
|
62
|
+
* fields instead of a raw platform id. Clone passes the clone's identity so
|
|
63
|
+
* the reference is re-pointed at the clone. Undefined: self references
|
|
64
|
+
* resolve only through import ids, as before.
|
|
65
|
+
*/
|
|
66
|
+
readonly selfAspectRef?: {
|
|
67
|
+
readonly __kind: "app" | "element" | "task";
|
|
68
|
+
readonly refName: string;
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly namespace?: string;
|
|
71
|
+
};
|
|
64
72
|
/** `data.<field-type>.<label>` → generated ref-only catalog member. */
|
|
65
73
|
readonly foreignFieldRefsByDataAddress?: ReadonlyMap<string, {
|
|
66
74
|
readonly ownerRefName: string;
|
|
@@ -82,6 +90,13 @@ export interface FromTfContext {
|
|
|
82
90
|
* only the FIRST same-name procedure under a CloudLink actually owns.
|
|
83
91
|
*/
|
|
84
92
|
readonly procedureKeysByDiscriminator?: ReadonlyMap<string, string>;
|
|
93
|
+
/**
|
|
94
|
+
* Group display name → the `org.groups` key the already-pulled org.ts
|
|
95
|
+
* assigned it. Two groups whose names sanitize to the same key get
|
|
96
|
+
* suffixed keys there (`ops`, `ops_1`); the export label alone can't tell
|
|
97
|
+
* which one a reference means (edk#1412).
|
|
98
|
+
*/
|
|
99
|
+
readonly groupKeysByName?: ReadonlyMap<string, string>;
|
|
85
100
|
/**
|
|
86
101
|
* Foreign app/element display names this stream saw referenced (currently:
|
|
87
102
|
* a RELATION field's `related_object_id` as a `data.elementum_app`/
|
|
@@ -125,8 +140,55 @@ export interface FromTfContext {
|
|
|
125
140
|
* `field/from-tf.ts`'s `implemented` check for the motivating case.
|
|
126
141
|
*/
|
|
127
142
|
readonly skipped: string[];
|
|
143
|
+
/**
|
|
144
|
+
* Authoring blockers: live configuration that authored source cannot
|
|
145
|
+
* reproduce, where printing what pull CAN reconstruct would make the next
|
|
146
|
+
* apply change or replace it (e.g. a replace-forcing part of a dynamic
|
|
147
|
+
* Dropdown that pull cannot rebuild). Extraction records them and carries
|
|
148
|
+
* on; a caller that writes the affected source refuses
|
|
149
|
+
* (`assertAuthorable` in stream-root.ts), while a caller that does not
|
|
150
|
+
* author it may proceed. Report through {@link reportAuthoringBlocker}.
|
|
151
|
+
*/
|
|
152
|
+
readonly authoringBlockers?: AuthoringBlocker[];
|
|
128
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Live configuration authored source cannot reproduce unchanged. Only its
|
|
156
|
+
* identity and what to do about it, never a live value.
|
|
157
|
+
*/
|
|
158
|
+
export interface AuthoringBlocker {
|
|
159
|
+
/** Address (`type.label`) of the resource that holds the configuration. */
|
|
160
|
+
readonly address: string;
|
|
161
|
+
/** One line naming the resource and what pull cannot reproduce. */
|
|
162
|
+
readonly description: string;
|
|
163
|
+
/** What the user does about it. Blockers that share a remedy list it once. */
|
|
164
|
+
readonly remedy: string;
|
|
165
|
+
/**
|
|
166
|
+
* The own-file child kind (e.g. `"automation"`) whose file authors the
|
|
167
|
+
* resource; absent when the stream root's own file authors it. Lets a
|
|
168
|
+
* caller that writes only some files refuse only for those.
|
|
169
|
+
*/
|
|
170
|
+
readonly ownFileKind?: string;
|
|
171
|
+
}
|
|
172
|
+
/** The pull-abort message for one or more authoring blockers. */
|
|
173
|
+
export declare function authoringBlockedMessage(blockers: readonly AuthoringBlocker[]): string;
|
|
174
|
+
/**
|
|
175
|
+
* Record an authoring blocker. Without a sink (a caller outside the stream
|
|
176
|
+
* pipeline) it throws, so a blocker is never silently dropped.
|
|
177
|
+
*/
|
|
178
|
+
export declare function reportAuthoringBlocker(ctx: Pick<FromTfContext, "authoringBlockers">, blocker: AuthoringBlocker): void;
|
|
179
|
+
/**
|
|
180
|
+
* An own-file child whose owner reference does not name the stream root being
|
|
181
|
+
* pulled. Export never produces one, and skipping it would drop a live,
|
|
182
|
+
* possibly adopted resource from source (edk#1484).
|
|
183
|
+
*/
|
|
184
|
+
export declare function ownerMismatchBlocker(address: string, reason: string, ownFileKind: string): AuthoringBlocker;
|
|
129
185
|
/** `data.<type>.<label>.id` → the label; undefined for any other shape. */
|
|
186
|
+
/**
|
|
187
|
+
* The `org.groups` key for a group a pulled reference names: the key org.ts
|
|
188
|
+
* assigned that group by name when known, else the export label's key
|
|
189
|
+
* (correct whenever no two group names sanitize to the same key).
|
|
190
|
+
*/
|
|
191
|
+
export declare function groupCatalogKey(ctx: Pick<FromTfContext, "groupKeysByName">, label: string, name: string): string;
|
|
130
192
|
export declare function dataRefLabel(v: TfValue | undefined, type: string): string | undefined;
|
|
131
193
|
/** `<type>.<label>.id` → the label; undefined for any other shape. */
|
|
132
194
|
export declare function resourceRefLabel(v: TfValue | undefined, type: string): string | undefined;
|
|
@@ -4,8 +4,47 @@
|
|
|
4
4
|
* inspectors. Entity-agnostic by definition — nothing in here may name a
|
|
5
5
|
* resource type. (The emission-side twin is src/engine/build/context.ts.)
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { EntityTfError } from "../entity.js";
|
|
8
|
+
import { isTfExpr, tfLabelToTsLabel } from "../tf/index.js";
|
|
9
|
+
/** The pull-abort message for one or more authoring blockers. */
|
|
10
|
+
export function authoringBlockedMessage(blockers) {
|
|
11
|
+
const remedies = [...new Set(blockers.map((blocker) => blocker.remedy))];
|
|
12
|
+
return ("Pull aborted: authored source cannot reproduce this live configuration, " +
|
|
13
|
+
"and printing the rest would change it on the next apply:\n" +
|
|
14
|
+
blockers.map((blocker) => ` - ${blocker.description}`).join("\n") +
|
|
15
|
+
remedies.map((remedy) => `\n${remedy}`).join(""));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Record an authoring blocker. Without a sink (a caller outside the stream
|
|
19
|
+
* pipeline) it throws, so a blocker is never silently dropped.
|
|
20
|
+
*/
|
|
21
|
+
export function reportAuthoringBlocker(ctx, blocker) {
|
|
22
|
+
if (ctx.authoringBlockers === undefined)
|
|
23
|
+
throw new EntityTfError(authoringBlockedMessage([blocker]));
|
|
24
|
+
ctx.authoringBlockers.push(blocker);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* An own-file child whose owner reference does not name the stream root being
|
|
28
|
+
* pulled. Export never produces one, and skipping it would drop a live,
|
|
29
|
+
* possibly adopted resource from source (edk#1484).
|
|
30
|
+
*/
|
|
31
|
+
export function ownerMismatchBlocker(address, reason, ownFileKind) {
|
|
32
|
+
return {
|
|
33
|
+
address,
|
|
34
|
+
description: `${reason}, so pull cannot write it and leaving it out would let the next plan destroy it.`,
|
|
35
|
+
remedy: "The export carries resources that do not belong to the app being pulled. Pull again; if it persists, report it to the EDK maintainers.",
|
|
36
|
+
ownFileKind,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
8
39
|
/** `data.<type>.<label>.id` → the label; undefined for any other shape. */
|
|
40
|
+
/**
|
|
41
|
+
* The `org.groups` key for a group a pulled reference names: the key org.ts
|
|
42
|
+
* assigned that group by name when known, else the export label's key
|
|
43
|
+
* (correct whenever no two group names sanitize to the same key).
|
|
44
|
+
*/
|
|
45
|
+
export function groupCatalogKey(ctx, label, name) {
|
|
46
|
+
return ctx.groupKeysByName?.get(name) ?? tfLabelToTsLabel(label);
|
|
47
|
+
}
|
|
9
48
|
export function dataRefLabel(v, type) {
|
|
10
49
|
if (v === undefined || !isTfExpr(v) || v.$expr !== "data-attr" || v.type !== type)
|
|
11
50
|
return undefined;
|
|
@@ -14,3 +14,11 @@ export declare function procedureDiscriminator(cloudLinkName: string, name: stri
|
|
|
14
14
|
* same-name overload to disambiguate.
|
|
15
15
|
*/
|
|
16
16
|
export declare function loadProcedureCatalogKeys(orgRoot: string): Promise<ReadonlyMap<string, string>>;
|
|
17
|
+
/**
|
|
18
|
+
* Group display name → the `org.groups` key the already-pulled
|
|
19
|
+
* `<orgRoot>/org.ts` assigned it. org.ts suffixes groups whose names sanitize
|
|
20
|
+
* to the same key (`ops`, `ops_1`), which a pulled reference's export label
|
|
21
|
+
* cannot reproduce (edk#1412). Empty when org.ts is missing or unloadable;
|
|
22
|
+
* callers then fall back to the label's key.
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadGroupCatalogKeys(orgRoot: string): Promise<ReadonlyMap<string, string>>;
|
|
@@ -67,3 +67,31 @@ export async function loadProcedureCatalogKeys(orgRoot) {
|
|
|
67
67
|
}
|
|
68
68
|
return map;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Group display name → the `org.groups` key the already-pulled
|
|
72
|
+
* `<orgRoot>/org.ts` assigned it. org.ts suffixes groups whose names sanitize
|
|
73
|
+
* to the same key (`ops`, `ops_1`), which a pulled reference's export label
|
|
74
|
+
* cannot reproduce (edk#1412). Empty when org.ts is missing or unloadable;
|
|
75
|
+
* callers then fall back to the label's key.
|
|
76
|
+
*/
|
|
77
|
+
export async function loadGroupCatalogKeys(orgRoot) {
|
|
78
|
+
const map = new Map();
|
|
79
|
+
const orgPath = join(orgRoot, "org.ts");
|
|
80
|
+
if (!existsSync(orgPath))
|
|
81
|
+
return map;
|
|
82
|
+
let mod;
|
|
83
|
+
try {
|
|
84
|
+
mod = (await createWorkspaceLoader(orgRoot).import(orgPath));
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return map;
|
|
88
|
+
}
|
|
89
|
+
for (const [key, group] of Object.entries(mod.org?.groups ?? {})) {
|
|
90
|
+
// Two groups with the exact same name: the first key wins. A by-name
|
|
91
|
+
// `data.elementum_group` lookup can't tell them apart either, so both
|
|
92
|
+
// references would bind to the same platform group regardless.
|
|
93
|
+
if (typeof group?.name === "string" && !map.has(group.name))
|
|
94
|
+
map.set(group.name, key);
|
|
95
|
+
}
|
|
96
|
+
return map;
|
|
97
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { coverageGapEvents, coverageGapMessages, coverageGapResultFields, describeGapKinds, strictCoverageExitCode, strictCoverageFailureMessage } from "../coverage-gaps.js";
|
|
1
2
|
import { takePartialReads } from "../ei/run.js";
|
|
2
3
|
import { flushRepeatedTechnicalLogs, machineReadableLogsEnabled, renderTextEffects, writeTechnicalLog, writeUserOutput } from "../progress.js";
|
|
3
4
|
export function managedResultStatus(operation, verdict) {
|
|
@@ -22,12 +23,19 @@ export function writePullResult(result, humanLines, status) {
|
|
|
22
23
|
const detail = partialReadDetail();
|
|
23
24
|
// A partial read means some fields were never read: the pull is incomplete
|
|
24
25
|
// even when everything that was read was written (docs/design/graphql-error-standard.md).
|
|
25
|
-
|
|
26
|
+
// Same gap definition as build/plan: distinct, non-advisory diagnostics.
|
|
27
|
+
const gapEvents = coverageGapEvents(coverageGapMessages(resultDiagnostics(result) ?? []));
|
|
28
|
+
const gapCount = gapEvents.length;
|
|
29
|
+
const effectiveStatus = status !== undefined && status.outcome === "success" && (reads.length > 0 || gapCount > 0)
|
|
26
30
|
? { ...status, outcome: "warning" }
|
|
27
31
|
: status;
|
|
32
|
+
// edk#1473: count the pull's coverage gaps (extract + build diagnostics) in
|
|
33
|
+
// the result and the closing summary instead of leaving them as loose WARNs.
|
|
34
|
+
const gapMessages = resultDiagnostics(result);
|
|
28
35
|
const resultWithStatus = result !== null && typeof result === "object"
|
|
29
36
|
? {
|
|
30
37
|
...result,
|
|
38
|
+
...(gapMessages === undefined ? {} : coverageGapResultFields(gapMessages)),
|
|
31
39
|
partialReads,
|
|
32
40
|
...(detail === "verbose" ? { partialReadDetails: reads } : {}),
|
|
33
41
|
...(reads.length > 0 && "exportComplete" in result ? { exportComplete: false } : {}),
|
|
@@ -35,8 +43,20 @@ export function writePullResult(result, humanLines, status) {
|
|
|
35
43
|
}
|
|
36
44
|
: result;
|
|
37
45
|
status = effectiveStatus;
|
|
46
|
+
// edk#1477: with --strict-coverage, a pull that finished with coverage gaps
|
|
47
|
+
// exits non-zero. A failure keeps its own exit code.
|
|
48
|
+
if (status?.outcome !== "failure") {
|
|
49
|
+
const strictCode = strictCoverageExitCode(0, gapCount);
|
|
50
|
+
if (strictCode !== 0) {
|
|
51
|
+
process.exitCode = strictCode;
|
|
52
|
+
writeTechnicalLog("ERROR", "edk", strictCoverageFailureMessage(`${status?.operation ?? "Pull"}`.toLowerCase(), gapCount));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
38
55
|
if (process.stdout.isTTY === true && !machineReadableLogsEnabled()) {
|
|
39
56
|
const renderedLines = humanLines.flatMap((line) => Array.isArray(line) && line.length === 0 ? [] : [renderPullResultLine(line)]);
|
|
57
|
+
if (gapCount > 0) {
|
|
58
|
+
renderedLines.push(` Coverage gaps: ${gapCount} setting${gapCount === 1 ? " was" : "s were"} ${describeGapKinds(gapEvents)} while pulling (see the warnings above)`);
|
|
59
|
+
}
|
|
40
60
|
renderedLines.push(...partialReadLines(reads, detail));
|
|
41
61
|
if (status !== undefined) {
|
|
42
62
|
const message = status.outcome === "success"
|
|
@@ -64,6 +84,12 @@ export function writePullResult(result, humanLines, status) {
|
|
|
64
84
|
}
|
|
65
85
|
process.stdout.write(`${JSON.stringify(resultWithStatus, null, 2)}\n`);
|
|
66
86
|
}
|
|
87
|
+
function resultDiagnostics(result) {
|
|
88
|
+
if (result === null || typeof result !== "object")
|
|
89
|
+
return undefined;
|
|
90
|
+
const diagnostics = result.diagnostics;
|
|
91
|
+
return Array.isArray(diagnostics) ? diagnostics.filter((d) => typeof d === "string") : undefined;
|
|
92
|
+
}
|
|
67
93
|
/**
|
|
68
94
|
* Reports partial reads no pull summary took: exports outside `pull` (clone,
|
|
69
95
|
* the refresh after apply) and a pull that failed before its summary. Called
|
|
@@ -9,4 +9,4 @@ export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./
|
|
|
9
9
|
export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
|
|
10
10
|
export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, parseHclDocuments, TfParseError, type BackendHclInspection, } from "./parse.js";
|
|
11
11
|
export { renderBlock, renderDocument } from "./render.js";
|
|
12
|
-
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, type ChildResourceScope, } from "./labels.js";
|
|
12
|
+
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, taskResourceLabelPrefix, type ChildResourceScope, type FieldOwnerScope, } from "./labels.js";
|
|
@@ -8,4 +8,4 @@ export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./
|
|
|
8
8
|
export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
|
|
9
9
|
export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, parseHclDocuments, TfParseError, } from "./parse.js";
|
|
10
10
|
export { renderBlock, renderDocument } from "./render.js";
|
|
11
|
-
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, } from "./labels.js";
|
|
11
|
+
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, taskResourceLabelPrefix, } from "./labels.js";
|
|
@@ -35,11 +35,17 @@ export declare function sanitizeName(name: string): string;
|
|
|
35
35
|
export declare function isUuid(value: string): boolean;
|
|
36
36
|
/** Scope for child resource labels under a stream root. */
|
|
37
37
|
export type ChildResourceScope = "app" | "element";
|
|
38
|
+
/** Owner scopes for child labels, including standalone tasks (custom fields only, edk#1464). */
|
|
39
|
+
export type FieldOwnerScope = ChildResourceScope | "task";
|
|
38
40
|
/**
|
|
39
41
|
* Prefix for app-owned child resource labels in a shared `.tf/out/` workspace.
|
|
40
42
|
* Uses the platform namespace (`appTfLabel`), matching ei's `AppResourceName`.
|
|
41
43
|
*/
|
|
42
44
|
export declare function appResourceLabelPrefix(appTfLabel: string): string;
|
|
45
|
+
/** Prefix for standalone-task-owned children (custom fields, edk#1464). */
|
|
46
|
+
export declare function taskResourceLabelPrefix(taskTfLabel: string): string;
|
|
47
|
+
/** Prefix for a child label in the given owner scope. */
|
|
48
|
+
export declare function scopedResourceLabelPrefix(ownerTfLabel: string, scope: FieldOwnerScope): string;
|
|
43
49
|
/** Prefix for element-owned children in a shared `.tf/out/` workspace. */
|
|
44
50
|
export declare function elementResourceLabelPrefix(elementTfLabel: string): string;
|
|
45
51
|
/**
|
|
@@ -67,13 +73,13 @@ export declare function appScopedResourceLabel(appTfLabel: string, childPart: st
|
|
|
67
73
|
* address ei already uses — see `__tests__/tf/labels.test.ts`'s "element-prefixed child labels
|
|
68
74
|
* round-trip" block. Re-pull an existing element (`elementum pull element <ns>`) before your
|
|
69
75
|
* next build/plan if it predates this fix; adoption's rename guard (board item 225,
|
|
70
|
-
* `docs/design/rename-label-identity.md`)
|
|
76
|
+
* `docs/design/rename-label-identity.md`) moves any address that does shift with a `moved` block.
|
|
71
77
|
*/
|
|
72
78
|
export declare function elementScopedResourceLabel(elementTfLabel: string, childPart: string): string;
|
|
73
79
|
/** Emit a scoped child label for the owning stream root kind. */
|
|
74
|
-
export declare function scopedResourceLabel(ownerTfLabel: string, childPart: string, scope:
|
|
80
|
+
export declare function scopedResourceLabel(ownerTfLabel: string, childPart: string, scope: FieldOwnerScope): string;
|
|
75
81
|
/** Strip a scoped child label back to its bare form (no-op when unprefixed). */
|
|
76
|
-
export declare function bareChildResourceLabel(ownerTfLabel: string, scopedLabel: string, scope?:
|
|
82
|
+
export declare function bareChildResourceLabel(ownerTfLabel: string, scopedLabel: string, scope?: FieldOwnerScope): string;
|
|
77
83
|
/**
|
|
78
84
|
* Child part after the owner namespace — bag keys omit the namespace prefix
|
|
79
85
|
* for both apps and elements. Strips `apps_<ns>_`/`elements_<ns>_` then
|
|
@@ -82,7 +88,18 @@ export declare function bareChildResourceLabel(ownerTfLabel: string, scopedLabel
|
|
|
82
88
|
* `startsWith` check is therefore always true for a well-formed label; it is
|
|
83
89
|
* kept only to no-op on unprefixed input.
|
|
84
90
|
*/
|
|
85
|
-
export declare function childPartFromScopedLabel(ownerTfLabel: string, scopedLabel: string, scope:
|
|
91
|
+
export declare function childPartFromScopedLabel(ownerTfLabel: string, scopedLabel: string, scope: FieldOwnerScope): string;
|
|
92
|
+
/**
|
|
93
|
+
* Owner encoded in `apps_<ns>_<ns>_<child>` / `elements_<ns>_<ns>_<child>` /
|
|
94
|
+
* `tasks_<ns>_<ns>_<child>`. The namespace may itself contain underscores, so
|
|
95
|
+
* the owner is the longest prefix that is immediately repeated. The shortest
|
|
96
|
+
* match treats a repeated token inside the namespace as the owner
|
|
97
|
+
* (`apps_foo_foo_foo_foo_status`).
|
|
98
|
+
*/
|
|
99
|
+
export declare function ownerFromScopedChildLabel(scopedLabel: string): {
|
|
100
|
+
readonly scope: FieldOwnerScope;
|
|
101
|
+
readonly ownerTfLabel: string;
|
|
102
|
+
} | undefined;
|
|
86
103
|
/**
|
|
87
104
|
* First 8 alphanumeric characters of `id`, lowercased. ei export's
|
|
88
105
|
* `stableIDSuffix` (cmd/elementum/export/search_table_refs.go) must stay
|
|
@@ -90,4 +107,4 @@ export declare function childPartFromScopedLabel(ownerTfLabel: string, scopedLab
|
|
|
90
107
|
*/
|
|
91
108
|
export declare function stableIdSuffix(id: string): string;
|
|
92
109
|
/** Scoped terraform label → authoring bag key / ref key. */
|
|
93
|
-
export declare function scopedLabelToBagKey(ownerTfLabel: string, scopedLabel: string, scope?:
|
|
110
|
+
export declare function scopedLabelToBagKey(ownerTfLabel: string, scopedLabel: string, scope?: FieldOwnerScope): string;
|
|
@@ -140,6 +140,16 @@ export function isUuid(value) {
|
|
|
140
140
|
export function appResourceLabelPrefix(appTfLabel) {
|
|
141
141
|
return `apps_${appTfLabel}_`;
|
|
142
142
|
}
|
|
143
|
+
/** Prefix for standalone-task-owned children (custom fields, edk#1464). */
|
|
144
|
+
export function taskResourceLabelPrefix(taskTfLabel) {
|
|
145
|
+
return `tasks_${taskTfLabel}_`;
|
|
146
|
+
}
|
|
147
|
+
/** Prefix for a child label in the given owner scope. */
|
|
148
|
+
export function scopedResourceLabelPrefix(ownerTfLabel, scope) {
|
|
149
|
+
return scope === "app" ? appResourceLabelPrefix(ownerTfLabel)
|
|
150
|
+
: scope === "task" ? taskResourceLabelPrefix(ownerTfLabel)
|
|
151
|
+
: elementResourceLabelPrefix(ownerTfLabel);
|
|
152
|
+
}
|
|
143
153
|
/** Prefix for element-owned children in a shared `.tf/out/` workspace. */
|
|
144
154
|
export function elementResourceLabelPrefix(elementTfLabel) {
|
|
145
155
|
return `elements_${elementTfLabel}_`;
|
|
@@ -171,18 +181,19 @@ export function appScopedResourceLabel(appTfLabel, childPart) {
|
|
|
171
181
|
* address ei already uses — see `__tests__/tf/labels.test.ts`'s "element-prefixed child labels
|
|
172
182
|
* round-trip" block. Re-pull an existing element (`elementum pull element <ns>`) before your
|
|
173
183
|
* next build/plan if it predates this fix; adoption's rename guard (board item 225,
|
|
174
|
-
* `docs/design/rename-label-identity.md`)
|
|
184
|
+
* `docs/design/rename-label-identity.md`) moves any address that does shift with a `moved` block.
|
|
175
185
|
*/
|
|
176
186
|
export function elementScopedResourceLabel(elementTfLabel, childPart) {
|
|
177
187
|
return `${elementResourceLabelPrefix(elementTfLabel)}${elementTfLabel}_${childPart}`;
|
|
178
188
|
}
|
|
179
189
|
/** Emit a scoped child label for the owning stream root kind. */
|
|
180
190
|
export function scopedResourceLabel(ownerTfLabel, childPart, scope) {
|
|
181
|
-
|
|
191
|
+
// Same unconditional `<prefix><ns>_<ns>_<child>` doubling for every scope (issue #115).
|
|
192
|
+
return `${scopedResourceLabelPrefix(ownerTfLabel, scope)}${ownerTfLabel}_${childPart}`;
|
|
182
193
|
}
|
|
183
194
|
/** Strip a scoped child label back to its bare form (no-op when unprefixed). */
|
|
184
195
|
export function bareChildResourceLabel(ownerTfLabel, scopedLabel, scope = "app") {
|
|
185
|
-
const prefix =
|
|
196
|
+
const prefix = scopedResourceLabelPrefix(ownerTfLabel, scope);
|
|
186
197
|
return scopedLabel.startsWith(prefix) ? scopedLabel.slice(prefix.length) : scopedLabel;
|
|
187
198
|
}
|
|
188
199
|
/**
|
|
@@ -198,6 +209,37 @@ export function childPartFromScopedLabel(ownerTfLabel, scopedLabel, scope) {
|
|
|
198
209
|
const nsPrefix = `${ownerTfLabel}_`;
|
|
199
210
|
return bare.startsWith(nsPrefix) ? bare.slice(nsPrefix.length) : bare;
|
|
200
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Owner encoded in `apps_<ns>_<ns>_<child>` / `elements_<ns>_<ns>_<child>` /
|
|
214
|
+
* `tasks_<ns>_<ns>_<child>`. The namespace may itself contain underscores, so
|
|
215
|
+
* the owner is the longest prefix that is immediately repeated. The shortest
|
|
216
|
+
* match treats a repeated token inside the namespace as the owner
|
|
217
|
+
* (`apps_foo_foo_foo_foo_status`).
|
|
218
|
+
*/
|
|
219
|
+
export function ownerFromScopedChildLabel(scopedLabel) {
|
|
220
|
+
const scope = scopedLabel.startsWith("elements_")
|
|
221
|
+
? "element"
|
|
222
|
+
: scopedLabel.startsWith("tasks_")
|
|
223
|
+
? "task"
|
|
224
|
+
: scopedLabel.startsWith("apps_")
|
|
225
|
+
? "app"
|
|
226
|
+
: undefined;
|
|
227
|
+
if (scope === undefined)
|
|
228
|
+
return undefined;
|
|
229
|
+
const prefixLen = scope === "element" ? "elements_".length
|
|
230
|
+
: scope === "task" ? "tasks_".length
|
|
231
|
+
: "apps_".length;
|
|
232
|
+
const rest = scopedLabel.slice(prefixLen);
|
|
233
|
+
let match;
|
|
234
|
+
for (let i = 1; i < rest.length; i++) {
|
|
235
|
+
if (rest[i] !== "_")
|
|
236
|
+
continue;
|
|
237
|
+
const owner = rest.slice(0, i);
|
|
238
|
+
if (rest.startsWith(`${owner}_${owner}_`))
|
|
239
|
+
match = { scope, ownerTfLabel: owner };
|
|
240
|
+
}
|
|
241
|
+
return match;
|
|
242
|
+
}
|
|
201
243
|
/**
|
|
202
244
|
* First 8 alphanumeric characters of `id`, lowercased. ei export's
|
|
203
245
|
* `stableIDSuffix` (cmd/elementum/export/search_table_refs.go) must stay
|
|
@@ -471,8 +471,9 @@ function isCredentialVariableContext(ctx) {
|
|
|
471
471
|
/^resource\.elementum_phone_provider\.[^.]+\.twilio(?:\.|$)/.test(ctx);
|
|
472
472
|
}
|
|
473
473
|
function isWriteOnlyApiSecretContext(ctx) {
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
// value_wo/username_wo are the provider's write-only forms (edk#1400).
|
|
475
|
+
return /^resource\.elementum_api_task\.[^.]+\.headers\[\d+\]\.value(?:_wo)?$/.test(ctx) ||
|
|
476
|
+
/^resource\.elementum_api_task\.[^.]+\.basic_auth\.username(?:_wo)?$/.test(ctx);
|
|
476
477
|
}
|
|
477
478
|
/**
|
|
478
479
|
* hcl2json reads `validation { condition = var.x != "" }` as
|
|
@@ -24,6 +24,11 @@ export declare class ValidationFailureError extends Error {
|
|
|
24
24
|
export declare function isValidationFailureError(error: unknown): error is ValidationFailureError;
|
|
25
25
|
export declare function withValidationSession<T>(mode: ValidationMode, run: () => T): T;
|
|
26
26
|
export declare function withValidationSessionAsync<T>(mode: ValidationMode, run: () => Promise<T>): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* A fresh session even inside another one, for a side computation whose
|
|
29
|
+
* findings must not reach the enclosing command's verdict.
|
|
30
|
+
*/
|
|
31
|
+
export declare function withIsolatedValidationSessionAsync<T>(mode: ValidationMode, run: () => Promise<T>): Promise<T>;
|
|
27
32
|
export declare function currentValidationMode(): ValidationMode | undefined;
|
|
28
33
|
export declare function currentValidationScope(): {
|
|
29
34
|
readonly appTfLabel?: string;
|
|
@@ -36,15 +36,25 @@ export function isValidationFailureError(error) {
|
|
|
36
36
|
return false;
|
|
37
37
|
return Array.isArray(error.failures);
|
|
38
38
|
}
|
|
39
|
+
function newSession(mode) {
|
|
40
|
+
return { mode, failures: [], seen: new Set() };
|
|
41
|
+
}
|
|
39
42
|
export function withValidationSession(mode, run) {
|
|
40
43
|
if (storage().getStore() !== undefined)
|
|
41
44
|
return run();
|
|
42
|
-
return storage().run(
|
|
45
|
+
return storage().run(newSession(mode), run);
|
|
43
46
|
}
|
|
44
47
|
export function withValidationSessionAsync(mode, run) {
|
|
45
48
|
if (storage().getStore() !== undefined)
|
|
46
49
|
return run();
|
|
47
|
-
return
|
|
50
|
+
return withIsolatedValidationSessionAsync(mode, run);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A fresh session even inside another one, for a side computation whose
|
|
54
|
+
* findings must not reach the enclosing command's verdict.
|
|
55
|
+
*/
|
|
56
|
+
export function withIsolatedValidationSessionAsync(mode, run) {
|
|
57
|
+
return storage().run(newSession(mode), run);
|
|
48
58
|
}
|
|
49
59
|
export function currentValidationMode() {
|
|
50
60
|
return storage().getStore()?.mode;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* dropped with a diagnostic rather than silently misattributed.
|
|
12
12
|
*/
|
|
13
13
|
import { EntityTfError } from "../../engine/entity.js";
|
|
14
|
-
import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
|
|
14
|
+
import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
|
|
15
15
|
import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedLabelToBagKey, scopedResourceLabel, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
16
16
|
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
17
17
|
import { groupId, userId, } from "./principal.js";
|
|
@@ -143,8 +143,45 @@ function principalListItem(item, dataType, where, ctx, owner) {
|
|
|
143
143
|
}
|
|
144
144
|
return { __kind: "serviceAccount", appRefName, name: value };
|
|
145
145
|
}
|
|
146
|
+
if (dataType === "elementum_group" && ctx.groupKeysByName?.has(value)) {
|
|
147
|
+
return { __kind: "orgPrincipalRef", dataType, label, value, catalogKey: groupCatalogKey(ctx, label, value) };
|
|
148
|
+
}
|
|
146
149
|
return { __kind: "orgPrincipalRef", dataType, label, value };
|
|
147
150
|
}
|
|
151
|
+
// Same-app service accounts export as resource-attr (not data-attr). Match
|
|
152
|
+
// skill/agent/role pull: recover name from the managed SA block.
|
|
153
|
+
if (dataType === "elementum_service_account") {
|
|
154
|
+
const resourceLabel = resourceRefLabel(item, "elementum_service_account");
|
|
155
|
+
if (resourceLabel !== undefined) {
|
|
156
|
+
const account = ctx.resourceByAddress?.(`elementum_service_account.${resourceLabel}`);
|
|
157
|
+
const explicitName = account?.attrs["name"];
|
|
158
|
+
const firstName = account?.attrs["first_name"];
|
|
159
|
+
const lastName = account?.attrs["last_name"];
|
|
160
|
+
const name = typeof explicitName === "string" && explicitName !== ""
|
|
161
|
+
? explicitName
|
|
162
|
+
: typeof firstName === "string" && typeof lastName === "string" ? `${firstName} ${lastName}` : undefined;
|
|
163
|
+
if (name === undefined) {
|
|
164
|
+
ctx.diagnostics.push(`${where}: elementum_service_account.${resourceLabel} has no recoverable display name; dropped`);
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
const appId = account?.attrs["app_id"];
|
|
168
|
+
const appDataLabel = dataRefLabel(appId, "elementum_app");
|
|
169
|
+
const appResourceLabel = resourceRefLabel(appId, "elementum_app");
|
|
170
|
+
const appName = appDataLabel === undefined ? undefined : ctx.dataName("elementum_app", appDataLabel);
|
|
171
|
+
const appRefName = appName !== undefined
|
|
172
|
+
? ctx.foreignAppRefNames?.get(appName)
|
|
173
|
+
: appResourceLabel !== undefined && owner?.scope === "app" && owner.label === appResourceLabel
|
|
174
|
+
? owner.ownerRefName
|
|
175
|
+
: appResourceLabel === undefined
|
|
176
|
+
? undefined
|
|
177
|
+
: ctx.foreignAppRefNamespaces?.get(appResourceLabel);
|
|
178
|
+
if (appRefName === undefined) {
|
|
179
|
+
ctx.diagnostics.push(`${where}: elementum_service_account.${resourceLabel} has no resolvable app_id owner; dropped`);
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
return { __kind: "serviceAccount", appRefName, name };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
148
185
|
if (typeof item === "string") {
|
|
149
186
|
if (dataType === "elementum_user")
|
|
150
187
|
return userId(item);
|
|
@@ -24,6 +24,8 @@ export interface AccessPolicyPrincipalRef<DataType extends PrincipalDataType = P
|
|
|
24
24
|
readonly label: string;
|
|
25
25
|
/** The data block's lookup value: email for a user, name for a group or service account. */
|
|
26
26
|
readonly value: string;
|
|
27
|
+
/** For a group: the `org.groups` key org.ts assigned it, when known (edk#1412). */
|
|
28
|
+
readonly catalogKey?: string;
|
|
27
29
|
}
|
|
28
30
|
export type AccessPolicyUserRef = UserId | RoleUserRef | AccessPolicyPrincipalRef<"elementum_user">;
|
|
29
31
|
export type AccessPolicyGroupRef = GroupId | GroupRef | AccessPolicyPrincipalRef<"elementum_group">;
|
|
@@ -55,6 +55,9 @@ export interface PrintAgentV2Options {
|
|
|
55
55
|
* `catalog.<refName>` instead of the literal stub.
|
|
56
56
|
*/
|
|
57
57
|
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
58
|
+
/** Terraform label → authored catalog ref. Field identities stay on the label. */
|
|
59
|
+
readonly foreignAppRefNamespaces?: ReadonlyMap<string, string>;
|
|
60
|
+
readonly foreignElementRefNamespaces?: ReadonlyMap<string, string>;
|
|
58
61
|
/** Aspect/table display-name pair → typed search-table identity. */
|
|
59
62
|
readonly foreignSearchTableRefsByName?: ReadonlyMap<string, {
|
|
60
63
|
readonly ownerRefName: string;
|