@elementumai/edk 0.9.18 → 0.9.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/dist-sdk/src/catalog/factories.d.ts +11 -0
- package/dist-sdk/src/catalog/factories.js +6 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.d.ts +39 -1
- package/dist-sdk/src/catalog/org.js +460 -50
- package/dist-sdk/src/catalog/types.d.ts +10 -0
- package/dist-sdk/src/catalog/types.js +2 -0
- package/dist-sdk/src/engine/pull/ref-only.js +54 -20
- package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
- package/dist-sdk/src/engine/pull/result-output.js +1 -1
- package/dist-sdk/src/engine/tf/expr.js +38 -13
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +2 -0
- package/dist-sdk/src/engine/tf/labels.js +4 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
- package/dist-sdk/src/engine/tf/parse.js +105 -6
- package/dist-sdk/src/engine/workspace/loader.js +49 -12
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/app/build.d.ts +10 -0
- package/dist-sdk/src/entities/app/build.js +0 -13
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -3
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +13 -0
- package/dist-sdk/src/entities/app/to-tf.js +2 -0
- package/dist-sdk/src/entities/automation/build.d.ts +2 -1
- package/dist-sdk/src/entities/automation/build.js +27 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +6 -0
- package/dist-sdk/src/entities/automation/from-tf.js +135 -26
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +2 -0
- package/dist-sdk/src/entities/automation/module.js +56 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
- package/dist-sdk/src/entities/automation/system-ref-name.js +44 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +15 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +38 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -2
- package/dist-sdk/src/entities/automation/to-tf.js +158 -84
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.js +33 -17
- package/dist-sdk/src/entities/chart/module.js +3 -1
- package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
- package/dist-sdk/src/entities/chart/printer.js +26 -16
- package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
- package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
- package/dist-sdk/src/entities/chart/to-tf.js +12 -10
- package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +51 -2
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
- package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
- package/dist-sdk/src/entities/element/build.d.ts +8 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +6 -2
- package/dist-sdk/src/entities/element/index.d.ts +1 -0
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +2 -0
- package/dist-sdk/src/entities/element/to-tf.js +12 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/field/from-tf.js +11 -0
- package/dist-sdk/src/entities/field/to-tf.js +13 -9
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +19 -10
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +23 -2
- package/dist-sdk/src/entities/shared/filters/index.js +24 -1
- package/dist-sdk/src/entities/shared/filters/print.js +14 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +23 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +46 -14
- package/dist-sdk/src/entities/shared/filters/types.d.ts +13 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
- package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
- package/dist-sdk/src/entities/skill/access-policy.js +101 -0
- package/dist-sdk/src/entities/skill/build.d.ts +3 -0
- package/dist-sdk/src/entities/skill/build.js +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +21 -0
- package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill/from-tf.js +4 -9
- package/dist-sdk/src/entities/skill/index.d.ts +2 -0
- package/dist-sdk/src/entities/skill/index.js +1 -0
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill/to-tf.js +5 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +224 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +36 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +288 -0
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +121 -0
- package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/view/from-tf.js +42 -7
- package/dist-sdk/src/entities/view/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/view/to-tf.js +30 -1
- package/dist-sdk/src/entities/view/types.js +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +2 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +25 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +43 -0
- package/dist-sdk/src/graph/index.js +9 -0
- package/dist-sdk/src/graph/types.d.ts +78 -0
- package/package.json +2 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build: `agentViews.<key>.layout` → the `layout` attribute of
|
|
3
|
+
* `elementum_agent_view`. Platform ids in the custom view resolve from typed
|
|
4
|
+
* references at the per-block id positions; a structurally broken custom view
|
|
5
|
+
* fails the build, because dropping it would make apply clear the live one.
|
|
6
|
+
*/
|
|
7
|
+
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
8
|
+
import { type ChildResourceScope, type TfValue } from "../../engine/tf/index.js";
|
|
9
|
+
export interface AgentViewLayoutToTfOptions {
|
|
10
|
+
readonly ownerRefName: string;
|
|
11
|
+
readonly ownerTfLabel: string;
|
|
12
|
+
readonly scope: ChildResourceScope;
|
|
13
|
+
readonly objectId: TfValue;
|
|
14
|
+
readonly diagnostics: string[];
|
|
15
|
+
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
16
|
+
readonly orgRefs?: OrgRefLookup;
|
|
17
|
+
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
18
|
+
/** Resolves an own-app field reference (view/to-tf's field resolver). */
|
|
19
|
+
readonly resolveField: (ref: unknown, where: string) => TfValue | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Wire shape of an authored layout (the public type, unchecked). */
|
|
22
|
+
export interface AppAgentViewLayoutWire {
|
|
23
|
+
readonly image?: {
|
|
24
|
+
readonly attachment?: unknown;
|
|
25
|
+
readonly url?: unknown;
|
|
26
|
+
};
|
|
27
|
+
readonly header?: string;
|
|
28
|
+
readonly subHeader?: string;
|
|
29
|
+
readonly branding?: {
|
|
30
|
+
readonly backgroundColor?: string;
|
|
31
|
+
readonly primaryColor?: string;
|
|
32
|
+
readonly fontFamily?: string;
|
|
33
|
+
};
|
|
34
|
+
readonly customView?: unknown;
|
|
35
|
+
}
|
|
36
|
+
export declare function agentViewLayoutToTf(layout: AppAgentViewLayoutWire, where: string, opts: AgentViewLayoutToTfOptions): TfValue;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
2
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
3
|
+
import { expr } from "../../engine/tf/index.js";
|
|
4
|
+
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
5
|
+
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "./types.js";
|
|
6
|
+
import { AGENT_VIEW_SPEC_FILTER_PROPS, AGENT_VIEW_SPEC_ID_PROPS, agentViewFontFamily, } from "./agent-view-layout.js";
|
|
7
|
+
const PLATFORM_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8
|
+
const HEX_COLOR = /^#[0-9a-fA-F]{3,8}$/;
|
|
9
|
+
const FONT_FAMILIES = new Set(Object.values(agentViewFontFamily));
|
|
10
|
+
const FILTER_PROPS = new Set(AGENT_VIEW_SPEC_FILTER_PROPS);
|
|
11
|
+
const ID_PROPS = AGENT_VIEW_SPEC_ID_PROPS;
|
|
12
|
+
/** Blocks the admin UI's JSON editor re-applies (its managed-view authoring policy). */
|
|
13
|
+
const SYSTEM_FIELD_KEYS = new Set(SYSTEM_FIELD_ID_ATTR_BY_KEY.keys());
|
|
14
|
+
const UI_EDITABLE_BLOCKS = new Set([
|
|
15
|
+
"ActionCardBlock", "BodyBlock", "BulletsBlock", "CardBlock", "DataTableBlock", "DetailsFieldsBlock",
|
|
16
|
+
"DetailsListBlock", "DividerBlock", "HeaderBlock", "RowBlock", "SpacerBlock", "StackBlock",
|
|
17
|
+
]);
|
|
18
|
+
export function agentViewLayoutToTf(layout, where, opts) {
|
|
19
|
+
const attrs = {};
|
|
20
|
+
const image = layout.image;
|
|
21
|
+
if (image !== undefined) {
|
|
22
|
+
const attachment = unsafeId(image.attachment);
|
|
23
|
+
if (attachment !== undefined) {
|
|
24
|
+
if (!PLATFORM_ID.test(attachment))
|
|
25
|
+
throw new EntityTfError(`${where}.image.attachment: "${attachment}" is not a platform id`);
|
|
26
|
+
attrs["image_url"] = `/api/v1/attachments/${attachment}`;
|
|
27
|
+
}
|
|
28
|
+
else if (typeof image.url === "string" && image.url !== "") {
|
|
29
|
+
attrs["image_url"] = image.url;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new EntityTfError(`${where}.image must be { attachment: unsafePlatformId(...) } or { url: "..." }`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (layout.header !== undefined && layout.header !== "")
|
|
36
|
+
attrs["header"] = layout.header;
|
|
37
|
+
if (layout.subHeader !== undefined && layout.subHeader !== "")
|
|
38
|
+
attrs["sub_header"] = layout.subHeader;
|
|
39
|
+
const branding = layout.branding ?? {};
|
|
40
|
+
for (const [key, attr] of [["backgroundColor", "background_color"], ["primaryColor", "primary_color"]]) {
|
|
41
|
+
const color = branding[key];
|
|
42
|
+
if (color === undefined || color === "")
|
|
43
|
+
continue;
|
|
44
|
+
if (!HEX_COLOR.test(color))
|
|
45
|
+
throw new EntityTfError(`${where}.branding.${key}: "${color}" is not a hex colour (#RGB to #RRGGBBAA)`);
|
|
46
|
+
attrs[attr] = color;
|
|
47
|
+
}
|
|
48
|
+
if (branding.fontFamily !== undefined) {
|
|
49
|
+
if (!FONT_FAMILIES.has(branding.fontFamily)) {
|
|
50
|
+
throw new EntityTfError(`${where}.branding.fontFamily: "${branding.fontFamily}" is not one of ${[...FONT_FAMILIES].join(", ")}`);
|
|
51
|
+
}
|
|
52
|
+
attrs["font_family"] = branding.fontFamily;
|
|
53
|
+
}
|
|
54
|
+
if (layout.customView !== undefined) {
|
|
55
|
+
attrs["custom_view"] = expr.jsonencode(customViewToTf(layout.customView, `${where}.customView`, opts));
|
|
56
|
+
}
|
|
57
|
+
return attrs;
|
|
58
|
+
}
|
|
59
|
+
function customViewToTf(spec, where, opts) {
|
|
60
|
+
const doc = record(spec);
|
|
61
|
+
if (doc === undefined)
|
|
62
|
+
throw new EntityTfError(`${where} must be an object`);
|
|
63
|
+
const elements = record(doc["elements"]);
|
|
64
|
+
if (typeof doc["root"] !== "string" || doc["root"] === "")
|
|
65
|
+
throw new EntityTfError(`${where}.root must name an element`);
|
|
66
|
+
if (elements === undefined || Object.keys(elements).length === 0)
|
|
67
|
+
throw new EntityTfError(`${where}.elements must have at least one element`);
|
|
68
|
+
checkStructure(doc["root"], elements, where, opts.diagnostics);
|
|
69
|
+
const out = {};
|
|
70
|
+
for (const [key, value] of Object.entries(doc)) {
|
|
71
|
+
if (key === "elements")
|
|
72
|
+
continue;
|
|
73
|
+
out[key] = literal(value, `${where}.${key}`, opts);
|
|
74
|
+
}
|
|
75
|
+
const outElements = {};
|
|
76
|
+
for (const [id, raw] of Object.entries(elements)) {
|
|
77
|
+
const element = record(raw);
|
|
78
|
+
const elementWhere = `${where}.elements.${id}`;
|
|
79
|
+
const type = typeof element["type"] === "string" ? element["type"] : "";
|
|
80
|
+
policyWarnings(type, element, elementWhere, opts.diagnostics);
|
|
81
|
+
const outElement = {};
|
|
82
|
+
for (const [key, value] of Object.entries(element)) {
|
|
83
|
+
outElement[key] = key === "props"
|
|
84
|
+
? propsToTf(type, value, `${elementWhere}.props`, opts)
|
|
85
|
+
: literal(value, `${elementWhere}.${key}`, opts);
|
|
86
|
+
}
|
|
87
|
+
outElements[id] = outElement;
|
|
88
|
+
}
|
|
89
|
+
out["elements"] = outElements;
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
function propsToTf(type, props, where, opts) {
|
|
93
|
+
const rec = record(props);
|
|
94
|
+
if (rec === undefined)
|
|
95
|
+
return literal(props, where, opts);
|
|
96
|
+
const idProps = ID_PROPS[type] ?? {};
|
|
97
|
+
const out = {};
|
|
98
|
+
for (const [key, value] of Object.entries(rec)) {
|
|
99
|
+
const propWhere = `${where}.${key}`;
|
|
100
|
+
const kind = idProps[key];
|
|
101
|
+
if (kind === "field" && (isReference(value) || SYSTEM_FIELD_KEYS.has(value))) {
|
|
102
|
+
// A string here is a system field key ("status", "createdAt", ...).
|
|
103
|
+
out[key] = fieldRef(value, propWhere, opts);
|
|
104
|
+
}
|
|
105
|
+
else if (kind === "app" && isReference(value)) {
|
|
106
|
+
out[key] = appRef(value, propWhere, opts);
|
|
107
|
+
}
|
|
108
|
+
else if (FILTER_PROPS.has(key)) {
|
|
109
|
+
out[key] = deepRefs(value, propWhere, opts);
|
|
110
|
+
}
|
|
111
|
+
else if (type === "ButtonBlock" && key === "buttons" && Array.isArray(value)) {
|
|
112
|
+
out[key] = value.map((item, i) => buttonToTf(item, `${propWhere}[${i}]`, opts));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
out[key] = literal(value, propWhere, opts);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
function buttonToTf(item, where, opts) {
|
|
121
|
+
const rec = record(item);
|
|
122
|
+
if (rec === undefined)
|
|
123
|
+
return literal(item, where, opts);
|
|
124
|
+
const out = {};
|
|
125
|
+
for (const [key, value] of Object.entries(rec)) {
|
|
126
|
+
const id = key === "viewId" ? unsafeId(value) : undefined;
|
|
127
|
+
out[key] = id !== undefined ? id : literal(value, `${where}.${key}`, opts);
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
function appRef(value, where, opts) {
|
|
132
|
+
const id = unsafeId(value);
|
|
133
|
+
if (id !== undefined)
|
|
134
|
+
return id;
|
|
135
|
+
const token = value;
|
|
136
|
+
const kind = token.__kind === "element" ? "element" : "app";
|
|
137
|
+
const refName = token.refName ?? "";
|
|
138
|
+
if (kind === "app" && refName === opts.ownerRefName)
|
|
139
|
+
return opts.objectId;
|
|
140
|
+
const sibling = opts.workspaceAspects?.get(workspaceAspectKey(kind, refName));
|
|
141
|
+
if (sibling !== undefined)
|
|
142
|
+
return expr.resourceAttr(kind === "app" ? "elementum_app" : "elementum_element", sibling.tfLabel, ["id"]);
|
|
143
|
+
if (opts.orgRefs === undefined)
|
|
144
|
+
throw new EntityTfError(`${where}: app "${refName}" cannot be resolved here; use unsafePlatformId(...)`);
|
|
145
|
+
return resolveForeignRef(kind, { name: token.name ?? refName, namespace: token.namespace }, opts.orgRefs, opts.diagnostics, where).value;
|
|
146
|
+
}
|
|
147
|
+
function fieldRef(value, where, opts) {
|
|
148
|
+
const id = unsafeId(value);
|
|
149
|
+
if (id !== undefined)
|
|
150
|
+
return id;
|
|
151
|
+
const parent = value.parent;
|
|
152
|
+
if (parent !== undefined && parent !== opts.ownerRefName) {
|
|
153
|
+
throw new EntityTfError(`${where}: field references must belong to this app ("${opts.ownerRefName}"); use unsafePlatformId(...) for "${parent}" fields`);
|
|
154
|
+
}
|
|
155
|
+
const before = opts.diagnostics.length;
|
|
156
|
+
const resolved = opts.resolveField(value, where);
|
|
157
|
+
if (resolved === undefined) {
|
|
158
|
+
const reason = opts.diagnostics.slice(before).join("; ");
|
|
159
|
+
throw new EntityTfError(reason !== "" ? reason : `${where}: field reference does not resolve`);
|
|
160
|
+
}
|
|
161
|
+
return resolved;
|
|
162
|
+
}
|
|
163
|
+
/** Nested filter values: references may sit at any depth. */
|
|
164
|
+
function deepRefs(value, where, opts) {
|
|
165
|
+
if (isReference(value)) {
|
|
166
|
+
const kind = value.__kind;
|
|
167
|
+
return kind === "app" || kind === "element" ? appRef(value, where, opts) : fieldRef(value, where, opts);
|
|
168
|
+
}
|
|
169
|
+
if (Array.isArray(value))
|
|
170
|
+
return value.map((item, i) => deepRefs(item, `${where}[${i}]`, opts));
|
|
171
|
+
const rec = record(value);
|
|
172
|
+
if (rec !== undefined) {
|
|
173
|
+
const out = {};
|
|
174
|
+
for (const [key, child] of Object.entries(rec))
|
|
175
|
+
out[checkKey(key, where)] = deepRefs(child, `${where}.${key}`, opts);
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
return literal(value, where, opts);
|
|
179
|
+
}
|
|
180
|
+
/** Plain JSON outside the id positions. */
|
|
181
|
+
function literal(value, where, opts) {
|
|
182
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
183
|
+
return value;
|
|
184
|
+
if (typeof value === "number") {
|
|
185
|
+
if (!Number.isFinite(value))
|
|
186
|
+
throw new EntityTfError(`${where}: ${value} is not a JSON number`);
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
if (Array.isArray(value))
|
|
190
|
+
return value.map((item, i) => literal(item, `${where}[${i}]`, opts));
|
|
191
|
+
if (isReference(value)) {
|
|
192
|
+
throw new EntityTfError(`${where}: references are only allowed at the custom view's id props; use a plain value here`);
|
|
193
|
+
}
|
|
194
|
+
const rec = record(value);
|
|
195
|
+
if (rec === undefined)
|
|
196
|
+
throw new EntityTfError(`${where}: ${typeof value} is not a JSON value`);
|
|
197
|
+
const out = {};
|
|
198
|
+
for (const [key, child] of Object.entries(rec))
|
|
199
|
+
out[checkKey(key, where)] = literal(child, `${where}.${key}`, opts);
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
function checkStructure(root, elements, where, diagnostics) {
|
|
203
|
+
// The platform's schema rejects these, so they fail the build.
|
|
204
|
+
if (!(root in elements))
|
|
205
|
+
throw new EntityTfError(`${where}.root "${root}" is not an element`);
|
|
206
|
+
for (const [id, raw] of Object.entries(elements)) {
|
|
207
|
+
const element = record(raw);
|
|
208
|
+
if (element === undefined || typeof element["type"] !== "string")
|
|
209
|
+
throw new EntityTfError(`${where}.elements.${id} must be a block with a type`);
|
|
210
|
+
if (record(element["props"]) === undefined)
|
|
211
|
+
throw new EntityTfError(`${where}.elements.${id}.props must be an object`);
|
|
212
|
+
const children = element["children"];
|
|
213
|
+
if (children !== undefined && !Array.isArray(children))
|
|
214
|
+
throw new EntityTfError(`${where}.elements.${id}.children must be a list of element ids`);
|
|
215
|
+
}
|
|
216
|
+
// The platform stores these (its schema does not cross-check child ids), but
|
|
217
|
+
// the page fails to render them. Warn rather than fail, so a pulled layout
|
|
218
|
+
// still builds and round-trips; fixing it is the author's call.
|
|
219
|
+
for (const [id, raw] of Object.entries(elements)) {
|
|
220
|
+
const children = record(raw)?.["children"];
|
|
221
|
+
if (!Array.isArray(children))
|
|
222
|
+
continue;
|
|
223
|
+
for (const child of children) {
|
|
224
|
+
if (typeof child !== "string" || !(child in elements)) {
|
|
225
|
+
diagnostics.push(`${where}.elements.${id}.children: "${String(child)}" is not an element; the page will fail to render this custom view`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const state = new Map();
|
|
230
|
+
let cycle;
|
|
231
|
+
const visit = (id, path) => {
|
|
232
|
+
if (cycle !== undefined || state.get(id) === "done")
|
|
233
|
+
return;
|
|
234
|
+
if (state.get(id) === "visiting") {
|
|
235
|
+
cycle = [...path, id].join(" → ");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
state.set(id, "visiting");
|
|
239
|
+
const children = record(elements[id])?.["children"];
|
|
240
|
+
if (Array.isArray(children))
|
|
241
|
+
for (const child of children)
|
|
242
|
+
if (typeof child === "string" && child in elements)
|
|
243
|
+
visit(child, [...path, id]);
|
|
244
|
+
state.set(id, "done");
|
|
245
|
+
};
|
|
246
|
+
for (const id of Object.keys(elements))
|
|
247
|
+
visit(id, []);
|
|
248
|
+
if (cycle !== undefined)
|
|
249
|
+
diagnostics.push(`${where}: children form a cycle (${cycle}); the page will fail to render this custom view`);
|
|
250
|
+
}
|
|
251
|
+
function policyWarnings(type, element, where, diagnostics) {
|
|
252
|
+
const reason = !UI_EDITABLE_BLOCKS.has(type)
|
|
253
|
+
? `${type} is outside the admin UI editor's block list`
|
|
254
|
+
: type === "DataTableBlock" && record(element["props"])?.["rows"] === undefined
|
|
255
|
+
? "a DataTableBlock without static rows is outside the admin UI editor's policy"
|
|
256
|
+
: element["on"] !== undefined
|
|
257
|
+
? "`on` handlers are outside the admin UI editor's policy"
|
|
258
|
+
: hasExpression(element["props"])
|
|
259
|
+
? "`$` expressions are outside the admin UI editor's policy"
|
|
260
|
+
: undefined;
|
|
261
|
+
if (reason !== undefined) {
|
|
262
|
+
diagnostics.push(`${where}: ${reason}; the platform renders it, but the admin UI's JSON editor will not re-apply it`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function hasExpression(value) {
|
|
266
|
+
if (Array.isArray(value))
|
|
267
|
+
return value.some(hasExpression);
|
|
268
|
+
const rec = record(value);
|
|
269
|
+
if (rec === undefined)
|
|
270
|
+
return false;
|
|
271
|
+
return Object.entries(rec).some(([key, child]) => key.startsWith("$") || hasExpression(child));
|
|
272
|
+
}
|
|
273
|
+
function checkKey(key, where) {
|
|
274
|
+
if (key === "$expr")
|
|
275
|
+
throw new EntityTfError(`${where}: the object key "$expr" is reserved and cannot appear in a custom view`);
|
|
276
|
+
return key;
|
|
277
|
+
}
|
|
278
|
+
function isReference(value) {
|
|
279
|
+
const rec = record(value);
|
|
280
|
+
return rec !== undefined && (typeof rec["__kind"] === "string" || rec["__unsafe"] === "platformId");
|
|
281
|
+
}
|
|
282
|
+
function unsafeId(value) {
|
|
283
|
+
const rec = record(value);
|
|
284
|
+
return rec !== undefined && rec["__unsafe"] === "platformId" && typeof rec["value"] === "string" ? rec["value"] : undefined;
|
|
285
|
+
}
|
|
286
|
+
function record(value) {
|
|
287
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
288
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent managed view layout customization (PF-5983): the Welcome landing
|
|
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).
|
|
6
|
+
*
|
|
7
|
+
* `customView` is an Elementum Blocks (Ragnarok) spec — the generated
|
|
8
|
+
* `ElementumBlocksSpec` — with platform ids replaced by typed references at
|
|
9
|
+
* the per-block id positions listed in `AGENT_VIEW_SPEC_ID_PROPS`.
|
|
10
|
+
*/
|
|
11
|
+
import type { AppCatalogRef, FieldRef } from "../../catalog/types.js";
|
|
12
|
+
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
13
|
+
import type { SystemFieldKey } from "../../core/system-fields.js";
|
|
14
|
+
import type { ElementumBlocksElement, ElementumBlocksSpec } from "./ragnarok.js";
|
|
15
|
+
/** Font families the agent view renders. */
|
|
16
|
+
export declare const agentViewFontFamily: {
|
|
17
|
+
readonly system: "system";
|
|
18
|
+
readonly sans: "sans";
|
|
19
|
+
readonly serif: "serif";
|
|
20
|
+
readonly mono: "mono";
|
|
21
|
+
};
|
|
22
|
+
export type AgentViewFontFamily = (typeof agentViewFontFamily)[keyof typeof agentViewFontFamily];
|
|
23
|
+
/** A hex colour, `#RGB` to `#RRGGBBAA`. Build checks the digits. */
|
|
24
|
+
export type AgentViewHexColor = `#${string}`;
|
|
25
|
+
/**
|
|
26
|
+
* The hero image: an attachment uploaded to this environment (the admin UI's
|
|
27
|
+
* upload, stored as `/api/v1/attachments/<id>`), or an external URL.
|
|
28
|
+
*/
|
|
29
|
+
export type AgentViewImage = {
|
|
30
|
+
readonly attachment: UnsafePlatformId;
|
|
31
|
+
readonly url?: never;
|
|
32
|
+
} | {
|
|
33
|
+
readonly url: string;
|
|
34
|
+
readonly attachment?: never;
|
|
35
|
+
};
|
|
36
|
+
export interface AgentViewBranding {
|
|
37
|
+
readonly backgroundColor?: AgentViewHexColor;
|
|
38
|
+
readonly primaryColor?: AgentViewHexColor;
|
|
39
|
+
/** Defaults to `system`. */
|
|
40
|
+
readonly fontFamily?: AgentViewFontFamily;
|
|
41
|
+
}
|
|
42
|
+
/** A self-fetching block's app: the view's own app, or another app by id. */
|
|
43
|
+
export type AgentViewSpecApp = AppCatalogRef | UnsafePlatformId;
|
|
44
|
+
/** A self-fetching block's field: one of the view's own app fields, or another field by id. */
|
|
45
|
+
export type AgentViewSpecField = FieldRef | SystemFieldKey | UnsafePlatformId;
|
|
46
|
+
/** A reference allowed anywhere inside a nested filter prop. */
|
|
47
|
+
export type AgentViewSpecFilterRef = AgentViewSpecApp | AgentViewSpecField;
|
|
48
|
+
/**
|
|
49
|
+
* Per block type, the top-level props that hold platform ids. Ids are scoped
|
|
50
|
+
* per block, not by prop name: DetailsFieldsBlock's `fields[].fieldId` is a
|
|
51
|
+
* render identity, not a field lookup.
|
|
52
|
+
*/
|
|
53
|
+
export declare const AGENT_VIEW_SPEC_ID_PROPS: {
|
|
54
|
+
readonly DataTableBlock: {
|
|
55
|
+
readonly aspectId: "app";
|
|
56
|
+
readonly selectedAspectId: "app";
|
|
57
|
+
};
|
|
58
|
+
readonly ListCollectionBlock: {
|
|
59
|
+
readonly aspectId: "app";
|
|
60
|
+
readonly selectedAspectId: "app";
|
|
61
|
+
};
|
|
62
|
+
readonly ListControlsBlock: {
|
|
63
|
+
readonly filterAspectId: "app";
|
|
64
|
+
};
|
|
65
|
+
readonly ChartBlock: {
|
|
66
|
+
readonly aspectId: "app";
|
|
67
|
+
readonly fieldId: "field";
|
|
68
|
+
readonly groupByFieldId: "field";
|
|
69
|
+
};
|
|
70
|
+
readonly MetricsRowBlock: {
|
|
71
|
+
readonly aspectId: "app";
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/** Props holding nested filter structures, where references may sit at any depth. */
|
|
75
|
+
export declare const AGENT_VIEW_SPEC_FILTER_PROPS: readonly ["filterJson", "filterFields", "quickFilters"];
|
|
76
|
+
type IdPropsFor<T> = T extends keyof typeof AGENT_VIEW_SPEC_ID_PROPS ? (typeof AGENT_VIEW_SPEC_ID_PROPS)[T] : Record<never, never>;
|
|
77
|
+
type FilterProp = (typeof AGENT_VIEW_SPEC_FILTER_PROPS)[number];
|
|
78
|
+
/**
|
|
79
|
+
* Replace the plain-string arm of a prop with a typed reference. `""` stays
|
|
80
|
+
* allowed: the platform accepts an empty id, and unsafePlatformId rejects one.
|
|
81
|
+
*/
|
|
82
|
+
type WithRef<V, R> = V extends string ? R | "" : V;
|
|
83
|
+
/** Allow a reference wherever a string sits inside a nested value. */
|
|
84
|
+
type WithDeepRefs<V> = V extends string ? V | AgentViewSpecFilterRef : V extends ReadonlyArray<infer I> ? ReadonlyArray<WithDeepRefs<I>> : V extends object ? {
|
|
85
|
+
readonly [K in keyof V]: WithDeepRefs<V[K]>;
|
|
86
|
+
} : V;
|
|
87
|
+
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" ? AgentViewSpecField : AgentViewSpecApp> : K extends FilterProp ? WithDeepRefs<P[K]> : T extends "ButtonBlock" ? K extends "buttons" ? MapButtons<P[K]> : P[K] : P[K];
|
|
89
|
+
} : never;
|
|
90
|
+
/** ButtonBlock link items name another managed view by id. */
|
|
91
|
+
type MapButtons<V> = V extends ReadonlyArray<infer I> ? ReadonlyArray<I extends {
|
|
92
|
+
readonly viewId?: string;
|
|
93
|
+
} ? Omit<I, "viewId"> & {
|
|
94
|
+
readonly viewId?: UnsafePlatformId;
|
|
95
|
+
} : I> : V;
|
|
96
|
+
type MapElement<E> = E extends {
|
|
97
|
+
readonly type: infer T;
|
|
98
|
+
readonly props: infer P;
|
|
99
|
+
} ? Omit<E, "props"> & {
|
|
100
|
+
readonly props: MapProps<T, P>;
|
|
101
|
+
} : E;
|
|
102
|
+
/** One block of an agent view's custom view. */
|
|
103
|
+
export type AgentViewBlock = MapElement<ElementumBlocksElement>;
|
|
104
|
+
/** An agent view's custom view: an Elementum Blocks spec with typed references. */
|
|
105
|
+
export type AgentViewCustomView = Omit<ElementumBlocksSpec, "elements"> & {
|
|
106
|
+
readonly elements: {
|
|
107
|
+
readonly [key: string]: AgentViewBlock;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/** The layout customization of an agent view (the admin UI's Layout panel). */
|
|
111
|
+
export interface AppAgentViewLayout {
|
|
112
|
+
readonly image?: AgentViewImage;
|
|
113
|
+
/** The UI's "Welcome header". When unset the page shows its default greeting. */
|
|
114
|
+
readonly header?: string;
|
|
115
|
+
/** The UI's "Welcome sub-header". When unset the page shows the agent's first message. */
|
|
116
|
+
readonly subHeader?: string;
|
|
117
|
+
readonly branding?: AgentViewBranding;
|
|
118
|
+
/** The custom JSON view below the chat. When unset there is none. */
|
|
119
|
+
readonly customView?: AgentViewCustomView;
|
|
120
|
+
}
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Font families the agent view renders. */
|
|
2
|
+
export const agentViewFontFamily = {
|
|
3
|
+
system: "system",
|
|
4
|
+
sans: "sans",
|
|
5
|
+
serif: "serif",
|
|
6
|
+
mono: "mono",
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Per block type, the top-level props that hold platform ids. Ids are scoped
|
|
10
|
+
* per block, not by prop name: DetailsFieldsBlock's `fields[].fieldId` is a
|
|
11
|
+
* render identity, not a field lookup.
|
|
12
|
+
*/
|
|
13
|
+
export const AGENT_VIEW_SPEC_ID_PROPS = {
|
|
14
|
+
DataTableBlock: { aspectId: "app", selectedAspectId: "app" },
|
|
15
|
+
ListCollectionBlock: { aspectId: "app", selectedAspectId: "app" },
|
|
16
|
+
ListControlsBlock: { filterAspectId: "app" },
|
|
17
|
+
ChartBlock: { aspectId: "app", fieldId: "field", groupByFieldId: "field" },
|
|
18
|
+
MetricsRowBlock: { aspectId: "app" },
|
|
19
|
+
};
|
|
20
|
+
/** Props holding nested filter structures, where references may sit at any depth. */
|
|
21
|
+
export const AGENT_VIEW_SPEC_FILTER_PROPS = ["filterJson", "filterFields", "quickFilters"];
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* module never names the app's own resource type.
|
|
7
7
|
*/
|
|
8
8
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
9
|
-
import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
|
|
9
|
+
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
10
|
+
import { type NormalizedManagedViewSort } from "./build.js";
|
|
10
11
|
import type { NormalizedAgentView, NormalizedCalendarView, NormalizedDashboardView, NormalizedKanbanView, NormalizedLayout, NormalizedListView } from "../app/deserializer/normalize.js";
|
|
11
12
|
/** Report every attribute key not in `known` as dialect growth — shared by all four view/section passes below. */
|
|
12
13
|
export interface ViewOwner {
|
|
@@ -32,3 +33,4 @@ export interface ViewsFromTfResult {
|
|
|
32
33
|
}
|
|
33
34
|
/** All three view resource kinds → the normalized shapes the app printer consumes. */
|
|
34
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 managedViewSortFromTf(value: TfValue | undefined, owner: ViewOwner, where: string, ctx: FromTfContext): NormalizedManagedViewSort | undefined;
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* owning app's from-tf drives this pass and says who the owner is — this
|
|
6
6
|
* module never names the app's own resource type.
|
|
7
7
|
*/
|
|
8
|
+
import { agentViewLayoutFromTf } from "./agent-view-layout-from-tf.js";
|
|
8
9
|
import { optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
10
|
import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
|
|
10
|
-
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
11
|
+
import { isTfExpr, isTfLabel, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
11
12
|
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
12
13
|
import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
|
|
13
14
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
@@ -22,7 +23,7 @@ function viewFilter(value, owner, where, ctx) {
|
|
|
22
23
|
ownerTfLabel: owner.ownerTfLabel,
|
|
23
24
|
scope: owner.scope ?? "app",
|
|
24
25
|
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
25
|
-
}, `${where}.filter`, ctx);
|
|
26
|
+
}, `${where}.filter`, ctx, { optionLookupsAreIdentities: true });
|
|
26
27
|
}
|
|
27
28
|
/** All three view resource kinds → the normalized shapes the app printer consumes. */
|
|
28
29
|
export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, kanbanViewBlocks, dashboardViewBlocks, agentViewBlocks, managedViewOrderBlocks, owner, ctx) {
|
|
@@ -206,10 +207,26 @@ function agentViewFromTf(block, owner, ctx) {
|
|
|
206
207
|
const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
|
|
207
208
|
const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
|
|
208
209
|
const filter = viewFilter(attrs["filter"], owner, where, ctx);
|
|
210
|
+
let layout;
|
|
211
|
+
if (attrs["layout"] !== undefined && attrs["layout"] !== null) {
|
|
212
|
+
const decoded = agentViewLayoutFromTf(attrs["layout"], {
|
|
213
|
+
isOwnApp: (value) => resourceRefLabel(value, owner.type) === owner.label,
|
|
214
|
+
fieldKey: (value) => fieldRefFromTf(value, owner.label, owner.ownerTfLabel, scope, ctx),
|
|
215
|
+
});
|
|
216
|
+
if (!decoded.ok) {
|
|
217
|
+
// The code owns the layout: printing the view without it would make the
|
|
218
|
+
// next apply clear the live customization. Leave the view unmanaged.
|
|
219
|
+
ctx.diagnostics.push(`${where}: ${decoded.reason}; the view is left unmanaged so its live layout is not cleared`);
|
|
220
|
+
ctx.skipped.push(`${AGENT_VIEW_RESOURCE_TYPE}.${label}`);
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
layout = decoded.layout;
|
|
224
|
+
}
|
|
209
225
|
return {
|
|
210
226
|
key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
|
|
211
227
|
name: optionalString(attrs, "name", where, ctx) ?? "",
|
|
212
228
|
agentKey: scopedLabelToBagKey(owner.ownerTfLabel, agentLabel, scope),
|
|
229
|
+
...(layout !== undefined && { layout }),
|
|
213
230
|
...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
|
|
214
231
|
...(filter !== undefined && { filter }),
|
|
215
232
|
...(sort !== undefined && { sort }),
|
|
@@ -232,7 +249,7 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
232
249
|
// Elements carry no stage_ids_by_key at all (see element/locals.ts) - an
|
|
233
250
|
// element's stage_id is always "" (build-side, see view/to-tf.ts's
|
|
234
251
|
// layoutToTf) or the platform's own Initiate stage id (a live pull) -
|
|
235
|
-
// neither resolves through
|
|
252
|
+
// neither resolves through stageIndexFromTf. But an element has exactly one
|
|
236
253
|
// possible layout, so "which stage" is never actually ambiguous the way
|
|
237
254
|
// it is for apps: always use the synthetic "layout" key, deterministically,
|
|
238
255
|
// with no diagnostic - matching both elementToTf's own bag key and the
|
|
@@ -254,10 +271,16 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
254
271
|
}
|
|
255
272
|
return { stageKey: "layout", sections };
|
|
256
273
|
}
|
|
257
|
-
const
|
|
274
|
+
const stageIndex = stageIndexFromTf(attrs["stage_id"], owner.label);
|
|
258
275
|
const labelStageKey = scopedLabelToBagKey(owner.ownerTfLabel, label, scope);
|
|
276
|
+
// Layout bag keys are tsLabels; an index outside the tfLabel alphabet keeps
|
|
277
|
+
// the key derived from the resource label instead.
|
|
278
|
+
const stageKey = stageIndex !== undefined && isTfLabel(stageIndex) ? tfLabelToTsLabel(stageIndex) : undefined;
|
|
259
279
|
const canInferStageKey = typeof attrs["stage_id"] === "string" && owner.stageKeys?.has(labelStageKey) === true;
|
|
260
|
-
if (
|
|
280
|
+
if (stageIndex !== undefined && stageKey === undefined) {
|
|
281
|
+
ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(stageIndex)} is outside the terraform label alphabet; using the layout's own label "${label}" as the stage key`);
|
|
282
|
+
}
|
|
283
|
+
else if (stageKey === undefined && !canInferStageKey) {
|
|
261
284
|
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)`);
|
|
262
285
|
}
|
|
263
286
|
const sectionsAttr = attrs["sections"];
|
|
@@ -274,7 +297,7 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
274
297
|
}
|
|
275
298
|
return { stageKey: stageKey ?? labelStageKey, sections };
|
|
276
299
|
}
|
|
277
|
-
function
|
|
300
|
+
function stageIndexFromTf(v, ownerLabel) {
|
|
278
301
|
if (v === undefined || !isTfExpr(v) || v.$expr !== "local")
|
|
279
302
|
return undefined;
|
|
280
303
|
if (v.name !== `${ownerLabel}_stage_ids_by_key`)
|
|
@@ -311,6 +334,18 @@ function sectionFromTf(raw, ownerLabel, ownerTfLabel, scope, where, ctx) {
|
|
|
311
334
|
section.color = rec["color"];
|
|
312
335
|
if (typeof rec["max_columns"] === "number")
|
|
313
336
|
section.maxColumns = rec["max_columns"];
|
|
337
|
+
if (rec["agent_id"] !== undefined) {
|
|
338
|
+
const agentLabel = resourceRefLabel(rec["agent_id"], "elementum_agent");
|
|
339
|
+
if (agentLabel === undefined) {
|
|
340
|
+
ctx.diagnostics.push(`${where}: section agent_id is not an elementum_agent resource reference; agent dropped`);
|
|
341
|
+
}
|
|
342
|
+
else if (scope !== "app") {
|
|
343
|
+
ctx.diagnostics.push(`${where}: agent-assisted sections are only supported on app-owned layouts; agent dropped`);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
section.agentKey = scopedLabelToBagKey(ownerTfLabel, agentLabel, "app");
|
|
347
|
+
}
|
|
348
|
+
}
|
|
314
349
|
const fieldIds = rec["field_ids"];
|
|
315
350
|
if (Array.isArray(fieldIds)) {
|
|
316
351
|
const fields = [];
|
|
@@ -428,7 +463,7 @@ function listViewFromTf(block, owner, ctx) {
|
|
|
428
463
|
function jsonencodeValue(v) {
|
|
429
464
|
return v !== undefined && isTfExpr(v) && v.$expr === "jsonencode" ? v.value : undefined;
|
|
430
465
|
}
|
|
431
|
-
function managedViewSortFromTf(value, owner, where, ctx) {
|
|
466
|
+
export function managedViewSortFromTf(value, owner, where, ctx) {
|
|
432
467
|
if (value === undefined)
|
|
433
468
|
return undefined;
|
|
434
469
|
const decoded = jsonencodeValue(value);
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
* reported, never silent. Invalid authored filter trees fail at build time
|
|
10
10
|
* with the same `EntityTfError` path used by access-policy row filters.
|
|
11
11
|
*/
|
|
12
|
+
import { type AppAgentViewLayoutWire } from "./agent-view-layout-to-tf.js";
|
|
12
13
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
13
14
|
import type { Filter } from "../shared/filters/types.js";
|
|
14
15
|
import type { ManagedViewSharing } from "./sharing.js";
|
|
15
16
|
import type { ListViewDensity, ManagedViewSort } from "./build.js";
|
|
16
17
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
17
|
-
import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
18
|
+
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
18
19
|
/** The authored field-ref shape post-`slimTokens`: a system key string, or a slimmed `FieldRef` token. */
|
|
19
20
|
export type ViewFieldRefWire = string | {
|
|
20
21
|
readonly __kind?: string;
|
|
@@ -30,6 +31,10 @@ export interface AppLayoutSectionWire {
|
|
|
30
31
|
readonly icon?: string;
|
|
31
32
|
readonly color?: string;
|
|
32
33
|
readonly maxColumns?: number;
|
|
34
|
+
readonly agent?: {
|
|
35
|
+
readonly refName?: string;
|
|
36
|
+
readonly parent?: string;
|
|
37
|
+
};
|
|
33
38
|
readonly fields?: readonly ViewFieldRefWire[];
|
|
34
39
|
readonly widgets?: readonly {
|
|
35
40
|
readonly __kind?: string;
|
|
@@ -60,6 +65,7 @@ export interface AppAgentViewWire extends ManagedViewSharing {
|
|
|
60
65
|
readonly filter?: Filter;
|
|
61
66
|
readonly sort?: ManagedViewSort;
|
|
62
67
|
readonly displayOrder?: number;
|
|
68
|
+
readonly layout?: AppAgentViewLayoutWire;
|
|
63
69
|
}
|
|
64
70
|
export interface AppCalendarViewWire extends ManagedViewSharing {
|
|
65
71
|
readonly name?: string;
|
|
@@ -104,6 +110,8 @@ export interface ViewToTfOptions {
|
|
|
104
110
|
/** Declared sibling dashboard keys, for fail-fast dashboard-view references. */
|
|
105
111
|
readonly dashboardKeys?: ReadonlySet<string>;
|
|
106
112
|
readonly orgRefs?: OrgRefLookup;
|
|
113
|
+
/** Sibling workspace apps/elements, for agent view custom-view app references. */
|
|
114
|
+
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
107
115
|
/** Known emitted field addresses keyed by field bag key, for robust reference resolution. */
|
|
108
116
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
109
117
|
/** Declared sibling widget keys, for typed classic-layout placement. */
|
|
@@ -116,3 +124,4 @@ export interface ViewToTfResult {
|
|
|
116
124
|
}
|
|
117
125
|
/** `layouts`/`listViews`/`viewOrder` → their resource blocks, in ei's dialect. */
|
|
118
126
|
export declare function viewToTf(layouts: Readonly<Record<string, AppLayoutWire>> | undefined, listViews: Readonly<Record<string, AppListViewWire>> | undefined, calendarViews: Readonly<Record<string, AppCalendarViewWire>> | undefined, kanbanViews: Readonly<Record<string, AppKanbanViewWire>> | undefined, dashboardViews: Readonly<Record<string, AppDashboardViewWire>> | undefined, agentViews: Readonly<Record<string, AppAgentViewWire>> | undefined, viewOrder: readonly string[] | undefined, opts: ViewToTfOptions): ViewToTfResult;
|
|
127
|
+
export declare function managedViewSortToTf(sort: ManagedViewSort, ownerTfLabel: string, scope: ChildResourceScope, where: string, diagnostics: string[], fieldAddresses?: ReadonlyMap<string, string>): TfValue;
|