@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
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
2
2
|
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
3
|
-
import { expr, isCanonicalTsLabel,
|
|
3
|
+
import { expr, isCanonicalTsLabel, isTfExpr, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
4
|
+
import { filterToTf } from "../access-policy/to-tf.js";
|
|
5
|
+
import { AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE } from "../automation/types.js";
|
|
4
6
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
7
|
+
import { targetFilterFieldResolver } from "../relationship/to-tf.js";
|
|
8
|
+
import { filterTfToWire } from "../shared/filters/tf-codec.js";
|
|
9
|
+
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
5
10
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
|
|
6
11
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
7
12
|
import { DYNAMIC_LAYOUT_RESOURCE_TYPE } from "./module.js";
|
|
8
|
-
import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS, dynamicLayoutActionWidgetName, dynamicLayoutFieldComponentWireKey, } from "./dialect.js";
|
|
13
|
+
import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS, dynamicLayoutActionWidgetName, dynamicLayoutCompanionWidgetLabel, dynamicLayoutFieldComponentWireKey, } from "./dialect.js";
|
|
9
14
|
export function dynamicLayoutsToTf(layouts, opts) {
|
|
10
15
|
const blocks = [];
|
|
11
|
-
for (const [key,
|
|
16
|
+
for (const [key, authored] of Object.entries(layouts ?? {})) {
|
|
12
17
|
const where = `dynamicLayouts.${key}`;
|
|
13
18
|
if (!isCanonicalTsLabel(key)) {
|
|
14
19
|
opts.diagnostics.push(`${where}: key is not a canonical tsLabel; dropped`);
|
|
15
20
|
continue;
|
|
16
21
|
}
|
|
17
|
-
const
|
|
22
|
+
const layout = scopeOf(opts) === "element" ? withoutStageConditions(authored, where, opts.diagnostics) : authored;
|
|
23
|
+
const layoutLabel = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(key), scopeOf(opts));
|
|
24
|
+
const componentResult = componentMap(layout.components ?? {}, key, layoutLabel, where, opts);
|
|
18
25
|
const attrs = {
|
|
19
|
-
app_id: opts.objectId,
|
|
26
|
+
[scopeOf(opts) === "element" ? "element_id" : "app_id"]: opts.objectId,
|
|
20
27
|
name: layout.name ?? "",
|
|
21
28
|
active: layout.active ?? true,
|
|
22
29
|
document_id: layout.documentId ?? "",
|
|
@@ -26,10 +33,11 @@ export function dynamicLayoutsToTf(layouts, opts) {
|
|
|
26
33
|
};
|
|
27
34
|
if (layout.description !== undefined)
|
|
28
35
|
attrs["description"] = layout.description;
|
|
29
|
-
if (layout.stage !== undefined) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
if (layout.stage !== undefined && scopeOf(opts) === "element") {
|
|
37
|
+
opts.diagnostics.push(`${where}.stage: elements have no stages; omit stage for the element's default DASHBOARD layout; dropped`);
|
|
38
|
+
}
|
|
39
|
+
else if (layout.stage !== undefined) {
|
|
40
|
+
attrs["stage_id"] = expr.local(`${opts.ownerTfLabel}_stage_ids_by_key`, [{ index: tsLabelToTfLabel(layout.stage) }]);
|
|
33
41
|
}
|
|
34
42
|
if (layout.conditions !== undefined)
|
|
35
43
|
attrs["conditions"] = conditionMap(layout.conditions, where, opts);
|
|
@@ -46,19 +54,112 @@ export function dynamicLayoutsToTf(layouts, opts) {
|
|
|
46
54
|
blocks.push({
|
|
47
55
|
kind: "resource",
|
|
48
56
|
type: DYNAMIC_LAYOUT_RESOURCE_TYPE,
|
|
49
|
-
label:
|
|
57
|
+
label: layoutLabel,
|
|
50
58
|
attrs,
|
|
51
59
|
});
|
|
52
|
-
blocks.push(...componentResult.companionWidgets);
|
|
60
|
+
blocks.push(...componentResult.companionWidgets, ...componentResult.automationLookups.values());
|
|
53
61
|
}
|
|
54
62
|
return blocks;
|
|
55
63
|
}
|
|
64
|
+
function scopeOf(opts) {
|
|
65
|
+
return opts.scope ?? "app";
|
|
66
|
+
}
|
|
67
|
+
const COMPONENT_CONDITION_LIST_KEYS = ["showWhen", "hideWhen", "enableWhen", "disableWhen", "requireWhen"];
|
|
68
|
+
/**
|
|
69
|
+
* Elements have no stages. Strip stage predicates, then remove every condition
|
|
70
|
+
* left without a variant (including `all`/`any`/`not` that only pointed at
|
|
71
|
+
* removed ones) and every reference to it; the provider rejects an empty
|
|
72
|
+
* condition and a dangling condition id.
|
|
73
|
+
*/
|
|
74
|
+
function withoutStageConditions(layout, where, diagnostics) {
|
|
75
|
+
if (layout.conditions === undefined)
|
|
76
|
+
return layout;
|
|
77
|
+
const conditions = new Map();
|
|
78
|
+
for (const [id, condition] of Object.entries(layout.conditions)) {
|
|
79
|
+
if (condition["stage"] === undefined) {
|
|
80
|
+
conditions.set(id, condition);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
diagnostics.push(`${where}.conditions.${id}.stage: elements have no stages; dropped`);
|
|
84
|
+
const { stage: _stage, ...rest } = condition;
|
|
85
|
+
conditions.set(id, rest);
|
|
86
|
+
}
|
|
87
|
+
const removed = new Set();
|
|
88
|
+
for (let changed = true; changed;) {
|
|
89
|
+
changed = false;
|
|
90
|
+
for (const [id, condition] of conditions) {
|
|
91
|
+
const pruned = pruneConditionRefs(condition, removed);
|
|
92
|
+
if (pruned === undefined) {
|
|
93
|
+
conditions.delete(id);
|
|
94
|
+
removed.add(id);
|
|
95
|
+
changed = true;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
conditions.set(id, pruned);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (removed.size === 0)
|
|
103
|
+
return { ...layout, conditions: Object.fromEntries(conditions) };
|
|
104
|
+
for (const id of removed) {
|
|
105
|
+
diagnostics.push(`${where}.conditions.${id}: no predicate left on an element; condition and its references removed`);
|
|
106
|
+
}
|
|
107
|
+
const components = {};
|
|
108
|
+
for (const [componentId, component] of Object.entries(layout.components ?? {})) {
|
|
109
|
+
const next = { ...component };
|
|
110
|
+
for (const listKey of COMPONENT_CONDITION_LIST_KEYS) {
|
|
111
|
+
const ids = next[listKey];
|
|
112
|
+
if (!Array.isArray(ids))
|
|
113
|
+
continue;
|
|
114
|
+
const kept = ids.filter((id) => !removed.has(id));
|
|
115
|
+
if (kept.length === 0)
|
|
116
|
+
delete next[listKey];
|
|
117
|
+
else
|
|
118
|
+
next[listKey] = kept;
|
|
119
|
+
}
|
|
120
|
+
components[componentId] = next;
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
...layout,
|
|
124
|
+
components,
|
|
125
|
+
conditions: Object.fromEntries(conditions),
|
|
126
|
+
...(layout.dependencies === undefined ? {} : {
|
|
127
|
+
dependencies: layout.dependencies.map((dependency) => {
|
|
128
|
+
if (!removed.has(dependency["condition"]))
|
|
129
|
+
return dependency;
|
|
130
|
+
const { condition: _condition, ...rest } = dependency;
|
|
131
|
+
return rest;
|
|
132
|
+
}),
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function pruneConditionRefs(condition, removed) {
|
|
137
|
+
const out = {};
|
|
138
|
+
for (const [key, value] of Object.entries(condition)) {
|
|
139
|
+
if (value === undefined)
|
|
140
|
+
continue;
|
|
141
|
+
if (key === "all" || key === "any") {
|
|
142
|
+
const ids = (object(value)["conditions"] ?? []).filter((id) => !removed.has(id));
|
|
143
|
+
if (ids.length > 0)
|
|
144
|
+
out[key] = { ...object(value), conditions: ids };
|
|
145
|
+
}
|
|
146
|
+
else if (key === "not") {
|
|
147
|
+
if (!removed.has(object(value)["condition"]))
|
|
148
|
+
out[key] = value;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
out[key] = value;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return Object.keys(out).length === 0 ? undefined : out;
|
|
155
|
+
}
|
|
56
156
|
function companionWidgetLabel(layoutKey, componentId, opts) {
|
|
57
|
-
return
|
|
157
|
+
return dynamicLayoutCompanionWidgetLabel(opts.ownerTfLabel, layoutKey, componentId, scopeOf(opts));
|
|
58
158
|
}
|
|
59
|
-
function componentMap(components, layoutKey, where, opts) {
|
|
159
|
+
function componentMap(components, layoutKey, layoutLabel, where, opts) {
|
|
60
160
|
const out = {};
|
|
61
161
|
const companionWidgets = [];
|
|
162
|
+
const automationLookups = new Map();
|
|
62
163
|
for (const [componentId, component] of Object.entries(components)) {
|
|
63
164
|
const attrs = {};
|
|
64
165
|
for (const [key, value] of Object.entries(component)) {
|
|
@@ -75,7 +176,10 @@ function componentMap(components, layoutKey, where, opts) {
|
|
|
75
176
|
const rec = object(value);
|
|
76
177
|
const section = snakeObject(rec, where, opts);
|
|
77
178
|
delete section["agent"];
|
|
78
|
-
if (rec["agent"] !== undefined) {
|
|
179
|
+
if (rec["agent"] !== undefined && scopeOf(opts) === "element") {
|
|
180
|
+
opts.diagnostics.push(`${where}.components.${componentId}.section.agent: agents belong to apps; elements cannot bind one; dropped`);
|
|
181
|
+
}
|
|
182
|
+
else if (rec["agent"] !== undefined) {
|
|
79
183
|
const agent = resolveAgent(rec["agent"], `${where}.components.${componentId}.section`, opts);
|
|
80
184
|
if (agent !== undefined)
|
|
81
185
|
section["agent_id"] = agent;
|
|
@@ -99,9 +203,31 @@ function componentMap(components, layoutKey, where, opts) {
|
|
|
99
203
|
const rec = object(value);
|
|
100
204
|
const button = snakeObject(rec, where, opts);
|
|
101
205
|
delete button["automation"];
|
|
206
|
+
delete button["automation_app"];
|
|
207
|
+
if (rec["automationApp"] !== undefined) {
|
|
208
|
+
const app = resolveAspect(rec["automationApp"], `${where}.components.${componentId}.automationButton.automationApp`, opts);
|
|
209
|
+
if (app !== undefined)
|
|
210
|
+
button["automation_app_id"] = app;
|
|
211
|
+
}
|
|
102
212
|
const token = rec["automation"];
|
|
103
213
|
const automation = resolveAutomation(token, `${where}.components.${componentId}.automationButton`, opts);
|
|
104
|
-
if (
|
|
214
|
+
if (Array.isArray(rec["inputs"])) {
|
|
215
|
+
const inputs = {
|
|
216
|
+
buttonAutomation: token === undefined ? undefined : { token, value: automation },
|
|
217
|
+
layoutLabel,
|
|
218
|
+
automationLookups,
|
|
219
|
+
};
|
|
220
|
+
button["inputs"] = rec["inputs"].flatMap((input, index) => automationButtonInput(object(input), inputs, `${where}.components.${componentId}.automationButton.inputs[${index}]`, opts));
|
|
221
|
+
}
|
|
222
|
+
delete button["widget"];
|
|
223
|
+
const widget = rec["widget"] === undefined
|
|
224
|
+
? undefined
|
|
225
|
+
: resolveWidget(rec["widget"], `${where}.components.${componentId}.automationButton.widget`, opts);
|
|
226
|
+
if (automation !== undefined && widget !== undefined) {
|
|
227
|
+
button["automation_id"] = automation;
|
|
228
|
+
button["widget_id"] = widget;
|
|
229
|
+
}
|
|
230
|
+
else if (automation !== undefined) {
|
|
105
231
|
button["automation_id"] = automation;
|
|
106
232
|
// The renderer executes the automation through a widget, not the
|
|
107
233
|
// automation id; without this binding it reports the button as not
|
|
@@ -132,13 +258,74 @@ function componentMap(components, layoutKey, where, opts) {
|
|
|
132
258
|
button["target_aspect_id"] = target;
|
|
133
259
|
attrs["create_button"] = button;
|
|
134
260
|
}
|
|
261
|
+
else if (key === "relatedItemsBlock") {
|
|
262
|
+
attrs["related_items_block"] = relatedItemsBlock(object(value), `${where}.components.${componentId}.relatedItemsBlock`, opts);
|
|
263
|
+
}
|
|
135
264
|
else {
|
|
136
265
|
attrs[snakeKey(key)] = snakeValue(value, where, opts);
|
|
137
266
|
}
|
|
138
267
|
}
|
|
139
268
|
out[componentId] = attrs;
|
|
140
269
|
}
|
|
141
|
-
return { components: out, companionWidgets };
|
|
270
|
+
return { components: out, companionWidgets, automationLookups };
|
|
271
|
+
}
|
|
272
|
+
function automationButtonInput(rec, inputs, where, opts) {
|
|
273
|
+
const out = snakeObject(rec, where, opts);
|
|
274
|
+
delete out["automation"];
|
|
275
|
+
if (out["parameter_id"] === undefined) {
|
|
276
|
+
const target = rec["automation"] === undefined
|
|
277
|
+
? inputs.buttonAutomation
|
|
278
|
+
: {
|
|
279
|
+
token: rec["automation"],
|
|
280
|
+
value: resolveAutomation(rec["automation"], `${where}.automation`, opts),
|
|
281
|
+
};
|
|
282
|
+
const label = target?.value !== undefined && isTfExpr(target.value) && target.value.$expr === "resource-attr"
|
|
283
|
+
? target.value.label
|
|
284
|
+
: undefined;
|
|
285
|
+
const name = rec["parameterName"];
|
|
286
|
+
if (label === undefined || typeof name !== "string") {
|
|
287
|
+
opts.diagnostics.push(`${where}: parameterName needs a managed button automation to bind to; dropped`);
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
out["parameter_id"] = isActiveAutomation(target?.token.refName ?? "", opts)
|
|
291
|
+
? expr.dataAttr(AUTOMATION_RESOURCE_TYPE, publishedAutomationLookup(label, inputs, opts), ["parameter_ids", { index: name }])
|
|
292
|
+
: expr.resourceAttr("elementum_on_demand_trigger", label, ["parameter_ids", { index: name }]);
|
|
293
|
+
}
|
|
294
|
+
if (Array.isArray(rec["fieldRefParams"])) {
|
|
295
|
+
out["field_ref_params"] = rec["fieldRefParams"].flatMap((param, index) => {
|
|
296
|
+
const entry = object(param);
|
|
297
|
+
const field = resolveField(entry["field"], `${where}.fieldRefParams[${index}]`, opts);
|
|
298
|
+
return field === undefined ? [] : [{ name: entry["name"], field_id: field }];
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return [out];
|
|
302
|
+
}
|
|
303
|
+
function relatedItemsBlock(rec, where, opts) {
|
|
304
|
+
const out = snakeObject(rec, where, opts);
|
|
305
|
+
delete out["related"];
|
|
306
|
+
delete out["filter"];
|
|
307
|
+
const related = rec["related"];
|
|
308
|
+
if (related !== undefined) {
|
|
309
|
+
const aspect = resolveAspect(related, `${where}.related`, opts);
|
|
310
|
+
if (aspect !== undefined)
|
|
311
|
+
out["related_aspect_id"] = aspect;
|
|
312
|
+
}
|
|
313
|
+
if (rec["filter"] !== undefined) {
|
|
314
|
+
const foreignField = related === undefined
|
|
315
|
+
? undefined
|
|
316
|
+
: targetFilterFieldResolver(related, `${where}.related`, { ...opts, scope: scopeOf(opts) });
|
|
317
|
+
const hclFilter = filterToTf(rec["filter"], `${where}.filter`, {
|
|
318
|
+
ownerTfLabel: opts.ownerTfLabel,
|
|
319
|
+
appRefName: opts.ownerRefName,
|
|
320
|
+
scope: scopeOf(opts),
|
|
321
|
+
objectId: opts.objectId,
|
|
322
|
+
diagnostics: opts.diagnostics,
|
|
323
|
+
orgRefs: opts.orgRefs,
|
|
324
|
+
...(foreignField !== undefined && { foreignField }),
|
|
325
|
+
});
|
|
326
|
+
out["filter"] = expr.jsonencode(filterTfToWire(hclFilter));
|
|
327
|
+
}
|
|
328
|
+
return out;
|
|
142
329
|
}
|
|
143
330
|
function fieldComponent(value, where, opts) {
|
|
144
331
|
const rec = object(value);
|
|
@@ -170,7 +357,7 @@ function conditionMap(conditions, where, opts) {
|
|
|
170
357
|
const stage = object(value)["stage"];
|
|
171
358
|
if (typeof stage === "string") {
|
|
172
359
|
attrs["stage"] = {
|
|
173
|
-
stage_id: expr.
|
|
360
|
+
stage_id: expr.local(`${opts.ownerTfLabel}_stage_ids_by_key`, [{ index: tsLabelToTfLabel(stage) }]),
|
|
174
361
|
};
|
|
175
362
|
}
|
|
176
363
|
}
|
|
@@ -223,6 +410,10 @@ function resolveFields(values, where, opts) {
|
|
|
223
410
|
}
|
|
224
411
|
function resolveField(value, where, opts) {
|
|
225
412
|
if (typeof value === "string") {
|
|
413
|
+
if (scopeOf(opts) === "element" && !ELEMENT_SYSTEM_FIELD_KEYS.includes(value)) {
|
|
414
|
+
opts.diagnostics.push(`${where}: "${value}" is not a known system field key on an element; dropped`);
|
|
415
|
+
return undefined;
|
|
416
|
+
}
|
|
226
417
|
const attr = SYSTEM_FIELD_ID_ATTR_BY_KEY.get(value);
|
|
227
418
|
if (attr === undefined)
|
|
228
419
|
opts.diagnostics.push(`${where}: "${value}" is not a known system field key; dropped`);
|
|
@@ -231,10 +422,10 @@ function resolveField(value, where, opts) {
|
|
|
231
422
|
const token = value;
|
|
232
423
|
const refName = token?.refName ?? "";
|
|
233
424
|
if (token?.parent !== undefined && token.parent !== opts.ownerRefName) {
|
|
234
|
-
opts.diagnostics.push(`${where}: field "${refName}" targets a different
|
|
425
|
+
opts.diagnostics.push(`${where}: field "${refName}" targets a different ${scopeOf(opts)}; dropped`);
|
|
235
426
|
return undefined;
|
|
236
427
|
}
|
|
237
|
-
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel,
|
|
428
|
+
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel, scopeOf(opts), opts.fieldAddresses);
|
|
238
429
|
if (resolved === undefined)
|
|
239
430
|
opts.diagnostics.push(`${where}: field "${refName}" has no Terraform mapping; dropped`);
|
|
240
431
|
return resolved;
|
|
@@ -247,7 +438,7 @@ function typedValue(value, fieldValue, opts) {
|
|
|
247
438
|
? `${opts.ownerTfLabel}_status_options_by_label`
|
|
248
439
|
: token.tags?.includes("STAGE")
|
|
249
440
|
? `${opts.ownerTfLabel}_stage_options_by_label`
|
|
250
|
-
: `${scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(token.refName ?? ""),
|
|
441
|
+
: `${scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(token.refName ?? ""), scopeOf(opts))}_options_by_label`;
|
|
251
442
|
return { string: expr.local(localName, [{ index: rec["string"] }]) };
|
|
252
443
|
}
|
|
253
444
|
return snakeObject(rec, "dynamic layout typed value", opts);
|
|
@@ -255,7 +446,7 @@ function typedValue(value, fieldValue, opts) {
|
|
|
255
446
|
function resolveAutomation(token, where, opts) {
|
|
256
447
|
const refName = token?.refName ?? "";
|
|
257
448
|
if (token?.parent !== undefined && token.parent !== opts.ownerRefName) {
|
|
258
|
-
opts.diagnostics.push(`${where}: cross
|
|
449
|
+
opts.diagnostics.push(`${where}: cross-${scopeOf(opts)} automations are not supported; dropped`);
|
|
259
450
|
return undefined;
|
|
260
451
|
}
|
|
261
452
|
if (!isCanonicalTsLabel(refName)) {
|
|
@@ -264,10 +455,50 @@ function resolveAutomation(token, where, opts) {
|
|
|
264
455
|
}
|
|
265
456
|
return expr.resourceAttr("elementum_automation", scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(refName), "app"), ["id"]);
|
|
266
457
|
}
|
|
458
|
+
function isActiveAutomation(refName, opts) {
|
|
459
|
+
return opts.workspaceAspects?.get(workspaceAspectKey(scopeOf(opts), opts.ownerRefName))
|
|
460
|
+
?.activeAutomationRefNames?.has(refName) === true;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* The on-demand trigger's `parameter_ids` describe the draft workflow, but a
|
|
464
|
+
* button runs the published one, whose parameter ids differ. Read them back
|
|
465
|
+
* after publish, as run-automation tasks do. The data address is
|
|
466
|
+
* module-global, so it is scoped to this layout.
|
|
467
|
+
*/
|
|
468
|
+
function publishedAutomationLookup(automationLabel, inputs, opts) {
|
|
469
|
+
const label = `${automationLabel}_for_${inputs.layoutLabel}`;
|
|
470
|
+
inputs.automationLookups.set(`${AUTOMATION_RESOURCE_TYPE}.${label}`, {
|
|
471
|
+
kind: "data",
|
|
472
|
+
type: AUTOMATION_RESOURCE_TYPE,
|
|
473
|
+
label,
|
|
474
|
+
attrs: {
|
|
475
|
+
app_id: opts.objectId,
|
|
476
|
+
id: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, automationLabel, ["id"]),
|
|
477
|
+
depends_on: [expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, automationLabel)],
|
|
478
|
+
},
|
|
479
|
+
});
|
|
480
|
+
return label;
|
|
481
|
+
}
|
|
482
|
+
function resolveWidget(token, where, opts) {
|
|
483
|
+
const key = token.refName ?? "";
|
|
484
|
+
if (token.__kind !== "widget" || key === "") {
|
|
485
|
+
opts.diagnostics.push(`${where}: expected a typed widget reference; dropped`);
|
|
486
|
+
return undefined;
|
|
487
|
+
}
|
|
488
|
+
if (token.parent !== undefined && token.parent !== opts.ownerRefName) {
|
|
489
|
+
opts.diagnostics.push(`${where}: widget belongs to ${JSON.stringify(token.parent)}, not ${JSON.stringify(opts.ownerRefName)}; dropped`);
|
|
490
|
+
return undefined;
|
|
491
|
+
}
|
|
492
|
+
if (opts.widgetKeys !== undefined && !opts.widgetKeys.has(key)) {
|
|
493
|
+
opts.diagnostics.push(`${where}: widget ${JSON.stringify(key)} is not declared in this ${scopeOf(opts)}; dropped`);
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
return expr.resourceAttr(WIDGET_RESOURCE_TYPE, scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(key), scopeOf(opts)), ["id"]);
|
|
497
|
+
}
|
|
267
498
|
function resolveAgent(token, where, opts) {
|
|
268
499
|
const refName = token?.refName ?? "";
|
|
269
500
|
if (token?.parent !== undefined && token.parent !== opts.ownerRefName) {
|
|
270
|
-
opts.diagnostics.push(`${where}: agent targets a different
|
|
501
|
+
opts.diagnostics.push(`${where}: agent targets a different ${scopeOf(opts)}; dropped`);
|
|
271
502
|
return undefined;
|
|
272
503
|
}
|
|
273
504
|
if (!isCanonicalTsLabel(refName)) {
|
|
@@ -279,7 +510,7 @@ function resolveAgent(token, where, opts) {
|
|
|
279
510
|
function resolveAspect(token, where, opts) {
|
|
280
511
|
const kind = token?.__kind === "element" ? "element" : "app";
|
|
281
512
|
const refName = token?.refName ?? "";
|
|
282
|
-
if (kind ===
|
|
513
|
+
if (kind === scopeOf(opts) && refName === opts.ownerRefName)
|
|
283
514
|
return opts.objectId;
|
|
284
515
|
const sibling = opts.workspaceAspects?.get(workspaceAspectKey(kind, refName));
|
|
285
516
|
if (sibling !== undefined) {
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { type AppOrElementRef, type CloudLinkRef, type FieldRef } from "../../catalog/index.js";
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
3
|
import type { AccessPolicyOptions } from "../access-policy/build.js";
|
|
4
|
-
import
|
|
4
|
+
import type { ElementDynamicLayout } from "../dynamic-layout/build.js";
|
|
5
|
+
import { type AppViewBags, type AppViewRefs, type AppCategory, type AppCustomView, type AppCloudOptions, type AppDashboard, type AppField, type AppFieldRefs, type AppLayout, type AppRecordCreateForm, type AppSystemFieldOverride } from "../app/build.js";
|
|
5
6
|
import { type DisplayBlock } from "../app/display-blocks.js";
|
|
6
7
|
import type { AppRelationship } from "../relationship/build.js";
|
|
7
8
|
import type { AppRole } from "../role/build.js";
|
|
8
9
|
import type { AppWidget } from "../widget/build.js";
|
|
9
10
|
import { type ElementSystemFieldKey } from "./system-fields.js";
|
|
11
|
+
/** A Custom view on an element. Agents are app-owned, so an element's Custom view has none. */
|
|
12
|
+
export type ElementCustomView = Omit<AppCustomView, "agent"> & {
|
|
13
|
+
readonly agent?: never;
|
|
14
|
+
};
|
|
10
15
|
export type { AppCalendarView, AppCategory, AppDashboard, AppDashboardView, AppField, AppKanbanView, AppLayout, AppListView, AppRecordCreateForm, AppRecordCreateFormSection, AppSystemFieldOverride, PicklistOption } from "../app/build.js";
|
|
11
16
|
export type { AppRelationship, AppRelationshipColumn } from "../relationship/build.js";
|
|
12
17
|
export type { AppWidget, CreateRecordWidget, LinkRecordsWidget, RelatedRecordsWidget, RunAutomationWidget, RunAutomationWidgetParameter, WidgetButtonStyle, WidgetButtonType } from "../widget/build.js";
|
|
@@ -15,6 +20,13 @@ export { ELEMENT_SYSTEM_FIELD_KEYS, type ElementSystemFieldKey } from "./system-
|
|
|
15
20
|
export interface ElementSystemFields {
|
|
16
21
|
readonly id?: AppSystemFieldOverride;
|
|
17
22
|
readonly title?: AppSystemFieldOverride;
|
|
23
|
+
/**
|
|
24
|
+
* The element carries the platform's audit fields (Created on/by, Updated
|
|
25
|
+
* on/by). The platform adds them to apps but only to some elements, and
|
|
26
|
+
* EDK cannot create them, so referencing `createdAt`, `createdBy`,
|
|
27
|
+
* `updatedAt` or `updatedBy` on an element without this is a build error.
|
|
28
|
+
*/
|
|
29
|
+
readonly audit?: boolean;
|
|
18
30
|
}
|
|
19
31
|
/**
|
|
20
32
|
* The source table a LINKED element maps to — an existing table in the
|
|
@@ -35,7 +47,14 @@ export interface ElementCloudConnection {
|
|
|
35
47
|
/** The record-id source column on the mapped table. */
|
|
36
48
|
readonly idColumnName?: string;
|
|
37
49
|
}
|
|
38
|
-
|
|
50
|
+
/** An element's managed views: an app's view bags without agent views. */
|
|
51
|
+
export type ElementViewBags = Omit<AppViewBags, "agentViews" | "customViews"> & {
|
|
52
|
+
/** Custom views (pages of Elementum Blocks), keyed by view ref name. */
|
|
53
|
+
readonly customViews?: Readonly<Record<string, ElementCustomView>>;
|
|
54
|
+
};
|
|
55
|
+
/** Element options; `V` carries the view bags so `ref().views` keeps their keys. */
|
|
56
|
+
export type ElementV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, V extends ElementViewBags = ElementViewBags> = ElementV2OptionsBase<F, R> & V;
|
|
57
|
+
interface ElementV2OptionsBase<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
|
|
39
58
|
/** Required platform handle (business acronym, e.g. "PRD") — distinct from the refName. */
|
|
40
59
|
readonly handle: string;
|
|
41
60
|
readonly name: string;
|
|
@@ -98,15 +117,15 @@ export interface ElementV2Options<F extends Record<string, AppField> = Record<st
|
|
|
98
117
|
* terraform address on a re-pull.
|
|
99
118
|
*/
|
|
100
119
|
readonly layouts?: Readonly<Record<string, AppLayout>>;
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Typed DASHBOARD record layouts (`elementum_dynamic_layout`) keyed by
|
|
122
|
+
* stable ref name. Elements have no stages, so each is an element-level
|
|
123
|
+
* default layout; build with `dynamicLayout(...)` to check component,
|
|
124
|
+
* condition, and save-group keys.
|
|
125
|
+
*/
|
|
126
|
+
readonly dynamicLayouts?: Readonly<Record<string, ElementDynamicLayout>>;
|
|
107
127
|
readonly dashboards?: Readonly<Record<string, AppDashboard>>;
|
|
108
128
|
readonly widgets?: Readonly<Record<string, AppWidget>>;
|
|
109
|
-
readonly dashboardViews?: Readonly<Record<string, AppDashboardView>>;
|
|
110
129
|
/**
|
|
111
130
|
* Typed new-record form (`elementum_record_create_form`). Mutually
|
|
112
131
|
* exclusive with `recordCreateDisplayBlocks` — author one or the other,
|
|
@@ -164,10 +183,11 @@ type ElementSystemFieldRefs<Parent extends string = string> = {
|
|
|
164
183
|
* record`). `id`/`title` round out the bag the same way `AppRef` folds in
|
|
165
184
|
* its full `SystemFieldKey` set — a finite, closed term, not a wide index.
|
|
166
185
|
*/
|
|
167
|
-
export type ElementRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string> = Extract<AppOrElementRef<RefName>, {
|
|
186
|
+
export type ElementRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string, V extends ElementViewBags = ElementViewBags> = Extract<AppOrElementRef<RefName>, {
|
|
168
187
|
readonly __kind: "element";
|
|
169
188
|
}> & {
|
|
170
189
|
readonly fields: AppFieldRefs<F, RefName> & ElementSystemFieldRefs<RefName> & R;
|
|
190
|
+
readonly views: AppViewRefs<V, RefName>;
|
|
171
191
|
};
|
|
172
192
|
/**
|
|
173
193
|
* The configured result of `element` — its reference surface (`ref()`)
|
|
@@ -175,9 +195,9 @@ export type ElementRef<F extends Record<string, AppField> = Record<string, AppFi
|
|
|
175
195
|
* argument**, not a constructor option — see `AppConfigured` in
|
|
176
196
|
* `src/aspects/build.ts` for the full rationale (identical here).
|
|
177
197
|
*/
|
|
178
|
-
export interface ElementConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never
|
|
179
|
-
ref<const RefName extends string>(refName: RefName): ElementRef<F, R, RefName>;
|
|
198
|
+
export interface ElementConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, V extends ElementViewBags = ElementViewBags> {
|
|
199
|
+
ref<const RefName extends string>(refName: RefName): ElementRef<F, R, RefName, V>;
|
|
180
200
|
def(refName: string): DeployableEntity;
|
|
181
201
|
}
|
|
182
202
|
/** Build a v2 element entity: org-owned, compose-body payload. Exposes `.ref(refName)` and `.def(refName)`. */
|
|
183
|
-
export declare function element<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never
|
|
203
|
+
export declare function element<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, const V extends ElementViewBags = ElementViewBags>(opts: ElementV2Options<F, R, V>): ElementConfigured<F, R, V>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { slimTokens } from "../../catalog/index.js";
|
|
2
2
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_REQUIRED, SYSTEM_FIELD_TAG_BY_KEY } from "../../core/system-fields.js";
|
|
3
|
-
import { assertNoSystemKeyCollision, picklistOptionLabels, serializeField, } from "../app/build.js";
|
|
3
|
+
import { appViewRefs, assertNoSystemKeyCollision, picklistOptionLabels, serializeField, } from "../app/build.js";
|
|
4
4
|
import { serializeDisplayBlocks } from "../app/display-blocks.js";
|
|
5
5
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "./system-fields.js";
|
|
6
6
|
export { ELEMENT_SYSTEM_FIELD_KEYS } from "./system-fields.js";
|
|
@@ -105,6 +105,7 @@ export function element(opts) {
|
|
|
105
105
|
name: opts.name,
|
|
106
106
|
...(opts.namespace !== undefined ? { namespace: opts.namespace } : {}),
|
|
107
107
|
fields,
|
|
108
|
+
views: appViewRefs(opts, { refName, name: opts.name, ...(opts.namespace !== undefined ? { namespace: opts.namespace } : {}) }, "element"),
|
|
108
109
|
};
|
|
109
110
|
},
|
|
110
111
|
def(refName) {
|
|
@@ -124,6 +125,7 @@ export function element(opts) {
|
|
|
124
125
|
...(opts.cloudOptions !== undefined ? { cloudOptions: opts.cloudOptions } : {}),
|
|
125
126
|
...(opts.cloudConnection !== undefined ? { cloudConnection: opts.cloudConnection } : {}),
|
|
126
127
|
...(opts.commentsEnabled !== undefined ? { commentsEnabled: opts.commentsEnabled } : {}),
|
|
128
|
+
...(opts.systemFields?.audit === true ? { auditFields: true } : {}),
|
|
127
129
|
fields: [
|
|
128
130
|
...serializeElementSystemFields(opts.systemFields),
|
|
129
131
|
...Object.entries(opts.fields).map(([bagKey, field]) => serializeField(field, bagKey)),
|
|
@@ -137,7 +139,9 @@ export function element(opts) {
|
|
|
137
139
|
...(opts.dashboards !== undefined ? { dashboards: opts.dashboards } : {}),
|
|
138
140
|
...(opts.widgets !== undefined ? { widgets: opts.widgets } : {}),
|
|
139
141
|
...(opts.dashboardViews !== undefined ? { dashboardViews: opts.dashboardViews } : {}),
|
|
142
|
+
...(opts.customViews !== undefined ? { customViews: opts.customViews } : {}),
|
|
140
143
|
...(opts.recordCreateForm !== undefined ? { recordCreateForm: opts.recordCreateForm } : {}),
|
|
144
|
+
...(opts.dynamicLayouts !== undefined ? { dynamicLayouts: opts.dynamicLayouts } : {}),
|
|
141
145
|
...(opts.relationships !== undefined ? { relationships: opts.relationships } : {}),
|
|
142
146
|
...(opts.viewOrder !== undefined ? { viewOrder: opts.viewOrder } : {}),
|
|
143
147
|
...(opts.accessPolicies !== undefined ? { accessPolicies: opts.accessPolicies } : {}),
|
|
@@ -17,11 +17,23 @@ export interface ElementFromTfViewBlocks {
|
|
|
17
17
|
readonly calendarViewBlocks: readonly TfBlock[];
|
|
18
18
|
readonly kanbanViewBlocks: readonly TfBlock[];
|
|
19
19
|
readonly dashboardViewBlocks: readonly TfBlock[];
|
|
20
|
+
readonly customViewBlocks?: readonly TfBlock[];
|
|
20
21
|
readonly managedViewOrderBlocks: readonly TfBlock[];
|
|
21
22
|
readonly recordCreateFormBlocks: readonly TfBlock[];
|
|
23
|
+
readonly dynamicLayoutBlocks?: readonly TfBlock[];
|
|
22
24
|
readonly relationshipBlocks: readonly TfBlock[];
|
|
23
25
|
readonly dashboardBlocks: readonly TfBlock[];
|
|
24
26
|
readonly dashboardWidgetBlocks: readonly TfBlock[];
|
|
25
27
|
readonly widgetBlocks: readonly TfBlock[];
|
|
26
28
|
}
|
|
27
29
|
export declare function elementFromTf(elementBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: ElementFromTfViewBlocks, accessPolicyBlocks?: readonly TfBlock[], roleBlocks?: readonly TfBlock[]): ElementFromTfResult;
|
|
30
|
+
/**
|
|
31
|
+
* The export references an element's audit fields only when the platform
|
|
32
|
+
* gave it those fields, which EDK cannot otherwise observe: through its
|
|
33
|
+
* `<label>_(created|updated)_(at|by)_field_id` locals, or, in the element's
|
|
34
|
+
* own automations, through a trigger's Created/Updated outputs. Locals
|
|
35
|
+
* blocks are skipped by callers: `ei` defines those locals on every element.
|
|
36
|
+
* An authored field with the same display name wins over trigger-output
|
|
37
|
+
* heuristics.
|
|
38
|
+
*/
|
|
39
|
+
export declare function referencesElementAuditFields(label: string, blocks: readonly TfBlock[], authoredFieldNames?: ReadonlySet<string>): boolean;
|