@elementumai/edk 0.10.2 → 0.10.4
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 +7 -7
- package/dist-sdk/src/catalog/org.d.ts +7 -5
- package/dist-sdk/src/catalog/org.js +14 -9
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/core/types/app.d.ts +22 -0
- package/dist-sdk/src/engine/build/context.d.ts +8 -0
- package/dist-sdk/src/engine/build/source-context.d.ts +3 -4
- package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +3 -0
- package/dist-sdk/src/engine/ei/state.d.ts +48 -0
- package/dist-sdk/src/engine/ei/state.js +91 -0
- package/dist-sdk/src/engine/pull/authored-address.d.ts +100 -0
- package/dist-sdk/src/engine/pull/authored-address.js +360 -0
- package/dist-sdk/src/engine/pull/context.d.ts +69 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +7 -0
- package/dist-sdk/src/engine/tf/expr.js +62 -18
- package/dist-sdk/src/engine/tf/index.d.ts +2 -1
- package/dist-sdk/src/engine/tf/index.js +2 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +10 -2
- package/dist-sdk/src/engine/tf/labels.js +15 -2
- package/dist-sdk/src/engine/tf/parse.js +19 -6
- package/dist-sdk/src/engine/tf/scan.d.ts +22 -0
- package/dist-sdk/src/engine/tf/scan.js +123 -0
- package/dist-sdk/src/engine/workspace/backend.d.ts +34 -0
- package/dist-sdk/src/engine/workspace/backend.js +104 -0
- package/dist-sdk/src/engine/workspace/generated-file.d.ts +3 -0
- package/dist-sdk/src/engine/workspace/generated-file.js +6 -0
- package/dist-sdk/src/engine/workspace/loader.d.ts +8 -0
- package/dist-sdk/src/engine/workspace/loader.js +22 -2
- package/dist-sdk/src/entities/agent/to-tf.d.ts +13 -11
- package/dist-sdk/src/entities/agent/to-tf.js +17 -12
- package/dist-sdk/src/entities/agent-tool/from-tf.js +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -1
- package/dist-sdk/src/entities/app/build.d.ts +36 -4
- package/dist-sdk/src/entities/app/build.js +67 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +18 -0
- package/dist-sdk/src/entities/app/from-tf.js +17 -9
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +82 -0
- package/dist-sdk/src/entities/app/stage-keys.js +160 -0
- package/dist-sdk/src/entities/app/to-tf.js +17 -21
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +31 -3
- package/dist-sdk/src/entities/approval-chain/module.js +12 -4
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.js +6 -1
- package/dist-sdk/src/entities/automation/build.js +25 -8
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +5 -3
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +90 -17
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +140 -23
- package/dist-sdk/src/entities/automation/module.js +158 -44
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +8 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +20 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +2 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +18 -0
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/to-tf.js +200 -38
- package/dist-sdk/src/entities/automation/triggers.d.ts +2 -0
- package/dist-sdk/src/entities/automation/triggers.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +51 -4
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +48 -4
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -2
- package/dist-sdk/src/entities/element/build.js +1 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +12 -6
- package/dist-sdk/src/entities/element/from-tf.js +26 -8
- package/dist-sdk/src/entities/element/module.js +3 -2
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +32 -25
- package/dist-sdk/src/entities/field/allow-list.d.ts +18 -0
- package/dist-sdk/src/entities/field/allow-list.js +42 -0
- package/dist-sdk/src/entities/field/build.d.ts +38 -3
- package/dist-sdk/src/entities/field/build.js +7 -2
- package/dist-sdk/src/entities/field/from-tf.js +178 -20
- package/dist-sdk/src/entities/field/module.js +2 -0
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/order.d.ts +9 -0
- package/dist-sdk/src/entities/field/order.js +33 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/to-tf.js +87 -0
- package/dist-sdk/src/entities/field/types.js +3 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +3 -3
- package/dist-sdk/src/entities/relationship/from-tf.js +4 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +3 -1
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +8 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.js +12 -4
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +5 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +13 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +1 -1
- package/dist-sdk/src/entities/skill/module.js +28 -2
- package/dist-sdk/src/entities/skill/to-tf.js +19 -14
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -1
- package/dist-sdk/src/entities/task/build.js +1 -1
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +6 -2
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +13 -38
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +29 -0
- package/dist-sdk/src/entities/view/custom-view-validate.js +293 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +10 -0
- package/dist-sdk/src/entities/view/from-tf.js +164 -26
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/view/to-tf.js +14 -6
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/visual-flow/from-tf.js +11 -2
- package/dist-sdk/src/entities/visual-flow/module.js +15 -5
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +8 -1
- package/dist-sdk/src/entities/widget/from-tf.js +12 -6
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +16 -0
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +8 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +6 -0
- package/dist-sdk/src/graph/index.js +1 -0
- package/dist-sdk/src/graph/types.d.ts +66 -2
- package/package.json +2 -17
|
@@ -60,6 +60,13 @@ export interface FieldRefAst {
|
|
|
60
60
|
*/
|
|
61
61
|
readonly foreign?: {
|
|
62
62
|
readonly entityType: "app" | "element" | "task";
|
|
63
|
+
/**
|
|
64
|
+
* Set when `entityType` is only a placeholder: the field was resolved
|
|
65
|
+
* from a raw field id whose registry entry names the owner but not its
|
|
66
|
+
* kind. Printers must then resolve the owner against pulled apps AND
|
|
67
|
+
* elements instead of trusting `entityType`.
|
|
68
|
+
*/
|
|
69
|
+
readonly ownerKindUnknown?: true;
|
|
63
70
|
/** The owner's display name — resolves a same-name local catalog entry, same convention as `AppRefAst.name`. */
|
|
64
71
|
readonly name: string;
|
|
65
72
|
/** Stable namespace for a portable inline fieldRef owner lookup. */
|
|
@@ -227,7 +227,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
227
227
|
// foreign-literal fallback used for an unresolved search table
|
|
228
228
|
// elsewhere in this printer). refName is a best-effort guess
|
|
229
229
|
// from the display name, not a verified catalog key.
|
|
230
|
-
` automation: { __kind: "automation", refName: ${quote(tfLabelToTsLabel(sanitizeName(tool.automationForeignName)))}, name: ${quote(tool.automationForeignName)}, parent: ${quote(tool.automationForeignParentRefName ?? tool.automationForeignParentName ?? "")}, parentName: ${quote(tool.automationForeignParentName ?? "")}, parentKind: ${quote(tool.automationForeignParentKind ?? "app")} } /* TODO: foreign automation reference - no catalog token available; verify the parent/refName before deploying */,`
|
|
230
|
+
` automation: { __kind: "automation", refName: ${quote(tfLabelToTsLabel(sanitizeName(tool.automationForeignName)))}, name: ${quote(tool.automationForeignName)}, parent: ${quote(tool.automationForeignParentRefName ?? tool.automationForeignParentName ?? "")}, parentName: ${quote(tool.automationForeignParentName ?? "")}, parentKind: ${quote(tool.automationForeignParentKind ?? "app")}${tool.automationForeignParentNamespace !== undefined ? `, parentNamespace: ${quote(tool.automationForeignParentNamespace)}` : ""} } /* TODO: foreign automation reference - no catalog token available; verify the parent/refName before deploying */,`
|
|
231
231
|
: ` automation: catalog.${appRefName}.automations${safeMember(tool.automationKey ?? "")},`);
|
|
232
232
|
const inputs = tool.inputs ?? [];
|
|
233
233
|
if (inputs.length > 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The skill entity's registry entry + resource-type constant (see src/graph/). */
|
|
2
2
|
import { rootParentFactoryEntry } from "../../catalog/render-helpers.js";
|
|
3
|
-
import { isTfExpr } from "../../engine/tf/index.js";
|
|
3
|
+
import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
4
4
|
import { printSkillV2 } from "./deserializer/print-skill-v2.js";
|
|
5
5
|
import { skillFromTf } from "./from-tf.js";
|
|
6
6
|
import { skillToTf } from "./to-tf.js";
|
|
@@ -41,6 +41,29 @@ function skillRefFromAuthoring(args) {
|
|
|
41
41
|
: entityRefName;
|
|
42
42
|
return { __kind: "skill", refName: entityRefName, name, parent: entityParent };
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A tool that runs a same-stream automation prints a catalog ref to it. If
|
|
46
|
+
* pull skips that automation and keeps no authored file for it, build cannot
|
|
47
|
+
* emit the tool, so stream-root drops it from the skill and releases it.
|
|
48
|
+
*/
|
|
49
|
+
function requireRunAutomationTarget(tool, skillRefName, ctx) {
|
|
50
|
+
const automation = tool.attrs["automation_id"];
|
|
51
|
+
const toolName = tool.attrs["name"];
|
|
52
|
+
if (!isTfExpr(automation) || automation.$expr !== "resource-attr" || typeof toolName !== "string")
|
|
53
|
+
return;
|
|
54
|
+
if (automation.type !== "elementum_workflow_publish" && automation.type !== "elementum_automation")
|
|
55
|
+
return;
|
|
56
|
+
ctx.requiresExtracted?.push({
|
|
57
|
+
address: `${tool.type}.${tool.label}`,
|
|
58
|
+
requires: `${automation.type}.${automation.label}`,
|
|
59
|
+
requiresOwnFile: { kind: "automation", refName: scopedLabelToBagKey(ctx.appTfLabel, automation.label) },
|
|
60
|
+
prune: (root) => root,
|
|
61
|
+
pruneOwnFile: {
|
|
62
|
+
kind: "skill",
|
|
63
|
+
prune: (skills) => skills.map((skill) => skill.refName === skillRefName ? { ...skill, tools: skill.tools.filter((t) => t.name !== toolName) } : skill),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
44
67
|
function extractSkills(ownBlocks, stream, ctx) {
|
|
45
68
|
const toolBlocks = stream.byKind.get("skill-tool") ?? [];
|
|
46
69
|
const items = [];
|
|
@@ -53,8 +76,11 @@ function extractSkills(ownBlocks, stream, ctx) {
|
|
|
53
76
|
return isTfExpr(ref) && ref.$expr === "resource-attr" && ref.type === SKILL_RESOURCE_TYPE && ref.label === skillLabel;
|
|
54
77
|
});
|
|
55
78
|
const { skill, skippedReason } = skillFromTf(skillBlock, ownTools, ctx.appTfLabel, ctx);
|
|
56
|
-
if (skill !== undefined)
|
|
79
|
+
if (skill !== undefined) {
|
|
57
80
|
items.push(skill);
|
|
81
|
+
for (const tool of ownTools)
|
|
82
|
+
requireRunAutomationTarget(tool, skill.refName, ctx);
|
|
83
|
+
}
|
|
58
84
|
else if (skippedReason !== undefined) {
|
|
59
85
|
skipped.push(`${SKILL_RESOURCE_TYPE}.${skillLabel}`);
|
|
60
86
|
diagnostics.push(skippedReason);
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
16
16
|
import { EntityTfError } from "../../engine/entity.js";
|
|
17
17
|
import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
18
|
+
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
18
19
|
import { skillToolToTf } from "../skill-tool/to-tf.js";
|
|
19
20
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
20
21
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
@@ -139,21 +140,25 @@ export function skillToTf(entity, ctx) {
|
|
|
139
140
|
});
|
|
140
141
|
return expr.dataAttr("elementum_search_table", label, ["id"]);
|
|
141
142
|
},
|
|
142
|
-
foreignAutomationRef: (tfLabel,
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
//
|
|
150
|
-
// (
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
foreignAutomationRef: (tfLabel, owner, automationName) => {
|
|
144
|
+
// The owner app/element resolves through the kind graph's root
|
|
145
|
+
// lookup (by namespace), the same as the agent tool path, automation
|
|
146
|
+
// tasks and every other foreign reference to it. A display-name
|
|
147
|
+
// rawLookup here gave the shared data address a second identity and
|
|
148
|
+
// failed the build when anything else referenced that owner (#1722).
|
|
149
|
+
const ownerRef = resolveForeignRef(owner.kind, { name: owner.name, ...(owner.namespace !== undefined ? { namespace: owner.namespace } : {}) }, ctx.orgRefs, ctx.diagnostics, "skill run-automation owner");
|
|
150
|
+
// Owner-scoped label: the owner prefix is the graph root-lookup label
|
|
151
|
+
// (sanitized namespace; the name only as the compatibility fallback)
|
|
152
|
+
// and the suffix is the automation's tfLabel, the same address an
|
|
153
|
+
// automation task's foreign target uses. A bare automation label
|
|
154
|
+
// would collide in ctx.orgRefs.rawLookup's `${type}.${label}` registry
|
|
155
|
+
// key across owners. ei's export prefixes `lookup.Label`, which is
|
|
156
|
+
// SanitizeName(display name) (imports.go), so the address equals
|
|
157
|
+
// ei's only when the name and namespace sanitize alike; data-block
|
|
158
|
+
// labels don't affect plans.
|
|
159
|
+
const automationLabel = `${ownerRef.tfLabel}_${tfLabel}`;
|
|
155
160
|
ctx.orgRefs.rawLookup("elementum_automation", automationLabel, automationName, {
|
|
156
|
-
app_id:
|
|
161
|
+
app_id: ownerRef.value,
|
|
157
162
|
});
|
|
158
163
|
return expr.dataAttr("elementum_automation", automationLabel, ["id"]);
|
|
159
164
|
},
|
|
@@ -90,6 +90,8 @@ export interface NormalizedSkillTool {
|
|
|
90
90
|
readonly automationForeignParentName?: string;
|
|
91
91
|
/** Canonical catalog refName of the owning app/element, when known. */
|
|
92
92
|
readonly automationForeignParentRefName?: string;
|
|
93
|
+
/** Namespace of the owning app/element, when the export looked it up by namespace. */
|
|
94
|
+
readonly automationForeignParentNamespace?: string;
|
|
93
95
|
readonly automationForeignParentKind?: "app" | "element";
|
|
94
96
|
readonly searchTableKey?: string;
|
|
95
97
|
/** Foreign table lookup name when search_table_id is data.elementum_search_table. */
|
|
@@ -149,6 +149,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
149
149
|
let automationForeignName;
|
|
150
150
|
let automationForeignParentName;
|
|
151
151
|
let automationForeignParentRefName;
|
|
152
|
+
let automationForeignParentNamespace;
|
|
152
153
|
let automationForeignParentKind;
|
|
153
154
|
if (automationLabel === undefined &&
|
|
154
155
|
automationRawId === undefined &&
|
|
@@ -173,6 +174,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
173
174
|
automationForeignName = automationName;
|
|
174
175
|
automationForeignParentName = resolvedOwner.name;
|
|
175
176
|
automationForeignParentRefName = resolvedOwner.key;
|
|
177
|
+
automationForeignParentNamespace = resolvedOwner.namespace;
|
|
176
178
|
automationForeignParentKind = ownerKind;
|
|
177
179
|
}
|
|
178
180
|
if (automationLabel === undefined && automationRawId === undefined && automationForeignName === undefined) {
|
|
@@ -220,6 +222,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
220
222
|
automationForeignName,
|
|
221
223
|
...(automationForeignParentName !== undefined && { automationForeignParentName }),
|
|
222
224
|
...(automationForeignParentRefName !== undefined && { automationForeignParentRefName }),
|
|
225
|
+
...(automationForeignParentNamespace !== undefined && { automationForeignParentNamespace }),
|
|
223
226
|
...(automationForeignParentKind !== undefined && { automationForeignParentKind }),
|
|
224
227
|
}
|
|
225
228
|
: { automationKey: scopedLabelToBagKey(owner.ownerTfLabel, automationLabel) }),
|
|
@@ -41,7 +41,12 @@ export interface SkillToolToTfContext {
|
|
|
41
41
|
* skill/agent tool targeting an automation this workspace doesn't own),
|
|
42
42
|
* returning the resolved `.id`. Live-confirmed on sanofi/eu (#1177).
|
|
43
43
|
*/
|
|
44
|
-
foreignAutomationRef?(tfLabel: string,
|
|
44
|
+
foreignAutomationRef?(tfLabel: string, owner: {
|
|
45
|
+
readonly kind: "app" | "element";
|
|
46
|
+
readonly refName: string;
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly namespace?: string;
|
|
49
|
+
}, automationName: string): TfValue | void;
|
|
45
50
|
/** Resolves a table-column token for a table-owned search tool. */
|
|
46
51
|
tableColumnRef?(tableRefName: string, tableName: string, columnName: string): TfValue | void;
|
|
47
52
|
/** App-local automations whose publish resource will be emitted in this build. */
|
|
@@ -229,7 +229,12 @@ export function skillToolToTf(entry, ctx) {
|
|
|
229
229
|
if (ctx.foreignAutomationRef !== undefined &&
|
|
230
230
|
typeof automation.parentName === "string" && automation.parentName !== "" &&
|
|
231
231
|
typeof automation.name === "string" && automation.name !== "") {
|
|
232
|
-
const lookup = ctx.foreignAutomationRef(automationTfLabel,
|
|
232
|
+
const lookup = ctx.foreignAutomationRef(automationTfLabel, {
|
|
233
|
+
kind: automation.parentKind ?? "app",
|
|
234
|
+
refName: automation.parent,
|
|
235
|
+
name: automation.parentName,
|
|
236
|
+
...(automation.parentNamespace !== undefined ? { namespace: automation.parentNamespace } : {}),
|
|
237
|
+
}, automation.name);
|
|
233
238
|
if (lookup === undefined) {
|
|
234
239
|
ctx.diagnostics.push(droppedSkillTool(where, "foreign automation lookup could not be materialized; dropped"));
|
|
235
240
|
return undefined;
|
|
@@ -20,7 +20,7 @@ export function task(opts) {
|
|
|
20
20
|
if (TASK_SYSTEM_FIELD_KEYS.has(key))
|
|
21
21
|
throw new Error(`task ${JSON.stringify(opts.name)}: fields.${key} collides with the task's ${key} system field; use ${key}Field or another key.`);
|
|
22
22
|
}
|
|
23
|
-
const fields = authoredFields === undefined ? undefined : Object.entries(authoredFields).map(([bagKey, field]) => serializeField(field, bagKey));
|
|
23
|
+
const fields = authoredFields === undefined ? undefined : Object.entries(authoredFields).map(([bagKey, field]) => serializeField(field, bagKey, `task ${JSON.stringify(opts.name)}`));
|
|
24
24
|
return { kind: "task", parent: "org", refName, payload: slimTokens({ ...rest, handle, namespace, ...(fields !== undefined && fields.length > 0 ? { fields } : {}) }), ...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}) };
|
|
25
25
|
} };
|
|
26
26
|
}
|
|
@@ -61,6 +61,8 @@ export interface AgentViewLayoutFromTfOptions {
|
|
|
61
61
|
readonly isOwnApp: (value: TfValue) => boolean;
|
|
62
62
|
/** Resolves a field reference to its bag key, a system field key, or a raw id. */
|
|
63
63
|
readonly fieldKey: (value: TfValue) => string | undefined;
|
|
64
|
+
/** Sees a raw platform id in a field position, which pulls as is (#1736 records the ones naming unextracted fields). */
|
|
65
|
+
readonly noteRawFieldId?: (id: string) => void;
|
|
64
66
|
/** Resolves another app's or element's data lookup. */
|
|
65
67
|
readonly foreignSource?: (value: TfValue) => ViewBlocksSourceMarker | undefined;
|
|
66
68
|
/** Resolves the data lookup of another app's or element's field. */
|
|
@@ -152,8 +152,10 @@ function deepRefs(value, where, opts) {
|
|
|
152
152
|
if (isTfExpr(value)) {
|
|
153
153
|
return sourceRef(value, opts) ?? fieldMarker(value, where, opts);
|
|
154
154
|
}
|
|
155
|
-
if (isPlatformId(value))
|
|
155
|
+
if (isPlatformId(value)) {
|
|
156
|
+
opts.noteRawFieldId?.(value);
|
|
156
157
|
return unsafe(value);
|
|
158
|
+
}
|
|
157
159
|
if (Array.isArray(value))
|
|
158
160
|
return value.map((item, i) => deepRefs(item, `${where}[${i}]`, opts));
|
|
159
161
|
const rec = plain(value);
|
|
@@ -201,8 +203,10 @@ function sourceRef(value, opts) {
|
|
|
201
203
|
return opts.foreignSource?.(value);
|
|
202
204
|
}
|
|
203
205
|
function fieldMarker(value, where, opts) {
|
|
204
|
-
if (typeof value === "string")
|
|
206
|
+
if (typeof value === "string") {
|
|
207
|
+
opts.noteRawFieldId?.(value);
|
|
205
208
|
return unsafe(value);
|
|
209
|
+
}
|
|
206
210
|
// Checked first: the owner's resolver reports a foreign lookup as unknown.
|
|
207
211
|
const foreign = opts.foreignField?.(value);
|
|
208
212
|
if (foreign !== undefined)
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
11
11
|
import { type ChildResourceScope, type TfValue } from "../../engine/tf/index.js";
|
|
12
|
+
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
12
13
|
export interface AgentViewLayoutToTfOptions {
|
|
13
14
|
readonly ownerRefName: string;
|
|
14
15
|
/** The view owner's kind; an agent view's owner is always an app. */
|
|
@@ -18,6 +19,10 @@ export interface AgentViewLayoutToTfOptions {
|
|
|
18
19
|
readonly objectId: TfValue;
|
|
19
20
|
readonly diagnostics: string[];
|
|
20
21
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
22
|
+
/** Field bag key → display name, for custom-view calc("Name") checks. */
|
|
23
|
+
readonly fieldNames?: ReadonlyMap<string, string>;
|
|
24
|
+
/** Field bag key → metadata (type, option labels, tags). */
|
|
25
|
+
readonly fieldMetadata?: ReadonlyMap<string, BuildFieldMetadata>;
|
|
21
26
|
readonly orgRefs?: OrgRefLookup;
|
|
22
27
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
23
28
|
/** Resolves an own-app field reference (view/to-tf's field resolver). */
|
|
@@ -46,6 +51,12 @@ export interface ViewBlocksToTfPolicy {
|
|
|
46
51
|
* policy.
|
|
47
52
|
*/
|
|
48
53
|
readonly editorPolicy: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Fail the build on structure / binding / reference problems the page cannot
|
|
56
|
+
* render (check.mjs Layer 1 + catalog Layer 3). Custom views set this; agent
|
|
57
|
+
* views keep soft diagnostics so a pulled broken welcome screen still builds.
|
|
58
|
+
*/
|
|
59
|
+
readonly strictStructure?: boolean;
|
|
49
60
|
}
|
|
50
61
|
/** A blocks layout → its HCL value (wrap it in `jsonencode`). */
|
|
51
62
|
export declare function viewBlocksToTf(spec: unknown, where: string, opts: AgentViewLayoutToTfOptions, policy: ViewBlocksToTfPolicy): TfValue;
|
|
@@ -6,6 +6,7 @@ import { SUB_TYPE_BY_TYPE_KEY } from "../field/types.js";
|
|
|
6
6
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
7
7
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "./types.js";
|
|
8
8
|
import { AGENT_VIEW_SPEC_FILTER_PROPS, AGENT_VIEW_SPEC_ID_PROPS, agentViewFontFamily, } from "./agent-view-layout.js";
|
|
9
|
+
import { reportStructureProblems, validateCustomViewLayout } from "./custom-view-validate.js";
|
|
9
10
|
const PLATFORM_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10
11
|
const HEX_COLOR = /^#[0-9a-fA-F]{3,8}$/;
|
|
11
12
|
const FONT_FAMILIES = new Set(Object.values(agentViewFontFamily));
|
|
@@ -68,7 +69,16 @@ export function viewBlocksToTf(spec, where, opts, policy) {
|
|
|
68
69
|
throw new EntityTfError(`${where}.root must name an element`);
|
|
69
70
|
if (elements === undefined || Object.keys(elements).length === 0)
|
|
70
71
|
throw new EntityTfError(`${where}.elements must have at least one element`);
|
|
71
|
-
|
|
72
|
+
if (policy.strictStructure) {
|
|
73
|
+
validateCustomViewLayout(doc, where, {
|
|
74
|
+
...(opts.fieldNames !== undefined ? { fieldNames: opts.fieldNames } : {}),
|
|
75
|
+
...(opts.fieldMetadata !== undefined ? { fieldMetadata: opts.fieldMetadata } : {}),
|
|
76
|
+
diagnostics: opts.diagnostics,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
checkStructure(doc["root"], elements, where, opts.diagnostics);
|
|
81
|
+
}
|
|
72
82
|
const out = {};
|
|
73
83
|
for (const [key, value] of Object.entries(doc)) {
|
|
74
84
|
if (key === "elements")
|
|
@@ -282,43 +292,8 @@ function checkStructure(root, elements, where, diagnostics) {
|
|
|
282
292
|
if (children !== undefined && !Array.isArray(children))
|
|
283
293
|
throw new EntityTfError(`${where}.elements.${id}.children must be a list of element ids`);
|
|
284
294
|
}
|
|
285
|
-
//
|
|
286
|
-
|
|
287
|
-
// still builds and round-trips; fixing it is the author's call.
|
|
288
|
-
for (const [id, raw] of Object.entries(elements)) {
|
|
289
|
-
const children = record(raw)?.["children"];
|
|
290
|
-
if (record(raw)?.["repeat"] !== undefined && (!Array.isArray(children) || children.length === 0)) {
|
|
291
|
-
diagnostics.push(`${where}.elements.${id}.repeat: a repeated element needs a child element as its template; the page will fail to render this custom view`);
|
|
292
|
-
}
|
|
293
|
-
if (!Array.isArray(children))
|
|
294
|
-
continue;
|
|
295
|
-
for (const child of children) {
|
|
296
|
-
if (typeof child !== "string" || !(child in elements)) {
|
|
297
|
-
diagnostics.push(`${where}.elements.${id}.children: "${String(child)}" is not an element; the page will fail to render this custom view`);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
const state = new Map();
|
|
302
|
-
let cycle;
|
|
303
|
-
const visit = (id, path) => {
|
|
304
|
-
if (cycle !== undefined || state.get(id) === "done")
|
|
305
|
-
return;
|
|
306
|
-
if (state.get(id) === "visiting") {
|
|
307
|
-
cycle = [...path, id].join(" → ");
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
state.set(id, "visiting");
|
|
311
|
-
const children = record(elements[id])?.["children"];
|
|
312
|
-
if (Array.isArray(children))
|
|
313
|
-
for (const child of children)
|
|
314
|
-
if (typeof child === "string" && child in elements)
|
|
315
|
-
visit(child, [...path, id]);
|
|
316
|
-
state.set(id, "done");
|
|
317
|
-
};
|
|
318
|
-
for (const id of Object.keys(elements))
|
|
319
|
-
visit(id, []);
|
|
320
|
-
if (cycle !== undefined)
|
|
321
|
-
diagnostics.push(`${where}: children form a cycle (${cycle}); the page will fail to render this custom view`);
|
|
295
|
+
// Agent views: warn so a pulled broken welcome screen still builds.
|
|
296
|
+
reportStructureProblems(root, elements, where, diagnostics);
|
|
322
297
|
}
|
|
323
298
|
function policyWarnings(type, element, where, diagnostics) {
|
|
324
299
|
const reason = !UI_EDITABLE_BLOCKS.has(type)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* check.mjs-parity structure checks for Custom managed views (#1771 / #1758).
|
|
3
|
+
* Hard structural failures (missing root/type, cycles, broken filters) fail the
|
|
4
|
+
* build as EntityTfError. Reachability and live-list selection gaps match
|
|
5
|
+
* check.mjs `warn` — they push to diagnostics so a pulled live layout still
|
|
6
|
+
* builds and plans clean (Blueprint Supplier Workspace has both). Agent views
|
|
7
|
+
* keep the softer diagnostics in checkStructure / reportStructureProblems.
|
|
8
|
+
*
|
|
9
|
+
* Layer 3 catalog checks (calc field names, option ids, tag helpers against
|
|
10
|
+
* the live App) need aspect-aware resolution; typed field refs already fail
|
|
11
|
+
* via resolveField. Syntax-only calc rules (AVG / empty COUNT) live here.
|
|
12
|
+
* TODO(#1784): consume fieldNames / fieldMetadata for Layer 3 + tag helpers.
|
|
13
|
+
*/
|
|
14
|
+
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
15
|
+
export interface CustomViewValidateOptions {
|
|
16
|
+
/** TODO(#1784): aspect-aware Layer 3 once #1770 lands Preston custom views. */
|
|
17
|
+
readonly fieldNames?: ReadonlyMap<string, string>;
|
|
18
|
+
readonly fieldMetadata?: ReadonlyMap<string, BuildFieldMetadata>;
|
|
19
|
+
/** Build warnings (check.mjs `warn`); pushed, never thrown. */
|
|
20
|
+
readonly diagnostics?: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Offline Layer 1 checks that Javier's check.mjs runs before paste.
|
|
24
|
+
* Call only for `customViews.*.layout` (strictStructure).
|
|
25
|
+
* Collects every problem, then throws once (parity with Go / check.mjs).
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateCustomViewLayout(spec: unknown, where: string, opts?: CustomViewValidateOptions): void;
|
|
28
|
+
/** Soft version used by agent views: same tree checks as today (diagnostics, not fatal). */
|
|
29
|
+
export declare function reportStructureProblems(_root: string, elements: Readonly<Record<string, unknown>>, where: string, diagnostics: string[]): void;
|