@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
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
const CONTAINERS = new Set(["PanesBlock", "StackBlock", "RowBlock", "CardBlock"]);
|
|
3
|
+
const LIST_BLOCKS = new Set(["ListCollectionBlock", "DataTableBlock"]);
|
|
4
|
+
const FILTER_GROUPS = new Set(["AND", "OR"]);
|
|
5
|
+
/** The record query ignores "not" on these, so the filter silently means the opposite. */
|
|
6
|
+
const NOT_IGNORED = new Set(["AND", "OR", "CONSECUTIVE_RANGE", "CURRENT_RANGE"]);
|
|
7
|
+
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
8
|
+
const AVG_CALL = /\bAVG\(/;
|
|
9
|
+
const EMPTY_COUNT = /COUNT\(\s*\)/;
|
|
10
|
+
const SELECTION_KEYS = ["selectedId", "selectedAspectId", "selectedHandle"];
|
|
11
|
+
function isObj(v) {
|
|
12
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
13
|
+
}
|
|
14
|
+
/** Any binding shape ($state / $bindState / $item / $index). Used for state-initial scans. */
|
|
15
|
+
function isBinding(v) {
|
|
16
|
+
return isObj(v) && ("$state" in v || "$bindState" in v || "$item" in v || "$index" in v);
|
|
17
|
+
}
|
|
18
|
+
/** Selection props must be $state / $bindState — $item / $index do not drive the details pane. */
|
|
19
|
+
function isStateBinding(v) {
|
|
20
|
+
return isObj(v) && ("$state" in v || "$bindState" in v);
|
|
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 function validateCustomViewLayout(spec, where, opts = {}) {
|
|
28
|
+
const problems = [];
|
|
29
|
+
const note = (at, msg) => {
|
|
30
|
+
problems.push(`${at}: ${msg}`);
|
|
31
|
+
};
|
|
32
|
+
/** check.mjs warn-class issues: do not fail build/pull of live layouts. */
|
|
33
|
+
const warn = (at, msg) => {
|
|
34
|
+
opts.diagnostics?.push(`${at}: ${msg}`);
|
|
35
|
+
};
|
|
36
|
+
if (!isObj(spec)) {
|
|
37
|
+
throw new EntityTfError(`${where}: must be an object`);
|
|
38
|
+
}
|
|
39
|
+
const json = JSON.stringify(spec);
|
|
40
|
+
const leftovers = [...new Set(json.match(/\{\{[^}]+\}\}/g) ?? [])];
|
|
41
|
+
if (leftovers.length > 0) {
|
|
42
|
+
note(`${where}.placeholders`, `fill these from the app's fields: ${leftovers.slice(0, 8).join(", ")}${leftovers.length > 8 ? ", ..." : ""}`);
|
|
43
|
+
}
|
|
44
|
+
const root = spec["root"];
|
|
45
|
+
const elementsRaw = spec["elements"];
|
|
46
|
+
if (typeof root !== "string" || root === "") {
|
|
47
|
+
note(`${where}.root`, "must name an element");
|
|
48
|
+
}
|
|
49
|
+
if (!isObj(elementsRaw) || Object.keys(elementsRaw).length === 0) {
|
|
50
|
+
note(`${where}.elements`, "must have at least one element");
|
|
51
|
+
throwIf(problems);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const elements = elementsRaw;
|
|
55
|
+
if (typeof root !== "string" || root === "") {
|
|
56
|
+
throwIf(problems);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!(root in elements)) {
|
|
60
|
+
note(`${where}.root`, `"${root}" is not an element`);
|
|
61
|
+
throwIf(problems);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const rootEl = elements[root];
|
|
65
|
+
const rootType = isObj(rootEl) && typeof rootEl["type"] === "string" ? rootEl["type"] : "";
|
|
66
|
+
// check.mjs warns on any non-PanesBlock root. We error only when a live list
|
|
67
|
+
// needs the details pane — chart/StackBlock dashboards without lists stay valid.
|
|
68
|
+
// A null aspectId (or repeat, below) counts as absent, as in the Go provider (#1784).
|
|
69
|
+
const hasLiveList = Object.values(elements).some((raw) => {
|
|
70
|
+
if (!isObj(raw) || !isObj(raw["props"]))
|
|
71
|
+
return false;
|
|
72
|
+
const t = raw["type"];
|
|
73
|
+
return typeof t === "string" && LIST_BLOCKS.has(t) && raw["props"]["aspectId"] != null;
|
|
74
|
+
});
|
|
75
|
+
if (hasLiveList && rootType !== "PanesBlock") {
|
|
76
|
+
note(`${where}.root`, `"${root}" must be a PanesBlock (got ${rootType === "" ? "no type" : `"${rootType}"`}); a live list needs a panes root so rows can open the details panel`);
|
|
77
|
+
}
|
|
78
|
+
else if (rootType !== "PanesBlock") {
|
|
79
|
+
// check.mjs: warn('spec.root', 'the root is usually a PanesBlock ...').
|
|
80
|
+
opts.diagnostics?.push(`${where}.root: "${root}" is ${rootType === "" ? "untyped" : `a ${rootType}`}; the root is usually a PanesBlock (needed for record lists to open the details pane)`);
|
|
81
|
+
}
|
|
82
|
+
const state = isObj(spec["state"]) ? spec["state"] : {};
|
|
83
|
+
const parents = {};
|
|
84
|
+
for (const [id, raw] of Object.entries(elements)) {
|
|
85
|
+
const elWhere = `${where}.elements.${id}`;
|
|
86
|
+
if (!isObj(raw) || typeof raw["type"] !== "string") {
|
|
87
|
+
note(elWhere, "each element needs a \"type\"");
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (!isObj(raw["props"])) {
|
|
91
|
+
note(elWhere, "each element needs a \"props\" object (use {} when empty)");
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const children = raw["children"];
|
|
95
|
+
if (children !== undefined) {
|
|
96
|
+
if (!Array.isArray(children)) {
|
|
97
|
+
note(elWhere, "\"children\" must be a list of element ids");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// Intended promotion (edk#1771): check.mjs only warns here. The page does not
|
|
101
|
+
// render these children, so EDK fails closed, same as the Go provider.
|
|
102
|
+
if (children.length > 0 && !CONTAINERS.has(raw["type"])) {
|
|
103
|
+
note(elWhere, `${raw["type"]} does not render children; only ${[...CONTAINERS].join(", ")} do`);
|
|
104
|
+
}
|
|
105
|
+
if (raw["repeat"] != null && children.length === 0) {
|
|
106
|
+
note(`${elWhere}.repeat`, "a repeated element needs a child element as its template; the page will fail to render this custom view");
|
|
107
|
+
}
|
|
108
|
+
for (const child of children) {
|
|
109
|
+
if (typeof child !== "string" || !(child in elements)) {
|
|
110
|
+
note(`${elWhere}.children`, `"${String(child)}" is not an element; the page will fail to render this custom view`);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
(parents[child] ??= []).push(id);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (raw["repeat"] != null) {
|
|
119
|
+
note(`${elWhere}.repeat`, "a repeated element needs a child element as its template; the page will fail to render this custom view");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for (const [child, list] of Object.entries(parents)) {
|
|
123
|
+
if (list.length > 1) {
|
|
124
|
+
note(`${where}.elements.${child}`, `used by several parents (${list.join(", ")}); give each placement its own element`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const reachable = new Set();
|
|
128
|
+
const visit = (id, path) => {
|
|
129
|
+
if (path.includes(id)) {
|
|
130
|
+
note(`${where}.elements.${id}`, `cycle: ${[...path, id].join(" -> ")}`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (reachable.has(id) || !(id in elements))
|
|
134
|
+
return;
|
|
135
|
+
reachable.add(id);
|
|
136
|
+
const children = elements[id]["children"];
|
|
137
|
+
if (Array.isArray(children)) {
|
|
138
|
+
for (const child of children)
|
|
139
|
+
if (typeof child === "string")
|
|
140
|
+
visit(child, [...path, id]);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
visit(root, []);
|
|
144
|
+
for (const id of Object.keys(elements)) {
|
|
145
|
+
if (!reachable.has(id)) {
|
|
146
|
+
warn(`${where}.elements.${id}`, "not reachable from the root, so it never renders");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const readState = (path) => {
|
|
150
|
+
let node = state;
|
|
151
|
+
for (const part of path.split("/").filter(Boolean)) {
|
|
152
|
+
if (!isObj(node) || !(part in node))
|
|
153
|
+
return { found: false };
|
|
154
|
+
node = node[part];
|
|
155
|
+
}
|
|
156
|
+
return { found: true, value: node };
|
|
157
|
+
};
|
|
158
|
+
const walkedState = new Set();
|
|
159
|
+
const walkFilter = (node, filterWhere) => {
|
|
160
|
+
if (node == null)
|
|
161
|
+
return;
|
|
162
|
+
if (!isObj(node)) {
|
|
163
|
+
note(filterWhere, "a filter must be an object");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (node["not"] === true && typeof node["type"] === "string" && NOT_IGNORED.has(node["type"])) {
|
|
167
|
+
const type = node["type"];
|
|
168
|
+
note(filterWhere, type === "AND" || type === "OR"
|
|
169
|
+
? `"not" is ignored on ${type} groups. Negate each child instead (not A and not B, instead of not (A or B)).`
|
|
170
|
+
: `"not" is ignored on ${type}. For "older than N", use a positive range that ends N units ago, e.g. { "type": "CONSECUTIVE_RANGE", "count": 3650, "offset": 30, "unit": "DAY" }.`);
|
|
171
|
+
}
|
|
172
|
+
if (FILTER_GROUPS.has(node["type"])) {
|
|
173
|
+
if (!Array.isArray(node["children"])) {
|
|
174
|
+
note(filterWhere, `${node["type"]} needs a "children" list`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
node["children"].forEach((c, i) => walkFilter(c, `${filterWhere}.children[${i}]`));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (typeof node["type"] !== "string") {
|
|
181
|
+
note(filterWhere, "filter node is missing \"type\"");
|
|
182
|
+
}
|
|
183
|
+
// Leaf filters without field / leftValue stay on the platform validator.
|
|
184
|
+
};
|
|
185
|
+
for (const [id, raw] of Object.entries(elements)) {
|
|
186
|
+
if (!isObj(raw) || !isObj(raw["props"]))
|
|
187
|
+
continue;
|
|
188
|
+
const elWhere = `${where}.elements.${id}`;
|
|
189
|
+
const props = raw["props"];
|
|
190
|
+
const type = raw["type"];
|
|
191
|
+
const scan = (value, path) => {
|
|
192
|
+
if (isBinding(value)) {
|
|
193
|
+
const target = value["$state"] ?? value["$bindState"];
|
|
194
|
+
if (typeof target === "string" && !target.startsWith("/host/") && !readState(target).found) {
|
|
195
|
+
note(`${elWhere}.${path}`, `binds to "${target}", which is not in spec.state. Add an initial value there.`);
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (Array.isArray(value))
|
|
200
|
+
value.forEach((v, i) => scan(v, `${path}[${i}]`));
|
|
201
|
+
else if (isObj(value))
|
|
202
|
+
for (const [k, v] of Object.entries(value))
|
|
203
|
+
scan(v, `${path}.${k}`);
|
|
204
|
+
};
|
|
205
|
+
for (const [key, value] of Object.entries(props))
|
|
206
|
+
scan(value, key);
|
|
207
|
+
if (props["filterJson"] !== undefined) {
|
|
208
|
+
if (isBinding(props["filterJson"])) {
|
|
209
|
+
const target = props["filterJson"]["$bindState"]
|
|
210
|
+
?? props["filterJson"]["$state"];
|
|
211
|
+
const initial = typeof target === "string" ? readState(target) : { found: false };
|
|
212
|
+
if (initial.found && initial.value != null && typeof target === "string" && !walkedState.has(target)) {
|
|
213
|
+
walkedState.add(target);
|
|
214
|
+
walkFilter(initial.value, `${where}.state${target.replaceAll("/", ".")}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
walkFilter(props["filterJson"], `${elWhere}.filterJson`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (typeof props["calc"] === "string") {
|
|
222
|
+
const calc = props["calc"];
|
|
223
|
+
if (AVG_CALL.test(calc))
|
|
224
|
+
note(`${elWhere}.calc`, "use AVERAGE, not AVG");
|
|
225
|
+
if (EMPTY_COUNT.test(calc))
|
|
226
|
+
note(`${elWhere}.calc`, "COUNT needs a field, e.g. COUNT(\"Title\")");
|
|
227
|
+
}
|
|
228
|
+
if (type === "ChartBlock" && (typeof props["dateFieldId"] === "string" || isObj(props["dateFieldId"]))) {
|
|
229
|
+
const range = props["range"];
|
|
230
|
+
if (typeof range === "string") {
|
|
231
|
+
const [a, b, extra] = range.split("/");
|
|
232
|
+
if (extra !== undefined || !DATE.test(a ?? "") || !DATE.test(b ?? "")) {
|
|
233
|
+
note(`${elWhere}.range`, `"${range}" is not a fixed date range. Relative presets like last90Days do not apply to date-series charts; use "YYYY-MM-DD/YYYY-MM-DD"`);
|
|
234
|
+
}
|
|
235
|
+
else if (a > b) {
|
|
236
|
+
note(`${elWhere}.range`, "start date is after end date");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Live lists on a custom view need all three selection bindings as $state /
|
|
241
|
+
// $bindState so the details pane opens. $item / $index do not count.
|
|
242
|
+
// Warn-only: pulled Blueprint layouts omit these and must still build.
|
|
243
|
+
if (LIST_BLOCKS.has(type) && props["aspectId"] != null) {
|
|
244
|
+
const missing = SELECTION_KEYS.filter((key) => !isStateBinding(props[key]));
|
|
245
|
+
if (missing.length > 0) {
|
|
246
|
+
warn(elWhere, `live list without selectedId/selectedAspectId/selectedHandle bindings; rows will not open the details pane (missing or not $state/$bindState: ${missing.join(", ")})`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
throwIf(problems);
|
|
251
|
+
}
|
|
252
|
+
function throwIf(problems) {
|
|
253
|
+
if (problems.length === 0)
|
|
254
|
+
return;
|
|
255
|
+
throw new EntityTfError(problems.join("\n"));
|
|
256
|
+
}
|
|
257
|
+
/** Soft version used by agent views: same tree checks as today (diagnostics, not fatal). */
|
|
258
|
+
export function reportStructureProblems(_root, elements, where, diagnostics) {
|
|
259
|
+
for (const [id, raw] of Object.entries(elements)) {
|
|
260
|
+
const children = isObj(raw) ? raw["children"] : undefined;
|
|
261
|
+
if (isObj(raw) && raw["repeat"] != null && (!Array.isArray(children) || children.length === 0)) {
|
|
262
|
+
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`);
|
|
263
|
+
}
|
|
264
|
+
if (!Array.isArray(children))
|
|
265
|
+
continue;
|
|
266
|
+
for (const child of children) {
|
|
267
|
+
if (typeof child !== "string" || !(child in elements)) {
|
|
268
|
+
diagnostics.push(`${where}.elements.${id}.children: "${String(child)}" is not an element; the page will fail to render this custom view`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const state = new Map();
|
|
273
|
+
let cycle;
|
|
274
|
+
const visit = (id, path) => {
|
|
275
|
+
if (cycle !== undefined || state.get(id) === "done")
|
|
276
|
+
return;
|
|
277
|
+
if (state.get(id) === "visiting") {
|
|
278
|
+
cycle = [...path, id].join(" → ");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
state.set(id, "visiting");
|
|
282
|
+
const children = isObj(elements[id]) ? elements[id]["children"] : undefined;
|
|
283
|
+
if (Array.isArray(children))
|
|
284
|
+
for (const child of children)
|
|
285
|
+
if (typeof child === "string" && child in elements)
|
|
286
|
+
visit(child, [...path, id]);
|
|
287
|
+
state.set(id, "done");
|
|
288
|
+
};
|
|
289
|
+
for (const id of Object.keys(elements))
|
|
290
|
+
visit(id, []);
|
|
291
|
+
if (cycle !== undefined)
|
|
292
|
+
diagnostics.push(`${where}: children form a cycle (${cycle}); the page will fail to render this custom view`);
|
|
293
|
+
}
|
|
@@ -21,6 +21,16 @@ export interface ViewOwner {
|
|
|
21
21
|
readonly scope?: ChildResourceScope;
|
|
22
22
|
/** Stage keys declared by the owning app, used when ei exports a raw stage UUID. */
|
|
23
23
|
readonly stageKeys?: ReadonlySet<string>;
|
|
24
|
+
/** The owning app's stage handles → real stage keys (see `stageKeyByHandle`, #1136). */
|
|
25
|
+
readonly stageKeyByHandle?: ReadonlyMap<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Keys of the fields pull extracted for this owner. A field reference whose
|
|
28
|
+
* field is not among them keeps its platform id instead of a key that
|
|
29
|
+
* builds as nothing (#1736). Undefined when the caller does not know.
|
|
30
|
+
*/
|
|
31
|
+
readonly fieldKeys?: ReadonlySet<string>;
|
|
32
|
+
/** Collects the platform ids kept for unextracted fields, so print can say they are intentional. */
|
|
33
|
+
readonly unextractedFieldIds?: Set<string>;
|
|
24
34
|
}
|
|
25
35
|
export interface ViewsFromTfResult {
|
|
26
36
|
readonly layouts: readonly NormalizedLayout[];
|
|
@@ -8,14 +8,18 @@
|
|
|
8
8
|
import { agentViewLayoutFromTf, viewBlocksFromTf, } from "./agent-view-layout-from-tf.js";
|
|
9
9
|
import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
10
10
|
import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
|
|
11
|
-
import {
|
|
11
|
+
import { canonicalImportId } from "../../engine/pull/authored-address.js";
|
|
12
|
+
import { SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
|
|
13
|
+
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
14
|
+
import { expr, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
15
|
+
import { lostStageMessage, pulledStageHandle } from "../app/stage-keys.js";
|
|
12
16
|
import { decodeForeignDataField, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
13
17
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
14
18
|
import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
|
|
15
19
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
16
20
|
import { filterFromTf, principalList } from "../access-policy/from-tf.js";
|
|
17
21
|
import { listViewDensity, } from "./build.js";
|
|
18
|
-
import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, KNOWN_AGENT_VIEW_ATTRS, KNOWN_CALENDAR_VIEW_ATTRS, KNOWN_CUSTOM_VIEW_ATTRS, KNOWN_DASHBOARD_VIEW_ATTRS, KNOWN_KANBAN_VIEW_ATTRS, KNOWN_LAYOUT_ATTRS, KNOWN_LAYOUT_SECTION_ATTRS, KNOWN_LIST_VIEW_ATTRS, KNOWN_MANAGED_VIEW_ORDER_ATTRS, LIST_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, SECTION_TYPE_FROM_WIRE, SYSTEM_FIELD_KEY_BY_ID_ATTR, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
|
|
22
|
+
import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, KNOWN_AGENT_VIEW_ATTRS, KNOWN_CALENDAR_VIEW_ATTRS, KNOWN_CUSTOM_VIEW_ATTRS, KNOWN_DASHBOARD_VIEW_ATTRS, KNOWN_KANBAN_VIEW_ATTRS, KNOWN_LAYOUT_ATTRS, KNOWN_LAYOUT_SECTION_ATTRS, KNOWN_LIST_VIEW_ATTRS, KNOWN_MANAGED_VIEW_ORDER_ATTRS, LIST_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, SECTION_TYPE_FROM_WIRE, SYSTEM_FIELD_KEY_BY_ID_ATTR, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
|
|
19
23
|
function viewFilter(value, owner, where, ctx) {
|
|
20
24
|
return value === undefined ? undefined : filterFromTf(value, {
|
|
21
25
|
type: owner.type,
|
|
@@ -131,7 +135,7 @@ function customViewFromTf(block, owner, ctx) {
|
|
|
131
135
|
if (layoutAttr !== undefined && layoutAttr !== null) {
|
|
132
136
|
if (!isTfExpr(layoutAttr) || layoutAttr.$expr !== "jsonencode")
|
|
133
137
|
return unmanaged("layout is not a jsonencode(...) expression");
|
|
134
|
-
const decoded = viewBlocksFromTf(layoutAttr.value, layoutRefOptions(owner, ctx));
|
|
138
|
+
const decoded = viewBlocksFromTf(layoutAttr.value, layoutRefOptions(owner, ctx, where));
|
|
135
139
|
if (!decoded.ok)
|
|
136
140
|
return unmanaged(decoded.reason);
|
|
137
141
|
layout = decoded.layout;
|
|
@@ -221,8 +225,8 @@ function typedFieldViewFromTf(block, owner, resourceType, knownAttrs, includeAll
|
|
|
221
225
|
return undefined;
|
|
222
226
|
}
|
|
223
227
|
const fields = [];
|
|
224
|
-
for (const value of raw) {
|
|
225
|
-
const key = fieldRefFromTf(value, owner
|
|
228
|
+
for (const [index, value] of raw.entries()) {
|
|
229
|
+
const key = fieldRefFromTf(value, owner, ctx, `${where} ${attr}[${index}]`);
|
|
226
230
|
if (key !== undefined)
|
|
227
231
|
fields.push(key);
|
|
228
232
|
}
|
|
@@ -230,7 +234,7 @@ function typedFieldViewFromTf(block, owner, resourceType, knownAttrs, includeAll
|
|
|
230
234
|
};
|
|
231
235
|
const columns = readFields("columns") ?? [];
|
|
232
236
|
const displayByField = attrs["display_by_field"] !== undefined
|
|
233
|
-
? fieldRefFromTf(attrs["display_by_field"], owner
|
|
237
|
+
? fieldRefFromTf(attrs["display_by_field"], owner, ctx, `${where} display_by_field`)
|
|
234
238
|
: undefined;
|
|
235
239
|
const allowedFilterFields = includeAllowedFilterFields ? readFields("allowed_filter_fields") : undefined;
|
|
236
240
|
const sort = managedViewSortFromTf(attrs["sort"], owner, where, ctx);
|
|
@@ -256,7 +260,7 @@ function typedFieldViewFromTf(block, owner, resourceType, knownAttrs, includeAll
|
|
|
256
260
|
* How a blocks layout's references pull: the owner and its fields, and other
|
|
257
261
|
* apps and elements and their fields through the export's data lookups.
|
|
258
262
|
*/
|
|
259
|
-
function layoutRefOptions(owner, ctx) {
|
|
263
|
+
function layoutRefOptions(owner, ctx, where) {
|
|
260
264
|
const foreignSource = (value) => {
|
|
261
265
|
for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
|
|
262
266
|
const dataLabel = dataRefLabel(value, type);
|
|
@@ -269,7 +273,8 @@ function layoutRefOptions(owner, ctx) {
|
|
|
269
273
|
};
|
|
270
274
|
return {
|
|
271
275
|
isOwnApp: (value) => resourceRefLabel(value, owner.type) === owner.label,
|
|
272
|
-
fieldKey: (value) => fieldRefFromTf(value, owner
|
|
276
|
+
fieldKey: (value) => fieldRefFromTf(value, owner, ctx, `${where} layout`),
|
|
277
|
+
noteRawFieldId: (id) => noteRawUnextractedFieldId(id, owner, ctx, `${where} layout`),
|
|
273
278
|
foreignSource,
|
|
274
279
|
foreignField: (value) => {
|
|
275
280
|
const dataLabel = dataRefLabel(value, "elementum_field");
|
|
@@ -321,7 +326,7 @@ function agentViewFromTf(block, owner, ctx) {
|
|
|
321
326
|
const filter = viewFilter(attrs["filter"], owner, where, ctx);
|
|
322
327
|
let layout;
|
|
323
328
|
if (attrs["layout"] !== undefined && attrs["layout"] !== null) {
|
|
324
|
-
const decoded = agentViewLayoutFromTf(attrs["layout"], layoutRefOptions(owner, ctx));
|
|
329
|
+
const decoded = agentViewLayoutFromTf(attrs["layout"], layoutRefOptions(owner, ctx, where));
|
|
325
330
|
if (!decoded.ok) {
|
|
326
331
|
// The code owns the layout: printing the view without it would make the
|
|
327
332
|
// next apply clear the live customization. Leave the view unmanaged.
|
|
@@ -369,8 +374,8 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
369
374
|
const sectionsAttr = attrs["sections"];
|
|
370
375
|
const sections = [];
|
|
371
376
|
if (Array.isArray(sectionsAttr)) {
|
|
372
|
-
for (const item of sectionsAttr) {
|
|
373
|
-
const section = sectionFromTf(item, owner
|
|
377
|
+
for (const [index, item] of sectionsAttr.entries()) {
|
|
378
|
+
const section = sectionFromTf(item, owner, `${where} sections[${index}]`, ctx);
|
|
374
379
|
if (section !== undefined)
|
|
375
380
|
sections.push(section);
|
|
376
381
|
}
|
|
@@ -382,12 +387,45 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
382
387
|
}
|
|
383
388
|
const stageIndex = stageIndexFromTf(attrs["stage_id"], owner.label);
|
|
384
389
|
const labelStageKey = scopedLabelToBagKey(owner.ownerTfLabel, label, scope);
|
|
385
|
-
// Layout bag keys are tsLabels
|
|
386
|
-
//
|
|
387
|
-
|
|
390
|
+
// Layout bag keys are tsLabels. An imported index that keeps punctuation
|
|
391
|
+
// ("pre-approval") uses its slug handle, which build maps back to the real
|
|
392
|
+
// key (#1136); an index with no handle keeps the resource-label key.
|
|
393
|
+
// ei names the layout resource SanitizeName(stage name), not the stage key.
|
|
394
|
+
// When that label is itself a handle for this same stage (a rename's
|
|
395
|
+
// `renamed_stage` for key `legacy_key`, `foo_bar` for key `foo__bar`), keep
|
|
396
|
+
// it as the bag key so build re-emits the same address; build still maps
|
|
397
|
+
// the handle back to the real key for stage_id.
|
|
398
|
+
const labelHandle = tsLabelToTfLabel(labelStageKey);
|
|
399
|
+
const labelStageOwner = owner.stageKeyByHandle?.get(labelHandle);
|
|
400
|
+
const labelIsStageHandle = stageIndex !== undefined && labelStageOwner === stageIndex;
|
|
401
|
+
const stageHandles = owner.stageKeyByHandle !== undefined && owner.stageKeys !== undefined
|
|
402
|
+
? { byHandle: owner.stageKeyByHandle, keys: owner.stageKeys }
|
|
403
|
+
: undefined;
|
|
404
|
+
// Never write a handle that build maps to another stage: a stage whose only
|
|
405
|
+
// handle is another stage's own key (`pre-approval` next to `pre_approval`)
|
|
406
|
+
// keeps its live layout unmanaged, with a warning (#1136).
|
|
407
|
+
const pulled = stageIndex === undefined || labelIsStageHandle ? undefined : pulledStageHandle(stageIndex, stageHandles);
|
|
408
|
+
const unmanaged = (lost) => {
|
|
409
|
+
ctx.diagnostics.push(lostStageMessage(where, stageIndex ?? "", lost, "the layout is left unmanaged"));
|
|
410
|
+
ctx.skipped.push(`${LAYOUT_RESOURCE_TYPE}.${label}`);
|
|
411
|
+
// Never authorable, so release an earlier adoption rather than destroy it.
|
|
412
|
+
ctx.releaseIfManaged?.push(`${LAYOUT_RESOURCE_TYPE}.${label}`);
|
|
413
|
+
return undefined;
|
|
414
|
+
};
|
|
415
|
+
if (pulled?.kind === "lost")
|
|
416
|
+
return unmanaged(pulled);
|
|
417
|
+
const stageHandle = stageIndex === undefined ? undefined : labelIsStageHandle ? labelHandle : pulled?.kind === "handle" ? pulled.handle : undefined;
|
|
418
|
+
const stageKey = stageHandle === undefined ? undefined : tfLabelToTsLabel(stageHandle);
|
|
419
|
+
// The fallback bag key is the layout's own label; never let it name another stage.
|
|
420
|
+
if (stageIndex !== undefined && stageKey === undefined && labelStageOwner !== undefined && labelStageOwner !== stageIndex) {
|
|
421
|
+
return unmanaged({ handle: labelHandle, owner: labelStageOwner });
|
|
422
|
+
}
|
|
423
|
+
if (stageIndex !== undefined && stageHandle !== undefined && labelStageOwner !== undefined && labelStageOwner !== stageIndex) {
|
|
424
|
+
ctx.diagnostics.push(`${where}: the layout's label "${labelHandle}" is a handle of stage "${labelStageOwner}", but it belongs to stage "${stageIndex}"; it is re-addressed under "${stageHandle}", so the next plan destroys and recreates it (#1136)`);
|
|
425
|
+
}
|
|
388
426
|
const canInferStageKey = typeof attrs["stage_id"] === "string" && owner.stageKeys?.has(labelStageKey) === true;
|
|
389
427
|
if (stageIndex !== undefined && stageKey === undefined) {
|
|
390
|
-
ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(stageIndex)}
|
|
428
|
+
ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(stageIndex)} has no terraform label handle; using the layout's own label "${label}" as the stage key`);
|
|
391
429
|
}
|
|
392
430
|
else if (stageKey === undefined && !canInferStageKey) {
|
|
393
431
|
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)`);
|
|
@@ -395,8 +433,8 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
395
433
|
const sectionsAttr = attrs["sections"];
|
|
396
434
|
const sections = [];
|
|
397
435
|
if (Array.isArray(sectionsAttr)) {
|
|
398
|
-
for (const item of sectionsAttr) {
|
|
399
|
-
const section = sectionFromTf(item, owner
|
|
436
|
+
for (const [index, item] of sectionsAttr.entries()) {
|
|
437
|
+
const section = sectionFromTf(item, owner, `${where} sections[${index}]`, ctx);
|
|
400
438
|
if (section !== undefined)
|
|
401
439
|
sections.push(section);
|
|
402
440
|
}
|
|
@@ -414,7 +452,9 @@ function stageIndexFromTf(v, ownerLabel) {
|
|
|
414
452
|
const seg = v.path[0];
|
|
415
453
|
return v.path.length === 1 && typeof seg === "object" && "index" in seg ? seg.index : undefined;
|
|
416
454
|
}
|
|
417
|
-
function sectionFromTf(raw,
|
|
455
|
+
function sectionFromTf(raw, owner, where, ctx) {
|
|
456
|
+
const ownerTfLabel = owner.ownerTfLabel;
|
|
457
|
+
const scope = owner.scope ?? "app";
|
|
418
458
|
const rec = plainObject(raw);
|
|
419
459
|
if (rec === undefined) {
|
|
420
460
|
ctx.diagnostics.push(`${where}: a sections entry has an unrecognized shape; dropped`);
|
|
@@ -460,7 +500,7 @@ function sectionFromTf(raw, ownerLabel, ownerTfLabel, scope, where, ctx) {
|
|
|
460
500
|
const fields = [];
|
|
461
501
|
const widgets = [];
|
|
462
502
|
const widgetAts = {};
|
|
463
|
-
for (const f of fieldIds) {
|
|
503
|
+
for (const [index, f] of fieldIds.entries()) {
|
|
464
504
|
const widgetLabel = resourceRefLabel(f, WIDGET_RESOURCE_TYPE);
|
|
465
505
|
if (widgetLabel !== undefined) {
|
|
466
506
|
const key = scopedLabelToBagKey(ownerTfLabel, widgetLabel, scope);
|
|
@@ -470,7 +510,7 @@ function sectionFromTf(raw, ownerLabel, ownerTfLabel, scope, where, ctx) {
|
|
|
470
510
|
widgetAts[key] = fields.length;
|
|
471
511
|
continue;
|
|
472
512
|
}
|
|
473
|
-
const key = fieldRefFromTf(f,
|
|
513
|
+
const key = fieldRefFromTf(f, owner, ctx, `${where} field_ids[${index}]`);
|
|
474
514
|
if (key !== undefined)
|
|
475
515
|
fields.push(key);
|
|
476
516
|
}
|
|
@@ -488,10 +528,13 @@ function sectionFromTf(raw, ownerLabel, ownerTfLabel, scope, where, ctx) {
|
|
|
488
528
|
return section;
|
|
489
529
|
}
|
|
490
530
|
/** A `field_ids`/`columns` entry → a system-field key or a custom field's bag key. */
|
|
491
|
-
function fieldRefFromTf(v,
|
|
492
|
-
const
|
|
531
|
+
function fieldRefFromTf(v, owner, ctx, site) {
|
|
532
|
+
const ownerLabel = owner.label;
|
|
533
|
+
const fieldKey = fieldKeyFromTfValue(v, tfLabelToTsLabel(ownerLabel), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
493
534
|
if (fieldKey !== undefined)
|
|
494
|
-
return fieldKey;
|
|
535
|
+
return unextractedFieldId(v, fieldKey, owner, ctx, site) ?? fieldKey;
|
|
536
|
+
if (typeof v === "string" && importedUnextractedFieldId(v, owner, ctx, site) !== undefined)
|
|
537
|
+
return v;
|
|
495
538
|
if (typeof v === "string" && v !== "") {
|
|
496
539
|
// The field itself couldn't be resolved to a portable reference at all
|
|
497
540
|
// - ei's own export already fell back to a bare platform-id string here
|
|
@@ -520,6 +563,98 @@ function fieldRefFromTf(v, ownerLabel, ownerTfLabel, scope, ctx) {
|
|
|
520
563
|
ctx.diagnostics.push(`field reference ${JSON.stringify(v)} does not resolve to a known field; dropped`);
|
|
521
564
|
return undefined;
|
|
522
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* The platform id of a field reference whose field pull did not extract for
|
|
568
|
+
* this owner (#1736). Its key prints as nothing, so build drops the column
|
|
569
|
+
* or section field and plan removes it. The id keeps it: a raw platform id
|
|
570
|
+
* as is (a re-pull of this fix's own output), or a resource reference's
|
|
571
|
+
* import id. Print marks it as intentional through `unextractedFieldIds`.
|
|
572
|
+
* Undefined when the field was extracted.
|
|
573
|
+
*/
|
|
574
|
+
function unextractedFieldId(v, fieldKey, owner, ctx, site) {
|
|
575
|
+
if (owner.fieldKeys === undefined || owner.fieldKeys.has(fieldKey))
|
|
576
|
+
return undefined;
|
|
577
|
+
// A system key is never in the extracted fields bag (element audit keys
|
|
578
|
+
// never are; an app's only when system_field_config names it), yet print
|
|
579
|
+
// and build turn it into the owner's system-field local. It stays a key.
|
|
580
|
+
if (isOwnerSystemFieldKey(fieldKey, owner))
|
|
581
|
+
return undefined;
|
|
582
|
+
let field;
|
|
583
|
+
let id;
|
|
584
|
+
if (typeof v === "string") {
|
|
585
|
+
field = `"${fieldKey}"`;
|
|
586
|
+
id = PLATFORM_ID.test(v) ? v : undefined;
|
|
587
|
+
}
|
|
588
|
+
else if (isTfExpr(v) && v.$expr === "resource-attr") {
|
|
589
|
+
field = `${v.type}.${v.label}`;
|
|
590
|
+
const importId = ctx.importId(field);
|
|
591
|
+
const canonical = importId === undefined ? undefined : canonicalImportId(importId);
|
|
592
|
+
id = canonical !== undefined && PLATFORM_ID.test(canonical) ? canonical : undefined;
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
reportUnextractedField(ctx, field, id, site);
|
|
598
|
+
if (id !== undefined)
|
|
599
|
+
owner.unextractedFieldIds?.add(id);
|
|
600
|
+
return id;
|
|
601
|
+
}
|
|
602
|
+
const ELEMENT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
|
|
603
|
+
function isOwnerSystemFieldKey(fieldKey, owner) {
|
|
604
|
+
return (owner.scope === "element" ? ELEMENT_SYSTEM_FIELD_KEY_SET : SYSTEM_FIELD_KEY_SET).has(fieldKey);
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* A raw platform id this owner's export imports as one of its own fields
|
|
608
|
+
* that pull did not extract: a re-pull of an id #1736 kept. Undefined
|
|
609
|
+
* otherwise.
|
|
610
|
+
*/
|
|
611
|
+
function importedUnextractedFieldId(v, owner, ctx, site) {
|
|
612
|
+
if (!PLATFORM_ID.test(v))
|
|
613
|
+
return undefined;
|
|
614
|
+
const imported = ctx.importedResource?.(v);
|
|
615
|
+
if (imported === undefined)
|
|
616
|
+
return undefined;
|
|
617
|
+
const importedRef = expr.resourceAttr(imported.type, imported.label, ["id"]);
|
|
618
|
+
const importedKey = fieldKeyFromTfValue(importedRef, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
619
|
+
if (importedKey === undefined)
|
|
620
|
+
return undefined;
|
|
621
|
+
return unextractedFieldId(importedRef, importedKey, owner, ctx, site) === v ? v : undefined;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Records a raw platform id that a caller keeps as is (a sort order, a blocks
|
|
625
|
+
* layout id prop) when it names a field pull did not extract, so print marks
|
|
626
|
+
* it as intentional too (#1736). The caller's value does not change.
|
|
627
|
+
*/
|
|
628
|
+
function noteRawUnextractedFieldId(v, owner, ctx, site) {
|
|
629
|
+
if (!PLATFORM_ID.test(v))
|
|
630
|
+
return;
|
|
631
|
+
const fieldKey = fieldKeyFromTfValue(v, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
632
|
+
if (fieldKey !== undefined)
|
|
633
|
+
unextractedFieldId(v, fieldKey, owner, ctx, site);
|
|
634
|
+
else
|
|
635
|
+
importedUnextractedFieldId(v, owner, ctx, site);
|
|
636
|
+
}
|
|
637
|
+
/** One diagnostic per unextracted field per pull, naming every view site that references it (#1736). */
|
|
638
|
+
const unextractedFieldReports = new WeakMap();
|
|
639
|
+
function reportUnextractedField(ctx, field, id, site) {
|
|
640
|
+
let byField = unextractedFieldReports.get(ctx.diagnostics);
|
|
641
|
+
if (byField === undefined) {
|
|
642
|
+
byField = new Map();
|
|
643
|
+
unextractedFieldReports.set(ctx.diagnostics, byField);
|
|
644
|
+
}
|
|
645
|
+
let report = byField.get(field);
|
|
646
|
+
if (report === undefined) {
|
|
647
|
+
report = { index: ctx.diagnostics.length, sites: [] };
|
|
648
|
+
byField.set(field, report);
|
|
649
|
+
ctx.diagnostics.push("");
|
|
650
|
+
}
|
|
651
|
+
if (!report.sites.includes(site))
|
|
652
|
+
report.sites.push(site);
|
|
653
|
+
const sites = report.sites.join(", ");
|
|
654
|
+
ctx.diagnostics[report.index] = id !== undefined
|
|
655
|
+
? `field ${field} was not extracted by pull; kept as its platform id ${id} at ${sites}, so plan keeps it in the view (dropping it would make plan remove it)`
|
|
656
|
+
: `field ${field} was not extracted by pull and has no platform id; ${sites} builds without it, so plan would remove it from the view`;
|
|
657
|
+
}
|
|
523
658
|
function listViewFromTf(block, owner, ctx) {
|
|
524
659
|
const label = block.label;
|
|
525
660
|
if (label === undefined || label === "") {
|
|
@@ -539,8 +674,8 @@ function listViewFromTf(block, owner, ctx) {
|
|
|
539
674
|
const columnsAttr = attrs["columns"];
|
|
540
675
|
const columns = [];
|
|
541
676
|
if (Array.isArray(columnsAttr)) {
|
|
542
|
-
for (const c of columnsAttr) {
|
|
543
|
-
const key = fieldRefFromTf(c, owner
|
|
677
|
+
for (const [index, c] of columnsAttr.entries()) {
|
|
678
|
+
const key = fieldRefFromTf(c, owner, ctx, `${where} columns[${index}]`);
|
|
544
679
|
if (key !== undefined)
|
|
545
680
|
columns.push(key);
|
|
546
681
|
}
|
|
@@ -606,9 +741,12 @@ export function managedViewSortFromTf(value, owner, where, ctx) {
|
|
|
606
741
|
return undefined;
|
|
607
742
|
}
|
|
608
743
|
const rawField = order["field"];
|
|
744
|
+
const site = `${where} sort.orders[${index}].field`;
|
|
745
|
+
if (typeof rawField === "string")
|
|
746
|
+
noteRawUnextractedFieldId(rawField, owner, ctx, site);
|
|
609
747
|
const field = typeof rawField === "string"
|
|
610
748
|
? (PLATFORM_ID.test(rawField) ? rawField : undefined)
|
|
611
|
-
: fieldRefFromTf(rawField, owner
|
|
749
|
+
: fieldRefFromTf(rawField, owner, ctx, site);
|
|
612
750
|
if (field === undefined) {
|
|
613
751
|
ctx.diagnostics.push(`${where}: sort.orders[${index}].field does not resolve to a field; dropped sort`);
|
|
614
752
|
return undefined;
|
|
@@ -119,6 +119,8 @@ export interface ViewToTfOptions {
|
|
|
119
119
|
readonly objectId: TfValue;
|
|
120
120
|
/** App stage terraform labels declared by systemFields.stage.options. */
|
|
121
121
|
readonly stageTfLabels?: ReadonlySet<string>;
|
|
122
|
+
/** Stage handle tfLabel → real `stage_ids_by_key` key, when they differ (#1136). */
|
|
123
|
+
readonly stageKeyByTfLabel?: ReadonlyMap<string, string>;
|
|
122
124
|
/** Declared sibling dashboard keys, for fail-fast dashboard-view references. */
|
|
123
125
|
readonly dashboardKeys?: ReadonlySet<string>;
|
|
124
126
|
readonly orgRefs?: OrgRefLookup;
|
|
@@ -126,6 +128,10 @@ export interface ViewToTfOptions {
|
|
|
126
128
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
127
129
|
/** Known emitted field addresses keyed by field bag key, for robust reference resolution. */
|
|
128
130
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
131
|
+
/** Field bag key → display name (custom-view calc checks). */
|
|
132
|
+
readonly fieldNames?: ReadonlyMap<string, string>;
|
|
133
|
+
/** Field bag key → metadata (custom-view tag / calc checks). */
|
|
134
|
+
readonly fieldMetadata?: ReadonlyMap<string, import("../../graph/types.js").BuildFieldMetadata>;
|
|
129
135
|
/** Declared sibling widget keys, for typed classic-layout placement. */
|
|
130
136
|
readonly widgetKeys?: ReadonlySet<string>;
|
|
131
137
|
/** Degradations land here — reported by the caller, never silent. */
|