@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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
9
9
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
10
|
+
import { type StageHandleIndex } from "../app/stage-keys.js";
|
|
10
11
|
import { type NormalizedManagedViewSort } from "./build.js";
|
|
11
12
|
import type { NormalizedAgentView, NormalizedCalendarView, NormalizedCustomView, NormalizedDashboardView, NormalizedKanbanView, NormalizedLayout, NormalizedListView } from "../app/deserializer/normalize.js";
|
|
12
13
|
/** Report every attribute key not in `known` as dialect growth — shared by all four view/section passes below. */
|
|
@@ -19,19 +20,34 @@ export interface ViewOwner {
|
|
|
19
20
|
readonly ownerTfLabel: string;
|
|
20
21
|
/** App vs element scope for prefix stripping. */
|
|
21
22
|
readonly scope?: ChildResourceScope;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The owning app's full stage-handle index: real stage keys (used when ei
|
|
25
|
+
* exports a raw stage UUID), handles → real keys (#1136) and stages whose
|
|
26
|
+
* only fallback handle another stage holds (#1767). One field, so a caller
|
|
27
|
+
* cannot pass the keys and handles without the fallback losses.
|
|
28
|
+
*/
|
|
29
|
+
readonly stageHandles?: StageHandleIndex;
|
|
26
30
|
/**
|
|
27
31
|
* Keys of the fields pull extracted for this owner. A field reference whose
|
|
28
32
|
* field is not among them keeps its platform id instead of a key that
|
|
29
33
|
* builds as nothing (#1736). Undefined when the caller does not know.
|
|
30
34
|
*/
|
|
31
35
|
readonly fieldKeys?: ReadonlySet<string>;
|
|
36
|
+
/**
|
|
37
|
+
* The extracted fields' keys by display name (lower case); null for a name
|
|
38
|
+
* two fields share. A data source names its field by display name, so
|
|
39
|
+
* this is how an own-app `data.elementum_field` resolves (#1991).
|
|
40
|
+
*/
|
|
41
|
+
readonly fieldKeysByName?: ReadonlyMap<string, string | null>;
|
|
32
42
|
/** Collects the platform ids kept for unextracted fields, so print can say they are intentional. */
|
|
33
43
|
readonly unextractedFieldIds?: Set<string>;
|
|
34
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* What the #1736 unextracted-field fallback reads from an owner. Record create
|
|
47
|
+
* forms, relationships, dynamic layouts and widgets pass one of these too, so
|
|
48
|
+
* their field references keep the same platform id (#1966).
|
|
49
|
+
*/
|
|
50
|
+
export type UnextractedFieldOwner = Pick<ViewOwner, "type" | "label" | "ownerTfLabel" | "scope" | "fieldKeys" | "fieldKeysByName" | "unextractedFieldIds">;
|
|
35
51
|
export interface ViewsFromTfResult {
|
|
36
52
|
readonly layouts: readonly NormalizedLayout[];
|
|
37
53
|
readonly listViews: readonly NormalizedListView[];
|
|
@@ -41,7 +57,55 @@ export interface ViewsFromTfResult {
|
|
|
41
57
|
readonly agentViews: readonly NormalizedAgentView[];
|
|
42
58
|
readonly customViews: readonly NormalizedCustomView[];
|
|
43
59
|
readonly viewOrder?: readonly string[];
|
|
60
|
+
readonly deleteDefaultListView?: boolean;
|
|
44
61
|
}
|
|
45
62
|
/** All three view resource kinds → the normalized shapes the app printer consumes. */
|
|
46
63
|
export declare function viewsFromTf(layoutBlocks: readonly TfBlock[], listViewBlocks: readonly TfBlock[], calendarViewBlocks: readonly TfBlock[], kanbanViewBlocks: readonly TfBlock[], dashboardViewBlocks: readonly TfBlock[], agentViewBlocks: readonly TfBlock[], managedViewOrderBlocks: readonly TfBlock[], owner: ViewOwner, ctx: FromTfContext, customViewBlocks?: readonly TfBlock[]): ViewsFromTfResult;
|
|
64
|
+
/**
|
|
65
|
+
* `ViewOwner.fieldKeysByName` from the extracted fields: lower-cased display
|
|
66
|
+
* name → key, or null for a name two fields share (it names neither).
|
|
67
|
+
*/
|
|
68
|
+
export declare function fieldKeysByDisplayName(fields: readonly {
|
|
69
|
+
readonly key: string;
|
|
70
|
+
readonly field: {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
};
|
|
73
|
+
}[]): ReadonlyMap<string, string | null>;
|
|
74
|
+
/**
|
|
75
|
+
* `ownDataFieldRef` for a caller outside this module (a widget column, a
|
|
76
|
+
* relationship's related field on its own app): the key to author, or
|
|
77
|
+
* "failedClosed" once the blocker naming `site` is recorded. Undefined when
|
|
78
|
+
* `v` is not an own-app data source lookup; the caller's handling stands.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveOwnDataFieldRef(v: TfValue | undefined, owner: UnextractedFieldOwner, ctx: FromTfContext, site: string): {
|
|
81
|
+
readonly key: string;
|
|
82
|
+
} | "failedClosed" | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* The value to author for a field reference outside views (#1966):
|
|
85
|
+
* `fieldKey` is what the caller resolved the reference to, if anything. A
|
|
86
|
+
* field pull did not extract keeps its platform id; otherwise the caller's
|
|
87
|
+
* key stands. Undefined when nothing resolves, or when this reference failed
|
|
88
|
+
* closed: no id is known, which fails the pull with an authoring blocker
|
|
89
|
+
* naming `site`, which must start with the holding resource's address (#1978).
|
|
90
|
+
* The result never depends on another reference's blocker at the same site.
|
|
91
|
+
* Clone drops import blocks, so it keeps the export's dropped id only for
|
|
92
|
+
* another owner's field and fails the same way for any other (#1990). A kept
|
|
93
|
+
* id is reported once per field, naming every site.
|
|
94
|
+
*/
|
|
95
|
+
export declare function unextractedFieldRefId(v: TfValue, fieldKey: string | undefined, owner: UnextractedFieldOwner, ctx: FromTfContext, site: string): string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* A bare platform-id field reference on another owner's side: a widget column
|
|
98
|
+
* whose target is another app or element, or a relationship's related field
|
|
99
|
+
* (#1991). `foreignOwner` names that owner when it is not this one, so the id
|
|
100
|
+
* is its field and keeps its platform id (Dax, 11:45). An id the export
|
|
101
|
+
* imports is checked through its field block instead: in a clone, a field of
|
|
102
|
+
* the source app fails and another owner's keeps its id (#1990); in pull, it
|
|
103
|
+
* is the platform's own and stays as is. With no foreign owner and no import,
|
|
104
|
+
* it fails like `bareFieldIdRef`, naming `site` and the id.
|
|
105
|
+
*/
|
|
106
|
+
export declare function bareForeignFieldIdRef(v: string, owner: UnextractedFieldOwner, ctx: FromTfContext, site: string, foreignOwner: string | undefined): string | undefined;
|
|
107
|
+
/** Whether `v` is a bare platform id, the shape an export writes for a field it can't name (#1991). */
|
|
108
|
+
export declare function isBarePlatformId(v: string): boolean;
|
|
109
|
+
/** Whether `fieldKey` names a field of this owner that pull did not extract (system keys never count). */
|
|
110
|
+
export declare function isUnextractedFieldKey(fieldKey: string, owner: UnextractedFieldOwner): boolean;
|
|
47
111
|
export declare function managedViewSortFromTf(value: TfValue | undefined, owner: ViewOwner, where: string, ctx: FromTfContext): NormalizedManagedViewSort | undefined;
|
|
@@ -6,16 +6,17 @@
|
|
|
6
6
|
* module never names the app's own resource type.
|
|
7
7
|
*/
|
|
8
8
|
import { agentViewLayoutFromTf, viewBlocksFromTf, } from "./agent-view-layout-from-tf.js";
|
|
9
|
-
import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
|
+
import { dataRefLabel, optionalString, plainObject, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
|
|
10
10
|
import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
|
|
11
11
|
import { canonicalImportId } from "../../engine/pull/authored-address.js";
|
|
12
12
|
import { SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
|
|
13
13
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
14
14
|
import { expr, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
15
15
|
import { lostStageMessage, pulledStageHandle } from "../app/stage-keys.js";
|
|
16
|
-
import { decodeForeignDataField, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
16
|
+
import { decodeForeignDataField, fieldBlockOwner, fieldKeyFromForeignDataLabel, fieldKeyFromTfValue, ownerMayHaveCustomField } from "../field/from-tf.js";
|
|
17
17
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
18
18
|
import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
|
|
19
|
+
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
19
20
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
20
21
|
import { filterFromTf, principalList } from "../access-policy/from-tf.js";
|
|
21
22
|
import { listViewDensity, } from "./build.js";
|
|
@@ -89,14 +90,25 @@ export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, ka
|
|
|
89
90
|
}
|
|
90
91
|
// Singleton per aspect — at most one block is expected; extras are reported.
|
|
91
92
|
let viewOrder;
|
|
93
|
+
let deleteDefaultListView;
|
|
92
94
|
for (const [i, block] of managedViewOrderBlocks.entries()) {
|
|
93
95
|
if (i > 0) {
|
|
94
96
|
ctx.diagnostics.push(`unexpected additional elementum_managed_view_order.${block.label ?? "?"} for one aspect; ignored`);
|
|
95
97
|
continue;
|
|
96
98
|
}
|
|
97
99
|
viewOrder = managedViewOrderFromTf(block, owner, keyByAddress, ctx);
|
|
100
|
+
const deleteAttr = block.attrs["delete_platform_default_list_view"];
|
|
101
|
+
if (deleteAttr === true)
|
|
102
|
+
deleteDefaultListView = true;
|
|
103
|
+
else if (deleteAttr !== undefined && deleteAttr !== false && deleteAttr !== null) {
|
|
104
|
+
ctx.diagnostics.push(`managed view order "${block.label ?? "?"}": delete_platform_default_list_view is not a boolean; dropped`);
|
|
105
|
+
}
|
|
98
106
|
}
|
|
99
|
-
return {
|
|
107
|
+
return {
|
|
108
|
+
layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews,
|
|
109
|
+
...(viewOrder !== undefined ? { viewOrder } : {}),
|
|
110
|
+
...(deleteDefaultListView !== undefined ? { deleteDefaultListView } : {}),
|
|
111
|
+
};
|
|
100
112
|
}
|
|
101
113
|
function customViewFromTf(block, owner, ctx) {
|
|
102
114
|
const label = block.label;
|
|
@@ -274,6 +286,7 @@ function layoutRefOptions(owner, ctx, where) {
|
|
|
274
286
|
return {
|
|
275
287
|
isOwnApp: (value) => resourceRefLabel(value, owner.type) === owner.label,
|
|
276
288
|
fieldKey: (value) => fieldRefFromTf(value, owner, ctx, `${where} layout`),
|
|
289
|
+
ownFieldKey: (id, systemKeys) => ownExtractedFieldKey(id, owner, ctx, systemKeys),
|
|
277
290
|
noteRawFieldId: (id) => noteRawUnextractedFieldId(id, owner, ctx, `${where} layout`),
|
|
278
291
|
foreignSource,
|
|
279
292
|
foreignField: (value) => {
|
|
@@ -396,11 +409,9 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
396
409
|
// it as the bag key so build re-emits the same address; build still maps
|
|
397
410
|
// the handle back to the real key for stage_id.
|
|
398
411
|
const labelHandle = tsLabelToTfLabel(labelStageKey);
|
|
399
|
-
const
|
|
412
|
+
const stageHandles = owner.stageHandles;
|
|
413
|
+
const labelStageOwner = stageHandles?.byHandle.get(labelHandle);
|
|
400
414
|
const labelIsStageHandle = stageIndex !== undefined && labelStageOwner === stageIndex;
|
|
401
|
-
const stageHandles = owner.stageKeyByHandle !== undefined && owner.stageKeys !== undefined
|
|
402
|
-
? { byHandle: owner.stageKeyByHandle, keys: owner.stageKeys }
|
|
403
|
-
: undefined;
|
|
404
415
|
// Never write a handle that build maps to another stage: a stage whose only
|
|
405
416
|
// handle is another stage's own key (`pre-approval` next to `pre_approval`)
|
|
406
417
|
// keeps its live layout unmanaged, with a warning (#1136).
|
|
@@ -423,7 +434,7 @@ function layoutFromTf(block, owner, ctx) {
|
|
|
423
434
|
if (stageIndex !== undefined && stageHandle !== undefined && labelStageOwner !== undefined && labelStageOwner !== stageIndex) {
|
|
424
435
|
ctx.diagnostics.push(`${where}: the layout's label "${labelHandle}" is a handle of stage "${labelStageOwner}", but it belongs to stage "${stageIndex}"; it is re-addressed under "${stageHandle}", so the next plan destroys and recreates it (#1136)`);
|
|
425
436
|
}
|
|
426
|
-
const canInferStageKey = typeof attrs["stage_id"] === "string" && owner.
|
|
437
|
+
const canInferStageKey = typeof attrs["stage_id"] === "string" && owner.stageHandles?.keys.has(labelStageKey) === true;
|
|
427
438
|
if (stageIndex !== undefined && stageKey === undefined) {
|
|
428
439
|
ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(stageIndex)} has no terraform label handle; using the layout's own label "${label}" as the stage key`);
|
|
429
440
|
}
|
|
@@ -532,7 +543,13 @@ function fieldRefFromTf(v, owner, ctx, site) {
|
|
|
532
543
|
const ownerLabel = owner.label;
|
|
533
544
|
const fieldKey = fieldKeyFromTfValue(v, tfLabelToTsLabel(ownerLabel), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
534
545
|
if (fieldKey !== undefined)
|
|
535
|
-
return unextractedFieldId(v, fieldKey, owner, ctx, site)
|
|
546
|
+
return keptIdOrKey(unextractedFieldId(v, fieldKey, owner, ctx, site), fieldKey);
|
|
547
|
+
const ownData = ownDataFieldRef(v, owner, ctx, site, false);
|
|
548
|
+
if (ownData !== undefined)
|
|
549
|
+
return authoredRef(ownData);
|
|
550
|
+
// Clone: a bare id is the SOURCE app's, so it never stays as is (#1991).
|
|
551
|
+
if (typeof v === "string" && ctx.cloning !== undefined && PLATFORM_ID.test(v))
|
|
552
|
+
return authoredRef(bareFieldIdRef(v, owner, ctx, site));
|
|
536
553
|
if (typeof v === "string" && importedUnextractedFieldId(v, owner, ctx, site) !== undefined)
|
|
537
554
|
return v;
|
|
538
555
|
if (typeof v === "string" && v !== "") {
|
|
@@ -563,15 +580,27 @@ function fieldRefFromTf(v, owner, ctx, site) {
|
|
|
563
580
|
ctx.diagnostics.push(`field reference ${JSON.stringify(v)} does not resolve to a known field; dropped`);
|
|
564
581
|
return undefined;
|
|
565
582
|
}
|
|
583
|
+
/**
|
|
584
|
+
* What a field reference resolver returns when it failed closed: it recorded
|
|
585
|
+
* an authoring blocker for this one reference, so the caller authors nothing
|
|
586
|
+
* for it, not even a key it resolved (#1991). Other references at the same
|
|
587
|
+
* site resolve on their own.
|
|
588
|
+
*/
|
|
589
|
+
const FAILED_CLOSED = Symbol("failed closed");
|
|
590
|
+
/** A resolver's result as the value to author: undefined when it failed closed. */
|
|
591
|
+
function authoredRef(ref) {
|
|
592
|
+
return ref === FAILED_CLOSED ? undefined : ref;
|
|
593
|
+
}
|
|
566
594
|
/**
|
|
567
595
|
* The platform id of a field reference whose field pull did not extract for
|
|
568
596
|
* this owner (#1736). Its key prints as nothing, so build drops the column
|
|
569
597
|
* or section field and plan removes it. The id keeps it: a raw platform id
|
|
570
598
|
* as is (a re-pull of this fix's own output), or a resource reference's
|
|
571
599
|
* import id. Print marks it as intentional through `unextractedFieldIds`.
|
|
572
|
-
* Undefined when the field was extracted
|
|
600
|
+
* Undefined when the field was extracted; FAILED_CLOSED when this reference
|
|
601
|
+
* recorded an authoring blocker.
|
|
573
602
|
*/
|
|
574
|
-
function unextractedFieldId(v, fieldKey, owner, ctx, site) {
|
|
603
|
+
function unextractedFieldId(v, fieldKey, owner, ctx, site, failClosed = false) {
|
|
575
604
|
if (owner.fieldKeys === undefined || owner.fieldKeys.has(fieldKey))
|
|
576
605
|
return undefined;
|
|
577
606
|
// A system key is never in the extracted fields bag (element audit keys
|
|
@@ -592,13 +621,189 @@ function unextractedFieldId(v, fieldKey, owner, ctx, site) {
|
|
|
592
621
|
id = canonical !== undefined && PLATFORM_ID.test(canonical) ? canonical : undefined;
|
|
593
622
|
}
|
|
594
623
|
else {
|
|
595
|
-
|
|
624
|
+
// A shape with no id to keep, such as a data source
|
|
625
|
+
// (`data.elementum_field.<label>.id`) or a local, for a field pull did not
|
|
626
|
+
// extract. A view outside a clone keeps it as before. Everywhere else it
|
|
627
|
+
// fails closed, naming the site and the key: the key would print as
|
|
628
|
+
// nothing, so handing it back would drop the reference silently (#1991).
|
|
629
|
+
if (!failClosed && ctx.cloning === undefined)
|
|
630
|
+
return undefined;
|
|
631
|
+
reportUnresolvableUnextractedField(ctx, `${unkeptFieldAddress(v)} (key ${JSON.stringify(fieldKey)})`, site, "which is a field of the source app that its export did not extract, so the clone would not have it", "which pull did not extract and which has no platform id to keep");
|
|
632
|
+
return FAILED_CLOSED;
|
|
633
|
+
}
|
|
634
|
+
if (id === undefined && ctx.cloning !== undefined) {
|
|
635
|
+
// Clone dropped the import blocks and never copies the field, so at
|
|
636
|
+
// every site, views included, it keeps only another owner's field, by
|
|
637
|
+
// the export's id, and fails on any other (#1990).
|
|
638
|
+
const kept = cloneKeptFieldId(v, field, owner, ctx);
|
|
639
|
+
if (typeof kept !== "string") {
|
|
640
|
+
reportUnresolvableUnextractedField(ctx, field, site, kept.reason);
|
|
641
|
+
return FAILED_CLOSED;
|
|
642
|
+
}
|
|
643
|
+
id = kept;
|
|
644
|
+
}
|
|
645
|
+
else if (id === undefined && failClosed) {
|
|
646
|
+
reportUnresolvableUnextractedField(ctx, field, site);
|
|
647
|
+
return FAILED_CLOSED;
|
|
596
648
|
}
|
|
597
|
-
reportUnextractedField(ctx, field, id, site);
|
|
649
|
+
reportUnextractedField(ctx, field, id, site, failClosed);
|
|
598
650
|
if (id !== undefined)
|
|
599
651
|
owner.unextractedFieldIds?.add(id);
|
|
600
652
|
return id;
|
|
601
653
|
}
|
|
654
|
+
/**
|
|
655
|
+
* Outside views, a reference to a field pull did not extract and has no
|
|
656
|
+
* platform id for fails the pull (Dax, #1978): leaving the entry out would
|
|
657
|
+
* make the next apply remove it. Each site is one blocker, so the pull-abort
|
|
658
|
+
* error names every one before any file is written. `site` starts with the
|
|
659
|
+
* holding resource's address (`type.label`).
|
|
660
|
+
*/
|
|
661
|
+
function reportUnresolvableUnextractedField(ctx, field, site, cloneReason, pullReason) {
|
|
662
|
+
const address = site.split(".").slice(0, 2).join(".");
|
|
663
|
+
const cloning = ctx.cloning !== undefined;
|
|
664
|
+
const description = cloning
|
|
665
|
+
? `${site} references field ${field}, ${cloneReason ?? "which the clone does not copy"}; the clone cannot keep this reference`
|
|
666
|
+
: `${site} references field ${field}, ${pullReason ?? "which pull did not extract and whose import block has no platform id"}, so the reference cannot be resolved`;
|
|
667
|
+
if (ctx.authoringBlockers?.some((blocker) => blocker.description === description) === true)
|
|
668
|
+
return;
|
|
669
|
+
reportAuthoringBlocker(ctx, { address, description, remedy: cloning ? UNRESOLVABLE_CLONE_FIELD_REMEDY : UNRESOLVABLE_UNEXTRACTED_FIELD_REMEDY });
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* A data source lookup of one of this owner's own fields
|
|
673
|
+
* (`data.elementum_field.<label>.id` whose object_id is the owner).
|
|
674
|
+
* `fieldKeyFromTfValue` keys a data source only for a system field, so
|
|
675
|
+
* without this the caller dropped it with only a diagnostic (#1991).
|
|
676
|
+
* - An extracted field resolves to its key by the data source's `name`.
|
|
677
|
+
* A name no extracted field has means the field was not extracted. Only
|
|
678
|
+
* with no name, or one two fields share, does the label decide, with ei's
|
|
679
|
+
* owner prefixes stripped (`elementum_app_<display name>_`, the namespace,
|
|
680
|
+
* the owner's label), as the widget decodes another owner's field.
|
|
681
|
+
* - A field pull did not extract fails closed with `unextractedFieldId`'s
|
|
682
|
+
* report, naming `site` and that key (or the name, when the label's key
|
|
683
|
+
* is another, extracted field's). `failClosed` is false for views, which fail
|
|
684
|
+
* closed only in a clone; in pull they keep dropping it (#1978).
|
|
685
|
+
* Undefined for any other value, a data source whose owner is another or
|
|
686
|
+
* unknown, or an unextracted field in a pull view: the caller's existing
|
|
687
|
+
* handling stands.
|
|
688
|
+
*/
|
|
689
|
+
function ownDataFieldRef(v, owner, ctx, site, failClosed) {
|
|
690
|
+
if (!isTfExpr(v) || v.$expr !== "data-attr" || v.type !== "elementum_field" || v.path.length !== 1 || v.path[0] !== "id")
|
|
691
|
+
return undefined;
|
|
692
|
+
if (owner.fieldKeys === undefined)
|
|
693
|
+
return undefined;
|
|
694
|
+
const address = `${owner.type}.${owner.label}`;
|
|
695
|
+
const ownerId = platformIdOf(ctx.cloning !== undefined ? ctx.cloning.sourceImportId(address) : ctx.importId(address));
|
|
696
|
+
if (fieldBlockOwner(ctx.dataAttrs?.(v.type, v.label)?.["object_id"], owner, ctx, ownerId) !== "own")
|
|
697
|
+
return undefined;
|
|
698
|
+
const field = ownDataFieldKey(v.label, owner, ctx);
|
|
699
|
+
if (field.extracted)
|
|
700
|
+
return field.key;
|
|
701
|
+
if (!failClosed && ctx.cloning === undefined)
|
|
702
|
+
return undefined;
|
|
703
|
+
// Not `unextractedFieldId`: with an unmatched name, the label's key may be
|
|
704
|
+
// an extracted field's, which that check would read as extracted. Such a
|
|
705
|
+
// key would misname the field, so the blocker names the data source's name.
|
|
706
|
+
const named = field.name !== undefined && owner.fieldKeys.has(field.key);
|
|
707
|
+
reportUnresolvableUnextractedField(ctx, `${unkeptFieldAddress(v)} (${named ? `name ${JSON.stringify(field.name)}` : `key ${JSON.stringify(field.key)}`})`, site, "which is a field of the source app that its export did not extract, so the clone would not have it", "which pull did not extract and which has no platform id to keep");
|
|
708
|
+
return FAILED_CLOSED;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* `ViewOwner.fieldKeysByName` from the extracted fields: lower-cased display
|
|
712
|
+
* name → key, or null for a name two fields share (it names neither).
|
|
713
|
+
*/
|
|
714
|
+
export function fieldKeysByDisplayName(fields) {
|
|
715
|
+
const byName = new Map();
|
|
716
|
+
for (const { key, field } of fields) {
|
|
717
|
+
const name = field.name.toLowerCase();
|
|
718
|
+
const prior = byName.get(name);
|
|
719
|
+
byName.set(name, prior === undefined ? key : prior === key ? key : null);
|
|
720
|
+
}
|
|
721
|
+
return byName;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* The field an own-app `data.elementum_field.<label>` names (see
|
|
725
|
+
* `ownDataFieldRef`). The provider looks the field up by `name`, so a name
|
|
726
|
+
* is authoritative: one extracted field's name gives its key, and a name no
|
|
727
|
+
* extracted field has means the field was not extracted, whatever the label
|
|
728
|
+
* says. Only with no name, or one two extracted fields share, does the
|
|
729
|
+
* label decide, with ei's owner prefixes stripped. `key` names the field in
|
|
730
|
+
* a blocker; `extracted` says whether to author it.
|
|
731
|
+
*/
|
|
732
|
+
function ownDataFieldKey(label, owner, ctx) {
|
|
733
|
+
const name = ctx.dataName("elementum_field", label);
|
|
734
|
+
const byName = name === undefined ? undefined : owner.fieldKeysByName?.get(name.toLowerCase());
|
|
735
|
+
if (typeof byName === "string")
|
|
736
|
+
return { key: byName, extracted: true };
|
|
737
|
+
const attrs = ctx.resourceByAddress?.(`${owner.type}.${owner.label}`)?.attrs;
|
|
738
|
+
const ownerName = attrs?.["name"];
|
|
739
|
+
const ownerNamespace = attrs?.["namespace"];
|
|
740
|
+
const key = fieldKeyFromForeignDataLabel(label, {
|
|
741
|
+
key: tfLabelToTsLabel(owner.label),
|
|
742
|
+
kind: owner.scope ?? "app",
|
|
743
|
+
...(typeof ownerName === "string" && { name: ownerName }),
|
|
744
|
+
...(typeof ownerNamespace === "string" && { namespace: ownerNamespace }),
|
|
745
|
+
}) ?? tfLabelToTsLabel(label);
|
|
746
|
+
// A name no extracted field has: never let the label pick another field.
|
|
747
|
+
if (name !== undefined && byName === undefined && owner.fieldKeysByName !== undefined)
|
|
748
|
+
return { key, extracted: false, name };
|
|
749
|
+
return { key, extracted: owner.fieldKeys?.has(key) === true || isOwnerSystemFieldKey(key, owner) };
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* `ownDataFieldRef` for a caller outside this module (a widget column, a
|
|
753
|
+
* relationship's related field on its own app): the key to author, or
|
|
754
|
+
* "failedClosed" once the blocker naming `site` is recorded. Undefined when
|
|
755
|
+
* `v` is not an own-app data source lookup; the caller's handling stands.
|
|
756
|
+
*/
|
|
757
|
+
export function resolveOwnDataFieldRef(v, owner, ctx, site) {
|
|
758
|
+
if (v === undefined)
|
|
759
|
+
return undefined;
|
|
760
|
+
const ref = ownDataFieldRef(v, owner, ctx, site, true);
|
|
761
|
+
return ref === FAILED_CLOSED ? "failedClosed" : ref === undefined ? undefined : { key: ref };
|
|
762
|
+
}
|
|
763
|
+
/** How a field reference that isn't an id or a resource reference reads in a blocker. */
|
|
764
|
+
function unkeptFieldAddress(v) {
|
|
765
|
+
if (isTfExpr(v) && v.$expr === "data-attr")
|
|
766
|
+
return `data.${v.type}.${v.label}`;
|
|
767
|
+
if (isTfExpr(v) && v.$expr === "local")
|
|
768
|
+
return `local.${v.name}`;
|
|
769
|
+
return "a reference with no platform id";
|
|
770
|
+
}
|
|
771
|
+
function platformIdOf(importId) {
|
|
772
|
+
const canonical = importId === undefined ? undefined : canonicalImportId(importId);
|
|
773
|
+
return canonical !== undefined && PLATFORM_ID.test(canonical) ? canonical : undefined;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* The id a clone keeps for a reference to a field it does not copy (#1990):
|
|
777
|
+
* the export's platform id, only when the field's block names another app,
|
|
778
|
+
* element or task as its owner, so the field exists without the clone. A
|
|
779
|
+
* field of the source app itself (or of no owner the clone can name) would
|
|
780
|
+
* leave the clone pointing at the source app or at nothing, so it fails
|
|
781
|
+
* with the reason instead.
|
|
782
|
+
*/
|
|
783
|
+
function cloneKeptFieldId(v, field, owner, ctx) {
|
|
784
|
+
const sourceId = isTfExpr(v) && v.$expr === "resource-attr" ? platformIdOf(ctx.cloning?.sourceImportId(field)) : undefined;
|
|
785
|
+
const block = isTfExpr(v) && v.$expr === "resource-attr" ? ctx.resourceByAddress?.(field) : undefined;
|
|
786
|
+
if (block === undefined) {
|
|
787
|
+
return {
|
|
788
|
+
reason: sourceId !== undefined
|
|
789
|
+
? `which the source app's export imports as ${sourceId} but has no field block for, so its owner is unknown`
|
|
790
|
+
: "which the source app's export does not include and has no platform id for",
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
const ownerId = platformIdOf(ctx.cloning?.sourceImportId(`${owner.type}.${owner.label}`));
|
|
794
|
+
switch (fieldBlockOwner(block.attrs["object_id"], owner, ctx, ownerId)) {
|
|
795
|
+
case "own":
|
|
796
|
+
return { reason: "which is a field of the source app that its export did not extract, so the clone would not have it" };
|
|
797
|
+
case "unresolved":
|
|
798
|
+
return { reason: "whose owner the clone cannot identify from its object_id" };
|
|
799
|
+
case "foreign":
|
|
800
|
+
return sourceId ?? { reason: "which belongs to another app, element or task but has no platform id in the source app's export" };
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const UNRESOLVABLE_UNEXTRACTED_FIELD_REMEDY = "Pull keeps a reference to a field it did not extract only by that field's platform id (#1966). " +
|
|
804
|
+
"Check that each field still exists on its app or element and pull again; if the export keeps omitting it, report it to the EDK maintainers.";
|
|
805
|
+
const UNRESOLVABLE_CLONE_FIELD_REMEDY = "Clone copies the source app's own fields and keeps a reference to another app's, element's or task's field by that field's platform id (#1990). " +
|
|
806
|
+
"Check that each field still exists on the app, element or task that owns it and that the source app's export includes it; if the export keeps omitting it, report it to the EDK maintainers.";
|
|
602
807
|
const ELEMENT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
|
|
603
808
|
function isOwnerSystemFieldKey(fieldKey, owner) {
|
|
604
809
|
return (owner.scope === "element" ? ELEMENT_SYSTEM_FIELD_KEY_SET : SYSTEM_FIELD_KEY_SET).has(fieldKey);
|
|
@@ -608,7 +813,7 @@ function isOwnerSystemFieldKey(fieldKey, owner) {
|
|
|
608
813
|
* that pull did not extract: a re-pull of an id #1736 kept. Undefined
|
|
609
814
|
* otherwise.
|
|
610
815
|
*/
|
|
611
|
-
function importedUnextractedFieldId(v, owner, ctx, site) {
|
|
816
|
+
function importedUnextractedFieldId(v, owner, ctx, site, failClosed = false) {
|
|
612
817
|
if (!PLATFORM_ID.test(v))
|
|
613
818
|
return undefined;
|
|
614
819
|
const imported = ctx.importedResource?.(v);
|
|
@@ -618,7 +823,135 @@ function importedUnextractedFieldId(v, owner, ctx, site) {
|
|
|
618
823
|
const importedKey = fieldKeyFromTfValue(importedRef, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
619
824
|
if (importedKey === undefined)
|
|
620
825
|
return undefined;
|
|
621
|
-
return unextractedFieldId(importedRef, importedKey, owner, ctx, site) === v ? v : undefined;
|
|
826
|
+
return unextractedFieldId(importedRef, importedKey, owner, ctx, site, failClosed) === v ? v : undefined;
|
|
827
|
+
}
|
|
828
|
+
/** The kept id, else the caller's key; undefined, never the key, when this reference failed closed. */
|
|
829
|
+
function keptIdOrKey(kept, fieldKey) {
|
|
830
|
+
return kept === FAILED_CLOSED ? undefined : kept ?? fieldKey;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* The value to author for a field reference outside views (#1966):
|
|
834
|
+
* `fieldKey` is what the caller resolved the reference to, if anything. A
|
|
835
|
+
* field pull did not extract keeps its platform id; otherwise the caller's
|
|
836
|
+
* key stands. Undefined when nothing resolves, or when this reference failed
|
|
837
|
+
* closed: no id is known, which fails the pull with an authoring blocker
|
|
838
|
+
* naming `site`, which must start with the holding resource's address (#1978).
|
|
839
|
+
* The result never depends on another reference's blocker at the same site.
|
|
840
|
+
* Clone drops import blocks, so it keeps the export's dropped id only for
|
|
841
|
+
* another owner's field and fails the same way for any other (#1990). A kept
|
|
842
|
+
* id is reported once per field, naming every site.
|
|
843
|
+
*/
|
|
844
|
+
export function unextractedFieldRefId(v, fieldKey, owner, ctx, site) {
|
|
845
|
+
if (fieldKey !== undefined)
|
|
846
|
+
return keptIdOrKey(unextractedFieldId(v, fieldKey, owner, ctx, site, true), fieldKey);
|
|
847
|
+
const ownData = ownDataFieldRef(v, owner, ctx, site, true);
|
|
848
|
+
if (ownData !== undefined)
|
|
849
|
+
return authoredRef(ownData);
|
|
850
|
+
return typeof v === "string" && PLATFORM_ID.test(v) ? authoredRef(bareFieldIdRef(v, owner, ctx, site)) : undefined;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* A bare platform-id field reference no key resolves: what an export writes
|
|
854
|
+
* when it can't name the field (#1991). It resolves through the import that
|
|
855
|
+
* names the id (in a clone, the source export's dropped one) to the field's
|
|
856
|
+
* key, or to the kept id of a field pull did not extract (another owner's,
|
|
857
|
+
* in a clone). Anything else fails the pull or clone with an authoring
|
|
858
|
+
* blocker naming `site` and the id, instead of dropping the entry or, in a
|
|
859
|
+
* clone, leaving the source app's id in place. Views outside a clone keep
|
|
860
|
+
* a bare id as is (#1178) and don't come here.
|
|
861
|
+
*/
|
|
862
|
+
function bareFieldIdRef(v, owner, ctx, site) {
|
|
863
|
+
const imported = ctx.importedResource?.(v);
|
|
864
|
+
if (imported !== undefined) {
|
|
865
|
+
const ref = expr.resourceAttr(imported.type, imported.label, ["id"]);
|
|
866
|
+
const key = fieldKeyFromTfValue(ref, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
867
|
+
if (key !== undefined) {
|
|
868
|
+
// A reference that failed closed never hands back the key, so nothing
|
|
869
|
+
// can author a field the clone doesn't have. Only this call's own
|
|
870
|
+
// result decides it, not blockers other references left at the site.
|
|
871
|
+
const kept = unextractedFieldId(ref, key, owner, ctx, site, true);
|
|
872
|
+
return kept === FAILED_CLOSED ? FAILED_CLOSED : kept ?? key;
|
|
873
|
+
}
|
|
874
|
+
if (ctx.cloning !== undefined) {
|
|
875
|
+
const kept = cloneKeptFieldId(ref, `${imported.type}.${imported.label}`, owner, ctx);
|
|
876
|
+
if (typeof kept === "string") {
|
|
877
|
+
reportUnextractedField(ctx, `${imported.type}.${imported.label}`, kept, site, true);
|
|
878
|
+
owner.unextractedFieldIds?.add(kept);
|
|
879
|
+
return kept;
|
|
880
|
+
}
|
|
881
|
+
reportUnresolvableUnextractedField(ctx, `${imported.type}.${imported.label}`, site, kept.reason);
|
|
882
|
+
return FAILED_CLOSED;
|
|
883
|
+
}
|
|
884
|
+
// Pull: the export names the id, so it is the platform's own; keep it.
|
|
885
|
+
ctx.diagnostics.push(`${site}: field id ${v} is imported as ${imported.type}.${imported.label}, not a field of this owner; kept as is`);
|
|
886
|
+
return v;
|
|
887
|
+
}
|
|
888
|
+
reportUnimportedBareFieldId(v, ctx, site);
|
|
889
|
+
return FAILED_CLOSED;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* A bare platform-id field reference on another owner's side: a widget column
|
|
893
|
+
* whose target is another app or element, or a relationship's related field
|
|
894
|
+
* (#1991). `foreignOwner` names that owner when it is not this one, so the id
|
|
895
|
+
* is its field and keeps its platform id (Dax, 11:45). An id the export
|
|
896
|
+
* imports is checked through its field block instead: in a clone, a field of
|
|
897
|
+
* the source app fails and another owner's keeps its id (#1990); in pull, it
|
|
898
|
+
* is the platform's own and stays as is. With no foreign owner and no import,
|
|
899
|
+
* it fails like `bareFieldIdRef`, naming `site` and the id.
|
|
900
|
+
*/
|
|
901
|
+
export function bareForeignFieldIdRef(v, owner, ctx, site, foreignOwner) {
|
|
902
|
+
const imported = ctx.importedResource?.(v);
|
|
903
|
+
if (imported !== undefined) {
|
|
904
|
+
const field = `${imported.type}.${imported.label}`;
|
|
905
|
+
if (ctx.cloning !== undefined) {
|
|
906
|
+
const kept = cloneKeptFieldId(expr.resourceAttr(imported.type, imported.label, ["id"]), field, owner, ctx);
|
|
907
|
+
if (typeof kept === "string") {
|
|
908
|
+
reportUnextractedField(ctx, field, kept, site, true);
|
|
909
|
+
owner.unextractedFieldIds?.add(kept);
|
|
910
|
+
return kept;
|
|
911
|
+
}
|
|
912
|
+
reportUnresolvableUnextractedField(ctx, field, site, kept.reason);
|
|
913
|
+
return undefined;
|
|
914
|
+
}
|
|
915
|
+
ctx.diagnostics.push(`${site}: field id ${v} is imported as ${field}, not a field of ${foreignOwner ?? "this owner"}; kept as is`);
|
|
916
|
+
return v;
|
|
917
|
+
}
|
|
918
|
+
if (foreignOwner !== undefined) {
|
|
919
|
+
ctx.diagnostics.push(`${site}: field id ${v} is a field of ${foreignOwner}, which this ${ctx.cloning !== undefined ? "clone" : "pull"} does not copy; kept as its platform id`);
|
|
920
|
+
owner.unextractedFieldIds?.add(v);
|
|
921
|
+
return v;
|
|
922
|
+
}
|
|
923
|
+
reportUnimportedBareFieldId(v, ctx, site);
|
|
924
|
+
return undefined;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* The blocker for a bare field id no import names (#1991). In a clone whose
|
|
928
|
+
* live system-field read failed, the id may be one of the source app's
|
|
929
|
+
* system fields, so the message names that read instead (#1492).
|
|
930
|
+
*/
|
|
931
|
+
function reportUnimportedBareFieldId(v, ctx, site) {
|
|
932
|
+
const address = site.split(".").slice(0, 2).join(".");
|
|
933
|
+
const readFailure = ctx.cloning?.systemFieldReadFailure;
|
|
934
|
+
const description = ctx.cloning === undefined
|
|
935
|
+
? `${site} references field id ${v}, which no import in the export names, so pull cannot resolve it to a field`
|
|
936
|
+
: readFailure !== undefined
|
|
937
|
+
? `${site} references field id ${v}, which no import in the source app's export names. It may be one of the source app's system fields, but the clone couldn't map them (${readFailure})`
|
|
938
|
+
: `${site} references field id ${v}, which no import in the source app's export names, so the clone cannot tell whose field it is`;
|
|
939
|
+
if (ctx.authoringBlockers?.some((blocker) => blocker.description === description) === true)
|
|
940
|
+
return;
|
|
941
|
+
const remedy = ctx.cloning === undefined
|
|
942
|
+
? UNRESOLVABLE_UNEXTRACTED_FIELD_REMEDY
|
|
943
|
+
: readFailure !== undefined
|
|
944
|
+
? "Fix the failed system-field read (check the profile's access to the source app) and run the clone again."
|
|
945
|
+
: UNRESOLVABLE_CLONE_FIELD_REMEDY;
|
|
946
|
+
reportAuthoringBlocker(ctx, { address, description, remedy });
|
|
947
|
+
}
|
|
948
|
+
/** Whether `v` is a bare platform id, the shape an export writes for a field it can't name (#1991). */
|
|
949
|
+
export function isBarePlatformId(v) {
|
|
950
|
+
return PLATFORM_ID.test(v);
|
|
951
|
+
}
|
|
952
|
+
/** Whether `fieldKey` names a field of this owner that pull did not extract (system keys never count). */
|
|
953
|
+
export function isUnextractedFieldKey(fieldKey, owner) {
|
|
954
|
+
return owner.fieldKeys !== undefined && !owner.fieldKeys.has(fieldKey) && !isOwnerSystemFieldKey(fieldKey, owner);
|
|
622
955
|
}
|
|
623
956
|
/**
|
|
624
957
|
* Records a raw platform id that a caller keeps as is (a sort order, a blocks
|
|
@@ -634,9 +967,34 @@ function noteRawUnextractedFieldId(v, owner, ctx, site) {
|
|
|
634
967
|
else
|
|
635
968
|
importedUnextractedFieldId(v, owner, ctx, site);
|
|
636
969
|
}
|
|
637
|
-
/**
|
|
970
|
+
/**
|
|
971
|
+
* The key of this owner's own field a raw platform id names, when pull
|
|
972
|
+
* extracted it (#2155): by its state identity, else by the import that names
|
|
973
|
+
* it. A system field counts only with `systemKeys` (it has no import), and
|
|
974
|
+
* not when a custom field of the owner shares its key. Any other id is
|
|
975
|
+
* undefined, and so is every id in a clone, whose ids are the
|
|
976
|
+
* source app's.
|
|
977
|
+
*/
|
|
978
|
+
function ownExtractedFieldKey(v, owner, ctx, systemKeys) {
|
|
979
|
+
if (ctx.cloning !== undefined || !PLATFORM_ID.test(v))
|
|
980
|
+
return undefined;
|
|
981
|
+
const ownerRefName = tfLabelToTsLabel(owner.label);
|
|
982
|
+
const scope = owner.scope ?? "app";
|
|
983
|
+
const imported = ctx.importedResource?.(v);
|
|
984
|
+
const key = fieldKeyFromTfValue(v, ownerRefName, owner.ownerTfLabel, scope, ctx)
|
|
985
|
+
?? (imported === undefined ? undefined : fieldKeyFromTfValue(expr.resourceAttr(imported.type, imported.label, ["id"]), ownerRefName, owner.ownerTfLabel, scope, ctx));
|
|
986
|
+
if (key === undefined)
|
|
987
|
+
return undefined;
|
|
988
|
+
// A custom field may own a system key (an element's createdAt); build
|
|
989
|
+
// resolves that key to the platform field, which would retarget the
|
|
990
|
+
// reference, so its id stays raw (as selfSystemField does).
|
|
991
|
+
if (isOwnerSystemFieldKey(key, owner))
|
|
992
|
+
return systemKeys && imported === undefined && !ownerMayHaveCustomField(owner, key, ctx) ? key : undefined;
|
|
993
|
+
return owner.fieldKeys?.has(key) === true ? key : undefined;
|
|
994
|
+
}
|
|
995
|
+
/** One diagnostic per unextracted field per pull, naming every site that references it (#1736, #1966). */
|
|
638
996
|
const unextractedFieldReports = new WeakMap();
|
|
639
|
-
function reportUnextractedField(ctx, field, id, site) {
|
|
997
|
+
function reportUnextractedField(ctx, field, id, site, outsideViews) {
|
|
640
998
|
let byField = unextractedFieldReports.get(ctx.diagnostics);
|
|
641
999
|
if (byField === undefined) {
|
|
642
1000
|
byField = new Map();
|
|
@@ -644,16 +1002,28 @@ function reportUnextractedField(ctx, field, id, site) {
|
|
|
644
1002
|
}
|
|
645
1003
|
let report = byField.get(field);
|
|
646
1004
|
if (report === undefined) {
|
|
647
|
-
report = { index: ctx.diagnostics.length, sites: [] };
|
|
1005
|
+
report = { index: ctx.diagnostics.length, sites: [], outsideViews: false };
|
|
648
1006
|
byField.set(field, report);
|
|
649
1007
|
ctx.diagnostics.push("");
|
|
650
1008
|
}
|
|
651
1009
|
if (!report.sites.includes(site))
|
|
652
1010
|
report.sites.push(site);
|
|
1011
|
+
report.outsideViews ||= outsideViews;
|
|
653
1012
|
const sites = report.sites.join(", ");
|
|
1013
|
+
// Views and dashboard widget sorts share this report, so name what holds
|
|
1014
|
+
// the reference: a view, a dashboard widget, or several kinds of site.
|
|
1015
|
+
const onDashboard = report.sites.filter((s) => s.startsWith(`${DASHBOARD_WIDGET_RESOURCE_TYPE}.`)).length;
|
|
1016
|
+
const holder = report.outsideViews || (onDashboard > 0 && onDashboard < report.sites.length)
|
|
1017
|
+
? undefined
|
|
1018
|
+
: onDashboard > 0 ? "dashboard widget" : "view";
|
|
654
1019
|
ctx.diagnostics[report.index] = id !== undefined
|
|
655
|
-
?
|
|
656
|
-
|
|
1020
|
+
? ctx.cloning !== undefined
|
|
1021
|
+
// A clone keeps only another owner's field, which exists without it (#1990).
|
|
1022
|
+
? `field ${field} belongs to another app, element or task, so the clone does not copy it; kept as its platform id ${id} at ${sites}`
|
|
1023
|
+
: `field ${field} was not extracted by pull; kept as its platform id ${id} at ${sites}, so plan keeps it ${holder === undefined ? "there" : `in the ${holder}`} (dropping it would make plan remove it)`
|
|
1024
|
+
// Only a view or dashboard widget sort outside a clone gets here;
|
|
1025
|
+
// anywhere else, and in a clone, that fails (#1978, #1990).
|
|
1026
|
+
: `field ${field} was not extracted by pull and has no platform id; ${sites} builds without it, so plan would remove it from ${holder === undefined ? "there" : `the ${holder}`}`;
|
|
657
1027
|
}
|
|
658
1028
|
function listViewFromTf(block, owner, ctx) {
|
|
659
1029
|
const label = block.label;
|
|
@@ -742,9 +1112,11 @@ export function managedViewSortFromTf(value, owner, where, ctx) {
|
|
|
742
1112
|
}
|
|
743
1113
|
const rawField = order["field"];
|
|
744
1114
|
const site = `${where} sort.orders[${index}].field`;
|
|
745
|
-
|
|
1115
|
+
// A clone resolves a bare id like any field reference (#1991).
|
|
1116
|
+
const cloningBareId = typeof rawField === "string" && ctx.cloning !== undefined && PLATFORM_ID.test(rawField);
|
|
1117
|
+
if (typeof rawField === "string" && !cloningBareId)
|
|
746
1118
|
noteRawUnextractedFieldId(rawField, owner, ctx, site);
|
|
747
|
-
const field = typeof rawField === "string"
|
|
1119
|
+
const field = typeof rawField === "string" && !cloningBareId
|
|
748
1120
|
? (PLATFORM_ID.test(rawField) ? rawField : undefined)
|
|
749
1121
|
: fieldRefFromTf(rawField, owner, ctx, site);
|
|
750
1122
|
if (field === undefined) {
|