@elementumai/edk 0.10.4 → 0.12.0
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 +49 -13
- package/dist-sdk/src/catalog/token.js +2 -1
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
- package/dist-sdk/src/core/triggers/on-demand.js +3 -0
- package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +7 -0
- package/dist-sdk/src/engine/coverage-gaps.js +12 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
- package/dist-sdk/src/engine/ei/run.d.ts +42 -1
- package/dist-sdk/src/engine/ei/run.js +201 -32
- package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
- package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
- package/dist-sdk/src/engine/ei/state.d.ts +1 -1
- package/dist-sdk/src/engine/ei/state.js +17 -4
- package/dist-sdk/src/engine/progress.d.ts +3 -1
- package/dist-sdk/src/engine/progress.js +7 -3
- package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
- package/dist-sdk/src/engine/pull/authored-address.js +180 -29
- package/dist-sdk/src/engine/pull/context.d.ts +37 -2
- package/dist-sdk/src/engine/pull/context.js +7 -4
- package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
- package/dist-sdk/src/engine/pull/ref-only.js +52 -0
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
- package/dist-sdk/src/engine/tf/labels.js +50 -0
- package/dist-sdk/src/engine/tf/model.d.ts +2 -0
- package/dist-sdk/src/engine/tf/model.js +26 -0
- package/dist-sdk/src/engine/validation.d.ts +2 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +18 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +58 -24
- package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
- package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
- package/dist-sdk/src/entities/access-policy/module.js +10 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
- package/dist-sdk/src/entities/agent/build.js +7 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +13 -3
- package/dist-sdk/src/entities/agent/to-tf.js +11 -5
- package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
- package/dist-sdk/src/entities/agent/tools.js +6 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
- package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
- package/dist-sdk/src/entities/agent-tool/types.js +13 -9
- package/dist-sdk/src/entities/app/build.d.ts +12 -1
- package/dist-sdk/src/entities/app/build.js +80 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
- package/dist-sdk/src/entities/app/from-tf.js +17 -12
- package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
- package/dist-sdk/src/entities/app/stage-keys.js +40 -6
- package/dist-sdk/src/entities/app/to-tf.js +7 -4
- package/dist-sdk/src/entities/automation/build.d.ts +52 -31
- package/dist-sdk/src/entities/automation/build.js +59 -20
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +39 -14
- package/dist-sdk/src/entities/automation/from-tf.d.ts +35 -2
- package/dist-sdk/src/entities/automation/from-tf.js +721 -93
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +22 -2
- package/dist-sdk/src/entities/automation/module.js +244 -57
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
- package/dist-sdk/src/entities/automation/run-target.d.ts +61 -0
- package/dist-sdk/src/entities/automation/run-target.js +104 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +11 -1
- package/dist-sdk/src/entities/automation/script-code.js +106 -4
- package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
- package/dist-sdk/src/entities/automation/script-lint.js +418 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -1
- package/dist-sdk/src/entities/automation/task-output-labels.js +58 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +67 -22
- package/dist-sdk/src/entities/automation/tasks.js +18 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
- package/dist-sdk/src/entities/automation/to-tf.js +354 -64
- package/dist-sdk/src/entities/automation/triggers.d.ts +63 -11
- package/dist-sdk/src/entities/automation/triggers.js +45 -5
- package/dist-sdk/src/entities/automation/types.d.ts +21 -0
- package/dist-sdk/src/entities/automation/types.js +26 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +25 -1
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/printer.js +5 -2
- package/dist-sdk/src/entities/chart/to-tf.js +19 -1
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +8 -2
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +66 -20
- package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
- package/dist-sdk/src/entities/element/build.d.ts +10 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +14 -9
- package/dist-sdk/src/entities/element/to-tf.js +7 -4
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +79 -1
- package/dist-sdk/src/entities/field/module.js +14 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +38 -3
- package/dist-sdk/src/entities/field/to-tf.js +108 -34
- package/dist-sdk/src/entities/file-reader/module.js +3 -3
- package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
- package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
- package/dist-sdk/src/entities/file-reader/types.js +7 -0
- package/dist-sdk/src/entities/org/group.d.ts +1 -0
- package/dist-sdk/src/entities/org/group.js +2 -1
- package/dist-sdk/src/entities/org/role.js +5 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
- package/dist-sdk/src/entities/role/from-tf.js +24 -7
- package/dist-sdk/src/entities/role/to-tf.js +25 -7
- package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
- package/dist-sdk/src/entities/service-account/module.js +20 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
- package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
- package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
- package/dist-sdk/src/entities/skill/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill/module.js +18 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/skill/to-tf.js +23 -14
- package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
- package/dist-sdk/src/entities/task/to-tf.js +1 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
- package/dist-sdk/src/entities/view/from-tf.d.ts +68 -4
- package/dist-sdk/src/entities/view/from-tf.js +394 -22
- package/dist-sdk/src/entities/view/module.js +20 -0
- package/dist-sdk/src/entities/view/portable.d.ts +11 -0
- package/dist-sdk/src/entities/view/portable.js +47 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
- package/dist-sdk/src/entities/view/to-tf.js +25 -7
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +4 -3
- package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/widget/from-tf.js +100 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
- package/dist-sdk/src/entities/widget/to-tf.js +77 -14
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +30 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/field-resource-types.js +11 -0
- package/dist-sdk/src/graph/index.d.ts +41 -3
- package/dist-sdk/src/graph/index.js +24 -2
- package/dist-sdk/src/graph/types.d.ts +195 -5
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { asNamedRef, namedFactoryEntry } from "../../catalog/render-helpers.js";
|
|
3
3
|
import { NO_CANVAS, NO_CATALOG, NO_DATA, NO_LIFECYCLE, } from "../../graph/types.js";
|
|
4
4
|
import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, PLATFORM_DEFAULT_LIST_VIEW_NAME, VIEW_DATA_RESOURCE_TYPE, } from "./types.js";
|
|
5
|
+
import { selectPlatformDefaultViews } from "./portable.js";
|
|
5
6
|
/**
|
|
6
7
|
* Layouts + list views are stream members folded into the app authoring file
|
|
7
8
|
* (inline), extracted by `appFromTf` — not own-file kinds.
|
|
@@ -55,6 +56,16 @@ export const viewModule = {
|
|
|
55
56
|
stubRef: (refName, parent) => ({ __kind: "view", refName, name: refName, parent }),
|
|
56
57
|
refFromAuthoring: () => undefined,
|
|
57
58
|
},
|
|
59
|
+
roundtrip: {
|
|
60
|
+
referenceAliases: [],
|
|
61
|
+
// Provider set attributes (edk#2437): view sharing order carries no meaning.
|
|
62
|
+
unorderedListAttributes: ["user_ids", "group_ids"],
|
|
63
|
+
},
|
|
64
|
+
portable: {
|
|
65
|
+
leaveOut: [
|
|
66
|
+
{ resourceType: LIST_VIEW_RESOURCE_TYPE, select: selectPlatformDefaultViews, reason: "the platform creates it with its app or element" },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
58
69
|
};
|
|
59
70
|
/**
|
|
60
71
|
* `elementum_managed_view_order` is a singleton per aspect with no identity
|
|
@@ -80,9 +91,18 @@ export const managedViewOrderModule = {
|
|
|
80
91
|
// The provider leaves the platform's default "List" view out of an order
|
|
81
92
|
// whose state doesn't list it (#1598); the export always lists it (#1658).
|
|
82
93
|
stateScopedPlatformEntries: [{ attribute: "view_ids", name: PLATFORM_DEFAULT_LIST_VIEW_NAME }],
|
|
94
|
+
// The platform has no record of the request to delete its default "List"
|
|
95
|
+
// view, so the export never carries it. A re-pull fills it from state only
|
|
96
|
+
// while it is `true` (set in source); omitted means `false` and is not
|
|
97
|
+
// printed. A fresh adopt has no state, so it drops from source (#1773).
|
|
98
|
+
unreadableAttributes: ["delete_platform_default_list_view"],
|
|
83
99
|
},
|
|
84
100
|
data: NO_DATA,
|
|
85
101
|
lifecycle: NO_LIFECYCLE,
|
|
86
102
|
canvas: NO_CANVAS,
|
|
87
103
|
catalog: NO_CATALOG,
|
|
104
|
+
// Build writes no order when the owner has no authored views.
|
|
105
|
+
portable: {
|
|
106
|
+
leaveOutWhenEmptied: [{ resourceType: MANAGED_VIEW_ORDER_RESOURCE_TYPE, attribute: "view_ids", reason: "it only ordered the left-out view" }],
|
|
107
|
+
},
|
|
88
108
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--portable`: which exported list view is the one the platform made with its
|
|
3
|
+
* app or element (edk#1894). `ei apps export` / `ei elements export` name it in
|
|
4
|
+
* {@link PLATFORM_DEFAULT_VIEWS_FILE}: the owner's first-created view when it
|
|
5
|
+
* is named "List" (cmd/elementum/export/platform_default_views.go).
|
|
6
|
+
*/
|
|
7
|
+
import type { PortableSelection } from "../../graph/types.js";
|
|
8
|
+
import type { TfBlock } from "../../engine/tf/index.js";
|
|
9
|
+
export declare const PLATFORM_DEFAULT_VIEWS_FILE = "platform-default-views.json";
|
|
10
|
+
/** The export's platform-made "List" views, matched by their `<owner id>:<view id>` import id. */
|
|
11
|
+
export declare function selectPlatformDefaultViews(exportDir: string, blocks: readonly TfBlock[]): Promise<PortableSelection>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--portable`: which exported list view is the one the platform made with its
|
|
3
|
+
* app or element (edk#1894). `ei apps export` / `ei elements export` name it in
|
|
4
|
+
* {@link PLATFORM_DEFAULT_VIEWS_FILE}: the owner's first-created view when it
|
|
5
|
+
* is named "List" (cmd/elementum/export/platform_default_views.go).
|
|
6
|
+
*/
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
export const PLATFORM_DEFAULT_VIEWS_FILE = "platform-default-views.json";
|
|
10
|
+
/** The export's platform-made "List" views, matched by their `<owner id>:<view id>` import id. */
|
|
11
|
+
export async function selectPlatformDefaultViews(exportDir, blocks) {
|
|
12
|
+
const path = join(exportDir, PLATFORM_DEFAULT_VIEWS_FILE);
|
|
13
|
+
let raw;
|
|
14
|
+
try {
|
|
15
|
+
raw = await readFile(path, "utf8");
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error.code !== "ENOENT")
|
|
19
|
+
throw error;
|
|
20
|
+
// Every current bridge writes the file for an app or element export.
|
|
21
|
+
const unresolved = blocks.length > 0
|
|
22
|
+
? [`the export has no ${PLATFORM_DEFAULT_VIEWS_FILE} (bridge older than edk#1894?), so the platform's "List" view could not be told apart and was kept`]
|
|
23
|
+
: [];
|
|
24
|
+
return { matches: () => false, unresolved };
|
|
25
|
+
}
|
|
26
|
+
let entries;
|
|
27
|
+
try {
|
|
28
|
+
entries = JSON.parse(raw);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new Error(`${path} is not valid JSON: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
if (!Array.isArray(entries))
|
|
34
|
+
throw new Error(`${path} must hold a list of { ownerId, viewId } entries`);
|
|
35
|
+
const ids = new Set();
|
|
36
|
+
const unresolved = [];
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const { ownerId, viewId, undetermined } = entry;
|
|
39
|
+
if (undetermined === true) {
|
|
40
|
+
unresolved.push(`the platform's "List" view of ${String(ownerId)} could not be told apart (a view has no readable creation time), so it was kept`);
|
|
41
|
+
}
|
|
42
|
+
else if (typeof ownerId === "string" && typeof viewId === "string") {
|
|
43
|
+
ids.add(`${ownerId}:${viewId}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { matches: (importId) => importId !== undefined && ids.has(importId), unresolved };
|
|
47
|
+
}
|
|
@@ -16,6 +16,7 @@ import type { ManagedViewSharing } from "./sharing.js";
|
|
|
16
16
|
import type { ListViewDensity, ManagedViewSort } from "./build.js";
|
|
17
17
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
18
18
|
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
19
|
+
import { type BuiltWidgets } from "../widget/to-tf.js";
|
|
19
20
|
/** The authored field-ref shape post-`slimTokens`: a system key string, or a slimmed `FieldRef` token. */
|
|
20
21
|
export type ViewFieldRefWire = string | {
|
|
21
22
|
readonly __kind?: string;
|
|
@@ -133,7 +134,9 @@ export interface ViewToTfOptions {
|
|
|
133
134
|
/** Field bag key → metadata (custom-view tag / calc checks). */
|
|
134
135
|
readonly fieldMetadata?: ReadonlyMap<string, import("../../graph/types.js").BuildFieldMetadata>;
|
|
135
136
|
/** Declared sibling widget keys, for typed classic-layout placement. */
|
|
136
|
-
readonly
|
|
137
|
+
readonly widgets?: BuiltWidgets;
|
|
138
|
+
/** Delete the platform's default "List" view when the order is applied (#1773). */
|
|
139
|
+
readonly deleteDefaultListView?: boolean;
|
|
137
140
|
/** Degradations land here — reported by the caller, never silent. */
|
|
138
141
|
readonly diagnostics: string[];
|
|
139
142
|
}
|
|
@@ -14,13 +14,15 @@ import { expr, isCanonicalTsLabel, scopedResourceLabel, tsLabelToTfLabel, } from
|
|
|
14
14
|
import { fieldRefToTfValue as customFieldRefToTfValue } from "../field/to-tf.js";
|
|
15
15
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
16
16
|
import { filterToTf, principalListToTf } from "../access-policy/to-tf.js";
|
|
17
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
17
18
|
import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
|
|
18
19
|
import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
|
|
19
20
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
21
|
+
import { unbuiltWidgetReferenceNote } from "../widget/to-tf.js";
|
|
20
22
|
import { AGENT_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, PLATFORM_DEFAULT_LIST_VIEW_NAME, SECTION_TYPE_TO_WIRE, SYSTEM_FIELD_ID_ATTR_BY_KEY, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
|
|
21
23
|
function appendViewSharingAttrs(attrs, view, where, ctx) {
|
|
22
|
-
const userIds = principalListToTf(view.userIds, "elementum_user", `${where}.userIds`, ctx);
|
|
23
|
-
const groupIds = principalListToTf(view.groupIds, "elementum_group", `${where}.groupIds`, ctx);
|
|
24
|
+
const userIds = principalListToTf(view.userIds, "elementum_user", `${where}.userIds`, ctx, "viewShare");
|
|
25
|
+
const groupIds = principalListToTf(view.groupIds, "elementum_group", `${where}.groupIds`, ctx, "viewShare");
|
|
24
26
|
if (view.userIds !== undefined) {
|
|
25
27
|
if (view.userIds.length === 0)
|
|
26
28
|
attrs["user_ids"] = [];
|
|
@@ -49,7 +51,16 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
49
51
|
diagnostics.push(`layouts.${stageKey} has no matching authored stage option; dropped`);
|
|
50
52
|
continue;
|
|
51
53
|
}
|
|
52
|
-
blocks.push(layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectId, diagnostics, fieldAddresses, opts.
|
|
54
|
+
blocks.push(layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectId, diagnostics, fieldAddresses, opts.widgets, opts.stageKeyByTfLabel?.get(stageTfLabel)));
|
|
55
|
+
}
|
|
56
|
+
if (opts.deleteDefaultListView === true) {
|
|
57
|
+
const named = [listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews]
|
|
58
|
+
.flatMap((bag) => Object.entries(bag ?? {}))
|
|
59
|
+
.filter(([, view]) => view.name === PLATFORM_DEFAULT_LIST_VIEW_NAME)
|
|
60
|
+
.map(([key]) => key);
|
|
61
|
+
if (named.length > 0) {
|
|
62
|
+
throw new EntityTfError(`${ownerRefName}: deleteDefaultListView deletes the platform's "${PLATFORM_DEFAULT_LIST_VIEW_NAME}" view, but view ${named.map((k) => `"${k}"`).join(", ")} is named "${PLATFORM_DEFAULT_LIST_VIEW_NAME}". Rename or remove that view, or drop deleteDefaultListView.`);
|
|
63
|
+
}
|
|
53
64
|
}
|
|
54
65
|
const viewAddressByKey = new Map();
|
|
55
66
|
for (const [viewKey, view] of Object.entries(listViews ?? {})) {
|
|
@@ -281,6 +292,9 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
281
292
|
blocks.push({ kind: "resource", type: CUSTOM_VIEW_RESOURCE_TYPE, label: tfLabel, attrs });
|
|
282
293
|
viewAddressByKey.set(viewKey, { type: CUSTOM_VIEW_RESOURCE_TYPE, label: tfLabel });
|
|
283
294
|
}
|
|
295
|
+
if (opts.deleteDefaultListView === true && viewAddressByKey.size === 0) {
|
|
296
|
+
throw new EntityTfError(`${ownerRefName}: deleteDefaultListView needs at least one declared view; without one there is no view order to apply and the "${PLATFORM_DEFAULT_LIST_VIEW_NAME}" view would stay.`);
|
|
297
|
+
}
|
|
284
298
|
if (viewAddressByKey.size > 0) {
|
|
285
299
|
const orderKeys = viewOrder ?? [
|
|
286
300
|
...Object.keys(listViews ?? {}),
|
|
@@ -325,7 +339,11 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
325
339
|
// No name of its own: labelled from the owner's namespace, like the record
|
|
326
340
|
// create form, so renaming the app or element keeps its address.
|
|
327
341
|
label: scopedResourceLabel(ownerTfLabel, "view_order", scope),
|
|
328
|
-
attrs: {
|
|
342
|
+
attrs: {
|
|
343
|
+
object_id: objectId,
|
|
344
|
+
view_ids: viewIds,
|
|
345
|
+
...(opts.deleteDefaultListView !== undefined ? { delete_platform_default_list_view: opts.deleteDefaultListView } : {}),
|
|
346
|
+
},
|
|
329
347
|
});
|
|
330
348
|
}
|
|
331
349
|
}
|
|
@@ -345,7 +363,7 @@ export function managedViewSortToTf(sort, ownerTfLabel, scope, where, diagnostic
|
|
|
345
363
|
}
|
|
346
364
|
return expr.jsonencode({ orders });
|
|
347
365
|
}
|
|
348
|
-
function layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectId, diagnostics, fieldAddresses,
|
|
366
|
+
function layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectId, diagnostics, fieldAddresses, widgets, stageIdKey) {
|
|
349
367
|
const sections = [];
|
|
350
368
|
for (const section of layout.sections) {
|
|
351
369
|
const authoringType = section.type ?? "group";
|
|
@@ -410,8 +428,8 @@ function layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectI
|
|
|
410
428
|
diagnostics.push(`${widgetWhere}: widget belongs to ${JSON.stringify(widget.parent)}, not ${JSON.stringify(ownerRefName)}; dropped`);
|
|
411
429
|
continue;
|
|
412
430
|
}
|
|
413
|
-
if (!
|
|
414
|
-
diagnostics.push(
|
|
431
|
+
if (!widgets?.built.has(key)) {
|
|
432
|
+
diagnostics.push(unbuiltWidgetReferenceNote(widgetWhere, key, scope, ownerRefName, widgets));
|
|
415
433
|
continue;
|
|
416
434
|
}
|
|
417
435
|
const widgetId = expr.resourceAttr(WIDGET_RESOURCE_TYPE, scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(key), scope), ["id"]);
|
|
@@ -140,4 +140,4 @@ export const KNOWN_DASHBOARD_VIEW_ATTRS = new Set([
|
|
|
140
140
|
"display_order",
|
|
141
141
|
]);
|
|
142
142
|
/** Attributes `managedViewOrderFromTf` understands. */
|
|
143
|
-
export const KNOWN_MANAGED_VIEW_ORDER_ATTRS = new Set(["object_id", "view_ids"]);
|
|
143
|
+
export const KNOWN_MANAGED_VIEW_ORDER_ATTRS = new Set(["object_id", "view_ids", "delete_platform_default_list_view"]);
|
|
@@ -99,9 +99,10 @@ export interface RunAutomationWidget extends WidgetButtonStyle {
|
|
|
99
99
|
readonly type: "runAutomation";
|
|
100
100
|
readonly name: string;
|
|
101
101
|
/**
|
|
102
|
-
* The automation this button runs.
|
|
103
|
-
*
|
|
104
|
-
*
|
|
102
|
+
* The automation this button runs. When the automation is not an authored
|
|
103
|
+
* file in this workspace, build looks it up by `name`, its display name.
|
|
104
|
+
* `displayName` is accepted for sources pulled before edk#1894 and wins
|
|
105
|
+
* when set; pull no longer prints it.
|
|
105
106
|
*/
|
|
106
107
|
readonly automation: AutomationRef & {
|
|
107
108
|
readonly displayName?: string;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
2
|
import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
|
|
3
3
|
import type { NormalizedWidget } from "../app/deserializer/normalize.js";
|
|
4
|
+
import { type UnextractedFieldOwner } from "../view/from-tf.js";
|
|
4
5
|
export interface WidgetOwner {
|
|
5
6
|
readonly type: "elementum_app" | "elementum_element";
|
|
6
7
|
readonly label: string;
|
|
7
8
|
readonly ownerRefName: string;
|
|
8
9
|
readonly ownerTfLabel: string;
|
|
9
10
|
readonly scope: ChildResourceScope;
|
|
11
|
+
/** The owner's extracted fields, so a field pull did not extract keeps its platform id (#1966). */
|
|
12
|
+
readonly unextracted?: UnextractedFieldOwner;
|
|
10
13
|
}
|
|
11
14
|
export declare function widgetsFromTf(blocks: readonly TfBlock[], owner: WidgetOwner, ctx: FromTfContext, dynamicLayoutCompanionLabels?: ReadonlySet<string>): NormalizedWidget[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
1
2
|
import { dataRefLabel, optionalBoolean, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
3
|
import { bareChildResourceLabel, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
3
4
|
import { AUTOMATION_RESOURCE_TYPE } from "../automation/types.js";
|
|
@@ -6,6 +7,7 @@ import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
|
6
7
|
import { WIDGET_RESOURCE_TYPE } from "./module.js";
|
|
7
8
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
8
9
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
10
|
+
import { bareForeignFieldIdRef, isBarePlatformId, isUnextractedFieldKey, resolveOwnDataFieldRef, unextractedFieldRefId } from "../view/from-tf.js";
|
|
9
11
|
const KNOWN_ROOT_ATTRS = new Set(["object_id", "related_object", "related_link_action", "related_create_action", "run_automation_action"]);
|
|
10
12
|
export function widgetsFromTf(blocks, owner, ctx, dynamicLayoutCompanionLabels = new Set()) {
|
|
11
13
|
const out = [];
|
|
@@ -101,6 +103,9 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
|
|
|
101
103
|
ctx.diagnostics.push(`${where}.run_automation_action: automation_id is not resolvable; skipped`);
|
|
102
104
|
return undefined;
|
|
103
105
|
}
|
|
106
|
+
const droppedGap = typeof automation === "string" ? droppedAutomationGap(key, automation, owner, ctx) : undefined;
|
|
107
|
+
if (droppedGap !== undefined)
|
|
108
|
+
ctx.diagnostics.push(droppedGap);
|
|
104
109
|
const parametersRaw = body["parameters"];
|
|
105
110
|
const parameters = Array.isArray(parametersRaw)
|
|
106
111
|
? parametersRaw.flatMap((raw, index) => {
|
|
@@ -109,7 +114,7 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
|
|
|
109
114
|
return [];
|
|
110
115
|
}
|
|
111
116
|
const rec = raw;
|
|
112
|
-
const field = ownerFieldRef(rec["field_id"], owner, ctx);
|
|
117
|
+
const field = keepUnextractedOwnerField(rec["field_id"], ownerFieldRef(rec["field_id"], owner, ctx), owner, ctx, `${where}.run_automation_action.parameters[${index}].field_id`);
|
|
113
118
|
return [{
|
|
114
119
|
name: typeof rec["name"] === "string" ? rec["name"] : "",
|
|
115
120
|
fieldType: typeof rec["field_type"] === "string" ? rec["field_type"] : "TEXT",
|
|
@@ -150,7 +155,7 @@ function columnsAndRows(attrs, target, owner, ctx, where) {
|
|
|
150
155
|
let columns;
|
|
151
156
|
if (Array.isArray(columnsRaw)) {
|
|
152
157
|
columns = columnsRaw.flatMap((value, index) => {
|
|
153
|
-
const decoded = widgetFieldRef(value, target, owner, ctx);
|
|
158
|
+
const decoded = keepUnextractedOwnerField(value, widgetFieldRef(value, target, owner, ctx), owner, ctx, `${where}.columns[${index}]`, target);
|
|
154
159
|
if (decoded === undefined) {
|
|
155
160
|
ctx.diagnostics.push(`${where}.columns[${index}]: field reference is not resolvable; dropped`);
|
|
156
161
|
return [];
|
|
@@ -266,6 +271,36 @@ function recordIdentityTarget(resourceType, target) {
|
|
|
266
271
|
const targetType = target.kind === "app" ? "elementum_app" : "elementum_element";
|
|
267
272
|
return resourceType === WIDGET_RESOURCE_TYPE || resourceType === targetType ? target : undefined;
|
|
268
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* A run-automation widget keeps a raw automation id as is. Pull warns, naming
|
|
276
|
+
* the widget and the automation, and continues (#1877) only when the
|
|
277
|
+
* automation is known to be dropped: the export listed it in
|
|
278
|
+
* omitted-automations.json (deleted, DISABLED, no draft, or unrepresentable),
|
|
279
|
+
* or wrote no id at all. Any other raw id is a valid reference to an automation this
|
|
280
|
+
* pull does not export, such as another app's, which build emits as is, so
|
|
281
|
+
* it stays silent. Unlike an unextracted field reference (#1978), a dropped
|
|
282
|
+
* automation does not fail the pull.
|
|
283
|
+
*/
|
|
284
|
+
function droppedAutomationGap(widgetKey, automationId, owner, ctx) {
|
|
285
|
+
const entity = `widget ${JSON.stringify(widgetKey)} (${owner.ownerRefName})`;
|
|
286
|
+
if (automationId === "") {
|
|
287
|
+
return typedCoverageGap({
|
|
288
|
+
kind: "degraded",
|
|
289
|
+
entity,
|
|
290
|
+
detail: "its run-automation button has no automation id in the export",
|
|
291
|
+
consequence: "the widget is pulled with an empty automation id, so the button has nothing to run. Choose its automation in the platform and pull again, or remove the widget",
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
const omitted = ctx.omittedAutomationsById?.get(automationId);
|
|
295
|
+
if (omitted === undefined)
|
|
296
|
+
return undefined;
|
|
297
|
+
return typedCoverageGap({
|
|
298
|
+
kind: "degraded",
|
|
299
|
+
entity,
|
|
300
|
+
detail: `its run-automation button runs automation ${JSON.stringify(omitted.name)} (${automationId}), which the export left out: ${omitted.reason}`,
|
|
301
|
+
consequence: "the widget is pulled with the automation's raw platform id, and the EDK does not manage that automation; if it was deleted, the button cannot run. Fix or restore the automation in the platform and pull again, or remove the widget",
|
|
302
|
+
});
|
|
303
|
+
}
|
|
269
304
|
function automationRef(value, owner, ctx) {
|
|
270
305
|
if (typeof value === "string")
|
|
271
306
|
return value;
|
|
@@ -279,11 +314,11 @@ function automationRef(value, owner, ctx) {
|
|
|
279
314
|
// platform-managed, so it is not in source.
|
|
280
315
|
const exportedName = ctx.resourceByAddress?.(`${AUTOMATION_RESOURCE_TYPE}.${label}`)?.attrs["name"];
|
|
281
316
|
const displayName = typeof exportedName === "string" && exportedName !== "" ? exportedName : undefined;
|
|
317
|
+
// Like every catalog ref: refName is the key, name the display name.
|
|
282
318
|
return {
|
|
283
319
|
kind: "automation",
|
|
284
320
|
key,
|
|
285
321
|
name: displayName ?? key,
|
|
286
|
-
...(displayName !== undefined ? { displayName } : {}),
|
|
287
322
|
parent: owner.ownerRefName,
|
|
288
323
|
};
|
|
289
324
|
}
|
|
@@ -295,6 +330,68 @@ function ownerFieldRef(value, owner, ctx) {
|
|
|
295
330
|
const key = fieldKeyFromTfRef(value, owner.ownerTfLabel, owner.scope);
|
|
296
331
|
return key === undefined ? undefined : { kind: "field", key, name: key, parent: owner.ownerRefName, fieldType: "TEXT" };
|
|
297
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* An owner field reference whose field pull did not extract becomes the
|
|
335
|
+
* field's platform id, which build emits as is (#1966). Its key would build
|
|
336
|
+
* a reference to a field resource that is not in source, which breaks plan.
|
|
337
|
+
* With no id the pull fails with an authoring blocker naming the site
|
|
338
|
+
* (#1978).
|
|
339
|
+
*/
|
|
340
|
+
function keepUnextractedOwnerField(value, decoded, owner, ctx, site, columnsTarget) {
|
|
341
|
+
if (value === undefined || owner.unextracted === undefined || decoded === undefined)
|
|
342
|
+
return decoded;
|
|
343
|
+
if (typeof decoded === "string") {
|
|
344
|
+
if (ctx.cloning === undefined || decoded !== value || !isBarePlatformId(value))
|
|
345
|
+
return decoded;
|
|
346
|
+
// Clone: a raw id nothing resolved on the widget's own app is the source
|
|
347
|
+
// app's, so it fails naming the site unless an import shows another
|
|
348
|
+
// owner's field. A column of another app's or element's records is that
|
|
349
|
+
// target's field and keeps its id (#1991, Dax 11:45).
|
|
350
|
+
const foreignTarget = columnsTarget === undefined ? undefined : foreignWidgetTarget(columnsTarget, owner);
|
|
351
|
+
return foreignTarget === undefined
|
|
352
|
+
? unextractedFieldRefId(value, undefined, owner.unextracted, ctx, site)
|
|
353
|
+
: bareForeignFieldIdRef(value, owner.unextracted, ctx, site, foreignTarget);
|
|
354
|
+
}
|
|
355
|
+
if (decoded.kind !== "field" || decoded.parent !== owner.ownerRefName)
|
|
356
|
+
return decoded;
|
|
357
|
+
// An own-app data source decodes here with only the widget's refName, so
|
|
358
|
+
// ei's `elementum_app_<display name>_` label prefix stays on the key. Match
|
|
359
|
+
// it against the extracted fields the way views do: an extracted field
|
|
360
|
+
// keeps its real key, and one pull did not extract fails closed naming it
|
|
361
|
+
// (#1991).
|
|
362
|
+
const ownData = resolveOwnDataFieldRef(value, owner.unextracted, ctx, site);
|
|
363
|
+
if (ownData === "failedClosed")
|
|
364
|
+
return undefined;
|
|
365
|
+
if (ownData !== undefined) {
|
|
366
|
+
if (ownData.key === decoded.key)
|
|
367
|
+
return decoded;
|
|
368
|
+
// The decoded name came from the same unstripped label; use the data
|
|
369
|
+
// source's own name, else the key, as a resource reference would.
|
|
370
|
+
const dataLabel = dataRefLabel(value, "elementum_field");
|
|
371
|
+
return { ...decoded, key: ownData.key, name: (dataLabel === undefined ? undefined : ctx.dataName("elementum_field", dataLabel)) ?? ownData.key };
|
|
372
|
+
}
|
|
373
|
+
if (!isUnextractedFieldKey(decoded.key, owner.unextracted))
|
|
374
|
+
return decoded;
|
|
375
|
+
// A raw id the field registry does not know resolves through its import
|
|
376
|
+
// block, as in a view, so both report under one field address.
|
|
377
|
+
const registryKey = typeof value === "string" && ctx.foreignFieldRefsById?.get(value) === undefined ? undefined : decoded.key;
|
|
378
|
+
const ref = unextractedFieldRefId(value, registryKey, owner.unextracted, ctx, site);
|
|
379
|
+
// The guard above already knows this key is not extracted, so a key that
|
|
380
|
+
// comes back never means "keep the decoded ref". The resolver keeps an id,
|
|
381
|
+
// or fails closed with a blocker naming the site and the key, for every
|
|
382
|
+
// shape, a data source included (#1991).
|
|
383
|
+
return ref === registryKey ? undefined : ref;
|
|
384
|
+
}
|
|
385
|
+
/** How a widget's target reads in a diagnostic when it is not the widget's own app or element; undefined when it is. */
|
|
386
|
+
function foreignWidgetTarget(target, owner) {
|
|
387
|
+
if (typeof target === "string")
|
|
388
|
+
return `the widget's target ${target}`;
|
|
389
|
+
if (target.kind === owner.scope && target.key === owner.ownerRefName)
|
|
390
|
+
return undefined;
|
|
391
|
+
if (target.kind !== "app" && target.kind !== "element")
|
|
392
|
+
return undefined;
|
|
393
|
+
return `the widget's target ${target.kind} ${JSON.stringify(target.name || target.key)}`;
|
|
394
|
+
}
|
|
298
395
|
function fieldRefFromRawId(id, target, owner, ctx) {
|
|
299
396
|
if (id === "")
|
|
300
397
|
return undefined;
|
|
@@ -62,5 +62,20 @@ export interface WidgetsToTfOptions {
|
|
|
62
62
|
*/
|
|
63
63
|
readonly relationshipTargets?: readonly RelationshipTargetWire[];
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
/** Which authored widgets build declared, and which it skipped with a warning. */
|
|
66
|
+
export interface BuiltWidgets {
|
|
67
|
+
readonly built: ReadonlySet<string>;
|
|
68
|
+
readonly skipped: ReadonlySet<string>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The note for a layout reference to a widget build did not declare. A layout
|
|
72
|
+
* may reference only a built widget: a skipped widget's reference would be an
|
|
73
|
+
* undeclared resource, which fails plan (#1877), so the reference is dropped.
|
|
74
|
+
*/
|
|
75
|
+
export declare function unbuiltWidgetReferenceNote(where: string, key: string, scope: ChildResourceScope, ownerRefName: string, widgets: BuiltWidgets | undefined): string;
|
|
76
|
+
/** The widget resources, and which widgets they declare (see {@link unbuiltWidgetReferenceNote}). */
|
|
77
|
+
export declare function widgetsToTf(widgets: Readonly<Record<string, AppWidgetWire>> | undefined, opts: WidgetsToTfOptions): {
|
|
78
|
+
readonly blocks: TfBlock[];
|
|
79
|
+
readonly widgets: BuiltWidgets;
|
|
80
|
+
};
|
|
66
81
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
1
2
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
2
3
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
3
4
|
import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
4
5
|
import { AUTOMATION_RESOURCE_TYPE, automationResourceLabel } from "../automation/types.js";
|
|
5
6
|
import { fieldMetadataFromEntries } from "../field/metadata.js";
|
|
6
|
-
import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
|
|
7
|
+
import { authoredFieldKeysFromPayload, droppedEntryGap, fieldLookupName, fieldRefToTfValue, unauthoredSiblingFieldRef, UNRESOLVED_FIELD_REF, } from "../field/to-tf.js";
|
|
7
8
|
import { runAutomationParameterValue } from "./build.js";
|
|
8
9
|
import { WIDGET_RESOURCE_TYPE } from "./module.js";
|
|
9
10
|
import { filterToTf } from "../access-policy/to-tf.js";
|
|
@@ -13,8 +14,20 @@ export function relationshipTargetsFromBag(relationships) {
|
|
|
13
14
|
refName: relationship.target?.refName,
|
|
14
15
|
}));
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The note for a layout reference to a widget build did not declare. A layout
|
|
19
|
+
* may reference only a built widget: a skipped widget's reference would be an
|
|
20
|
+
* undeclared resource, which fails plan (#1877), so the reference is dropped.
|
|
21
|
+
*/
|
|
22
|
+
export function unbuiltWidgetReferenceNote(where, key, scope, ownerRefName, widgets) {
|
|
23
|
+
return widgets?.skipped.has(key) === true
|
|
24
|
+
? `${where}: build skipped widget ${JSON.stringify(key)} (${ownerRefName}) (see its warning), so the layout reference is dropped; if that widget is already managed, the next apply deletes it`
|
|
25
|
+
: `${where}: widget ${JSON.stringify(key)} is not declared in this ${scope}; dropped`;
|
|
26
|
+
}
|
|
27
|
+
/** The widget resources, and which widgets they declare (see {@link unbuiltWidgetReferenceNote}). */
|
|
16
28
|
export function widgetsToTf(widgets, opts) {
|
|
17
29
|
const blocks = [];
|
|
30
|
+
const builtKeys = new Set();
|
|
18
31
|
for (const [key, widget] of Object.entries(widgets ?? {})) {
|
|
19
32
|
const where = `widgets.${key}`;
|
|
20
33
|
if (!isCanonicalTsLabel(key)) {
|
|
@@ -73,7 +86,7 @@ export function widgetsToTf(widgets, opts) {
|
|
|
73
86
|
break;
|
|
74
87
|
}
|
|
75
88
|
case "runAutomation": {
|
|
76
|
-
const automationId = resolveAutomation(widget.automation, `${where}.automation`, opts);
|
|
89
|
+
const automationId = resolveAutomation(widget.automation, key, `${where}.automation`, opts);
|
|
77
90
|
if (automationId === undefined)
|
|
78
91
|
continue;
|
|
79
92
|
const body = buttonBody(widget);
|
|
@@ -94,8 +107,10 @@ export function widgetsToTf(widgets, opts) {
|
|
|
94
107
|
label: scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(key), opts.scope),
|
|
95
108
|
attrs,
|
|
96
109
|
});
|
|
110
|
+
builtKeys.add(key);
|
|
97
111
|
}
|
|
98
|
-
|
|
112
|
+
const skipped = new Set(Object.keys(widgets ?? {}).filter((key) => !builtKeys.has(key)));
|
|
113
|
+
return { blocks, widgets: { built: builtKeys, skipped } };
|
|
99
114
|
}
|
|
100
115
|
function diagnoseRelatedRecordsJoin(where, target, opts) {
|
|
101
116
|
if (target.refName === undefined || target.kind === undefined)
|
|
@@ -186,6 +201,29 @@ function resolveManagedSystemColumn(key, target) {
|
|
|
186
201
|
return undefined;
|
|
187
202
|
return fieldRefToTfValue("HANDLE", key, target.tfLabel, target.kind, target.fieldOwnership);
|
|
188
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* The aspect a column's field is built against. A resolved widget target wins.
|
|
206
|
+
* A raw target id has no kind; the column's `parent`, when it is an app or
|
|
207
|
+
* element in this workspace, is that aspect (#2087). Element wins over an app
|
|
208
|
+
* of the same refName unless only the app owns the field key.
|
|
209
|
+
*/
|
|
210
|
+
function columnAspect(value, target, where, opts) {
|
|
211
|
+
if (target.kind !== undefined)
|
|
212
|
+
return target;
|
|
213
|
+
const parent = value.parent;
|
|
214
|
+
if (parent === undefined || parent === "")
|
|
215
|
+
return target;
|
|
216
|
+
const kinds = ["element", "app"].filter((kind) => opts.workspaceAspects?.get(workspaceAspectKey(kind, parent)) !== undefined);
|
|
217
|
+
if (kinds.length === 0)
|
|
218
|
+
return target;
|
|
219
|
+
const refName = value.refName ?? "";
|
|
220
|
+
const owning = kinds.find((kind) => {
|
|
221
|
+
const aspect = opts.workspaceAspects?.get(workspaceAspectKey(kind, parent));
|
|
222
|
+
return authoredFieldKeysFromPayload(aspect?.streamRootEntity?.payload)?.has(refName) === true;
|
|
223
|
+
});
|
|
224
|
+
const kind = owning ?? kinds[0];
|
|
225
|
+
return resolveAspect({ __kind: kind, refName: parent, name: parent }, where, opts) ?? target;
|
|
226
|
+
}
|
|
189
227
|
function resolveColumns(columns, target, where, opts) {
|
|
190
228
|
const out = [];
|
|
191
229
|
for (const [index, value] of (columns ?? []).entries()) {
|
|
@@ -221,7 +259,7 @@ function resolveColumns(columns, target, where, opts) {
|
|
|
221
259
|
continue;
|
|
222
260
|
}
|
|
223
261
|
if (value == null) {
|
|
224
|
-
opts.diagnostics.push(`${where}[${index}]
|
|
262
|
+
opts.diagnostics.push(droppedEntryGap(`${where}[${index}]`, `${UNRESOLVED_FIELD_REF}; dropped`, "widget"));
|
|
225
263
|
continue;
|
|
226
264
|
}
|
|
227
265
|
const refName = value.refName ?? "";
|
|
@@ -233,17 +271,34 @@ function resolveColumns(columns, target, where, opts) {
|
|
|
233
271
|
opts.diagnostics.push(`${where}[${index}]: field belongs to ${JSON.stringify(value.parent)}, not target ${JSON.stringify(target.refName)}; dropped`);
|
|
234
272
|
continue;
|
|
235
273
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
274
|
+
// A target pull left as a raw id has no kind, but the column still names
|
|
275
|
+
// its parent app or element. Resolve the field there instead of dropping
|
|
276
|
+
// the column and planning an empty list (#2087).
|
|
277
|
+
const columnTarget = columnAspect(value, target, `${where}[${index}]`, opts);
|
|
278
|
+
if (columnTarget.managed && columnTarget.kind !== undefined && columnTarget.tfLabel !== undefined) {
|
|
279
|
+
const column = resolveManagedColumn(value, refName, columnTarget, opts);
|
|
280
|
+
// Another app's or element's field that its source doesn't have has no
|
|
281
|
+
// resource to reference (#1966): look it up on the platform by name
|
|
282
|
+
// below, as the export did. A ref with no name can't be resolved.
|
|
283
|
+
const ownTarget = columnTarget.kind === opts.scope && columnTarget.refName === opts.ownerRefName;
|
|
284
|
+
const unauthored = ownTarget
|
|
285
|
+
? undefined
|
|
286
|
+
: unauthoredSiblingFieldRef(column.refName, { kind: columnTarget.kind, refName: columnTarget.refName ?? refName, fieldOwnership: columnTarget.fieldOwnership });
|
|
287
|
+
if (unauthored !== undefined && fieldLookupName(value) === undefined) {
|
|
288
|
+
opts.diagnostics.push(droppedEntryGap(`${where}[${index}]`, `${unauthored}; dropped`, "widget"));
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
const direct = unauthored !== undefined
|
|
292
|
+
? undefined
|
|
293
|
+
: fieldRefToTfValue(column.fieldType, column.refName, columnTarget.tfLabel, columnTarget.kind, columnTarget.fieldOwnership);
|
|
239
294
|
if (direct !== undefined) {
|
|
240
295
|
out.push(direct);
|
|
241
296
|
continue;
|
|
242
297
|
}
|
|
243
298
|
}
|
|
244
|
-
if (
|
|
245
|
-
const label = foreignFieldDataLabel(
|
|
246
|
-
opts.orgRefs.foreignField("elementum_field", label,
|
|
299
|
+
if (columnTarget.kind !== undefined) {
|
|
300
|
+
const label = foreignFieldDataLabel(columnTarget.kind, columnTarget.tfLabel ?? columnTarget.refName ?? "target", value.name ?? refName);
|
|
301
|
+
opts.orgRefs.foreignField("elementum_field", label, columnTarget.value, value.name ?? refName);
|
|
247
302
|
out.push(expr.dataAttr("elementum_field", label, ["id"]));
|
|
248
303
|
continue;
|
|
249
304
|
}
|
|
@@ -303,7 +358,7 @@ function onDemandRecordParamForWidget(automation, opts) {
|
|
|
303
358
|
?.onDemandRecordParamByAutomationRefName
|
|
304
359
|
?.get(automation.refName);
|
|
305
360
|
}
|
|
306
|
-
function resolveAutomation(value, where, opts) {
|
|
361
|
+
function resolveAutomation(value, widgetKey, where, opts) {
|
|
307
362
|
if (typeof value === "string")
|
|
308
363
|
return value;
|
|
309
364
|
const refName = value?.refName ?? "";
|
|
@@ -321,10 +376,18 @@ function resolveAutomation(value, where, opts) {
|
|
|
321
376
|
if (authored !== undefined && !authored.has(refName)) {
|
|
322
377
|
// Not in source: pull leaves some automations platform-managed. Look the
|
|
323
378
|
// live one up by display name in this owner rather than reference a
|
|
324
|
-
// resource the build never declares.
|
|
325
|
-
|
|
379
|
+
// resource the build never declares. `name` is the display name; sources
|
|
380
|
+
// pulled before edk#1894 carry it in `displayName` instead.
|
|
381
|
+
const displayName = value?.displayName ?? value?.name ?? "";
|
|
326
382
|
if (displayName === "") {
|
|
327
|
-
|
|
383
|
+
// Warn and keep building the rest (#1877). The caller skips the widget
|
|
384
|
+
// and every layout drops its reference, so plan still validates.
|
|
385
|
+
opts.diagnostics.push(typedCoverageGap({
|
|
386
|
+
kind: "skipped",
|
|
387
|
+
entity: `widget ${JSON.stringify(widgetKey)} (${opts.ownerRefName})`,
|
|
388
|
+
detail: `its automation ${JSON.stringify(refName)} is not in source, and the reference has no display name to look the live automation up by, so the widget is skipped`,
|
|
389
|
+
consequence: "it is not built, and build removes it from every layout that places it; if the widget is already managed, the next plan deletes it. If this source was pulled before #1901, pull it again; otherwise restore the automation in source or remove the widget",
|
|
390
|
+
}));
|
|
328
391
|
return undefined;
|
|
329
392
|
}
|
|
330
393
|
const label = `${opts.ownerTfLabel}_${tsLabelToTfLabel(refName)}`;
|