@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,3 +1,4 @@
|
|
|
1
|
+
import { type ChildResourceScope } from "../../engine/tf/index.js";
|
|
1
2
|
export declare const DYNAMIC_LAYOUT_FIELD_COMPONENT_WIRE_KEY_BY_PUBLIC_KEY: ReadonlyMap<string, string>;
|
|
2
3
|
export declare const DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS: ReadonlySet<string>;
|
|
3
4
|
export declare function dynamicLayoutFieldComponentWireKey(publicKey: string): string;
|
|
@@ -10,3 +11,5 @@ export declare const DYNAMIC_LAYOUT_COMPARISON_KEYS: ReadonlySet<string>;
|
|
|
10
11
|
*/
|
|
11
12
|
export declare const DYNAMIC_LAYOUT_ACTION_WIDGET_NAME_PREFIX = "EDK dynamic layout action ";
|
|
12
13
|
export declare function dynamicLayoutActionWidgetName(layoutKey: string, componentId: string): string;
|
|
14
|
+
/** Terraform label of the companion widget build derives for one automation button. */
|
|
15
|
+
export declare function dynamicLayoutCompanionWidgetLabel(ownerTfLabel: string, layoutKey: string, componentId: string, scope: ChildResourceScope): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sanitizeName, scopedResourceLabel } from "../../engine/tf/index.js";
|
|
1
2
|
import { splitCamelCase } from "../../engine/tf/labels.js";
|
|
2
3
|
/**
|
|
3
4
|
* Public field-component keys are listed exhaustively against the authoring
|
|
@@ -57,3 +58,7 @@ export function dynamicLayoutActionWidgetName(layoutKey, componentId) {
|
|
|
57
58
|
const words = (value) => splitCamelCase(value.replace(/[_-]+/g, " ")).toLowerCase();
|
|
58
59
|
return `${DYNAMIC_LAYOUT_ACTION_WIDGET_NAME_PREFIX}${words(layoutKey)} ${words(componentId)}`;
|
|
59
60
|
}
|
|
61
|
+
/** Terraform label of the companion widget build derives for one automation button. */
|
|
62
|
+
export function dynamicLayoutCompanionWidgetLabel(ownerTfLabel, layoutKey, componentId, scope) {
|
|
63
|
+
return scopedResourceLabel(ownerTfLabel, sanitizeName(dynamicLayoutActionWidgetName(layoutKey, componentId)), scope);
|
|
64
|
+
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
-
import { type TfBlock } from "../../engine/tf/index.js";
|
|
2
|
+
import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
|
|
3
3
|
import type { NormalizedDynamicLayout } from "../app/deserializer/normalize.js";
|
|
4
4
|
export interface DynamicLayoutOwner {
|
|
5
5
|
readonly type: string;
|
|
6
6
|
readonly label: string;
|
|
7
7
|
readonly ownerRefName: string;
|
|
8
8
|
readonly ownerTfLabel: string;
|
|
9
|
+
/** Owning stream root kind; defaults to `"app"`. */
|
|
10
|
+
readonly scope?: ChildResourceScope;
|
|
9
11
|
}
|
|
10
12
|
export declare function dynamicLayoutsFromTf(blocks: readonly TfBlock[], owner: DynamicLayoutOwner, ctx: FromTfContext): NormalizedDynamicLayout[];
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
13
|
-
* The label is the companion
|
|
14
|
-
* name is mutable and cannot safely
|
|
15
|
-
* widgets during pull.
|
|
14
|
+
* Labels of the companion widgets build derives for dynamic-layout automation
|
|
15
|
+
* buttons, among those the buttons reference. The label is the companion's
|
|
16
|
+
* stable Terraform identity; its display name is mutable and cannot safely
|
|
17
|
+
* distinguish generated from authored widgets during pull. A button bound to
|
|
18
|
+
* any other widget keeps that widget as authored source.
|
|
16
19
|
*/
|
|
17
|
-
export declare function dynamicLayoutCompanionWidgetLabels(blocks: readonly TfBlock[]): ReadonlySet<string>;
|
|
20
|
+
export declare function dynamicLayoutCompanionWidgetLabels(blocks: readonly TfBlock[], owner: DynamicLayoutOwner): ReadonlySet<string>;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
-
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
3
|
-
import {
|
|
2
|
+
import { isTfExpr, isTfLabel, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
3
|
+
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
4
|
+
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
|
+
import { filterOwnerForAspect } from "../relationship/from-tf.js";
|
|
6
|
+
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
4
7
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
5
8
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
6
9
|
import { DYNAMIC_LAYOUT_RESOURCE_TYPE } from "./module.js";
|
|
7
|
-
import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_WIRE_KEY_BY_PUBLIC_KEY, } from "./dialect.js";
|
|
10
|
+
import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_WIRE_KEY_BY_PUBLIC_KEY, dynamicLayoutCompanionWidgetLabel, } from "./dialect.js";
|
|
8
11
|
const KNOWN_ATTRS = new Set([
|
|
9
|
-
"app_id", "stage_id", "name", "description", "active", "document_id", "document_version",
|
|
12
|
+
"app_id", "element_id", "stage_id", "name", "description", "active", "document_id", "document_version",
|
|
10
13
|
"root_component", "components", "conditions", "save_groups", "field_validations", "dependencies",
|
|
11
14
|
"metadata", "version", "created_at", "updated_at",
|
|
12
15
|
]);
|
|
@@ -20,25 +23,28 @@ export function dynamicLayoutsFromTf(blocks, owner, ctx) {
|
|
|
20
23
|
return out;
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
24
|
-
* The label is the companion
|
|
25
|
-
* name is mutable and cannot safely
|
|
26
|
-
* widgets during pull.
|
|
26
|
+
* Labels of the companion widgets build derives for dynamic-layout automation
|
|
27
|
+
* buttons, among those the buttons reference. The label is the companion's
|
|
28
|
+
* stable Terraform identity; its display name is mutable and cannot safely
|
|
29
|
+
* distinguish generated from authored widgets during pull. A button bound to
|
|
30
|
+
* any other widget keeps that widget as authored source.
|
|
27
31
|
*/
|
|
28
|
-
export function dynamicLayoutCompanionWidgetLabels(blocks) {
|
|
32
|
+
export function dynamicLayoutCompanionWidgetLabels(blocks, owner) {
|
|
29
33
|
const labels = new Set();
|
|
30
34
|
for (const block of blocks) {
|
|
31
35
|
const components = plainObject(block.attrs["components"]);
|
|
32
36
|
if (components === undefined)
|
|
33
37
|
continue;
|
|
34
|
-
|
|
38
|
+
const layoutKey = scopedLabelToBagKey(owner.ownerTfLabel, block.label ?? "", scopeOf(owner));
|
|
39
|
+
for (const [componentId, raw] of Object.entries(components)) {
|
|
35
40
|
const component = plainObject(raw);
|
|
36
41
|
const button = component === undefined ? undefined : plainObject(component["automation_button"]);
|
|
37
42
|
const label = button === undefined
|
|
38
43
|
? undefined
|
|
39
44
|
: resourceRefLabel(button["widget_id"], WIDGET_RESOURCE_TYPE);
|
|
40
|
-
if (label !== undefined)
|
|
45
|
+
if (label !== undefined && label === dynamicLayoutCompanionWidgetLabel(owner.label, layoutKey, componentId, scopeOf(owner))) {
|
|
41
46
|
labels.add(label);
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
return labels;
|
|
@@ -49,8 +55,9 @@ function dynamicLayoutFromTf(block, owner, ctx) {
|
|
|
49
55
|
if (!KNOWN_ATTRS.has(key))
|
|
50
56
|
ctx.diagnostics.push(`${where}: unhandled attribute "${key}" — extend dynamic-layout extraction`);
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
const ownerAttr = scopeOf(owner) === "element" ? "element_id" : "app_id";
|
|
59
|
+
if (resourceRefLabel(block.attrs[ownerAttr], owner.type) !== owner.label) {
|
|
60
|
+
ctx.diagnostics.push(`${where}: ${ownerAttr} does not reference ${owner.type}.${owner.label}; skipped`);
|
|
54
61
|
return undefined;
|
|
55
62
|
}
|
|
56
63
|
const componentsRaw = plainObject(block.attrs["components"]);
|
|
@@ -58,8 +65,8 @@ function dynamicLayoutFromTf(block, owner, ctx) {
|
|
|
58
65
|
ctx.diagnostics.push(`${where}: components is not an object; skipped`);
|
|
59
66
|
return undefined;
|
|
60
67
|
}
|
|
61
|
-
const resolvedStageKey = stageKey(block.attrs["stage_id"], owner);
|
|
62
|
-
if (block.attrs["stage_id"] !== undefined &&
|
|
68
|
+
const resolvedStageKey = stageKey(block.attrs["stage_id"], owner, ctx, `${where}.stage_id`);
|
|
69
|
+
if (block.attrs["stage_id"] !== undefined && stageIndex(block.attrs["stage_id"], owner) === undefined) {
|
|
63
70
|
ctx.diagnostics.push(`${where}: stage_id has an unrecognized shape; layout kept unscoped instead of guessing`);
|
|
64
71
|
}
|
|
65
72
|
const layout = {
|
|
@@ -70,7 +77,7 @@ function dynamicLayoutFromTf(block, owner, ctx) {
|
|
|
70
77
|
documentId: optionalString(block.attrs, "document_id", where, ctx) ?? "",
|
|
71
78
|
...(typeof block.attrs["document_version"] === "string" && { documentVersion: block.attrs["document_version"] }),
|
|
72
79
|
rootComponent: optionalString(block.attrs, "root_component", where, ctx) ?? "",
|
|
73
|
-
components: componentMap(componentsRaw, owner, ctx, where),
|
|
80
|
+
components: componentMap(componentsRaw, scopedLabelToBagKey(owner.ownerTfLabel, block.label ?? "", scopeOf(owner)), owner, ctx, where),
|
|
74
81
|
};
|
|
75
82
|
const conditions = plainObject(block.attrs["conditions"]);
|
|
76
83
|
if (conditions !== undefined)
|
|
@@ -88,11 +95,14 @@ function dynamicLayoutFromTf(block, owner, ctx) {
|
|
|
88
95
|
if (metadata !== undefined)
|
|
89
96
|
layout["metadata"] = camelObject(metadata);
|
|
90
97
|
return {
|
|
91
|
-
key: scopedLabelToBagKey(owner.ownerTfLabel, block.label ?? "",
|
|
98
|
+
key: scopedLabelToBagKey(owner.ownerTfLabel, block.label ?? "", scopeOf(owner)),
|
|
92
99
|
layout,
|
|
93
100
|
};
|
|
94
101
|
}
|
|
95
|
-
function
|
|
102
|
+
function scopeOf(owner) {
|
|
103
|
+
return owner.scope ?? "app";
|
|
104
|
+
}
|
|
105
|
+
function componentMap(values, layoutKey, owner, ctx, where) {
|
|
96
106
|
const out = {};
|
|
97
107
|
for (const [id, raw] of Object.entries(values)) {
|
|
98
108
|
const component = camelObject(plainObject(raw) ?? {});
|
|
@@ -129,9 +139,14 @@ function componentMap(values, owner, ctx, where) {
|
|
|
129
139
|
}
|
|
130
140
|
const automation = plainUnknownObject(component["automationButton"]);
|
|
131
141
|
if (automation !== undefined) {
|
|
132
|
-
// Build derives
|
|
142
|
+
// Build derives a companion widget from the component itself, so that
|
|
133
143
|
// binding is never authored and must not be printed back into source.
|
|
144
|
+
const widgetLabel = resourceRefLabel(automation["widgetId"], WIDGET_RESOURCE_TYPE);
|
|
145
|
+
if (widgetLabel !== undefined && widgetLabel !== dynamicLayoutCompanionWidgetLabel(owner.label, layoutKey, id, scopeOf(owner))) {
|
|
146
|
+
automation["widget"] = pulledRef("widget", scopedLabelToBagKey(owner.label, widgetLabel, scopeOf(owner)), owner.ownerRefName);
|
|
147
|
+
}
|
|
134
148
|
delete automation["widgetId"];
|
|
149
|
+
const automationId = automation["automationId"];
|
|
135
150
|
if (automation["automationId"] !== undefined) {
|
|
136
151
|
const label = resourceRefLabel(automation["automationId"], "elementum_automation");
|
|
137
152
|
if (label !== undefined) {
|
|
@@ -141,7 +156,52 @@ function componentMap(values, owner, ctx, where) {
|
|
|
141
156
|
ctx.diagnostics.push(`${where}.components.${id}.automationButton: automation_id is not a managed automation ref; dropped`);
|
|
142
157
|
delete automation["automationId"];
|
|
143
158
|
}
|
|
159
|
+
if (automation["automationAppId"] !== undefined) {
|
|
160
|
+
const ref = aspectRef(automation["automationAppId"], owner, ctx);
|
|
161
|
+
if (ref !== undefined)
|
|
162
|
+
automation["automationApp"] = ref;
|
|
163
|
+
else
|
|
164
|
+
ctx.diagnostics.push(`${where}.components.${id}.automationButton: automation_app_id is not resolvable; dropped`);
|
|
165
|
+
delete automation["automationAppId"];
|
|
166
|
+
}
|
|
167
|
+
if (Array.isArray(automation["inputs"])) {
|
|
168
|
+
const automationLabel = automationId === undefined ? undefined : resourceRefLabel(automationId, "elementum_automation");
|
|
169
|
+
automation["inputs"] = automation["inputs"].flatMap((raw, index) => {
|
|
170
|
+
const input = plainUnknownObject(raw);
|
|
171
|
+
if (input === undefined)
|
|
172
|
+
return [];
|
|
173
|
+
const parameter = input["parameterId"];
|
|
174
|
+
if (parameter !== undefined && isTfExpr(parameter)) {
|
|
175
|
+
const managed = managedParameter(parameter, ctx);
|
|
176
|
+
if (managed === undefined) {
|
|
177
|
+
ctx.diagnostics.push(`${where}.components.${id}.automationButton.inputs[${index}]: parameter_id is not a managed automation parameter; dropped`);
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
input["parameterName"] = managed.name;
|
|
181
|
+
if (managed.automationLabel !== automationLabel) {
|
|
182
|
+
input["automation"] = pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, managed.automationLabel, "app"), owner.ownerRefName);
|
|
183
|
+
}
|
|
184
|
+
delete input["parameterId"];
|
|
185
|
+
}
|
|
186
|
+
return [input];
|
|
187
|
+
});
|
|
188
|
+
for (const [index, raw] of automation["inputs"].entries()) {
|
|
189
|
+
const input = plainUnknownObject(raw);
|
|
190
|
+
if (input === undefined || !Array.isArray(input["fieldRefParams"]))
|
|
191
|
+
continue;
|
|
192
|
+
input["fieldRefParams"] = input["fieldRefParams"].flatMap((param) => {
|
|
193
|
+
const entry = plainUnknownObject(param);
|
|
194
|
+
const field = entry === undefined
|
|
195
|
+
? undefined
|
|
196
|
+
: fieldKey(entry["fieldId"], owner, ctx, `${where}.components.${id}.automationButton.inputs[${index}]`);
|
|
197
|
+
return field === undefined ? [] : [{ name: entry["name"], field }];
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
144
201
|
}
|
|
202
|
+
const related = plainUnknownObject(component["relatedItemsBlock"]);
|
|
203
|
+
if (related !== undefined)
|
|
204
|
+
relatedItemsBlock(related, owner, ctx, `${where}.components.${id}.relatedItemsBlock`);
|
|
145
205
|
const create = plainUnknownObject(component["createButton"]);
|
|
146
206
|
if (create !== undefined && create["targetAspectId"] !== undefined) {
|
|
147
207
|
const ref = aspectRef(create["targetAspectId"], owner, ctx);
|
|
@@ -155,6 +215,101 @@ function componentMap(values, owner, ctx, where) {
|
|
|
155
215
|
}
|
|
156
216
|
return out;
|
|
157
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* A managed automation's parameter, read from its draft on-demand trigger or
|
|
220
|
+
* from a `data.elementum_automation` lookup of the published workflow.
|
|
221
|
+
*/
|
|
222
|
+
function managedParameter(parameter, ctx) {
|
|
223
|
+
if (!isTfExpr(parameter) || (parameter.$expr !== "resource-attr" && parameter.$expr !== "data-attr"))
|
|
224
|
+
return undefined;
|
|
225
|
+
const segment = parameter.path[1];
|
|
226
|
+
const name = typeof segment === "object" && segment !== null && "index" in segment ? segment.index : undefined;
|
|
227
|
+
if (parameter.path.length !== 2 || parameter.path[0] !== "parameter_ids" || typeof name !== "string")
|
|
228
|
+
return undefined;
|
|
229
|
+
if (parameter.$expr === "resource-attr") {
|
|
230
|
+
return parameter.type === "elementum_on_demand_trigger" ? { automationLabel: parameter.label, name } : undefined;
|
|
231
|
+
}
|
|
232
|
+
if (parameter.type !== "elementum_automation")
|
|
233
|
+
return undefined;
|
|
234
|
+
const automationId = ctx.dataAttrs?.("elementum_automation", parameter.label)?.["id"];
|
|
235
|
+
const automationLabel = automationId === undefined ? undefined : resourceRefLabel(automationId, "elementum_automation");
|
|
236
|
+
return automationLabel === undefined ? undefined : { automationLabel, name };
|
|
237
|
+
}
|
|
238
|
+
function relatedItemsBlock(block, owner, ctx, where) {
|
|
239
|
+
const aspectId = block["relatedAspectId"];
|
|
240
|
+
delete block["relatedAspectId"];
|
|
241
|
+
if (aspectId !== undefined) {
|
|
242
|
+
const ref = aspectRef(aspectId, owner, ctx);
|
|
243
|
+
if (ref !== undefined)
|
|
244
|
+
block["related"] = ref;
|
|
245
|
+
else
|
|
246
|
+
ctx.diagnostics.push(`${where}: related_aspect_id is not resolvable; dropped`);
|
|
247
|
+
}
|
|
248
|
+
const raw = block["filter"];
|
|
249
|
+
delete block["filter"];
|
|
250
|
+
if (raw === undefined)
|
|
251
|
+
return;
|
|
252
|
+
const wire = filterWireToTf(decodeJson(raw));
|
|
253
|
+
const filterOwners = [{
|
|
254
|
+
type: owner.type,
|
|
255
|
+
label: owner.label,
|
|
256
|
+
ownerRefName: owner.ownerRefName,
|
|
257
|
+
ownerTfLabel: owner.ownerTfLabel,
|
|
258
|
+
scope: scopeOf(owner),
|
|
259
|
+
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
260
|
+
}];
|
|
261
|
+
// The filter ranges over the related aspect's records, so its fields may
|
|
262
|
+
// belong to that aspect rather than to the layout's owner.
|
|
263
|
+
const aspectOwner = aspectId === undefined || resourceRefLabel(aspectId, owner.type) === owner.label
|
|
264
|
+
? undefined
|
|
265
|
+
: filterOwnerForAspect(aspectId, ctx);
|
|
266
|
+
if (aspectOwner !== undefined)
|
|
267
|
+
filterOwners.push(aspectOwner);
|
|
268
|
+
// A raw field id decodes without throwing even when it is not the owner's
|
|
269
|
+
// field, so a decode that leaves one unresolved is only a fallback.
|
|
270
|
+
let failure;
|
|
271
|
+
let partial;
|
|
272
|
+
for (const filterOwner of filterOwners) {
|
|
273
|
+
try {
|
|
274
|
+
const decoded = filterFromTf(wire, filterOwner, `${where}.filter`, ctx);
|
|
275
|
+
if (!hasUnresolvedRef(decoded)) {
|
|
276
|
+
block["filter"] = decoded;
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
partial ??= decoded;
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
failure ??= error;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (partial !== undefined) {
|
|
286
|
+
block["filter"] = partial;
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
ctx.diagnostics.push(failure instanceof Error ? `${failure.message}; filter dropped` : `${where}.filter: not decodable; dropped`);
|
|
290
|
+
}
|
|
291
|
+
function hasUnresolvedRef(value) {
|
|
292
|
+
if (Array.isArray(value))
|
|
293
|
+
return value.some(hasUnresolvedRef);
|
|
294
|
+
if (typeof value !== "object" || value === null)
|
|
295
|
+
return false;
|
|
296
|
+
if (value.kind === "unresolved")
|
|
297
|
+
return true;
|
|
298
|
+
return Object.values(value).some(hasUnresolvedRef);
|
|
299
|
+
}
|
|
300
|
+
function decodeJson(value) {
|
|
301
|
+
if (isTfExpr(value) && value.$expr === "jsonencode")
|
|
302
|
+
return value.value;
|
|
303
|
+
if (typeof value === "string") {
|
|
304
|
+
try {
|
|
305
|
+
return JSON.parse(value);
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
return value;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return value;
|
|
312
|
+
}
|
|
158
313
|
function conditionMap(values, owner, ctx, where) {
|
|
159
314
|
const out = {};
|
|
160
315
|
for (const [id, raw] of Object.entries(values)) {
|
|
@@ -176,7 +331,7 @@ function conditionMap(values, owner, ctx, where) {
|
|
|
176
331
|
}
|
|
177
332
|
const stage = plainUnknownObject(condition["stage"]);
|
|
178
333
|
if (stage !== undefined && stage["stageId"] !== undefined) {
|
|
179
|
-
const key = stageKey(stage["stageId"], owner);
|
|
334
|
+
const key = stageKey(stage["stageId"], owner, ctx, `${where}.conditions.${id}.stage`);
|
|
180
335
|
if (key !== undefined)
|
|
181
336
|
stage["stage"] = key;
|
|
182
337
|
delete stage["stageId"];
|
|
@@ -221,30 +376,37 @@ function dependency(value, owner, ctx, where) {
|
|
|
221
376
|
return out;
|
|
222
377
|
}
|
|
223
378
|
function fieldKey(value, owner, ctx, where) {
|
|
224
|
-
const key =
|
|
379
|
+
const key = fieldKeyFromTfValue(value, owner.ownerRefName, owner.ownerTfLabel, scopeOf(owner), ctx);
|
|
225
380
|
if (key === undefined) {
|
|
226
381
|
ctx.diagnostics.push(`${where}: field reference ${JSON.stringify(value)} is not resolvable; dropped`);
|
|
227
382
|
}
|
|
228
383
|
return key;
|
|
229
384
|
}
|
|
230
|
-
function stageKey(value, owner) {
|
|
385
|
+
function stageKey(value, owner, ctx, where) {
|
|
386
|
+
const index = stageIndex(value, owner);
|
|
387
|
+
if (index === undefined || isTfLabel(index))
|
|
388
|
+
return index === undefined ? undefined : tfLabelToTsLabel(index);
|
|
389
|
+
ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(index)} is outside the terraform label alphabet; stage dropped`);
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
function stageIndex(value, owner) {
|
|
231
393
|
if (value === undefined || !isTfExpr(value))
|
|
232
394
|
return undefined;
|
|
233
395
|
if (value.$expr === "resource-attr" && value.type === owner.type && value.label === owner.label && value.path[0] === "stage_ids_by_key") {
|
|
234
396
|
const segment = value.path[1];
|
|
235
397
|
if (value.path.length === 2 && typeof segment === "object" && segment !== null && "index" in segment)
|
|
236
|
-
return
|
|
398
|
+
return segment.index;
|
|
237
399
|
}
|
|
238
|
-
if (value.$expr === "local" && value.name === `${owner.
|
|
400
|
+
if (value.$expr === "local" && value.name === `${owner.label}_stage_ids_by_key`) {
|
|
239
401
|
const segment = value.path[0];
|
|
240
402
|
if (value.path.length === 1 && typeof segment === "object" && segment !== null && "index" in segment)
|
|
241
|
-
return
|
|
403
|
+
return segment.index;
|
|
242
404
|
}
|
|
243
405
|
return undefined;
|
|
244
406
|
}
|
|
245
407
|
function aspectRef(value, owner, ctx) {
|
|
246
408
|
if (resourceRefLabel(value, owner.type) === owner.label)
|
|
247
|
-
return pulledRef(
|
|
409
|
+
return pulledRef(scopeOf(owner), owner.ownerRefName);
|
|
248
410
|
for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
|
|
249
411
|
const resourceLabel = resourceRefLabel(value, type);
|
|
250
412
|
if (resourceLabel !== undefined)
|
|
@@ -4,7 +4,10 @@ export const dynamicLayoutModule = {
|
|
|
4
4
|
kind: "dynamic-layout",
|
|
5
5
|
stream: { role: "streamMember" },
|
|
6
6
|
authoring: { unit: "inline", bag: "dynamicLayouts" },
|
|
7
|
-
parents: [
|
|
7
|
+
parents: [
|
|
8
|
+
{ parent: "app", child: "dynamic-layout" },
|
|
9
|
+
{ parent: "element", child: "dynamic-layout" },
|
|
10
|
+
],
|
|
8
11
|
resource: { shape: "single", resourceType: DYNAMIC_LAYOUT_RESOURCE_TYPE, adoptable: true },
|
|
9
12
|
data: NO_DATA,
|
|
10
13
|
lifecycle: NO_LIFECYCLE,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
2
|
-
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
2
|
+
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
3
3
|
export interface DynamicLayoutWire {
|
|
4
4
|
readonly name?: string;
|
|
5
5
|
readonly description?: string;
|
|
@@ -18,10 +18,14 @@ export interface DynamicLayoutWire {
|
|
|
18
18
|
export interface DynamicLayoutToTfOptions {
|
|
19
19
|
readonly ownerRefName: string;
|
|
20
20
|
readonly ownerTfLabel: string;
|
|
21
|
+
/** Owning stream root kind; defaults to `"app"`. Elements have no stages. */
|
|
22
|
+
readonly scope?: ChildResourceScope;
|
|
21
23
|
readonly objectId: TfValue;
|
|
22
24
|
readonly diagnostics: string[];
|
|
23
25
|
readonly orgRefs: OrgRefLookup;
|
|
24
26
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
25
27
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
28
|
+
/** Widget keys the owner declares, for buttons that run through an authored widget. */
|
|
29
|
+
readonly widgetKeys?: ReadonlySet<string>;
|
|
26
30
|
}
|
|
27
31
|
export declare function dynamicLayoutsToTf(layouts: Readonly<Record<string, DynamicLayoutWire>> | undefined, opts: DynamicLayoutToTfOptions): TfBlock[];
|