@elementumai/edk 0.8.0-preview.11 → 0.8.2-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +510 -324
- package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
- package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
- package/dist-sdk/src/catalog/factories.d.ts +56 -3
- package/dist-sdk/src/catalog/factories.js +83 -4
- package/dist-sdk/src/catalog/from-authoring.js +19 -2
- package/dist-sdk/src/catalog/index.d.ts +3 -2
- package/dist-sdk/src/catalog/index.js +3 -2
- package/dist-sdk/src/catalog/org.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +134 -50
- package/dist-sdk/src/catalog/render.d.ts +13 -1
- package/dist-sdk/src/catalog/render.js +21 -4
- package/dist-sdk/src/catalog/token.js +18 -0
- package/dist-sdk/src/catalog/types.d.ts +75 -3
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +2 -0
- package/dist-sdk/src/core/system-fields.js +2 -0
- package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
- package/dist-sdk/src/core/types/ai-provider.js +1 -25
- package/dist-sdk/src/core/types/app.d.ts +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +58 -0
- package/dist-sdk/src/engine/build/context.js +11 -1
- package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
- package/dist-sdk/src/engine/build/source-context.js +23 -0
- package/dist-sdk/src/engine/pull/context.d.ts +15 -0
- package/dist-sdk/src/engine/pull/org.d.ts +10 -0
- package/dist-sdk/src/engine/pull/org.js +34 -4
- 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 +54 -0
- package/dist-sdk/src/engine/tf/labels.js +75 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +15 -0
- package/dist-sdk/src/engine/tf/parse.js +162 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
- package/dist-sdk/src/entities/access-policy/build.js +7 -0
- package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
- package/dist-sdk/src/entities/access-policy/filter.js +83 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +66 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +187 -0
- package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
- package/dist-sdk/src/entities/access-policy/module.js +17 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +43 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +164 -0
- package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/types.js +10 -0
- package/dist-sdk/src/entities/agent/build.d.ts +2 -0
- package/dist-sdk/src/entities/agent/build.js +1 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +257 -32
- package/dist-sdk/src/entities/agent/from-tf.d.ts +29 -9
- package/dist-sdk/src/entities/agent/from-tf.js +146 -19
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +14 -4
- package/dist-sdk/src/entities/agent/to-tf.d.ts +46 -1
- package/dist-sdk/src/entities/agent/to-tf.js +160 -14
- package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
- package/dist-sdk/src/entities/agent/tools.js +46 -7
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +64 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.d.ts +4 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.js +14 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.d.ts +40 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +47 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
- package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +176 -30
- package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
- package/dist-sdk/src/entities/agent-tool/types.js +38 -6
- package/dist-sdk/src/entities/app/build.d.ts +91 -13
- package/dist-sdk/src/entities/app/build.js +63 -5
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/from-tf.js +32 -22
- package/dist-sdk/src/entities/app/index.d.ts +4 -1
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/module.js +10 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
- package/dist-sdk/src/entities/app/to-tf.js +45 -4
- package/dist-sdk/src/entities/automation/build.d.ts +57 -13
- package/dist-sdk/src/entities/automation/build.js +62 -42
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +206 -47
- package/dist-sdk/src/entities/automation/filter.d.ts +37 -3
- package/dist-sdk/src/entities/automation/filter.js +54 -3
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
- package/dist-sdk/src/entities/automation/from-tf.js +1344 -222
- package/dist-sdk/src/entities/automation/index.d.ts +4 -0
- package/dist-sdk/src/entities/automation/index.js +4 -0
- package/dist-sdk/src/entities/automation/module.js +29 -32
- package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
- package/dist-sdk/src/entities/automation/operators.js +27 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
- package/dist-sdk/src/entities/automation/script-code.js +272 -5
- package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
- package/dist-sdk/src/entities/automation/tasks.js +83 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
- package/dist-sdk/src/entities/automation/to-tf.js +1291 -230
- package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
- package/dist-sdk/src/entities/automation/types.d.ts +29 -4
- package/dist-sdk/src/entities/automation/types.js +76 -46
- package/dist-sdk/src/entities/element/build.d.ts +44 -13
- package/dist-sdk/src/entities/element/build.js +45 -3
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/from-tf.js +28 -14
- package/dist-sdk/src/entities/element/index.d.ts +4 -1
- package/dist-sdk/src/entities/element/index.js +2 -1
- package/dist-sdk/src/entities/element/module.js +4 -1
- package/dist-sdk/src/entities/element/to-tf.js +26 -3
- package/dist-sdk/src/entities/field/build.d.ts +61 -14
- package/dist-sdk/src/entities/field/build.js +10 -0
- package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
- package/dist-sdk/src/entities/field/from-tf.js +118 -7
- package/dist-sdk/src/entities/field/module.js +3 -2
- package/dist-sdk/src/entities/field/to-tf.d.ts +46 -11
- package/dist-sdk/src/entities/field/to-tf.js +166 -17
- package/dist-sdk/src/entities/field/types.d.ts +26 -0
- package/dist-sdk/src/entities/field/types.js +34 -12
- package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
- package/dist-sdk/src/entities/file-reader/build.js +23 -23
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
- package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
- package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
- package/dist-sdk/src/entities/file-reader/index.js +7 -2
- package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
- package/dist-sdk/src/entities/file-reader/module.js +115 -0
- package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
- package/dist-sdk/src/entities/file-reader/types.js +30 -0
- package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
- package/dist-sdk/src/entities/org/ai-provider.js +46 -0
- package/dist-sdk/src/entities/org/connector.d.ts +8 -1
- package/dist-sdk/src/entities/org/connector.js +12 -14
- package/dist-sdk/src/entities/org/group.js +10 -1
- 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/user.js +10 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +59 -9
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +46 -0
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +128 -11
- package/dist-sdk/src/entities/skill/from-tf.js +4 -3
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/module.js +7 -1
- package/dist-sdk/src/entities/skill/to-tf.d.ts +26 -0
- package/dist-sdk/src/entities/skill/to-tf.js +65 -4
- package/dist-sdk/src/entities/skill/tools.d.ts +37 -8
- package/dist-sdk/src/entities/skill/tools.js +43 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +34 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.js +128 -18
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +13 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +164 -25
- package/dist-sdk/src/entities/skill-tool/types.d.ts +5 -7
- package/dist-sdk/src/entities/skill-tool/types.js +47 -11
- package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
- package/dist-sdk/src/entities/view/from-tf.js +11 -9
- package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/view/to-tf.js +39 -18
- package/dist-sdk/src/entities/view/types.d.ts +1 -1
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
- package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
- package/dist-sdk/src/graph/index.d.ts +8 -0
- package/dist-sdk/src/graph/index.js +13 -9
- package/dist-sdk/src/graph/modules.js +8 -1
- package/dist-sdk/src/graph/types.d.ts +98 -4
- package/package.json +49 -16
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
- package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
|
@@ -6,35 +6,84 @@
|
|
|
6
6
|
* (`skill_id`) — this module never names the skill or app resource types.
|
|
7
7
|
* Mirrors `entities/agent-tool/to-tf.ts`.
|
|
8
8
|
*/
|
|
9
|
-
import { expr, sanitizeName } from "../../engine/tf/index.js";
|
|
9
|
+
import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
10
10
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
11
11
|
import { SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
12
|
-
/** authoring
|
|
13
|
-
function
|
|
12
|
+
/** authoring AspectRef token → its resolved target (self resource ref or foreign data ref). */
|
|
13
|
+
function resolveTarget(token, ctx) {
|
|
14
14
|
const refName = token.refName ?? "";
|
|
15
|
+
const kind = token.__kind === "element" ? "element" : "app";
|
|
16
|
+
if (kind === "app" && refName === ctx.appRefName) {
|
|
17
|
+
return { value: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]), refName, kind, isSelf: true };
|
|
18
|
+
}
|
|
19
|
+
// ei derives foreign-app/foreign-element data labels from the display NAME.
|
|
20
|
+
const name = token.name ?? refName;
|
|
21
|
+
const tfLabel = sanitizeName(name);
|
|
22
|
+
// Board issue #42: an aspect token can be an element, not just an app.
|
|
23
|
+
if (kind === "element") {
|
|
24
|
+
ctx.foreignElementRef(tfLabel, name);
|
|
25
|
+
return { value: expr.dataAttr("elementum_element", tfLabel, ["id"]), refName, kind, isSelf: false, foreignTfLabel: tfLabel };
|
|
26
|
+
}
|
|
27
|
+
ctx.foreignAppRef(tfLabel, name);
|
|
28
|
+
return { value: expr.dataAttr("elementum_app", tfLabel, ["id"]), refName, kind, isSelf: false, foreignTfLabel: tfLabel };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A field belonging to the tool's target aspect, when that target is
|
|
32
|
+
* foreign to the tool's owning app — resolved via a `data.elementum_field`
|
|
33
|
+
* lookup keyed by the TARGET's already-resolved id (never re-derived from
|
|
34
|
+
* the field token's own `parentKind`/`parentName`) + the field's display
|
|
35
|
+
* name. Mirrors `agent-tool/to-tf.ts`'s `foreignTargetFieldRefValue`.
|
|
36
|
+
*/
|
|
37
|
+
function foreignTargetFieldRefValue(token, refName, target, ctx) {
|
|
38
|
+
const fieldName = token.name ?? refName;
|
|
39
|
+
const fieldLabel = `${target.kind}_${target.foreignTfLabel}_${tsLabelToTfLabel(refName)}`;
|
|
40
|
+
ctx.foreignFieldRef("elementum_field", fieldLabel, target.value, fieldName);
|
|
41
|
+
return expr.dataAttr("elementum_field", fieldLabel, ["id"]);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* authoring FieldRef token → the field resource address, resolved against
|
|
45
|
+
* the tool's ACTUAL target aspect, not just the tool's owning app — see
|
|
46
|
+
* `agent-tool/to-tf.ts`'s identical `fieldRefValue` for the full rationale.
|
|
47
|
+
*/
|
|
48
|
+
function fieldRefValue(token, where, ctx, target) {
|
|
49
|
+
const refName = token.refName ?? "";
|
|
50
|
+
if (target !== undefined) {
|
|
51
|
+
// `parentKind` is stamped ALONGSIDE a FOREIGN `parent` by `appCatalog`/
|
|
52
|
+
// `elementCatalog` (see `FieldRef`'s doc comment) — but a field's own
|
|
53
|
+
// `.ref()` on ITS OWN app/element stamps `parent` (as a self-reference)
|
|
54
|
+
// without `parentKind` at all (a real, common shape — see
|
|
55
|
+
// `agent-tool/to-tf.ts`'s identical check for the full rationale), so
|
|
56
|
+
// only a parent naming something OTHER than the tool's owning app is
|
|
57
|
+
// genuinely ambiguous.
|
|
58
|
+
if (token.parent !== undefined && token.parent !== ctx.appRefName && token.parentKind === undefined) {
|
|
59
|
+
ctx.diagnostics.push(`${where}: field "${refName}" has a parent ("${token.parent}") but no parentKind — incomplete foreign-field provenance; dropped`);
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const parent = token.parent ?? ctx.appRefName;
|
|
63
|
+
const parentKind = token.parentKind ?? "app";
|
|
64
|
+
if (parent !== target.refName || parentKind !== target.kind) {
|
|
65
|
+
ctx.diagnostics.push(`${where}: field "${refName}" belongs to ${parentKind} "${parent}", not the tool's target ${target.kind} "${target.refName}" — a tool's fields must belong to its own target aspect; dropped`);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (!target.isSelf)
|
|
69
|
+
return foreignTargetFieldRefValue(token, refName, target, ctx);
|
|
70
|
+
}
|
|
71
|
+
else if (token.parent !== undefined && (token.parent !== ctx.appRefName || token.parentKind === "element")) {
|
|
72
|
+
ctx.diagnostics.push(`${where}: field "${refName}" belongs to "${token.parent}", not this tool's app; dropped`);
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
15
75
|
const authoringType = token.fieldType ?? "";
|
|
16
|
-
|
|
76
|
+
// appTfLabel, not appRefName: fieldRefToTfValue builds a terraform address
|
|
77
|
+
// (resource label prefix / local name), and the two differ whenever an
|
|
78
|
+
// app's authoring ref doesn't match its platform namespace (e.g. a clone).
|
|
79
|
+
// agent-tool/to-tf.ts's equivalent already passes appTfLabel.
|
|
80
|
+
const ref = refName === "" ? undefined : fieldRefToTfValue(authoringType, refName, ctx.appTfLabel);
|
|
17
81
|
if (ref === undefined) {
|
|
18
82
|
ctx.diagnostics.push(`${where}: field token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(authoringType)}); dropped`);
|
|
19
83
|
return undefined;
|
|
20
84
|
}
|
|
21
|
-
if (token.parent !== undefined && token.parent !== ctx.appRefName) {
|
|
22
|
-
ctx.diagnostics.push(`${where}: field token "${refName}" belongs to app "${token.parent}", not this workspace's config — cross-app field refs are not supported on the terraform path yet; dropped`);
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
85
|
return ref;
|
|
26
86
|
}
|
|
27
|
-
/** authoring AspectRef token → target_id value (self resource ref or foreign data ref). */
|
|
28
|
-
function targetIdValue(token, ctx) {
|
|
29
|
-
if ((token.refName ?? "") === ctx.appRefName) {
|
|
30
|
-
return expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]);
|
|
31
|
-
}
|
|
32
|
-
// ei derives foreign-app data labels from the display NAME.
|
|
33
|
-
const name = token.name ?? token.refName ?? "";
|
|
34
|
-
const tfLabel = sanitizeName(name);
|
|
35
|
-
ctx.foreignAppRef(tfLabel, name);
|
|
36
|
-
return expr.dataAttr("elementum_app", tfLabel, ["id"]);
|
|
37
|
-
}
|
|
38
87
|
/**
|
|
39
88
|
* One authored tool entry (`{ createRecord: {...} }`) → its resource block;
|
|
40
89
|
* undefined = degraded with a diagnostic (unimplemented sub-type, missing
|
|
@@ -61,9 +110,7 @@ export function skillToolToTf(entry, ctx) {
|
|
|
61
110
|
return undefined;
|
|
62
111
|
}
|
|
63
112
|
const where = `skill tool "${name}"`;
|
|
64
|
-
|
|
65
|
-
// tools by name alone, unprefixed — confirmed live against `ei apps export`.
|
|
66
|
-
const tfLabel = sanitizeName(name);
|
|
113
|
+
const tfLabel = appScopedResourceLabel(ctx.appTfLabel, `${sanitizeName(name)}${ctx.labelSuffix ?? ""}`);
|
|
67
114
|
const attrs = {
|
|
68
115
|
skill_id: expr.resourceAttr("elementum_agentic_skill", ctx.skillTfLabel, ["id"]),
|
|
69
116
|
app_id: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]),
|
|
@@ -73,11 +120,87 @@ export function skillToolToTf(entry, ctx) {
|
|
|
73
120
|
};
|
|
74
121
|
if (inner.startMessage !== undefined)
|
|
75
122
|
attrs["start_message"] = inner.startMessage;
|
|
123
|
+
if (inner.runAs?.["currentUser"] === true) {
|
|
124
|
+
attrs["run_as"] = "current_user";
|
|
125
|
+
}
|
|
126
|
+
else if (inner.runAs?.["publisher"] === true) {
|
|
127
|
+
attrs["run_as"] = "publisher";
|
|
128
|
+
}
|
|
129
|
+
else if (inner.runAs?.["serviceAccount"] !== undefined) {
|
|
130
|
+
const serviceAccount = inner.runAs["serviceAccount"];
|
|
131
|
+
if (typeof serviceAccount.serviceAccount === "string" && serviceAccount.serviceAccount !== "") {
|
|
132
|
+
attrs["run_as"] = "service_account";
|
|
133
|
+
attrs["service_account_id"] = serviceAccount.serviceAccount;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
ctx.diagnostics.push(`${where}: service-account runAs has no service account id; dropped`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (inner.runAs !== undefined) {
|
|
140
|
+
ctx.diagnostics.push(`${where}: runAs ${JSON.stringify(inner.runAs)} is not supported; dropped`);
|
|
141
|
+
}
|
|
142
|
+
if (typeKey === "automation") {
|
|
143
|
+
const automation = inner.automationId;
|
|
144
|
+
const automationTfLabel = typeof automation?.refName === "string" && automation.refName !== ""
|
|
145
|
+
? tsLabelToTfLabel(automation.refName)
|
|
146
|
+
: typeof automation?.name === "string" && automation.name !== ""
|
|
147
|
+
? sanitizeName(automation.name)
|
|
148
|
+
: undefined;
|
|
149
|
+
if (automationTfLabel === undefined) {
|
|
150
|
+
ctx.diagnostics.push(`${where}: no target automation token; dropped`);
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
if (automation?.parent !== undefined && automation.parent !== ctx.appRefName) {
|
|
154
|
+
ctx.diagnostics.push(`${where}: cross-app automation targets are not supported; dropped`);
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
attrs["automation_id"] = expr.resourceAttr("elementum_workflow_publish", appScopedResourceLabel(ctx.appTfLabel, automationTfLabel), ["id"]);
|
|
158
|
+
if (inner.inputs !== undefined && inner.inputs.length > 0) {
|
|
159
|
+
attrs["inputs"] = inner.inputs.map((input) => ({
|
|
160
|
+
parameter_name: input.parameterName ?? "",
|
|
161
|
+
...(input.displayName !== undefined && input.displayName !== input.parameterName && { display_name: input.displayName }),
|
|
162
|
+
...(input.description !== undefined && input.description !== "" && { description: input.description }),
|
|
163
|
+
required: input.required ?? false,
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
if (inner.outputs !== undefined && inner.outputs.length > 0) {
|
|
167
|
+
attrs["outputs"] = inner.outputs.map((output) => ({
|
|
168
|
+
workflow_property_name: output.workflowPropertyName ?? "",
|
|
169
|
+
...(output.displayName !== undefined && output.displayName !== output.workflowPropertyName && { display_name: output.displayName }),
|
|
170
|
+
...(output.description !== undefined && output.description !== "" && { description: output.description }),
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
const block = { kind: "resource", type: subType.resourceType, label: tfLabel, attrs };
|
|
174
|
+
return { block, address: `${subType.resourceType}.${tfLabel}` };
|
|
175
|
+
}
|
|
176
|
+
if (typeKey === "runAgent") {
|
|
177
|
+
const target = inner.targetAgentId;
|
|
178
|
+
if (target?.refName === undefined || target.refName === "") {
|
|
179
|
+
ctx.diagnostics.push(`${where}: no target agent token; dropped`);
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
if (target.parent !== undefined && target.parent !== ctx.appRefName) {
|
|
183
|
+
ctx.diagnostics.push(`${where}: cross-app target agents are not supported; dropped`);
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
attrs["target_agent_id"] = expr.resourceAttr("elementum_agent", appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(target.refName)), ["id"]);
|
|
187
|
+
attrs["worker_task_prompt"] = inner.workerTaskPrompt ?? "";
|
|
188
|
+
const block = { kind: "resource", type: subType.resourceType, label: tfLabel, attrs };
|
|
189
|
+
return { block, address: `${subType.resourceType}.${tfLabel}` };
|
|
190
|
+
}
|
|
76
191
|
if (inner.aspectId === undefined) {
|
|
77
192
|
ctx.diagnostics.push(`${where}: no target aspect token; dropped`);
|
|
78
193
|
return undefined;
|
|
79
194
|
}
|
|
80
|
-
|
|
195
|
+
const target = resolveTarget(inner.aspectId, ctx);
|
|
196
|
+
attrs["target_id"] = target.value;
|
|
197
|
+
if (typeKey === "updateRecord") {
|
|
198
|
+
if (inner.handleDescription === undefined || inner.handleDescription === "") {
|
|
199
|
+
ctx.diagnostics.push(`${where}: no handleDescription; dropped`);
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
attrs["handle_description"] = inner.handleDescription;
|
|
203
|
+
}
|
|
81
204
|
if (typeKey === "searchAspect") {
|
|
82
205
|
attrs["query_description"] = inner.queryDescription ?? "";
|
|
83
206
|
if (inner.limit !== undefined)
|
|
@@ -86,14 +209,30 @@ export function skillToolToTf(entry, ctx) {
|
|
|
86
209
|
if (inner.fields !== undefined && inner.fields.length > 0) {
|
|
87
210
|
const fieldValues = [];
|
|
88
211
|
for (const f of inner.fields) {
|
|
89
|
-
|
|
212
|
+
// A raw-id fallback field (board issue #169) is echoed straight
|
|
213
|
+
// through — ei never resolves it to a reference either, so there's
|
|
214
|
+
// nothing to re-derive.
|
|
215
|
+
const ref = typeof f.fieldId === "string"
|
|
216
|
+
? f.fieldId
|
|
217
|
+
: f.fieldId === undefined
|
|
218
|
+
? undefined
|
|
219
|
+
: fieldRefValue(f.fieldId, where, ctx, target);
|
|
90
220
|
if (ref === undefined)
|
|
91
221
|
continue;
|
|
92
222
|
fieldValues.push({
|
|
93
223
|
field_id: ref,
|
|
94
224
|
name: f.name ?? "",
|
|
95
225
|
description: f.description ?? "",
|
|
96
|
-
|
|
226
|
+
// `required` on a searchAspect field is documented by the provider's
|
|
227
|
+
// own schema as "Not used by search tools" — the platform never
|
|
228
|
+
// queries or stores a meaningful value for it there, unlike
|
|
229
|
+
// createRecord's fields, where it's real and must always be emitted
|
|
230
|
+
// (defaulting false) per the agent-tool/to-tf.ts fix of 2026-08-05.
|
|
231
|
+
// (A `required: false` that used to show up in `ei apps export` for
|
|
232
|
+
// search tools was a bug in the exporter itself — cmd/elementum's
|
|
233
|
+
// hcl_skill.go was fabricating it from Go's zero-value default
|
|
234
|
+
// rather than an actually-discovered value; fixed 2026-08-11.)
|
|
235
|
+
...(typeKey !== "searchAspect" && typeKey !== "searchTable" && { required: f.required ?? false }),
|
|
97
236
|
});
|
|
98
237
|
if (f.defaultValue !== undefined) {
|
|
99
238
|
ctx.diagnostics.push(`${where}: field default values are not supported on the terraform path yet; dropped`);
|
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
* name/description/status) — so per-sub-type knowledge is one ROW here,
|
|
5
5
|
* exactly like `entities/agent-tool/types.ts` (which this mirrors).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* resource", and adoption scopes ONLY the implemented ones — an adopted type
|
|
10
|
-
* the printer can't reconstruct would plan as a destroy on rebuild.
|
|
7
|
+
* Search-table support stays coupled to the underlying AI search-table graph
|
|
8
|
+
* module; every other provider skill-tool resource is implemented end to end.
|
|
11
9
|
*
|
|
12
10
|
* Note the wire key for the automation tool is `automation`, not agent-tool's
|
|
13
11
|
* `executeWorkflow` — confirmed against the live provider schema
|
|
@@ -31,9 +29,9 @@ export declare const IMPLEMENTED_SKILL_TOOL_RESOURCE_TYPES: readonly string[];
|
|
|
31
29
|
export declare const ALL_SKILL_TOOL_RESOURCE_TYPES: readonly string[];
|
|
32
30
|
/**
|
|
33
31
|
* Attributes `skillToolFromTf` understands per implemented sub-type — growth
|
|
34
|
-
* is reported loudly. `run_as
|
|
35
|
-
*
|
|
36
|
-
*
|
|
32
|
+
* is reported loudly. Shared permissions (`run_as` and
|
|
33
|
+
* `service_account_id`) are included in every implemented row so pull never
|
|
34
|
+
* drops a tool's execution identity.
|
|
37
35
|
*/
|
|
38
36
|
export declare const KNOWN_SKILL_TOOL_ATTRS: Readonly<Record<string, ReadonlySet<string>>>;
|
|
39
37
|
/** Known provider attrs with no authoring slot yet — reported by name, tool still pulled. */
|
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
* name/description/status) — so per-sub-type knowledge is one ROW here,
|
|
5
5
|
* exactly like `entities/agent-tool/types.ts` (which this mirrors).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* resource", and adoption scopes ONLY the implemented ones — an adopted type
|
|
10
|
-
* the printer can't reconstruct would plan as a destroy on rebuild.
|
|
7
|
+
* Search-table support stays coupled to the underlying AI search-table graph
|
|
8
|
+
* module; every other provider skill-tool resource is implemented end to end.
|
|
11
9
|
*
|
|
12
10
|
* Note the wire key for the automation tool is `automation`, not agent-tool's
|
|
13
11
|
* `executeWorkflow` — confirmed against the live provider schema
|
|
@@ -16,10 +14,10 @@
|
|
|
16
14
|
export const SKILL_TOOL_SUB_TYPES = [
|
|
17
15
|
{ typeKey: "createRecord", resourceType: "elementum_agentic_skill_create_record_tool", implemented: true },
|
|
18
16
|
{ typeKey: "searchAspect", resourceType: "elementum_agentic_skill_search_records_tool", implemented: true },
|
|
19
|
-
{ typeKey: "updateRecord", resourceType: "elementum_agentic_skill_update_record_tool" },
|
|
17
|
+
{ typeKey: "updateRecord", resourceType: "elementum_agentic_skill_update_record_tool", implemented: true },
|
|
20
18
|
{ typeKey: "searchTable", resourceType: "elementum_agentic_skill_ai_search_tool" },
|
|
21
|
-
{ typeKey: "runAgent", resourceType: "elementum_agentic_skill_run_agent_tool" },
|
|
22
|
-
{ typeKey: "automation", resourceType: "elementum_agentic_skill_run_automation_tool" },
|
|
19
|
+
{ typeKey: "runAgent", resourceType: "elementum_agentic_skill_run_agent_tool", implemented: true },
|
|
20
|
+
{ typeKey: "automation", resourceType: "elementum_agentic_skill_run_automation_tool", implemented: true },
|
|
23
21
|
];
|
|
24
22
|
export const SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY = new Map(SKILL_TOOL_SUB_TYPES.map((t) => [t.typeKey, t]));
|
|
25
23
|
export const SKILL_TOOL_SUB_TYPE_BY_RESOURCE = new Map(SKILL_TOOL_SUB_TYPES.map((t) => [t.resourceType, t]));
|
|
@@ -29,9 +27,9 @@ export const IMPLEMENTED_SKILL_TOOL_RESOURCE_TYPES = SKILL_TOOL_SUB_TYPES.filter
|
|
|
29
27
|
export const ALL_SKILL_TOOL_RESOURCE_TYPES = SKILL_TOOL_SUB_TYPES.map((t) => t.resourceType);
|
|
30
28
|
/**
|
|
31
29
|
* Attributes `skillToolFromTf` understands per implemented sub-type — growth
|
|
32
|
-
* is reported loudly. `run_as
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* is reported loudly. Shared permissions (`run_as` and
|
|
31
|
+
* `service_account_id`) are included in every implemented row so pull never
|
|
32
|
+
* drops a tool's execution identity.
|
|
35
33
|
*/
|
|
36
34
|
export const KNOWN_SKILL_TOOL_ATTRS = {
|
|
37
35
|
createRecord: new Set([
|
|
@@ -62,6 +60,44 @@ export const KNOWN_SKILL_TOOL_ATTRS = {
|
|
|
62
60
|
"filter",
|
|
63
61
|
"filter_variables",
|
|
64
62
|
]),
|
|
63
|
+
updateRecord: new Set([
|
|
64
|
+
"skill_id",
|
|
65
|
+
"app_id",
|
|
66
|
+
"name",
|
|
67
|
+
"description",
|
|
68
|
+
"status",
|
|
69
|
+
"start_message",
|
|
70
|
+
"run_as",
|
|
71
|
+
"service_account_id",
|
|
72
|
+
"target_id",
|
|
73
|
+
"handle_description",
|
|
74
|
+
"fields",
|
|
75
|
+
]),
|
|
76
|
+
runAgent: new Set([
|
|
77
|
+
"skill_id",
|
|
78
|
+
"app_id",
|
|
79
|
+
"name",
|
|
80
|
+
"description",
|
|
81
|
+
"status",
|
|
82
|
+
"start_message",
|
|
83
|
+
"run_as",
|
|
84
|
+
"service_account_id",
|
|
85
|
+
"target_agent_id",
|
|
86
|
+
"worker_task_prompt",
|
|
87
|
+
]),
|
|
88
|
+
automation: new Set([
|
|
89
|
+
"skill_id",
|
|
90
|
+
"app_id",
|
|
91
|
+
"name",
|
|
92
|
+
"description",
|
|
93
|
+
"status",
|
|
94
|
+
"start_message",
|
|
95
|
+
"run_as",
|
|
96
|
+
"service_account_id",
|
|
97
|
+
"automation_id",
|
|
98
|
+
"inputs",
|
|
99
|
+
"outputs",
|
|
100
|
+
]),
|
|
65
101
|
};
|
|
66
102
|
/** Known provider attrs with no authoring slot yet — reported by name, tool still pulled. */
|
|
67
|
-
export const UNAUTHORABLE_SKILL_TOOL_ATTRS = new Set(
|
|
103
|
+
export const UNAUTHORABLE_SKILL_TOOL_ATTRS = new Set();
|
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
* module never names the app's own resource type.
|
|
7
7
|
*/
|
|
8
8
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
9
|
-
import { type TfBlock } from "../../engine/tf/index.js";
|
|
9
|
+
import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
|
|
10
10
|
import type { NormalizedLayout, NormalizedListView } from "../app/deserializer/normalize.js";
|
|
11
11
|
export interface ViewOwner {
|
|
12
12
|
/** The owner's resource type ("elementum_app") — what `object_id`/`aspect_id` must reference. */
|
|
13
13
|
readonly type: string;
|
|
14
|
-
/** The owner's tfLabel. */
|
|
14
|
+
/** The owner's tfLabel (namespace). */
|
|
15
15
|
readonly label: string;
|
|
16
|
+
/** Namespace tf label for stripping child label prefixes. */
|
|
17
|
+
readonly ownerTfLabel: string;
|
|
18
|
+
/** App vs element scope for prefix stripping. */
|
|
19
|
+
readonly scope?: ChildResourceScope;
|
|
16
20
|
/** Stage keys declared by the owning app, used when ei exports a raw stage UUID. */
|
|
17
21
|
readonly stageKeys?: ReadonlySet<string>;
|
|
18
22
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* module never names the app's own resource type.
|
|
7
7
|
*/
|
|
8
8
|
import { optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
|
-
import { isTfExpr,
|
|
9
|
+
import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
10
10
|
import { fieldKeyFromTfRef } from "../field/from-tf.js";
|
|
11
11
|
import { GROUP_SECTION_WIRE_TYPE, KNOWN_LAYOUT_ATTRS, KNOWN_LAYOUT_SECTION_ATTRS, KNOWN_LIST_VIEW_ATTRS, KNOWN_MANAGED_VIEW_ORDER_ATTRS, LIST_VIEW_RESOURCE_TYPE, SECTION_TYPE_FROM_WIRE, SYSTEM_FIELD_KEY_BY_ID_ATTR, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
|
|
12
12
|
/** Report every attribute key not in `known` as dialect growth — shared by all four view/section passes below. */
|
|
@@ -56,7 +56,8 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
56
56
|
return undefined;
|
|
57
57
|
}
|
|
58
58
|
const stageKey = stageKeyFromTf(attrs["stage_id"], owner.label);
|
|
59
|
-
const
|
|
59
|
+
const scope = owner.scope ?? "app";
|
|
60
|
+
const labelStageKey = scopedLabelToBagKey(owner.ownerTfLabel, label, scope);
|
|
60
61
|
const canInferStageKey = typeof attrs["stage_id"] === "string" && owner.stageKeys?.has(labelStageKey) === true;
|
|
61
62
|
if (stageKey === undefined && !canInferStageKey) {
|
|
62
63
|
ctx.diagnostics.push(`${where}: stage_id is not a "local.${owner.label}_stage_ids_by_key[...]" reference; using the layout's own label "${label}" as the stage key (may not match the platform's real stage key)`);
|
|
@@ -65,7 +66,7 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
65
66
|
const sections = [];
|
|
66
67
|
if (Array.isArray(sectionsAttr)) {
|
|
67
68
|
for (const item of sectionsAttr) {
|
|
68
|
-
const section = sectionFromTf(item, owner.label, where, ctx);
|
|
69
|
+
const section = sectionFromTf(item, owner.label, owner.ownerTfLabel, scope, where, ctx);
|
|
69
70
|
if (section !== undefined)
|
|
70
71
|
sections.push(section);
|
|
71
72
|
}
|
|
@@ -83,7 +84,7 @@ function stageKeyFromTf(v, ownerLabel) {
|
|
|
83
84
|
const seg = v.path[0];
|
|
84
85
|
return v.path.length === 1 && typeof seg === "object" && "index" in seg ? seg.index : undefined;
|
|
85
86
|
}
|
|
86
|
-
function sectionFromTf(raw, ownerLabel, where, ctx) {
|
|
87
|
+
function sectionFromTf(raw, ownerLabel, ownerTfLabel, scope, where, ctx) {
|
|
87
88
|
const rec = plainObject(raw);
|
|
88
89
|
if (rec === undefined) {
|
|
89
90
|
ctx.diagnostics.push(`${where}: a sections entry has an unrecognized shape; dropped`);
|
|
@@ -114,7 +115,7 @@ function sectionFromTf(raw, ownerLabel, where, ctx) {
|
|
|
114
115
|
if (Array.isArray(fieldIds)) {
|
|
115
116
|
const fields = [];
|
|
116
117
|
for (const f of fieldIds) {
|
|
117
|
-
const key = fieldRefFromTf(f, ownerLabel, ctx);
|
|
118
|
+
const key = fieldRefFromTf(f, ownerLabel, ownerTfLabel, scope, ctx);
|
|
118
119
|
if (key !== undefined)
|
|
119
120
|
fields.push(key);
|
|
120
121
|
}
|
|
@@ -127,7 +128,7 @@ function sectionFromTf(raw, ownerLabel, where, ctx) {
|
|
|
127
128
|
return section;
|
|
128
129
|
}
|
|
129
130
|
/** A `field_ids`/`columns` entry → a system-field key or a custom field's bag key. */
|
|
130
|
-
function fieldRefFromTf(v, ownerLabel, ctx) {
|
|
131
|
+
function fieldRefFromTf(v, ownerLabel, ownerTfLabel, scope, ctx) {
|
|
131
132
|
if (!isTfExpr(v)) {
|
|
132
133
|
ctx.diagnostics.push(`field reference has an unrecognized (non-expression) shape; dropped`);
|
|
133
134
|
return undefined;
|
|
@@ -140,7 +141,7 @@ function fieldRefFromTf(v, ownerLabel, ctx) {
|
|
|
140
141
|
}
|
|
141
142
|
// Custom field ref resolution is shared with agent-tool's field refs
|
|
142
143
|
// (src/entities/agent-tool/from-tf.ts) via entities/field/from-tf.ts.
|
|
143
|
-
const fieldKey = fieldKeyFromTfRef(v);
|
|
144
|
+
const fieldKey = fieldKeyFromTfRef(v, ownerTfLabel, scope);
|
|
144
145
|
if (fieldKey !== undefined)
|
|
145
146
|
return fieldKey;
|
|
146
147
|
ctx.diagnostics.push(`field reference ${JSON.stringify(v)} does not resolve to a known field; dropped`);
|
|
@@ -160,12 +161,13 @@ function listViewFromTf(block, owner, ctx) {
|
|
|
160
161
|
ctx.diagnostics.push(`${where}: aspect_id does not reference ${owner.type}.${owner.label}; skipped`);
|
|
161
162
|
return undefined;
|
|
162
163
|
}
|
|
164
|
+
const scope = owner.scope ?? "app";
|
|
163
165
|
const name = optionalString(attrs, "name", where, ctx) ?? "";
|
|
164
166
|
const columnsAttr = attrs["columns"];
|
|
165
167
|
const columns = [];
|
|
166
168
|
if (Array.isArray(columnsAttr)) {
|
|
167
169
|
for (const c of columnsAttr) {
|
|
168
|
-
const key = fieldRefFromTf(c, owner.label, ctx);
|
|
170
|
+
const key = fieldRefFromTf(c, owner.label, owner.ownerTfLabel, scope, ctx);
|
|
169
171
|
if (key !== undefined)
|
|
170
172
|
columns.push(key);
|
|
171
173
|
}
|
|
@@ -190,7 +192,7 @@ function listViewFromTf(block, owner, ctx) {
|
|
|
190
192
|
ctx.diagnostics.push(`${where}: sort is not a jsonencode(...) expression; dropped`);
|
|
191
193
|
}
|
|
192
194
|
return {
|
|
193
|
-
key:
|
|
195
|
+
key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
|
|
194
196
|
name,
|
|
195
197
|
columns,
|
|
196
198
|
...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* (views have no nested sub-entities of their own), so this module never
|
|
11
11
|
* throws `EntityTfError`.
|
|
12
12
|
*/
|
|
13
|
-
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
13
|
+
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
14
14
|
/** The authored field-ref shape post-`slimTokens`: a system key string, or a slimmed `FieldRef` token. */
|
|
15
15
|
export type ViewFieldRefWire = string | {
|
|
16
16
|
readonly __kind?: string;
|
|
@@ -42,16 +42,18 @@ export interface AppListViewWire {
|
|
|
42
42
|
readonly sort?: unknown;
|
|
43
43
|
}
|
|
44
44
|
export interface ViewToTfOptions {
|
|
45
|
-
/** The owning
|
|
46
|
-
readonly
|
|
45
|
+
/** The owning stream root's terraform label (namespace). */
|
|
46
|
+
readonly ownerTfLabel: string;
|
|
47
|
+
/** App children use `apps_<ns>_`; element children use `<ns>_`. */
|
|
48
|
+
readonly scope?: ChildResourceScope;
|
|
47
49
|
/**
|
|
48
|
-
* The owning
|
|
50
|
+
* The owning aspect's display name — `elementum_managed_view_order`'s label
|
|
49
51
|
* has no authored bag key (it's a derived aspect-wide singleton), so ei
|
|
50
|
-
* derives it from the
|
|
52
|
+
* derives it from the NAME (its `SanitizeName`, not the namespace);
|
|
51
53
|
* matching that here keeps the build-vs-export address-stable across a real pull.
|
|
52
54
|
*/
|
|
53
|
-
readonly
|
|
54
|
-
/** The owning
|
|
55
|
+
readonly aspectName: string;
|
|
56
|
+
/** The owning aspect's id reference — computed by the caller. */
|
|
55
57
|
readonly objectId: TfValue;
|
|
56
58
|
/** Degradations land here — reported by the caller, never silent. */
|
|
57
59
|
readonly diagnostics: string[];
|
|
@@ -10,16 +10,22 @@
|
|
|
10
10
|
* (views have no nested sub-entities of their own), so this module never
|
|
11
11
|
* throws `EntityTfError`.
|
|
12
12
|
*/
|
|
13
|
-
import { expr, isCanonicalTsLabel, sanitizeName, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
13
|
+
import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
14
14
|
import { fieldRefToTfValue as customFieldRefToTfValue } from "../field/to-tf.js";
|
|
15
15
|
import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
|
|
16
16
|
import { GROUP_SECTION_WIRE_TYPE, LAYOUT_RESOURCE_TYPE, LAYOUT_RESTRICTED_SYSTEM_FIELD_KEYS, LIST_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, SECTION_TYPE_TO_WIRE, SYSTEM_FIELD_ID_ATTR_BY_KEY, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
|
|
17
|
+
/** Elements only have `id`/`title` as real system fields (no status/stage/audit fields) — see `element/locals.ts`. */
|
|
18
|
+
const ELEMENT_SYSTEM_FIELD_KEYS = new Set(["id", "title"]);
|
|
17
19
|
/** `layouts`/`listViews`/`viewOrder` → their resource blocks, in ei's dialect. */
|
|
18
20
|
export function viewToTf(layouts, listViews, viewOrder, opts) {
|
|
19
|
-
const {
|
|
21
|
+
const { ownerTfLabel, scope = "app", aspectName, objectId, diagnostics } = opts;
|
|
20
22
|
const blocks = [];
|
|
21
23
|
for (const [stageKey, layout] of Object.entries(layouts ?? {})) {
|
|
22
|
-
|
|
24
|
+
if (!isCanonicalTsLabel(stageKey)) {
|
|
25
|
+
diagnostics.push(`layouts key "${stageKey}" is not a canonical tsLabel (see src/engine/tf/labels.ts) — rename the key`);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
blocks.push(layoutToTf(stageKey, layout, ownerTfLabel, scope, objectId, diagnostics));
|
|
23
29
|
}
|
|
24
30
|
const viewAddressByKey = new Map();
|
|
25
31
|
for (const [viewKey, view] of Object.entries(listViews ?? {})) {
|
|
@@ -27,12 +33,12 @@ export function viewToTf(layouts, listViews, viewOrder, opts) {
|
|
|
27
33
|
diagnostics.push(`listViews key "${viewKey}" is not a canonical tsLabel (see src/engine/tf/labels.ts) — rename the key`);
|
|
28
34
|
continue;
|
|
29
35
|
}
|
|
30
|
-
const tfLabel = tsLabelToTfLabel(viewKey);
|
|
36
|
+
const tfLabel = scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(viewKey), scope);
|
|
31
37
|
const attrs = {
|
|
32
38
|
aspect_id: objectId,
|
|
33
39
|
name: view.name ?? "",
|
|
34
40
|
allow_record_creation: view.allowRecordCreation ?? true,
|
|
35
|
-
columns: resolveFieldRefs(view.columns ?? [],
|
|
41
|
+
columns: resolveFieldRefs(view.columns ?? [], ownerTfLabel, scope, `listViews.${viewKey}.columns`, diagnostics),
|
|
36
42
|
density: view.density ?? "STANDARD",
|
|
37
43
|
rows: view.rows ?? 25,
|
|
38
44
|
};
|
|
@@ -69,14 +75,14 @@ export function viewToTf(layouts, listViews, viewOrder, opts) {
|
|
|
69
75
|
blocks.push({
|
|
70
76
|
kind: "resource",
|
|
71
77
|
type: MANAGED_VIEW_ORDER_RESOURCE_TYPE,
|
|
72
|
-
label: `${sanitizeName(
|
|
78
|
+
label: `${sanitizeName(aspectName)}_view_order`,
|
|
73
79
|
attrs: { object_id: objectId, view_ids: viewIds },
|
|
74
80
|
});
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
return { blocks };
|
|
78
84
|
}
|
|
79
|
-
function layoutToTf(stageKey, layout,
|
|
85
|
+
function layoutToTf(stageKey, layout, ownerTfLabel, scope, objectId, diagnostics) {
|
|
80
86
|
const sections = [];
|
|
81
87
|
for (const section of layout.sections) {
|
|
82
88
|
const authoringType = section.type ?? "group";
|
|
@@ -89,8 +95,14 @@ function layoutToTf(stageKey, layout, appTfLabel, objectId, diagnostics) {
|
|
|
89
95
|
type: wireType,
|
|
90
96
|
display_location: section.displayLocation ?? "CENTER",
|
|
91
97
|
display_order: section.displayOrder ?? 0,
|
|
92
|
-
side_nav_item: section.sideNavItem ?? false,
|
|
93
98
|
};
|
|
99
|
+
// Mirrors ei's exporter (hcl_app.go): true is the platform default and is
|
|
100
|
+
// NEVER emitted; only an explicit false is written. Always emitting a
|
|
101
|
+
// value here (like the other three) would force `false` on every section
|
|
102
|
+
// whose sideNavItem was never captured (i.e. is really `true`), planning
|
|
103
|
+
// a spurious change on every build.
|
|
104
|
+
if (section.sideNavItem === false)
|
|
105
|
+
sec.side_nav_item = false;
|
|
94
106
|
if (wireType === GROUP_SECTION_WIRE_TYPE) {
|
|
95
107
|
sec.name = section.name ?? "";
|
|
96
108
|
if (section.icon !== undefined)
|
|
@@ -105,41 +117,52 @@ function layoutToTf(stageKey, layout, appTfLabel, objectId, diagnostics) {
|
|
|
105
117
|
}
|
|
106
118
|
return true;
|
|
107
119
|
});
|
|
108
|
-
sec.field_ids = resolveFieldRefs(fields,
|
|
120
|
+
sec.field_ids = resolveFieldRefs(fields, ownerTfLabel, scope, where, diagnostics);
|
|
109
121
|
}
|
|
110
122
|
else if (wireType === UPDATE_SECTION_WIRE_TYPE && section.name !== undefined) {
|
|
111
123
|
sec.name = section.name;
|
|
112
124
|
}
|
|
113
125
|
sections.push(sec);
|
|
114
126
|
}
|
|
127
|
+
// `stage_ids_by_key` (a real provider-computed attribute) is keyed by
|
|
128
|
+
// tfLabel ("in_progress"), not the authored tsLabel ("inProgress") — same
|
|
129
|
+
// bijection listViews already applies to its own label just above. Reusing
|
|
130
|
+
// the raw tsLabel here would both mislabel the resource (a fresh terraform
|
|
131
|
+
// address ei never produced) and index the map with a key that doesn't
|
|
132
|
+
// exist, breaking every plan.
|
|
133
|
+
const tfLabel = tsLabelToTfLabel(stageKey);
|
|
115
134
|
return {
|
|
116
135
|
kind: "resource",
|
|
117
136
|
type: LAYOUT_RESOURCE_TYPE,
|
|
118
|
-
label:
|
|
137
|
+
label: scopedResourceLabel(ownerTfLabel, tfLabel, scope),
|
|
119
138
|
attrs: {
|
|
120
139
|
object_id: objectId,
|
|
121
|
-
stage_id: expr.local(`${
|
|
140
|
+
stage_id: expr.local(`${ownerTfLabel}_stage_ids_by_key`, [{ index: tfLabel }]),
|
|
122
141
|
sections,
|
|
123
142
|
},
|
|
124
143
|
};
|
|
125
144
|
}
|
|
126
|
-
function resolveFieldRefs(refs,
|
|
145
|
+
function resolveFieldRefs(refs, ownerTfLabel, scope, where, diagnostics) {
|
|
127
146
|
const out = [];
|
|
128
147
|
for (const ref of refs) {
|
|
129
|
-
const resolved = fieldRefToTfValue(ref,
|
|
148
|
+
const resolved = fieldRefToTfValue(ref, ownerTfLabel, scope, where, diagnostics);
|
|
130
149
|
if (resolved !== undefined)
|
|
131
150
|
out.push(resolved);
|
|
132
151
|
}
|
|
133
152
|
return out;
|
|
134
153
|
}
|
|
135
|
-
function fieldRefToTfValue(ref,
|
|
154
|
+
function fieldRefToTfValue(ref, ownerTfLabel, scope, where, diagnostics) {
|
|
136
155
|
if (typeof ref === "string") {
|
|
156
|
+
if (scope === "element" && !ELEMENT_SYSTEM_FIELD_KEYS.has(ref)) {
|
|
157
|
+
diagnostics.push(`${where}: "${ref}" is not a known system field key on an element; dropped`);
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
137
160
|
const attr = SYSTEM_FIELD_ID_ATTR_BY_KEY.get(ref);
|
|
138
161
|
if (attr === undefined) {
|
|
139
162
|
diagnostics.push(`${where}: "${ref}" is not a known system field key; dropped`);
|
|
140
163
|
return undefined;
|
|
141
164
|
}
|
|
142
|
-
return expr.local(`${
|
|
165
|
+
return expr.local(`${ownerTfLabel}_${attr}`);
|
|
143
166
|
}
|
|
144
167
|
const refName = ref.refName ?? "";
|
|
145
168
|
if (!SUB_TYPE_BY_AUTHORING_TYPE.has(ref.fieldType ?? "")) {
|
|
@@ -150,7 +173,5 @@ function fieldRefToTfValue(ref, appTfLabel, where, diagnostics) {
|
|
|
150
173
|
diagnostics.push(`${where}: field bag key "${refName}" is not a canonical tsLabel; dropped`);
|
|
151
174
|
return undefined;
|
|
152
175
|
}
|
|
153
|
-
|
|
154
|
-
// (src/entities/agent-tool/to-tf.ts) via entities/field/to-tf.ts.
|
|
155
|
-
return customFieldRefToTfValue(ref.fieldType, refName);
|
|
176
|
+
return customFieldRefToTfValue(ref.fieldType, refName, ownerTfLabel, scope);
|
|
156
177
|
}
|
|
@@ -15,7 +15,7 @@ export declare const LIST_VIEW_RESOURCE_TYPE = "elementum_list_view";
|
|
|
15
15
|
export declare const MANAGED_VIEW_ORDER_RESOURCE_TYPE = "elementum_managed_view_order";
|
|
16
16
|
/**
|
|
17
17
|
* Layout section `type` discriminator: authoring camelCase ↔ the provider's
|
|
18
|
-
* wire value, verified against `
|
|
18
|
+
* wire value, verified against `provider/internal/provider/layout_resource.go`
|
|
19
19
|
* (the schema's own embedded doc table). Only `group` carries
|
|
20
20
|
* `name`/`icon`/`color`/`field_ids`; `update` additionally takes an optional
|
|
21
21
|
* `name`; the rest are bare component sections.
|