@elementumai/edk 0.13.0 → 0.13.2
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 +6 -2
- package/dist-sdk/src/catalog/factories.js +8 -2
- package/dist-sdk/src/catalog/types.d.ts +5 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +12 -0
- package/dist-sdk/src/engine/coverage-gaps.js +23 -0
- package/dist-sdk/src/engine/ei/run.d.ts +8 -0
- package/dist-sdk/src/engine/ei/run.js +46 -7
- package/dist-sdk/src/engine/progress.d.ts +1 -0
- package/dist-sdk/src/engine/progress.js +6 -0
- package/dist-sdk/src/engine/pull/context.d.ts +24 -0
- package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
- package/dist-sdk/src/engine/pull/result-output.js +1 -1
- package/dist-sdk/src/engine/pull/stream-root.d.ts +11 -0
- package/dist-sdk/src/engine/pull/stream-root.js +22 -6
- package/dist-sdk/src/engine/tf/escape.d.ts +8 -3
- package/dist-sdk/src/engine/tf/escape.js +17 -4
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +4 -7
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +28 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/to-tf.js +21 -3
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +6 -23
- package/dist-sdk/src/entities/app/index.d.ts +1 -1
- package/dist-sdk/src/entities/app/module.js +2 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.js +2 -2
- package/dist-sdk/src/entities/automation/build.d.ts +10 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +1 -0
- package/dist-sdk/src/entities/automation/from-tf.js +72 -11
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +12 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
- package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/automation/to-tf.js +312 -51
- package/dist-sdk/src/entities/automation/triggers.d.ts +5 -1
- package/dist-sdk/src/entities/automation/workflow-output.d.ts +7 -0
- package/dist-sdk/src/entities/automation/workflow-output.js +8 -0
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- package/dist-sdk/src/entities/dynamic-layout/lint.d.ts +7 -0
- package/dist-sdk/src/entities/dynamic-layout/lint.js +48 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +2 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +5 -21
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/element/module.js +2 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +25 -2
- package/dist-sdk/src/entities/field/from-tf.js +119 -14
- package/dist-sdk/src/entities/relationship/from-tf.js +2 -2
- package/dist-sdk/src/entities/role/build.d.ts +3 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
- package/dist-sdk/src/entities/search-table/build.js +4 -4
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
- package/dist-sdk/src/entities/shared/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +24 -13
- package/dist-sdk/src/entities/shared/filters/index.js +12 -1
- package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +15 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +4 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +16 -0
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +2 -5
- package/dist-sdk/src/entities/task/from-tf.js +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +6 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +6 -1
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +14 -2
- package/dist-sdk/src/entities/view/custom-view-references.d.ts +33 -0
- package/dist-sdk/src/entities/view/custom-view-references.js +140 -0
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +16 -9
- package/dist-sdk/src/entities/view/custom-view-validate.js +38 -18
- package/dist-sdk/src/entities/view/from-tf.js +9 -0
- package/dist-sdk/src/entities/view/layout-lint.d.ts +26 -0
- package/dist-sdk/src/entities/view/layout-lint.js +50 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/to-tf.js +69 -47
- package/dist-sdk/src/entities/visual-flow/build.d.ts +8 -1
- package/dist-sdk/src/entities/visual-flow/from-tf.js +16 -0
- package/dist-sdk/src/entities/visual-flow/initiate.d.ts +12 -0
- package/dist-sdk/src/entities/visual-flow/initiate.js +12 -0
- package/dist-sdk/src/entities/visual-flow/module.js +52 -1
- package/dist-sdk/src/entities/visual-flow/to-tf.js +16 -2
- package/dist-sdk/src/entities/widget/from-tf.js +6 -6
- package/dist-sdk/src/graph/index.d.ts +4 -0
- package/dist-sdk/src/graph/index.js +1 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +36 -1
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
|
3
3
|
import { filterToTf } from "../access-policy/to-tf.js";
|
|
4
4
|
import { filterTfToWire } from "../shared/filters/tf-codec.js";
|
|
5
5
|
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
6
|
+
import { dashboardWidgetOrderToTf } from "../dashboard-widget-order/order.js";
|
|
6
7
|
import { targetFilterFieldResolver } from "../relationship/to-tf.js";
|
|
7
8
|
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
8
9
|
import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
|
|
@@ -30,6 +31,8 @@ export function dashboardsToTf(dashboards, opts) {
|
|
|
30
31
|
label: dashboardLabel,
|
|
31
32
|
attrs,
|
|
32
33
|
});
|
|
34
|
+
// The widgets bag's key order is the dashboard's widget order.
|
|
35
|
+
const widgetLabels = [];
|
|
33
36
|
for (const [widgetKey, widget] of Object.entries(dashboard.widgets ?? {})) {
|
|
34
37
|
const where = `dashboards.${key}.widgets.${widgetKey}`;
|
|
35
38
|
if (!isCanonicalTsLabel(widgetKey)) {
|
|
@@ -92,8 +95,13 @@ export function dashboardsToTf(dashboards, opts) {
|
|
|
92
95
|
opts.diagnostics.push(`${where}: unsupported widget type; dropped`);
|
|
93
96
|
continue;
|
|
94
97
|
}
|
|
95
|
-
|
|
98
|
+
const widgetLabel = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(`${key}_${widgetKey}`), opts.scope);
|
|
99
|
+
widgetLabels.push(widgetLabel);
|
|
100
|
+
blocks.push({ kind: "resource", type: DASHBOARD_WIDGET_RESOURCE_TYPE, label: widgetLabel, attrs: widgetAttrs });
|
|
96
101
|
}
|
|
102
|
+
const order = dashboardWidgetOrderToTf(dashboardLabel, opts.ownerId, expr.resourceAttr(DASHBOARD_RESOURCE_TYPE, dashboardLabel, ["id"]), widgetLabels);
|
|
103
|
+
if (order !== undefined)
|
|
104
|
+
blocks.push(order);
|
|
97
105
|
}
|
|
98
106
|
return blocks;
|
|
99
107
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type EntityKindModule } from "../../graph/types.js";
|
|
2
|
+
import { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE } from "./order.js";
|
|
3
|
+
export { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE };
|
|
4
|
+
/**
|
|
5
|
+
* `elementum_dashboard_widget_order` orders one dashboard's widgets. Build
|
|
6
|
+
* emits it from the authored `widgets` key order; pull prints widgets in its
|
|
7
|
+
* order. It has no authoring of its own: the bag order is the order. Its
|
|
8
|
+
* import id is `<owner id>:<dashboard id>`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const dashboardWidgetOrderModule: EntityKindModule;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NO_CANVAS, NO_CATALOG, NO_DATA, NO_LIFECYCLE } from "../../graph/types.js";
|
|
2
|
+
import { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, dashboardWidgetOrderStateAdoption } from "./order.js";
|
|
3
|
+
export { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE };
|
|
4
|
+
/**
|
|
5
|
+
* `elementum_dashboard_widget_order` orders one dashboard's widgets. Build
|
|
6
|
+
* emits it from the authored `widgets` key order; pull prints widgets in its
|
|
7
|
+
* order. It has no authoring of its own: the bag order is the order. Its
|
|
8
|
+
* import id is `<owner id>:<dashboard id>`.
|
|
9
|
+
*/
|
|
10
|
+
export const dashboardWidgetOrderModule = {
|
|
11
|
+
kind: "dashboard-widget-order",
|
|
12
|
+
stream: { role: "streamMember" },
|
|
13
|
+
authoring: { unit: "inline", bag: "widgets" },
|
|
14
|
+
parents: [{ parent: "dashboard", child: "dashboard-widget-order" }],
|
|
15
|
+
resource: { shape: "single", resourceType: DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, adoptable: true },
|
|
16
|
+
data: NO_DATA,
|
|
17
|
+
lifecycle: NO_LIFECYCLE,
|
|
18
|
+
canvas: NO_CANVAS,
|
|
19
|
+
catalog: NO_CATALOG,
|
|
20
|
+
stateAdoption: dashboardWidgetOrderStateAdoption,
|
|
21
|
+
// Build writes no order when the dashboard has no authored widgets.
|
|
22
|
+
portable: {
|
|
23
|
+
leaveOutWhenEmptied: [{ resourceType: DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, attribute: "widget_ids", reason: "it only ordered the left-out widgets" }],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
2
|
+
import type { StateAdoptionFacet } from "../../graph/types.js";
|
|
3
|
+
export declare const DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE = "elementum_dashboard_widget_order";
|
|
4
|
+
/**
|
|
5
|
+
* The dashboard's widget order block, or undefined when it has no widget
|
|
6
|
+
* resource. It takes the dashboard's own label (one order per dashboard), as
|
|
7
|
+
* `ei export` names it. `widgetLabels` is in authored order.
|
|
8
|
+
*/
|
|
9
|
+
export declare function dashboardWidgetOrderToTf(dashboardLabel: string, ownerId: TfValue, dashboardId: TfValue, widgetLabels: readonly string[]): TfBlock | undefined;
|
|
10
|
+
/** Attributes `inDashboardWidgetOrder` reads. */
|
|
11
|
+
export declare const KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS: ReadonlySet<string>;
|
|
12
|
+
/** The order block whose `dashboard_id` references `dashboardType.dashboardLabel`. */
|
|
13
|
+
export declare function dashboardWidgetOrderFor(orderBlocks: readonly TfBlock[], dashboardType: string, dashboardLabel: string): TfBlock | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* `widgetBlocks` in the order the dashboard's widget order lists them, so pull
|
|
16
|
+
* prints widgets in the platform's order instead of the parser's label order.
|
|
17
|
+
* Widgets it doesn't list keep their relative order after the listed ones.
|
|
18
|
+
*/
|
|
19
|
+
export declare function inDashboardWidgetOrder(widgetBlocks: readonly TfBlock[], orderBlock: TfBlock | undefined): readonly TfBlock[];
|
|
20
|
+
/**
|
|
21
|
+
* A dashboard whose order has no state would plan a hidden create (a live
|
|
22
|
+
* reorder): a workspace pulled before widget order was managed, or a pull that
|
|
23
|
+
* left one of the dashboard's widgets out of source and released the order
|
|
24
|
+
* with it. When the dashboard is in state but its order isn't, import the live
|
|
25
|
+
* order, keyed `<owner id>:<dashboard id>:<widget ids>` with the ids of the
|
|
26
|
+
* widgets build lists that state already holds. The provider then tracks only
|
|
27
|
+
* those widgets, so a widget source doesn't hold never shows as a change, and
|
|
28
|
+
* any reorder of the listed ones shows as a visible in-place `widget_ids`
|
|
29
|
+
* update.
|
|
30
|
+
*/
|
|
31
|
+
export declare const dashboardWidgetOrderStateAdoption: StateAdoptionFacet;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A dashboard's widget order: `elementum_dashboard_widget_order` lists the
|
|
3
|
+
* dashboard's widget resources in authored `widgets` key order. Without it a
|
|
4
|
+
* widget keeps the position the platform gave it at create (the widget count
|
|
5
|
+
* then), and every add or delete shifts the rest, so the rendered order drifts
|
|
6
|
+
* between applies.
|
|
7
|
+
*/
|
|
8
|
+
import { resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
|
+
import { expr, isTfExpr } from "../../engine/tf/index.js";
|
|
10
|
+
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
11
|
+
export const DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE = "elementum_dashboard_widget_order";
|
|
12
|
+
/**
|
|
13
|
+
* The dashboard's widget order block, or undefined when it has no widget
|
|
14
|
+
* resource. It takes the dashboard's own label (one order per dashboard), as
|
|
15
|
+
* `ei export` names it. `widgetLabels` is in authored order.
|
|
16
|
+
*/
|
|
17
|
+
export function dashboardWidgetOrderToTf(dashboardLabel, ownerId, dashboardId, widgetLabels) {
|
|
18
|
+
if (widgetLabels.length === 0)
|
|
19
|
+
return undefined;
|
|
20
|
+
return {
|
|
21
|
+
kind: "resource",
|
|
22
|
+
type: DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE,
|
|
23
|
+
label: dashboardLabel,
|
|
24
|
+
attrs: {
|
|
25
|
+
owner_id: ownerId,
|
|
26
|
+
dashboard_id: dashboardId,
|
|
27
|
+
widget_ids: widgetLabels.map((label) => expr.resourceAttr(DASHBOARD_WIDGET_RESOURCE_TYPE, label, ["id"])),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Attributes `inDashboardWidgetOrder` reads. */
|
|
32
|
+
export const KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS = new Set(["owner_id", "dashboard_id", "widget_ids"]);
|
|
33
|
+
/** The order block whose `dashboard_id` references `dashboardType.dashboardLabel`. */
|
|
34
|
+
export function dashboardWidgetOrderFor(orderBlocks, dashboardType, dashboardLabel) {
|
|
35
|
+
return orderBlocks.find((block) => resourceRefLabel(block.attrs["dashboard_id"], dashboardType) === dashboardLabel);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `widgetBlocks` in the order the dashboard's widget order lists them, so pull
|
|
39
|
+
* prints widgets in the platform's order instead of the parser's label order.
|
|
40
|
+
* Widgets it doesn't list keep their relative order after the listed ones.
|
|
41
|
+
*/
|
|
42
|
+
export function inDashboardWidgetOrder(widgetBlocks, orderBlock) {
|
|
43
|
+
const widgetIds = orderBlock?.attrs["widget_ids"];
|
|
44
|
+
if (!Array.isArray(widgetIds))
|
|
45
|
+
return widgetBlocks;
|
|
46
|
+
const position = new Map();
|
|
47
|
+
for (const [index, value] of widgetIds.entries()) {
|
|
48
|
+
const label = resourceRefLabel(value, DASHBOARD_WIDGET_RESOURCE_TYPE);
|
|
49
|
+
if (label !== undefined)
|
|
50
|
+
position.set(label, index);
|
|
51
|
+
}
|
|
52
|
+
const at = (block) => position.get(block.label ?? "") ?? Number.MAX_SAFE_INTEGER;
|
|
53
|
+
return [...widgetBlocks].sort((a, b) => at(a) - at(b));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A dashboard whose order has no state would plan a hidden create (a live
|
|
57
|
+
* reorder): a workspace pulled before widget order was managed, or a pull that
|
|
58
|
+
* left one of the dashboard's widgets out of source and released the order
|
|
59
|
+
* with it. When the dashboard is in state but its order isn't, import the live
|
|
60
|
+
* order, keyed `<owner id>:<dashboard id>:<widget ids>` with the ids of the
|
|
61
|
+
* widgets build lists that state already holds. The provider then tracks only
|
|
62
|
+
* those widgets, so a widget source doesn't hold never shows as a change, and
|
|
63
|
+
* any reorder of the listed ones shows as a visible in-place `widget_ids`
|
|
64
|
+
* update.
|
|
65
|
+
*/
|
|
66
|
+
export const dashboardWidgetOrderStateAdoption = {
|
|
67
|
+
importsFor(blocks, state) {
|
|
68
|
+
const out = [];
|
|
69
|
+
for (const block of blocks) {
|
|
70
|
+
if (block.kind !== "resource" || block.type !== DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE || block.label === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
if (state.has(block.type, block.label))
|
|
73
|
+
continue;
|
|
74
|
+
const owner = block.attrs["owner_id"];
|
|
75
|
+
const dashboard = block.attrs["dashboard_id"];
|
|
76
|
+
if (!isTfExpr(owner) || owner.$expr !== "resource-attr")
|
|
77
|
+
continue;
|
|
78
|
+
if (!isTfExpr(dashboard) || dashboard.$expr !== "resource-attr")
|
|
79
|
+
continue;
|
|
80
|
+
const ownerId = state.idOf(owner.type, owner.label);
|
|
81
|
+
const dashboardId = state.idOf(dashboard.type, dashboard.label);
|
|
82
|
+
if (ownerId === undefined || dashboardId === undefined)
|
|
83
|
+
continue;
|
|
84
|
+
const widgetIds = Array.isArray(block.attrs["widget_ids"]) ? block.attrs["widget_ids"] : [];
|
|
85
|
+
const tracked = widgetIds.flatMap((value) => {
|
|
86
|
+
const label = resourceRefLabel(value, DASHBOARD_WIDGET_RESOURCE_TYPE);
|
|
87
|
+
const id = label === undefined ? undefined : state.idOf(DASHBOARD_WIDGET_RESOURCE_TYPE, label);
|
|
88
|
+
return id === undefined ? [] : [id];
|
|
89
|
+
});
|
|
90
|
+
out.push({ type: block.type, label: block.label, id: `${ownerId}:${dashboardId}:${tracked.join(",")}` });
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
},
|
|
94
|
+
warning(imports) {
|
|
95
|
+
const names = imports.slice(0, 5).map((i) => i.label).join(", ");
|
|
96
|
+
const more = imports.length > 5 ? `, … (+${imports.length - 5} more)` : "";
|
|
97
|
+
return [
|
|
98
|
+
`${imports.length} dashboard(s) have no ${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE} state (a workspace pulled before widget order was managed, or a pull that left one of the dashboard's widgets out): ${names}${more}.`,
|
|
99
|
+
"Importing their live widget order for the widgets in source; a widget_ids change in the plan reorders the dashboard to match the widgets' order in source.",
|
|
100
|
+
].join("\n");
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type ComponentWire = Readonly<Record<string, unknown>>;
|
|
2
|
+
/**
|
|
3
|
+
* Advisories for one typed dynamic layout's component graph, pushed onto
|
|
4
|
+
* `diagnostics`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function lintDynamicLayout(where: string, components: Readonly<Record<string, ComponentWire>>, diagnostics: string[]): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build checks for typed dynamic layouts that read badly (#1774): the
|
|
3
|
+
* dynamic-layout half of `src/entities/view/layout-lint.ts` (empty
|
|
4
|
+
* containers and one long column of fields). Both are advisories
|
|
5
|
+
* (`ADVISORY_DIAGNOSTICS` in `src/engine/coverage-gaps.ts`):
|
|
6
|
+
* `dynamicLayoutsToTf` still emits every component as authored, so they are
|
|
7
|
+
* printed but never counted as coverage gaps. `column.span` is not checked:
|
|
8
|
+
* the provider writes it on every column (`layoutconfig/parse.go`), so
|
|
9
|
+
* nothing about it is dropped.
|
|
10
|
+
*/
|
|
11
|
+
import { LONG_COLUMN_FIELD_COUNT } from "../view/layout-lint.js";
|
|
12
|
+
import { DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS } from "./dialect.js";
|
|
13
|
+
/** Layout variants that only arrange their children. */
|
|
14
|
+
const CONTAINER_VARIANTS = ["container", "section", "row", "column", "grid", "card"];
|
|
15
|
+
function containerVariantOf(component) {
|
|
16
|
+
return component === undefined ? undefined : CONTAINER_VARIANTS.find((variant) => variant in component);
|
|
17
|
+
}
|
|
18
|
+
function childrenOf(component) {
|
|
19
|
+
const children = component?.["children"];
|
|
20
|
+
return Array.isArray(children) ? children.filter((id) => typeof id === "string") : [];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Advisories for one typed dynamic layout's component graph, pushed onto
|
|
24
|
+
* `diagnostics`.
|
|
25
|
+
*/
|
|
26
|
+
export function lintDynamicLayout(where, components, diagnostics) {
|
|
27
|
+
const fieldVariants = DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS;
|
|
28
|
+
for (const [id, component] of Object.entries(components)) {
|
|
29
|
+
const variant = containerVariantOf(component);
|
|
30
|
+
if (variant === undefined)
|
|
31
|
+
continue;
|
|
32
|
+
const at = `${where}.components.${id}`;
|
|
33
|
+
const children = childrenOf(component);
|
|
34
|
+
if (children.length === 0) {
|
|
35
|
+
diagnostics.push(`${at}: ${variant} has no children, so it renders empty; add components or remove it`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (variant !== "grid" && variant !== "row") {
|
|
39
|
+
const fields = children.filter((child) => {
|
|
40
|
+
const childComponent = components[child];
|
|
41
|
+
return childComponent !== undefined && Object.keys(childComponent).some((key) => fieldVariants.has(key));
|
|
42
|
+
}).length;
|
|
43
|
+
if (fields > LONG_COLUMN_FIELD_COUNT) {
|
|
44
|
+
diagnostics.push(`${at}: ${variant} stacks ${fields} fields in one column; put them in a grid (columns: 2) or split them into titled sections`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -13,6 +13,7 @@ import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
|
13
13
|
import { unbuiltWidgetReferenceNote } from "../widget/to-tf.js";
|
|
14
14
|
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
15
15
|
import { DYNAMIC_LAYOUT_RESOURCE_TYPE } from "./module.js";
|
|
16
|
+
import { lintDynamicLayout } from "./lint.js";
|
|
16
17
|
import { EntityTfError } from "../../engine/entity.js";
|
|
17
18
|
import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS, dynamicLayoutActionWidgetName, dynamicLayoutCompanionWidgetLabel, dynamicLayoutFieldComponentWireKey, } from "./dialect.js";
|
|
18
19
|
export function dynamicLayoutsToTf(layouts, opts) {
|
|
@@ -25,6 +26,7 @@ export function dynamicLayoutsToTf(layouts, opts) {
|
|
|
25
26
|
}
|
|
26
27
|
const staged = scopeOf(opts) === "element" ? withoutStageConditions(authored, where, opts.diagnostics) : authored;
|
|
27
28
|
const layout = withoutUnbuildableButtons(withoutUnresolvedFieldEntries(staged, where, opts), where, opts);
|
|
29
|
+
lintDynamicLayout(where, layout.components ?? {}, opts.diagnostics);
|
|
28
30
|
const layoutLabel = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(key), scopeOf(opts));
|
|
29
31
|
const componentResult = componentMap(layout.components ?? {}, key, layoutLabel, where, opts);
|
|
30
32
|
const identity = requiredLayoutIdentity(layout, where, opts);
|
|
@@ -24,6 +24,7 @@ export interface ElementFromTfViewBlocks {
|
|
|
24
24
|
readonly relationshipBlocks: readonly TfBlock[];
|
|
25
25
|
readonly dashboardBlocks: readonly TfBlock[];
|
|
26
26
|
readonly dashboardWidgetBlocks: readonly TfBlock[];
|
|
27
|
+
readonly dashboardWidgetOrderBlocks?: readonly TfBlock[];
|
|
27
28
|
readonly widgetBlocks: readonly TfBlock[];
|
|
28
29
|
}
|
|
29
30
|
export declare function elementFromTf(elementBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: ElementFromTfViewBlocks, accessPolicyBlocks?: readonly TfBlock[], roleBlocks?: readonly TfBlock[]): ElementFromTfResult;
|
|
@@ -7,18 +7,17 @@ import { autoShareFromTf } from "../app/auto-share.js";
|
|
|
7
7
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES } from "../../core/system-fields.js";
|
|
8
8
|
import { EntityTfError } from "../../engine/entity.js";
|
|
9
9
|
import { dataRefLabel, optionalBoolean, optionalString } from "../../engine/pull/context.js";
|
|
10
|
-
import {
|
|
10
|
+
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
11
11
|
import { accessPolicyBlocksInLabelOrder, accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
12
12
|
import { dashboardsFromTf } from "../dashboard/from-tf.js";
|
|
13
13
|
import { dynamicLayoutCompanionWidgetLabels, dynamicLayoutsFromTf } from "../dynamic-layout/from-tf.js";
|
|
14
|
-
import {
|
|
14
|
+
import { fieldsFromTf } from "../field/from-tf.js";
|
|
15
15
|
import { recordCreateFormFromTf } from "../record-create-form/from-tf.js";
|
|
16
16
|
import { relationshipsFromTf } from "../relationship/from-tf.js";
|
|
17
17
|
import { rolesFromTf } from "../role/from-tf.js";
|
|
18
18
|
import { fieldKeysByDisplayName, viewsFromTf } from "../view/from-tf.js";
|
|
19
19
|
import { widgetsFromTf } from "../widget/from-tf.js";
|
|
20
20
|
import { ELEMENT_RESOURCE_TYPE } from "./module.js";
|
|
21
|
-
import { ELEMENT_SYSTEM_FIELD_KEYS } from "./system-fields.js";
|
|
22
21
|
/** Attributes `elementFromTf` understands — anything else is dialect growth. */
|
|
23
22
|
const KNOWN_ELEMENT_ATTRS = new Set([
|
|
24
23
|
"name",
|
|
@@ -140,23 +139,8 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
140
139
|
fields.push(systemEntry("id", idName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.id, "TEXT", "HANDLE", idFieldDescription));
|
|
141
140
|
}
|
|
142
141
|
const owner = { type: ELEMENT_RESOURCE_TYPE, label, scope: "element", refName };
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const reservedBlocks = [];
|
|
146
|
-
const elementReserved = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
|
|
147
|
-
for (const block of fieldBlocks) {
|
|
148
|
-
if (block.label === undefined) {
|
|
149
|
-
nonReservedBlocks.push(block);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const natural = scopedLabelToBagKey(label, block.label, "element");
|
|
153
|
-
(elementReserved.has(natural) ? reservedBlocks : nonReservedBlocks).push(block);
|
|
154
|
-
}
|
|
155
|
-
for (const block of [...nonReservedBlocks, ...reservedBlocks]) {
|
|
156
|
-
const entry = fieldFromTf(block, owner, ctx, usedFieldKeys);
|
|
157
|
-
if (entry !== undefined)
|
|
158
|
-
fields.push(entry);
|
|
159
|
-
}
|
|
142
|
+
// Custom fields in the live field order, keys claimed two-pass (#1871 B1, edk#2920).
|
|
143
|
+
fields.push(...fieldsFromTf(fieldBlocks, owner, ctx));
|
|
160
144
|
const elementId = ctx.importId(`${ELEMENT_RESOURCE_TYPE}.${label}`);
|
|
161
145
|
if (elementId === undefined) {
|
|
162
146
|
ctx.diagnostics.push(`element "${label}": no import block in the stream — adoption has no identity to bind`);
|
|
@@ -164,7 +148,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
164
148
|
const unextractedFieldIds = new Set();
|
|
165
149
|
const fieldKeys = new Set(fields.map((field) => field.key));
|
|
166
150
|
const fieldKeysByName = fieldKeysByDisplayName(fields);
|
|
167
|
-
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "element", ownerType: "ELEMENT_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx);
|
|
151
|
+
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "element", ownerType: "ELEMENT_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx, viewBlocks.dashboardWidgetOrderBlocks);
|
|
168
152
|
// Every field reference pull writes keeps an unextracted field as its platform id (#1736, #1966).
|
|
169
153
|
const unextracted = { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element", fieldKeys, fieldKeysByName, unextractedFieldIds };
|
|
170
154
|
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, customViews, viewOrder, deleteDefaultListView } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, unextracted, ctx, viewBlocks.customViewBlocks);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* field/print internals genuinely shared between both aspect kinds).
|
|
7
7
|
*/
|
|
8
8
|
export { element, type ElementCloudConnection, type ElementConfigured, type ElementCustomView, type ElementRef, type ElementSystemFields, type ElementV2Options, } from "./build.js";
|
|
9
|
-
export { type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, } from "../view/agent-view-layout.js";
|
|
9
|
+
export { type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, type ViewBlocksStateValue, } from "../view/agent-view-layout.js";
|
|
10
10
|
export { type AppRecordCreateForm, type AppRecordCreateFormSection } from "../app/build.js";
|
|
11
11
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, type ListViewDensity, type ManagedViewSort, type ManagedViewSortAggregation, type ManagedViewSortDirection, type ManagedViewSortField, type ManagedViewSortOrder, } from "../view/build.js";
|
|
12
12
|
export { type AppRelationship, type AppRelationshipColumn } from "../relationship/build.js";
|
|
@@ -32,6 +32,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
32
32
|
const relationshipBlocks = stream.byKind.get("relationship") ?? [];
|
|
33
33
|
const dashboardBlocks = stream.byKind.get("dashboard") ?? [];
|
|
34
34
|
const dashboardWidgetBlocks = stream.byKind.get("dashboard-widget") ?? [];
|
|
35
|
+
const dashboardWidgetOrderBlocks = stream.byKind.get("dashboard-widget-order") ?? [];
|
|
35
36
|
const widgetBlocks = stream.byKind.get("widget") ?? [];
|
|
36
37
|
const accessPolicyBlocks = stream.byKind.get("access-policy") ?? [];
|
|
37
38
|
const roleBlocks = stream.byKind.get("role") ?? [];
|
|
@@ -48,6 +49,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
48
49
|
relationshipBlocks,
|
|
49
50
|
dashboardBlocks,
|
|
50
51
|
dashboardWidgetBlocks,
|
|
52
|
+
dashboardWidgetOrderBlocks,
|
|
51
53
|
widgetBlocks,
|
|
52
54
|
}, accessPolicyBlocks, roleBlocks);
|
|
53
55
|
// Automations are extracted separately, but their trigger outputs are the
|
|
@@ -249,6 +249,7 @@ export function elementToTf(entity, ctx) {
|
|
|
249
249
|
fieldAddresses,
|
|
250
250
|
fieldNames,
|
|
251
251
|
fieldMetadata,
|
|
252
|
+
ownerAuditFields: payload.auditFields === true,
|
|
252
253
|
widgets: widgets.widgets,
|
|
253
254
|
...(payload.deleteDefaultListView !== undefined ? { deleteDefaultListView: payload.deleteDefaultListView } : {}),
|
|
254
255
|
}, payload.customViews);
|
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
9
9
|
import { type FieldOwnerScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
10
10
|
import type { NormalizedField } from "../app/deserializer/normalize.js";
|
|
11
|
+
type ClaimContext = Pick<FromTfContext, "resourcesOfType">;
|
|
12
|
+
/**
|
|
13
|
+
* Bag key of an owner's custom field, by its Terraform label, as pull keys it
|
|
14
|
+
* (#1871, edk#2933). Every same-owner reference to a field (dropdown parents,
|
|
15
|
+
* dynamic configs, views, layouts, relationships, widgets, approval chains,
|
|
16
|
+
* access policies, tools) resolves through this, so a reference names the
|
|
17
|
+
* key the field itself was printed under. Without a context that lists the
|
|
18
|
+
* stream, a reserved natural falls back to `<key>Custom`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function pulledFieldBagKey(ownerTfLabel: string, fieldLabel: string, scope: FieldOwnerScope, ctx?: ClaimContext): string;
|
|
11
21
|
/**
|
|
12
22
|
* Bag key for a pulled custom field resource. A key that matches a reserved
|
|
13
23
|
* system-field key is rewritten to `<key>Custom` so pulled source builds
|
|
@@ -59,19 +69,31 @@ export type FieldBlockOwner = "own" | "foreign" | "unresolved";
|
|
|
59
69
|
* literal string, or absent from the owner's block.
|
|
60
70
|
*/
|
|
61
71
|
export declare function fieldBlockOwner(objectId: TfValue | undefined, owner: Pick<FieldOwner, "type" | "label">, ctx: FromTfContext, ownerId: string | undefined): FieldBlockOwner;
|
|
72
|
+
/**
|
|
73
|
+
* An owner's field blocks → their normalized entries, in the blocks' (live
|
|
74
|
+
* field) order. Keys are claimed up front over every field the owner owns
|
|
75
|
+
* (two passes, #1871 B1; see {@link claimFieldBagKeys}) and recorded on the
|
|
76
|
+
* context before any field is extracted, so a reference from one field to
|
|
77
|
+
* another (a dependent dropdown's parent, a dynamic config) and every later
|
|
78
|
+
* same-owner reference resolve to the key the field prints under. Fields
|
|
79
|
+
* print in the live order, not the claim order: a re-keyed field moved last
|
|
80
|
+
* would reorder the live fields on the next apply (edk#2920). Apps, elements
|
|
81
|
+
* and standalone tasks all extract fields here (edk#2933).
|
|
82
|
+
*/
|
|
83
|
+
export declare function fieldsFromTf(fieldBlocks: readonly TfBlock[], owner: FieldOwner, ctx: FromTfContext): NormalizedField[];
|
|
62
84
|
/**
|
|
63
85
|
* One field block → its normalized entry; undefined = skipped with a
|
|
64
86
|
* diagnostic (unknown resource type, or a field belonging to a different
|
|
65
87
|
* owner — a recursive stream carries discovered aspects' fields too).
|
|
66
88
|
*/
|
|
67
|
-
export declare function fieldFromTf(block: TfBlock, owner: FieldOwner, ctx: FromTfContext
|
|
89
|
+
export declare function fieldFromTf(block: TfBlock, owner: FieldOwner, ctx: FromTfContext): NormalizedField | undefined;
|
|
68
90
|
/**
|
|
69
91
|
* `<resourceType>.<tfLabel>.id` → the field's bag key — shared by anything
|
|
70
92
|
* that names a field by ref rather than owning it directly (agent-tool
|
|
71
93
|
* fields, view field_ids/columns). Undefined for any other shape or an
|
|
72
94
|
* unknown resource type.
|
|
73
95
|
*/
|
|
74
|
-
export declare function fieldKeyFromTfRef(v: TfValue, ownerTfLabel?: string, scope?: FieldOwnerScope): string | undefined;
|
|
96
|
+
export declare function fieldKeyFromTfRef(v: TfValue, ownerTfLabel?: string, scope?: FieldOwnerScope, ctx?: ClaimContext): string | undefined;
|
|
75
97
|
/**
|
|
76
98
|
* Resolve either a normal Terraform field reference or a raw platform field
|
|
77
99
|
* ID recovered from post-adoption state. The owner check prevents a UUID from
|
|
@@ -114,3 +136,4 @@ export declare function fieldKeyFromForeignDataLabel(dataLabel: string, target:
|
|
|
114
136
|
readonly kind?: string;
|
|
115
137
|
readonly ownerDataLabel?: string;
|
|
116
138
|
}): string | undefined;
|
|
139
|
+
export {};
|