@elementumai/edk 0.9.19 → 0.9.20
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 +146 -6
- package/dist-sdk/src/catalog/factories.d.ts +24 -1
- package/dist-sdk/src/catalog/factories.js +30 -0
- package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
- package/dist-sdk/src/catalog/from-authoring.js +34 -9
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/render.js +6 -6
- package/dist-sdk/src/catalog/token.js +7 -0
- package/dist-sdk/src/catalog/types.d.ts +34 -1
- package/dist-sdk/src/catalog/types.js +11 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +39 -3
- package/dist-sdk/src/core/triggers/on-demand.js +10 -2
- package/dist-sdk/src/engine/build/context.d.ts +1 -1
- package/dist-sdk/src/engine/ei/run.d.ts +149 -0
- package/dist-sdk/src/engine/ei/run.js +1132 -0
- package/dist-sdk/src/engine/logging.d.ts +17 -0
- package/dist-sdk/src/engine/logging.js +18 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
- package/dist-sdk/src/engine/pull/ref-only.js +10 -7
- package/dist-sdk/src/engine/pull/result-output.d.ts +6 -0
- package/dist-sdk/src/engine/pull/result-output.js +87 -3
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +6 -0
- package/dist-sdk/src/engine/tf/labels.js +9 -0
- package/dist-sdk/src/engine/tf/model.d.ts +22 -1
- package/dist-sdk/src/engine/tf/parse.js +92 -4
- package/dist-sdk/src/engine/tf/render.d.ts +4 -2
- package/dist-sdk/src/engine/tf/render.js +41 -7
- package/dist-sdk/src/engine/validation.d.ts +39 -0
- package/dist-sdk/src/engine/validation.js +85 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +5 -2
- package/dist-sdk/src/entities/agent/build.d.ts +4 -16
- package/dist-sdk/src/entities/agent/build.js +40 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +4 -2
- package/dist-sdk/src/entities/agent/to-tf.js +6 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +7 -1
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +27 -5
- package/dist-sdk/src/entities/app/build.d.ts +89 -20
- package/dist-sdk/src/entities/app/build.js +51 -6
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +16 -0
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -2
- package/dist-sdk/src/entities/app/index.d.ts +6 -6
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +5 -2
- package/dist-sdk/src/entities/app/to-tf.js +19 -11
- package/dist-sdk/src/entities/automation/build.d.ts +47 -5
- package/dist-sdk/src/entities/automation/build.js +137 -20
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +24 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +314 -39
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +428 -48
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.js +37 -8
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +17 -0
- package/dist-sdk/src/entities/automation/script-code.js +91 -5
- package/dist-sdk/src/entities/automation/system-ref-name.js +4 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +9 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +24 -2
- package/dist-sdk/src/entities/automation/tasks.js +38 -9
- package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/automation/to-tf.js +489 -83
- package/dist-sdk/src/entities/automation/triggers.d.ts +4 -2
- package/dist-sdk/src/entities/automation/triggers.js +4 -0
- package/dist-sdk/src/entities/chart/to-tf.js +10 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +24 -31
- package/dist-sdk/src/entities/element/build.d.ts +25 -13
- package/dist-sdk/src/entities/element/build.js +4 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/element/from-tf.js +58 -1
- package/dist-sdk/src/entities/element/index.d.ts +5 -3
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +9 -3
- package/dist-sdk/src/entities/element/to-tf.js +8 -2
- package/dist-sdk/src/entities/field/build.d.ts +14 -1
- package/dist-sdk/src/entities/field/build.js +3 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/field/from-tf.js +39 -1
- package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
- package/dist-sdk/src/entities/field/media-types.js +30 -0
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +23 -2
- package/dist-sdk/src/entities/field/to-tf.js +130 -14
- package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
- package/dist-sdk/src/entities/file-reader/module.js +1 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
- package/dist-sdk/src/entities/file-reader/types.js +1 -1
- package/dist-sdk/src/entities/portal/build.d.ts +26 -0
- package/dist-sdk/src/entities/portal/build.js +37 -0
- package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
- package/dist-sdk/src/entities/portal/from-tf.js +75 -0
- package/dist-sdk/src/entities/portal/index.d.ts +1 -0
- package/dist-sdk/src/entities/portal/index.js +1 -0
- package/dist-sdk/src/entities/portal/module.d.ts +3 -0
- package/dist-sdk/src/entities/portal/module.js +28 -0
- package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/portal/to-tf.js +73 -0
- package/dist-sdk/src/entities/portal/types.d.ts +1 -0
- package/dist-sdk/src/entities/portal/types.js +1 -0
- package/dist-sdk/src/entities/relationship/module.js +2 -0
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
- package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
- package/dist-sdk/src/entities/search-table/module.js +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
- package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
- package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +17 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +8 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.js +14 -4
- package/dist-sdk/src/entities/shared/filters/print.js +17 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +5 -1
- package/dist-sdk/src/entities/shared/filters/types.d.ts +9 -1
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -5
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +2 -1
- package/dist-sdk/src/entities/skill/from-tf.js +66 -13
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
- package/dist-sdk/src/entities/skill/to-tf.js +14 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +8 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +27 -5
- package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
- package/dist-sdk/src/entities/table/catalog.js +66 -0
- package/dist-sdk/src/entities/table/module.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +2 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -9
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +71 -18
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +19 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +82 -10
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +53 -23
- package/dist-sdk/src/entities/view/agent-view-layout.js +1 -1
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +124 -12
- package/dist-sdk/src/entities/view/module.js +30 -3
- package/dist-sdk/src/entities/view/to-tf.d.ts +14 -1
- package/dist-sdk/src/entities/view/to-tf.js +67 -10
- package/dist-sdk/src/entities/view/types.d.ts +4 -15
- package/dist-sdk/src/entities/view/types.js +15 -15
- package/dist-sdk/src/entities/widget/build.d.ts +16 -1
- package/dist-sdk/src/entities/widget/build.js +11 -1
- package/dist-sdk/src/entities/widget/to-tf.js +34 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +16 -5
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +11 -0
- package/dist-sdk/src/graph/index.js +21 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +55 -2
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +10 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pull:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Pull: blocks layouts → normalized values the printer turns back into source.
|
|
3
|
+
* `elementum_agent_view.layout` → `agentViews.<key>.layout`;
|
|
4
|
+
* `elementum_custom_view.layout` → `customViews.<key>.layout` (see
|
|
5
|
+
* `viewBlocksFromTf`). References become typed markers at the per-block id
|
|
6
|
+
* positions, inside nested filters and inside actions; raw platform ids there
|
|
7
|
+
* become `unsafePlatformId(...)`. A layout this cannot represent makes the
|
|
8
|
+
* whole view unmanaged (skipped), never silently dropped: the code owns the
|
|
9
|
+
* layout, so a dropped detail would be cleared on the next apply.
|
|
8
10
|
*/
|
|
9
11
|
import { isTfExpr } from "../../engine/tf/index.js";
|
|
10
12
|
import { AGENT_VIEW_SPEC_FILTER_PROPS, AGENT_VIEW_SPEC_ID_PROPS } from "./agent-view-layout.js";
|
|
@@ -67,29 +69,42 @@ function decodeLayout(value, opts) {
|
|
|
67
69
|
}
|
|
68
70
|
return layout;
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
/** A blocks layout (the value inside `jsonencode(...)`) → plain JSON with `AgentViewSpecMarker` objects at reference positions. */
|
|
73
|
+
export function viewBlocksFromTf(value, opts) {
|
|
74
|
+
try {
|
|
75
|
+
return { ok: true, layout: decodeSpec(value, opts, "layout") };
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error instanceof Unrepresentable)
|
|
79
|
+
return { ok: false, reason: error.message };
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function decodeSpec(value, opts, root = "custom_view") {
|
|
71
84
|
const spec = plain(value);
|
|
72
85
|
if (spec === undefined)
|
|
73
|
-
throw new Unrepresentable(
|
|
86
|
+
throw new Unrepresentable(`${root} is not an object`);
|
|
74
87
|
const out = {};
|
|
75
88
|
for (const [key, child] of Object.entries(spec)) {
|
|
76
89
|
if (key !== "elements") {
|
|
77
|
-
out[key] = literal(child,
|
|
90
|
+
out[key] = literal(child, `${root}.${key}`);
|
|
78
91
|
continue;
|
|
79
92
|
}
|
|
80
93
|
const elements = plain(child);
|
|
81
94
|
if (elements === undefined)
|
|
82
|
-
throw new Unrepresentable(
|
|
95
|
+
throw new Unrepresentable(`${root}.elements is not an object`);
|
|
83
96
|
const outElements = {};
|
|
84
97
|
for (const [id, rawElement] of Object.entries(elements)) {
|
|
85
98
|
const element = plain(rawElement);
|
|
86
99
|
if (element === undefined)
|
|
87
|
-
throw new Unrepresentable(
|
|
100
|
+
throw new Unrepresentable(`${root}.elements.${id} is not an object`);
|
|
88
101
|
const type = typeof element["type"] === "string" ? element["type"] : "";
|
|
89
102
|
const outElement = {};
|
|
90
103
|
for (const [elKey, elValue] of Object.entries(element)) {
|
|
91
|
-
const where =
|
|
92
|
-
outElement[elKey] = elKey === "props"
|
|
104
|
+
const where = `${root}.elements.${id}.${elKey}`;
|
|
105
|
+
outElement[elKey] = elKey === "props"
|
|
106
|
+
? decodeProps(type, elValue, where, opts)
|
|
107
|
+
: elKey === "on" ? deepSourceMarkers(elValue, where, opts) : literal(elValue, where);
|
|
93
108
|
}
|
|
94
109
|
outElements[id] = outElement;
|
|
95
110
|
}
|
|
@@ -119,7 +134,11 @@ function decodeProps(type, value, where, opts) {
|
|
|
119
134
|
return literal(item, `${propWhere}[${i}]`);
|
|
120
135
|
return Object.fromEntries(Object.entries(button).map(([bKey, bValue]) => [
|
|
121
136
|
bKey,
|
|
122
|
-
bKey === "viewId" && typeof bValue === "string" && bValue !== ""
|
|
137
|
+
bKey === "viewId" && typeof bValue === "string" && bValue !== ""
|
|
138
|
+
? unsafe(bValue)
|
|
139
|
+
: bKey === "onPress"
|
|
140
|
+
? deepSourceMarkers(bValue, `${propWhere}[${i}].${bKey}`, opts)
|
|
141
|
+
: literal(bValue, `${propWhere}[${i}].${bKey}`),
|
|
123
142
|
]));
|
|
124
143
|
});
|
|
125
144
|
}
|
|
@@ -131,9 +150,7 @@ function decodeProps(type, value, where, opts) {
|
|
|
131
150
|
}
|
|
132
151
|
function deepRefs(value, where, opts) {
|
|
133
152
|
if (isTfExpr(value)) {
|
|
134
|
-
|
|
135
|
-
return { __specRef: "app" };
|
|
136
|
-
return fieldMarker(value, where, opts);
|
|
153
|
+
return sourceRef(value, opts) ?? fieldMarker(value, where, opts);
|
|
137
154
|
}
|
|
138
155
|
if (isPlatformId(value))
|
|
139
156
|
return unsafe(value);
|
|
@@ -144,6 +161,27 @@ function deepRefs(value, where, opts) {
|
|
|
144
161
|
return Object.fromEntries(Object.entries(rec).map(([key, child]) => [key, deepRefs(child, `${where}.${key}`, opts)]));
|
|
145
162
|
return value;
|
|
146
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Actions (`on` events, button `onPress`): only app or element references may
|
|
166
|
+
* appear. A platform id export could not resolve becomes unsafePlatformId(...);
|
|
167
|
+
* other strings stay plain.
|
|
168
|
+
*/
|
|
169
|
+
function deepSourceMarkers(value, where, opts) {
|
|
170
|
+
if (isTfExpr(value)) {
|
|
171
|
+
const ref = sourceRef(value, opts);
|
|
172
|
+
if (ref === undefined)
|
|
173
|
+
throw new Unrepresentable(`${where} holds a reference the EDK cannot represent inside an action`);
|
|
174
|
+
return ref;
|
|
175
|
+
}
|
|
176
|
+
if (isPlatformId(value))
|
|
177
|
+
return unsafe(value);
|
|
178
|
+
if (Array.isArray(value))
|
|
179
|
+
return value.map((item, i) => deepSourceMarkers(item, `${where}[${i}]`, opts));
|
|
180
|
+
const rec = plain(value);
|
|
181
|
+
if (rec !== undefined)
|
|
182
|
+
return Object.fromEntries(Object.entries(rec).map(([key, child]) => [key, deepSourceMarkers(child, `${where}.${key}`, opts)]));
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
147
185
|
// Any non-empty string at an id position — a platform id, or a value the
|
|
148
186
|
// platform accepted that is not one — prints as unsafePlatformId(...), which
|
|
149
187
|
// build passes through unchanged, so pull → build round-trips exactly. An
|
|
@@ -151,13 +189,24 @@ function deepRefs(value, where, opts) {
|
|
|
151
189
|
function appMarker(value, where, opts) {
|
|
152
190
|
if (typeof value === "string")
|
|
153
191
|
return unsafe(value);
|
|
192
|
+
const ref = sourceRef(value, opts);
|
|
193
|
+
if (ref === undefined)
|
|
194
|
+
throw new Unrepresentable(`${where} references an app the EDK cannot represent here`);
|
|
195
|
+
return ref;
|
|
196
|
+
}
|
|
197
|
+
/** The owner, or another app or element through its data lookup. */
|
|
198
|
+
function sourceRef(value, opts) {
|
|
154
199
|
if (opts.isOwnApp(value))
|
|
155
200
|
return { __specRef: "app" };
|
|
156
|
-
|
|
201
|
+
return opts.foreignSource?.(value);
|
|
157
202
|
}
|
|
158
203
|
function fieldMarker(value, where, opts) {
|
|
159
204
|
if (typeof value === "string")
|
|
160
205
|
return unsafe(value);
|
|
206
|
+
// Checked first: the owner's resolver reports a foreign lookup as unknown.
|
|
207
|
+
const foreign = opts.foreignField?.(value);
|
|
208
|
+
if (foreign !== undefined)
|
|
209
|
+
return foreign;
|
|
161
210
|
const key = opts.fieldKey(value);
|
|
162
211
|
if (key === undefined)
|
|
163
212
|
throw new Unrepresentable(`${where} references a field the EDK cannot represent here`);
|
|
@@ -222,3 +271,7 @@ export function collectAgentViewLayoutFieldKeys(layout) {
|
|
|
222
271
|
walk(layout?.customView);
|
|
223
272
|
return keys;
|
|
224
273
|
}
|
|
274
|
+
/** Own field bag keys a pulled blocks layout references (for hoisting their consts). */
|
|
275
|
+
export function collectViewBlocksFieldKeys(layout) {
|
|
276
|
+
return collectAgentViewLayoutFieldKeys(layout === undefined ? undefined : { customView: layout });
|
|
277
|
+
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Build: `agentViews.<key>.layout` → the `layout`
|
|
3
|
-
* `elementum_agent_view
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Build: blocks layouts → HCL. `agentViews.<key>.layout` → the `layout`
|
|
3
|
+
* attribute of `elementum_agent_view` (its custom view is a blocks layout);
|
|
4
|
+
* `customViews.<key>.layout` → the `layout` attribute of
|
|
5
|
+
* `elementum_custom_view` (see `viewBlocksToTf`). Platform ids resolve from
|
|
6
|
+
* typed references at the per-block id positions, inside nested filters and
|
|
7
|
+
* inside actions; a structurally broken layout fails the build, because
|
|
8
|
+
* dropping it would make apply clear the live one.
|
|
6
9
|
*/
|
|
7
10
|
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
8
11
|
import { type ChildResourceScope, type TfValue } from "../../engine/tf/index.js";
|
|
9
12
|
export interface AgentViewLayoutToTfOptions {
|
|
10
13
|
readonly ownerRefName: string;
|
|
14
|
+
/** The view owner's kind; an agent view's owner is always an app. */
|
|
15
|
+
readonly ownerKind?: "app" | "element";
|
|
11
16
|
readonly ownerTfLabel: string;
|
|
12
17
|
readonly scope: ChildResourceScope;
|
|
13
18
|
readonly objectId: TfValue;
|
|
@@ -34,3 +39,13 @@ export interface AppAgentViewLayoutWire {
|
|
|
34
39
|
readonly customView?: unknown;
|
|
35
40
|
}
|
|
36
41
|
export declare function agentViewLayoutToTf(layout: AppAgentViewLayoutWire, where: string, opts: AgentViewLayoutToTfOptions): TfValue;
|
|
42
|
+
export interface ViewBlocksToTfPolicy {
|
|
43
|
+
/**
|
|
44
|
+
* Warn about blocks the agent view admin UI's JSON editor will not re-apply
|
|
45
|
+
* (its managed-view authoring policy). The Custom view builder has no such
|
|
46
|
+
* policy.
|
|
47
|
+
*/
|
|
48
|
+
readonly editorPolicy: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** A blocks layout → its HCL value (wrap it in `jsonencode`). */
|
|
51
|
+
export declare function viewBlocksToTf(spec: unknown, where: string, opts: AgentViewLayoutToTfOptions, policy: ViewBlocksToTfPolicy): TfValue;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
2
2
|
import { EntityTfError } from "../../engine/entity.js";
|
|
3
3
|
import { expr } from "../../engine/tf/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { authoredFieldKeysFromPayload, fieldRefToTfValue } from "../field/to-tf.js";
|
|
5
|
+
import { SUB_TYPE_BY_TYPE_KEY } from "../field/types.js";
|
|
6
|
+
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
5
7
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "./types.js";
|
|
6
8
|
import { AGENT_VIEW_SPEC_FILTER_PROPS, AGENT_VIEW_SPEC_ID_PROPS, agentViewFontFamily, } from "./agent-view-layout.js";
|
|
7
9
|
const PLATFORM_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -52,11 +54,12 @@ export function agentViewLayoutToTf(layout, where, opts) {
|
|
|
52
54
|
attrs["font_family"] = branding.fontFamily;
|
|
53
55
|
}
|
|
54
56
|
if (layout.customView !== undefined) {
|
|
55
|
-
attrs["custom_view"] = expr.jsonencode(
|
|
57
|
+
attrs["custom_view"] = expr.jsonencode(viewBlocksToTf(layout.customView, `${where}.customView`, opts, { editorPolicy: true }));
|
|
56
58
|
}
|
|
57
59
|
return attrs;
|
|
58
60
|
}
|
|
59
|
-
|
|
61
|
+
/** A blocks layout → its HCL value (wrap it in `jsonencode`). */
|
|
62
|
+
export function viewBlocksToTf(spec, where, opts, policy) {
|
|
60
63
|
const doc = record(spec);
|
|
61
64
|
if (doc === undefined)
|
|
62
65
|
throw new EntityTfError(`${where} must be an object`);
|
|
@@ -77,12 +80,15 @@ function customViewToTf(spec, where, opts) {
|
|
|
77
80
|
const element = record(raw);
|
|
78
81
|
const elementWhere = `${where}.elements.${id}`;
|
|
79
82
|
const type = typeof element["type"] === "string" ? element["type"] : "";
|
|
80
|
-
|
|
83
|
+
if (policy.editorPolicy)
|
|
84
|
+
policyWarnings(type, element, elementWhere, opts.diagnostics);
|
|
81
85
|
const outElement = {};
|
|
82
86
|
for (const [key, value] of Object.entries(element)) {
|
|
83
87
|
outElement[key] = key === "props"
|
|
84
88
|
? propsToTf(type, value, `${elementWhere}.props`, opts)
|
|
85
|
-
:
|
|
89
|
+
: key === "on"
|
|
90
|
+
? deepSourceRefs(value, `${elementWhere}.on`, opts)
|
|
91
|
+
: literal(value, `${elementWhere}.${key}`, opts);
|
|
86
92
|
}
|
|
87
93
|
outElements[id] = outElement;
|
|
88
94
|
}
|
|
@@ -124,10 +130,33 @@ function buttonToTf(item, where, opts) {
|
|
|
124
130
|
const out = {};
|
|
125
131
|
for (const [key, value] of Object.entries(rec)) {
|
|
126
132
|
const id = key === "viewId" ? unsafeId(value) : undefined;
|
|
127
|
-
out[key] = id !== undefined
|
|
133
|
+
out[key] = id !== undefined
|
|
134
|
+
? id
|
|
135
|
+
: key === "onPress"
|
|
136
|
+
? deepSourceRefs(value, `${where}.${key}`, opts)
|
|
137
|
+
: literal(value, `${where}.${key}`, opts);
|
|
128
138
|
}
|
|
129
139
|
return out;
|
|
130
140
|
}
|
|
141
|
+
/** Actions (`on` events, button `onPress`): app or element references may sit at any depth. */
|
|
142
|
+
function deepSourceRefs(value, where, opts) {
|
|
143
|
+
if (isReference(value)) {
|
|
144
|
+
const kind = value.__kind;
|
|
145
|
+
if (kind === undefined || kind === "app" || kind === "element")
|
|
146
|
+
return appRef(value, where, opts);
|
|
147
|
+
throw new EntityTfError(`${where}: only app or element references (or unsafePlatformId(...)) are allowed inside actions`);
|
|
148
|
+
}
|
|
149
|
+
if (Array.isArray(value))
|
|
150
|
+
return value.map((item, i) => deepSourceRefs(item, `${where}[${i}]`, opts));
|
|
151
|
+
const rec = record(value);
|
|
152
|
+
if (rec !== undefined) {
|
|
153
|
+
const out = {};
|
|
154
|
+
for (const [key, child] of Object.entries(rec))
|
|
155
|
+
out[checkKey(key, where)] = deepSourceRefs(child, `${where}.${key}`, opts);
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
return literal(value, where, opts);
|
|
159
|
+
}
|
|
131
160
|
function appRef(value, where, opts) {
|
|
132
161
|
const id = unsafeId(value);
|
|
133
162
|
if (id !== undefined)
|
|
@@ -135,7 +164,7 @@ function appRef(value, where, opts) {
|
|
|
135
164
|
const token = value;
|
|
136
165
|
const kind = token.__kind === "element" ? "element" : "app";
|
|
137
166
|
const refName = token.refName ?? "";
|
|
138
|
-
if (kind === "app" && refName === opts.ownerRefName)
|
|
167
|
+
if (kind === (opts.ownerKind ?? "app") && refName === opts.ownerRefName)
|
|
139
168
|
return opts.objectId;
|
|
140
169
|
const sibling = opts.workspaceAspects?.get(workspaceAspectKey(kind, refName));
|
|
141
170
|
if (sibling !== undefined)
|
|
@@ -148,9 +177,10 @@ function fieldRef(value, where, opts) {
|
|
|
148
177
|
const id = unsafeId(value);
|
|
149
178
|
if (id !== undefined)
|
|
150
179
|
return id;
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
180
|
+
const token = value;
|
|
181
|
+
const ownerKind = opts.ownerKind ?? "app";
|
|
182
|
+
if (token.parent !== undefined && (token.parent !== opts.ownerRefName || (token.parentKind ?? ownerKind) !== ownerKind)) {
|
|
183
|
+
return foreignFieldRef(value, where, opts);
|
|
154
184
|
}
|
|
155
185
|
const before = opts.diagnostics.length;
|
|
156
186
|
const resolved = opts.resolveField(value, where);
|
|
@@ -160,6 +190,45 @@ function fieldRef(value, where, opts) {
|
|
|
160
190
|
}
|
|
161
191
|
return resolved;
|
|
162
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Another app's or element's field. A field of a sibling in this workspace is
|
|
195
|
+
* its resource, so Terraform creates the field before the layout that names
|
|
196
|
+
* it; any other owner's field is a data lookup scoped to that owner (the chart
|
|
197
|
+
* datasource rule).
|
|
198
|
+
*/
|
|
199
|
+
function foreignFieldRef(value, where, opts) {
|
|
200
|
+
const token = value;
|
|
201
|
+
if (token.parentKind !== undefined && token.parentKind !== "app" && token.parentKind !== "element") {
|
|
202
|
+
throw new EntityTfError(`${where}: fields of a ${token.parentKind} cannot be referenced here; use unsafePlatformId(...)`);
|
|
203
|
+
}
|
|
204
|
+
const kind = token.parentKind ?? "app";
|
|
205
|
+
if (token.refName === undefined || token.refName === "")
|
|
206
|
+
throw new EntityTfError(`${where}: field ref is missing its key`);
|
|
207
|
+
if (opts.orgRefs === undefined)
|
|
208
|
+
throw new EntityTfError(`${where}: the "${token.parent}" field "${token.refName}" cannot be resolved here; use unsafePlatformId(...)`);
|
|
209
|
+
const sibling = opts.workspaceAspects?.get(workspaceAspectKey(kind, token.parent));
|
|
210
|
+
const siblingType = sibling === undefined ? undefined : siblingFieldType(sibling.streamRootEntity?.payload, token.refName);
|
|
211
|
+
const direct = sibling !== undefined && siblingType !== undefined
|
|
212
|
+
? fieldRefToTfValue(siblingType, token.refName, sibling.tfLabel, kind, authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload))
|
|
213
|
+
: undefined;
|
|
214
|
+
if (direct !== undefined)
|
|
215
|
+
return direct;
|
|
216
|
+
const owner = sibling !== undefined
|
|
217
|
+
? { value: expr.resourceAttr(kind === "app" ? "elementum_app" : "elementum_element", sibling.tfLabel, ["id"]), tfLabel: sibling.tfLabel }
|
|
218
|
+
: resolveForeignRef(kind, { name: token.parentName ?? token.parent, namespace: token.parentNamespace }, opts.orgRefs, opts.diagnostics, where);
|
|
219
|
+
const fieldName = token.name ?? token.refName;
|
|
220
|
+
// The label every entity's build uses for this field, so one lookup is emitted per field.
|
|
221
|
+
const label = foreignFieldDataLabel(kind, owner.tfLabel, fieldName);
|
|
222
|
+
opts.orgRefs.foreignField("elementum_field", label, owner.value, fieldName);
|
|
223
|
+
return expr.dataAttr("elementum_field", label, ["id"]);
|
|
224
|
+
}
|
|
225
|
+
/** A sibling root's authored field type, from its wire field entry (`{ <typeKey>: { __refName } }`). */
|
|
226
|
+
function siblingFieldType(payload, refName) {
|
|
227
|
+
const fields = payload?.fields;
|
|
228
|
+
const entry = fields?.find((field) => Object.values(field)[0]?.__refName === refName);
|
|
229
|
+
const typeKey = entry === undefined ? undefined : Object.keys(entry)[0];
|
|
230
|
+
return typeKey === undefined ? undefined : SUB_TYPE_BY_TYPE_KEY.get(typeKey)?.authoringType;
|
|
231
|
+
}
|
|
163
232
|
/** Nested filter values: references may sit at any depth. */
|
|
164
233
|
function deepRefs(value, where, opts) {
|
|
165
234
|
if (isReference(value)) {
|
|
@@ -218,6 +287,9 @@ function checkStructure(root, elements, where, diagnostics) {
|
|
|
218
287
|
// still builds and round-trips; fixing it is the author's call.
|
|
219
288
|
for (const [id, raw] of Object.entries(elements)) {
|
|
220
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
|
+
}
|
|
221
293
|
if (!Array.isArray(children))
|
|
222
294
|
continue;
|
|
223
295
|
for (const child of children) {
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* screen an agent view shows before the first message. Authored on
|
|
4
|
-
* `agentViews.<key>.layout`; present means the Welcome template, absent means
|
|
5
|
-
* the standard chat (an apply then clears any live customization).
|
|
2
|
+
* Elementum Blocks layouts with typed references, shared by two views:
|
|
6
3
|
*
|
|
7
|
-
*
|
|
4
|
+
* - the agent managed view layout customization (PF-5983): the Welcome landing
|
|
5
|
+
* screen an agent view shows before the first message, authored on
|
|
6
|
+
* `agentViews.<key>.layout` (its `customView` is a blocks layout);
|
|
7
|
+
* - the Custom view (PF-5633), whose whole page is a blocks layout, authored on
|
|
8
|
+
* `customViews.<key>.layout`.
|
|
9
|
+
*
|
|
10
|
+
* A blocks layout is an Elementum Blocks (Ragnarok) spec — the generated
|
|
8
11
|
* `ElementumBlocksSpec` — with platform ids replaced by typed references at
|
|
9
|
-
* the per-block id positions listed in `AGENT_VIEW_SPEC_ID_PROPS
|
|
12
|
+
* the per-block id positions listed in `AGENT_VIEW_SPEC_ID_PROPS`, inside
|
|
13
|
+
* nested filters, and inside actions (`on` events, button `onPress`).
|
|
10
14
|
*/
|
|
11
|
-
import type { AppCatalogRef, FieldRef } from "../../catalog/types.js";
|
|
15
|
+
import type { AppCatalogRef, ElementCatalogRef, FieldRef } from "../../catalog/types.js";
|
|
12
16
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
13
17
|
import type { SystemFieldKey } from "../../core/system-fields.js";
|
|
14
18
|
import type { ElementumBlocksElement, ElementumBlocksSpec } from "./ragnarok.js";
|
|
@@ -39,12 +43,18 @@ export interface AgentViewBranding {
|
|
|
39
43
|
/** Defaults to `system`. */
|
|
40
44
|
readonly fontFamily?: AgentViewFontFamily;
|
|
41
45
|
}
|
|
42
|
-
/** A
|
|
43
|
-
export type
|
|
44
|
-
/** A self-fetching block's field:
|
|
45
|
-
export type
|
|
46
|
+
/** A block's source: the view's own app or element, another app or element, or one by id. */
|
|
47
|
+
export type ViewBlocksSource = AppCatalogRef | ElementCatalogRef | UnsafePlatformId;
|
|
48
|
+
/** A self-fetching block's field: the view owner's, another app's or element's, or one by id. */
|
|
49
|
+
export type ViewBlocksField = FieldRef | SystemFieldKey | UnsafePlatformId;
|
|
46
50
|
/** A reference allowed anywhere inside a nested filter prop. */
|
|
47
|
-
export type
|
|
51
|
+
export type ViewBlocksFilterRef = ViewBlocksSource | ViewBlocksField;
|
|
52
|
+
/** Same as `ViewBlocksSource` (the agent view name). */
|
|
53
|
+
export type AgentViewSpecApp = ViewBlocksSource;
|
|
54
|
+
/** Same as `ViewBlocksField` (the agent view name). */
|
|
55
|
+
export type AgentViewSpecField = ViewBlocksField;
|
|
56
|
+
/** Same as `ViewBlocksFilterRef` (the agent view name). */
|
|
57
|
+
export type AgentViewSpecFilterRef = ViewBlocksFilterRef;
|
|
48
58
|
/**
|
|
49
59
|
* Per block type, the top-level props that hold platform ids. Ids are scoped
|
|
50
60
|
* per block, not by prop name: DetailsFieldsBlock's `fields[].fieldId` is a
|
|
@@ -66,6 +76,7 @@ export declare const AGENT_VIEW_SPEC_ID_PROPS: {
|
|
|
66
76
|
readonly aspectId: "app";
|
|
67
77
|
readonly fieldId: "field";
|
|
68
78
|
readonly groupByFieldId: "field";
|
|
79
|
+
readonly dateFieldId: "field";
|
|
69
80
|
};
|
|
70
81
|
readonly MetricsRowBlock: {
|
|
71
82
|
readonly aspectId: "app";
|
|
@@ -81,32 +92,51 @@ type FilterProp = (typeof AGENT_VIEW_SPEC_FILTER_PROPS)[number];
|
|
|
81
92
|
*/
|
|
82
93
|
type WithRef<V, R> = V extends string ? R | "" : V;
|
|
83
94
|
/** Allow a reference wherever a string sits inside a nested value. */
|
|
84
|
-
type WithDeepRefs<V> = V extends string ? V |
|
|
95
|
+
type WithDeepRefs<V> = V extends string ? V | ViewBlocksFilterRef : V extends ReadonlyArray<infer I> ? ReadonlyArray<WithDeepRefs<I>> : V extends object ? {
|
|
85
96
|
readonly [K in keyof V]: WithDeepRefs<V[K]>;
|
|
86
97
|
} : V;
|
|
98
|
+
/** Allow an app or element reference wherever a string sits inside an action (e.g. createRecord's aspectId). */
|
|
99
|
+
type WithDeepSourceRefs<V> = V extends string ? V | ViewBlocksSource : V extends ReadonlyArray<infer I> ? ReadonlyArray<WithDeepSourceRefs<I>> : V extends object ? {
|
|
100
|
+
readonly [K in keyof V]: WithDeepSourceRefs<V[K]>;
|
|
101
|
+
} : V;
|
|
87
102
|
type MapProps<T, P> = P extends unknown ? {
|
|
88
|
-
readonly [K in keyof P]: K extends keyof IdPropsFor<T> ? WithRef<P[K], IdPropsFor<T>[K] extends "field" ?
|
|
103
|
+
readonly [K in keyof P]: K extends keyof IdPropsFor<T> ? WithRef<P[K], IdPropsFor<T>[K] extends "field" ? ViewBlocksField : ViewBlocksSource> : K extends FilterProp ? WithDeepRefs<P[K]> : T extends "ButtonBlock" ? K extends "buttons" ? MapButtons<P[K]> : P[K] : P[K];
|
|
89
104
|
} : never;
|
|
90
|
-
/**
|
|
91
|
-
|
|
105
|
+
/**
|
|
106
|
+
* ButtonBlock items: link items name another managed view by id, and action
|
|
107
|
+
* items (`onPress`, e.g. createRecord) may name an app or element.
|
|
108
|
+
*/
|
|
109
|
+
type MapButtons<V> = V extends ReadonlyArray<infer I> ? ReadonlyArray<MapButton<I>> : V;
|
|
110
|
+
type MapButton<I> = I extends {
|
|
92
111
|
readonly viewId?: string;
|
|
93
112
|
} ? Omit<I, "viewId"> & {
|
|
94
113
|
readonly viewId?: UnsafePlatformId;
|
|
95
|
-
} : I
|
|
114
|
+
} : I extends {
|
|
115
|
+
readonly onPress: infer A;
|
|
116
|
+
} ? Omit<I, "onPress"> & {
|
|
117
|
+
readonly onPress: WithDeepSourceRefs<A>;
|
|
118
|
+
} : I;
|
|
96
119
|
type MapElement<E> = E extends {
|
|
97
120
|
readonly type: infer T;
|
|
98
121
|
readonly props: infer P;
|
|
99
|
-
} ? Omit<E, "props"> & {
|
|
122
|
+
} ? Omit<E, "props" | "on"> & {
|
|
100
123
|
readonly props: MapProps<T, P>;
|
|
124
|
+
readonly on?: E extends {
|
|
125
|
+
readonly on?: infer O;
|
|
126
|
+
} ? WithDeepSourceRefs<O> : never;
|
|
101
127
|
} : E;
|
|
102
|
-
/** One block of
|
|
103
|
-
export type
|
|
104
|
-
/**
|
|
105
|
-
export type
|
|
128
|
+
/** One block of a blocks layout. */
|
|
129
|
+
export type ViewBlock = MapElement<ElementumBlocksElement>;
|
|
130
|
+
/** A blocks layout: an Elementum Blocks spec with typed references. */
|
|
131
|
+
export type ViewBlocksLayout = Omit<ElementumBlocksSpec, "elements"> & {
|
|
106
132
|
readonly elements: {
|
|
107
|
-
readonly [key: string]:
|
|
133
|
+
readonly [key: string]: ViewBlock;
|
|
108
134
|
};
|
|
109
135
|
};
|
|
136
|
+
/** One block of an agent view's custom view. */
|
|
137
|
+
export type AgentViewBlock = ViewBlock;
|
|
138
|
+
/** An agent view's custom view: a blocks layout. */
|
|
139
|
+
export type AgentViewCustomView = ViewBlocksLayout;
|
|
110
140
|
/** The layout customization of an agent view (the admin UI's Layout panel). */
|
|
111
141
|
export interface AppAgentViewLayout {
|
|
112
142
|
readonly image?: AgentViewImage;
|
|
@@ -14,7 +14,7 @@ export const AGENT_VIEW_SPEC_ID_PROPS = {
|
|
|
14
14
|
DataTableBlock: { aspectId: "app", selectedAspectId: "app" },
|
|
15
15
|
ListCollectionBlock: { aspectId: "app", selectedAspectId: "app" },
|
|
16
16
|
ListControlsBlock: { filterAspectId: "app" },
|
|
17
|
-
ChartBlock: { aspectId: "app", fieldId: "field", groupByFieldId: "field" },
|
|
17
|
+
ChartBlock: { aspectId: "app", fieldId: "field", groupByFieldId: "field", dateFieldId: "field" },
|
|
18
18
|
MetricsRowBlock: { aspectId: "app" },
|
|
19
19
|
};
|
|
20
20
|
/** Props holding nested filter structures, where references may sit at any depth. */
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
9
9
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
10
10
|
import { type NormalizedManagedViewSort } from "./build.js";
|
|
11
|
-
import type { NormalizedAgentView, NormalizedCalendarView, NormalizedDashboardView, NormalizedKanbanView, NormalizedLayout, NormalizedListView } from "../app/deserializer/normalize.js";
|
|
11
|
+
import type { NormalizedAgentView, NormalizedCalendarView, NormalizedCustomView, NormalizedDashboardView, NormalizedKanbanView, NormalizedLayout, NormalizedListView } from "../app/deserializer/normalize.js";
|
|
12
12
|
/** Report every attribute key not in `known` as dialect growth — shared by all four view/section passes below. */
|
|
13
13
|
export interface ViewOwner {
|
|
14
14
|
/** The owner's resource type ("elementum_app") — what `object_id`/`aspect_id` must reference. */
|
|
@@ -29,8 +29,9 @@ export interface ViewsFromTfResult {
|
|
|
29
29
|
readonly kanbanViews: readonly NormalizedKanbanView[];
|
|
30
30
|
readonly dashboardViews: readonly NormalizedDashboardView[];
|
|
31
31
|
readonly agentViews: readonly NormalizedAgentView[];
|
|
32
|
+
readonly customViews: readonly NormalizedCustomView[];
|
|
32
33
|
readonly viewOrder?: readonly string[];
|
|
33
34
|
}
|
|
34
35
|
/** All three view resource kinds → the normalized shapes the app printer consumes. */
|
|
35
|
-
export declare function viewsFromTf(layoutBlocks: readonly TfBlock[], listViewBlocks: readonly TfBlock[], calendarViewBlocks: readonly TfBlock[], kanbanViewBlocks: readonly TfBlock[], dashboardViewBlocks: readonly TfBlock[], agentViewBlocks: readonly TfBlock[], managedViewOrderBlocks: readonly TfBlock[], owner: ViewOwner, ctx: FromTfContext): ViewsFromTfResult;
|
|
36
|
+
export declare function viewsFromTf(layoutBlocks: readonly TfBlock[], listViewBlocks: readonly TfBlock[], calendarViewBlocks: readonly TfBlock[], kanbanViewBlocks: readonly TfBlock[], dashboardViewBlocks: readonly TfBlock[], agentViewBlocks: readonly TfBlock[], managedViewOrderBlocks: readonly TfBlock[], owner: ViewOwner, ctx: FromTfContext, customViewBlocks?: readonly TfBlock[]): ViewsFromTfResult;
|
|
36
37
|
export declare function managedViewSortFromTf(value: TfValue | undefined, owner: ViewOwner, where: string, ctx: FromTfContext): NormalizedManagedViewSort | undefined;
|