@elementumai/edk 0.9.18 → 0.9.19
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 +8 -3
- package/dist-sdk/src/catalog/factories.d.ts +11 -0
- package/dist-sdk/src/catalog/factories.js +6 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.d.ts +39 -1
- package/dist-sdk/src/catalog/org.js +460 -50
- package/dist-sdk/src/catalog/types.d.ts +10 -0
- package/dist-sdk/src/catalog/types.js +2 -0
- package/dist-sdk/src/engine/pull/ref-only.js +54 -20
- package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
- package/dist-sdk/src/engine/pull/result-output.js +1 -1
- package/dist-sdk/src/engine/tf/expr.js +38 -13
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +2 -0
- package/dist-sdk/src/engine/tf/labels.js +4 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
- package/dist-sdk/src/engine/tf/parse.js +105 -6
- package/dist-sdk/src/engine/workspace/loader.js +49 -12
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/app/build.d.ts +10 -0
- package/dist-sdk/src/entities/app/build.js +0 -13
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -3
- 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 +13 -0
- package/dist-sdk/src/entities/app/to-tf.js +2 -0
- package/dist-sdk/src/entities/automation/build.d.ts +2 -1
- package/dist-sdk/src/entities/automation/build.js +27 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +6 -0
- package/dist-sdk/src/entities/automation/from-tf.js +135 -26
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +2 -0
- package/dist-sdk/src/entities/automation/module.js +56 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
- package/dist-sdk/src/entities/automation/system-ref-name.js +44 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +15 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +38 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -2
- package/dist-sdk/src/entities/automation/to-tf.js +158 -84
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.js +33 -17
- package/dist-sdk/src/entities/chart/module.js +3 -1
- package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
- package/dist-sdk/src/entities/chart/printer.js +26 -16
- package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
- package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
- package/dist-sdk/src/entities/chart/to-tf.js +12 -10
- package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +51 -2
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
- package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
- package/dist-sdk/src/entities/element/build.d.ts +8 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +6 -2
- package/dist-sdk/src/entities/element/index.d.ts +1 -0
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +2 -0
- package/dist-sdk/src/entities/element/to-tf.js +12 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/field/from-tf.js +11 -0
- package/dist-sdk/src/entities/field/to-tf.js +13 -9
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +19 -10
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +23 -2
- package/dist-sdk/src/entities/shared/filters/index.js +24 -1
- package/dist-sdk/src/entities/shared/filters/print.js +14 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +23 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +46 -14
- package/dist-sdk/src/entities/shared/filters/types.d.ts +13 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
- package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
- package/dist-sdk/src/entities/skill/access-policy.js +101 -0
- package/dist-sdk/src/entities/skill/build.d.ts +3 -0
- package/dist-sdk/src/entities/skill/build.js +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +21 -0
- package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill/from-tf.js +4 -9
- package/dist-sdk/src/entities/skill/index.d.ts +2 -0
- package/dist-sdk/src/entities/skill/index.js +1 -0
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill/to-tf.js +5 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +224 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +36 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +288 -0
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +121 -0
- package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/view/from-tf.js +42 -7
- package/dist-sdk/src/entities/view/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/view/to-tf.js +30 -1
- package/dist-sdk/src/entities/view/types.js +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +2 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +25 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +43 -0
- package/dist-sdk/src/graph/index.js +9 -0
- package/dist-sdk/src/graph/types.d.ts +78 -0
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SYSTEM_FIELD_KEY_BY_TAG, systemFieldTag } from "../../core/system-fields.js";
|
|
1
2
|
import { isTfExpr, tfLabelToTsLabel } from "../tf/index.js";
|
|
2
3
|
function singleLineComment(value) {
|
|
3
4
|
return value.replace(/\*\//g, "* /").replace(/\s+/g, " ").trim();
|
|
@@ -39,7 +40,7 @@ function parseRoot(payload) {
|
|
|
39
40
|
const wireRefName = stringAt(obj, "refName");
|
|
40
41
|
if ((kind !== "app" && kind !== "element" && kind !== "table" && kind !== "task") || name === undefined || wireRefName === undefined)
|
|
41
42
|
return undefined;
|
|
42
|
-
const
|
|
43
|
+
const pending = [];
|
|
43
44
|
for (const rawField of Array.isArray(obj.fields) ? obj.fields : []) {
|
|
44
45
|
const field = record(rawField);
|
|
45
46
|
if (field === undefined)
|
|
@@ -51,14 +52,43 @@ function parseRoot(payload) {
|
|
|
51
52
|
continue;
|
|
52
53
|
const tags = Array.isArray(field.tags) && field.tags.every((v) => typeof v === "string") ? field.tags : undefined;
|
|
53
54
|
const options = Array.isArray(field.options) && field.options.every((v) => typeof v === "string") ? field.options : undefined;
|
|
55
|
+
const systemTag = systemFieldTag({ tags });
|
|
56
|
+
const systemKey = systemTag === undefined ? undefined : SYSTEM_FIELD_KEY_BY_TAG[systemTag];
|
|
57
|
+
pending.push({ fieldName, fieldRefName, fieldType, tags, options, systemKey, systemTag });
|
|
58
|
+
}
|
|
59
|
+
// Owning apps print TITLE into systemFields.title and a custom "Title"
|
|
60
|
+
// into fields.title. Ref-only catalogs flatten both into one bag, so the
|
|
61
|
+
// tagged system field must keep the canonical key. The owner does not
|
|
62
|
+
// suffix the custom field (title2), so inventing that key would not match
|
|
63
|
+
// catalog.fields; omit the custom field and diagnose instead.
|
|
64
|
+
const systemKeyByCanonical = new Map();
|
|
65
|
+
for (const field of pending) {
|
|
66
|
+
if (field.systemKey === undefined || field.systemTag === undefined || systemKeyByCanonical.has(field.systemKey))
|
|
67
|
+
continue;
|
|
68
|
+
systemKeyByCanonical.set(field.systemKey, field.systemTag);
|
|
69
|
+
}
|
|
70
|
+
const fields = [];
|
|
71
|
+
const diagnostics = [];
|
|
72
|
+
const emittedSystemKeys = new Set();
|
|
73
|
+
for (const field of pending) {
|
|
74
|
+
const key = field.systemKey ?? tfLabelToTsLabel(field.fieldRefName);
|
|
75
|
+
if (field.systemKey !== undefined) {
|
|
76
|
+
if (emittedSystemKeys.has(field.systemKey))
|
|
77
|
+
continue;
|
|
78
|
+
emittedSystemKeys.add(field.systemKey);
|
|
79
|
+
}
|
|
80
|
+
else if (systemKeyByCanonical.has(key)) {
|
|
81
|
+
diagnostics.push(`ref-only ${kind} "${name}": custom field "${field.fieldName}" (wire ref "${field.fieldRefName}") collides with the ${systemKeyByCanonical.get(key)} system field key "${key}"; omitted it rather than inventing a catalog key the owning app would not use`);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
54
84
|
fields.push({
|
|
55
85
|
__kind: "field",
|
|
56
|
-
refName:
|
|
57
|
-
name: fieldName,
|
|
86
|
+
refName: key,
|
|
87
|
+
name: field.fieldName,
|
|
58
88
|
parent: tfLabelToTsLabel(wireRefName),
|
|
59
|
-
fieldType,
|
|
60
|
-
...(tags !== undefined && tags.length > 0 ? { tags } : {}),
|
|
61
|
-
...(options !== undefined && options.length > 0 ? { options } : {}),
|
|
89
|
+
fieldType: field.fieldType,
|
|
90
|
+
...(field.tags !== undefined && field.tags.length > 0 ? { tags: field.tags } : {}),
|
|
91
|
+
...(field.options !== undefined && field.options.length > 0 ? { options: field.options } : {}),
|
|
62
92
|
});
|
|
63
93
|
}
|
|
64
94
|
const columns = (Array.isArray(obj.columns) ? obj.columns : []).flatMap((rawColumn) => {
|
|
@@ -124,15 +154,18 @@ function parseRoot(payload) {
|
|
|
124
154
|
: [{ refName: tfLabelToTsLabel(skillRefName), name: skillName }];
|
|
125
155
|
});
|
|
126
156
|
return {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
157
|
+
root: {
|
|
158
|
+
kind,
|
|
159
|
+
refName: tfLabelToTsLabel(wireRefName),
|
|
160
|
+
name,
|
|
161
|
+
...(stringAt(obj, "namespace") !== undefined ? { namespace: stringAt(obj, "namespace") } : {}),
|
|
162
|
+
fields,
|
|
163
|
+
columns,
|
|
164
|
+
datamines,
|
|
165
|
+
automations,
|
|
166
|
+
skills,
|
|
167
|
+
},
|
|
168
|
+
diagnostics,
|
|
136
169
|
};
|
|
137
170
|
}
|
|
138
171
|
function parseUnresolved(payload) {
|
|
@@ -164,13 +197,14 @@ export function readRefOnlyMetadata(doc) {
|
|
|
164
197
|
if (typeof value !== "string")
|
|
165
198
|
continue;
|
|
166
199
|
if (key.startsWith("edk_ref_only_")) {
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
200
|
+
const parsed = parseRoot(value);
|
|
201
|
+
if (parsed !== undefined) {
|
|
202
|
+
diagnostics.push(...parsed.diagnostics);
|
|
203
|
+
if ((parsed.root.kind === "app" || parsed.root.kind === "element") && (parsed.root.namespace === undefined || parsed.root.namespace === "")) {
|
|
204
|
+
diagnostics.push(`ref-only ${parsed.root.kind} "${parsed.root.name}" is missing its required namespace; catalog materialization was skipped`);
|
|
171
205
|
}
|
|
172
206
|
else {
|
|
173
|
-
roots.push(root);
|
|
207
|
+
roots.push(parsed.root);
|
|
174
208
|
}
|
|
175
209
|
}
|
|
176
210
|
}
|
|
@@ -13,6 +13,8 @@ export interface ManagedResultVerdict {
|
|
|
13
13
|
readonly failed?: boolean;
|
|
14
14
|
readonly skipped?: number;
|
|
15
15
|
readonly gaps?: number;
|
|
16
|
+
/** Live configuration left out of source on request (e.g. `--skip-unsupported-layouts`). */
|
|
17
|
+
readonly omitted?: number;
|
|
16
18
|
}
|
|
17
19
|
export declare function managedResultStatus(operation: string, verdict: ManagedResultVerdict): ManagedResultStatus;
|
|
18
20
|
/**
|
|
@@ -2,7 +2,7 @@ import { flushRepeatedTechnicalLogs, machineReadableLogsEnabled, renderTextEffec
|
|
|
2
2
|
export function managedResultStatus(operation, verdict) {
|
|
3
3
|
const outcome = verdict.failed === true
|
|
4
4
|
? "failure"
|
|
5
|
-
: (verdict.skipped ?? 0) > 0 || (verdict.gaps ?? 0) > 0
|
|
5
|
+
: (verdict.skipped ?? 0) > 0 || (verdict.gaps ?? 0) > 0 || (verdict.omitted ?? 0) > 0
|
|
6
6
|
? "warning"
|
|
7
7
|
: "success";
|
|
8
8
|
return { operation, outcome };
|
|
@@ -98,6 +98,17 @@ function skipQuotedString(s, openQuote) {
|
|
|
98
98
|
}
|
|
99
99
|
throw new TfExprError("unterminated string literal", s);
|
|
100
100
|
}
|
|
101
|
+
function hasLiveInterpolation(rawInner) {
|
|
102
|
+
for (let i = 0; i < rawInner.length; i++) {
|
|
103
|
+
if (rawInner.startsWith("$${", i) || rawInner.startsWith("%%{", i)) {
|
|
104
|
+
i += 2;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (rawInner.startsWith("${", i) || rawInner.startsWith("%{", i))
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
101
112
|
/** Parse the inside of a ${...} interpolation. */
|
|
102
113
|
export function parseExpression(src, options = {}) {
|
|
103
114
|
const p = new Parser(src, options);
|
|
@@ -236,7 +247,7 @@ class Parser {
|
|
|
236
247
|
if (c === "[")
|
|
237
248
|
return this.parseArrayLiteral();
|
|
238
249
|
if (c === '"')
|
|
239
|
-
return this.
|
|
250
|
+
return this.parseQuotedValue();
|
|
240
251
|
if (c === "-" || (c !== undefined && c >= "0" && c <= "9"))
|
|
241
252
|
return this.parseNumber();
|
|
242
253
|
const identStart = this.pos;
|
|
@@ -296,6 +307,26 @@ class Parser {
|
|
|
296
307
|
}
|
|
297
308
|
return Number(m[0]);
|
|
298
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* A payload value may be a template — the renderer writes one for a
|
|
312
|
+
* reference embedded in jsonencoded text (`"variable|${…id}"`). It parses
|
|
313
|
+
* to a template expression, never to literal text.
|
|
314
|
+
*/
|
|
315
|
+
parseQuotedValue() {
|
|
316
|
+
const start = this.pos;
|
|
317
|
+
const end = skipQuotedString(this.src, this.pos);
|
|
318
|
+
const rawInner = this.src.slice(this.pos + 1, end - 1);
|
|
319
|
+
if (!hasLiveInterpolation(rawInner))
|
|
320
|
+
return this.parseQuotedString();
|
|
321
|
+
this.pos = end;
|
|
322
|
+
try {
|
|
323
|
+
return parseStringValue(decodeStringEscapes(rawInner, this.src), this.options);
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
this.pos = start;
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
299
330
|
parseQuotedString() {
|
|
300
331
|
if (this.peek() !== '"') {
|
|
301
332
|
throw new TfExprError(`expected string at "${this.rest().slice(0, 20)}"`, this.src);
|
|
@@ -303,18 +334,12 @@ class Parser {
|
|
|
303
334
|
const end = skipQuotedString(this.src, this.pos);
|
|
304
335
|
const rawInner = this.src.slice(this.pos + 1, end - 1);
|
|
305
336
|
this.pos = end;
|
|
306
|
-
// Live interpolations
|
|
307
|
-
//
|
|
308
|
-
//
|
|
309
|
-
//
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
i += 2;
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
if (rawInner.startsWith("${", i) || rawInner.startsWith("%{", i)) {
|
|
316
|
-
throw new TfExprError("interpolation inside an expression string is outside the supported grammar", this.src);
|
|
317
|
-
}
|
|
337
|
+
// Live interpolations in keys and indexes (a dynamic index key, a
|
|
338
|
+
// computed object key) are OUTSIDE the closed grammar — silently
|
|
339
|
+
// literalizing them would change semantics while the structural
|
|
340
|
+
// round-trip stayed green. Loud instead.
|
|
341
|
+
if (hasLiveInterpolation(rawInner)) {
|
|
342
|
+
throw new TfExprError("interpolation inside an expression string is outside the supported grammar", this.src);
|
|
318
343
|
}
|
|
319
344
|
// Every string crossing the parse boundary follows the same rule:
|
|
320
345
|
// standard escapes decode, then template escapes decode (render is the
|
|
@@ -7,6 +7,6 @@ export type { PathSeg, TfBlock, TfBlockKind, TfDocument, TfExpr, TfValue } from
|
|
|
7
7
|
export { expr, isTfExpr } from "./model.js";
|
|
8
8
|
export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./escape.js";
|
|
9
9
|
export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
|
|
10
|
-
export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, TfParseError, type BackendHclInspection, } from "./parse.js";
|
|
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, isUuid, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, tfLabelToTsLabel, tsLabelToTfLabel, type ChildResourceScope, } from "./labels.js";
|
|
12
|
+
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, tfLabelToTsLabel, tsLabelToTfLabel, type ChildResourceScope, } from "./labels.js";
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
export { expr, isTfExpr } from "./model.js";
|
|
7
7
|
export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./escape.js";
|
|
8
8
|
export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
|
|
9
|
-
export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, TfParseError, } from "./parse.js";
|
|
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, isUuid, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, tfLabelToTsLabel, tsLabelToTfLabel, } from "./labels.js";
|
|
11
|
+
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, tfLabelToTsLabel, tsLabelToTfLabel, } from "./labels.js";
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* "WaaS Request", "DLUpdate" → "DL Update", "A2ATranscript" → "A2A Transcript").
|
|
13
13
|
*/
|
|
14
14
|
export declare function splitCamelCase(name: string): string;
|
|
15
|
+
/** Whether `value` is in the domain {@link tfLabelToTsLabel} accepts. */
|
|
16
|
+
export declare function isTfLabel(value: string): boolean;
|
|
15
17
|
export declare function tfLabelToTsLabel(tfLabel: string): string;
|
|
16
18
|
export declare function tsLabelToTfLabel(tsLabel: string): string;
|
|
17
19
|
/**
|
|
@@ -56,6 +56,10 @@ export function splitCamelCase(name) {
|
|
|
56
56
|
*/
|
|
57
57
|
/** The alphabet ei's SanitizeName emits — the bijection's valid domain. */
|
|
58
58
|
const TF_LABEL_RE = /^[a-z_][a-z0-9_]*$/;
|
|
59
|
+
/** Whether `value` is in the domain {@link tfLabelToTsLabel} accepts. */
|
|
60
|
+
export function isTfLabel(value) {
|
|
61
|
+
return TF_LABEL_RE.test(value);
|
|
62
|
+
}
|
|
59
63
|
export function tfLabelToTsLabel(tfLabel) {
|
|
60
64
|
if (!TF_LABEL_RE.test(tfLabel)) {
|
|
61
65
|
// Outside [a-z0-9_] the conversion is not a bijection (an uppercase
|
|
@@ -12,6 +12,20 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { TfDocument } from "./model.js";
|
|
14
14
|
type Hcl2JsonParser = (filename: string, contents: string) => Promise<Record<string, unknown>>;
|
|
15
|
+
export interface Hcl2JsonInput {
|
|
16
|
+
readonly filename: string;
|
|
17
|
+
readonly contents: string;
|
|
18
|
+
}
|
|
19
|
+
/** Converts many documents in one call; a per-document failure is an Error entry. */
|
|
20
|
+
export type Hcl2JsonBatchParser = (inputs: readonly Hcl2JsonInput[]) => Promise<ReadonlyArray<Record<string, unknown> | Error>>;
|
|
21
|
+
/** Test seam: forget cached conversions. */
|
|
22
|
+
export declare function clearHclParseCache(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Install a batch converter (the CLI's native bridge). Batch reads prefer it;
|
|
25
|
+
* when it throws, parsing falls back to the WASM parser for the rest of the
|
|
26
|
+
* process.
|
|
27
|
+
*/
|
|
28
|
+
export declare function installHcl2JsonBatchRuntime(parser: Hcl2JsonBatchParser | undefined): void;
|
|
15
29
|
/**
|
|
16
30
|
* The Bun executable installs an embedded-WASM parser before loading the CLI.
|
|
17
31
|
* Node/SDK consumers keep using the upstream package directly.
|
|
@@ -40,6 +54,11 @@ export interface BackendHclInspection {
|
|
|
40
54
|
*/
|
|
41
55
|
export declare function inspectBackendHcl(text: string): Promise<BackendHclInspection>;
|
|
42
56
|
export declare function parseHcl(text: string): Promise<TfDocument>;
|
|
57
|
+
/**
|
|
58
|
+
* Parse many HCL texts, in order. A document that fails yields its
|
|
59
|
+
* TfParseError in place so one bad file never hides the others.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseHclDocuments(texts: readonly string[]): Promise<Array<TfDocument | TfParseError>>;
|
|
43
62
|
/**
|
|
44
63
|
* Refuse to parse text whose integer literals exceed Number.MAX_SAFE_INTEGER —
|
|
45
64
|
* hcl2json would round them silently (verified: 2^53+1 → 2^53).
|
|
@@ -13,8 +13,45 @@
|
|
|
13
13
|
import { decodeTemplateEscapes } from "./escape.js";
|
|
14
14
|
import { parseStringValue, TfExprError } from "./expr.js";
|
|
15
15
|
let runtimeParser;
|
|
16
|
+
let batchParser;
|
|
16
17
|
let packageParser;
|
|
17
18
|
const HCL2JSON_PACKAGE = `@cdktf/${"hcl2json"}`;
|
|
19
|
+
/**
|
|
20
|
+
* Converted hcl2json output keyed by source text. Pull normalizers re-read the
|
|
21
|
+
* whole export directory several times; unchanged files reuse the conversion.
|
|
22
|
+
* Safe to share because conversion below never mutates the raw objects.
|
|
23
|
+
*/
|
|
24
|
+
const rawCache = new Map();
|
|
25
|
+
const RAW_CACHE_MAX_TEXT_CHARS = 64 * 1024 * 1024;
|
|
26
|
+
let rawCacheTextChars = 0;
|
|
27
|
+
function cacheRaw(text, raw) {
|
|
28
|
+
if (text.length > RAW_CACHE_MAX_TEXT_CHARS)
|
|
29
|
+
return;
|
|
30
|
+
if (rawCache.has(text))
|
|
31
|
+
return;
|
|
32
|
+
while (rawCacheTextChars + text.length > RAW_CACHE_MAX_TEXT_CHARS) {
|
|
33
|
+
const oldest = rawCache.keys().next();
|
|
34
|
+
if (oldest.done === true)
|
|
35
|
+
break;
|
|
36
|
+
rawCache.delete(oldest.value);
|
|
37
|
+
rawCacheTextChars -= oldest.value.length;
|
|
38
|
+
}
|
|
39
|
+
rawCache.set(text, raw);
|
|
40
|
+
rawCacheTextChars += text.length;
|
|
41
|
+
}
|
|
42
|
+
/** Test seam: forget cached conversions. */
|
|
43
|
+
export function clearHclParseCache() {
|
|
44
|
+
rawCache.clear();
|
|
45
|
+
rawCacheTextChars = 0;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Install a batch converter (the CLI's native bridge). Batch reads prefer it;
|
|
49
|
+
* when it throws, parsing falls back to the WASM parser for the rest of the
|
|
50
|
+
* process.
|
|
51
|
+
*/
|
|
52
|
+
export function installHcl2JsonBatchRuntime(parser) {
|
|
53
|
+
batchParser = parser;
|
|
54
|
+
}
|
|
18
55
|
/**
|
|
19
56
|
* The Bun executable installs an embedded-WASM parser before loading the CLI.
|
|
20
57
|
* Node/SDK consumers keep using the upstream package directly.
|
|
@@ -207,14 +244,76 @@ function hasLiteralBackendValue(body, key) {
|
|
|
207
244
|
return typeof value === "string" && value !== "" && !value.startsWith("${");
|
|
208
245
|
}
|
|
209
246
|
export async function parseHcl(text) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
247
|
+
const [result] = await parseHclDocuments([text]);
|
|
248
|
+
if (result instanceof Error)
|
|
249
|
+
throw result;
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Parse many HCL texts, in order. A document that fails yields its
|
|
254
|
+
* TfParseError in place so one bad file never hides the others.
|
|
255
|
+
*/
|
|
256
|
+
export async function parseHclDocuments(texts) {
|
|
257
|
+
const raws = texts.map((text) => {
|
|
258
|
+
try {
|
|
259
|
+
assertNoUnsafeIntegers(text);
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
return e instanceof TfParseError ? e : new TfParseError(String(e));
|
|
263
|
+
}
|
|
264
|
+
return rawCache.get(text);
|
|
265
|
+
});
|
|
266
|
+
const pending = texts.flatMap((text, index) => (raws[index] === undefined ? [{ text, index }] : []));
|
|
267
|
+
if (pending.length > 0) {
|
|
268
|
+
const converted = await convertWithHcl2Json(pending.map(({ text }) => text));
|
|
269
|
+
pending.forEach(({ text, index }, i) => {
|
|
270
|
+
const raw = converted[i];
|
|
271
|
+
if (raw instanceof Error) {
|
|
272
|
+
raws[index] = new TfParseError(`HCL parse failed: ${raw.message}`);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
cacheRaw(text, raw);
|
|
276
|
+
raws[index] = raw;
|
|
277
|
+
});
|
|
214
278
|
}
|
|
215
|
-
|
|
216
|
-
|
|
279
|
+
return raws.map((raw) => {
|
|
280
|
+
if (raw instanceof TfParseError)
|
|
281
|
+
return raw;
|
|
282
|
+
try {
|
|
283
|
+
return documentFromHcl2Json(raw);
|
|
284
|
+
}
|
|
285
|
+
catch (e) {
|
|
286
|
+
if (e instanceof TfParseError)
|
|
287
|
+
return e;
|
|
288
|
+
throw e;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
async function convertWithHcl2Json(texts) {
|
|
293
|
+
const inputs = texts.map((contents) => ({ filename: "edk-parse.tf", contents }));
|
|
294
|
+
if (batchParser !== undefined) {
|
|
295
|
+
try {
|
|
296
|
+
const results = await batchParser(inputs);
|
|
297
|
+
if (results.length === inputs.length)
|
|
298
|
+
return results;
|
|
299
|
+
throw new Error(`batch HCL parser returned ${results.length} results for ${inputs.length} documents`);
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
batchParser = undefined;
|
|
303
|
+
}
|
|
217
304
|
}
|
|
305
|
+
const results = [];
|
|
306
|
+
for (const input of inputs) {
|
|
307
|
+
try {
|
|
308
|
+
results.push(await parseWithHcl2Json(input.filename, input.contents));
|
|
309
|
+
}
|
|
310
|
+
catch (e) {
|
|
311
|
+
results.push(e instanceof Error ? e : new Error(String(e)));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return results;
|
|
315
|
+
}
|
|
316
|
+
function documentFromHcl2Json(raw) {
|
|
218
317
|
const blocks = [];
|
|
219
318
|
for (const key of Object.keys(raw)) {
|
|
220
319
|
if (!KNOWN_TOP_LEVEL.has(key)) {
|
|
@@ -211,7 +211,11 @@ function registerHooksOnce() {
|
|
|
211
211
|
}
|
|
212
212
|
const resolved = nextResolveOrTsSibling(specifier, context, nextResolve, parentURL);
|
|
213
213
|
if (resolved.url.startsWith("file:")) {
|
|
214
|
-
const
|
|
214
|
+
const resolvedPath = fileURLToPath(resolved.url.split("?")[0]);
|
|
215
|
+
const resolvedRoot = owningRoot(resolvedPath);
|
|
216
|
+
if (resolvedRoot !== undefined && context.conditions?.includes("require") && resolvedPath.endsWith(".ts")) {
|
|
217
|
+
return { url: pathToFileURL(generationRequirePath(resolvedPath)).href, format: "module-typescript", shortCircuit: true };
|
|
218
|
+
}
|
|
215
219
|
if (resolvedRoot !== undefined) {
|
|
216
220
|
return { ...resolved, url: stamp(resolved.url, resolvedRoot) };
|
|
217
221
|
}
|
|
@@ -219,6 +223,10 @@ function registerHooksOnce() {
|
|
|
219
223
|
return resolved;
|
|
220
224
|
},
|
|
221
225
|
load(url, context, nextLoad) {
|
|
226
|
+
const requiredPath = url.startsWith("file:") ? realPathOfGenerationRequire(fileURLToPath(url)) : undefined;
|
|
227
|
+
if (requiredPath !== undefined) {
|
|
228
|
+
return { format: "module-typescript", source: readFileSync(requiredPath, "utf8"), shortCircuit: true };
|
|
229
|
+
}
|
|
222
230
|
// Authored source is always ESM. Without this, the module type is
|
|
223
231
|
// decided by whichever `package.json` happens to sit above the
|
|
224
232
|
// workspace — a root missing `"type": "module"` (an older workspace, or
|
|
@@ -265,6 +273,33 @@ function nextResolveOrTsSibling(specifier, context, nextResolve, parentURL) {
|
|
|
265
273
|
}
|
|
266
274
|
return nextResolve(specifier, context);
|
|
267
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* CommonJS `require` (the org barrel's lazy `catalogRequire` getters) caches
|
|
278
|
+
* by file path and drops the generation query, so a stamped URL would still
|
|
279
|
+
* hand every later generation the first module this process required. A
|
|
280
|
+
* per-generation sibling filename makes the cache key unique; the load hook
|
|
281
|
+
* serves the real file's source for it. Relative imports inside the module
|
|
282
|
+
* resolve unchanged because the virtual file shares the real one's directory.
|
|
283
|
+
*/
|
|
284
|
+
const GENERATION_REQUIRE_SUFFIX = /\.__edk_gen_\d+__\.ts$/;
|
|
285
|
+
function generationRequirePath(path) {
|
|
286
|
+
return `${path.slice(0, -".ts".length)}.__edk_gen_${stampGeneration}__.ts`;
|
|
287
|
+
}
|
|
288
|
+
function realPathOfGenerationRequire(path) {
|
|
289
|
+
return GENERATION_REQUIRE_SUFFIX.test(path) ? path.replace(GENERATION_REQUIRE_SUFFIX, ".ts") : undefined;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* CommonJS also memoizes `(parent directory, request) -> filename`, and
|
|
293
|
+
* honors that memo while the filename is still in `require.cache`. Dropping
|
|
294
|
+
* the previous generations' virtual entries forces a fresh resolve.
|
|
295
|
+
*/
|
|
296
|
+
function evictGenerationRequires() {
|
|
297
|
+
const cache = nodeModule.createRequire(import.meta.url).cache;
|
|
298
|
+
for (const key of Object.keys(cache)) {
|
|
299
|
+
if (GENERATION_REQUIRE_SUFFIX.test(key))
|
|
300
|
+
delete cache[key];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
268
303
|
function stamp(url, _root) {
|
|
269
304
|
const separator = url.includes("?") ? "&" : "?";
|
|
270
305
|
return `${url}${separator}${GENERATION_KEY}=${stampGeneration}`;
|
|
@@ -331,18 +366,20 @@ export function createWorkspaceLoader(orgRoot) {
|
|
|
331
366
|
return {
|
|
332
367
|
async import(file) {
|
|
333
368
|
return enqueueImport(async () => {
|
|
334
|
-
generation
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
try {
|
|
338
|
-
const url = pathToFileURL(resolve(file)).href;
|
|
339
|
-
// Set inside the serialized section so overlapping imports cannot
|
|
340
|
-
// see each other's file.
|
|
341
|
-
return await withImportingFile(resolve(file), () => nativeImport(`${url}?${GENERATION_KEY}=${generation}`));
|
|
342
|
-
}
|
|
343
|
-
finally {
|
|
344
|
-
stampGeneration = previous;
|
|
369
|
+
if (generation === undefined) {
|
|
370
|
+
generation = ++nextGeneration;
|
|
371
|
+
evictGenerationRequires();
|
|
345
372
|
}
|
|
373
|
+
// Deliberately left set after the import: the org barrel's lazy
|
|
374
|
+
// `catalogRequire` getters resolve when authored callbacks run, long
|
|
375
|
+
// after the import returned. Resetting would bind those reads to one
|
|
376
|
+
// stale generation for the whole process (a pull's throwaway stub
|
|
377
|
+
// catalog leaked into its own later build that way).
|
|
378
|
+
stampGeneration = generation;
|
|
379
|
+
const url = pathToFileURL(resolve(file)).href;
|
|
380
|
+
// Set inside the serialized section so overlapping imports cannot
|
|
381
|
+
// see each other's file.
|
|
382
|
+
return await withImportingFile(resolve(file), () => nativeImport(`${url}?${GENERATION_KEY}=${generation}`));
|
|
346
383
|
});
|
|
347
384
|
},
|
|
348
385
|
};
|
|
@@ -28,6 +28,8 @@ export interface AccessPolicyOwner {
|
|
|
28
28
|
readonly ownerRefName: string;
|
|
29
29
|
readonly fieldKey: string;
|
|
30
30
|
}>;
|
|
31
|
+
/** Decode a `data.elementum_field.<label>.id` owned by this owner (an unmanaged relationship target). */
|
|
32
|
+
readonly dataField?: (label: string) => RefExpr | undefined;
|
|
31
33
|
}
|
|
32
34
|
export interface NormalizedAccessPolicy {
|
|
33
35
|
readonly filter: Filter<RefExpr, RefExpr>;
|
|
@@ -35,8 +37,16 @@ export interface NormalizedAccessPolicy {
|
|
|
35
37
|
readonly groupIds?: readonly AccessPolicyGroupRef[];
|
|
36
38
|
readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
|
|
37
39
|
}
|
|
40
|
+
export interface FilterFromTfOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Views keep a raw word a word, so a TEXT-wrapped option lookup must say it
|
|
43
|
+
* is an option — otherwise build rewrites the stored wrapper type. Owners
|
|
44
|
+
* that always rebuild a bare label into its lookup leave this off.
|
|
45
|
+
*/
|
|
46
|
+
readonly optionLookupsAreIdentities?: boolean;
|
|
47
|
+
}
|
|
38
48
|
/** Decode one `filter` attribute through the shared exhaustive codec. */
|
|
39
|
-
export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string, ctx?: FromTfContext): Filter<RefExpr, RefExpr>;
|
|
49
|
+
export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string, ctx?: FromTfContext, options?: FilterFromTfOptions): Filter<RefExpr, RefExpr>;
|
|
40
50
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_user", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyUserRef[] | undefined;
|
|
41
51
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_group", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyGroupRef[] | undefined;
|
|
42
52
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_service_account", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyServiceAccountRef[] | undefined;
|
|
@@ -50,6 +50,10 @@ function fieldRef(value, owner, where) {
|
|
|
50
50
|
}
|
|
51
51
|
return { kind: "unresolved", uuid: value, hint: "field" };
|
|
52
52
|
}
|
|
53
|
+
const dataLabel = owner.dataField === undefined ? undefined : dataRefLabel(value, "elementum_field");
|
|
54
|
+
const dataField = dataLabel === undefined ? undefined : owner.dataField?.(dataLabel);
|
|
55
|
+
if (dataField !== undefined)
|
|
56
|
+
return dataField;
|
|
53
57
|
throw new EntityTfError(`${where}: field reference cannot be reconstructed`);
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
@@ -76,12 +80,13 @@ function picklistOptionLabel(value, owner) {
|
|
|
76
80
|
: undefined;
|
|
77
81
|
}
|
|
78
82
|
/** Decode one `filter` attribute through the shared exhaustive codec. */
|
|
79
|
-
export function filterFromTf(value, owner, where, ctx) {
|
|
83
|
+
export function filterFromTf(value, owner, where, ctx, options) {
|
|
80
84
|
try {
|
|
81
85
|
return deserializeFilterFromTf(value, {
|
|
82
86
|
field: (fieldValue) => fieldRef(fieldValue, owner, where),
|
|
83
87
|
reference: () => { throw new EntityTfError(`${where}: access-policy reference values are not supported`); },
|
|
84
88
|
literal: (literal) => picklistOptionLabel(literal, owner) ?? stageName(literal, owner, ctx) ?? literal,
|
|
89
|
+
...(options?.optionLookupsAreIdentities === true && { optionLookupsAreIdentities: true }),
|
|
85
90
|
});
|
|
86
91
|
}
|
|
87
92
|
catch (error) {
|
|
@@ -63,6 +63,17 @@ export interface FilterToTfContext extends Omit<AccessPolicyToTfContext, "orgRef
|
|
|
63
63
|
* Explicit UUID selections retain their identity regardless of this flag.
|
|
64
64
|
*/
|
|
65
65
|
readonly resolvePicklistLiterals?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a filter field owned by another aspect (a relationship filter on
|
|
68
|
+
* the related record's field). Returning undefined keeps the owner-scoped
|
|
69
|
+
* mapping.
|
|
70
|
+
*/
|
|
71
|
+
readonly foreignField?: (token: {
|
|
72
|
+
readonly refName: string;
|
|
73
|
+
readonly parent: string;
|
|
74
|
+
readonly fieldType?: string;
|
|
75
|
+
readonly name?: string;
|
|
76
|
+
}, where: string) => TfValue | undefined;
|
|
66
77
|
}
|
|
67
78
|
export interface AccessPolicyToTfResult {
|
|
68
79
|
readonly block: TfBlock;
|
|
@@ -29,6 +29,12 @@ function isFieldToken(v) {
|
|
|
29
29
|
}
|
|
30
30
|
function fieldValueToTf(token, where, ctx) {
|
|
31
31
|
const refName = token.refName ?? "";
|
|
32
|
+
const parent = token.parent;
|
|
33
|
+
if (ctx.foreignField !== undefined && parent !== undefined && parent !== (ctx.ownerRefName ?? ctx.appRefName) && parent !== ctx.ownerTfLabel) {
|
|
34
|
+
const foreign = ctx.foreignField({ ...token, refName, parent }, where);
|
|
35
|
+
if (foreign !== undefined)
|
|
36
|
+
return foreign;
|
|
37
|
+
}
|
|
32
38
|
const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope, ctx.fieldAddresses);
|
|
33
39
|
if (value === undefined) {
|
|
34
40
|
throw new EntityTfError(`${where}: field token "${refName}" has no terraform field resource mapping`);
|
|
@@ -70,11 +76,12 @@ export function filterToTf(f, where, ctx) {
|
|
|
70
76
|
return fieldValueToTf(field, where, ctx);
|
|
71
77
|
},
|
|
72
78
|
reference: () => { throw new EntityTfError(`${where}: access-policy filters do not support reference values`); },
|
|
73
|
-
literal: (value, field,
|
|
79
|
+
literal: (value, field, _valueType, isOptionLabel) => {
|
|
74
80
|
if (typeof value === "string") {
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
|
|
81
|
+
// An option selection stays an identity whichever wrapper the platform
|
|
82
|
+
// stored it behind, even on views where raw TEXT picklist labels
|
|
83
|
+
// intentionally stay literal (rather than IDs).
|
|
84
|
+
if (isOptionLabel && isFieldToken(field)) {
|
|
78
85
|
if (field.options?.includes(value)) {
|
|
79
86
|
const ownerRefName = ctx.ownerRefName ?? ctx.appRefName;
|
|
80
87
|
const sameOwner = (typeof field.parent === "string" && (field.parent === ctx.ownerTfLabel || field.parent === ownerRefName)) || field.parentNamespace === ctx.ownerTfLabel;
|
|
@@ -16,6 +16,7 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
|
16
16
|
import { automationRunTargetResourceAttr } from "../automation/to-tf.js";
|
|
17
17
|
import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
18
18
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
19
|
+
import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
|
|
19
20
|
import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
|
|
20
21
|
import { TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
21
22
|
function serviceAccountIdValue(token, where, ctx) {
|
|
@@ -100,7 +101,7 @@ function resolveTarget(token, ctx) {
|
|
|
100
101
|
function foreignTargetFieldRefValue(token, refName, target, ctx) {
|
|
101
102
|
const fieldName = token.name ?? refName;
|
|
102
103
|
const ownerLabel = target.foreignTfLabel ?? sanitizeName(target.refName);
|
|
103
|
-
const fieldLabel =
|
|
104
|
+
const fieldLabel = foreignFieldDataLabel(target.kind, ownerLabel, fieldName);
|
|
104
105
|
ctx.foreignFieldRef("elementum_field", fieldLabel, target.value, fieldName);
|
|
105
106
|
return expr.dataAttr("elementum_field", fieldLabel, ["id"]);
|
|
106
107
|
}
|