@elementumai/edk 0.9.18 → 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 +154 -9
- package/dist-sdk/src/catalog/factories.d.ts +35 -1
- package/dist-sdk/src/catalog/factories.js +36 -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/org.d.ts +39 -1
- package/dist-sdk/src/catalog/org.js +460 -50
- 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 +44 -1
- package/dist-sdk/src/catalog/types.js +13 -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 +64 -27
- package/dist-sdk/src/engine/pull/result-output.d.ts +8 -0
- package/dist-sdk/src/engine/pull/result-output.js +88 -4
- package/dist-sdk/src/engine/tf/expr.js +39 -14
- package/dist-sdk/src/engine/tf/index.d.ts +3 -3
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +8 -0
- package/dist-sdk/src/engine/tf/labels.js +13 -0
- package/dist-sdk/src/engine/tf/model.d.ts +22 -1
- package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
- package/dist-sdk/src/engine/tf/parse.js +197 -10
- 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/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 +16 -6
- 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 +29 -6
- package/dist-sdk/src/entities/app/build.d.ts +98 -19
- package/dist-sdk/src/entities/app/build.js +51 -19
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +22 -1
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +11 -5
- package/dist-sdk/src/entities/app/index.d.ts +6 -5
- package/dist-sdk/src/entities/app/index.js +2 -0
- package/dist-sdk/src/entities/app/module.js +18 -2
- package/dist-sdk/src/entities/app/to-tf.js +21 -11
- package/dist-sdk/src/entities/automation/build.d.ts +49 -6
- package/dist-sdk/src/entities/automation/build.js +163 -19
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +24 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +320 -39
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +563 -74
- 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.d.ts +2 -0
- package/dist-sdk/src/entities/automation/module.js +93 -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.d.ts +16 -0
- package/dist-sdk/src/entities/automation/system-ref-name.js +48 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +47 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +53 -4
- 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 +647 -167
- 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/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 +21 -12
- 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 +72 -30
- 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 +33 -13
- package/dist-sdk/src/entities/element/build.js +5 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/element/from-tf.js +64 -3
- package/dist-sdk/src/entities/element/index.d.ts +5 -2
- package/dist-sdk/src/entities/element/index.js +2 -0
- package/dist-sdk/src/entities/element/module.js +11 -3
- package/dist-sdk/src/entities/element/to-tf.js +20 -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 +3 -0
- package/dist-sdk/src/entities/field/from-tf.js +50 -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 +142 -22
- 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/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
- 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 +10 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +31 -13
- 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 +15 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +25 -2
- package/dist-sdk/src/entities/shared/filters/index.js +38 -5
- package/dist-sdk/src/entities/shared/filters/print.js +31 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +25 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +51 -15
- package/dist-sdk/src/entities/shared/filters/types.d.ts +22 -5
- 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/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/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 +23 -1
- package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill/from-tf.js +70 -22
- 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/input-coverage.d.ts +7 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +11 -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 +19 -6
- 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 +29 -6
- 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 +5 -5
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +89 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +277 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +51 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +360 -0
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +151 -0
- package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +6 -3
- package/dist-sdk/src/entities/view/from-tf.js +161 -14
- package/dist-sdk/src/entities/view/module.js +30 -3
- package/dist-sdk/src/entities/view/to-tf.d.ts +24 -2
- package/dist-sdk/src/entities/view/to-tf.js +95 -9
- package/dist-sdk/src/entities/view/types.d.ts +4 -15
- package/dist-sdk/src/entities/view/types.js +17 -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 +36 -10
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +38 -10
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +54 -0
- package/dist-sdk/src/graph/index.js +30 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +133 -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 +11 -1
|
@@ -5,15 +5,17 @@
|
|
|
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 {
|
|
8
|
+
import { agentViewLayoutFromTf, viewBlocksFromTf, } from "./agent-view-layout-from-tf.js";
|
|
9
|
+
import { dataRefLabel, 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 { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
11
|
+
import { isTfExpr, isTfLabel, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
12
|
+
import { decodeForeignDataField, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
13
|
+
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
12
14
|
import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
|
|
13
15
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
14
16
|
import { filterFromTf, principalList } from "../access-policy/from-tf.js";
|
|
15
17
|
import { listViewDensity, } from "./build.js";
|
|
16
|
-
import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, KNOWN_AGENT_VIEW_ATTRS, KNOWN_CALENDAR_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";
|
|
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";
|
|
17
19
|
function viewFilter(value, owner, where, ctx) {
|
|
18
20
|
return value === undefined ? undefined : filterFromTf(value, {
|
|
19
21
|
type: owner.type,
|
|
@@ -22,10 +24,10 @@ function viewFilter(value, owner, where, ctx) {
|
|
|
22
24
|
ownerTfLabel: owner.ownerTfLabel,
|
|
23
25
|
scope: owner.scope ?? "app",
|
|
24
26
|
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
25
|
-
}, `${where}.filter`, ctx);
|
|
27
|
+
}, `${where}.filter`, ctx, { optionLookupsAreIdentities: true });
|
|
26
28
|
}
|
|
27
29
|
/** All three view resource kinds → the normalized shapes the app printer consumes. */
|
|
28
|
-
export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, kanbanViewBlocks, dashboardViewBlocks, agentViewBlocks, managedViewOrderBlocks, owner, ctx) {
|
|
30
|
+
export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, kanbanViewBlocks, dashboardViewBlocks, agentViewBlocks, managedViewOrderBlocks, owner, ctx, customViewBlocks = []) {
|
|
29
31
|
const layouts = [];
|
|
30
32
|
for (const block of layoutBlocks) {
|
|
31
33
|
const layout = layoutFromTf(block, owner, ctx);
|
|
@@ -49,6 +51,14 @@ export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, ka
|
|
|
49
51
|
keyByAddress.set(`${AGENT_VIEW_RESOURCE_TYPE}.${block.label ?? ""}`, view.key);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
54
|
+
const customViews = [];
|
|
55
|
+
for (const block of customViewBlocks) {
|
|
56
|
+
const view = customViewFromTf(block, owner, ctx);
|
|
57
|
+
if (view !== undefined) {
|
|
58
|
+
customViews.push(view);
|
|
59
|
+
keyByAddress.set(`${CUSTOM_VIEW_RESOURCE_TYPE}.${block.label ?? ""}`, view.key);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
52
62
|
const calendarViews = [];
|
|
53
63
|
for (const block of calendarViewBlocks) {
|
|
54
64
|
const view = calendarViewFromTf(block, owner, ctx);
|
|
@@ -82,7 +92,68 @@ export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, ka
|
|
|
82
92
|
}
|
|
83
93
|
viewOrder = managedViewOrderFromTf(block, owner, keyByAddress, ctx);
|
|
84
94
|
}
|
|
85
|
-
return { layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, ...(viewOrder !== undefined ? { viewOrder } : {}) };
|
|
95
|
+
return { layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews, ...(viewOrder !== undefined ? { viewOrder } : {}) };
|
|
96
|
+
}
|
|
97
|
+
function customViewFromTf(block, owner, ctx) {
|
|
98
|
+
const label = block.label;
|
|
99
|
+
if (label === undefined || label === "") {
|
|
100
|
+
ctx.diagnostics.push(`${CUSTOM_VIEW_RESOURCE_TYPE} block is missing its label; skipped`);
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const attrs = block.attrs;
|
|
104
|
+
const where = `custom view "${label}"`;
|
|
105
|
+
reportUnknownAttrs(attrs, KNOWN_CUSTOM_VIEW_ATTRS, where, "customViewFromTf", ctx);
|
|
106
|
+
if (resourceRefLabel(attrs["aspect_id"], owner.type) !== owner.label) {
|
|
107
|
+
ctx.diagnostics.push(`${where}: aspect_id does not reference ${owner.type}.${owner.label}; skipped`);
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const scope = owner.scope ?? "app";
|
|
111
|
+
// An unmanaged view keeps its live layout and agent; printing a partial one
|
|
112
|
+
// would make the next apply clear them.
|
|
113
|
+
const unmanaged = (reason) => {
|
|
114
|
+
ctx.diagnostics.push(`${where}: ${reason}; the view is left unmanaged so its live layout is not cleared`);
|
|
115
|
+
ctx.skipped.push(`${CUSTOM_VIEW_RESOURCE_TYPE}.${label}`);
|
|
116
|
+
return undefined;
|
|
117
|
+
};
|
|
118
|
+
let agentKey;
|
|
119
|
+
if (attrs["agent_id"] !== undefined && attrs["agent_id"] !== null) {
|
|
120
|
+
// Agents are app-owned: an element's view cannot name its agent in source,
|
|
121
|
+
// and building it without the agent would detach it on apply.
|
|
122
|
+
if (scope === "element")
|
|
123
|
+
return unmanaged("element views cannot reference an agent in source");
|
|
124
|
+
const agentLabel = resourceRefLabel(attrs["agent_id"], "elementum_agent");
|
|
125
|
+
if (agentLabel === undefined)
|
|
126
|
+
return unmanaged("agent_id is not an elementum_agent resource reference");
|
|
127
|
+
agentKey = scopedLabelToBagKey(owner.ownerTfLabel, agentLabel, scope);
|
|
128
|
+
}
|
|
129
|
+
let layout;
|
|
130
|
+
const layoutAttr = attrs["layout"];
|
|
131
|
+
if (layoutAttr !== undefined && layoutAttr !== null) {
|
|
132
|
+
if (!isTfExpr(layoutAttr) || layoutAttr.$expr !== "jsonencode")
|
|
133
|
+
return unmanaged("layout is not a jsonencode(...) expression");
|
|
134
|
+
const decoded = viewBlocksFromTf(layoutAttr.value, layoutRefOptions(owner, ctx));
|
|
135
|
+
if (!decoded.ok)
|
|
136
|
+
return unmanaged(decoded.reason);
|
|
137
|
+
layout = decoded.layout;
|
|
138
|
+
}
|
|
139
|
+
const sort = managedViewSortFromTf(attrs["sort"], owner, where, ctx);
|
|
140
|
+
const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
|
|
141
|
+
const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
|
|
142
|
+
const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
|
|
143
|
+
const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
|
|
144
|
+
const filter = viewFilter(attrs["filter"], owner, where, ctx);
|
|
145
|
+
return {
|
|
146
|
+
key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
|
|
147
|
+
name: optionalString(attrs, "name", where, ctx) ?? "",
|
|
148
|
+
...(agentKey !== undefined && { agentKey }),
|
|
149
|
+
...(layout !== undefined && { layout }),
|
|
150
|
+
...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
|
|
151
|
+
...(filter !== undefined && { filter }),
|
|
152
|
+
...(sort !== undefined && { sort }),
|
|
153
|
+
...(userIds !== undefined ? { userIds } : emptyUserIds ? { userIds: [] } : {}),
|
|
154
|
+
...(groupIds !== undefined ? { groupIds } : emptyGroupIds ? { groupIds: [] } : {}),
|
|
155
|
+
...(typeof attrs["display_order"] === "number" && { displayOrder: attrs["display_order"] }),
|
|
156
|
+
};
|
|
86
157
|
}
|
|
87
158
|
function dashboardViewFromTf(block, owner, ctx) {
|
|
88
159
|
const label = block.label;
|
|
@@ -181,6 +252,48 @@ function typedFieldViewFromTf(block, owner, resourceType, knownAttrs, includeAll
|
|
|
181
252
|
...(groupIds !== undefined ? { groupIds } : emptyGroupIds ? { groupIds: [] } : {}),
|
|
182
253
|
};
|
|
183
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* How a blocks layout's references pull: the owner and its fields, and other
|
|
257
|
+
* apps and elements and their fields through the export's data lookups.
|
|
258
|
+
*/
|
|
259
|
+
function layoutRefOptions(owner, ctx) {
|
|
260
|
+
const foreignSource = (value) => {
|
|
261
|
+
for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
|
|
262
|
+
const dataLabel = dataRefLabel(value, type);
|
|
263
|
+
if (dataLabel === undefined)
|
|
264
|
+
continue;
|
|
265
|
+
const target = resolveDataAspectTarget(ctx, kind, dataLabel);
|
|
266
|
+
return { __specRef: "source", kind, key: target.key, name: target.name, ...(target.namespace !== undefined && { namespace: target.namespace }) };
|
|
267
|
+
}
|
|
268
|
+
return undefined;
|
|
269
|
+
};
|
|
270
|
+
return {
|
|
271
|
+
isOwnApp: (value) => resourceRefLabel(value, owner.type) === owner.label,
|
|
272
|
+
fieldKey: (value) => fieldRefFromTf(value, owner.label, owner.ownerTfLabel, owner.scope ?? "app", ctx),
|
|
273
|
+
foreignSource,
|
|
274
|
+
foreignField: (value) => {
|
|
275
|
+
const dataLabel = dataRefLabel(value, "elementum_field");
|
|
276
|
+
const parent = dataLabel === undefined ? undefined : foreignSource(ctx.dataAttrs?.("elementum_field", dataLabel)?.["object_id"] ?? null);
|
|
277
|
+
if (dataLabel === undefined || parent === undefined)
|
|
278
|
+
return undefined;
|
|
279
|
+
const field = decodeForeignDataField(dataLabel, { key: parent.key, name: parent.name, namespace: parent.namespace, kind: parent.kind }, ctx);
|
|
280
|
+
return {
|
|
281
|
+
__specRef: "foreignField",
|
|
282
|
+
key: field.key,
|
|
283
|
+
name: field.name,
|
|
284
|
+
// The pull's ref-only catalog normally supplies the type. Without it,
|
|
285
|
+
// fall back to TEXT like every other foreign field ref the EDK prints
|
|
286
|
+
// (widgets, relationship columns, filters): build looks a foreign
|
|
287
|
+
// field up by owner and name, never by type, so the guess is cosmetic.
|
|
288
|
+
fieldType: field.fieldType ?? "TEXT",
|
|
289
|
+
parent: ctx.foreignFieldRefsByDataAddress?.get(`elementum_field.${dataLabel}`)?.ownerRefName ?? parent.key,
|
|
290
|
+
parentKind: parent.kind,
|
|
291
|
+
parentName: parent.name,
|
|
292
|
+
...(parent.namespace !== undefined && { parentNamespace: parent.namespace }),
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
184
297
|
function agentViewFromTf(block, owner, ctx) {
|
|
185
298
|
const label = block.label;
|
|
186
299
|
if (label === undefined || label === "") {
|
|
@@ -206,10 +319,23 @@ function agentViewFromTf(block, owner, ctx) {
|
|
|
206
319
|
const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
|
|
207
320
|
const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
|
|
208
321
|
const filter = viewFilter(attrs["filter"], owner, where, ctx);
|
|
322
|
+
let layout;
|
|
323
|
+
if (attrs["layout"] !== undefined && attrs["layout"] !== null) {
|
|
324
|
+
const decoded = agentViewLayoutFromTf(attrs["layout"], layoutRefOptions(owner, ctx));
|
|
325
|
+
if (!decoded.ok) {
|
|
326
|
+
// The code owns the layout: printing the view without it would make the
|
|
327
|
+
// next apply clear the live customization. Leave the view unmanaged.
|
|
328
|
+
ctx.diagnostics.push(`${where}: ${decoded.reason}; the view is left unmanaged so its live layout is not cleared`);
|
|
329
|
+
ctx.skipped.push(`${AGENT_VIEW_RESOURCE_TYPE}.${label}`);
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
layout = decoded.layout;
|
|
333
|
+
}
|
|
209
334
|
return {
|
|
210
335
|
key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
|
|
211
336
|
name: optionalString(attrs, "name", where, ctx) ?? "",
|
|
212
337
|
agentKey: scopedLabelToBagKey(owner.ownerTfLabel, agentLabel, scope),
|
|
338
|
+
...(layout !== undefined && { layout }),
|
|
213
339
|
...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
|
|
214
340
|
...(filter !== undefined && { filter }),
|
|
215
341
|
...(sort !== undefined && { sort }),
|
|
@@ -232,7 +358,7 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
232
358
|
// Elements carry no stage_ids_by_key at all (see element/locals.ts) - an
|
|
233
359
|
// element's stage_id is always "" (build-side, see view/to-tf.ts's
|
|
234
360
|
// layoutToTf) or the platform's own Initiate stage id (a live pull) -
|
|
235
|
-
// neither resolves through
|
|
361
|
+
// neither resolves through stageIndexFromTf. But an element has exactly one
|
|
236
362
|
// possible layout, so "which stage" is never actually ambiguous the way
|
|
237
363
|
// it is for apps: always use the synthetic "layout" key, deterministically,
|
|
238
364
|
// with no diagnostic - matching both elementToTf's own bag key and the
|
|
@@ -254,10 +380,16 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
254
380
|
}
|
|
255
381
|
return { stageKey: "layout", sections };
|
|
256
382
|
}
|
|
257
|
-
const
|
|
383
|
+
const stageIndex = stageIndexFromTf(attrs["stage_id"], owner.label);
|
|
258
384
|
const labelStageKey = scopedLabelToBagKey(owner.ownerTfLabel, label, scope);
|
|
385
|
+
// Layout bag keys are tsLabels; an index outside the tfLabel alphabet keeps
|
|
386
|
+
// the key derived from the resource label instead.
|
|
387
|
+
const stageKey = stageIndex !== undefined && isTfLabel(stageIndex) ? tfLabelToTsLabel(stageIndex) : undefined;
|
|
259
388
|
const canInferStageKey = typeof attrs["stage_id"] === "string" && owner.stageKeys?.has(labelStageKey) === true;
|
|
260
|
-
if (
|
|
389
|
+
if (stageIndex !== undefined && stageKey === undefined) {
|
|
390
|
+
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`);
|
|
391
|
+
}
|
|
392
|
+
else if (stageKey === undefined && !canInferStageKey) {
|
|
261
393
|
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
394
|
}
|
|
263
395
|
const sectionsAttr = attrs["sections"];
|
|
@@ -274,7 +406,7 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
274
406
|
}
|
|
275
407
|
return { stageKey: stageKey ?? labelStageKey, sections };
|
|
276
408
|
}
|
|
277
|
-
function
|
|
409
|
+
function stageIndexFromTf(v, ownerLabel) {
|
|
278
410
|
if (v === undefined || !isTfExpr(v) || v.$expr !== "local")
|
|
279
411
|
return undefined;
|
|
280
412
|
if (v.name !== `${ownerLabel}_stage_ids_by_key`)
|
|
@@ -311,6 +443,18 @@ function sectionFromTf(raw, ownerLabel, ownerTfLabel, scope, where, ctx) {
|
|
|
311
443
|
section.color = rec["color"];
|
|
312
444
|
if (typeof rec["max_columns"] === "number")
|
|
313
445
|
section.maxColumns = rec["max_columns"];
|
|
446
|
+
if (rec["agent_id"] !== undefined) {
|
|
447
|
+
const agentLabel = resourceRefLabel(rec["agent_id"], "elementum_agent");
|
|
448
|
+
if (agentLabel === undefined) {
|
|
449
|
+
ctx.diagnostics.push(`${where}: section agent_id is not an elementum_agent resource reference; agent dropped`);
|
|
450
|
+
}
|
|
451
|
+
else if (scope !== "app") {
|
|
452
|
+
ctx.diagnostics.push(`${where}: agent-assisted sections are only supported on app-owned layouts; agent dropped`);
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
section.agentKey = scopedLabelToBagKey(ownerTfLabel, agentLabel, "app");
|
|
456
|
+
}
|
|
457
|
+
}
|
|
314
458
|
const fieldIds = rec["field_ids"];
|
|
315
459
|
if (Array.isArray(fieldIds)) {
|
|
316
460
|
const fields = [];
|
|
@@ -428,7 +572,7 @@ function listViewFromTf(block, owner, ctx) {
|
|
|
428
572
|
function jsonencodeValue(v) {
|
|
429
573
|
return v !== undefined && isTfExpr(v) && v.$expr === "jsonencode" ? v.value : undefined;
|
|
430
574
|
}
|
|
431
|
-
function managedViewSortFromTf(value, owner, where, ctx) {
|
|
575
|
+
export function managedViewSortFromTf(value, owner, where, ctx) {
|
|
432
576
|
if (value === undefined)
|
|
433
577
|
return undefined;
|
|
434
578
|
const decoded = jsonencodeValue(value);
|
|
@@ -504,6 +648,7 @@ function managedViewOrderFromTf(block, owner, keyByAddress, ctx) {
|
|
|
504
648
|
const calendarLabel = resourceRefLabel(v, CALENDAR_VIEW_RESOURCE_TYPE);
|
|
505
649
|
const kanbanLabel = resourceRefLabel(v, KANBAN_VIEW_RESOURCE_TYPE);
|
|
506
650
|
const dashboardLabel = resourceRefLabel(v, DASHBOARD_VIEW_RESOURCE_TYPE);
|
|
651
|
+
const customLabel = resourceRefLabel(v, CUSTOM_VIEW_RESOURCE_TYPE);
|
|
507
652
|
const key = listLabel !== undefined
|
|
508
653
|
? keyByAddress.get(`${LIST_VIEW_RESOURCE_TYPE}.${listLabel}`)
|
|
509
654
|
: agentLabel !== undefined
|
|
@@ -514,9 +659,11 @@ function managedViewOrderFromTf(block, owner, keyByAddress, ctx) {
|
|
|
514
659
|
? keyByAddress.get(`${KANBAN_VIEW_RESOURCE_TYPE}.${kanbanLabel}`)
|
|
515
660
|
: dashboardLabel !== undefined
|
|
516
661
|
? keyByAddress.get(`${DASHBOARD_VIEW_RESOURCE_TYPE}.${dashboardLabel}`)
|
|
517
|
-
: undefined
|
|
662
|
+
: customLabel !== undefined
|
|
663
|
+
? keyByAddress.get(`${CUSTOM_VIEW_RESOURCE_TYPE}.${customLabel}`)
|
|
664
|
+
: undefined;
|
|
518
665
|
if (key === undefined) {
|
|
519
|
-
ctx.diagnostics.push(`${where}: a view_ids entry does not resolve to a known
|
|
666
|
+
ctx.diagnostics.push(`${where}: a view_ids entry does not resolve to a known managed view; dropped`);
|
|
520
667
|
continue;
|
|
521
668
|
}
|
|
522
669
|
order.push(key);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** The view entity's registry entries (see src/graph/). */
|
|
2
|
+
import { asNamedRef, namedFactoryEntry } from "../../catalog/render-helpers.js";
|
|
2
3
|
import { NO_CANVAS, NO_CATALOG, NO_DATA, NO_LIFECYCLE, } from "../../graph/types.js";
|
|
3
|
-
import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, } from "./types.js";
|
|
4
|
+
import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, VIEW_DATA_RESOURCE_TYPE, } from "./types.js";
|
|
4
5
|
/**
|
|
5
6
|
* Layouts + list views are stream members folded into the app authoring file
|
|
6
7
|
* (inline), extracted by `appFromTf` — not own-file kinds.
|
|
@@ -22,12 +23,38 @@ export const viewModule = {
|
|
|
22
23
|
{ key: "calendarView", resourceType: CALENDAR_VIEW_RESOURCE_TYPE, implemented: true },
|
|
23
24
|
{ key: "dashboardView", resourceType: DASHBOARD_VIEW_RESOURCE_TYPE, implemented: true },
|
|
24
25
|
{ key: "kanbanView", resourceType: KANBAN_VIEW_RESOURCE_TYPE, implemented: true },
|
|
26
|
+
{ key: "customView", resourceType: CUSTOM_VIEW_RESOURCE_TYPE, implemented: true },
|
|
25
27
|
],
|
|
26
28
|
},
|
|
27
|
-
|
|
29
|
+
// A portal menu names a view outside the workspace by owner and name.
|
|
30
|
+
data: { participates: true, resourceType: VIEW_DATA_RESOURCE_TYPE, lookupAttr: "name", referencedByBuild: true },
|
|
28
31
|
lifecycle: NO_LIFECYCLE,
|
|
29
32
|
canvas: NO_CANVAS,
|
|
30
|
-
|
|
33
|
+
// Inline under the app/element: generated catalogs read `views` live from
|
|
34
|
+
// the owner's `.ref()` (like fields), so other stream roots — a portal's
|
|
35
|
+
// menu — can reference a view by owner and name.
|
|
36
|
+
catalog: {
|
|
37
|
+
participates: true,
|
|
38
|
+
refKind: "view",
|
|
39
|
+
catalogBag: "views",
|
|
40
|
+
renderOrder: 51,
|
|
41
|
+
catalogRoot: "app",
|
|
42
|
+
fromOwnRef: true,
|
|
43
|
+
renderEntry: (args) => {
|
|
44
|
+
const named = asNamedRef(args.ref);
|
|
45
|
+
const viewType = args.ref.viewType;
|
|
46
|
+
return namedFactoryEntry({
|
|
47
|
+
factoryName: "viewRef",
|
|
48
|
+
keyName: args.keyName,
|
|
49
|
+
baseIndent: args.baseIndent,
|
|
50
|
+
name: named.name,
|
|
51
|
+
parent: named.parent,
|
|
52
|
+
...(viewType !== undefined ? { extraParts: [`viewType: ${JSON.stringify(viewType)}`] } : {}),
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
stubRef: (refName, parent) => ({ __kind: "view", refName, name: refName, parent }),
|
|
56
|
+
refFromAuthoring: () => undefined,
|
|
57
|
+
},
|
|
31
58
|
};
|
|
32
59
|
/**
|
|
33
60
|
* `elementum_managed_view_order` is a singleton per aspect with no identity
|
|
@@ -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,20 @@ export interface AppAgentViewWire extends ManagedViewSharing {
|
|
|
60
65
|
readonly filter?: Filter;
|
|
61
66
|
readonly sort?: ManagedViewSort;
|
|
62
67
|
readonly displayOrder?: number;
|
|
68
|
+
readonly layout?: AppAgentViewLayoutWire;
|
|
69
|
+
}
|
|
70
|
+
export interface AppCustomViewWire extends ManagedViewSharing {
|
|
71
|
+
readonly name?: string;
|
|
72
|
+
readonly agent?: {
|
|
73
|
+
readonly refName?: string;
|
|
74
|
+
readonly parent?: string;
|
|
75
|
+
};
|
|
76
|
+
readonly allowRecordCreation?: boolean;
|
|
77
|
+
readonly filter?: Filter;
|
|
78
|
+
readonly sort?: ManagedViewSort;
|
|
79
|
+
readonly displayOrder?: number;
|
|
80
|
+
/** A blocks layout (the public type, unchecked). */
|
|
81
|
+
readonly layout?: unknown;
|
|
63
82
|
}
|
|
64
83
|
export interface AppCalendarViewWire extends ManagedViewSharing {
|
|
65
84
|
readonly name?: string;
|
|
@@ -104,6 +123,8 @@ export interface ViewToTfOptions {
|
|
|
104
123
|
/** Declared sibling dashboard keys, for fail-fast dashboard-view references. */
|
|
105
124
|
readonly dashboardKeys?: ReadonlySet<string>;
|
|
106
125
|
readonly orgRefs?: OrgRefLookup;
|
|
126
|
+
/** Sibling workspace apps/elements, for agent view custom-view app references. */
|
|
127
|
+
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
107
128
|
/** Known emitted field addresses keyed by field bag key, for robust reference resolution. */
|
|
108
129
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
109
130
|
/** Declared sibling widget keys, for typed classic-layout placement. */
|
|
@@ -115,4 +136,5 @@ export interface ViewToTfResult {
|
|
|
115
136
|
readonly blocks: readonly TfBlock[];
|
|
116
137
|
}
|
|
117
138
|
/** `layouts`/`listViews`/`viewOrder` → their resource blocks, in ei's dialect. */
|
|
118
|
-
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;
|
|
139
|
+
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, customViews?: Readonly<Record<string, AppCustomViewWire>>): ViewToTfResult;
|
|
140
|
+
export declare function managedViewSortToTf(sort: ManagedViewSort, ownerTfLabel: string, scope: ChildResourceScope, where: string, diagnostics: string[], fieldAddresses?: ReadonlyMap<string, string>): TfValue;
|
|
@@ -9,6 +9,7 @@
|
|
|
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 { agentViewLayoutToTf, viewBlocksToTf } from "./agent-view-layout-to-tf.js";
|
|
12
13
|
import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
13
14
|
import { fieldRefToTfValue as customFieldRefToTfValue } from "../field/to-tf.js";
|
|
14
15
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
@@ -16,7 +17,7 @@ import { filterToTf, principalListToTf } from "../access-policy/to-tf.js";
|
|
|
16
17
|
import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
|
|
17
18
|
import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
|
|
18
19
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
19
|
-
import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, LAYOUT_RESOURCE_TYPE,
|
|
20
|
+
import { AGENT_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, SECTION_TYPE_TO_WIRE, SYSTEM_FIELD_ID_ATTR_BY_KEY, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
|
|
20
21
|
function appendViewSharingAttrs(attrs, view, where, ctx) {
|
|
21
22
|
const userIds = principalListToTf(view.userIds, "elementum_user", `${where}.userIds`, ctx);
|
|
22
23
|
const groupIds = principalListToTf(view.groupIds, "elementum_group", `${where}.groupIds`, ctx);
|
|
@@ -34,7 +35,7 @@ function appendViewSharingAttrs(attrs, view, where, ctx) {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
/** `layouts`/`listViews`/`viewOrder` → their resource blocks, in ei's dialect. */
|
|
37
|
-
export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, viewOrder, opts) {
|
|
38
|
+
export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, viewOrder, opts, customViews) {
|
|
38
39
|
const { ownerRefName, ownerTfLabel, scope = "app", aspectName, objectId, diagnostics, fieldAddresses } = opts;
|
|
39
40
|
const principalCtx = { ...opts, scope, objectId };
|
|
40
41
|
const blocks = [];
|
|
@@ -208,9 +209,76 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
208
209
|
appendViewSharingAttrs(attrs, view, `agentViews.${viewKey}`, principalCtx);
|
|
209
210
|
if (view.displayOrder !== undefined)
|
|
210
211
|
attrs["display_order"] = view.displayOrder;
|
|
212
|
+
if (view.layout !== undefined) {
|
|
213
|
+
attrs["layout"] = agentViewLayoutToTf(view.layout, `agentViews.${viewKey}.layout`, {
|
|
214
|
+
ownerRefName,
|
|
215
|
+
ownerTfLabel,
|
|
216
|
+
scope,
|
|
217
|
+
objectId,
|
|
218
|
+
diagnostics,
|
|
219
|
+
fieldAddresses,
|
|
220
|
+
orgRefs: opts.orgRefs,
|
|
221
|
+
workspaceAspects: opts.workspaceAspects,
|
|
222
|
+
resolveField: (ref, where) => fieldRefToTfValue(ref, ownerTfLabel, scope, where, diagnostics, fieldAddresses),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
211
225
|
blocks.push({ kind: "resource", type: AGENT_VIEW_RESOURCE_TYPE, label: tfLabel, attrs });
|
|
212
226
|
viewAddressByKey.set(viewKey, { type: AGENT_VIEW_RESOURCE_TYPE, label: tfLabel });
|
|
213
227
|
}
|
|
228
|
+
for (const [viewKey, view] of Object.entries(customViews ?? {})) {
|
|
229
|
+
const where = `customViews.${viewKey}`;
|
|
230
|
+
if (!isCanonicalTsLabel(viewKey)) {
|
|
231
|
+
diagnostics.push(`customViews key "${viewKey}" is not a canonical tsLabel (see src/engine/tf/labels.ts) — rename the key`);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (viewAddressByKey.has(viewKey)) {
|
|
235
|
+
diagnostics.push(`${where} collides with another view key; dropped`);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const tfLabel = scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(viewKey), scope);
|
|
239
|
+
const attrs = {
|
|
240
|
+
aspect_id: objectId,
|
|
241
|
+
name: view.name ?? "",
|
|
242
|
+
allow_record_creation: view.allowRecordCreation ?? true,
|
|
243
|
+
};
|
|
244
|
+
if (view.agent !== undefined) {
|
|
245
|
+
const agentRefName = view.agent.refName ?? "";
|
|
246
|
+
if (agentRefName === "" || view.agent.parent !== ownerRefName) {
|
|
247
|
+
// Dropping only the agent would detach it on apply; keep the whole view out instead.
|
|
248
|
+
diagnostics.push(`${where}.agent must be an agent of this ${scope === "element" ? "element" : "app"}; dropped`);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
attrs["agent_id"] = expr.resourceAttr("elementum_agent", scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(agentRefName), scope), ["id"]);
|
|
252
|
+
}
|
|
253
|
+
if (view.filter !== undefined)
|
|
254
|
+
attrs["filter"] = filterToTf(view.filter, `${where}.filter`, { ownerTfLabel, appRefName: ownerRefName, scope, objectId, diagnostics, resolvePicklistLiterals: false, fieldAddresses });
|
|
255
|
+
if (view.sort !== undefined)
|
|
256
|
+
attrs["sort"] = managedViewSortToTf(view.sort, ownerTfLabel, scope, `${where}.sort`, diagnostics, fieldAddresses);
|
|
257
|
+
appendViewSharingAttrs(attrs, view, where, principalCtx);
|
|
258
|
+
if (view.displayOrder !== undefined)
|
|
259
|
+
attrs["display_order"] = view.displayOrder;
|
|
260
|
+
if (view.layout !== undefined) {
|
|
261
|
+
attrs["layout"] = expr.jsonencode(viewBlocksToTf(view.layout, `${where}.layout`, {
|
|
262
|
+
ownerRefName,
|
|
263
|
+
ownerKind: scope === "element" ? "element" : "app",
|
|
264
|
+
ownerTfLabel,
|
|
265
|
+
scope,
|
|
266
|
+
objectId,
|
|
267
|
+
diagnostics,
|
|
268
|
+
fieldAddresses,
|
|
269
|
+
orgRefs: opts.orgRefs,
|
|
270
|
+
workspaceAspects: opts.workspaceAspects,
|
|
271
|
+
resolveField: (ref, fieldWhere) => fieldRefToTfValue(ref, ownerTfLabel, scope, fieldWhere, diagnostics, fieldAddresses),
|
|
272
|
+
}, { editorPolicy: false }));
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
// The page needs a layout document, and the platform rejects a blank
|
|
276
|
+
// one, so a view without a layout cannot be opened in the admin UI.
|
|
277
|
+
diagnostics.push(`${where} has no layout, so the admin UI cannot open this view ("This custom view could not be loaded"); add a layout`);
|
|
278
|
+
}
|
|
279
|
+
blocks.push({ kind: "resource", type: CUSTOM_VIEW_RESOURCE_TYPE, label: tfLabel, attrs });
|
|
280
|
+
viewAddressByKey.set(viewKey, { type: CUSTOM_VIEW_RESOURCE_TYPE, label: tfLabel });
|
|
281
|
+
}
|
|
214
282
|
if (viewAddressByKey.size > 0) {
|
|
215
283
|
const orderKeys = viewOrder ?? [
|
|
216
284
|
...Object.keys(listViews ?? {}),
|
|
@@ -218,6 +286,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
218
286
|
...Object.keys(kanbanViews ?? {}),
|
|
219
287
|
...Object.keys(dashboardViews ?? {}),
|
|
220
288
|
...Object.keys(agentViews ?? {}),
|
|
289
|
+
...Object.keys(customViews ?? {}),
|
|
221
290
|
];
|
|
222
291
|
const placed = new Set();
|
|
223
292
|
const viewIds = [];
|
|
@@ -250,7 +319,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
250
319
|
}
|
|
251
320
|
return { blocks };
|
|
252
321
|
}
|
|
253
|
-
function managedViewSortToTf(sort, ownerTfLabel, scope, where, diagnostics, fieldAddresses) {
|
|
322
|
+
export function managedViewSortToTf(sort, ownerTfLabel, scope, where, diagnostics, fieldAddresses) {
|
|
254
323
|
const orders = [];
|
|
255
324
|
for (const [index, order] of sort.orders.entries()) {
|
|
256
325
|
const field = fieldRefToTfValue(order.field, ownerTfLabel, scope, `${where}.orders[${index}].field`, diagnostics, fieldAddresses);
|
|
@@ -292,13 +361,30 @@ function layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectI
|
|
|
292
361
|
if (section.maxColumns !== undefined)
|
|
293
362
|
sec.max_columns = section.maxColumns;
|
|
294
363
|
const where = `layouts.${stageKey} section "${section.name ?? ""}"`;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
364
|
+
if (section.agent !== undefined) {
|
|
365
|
+
const agentRefName = section.agent.refName ?? "";
|
|
366
|
+
if (scope !== "app") {
|
|
367
|
+
diagnostics.push(`${where}: agent-assisted sections are only resolvable for app-owned agents; agent dropped`);
|
|
299
368
|
}
|
|
300
|
-
|
|
301
|
-
|
|
369
|
+
else if (section.agent.parent !== ownerRefName) {
|
|
370
|
+
diagnostics.push(`${where}: agent belongs to ${JSON.stringify(section.agent.parent)}, not ${JSON.stringify(ownerRefName)}; agent dropped`);
|
|
371
|
+
}
|
|
372
|
+
else if (!isCanonicalTsLabel(agentRefName)) {
|
|
373
|
+
diagnostics.push(`${where}: agent key "${agentRefName}" is not a canonical tsLabel; agent dropped`);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
sec.agent_id = expr.resourceAttr("elementum_agent", scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(agentRefName), "app"), ["id"]);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// System fields (ID/Title/Status included) are kept in their authored
|
|
380
|
+
// position as the owner's `local.<ns>_<key>_field_id`. A UI-placed
|
|
381
|
+
// system field is a real section member: the provider reads it back
|
|
382
|
+
// into `field_ids` and `ei export` emits it (as its platform id), so
|
|
383
|
+
// dropping it here rebuilt a shorter list, which plans a destructive
|
|
384
|
+
// replace that removes the field from the live section. The platform
|
|
385
|
+
// accepts ID/Title/Status field blocks like any field, so the
|
|
386
|
+
// provider re-places them when it recreates the layout.
|
|
387
|
+
const fields = section.fields ?? [];
|
|
302
388
|
const widgetIds = [];
|
|
303
389
|
for (const [index, widget] of (section.widgets ?? []).entries()) {
|
|
304
390
|
const widgetWhere = `${where}.widgets[${index}]`;
|
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
export declare const LAYOUT_RESOURCE_TYPE = "elementum_layout";
|
|
14
14
|
export declare const LIST_VIEW_RESOURCE_TYPE = "elementum_list_view";
|
|
15
15
|
export declare const AGENT_VIEW_RESOURCE_TYPE = "elementum_agent_view";
|
|
16
|
+
export declare const CUSTOM_VIEW_RESOURCE_TYPE = "elementum_custom_view";
|
|
16
17
|
export declare const CALENDAR_VIEW_RESOURCE_TYPE = "elementum_calendar_view";
|
|
17
18
|
export declare const KANBAN_VIEW_RESOURCE_TYPE = "elementum_kanban_view";
|
|
18
19
|
export declare const DASHBOARD_VIEW_RESOURCE_TYPE = "elementum_dashboard_view";
|
|
19
20
|
export declare const MANAGED_VIEW_ORDER_RESOURCE_TYPE = "elementum_managed_view_order";
|
|
21
|
+
/** Looks up a managed view by owner and name (a portal menu's view outside the workspace). */
|
|
22
|
+
export declare const VIEW_DATA_RESOURCE_TYPE = "elementum_view";
|
|
20
23
|
/**
|
|
21
24
|
* Layout section `type` discriminator: authoring camelCase ↔ the provider's
|
|
22
25
|
* wire value, verified against `provider/internal/provider/layout_resource.go`
|
|
@@ -30,21 +33,6 @@ export declare const SECTION_TYPE_FROM_WIRE: ReadonlyMap<string, string>;
|
|
|
30
33
|
export declare const GROUP_SECTION_WIRE_TYPE = "group";
|
|
31
34
|
/** The one other section type carrying an (optional) `name`. */
|
|
32
35
|
export declare const UPDATE_SECTION_WIRE_TYPE = "update";
|
|
33
|
-
/**
|
|
34
|
-
* System-field keys the platform refuses to accept in a layout `group`
|
|
35
|
-
* section's `field_ids` on create — confirmed live against `prestonhigh`:
|
|
36
|
-
* `elementum_layout` create errors "cannot place system fields in layout
|
|
37
|
-
* sections: ID (has HANDLE, TITLE, or STATUS tag), Title (...), Status
|
|
38
|
-
* (...)". The platform's OWN auto-provisioned default "System" section
|
|
39
|
-
* legitimately contains them (so `ei export`/`layoutFromTf` still capture
|
|
40
|
-
* them faithfully — this is a real, current fact about the app), but
|
|
41
|
-
* terraform can never re-create a section containing them: `to-tf` must
|
|
42
|
-
* drop these three specifically wherever a group section names them, or
|
|
43
|
-
* every layout recreate (any `sections` edit forces a full replace) fails.
|
|
44
|
-
* Audit fields (createdAt/createdBy/updatedAt/updatedBy/closedAt/closedBy)
|
|
45
|
-
* are NOT restricted — only HANDLE/TITLE/STATUS.
|
|
46
|
-
*/
|
|
47
|
-
export declare const LAYOUT_RESTRICTED_SYSTEM_FIELD_KEYS: ReadonlySet<string>;
|
|
48
36
|
/**
|
|
49
37
|
* System-field key → the `local.<ns>_<attr>` name `entities/app/locals.ts`
|
|
50
38
|
* emits for it (`SYSTEM_FIELD_ID_ATTRS`'s `<tfLabel>_field_id` shape there).
|
|
@@ -59,6 +47,7 @@ export declare const KNOWN_LAYOUT_SECTION_ATTRS: ReadonlySet<string>;
|
|
|
59
47
|
/** Attributes `listViewFromTf` understands. */
|
|
60
48
|
export declare const KNOWN_LIST_VIEW_ATTRS: ReadonlySet<string>;
|
|
61
49
|
export declare const KNOWN_AGENT_VIEW_ATTRS: ReadonlySet<string>;
|
|
50
|
+
export declare const KNOWN_CUSTOM_VIEW_ATTRS: ReadonlySet<string>;
|
|
62
51
|
export declare const KNOWN_CALENDAR_VIEW_ATTRS: ReadonlySet<string>;
|
|
63
52
|
export declare const KNOWN_KANBAN_VIEW_ATTRS: ReadonlySet<string>;
|
|
64
53
|
export declare const KNOWN_DASHBOARD_VIEW_ATTRS: ReadonlySet<string>;
|