@elementumai/edk 0.10.4 → 0.11.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 +11 -7
- package/dist-sdk/src/catalog/token.js +2 -1
- 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 +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +3 -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 +22 -0
- package/dist-sdk/src/engine/ei/run.js +99 -18
- 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/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 +17 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +52 -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 +5 -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 +11 -0
- package/dist-sdk/src/entities/app/build.js +1 -0
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
- package/dist-sdk/src/entities/app/from-tf.js +16 -10
- package/dist-sdk/src/entities/app/to-tf.js +6 -4
- package/dist-sdk/src/entities/automation/build.d.ts +2 -7
- package/dist-sdk/src/entities/automation/build.js +43 -14
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +7 -11
- package/dist-sdk/src/entities/automation/from-tf.d.ts +23 -1
- package/dist-sdk/src/entities/automation/from-tf.js +456 -34
- 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 +59 -0
- package/dist-sdk/src/entities/automation/run-target.js +99 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +9 -0
- package/dist-sdk/src/entities/automation/script-code.js +24 -3
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +16 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +49 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +20 -8
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
- package/dist-sdk/src/entities/automation/to-tf.js +102 -40
- package/dist-sdk/src/entities/automation/triggers.d.ts +22 -3
- package/dist-sdk/src/entities/automation/triggers.js +40 -0
- 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/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 +7 -2
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +65 -19
- 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 +6 -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 +7 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +30 -1
- package/dist-sdk/src/entities/field/to-tf.js +51 -0
- 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/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 +15 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
- 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/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 +16 -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/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 +60 -0
- package/dist-sdk/src/entities/view/from-tf.js +391 -17
- package/dist-sdk/src/entities/view/module.js +15 -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 +27 -8
- 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 +28 -3
- package/dist-sdk/src/graph/index.js +12 -2
- package/dist-sdk/src/graph/types.d.ts +157 -5
- package/package.json +1 -1
|
@@ -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) => {
|
|
@@ -532,7 +545,13 @@ function fieldRefFromTf(v, owner, ctx, site) {
|
|
|
532
545
|
const ownerLabel = owner.label;
|
|
533
546
|
const fieldKey = fieldKeyFromTfValue(v, tfLabelToTsLabel(ownerLabel), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
534
547
|
if (fieldKey !== undefined)
|
|
535
|
-
return unextractedFieldId(v, fieldKey, owner, ctx, site)
|
|
548
|
+
return keptIdOrKey(unextractedFieldId(v, fieldKey, owner, ctx, site), fieldKey);
|
|
549
|
+
const ownData = ownDataFieldRef(v, owner, ctx, site, false);
|
|
550
|
+
if (ownData !== undefined)
|
|
551
|
+
return authoredRef(ownData);
|
|
552
|
+
// Clone: a bare id is the SOURCE app's, so it never stays as is (#1991).
|
|
553
|
+
if (typeof v === "string" && ctx.cloning !== undefined && PLATFORM_ID.test(v))
|
|
554
|
+
return authoredRef(bareFieldIdRef(v, owner, ctx, site));
|
|
536
555
|
if (typeof v === "string" && importedUnextractedFieldId(v, owner, ctx, site) !== undefined)
|
|
537
556
|
return v;
|
|
538
557
|
if (typeof v === "string" && v !== "") {
|
|
@@ -563,15 +582,27 @@ function fieldRefFromTf(v, owner, ctx, site) {
|
|
|
563
582
|
ctx.diagnostics.push(`field reference ${JSON.stringify(v)} does not resolve to a known field; dropped`);
|
|
564
583
|
return undefined;
|
|
565
584
|
}
|
|
585
|
+
/**
|
|
586
|
+
* What a field reference resolver returns when it failed closed: it recorded
|
|
587
|
+
* an authoring blocker for this one reference, so the caller authors nothing
|
|
588
|
+
* for it, not even a key it resolved (#1991). Other references at the same
|
|
589
|
+
* site resolve on their own.
|
|
590
|
+
*/
|
|
591
|
+
const FAILED_CLOSED = Symbol("failed closed");
|
|
592
|
+
/** A resolver's result as the value to author: undefined when it failed closed. */
|
|
593
|
+
function authoredRef(ref) {
|
|
594
|
+
return ref === FAILED_CLOSED ? undefined : ref;
|
|
595
|
+
}
|
|
566
596
|
/**
|
|
567
597
|
* The platform id of a field reference whose field pull did not extract for
|
|
568
598
|
* this owner (#1736). Its key prints as nothing, so build drops the column
|
|
569
599
|
* or section field and plan removes it. The id keeps it: a raw platform id
|
|
570
600
|
* as is (a re-pull of this fix's own output), or a resource reference's
|
|
571
601
|
* import id. Print marks it as intentional through `unextractedFieldIds`.
|
|
572
|
-
* Undefined when the field was extracted
|
|
602
|
+
* Undefined when the field was extracted; FAILED_CLOSED when this reference
|
|
603
|
+
* recorded an authoring blocker.
|
|
573
604
|
*/
|
|
574
|
-
function unextractedFieldId(v, fieldKey, owner, ctx, site) {
|
|
605
|
+
function unextractedFieldId(v, fieldKey, owner, ctx, site, failClosed = false) {
|
|
575
606
|
if (owner.fieldKeys === undefined || owner.fieldKeys.has(fieldKey))
|
|
576
607
|
return undefined;
|
|
577
608
|
// A system key is never in the extracted fields bag (element audit keys
|
|
@@ -592,13 +623,189 @@ function unextractedFieldId(v, fieldKey, owner, ctx, site) {
|
|
|
592
623
|
id = canonical !== undefined && PLATFORM_ID.test(canonical) ? canonical : undefined;
|
|
593
624
|
}
|
|
594
625
|
else {
|
|
595
|
-
|
|
626
|
+
// A shape with no id to keep, such as a data source
|
|
627
|
+
// (`data.elementum_field.<label>.id`) or a local, for a field pull did not
|
|
628
|
+
// extract. A view outside a clone keeps it as before. Everywhere else it
|
|
629
|
+
// fails closed, naming the site and the key: the key would print as
|
|
630
|
+
// nothing, so handing it back would drop the reference silently (#1991).
|
|
631
|
+
if (!failClosed && ctx.cloning === undefined)
|
|
632
|
+
return undefined;
|
|
633
|
+
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");
|
|
634
|
+
return FAILED_CLOSED;
|
|
635
|
+
}
|
|
636
|
+
if (id === undefined && ctx.cloning !== undefined) {
|
|
637
|
+
// Clone dropped the import blocks and never copies the field, so at
|
|
638
|
+
// every site, views included, it keeps only another owner's field, by
|
|
639
|
+
// the export's id, and fails on any other (#1990).
|
|
640
|
+
const kept = cloneKeptFieldId(v, field, owner, ctx);
|
|
641
|
+
if (typeof kept !== "string") {
|
|
642
|
+
reportUnresolvableUnextractedField(ctx, field, site, kept.reason);
|
|
643
|
+
return FAILED_CLOSED;
|
|
644
|
+
}
|
|
645
|
+
id = kept;
|
|
596
646
|
}
|
|
597
|
-
|
|
647
|
+
else if (id === undefined && failClosed) {
|
|
648
|
+
reportUnresolvableUnextractedField(ctx, field, site);
|
|
649
|
+
return FAILED_CLOSED;
|
|
650
|
+
}
|
|
651
|
+
reportUnextractedField(ctx, field, id, site, failClosed);
|
|
598
652
|
if (id !== undefined)
|
|
599
653
|
owner.unextractedFieldIds?.add(id);
|
|
600
654
|
return id;
|
|
601
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* Outside views, a reference to a field pull did not extract and has no
|
|
658
|
+
* platform id for fails the pull (Dax, #1978): leaving the entry out would
|
|
659
|
+
* make the next apply remove it. Each site is one blocker, so the pull-abort
|
|
660
|
+
* error names every one before any file is written. `site` starts with the
|
|
661
|
+
* holding resource's address (`type.label`).
|
|
662
|
+
*/
|
|
663
|
+
function reportUnresolvableUnextractedField(ctx, field, site, cloneReason, pullReason) {
|
|
664
|
+
const address = site.split(".").slice(0, 2).join(".");
|
|
665
|
+
const cloning = ctx.cloning !== undefined;
|
|
666
|
+
const description = cloning
|
|
667
|
+
? `${site} references field ${field}, ${cloneReason ?? "which the clone does not copy"}; the clone cannot keep this reference`
|
|
668
|
+
: `${site} references field ${field}, ${pullReason ?? "which pull did not extract and whose import block has no platform id"}, so the reference cannot be resolved`;
|
|
669
|
+
if (ctx.authoringBlockers?.some((blocker) => blocker.description === description) === true)
|
|
670
|
+
return;
|
|
671
|
+
reportAuthoringBlocker(ctx, { address, description, remedy: cloning ? UNRESOLVABLE_CLONE_FIELD_REMEDY : UNRESOLVABLE_UNEXTRACTED_FIELD_REMEDY });
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* A data source lookup of one of this owner's own fields
|
|
675
|
+
* (`data.elementum_field.<label>.id` whose object_id is the owner).
|
|
676
|
+
* `fieldKeyFromTfValue` keys a data source only for a system field, so
|
|
677
|
+
* without this the caller dropped it with only a diagnostic (#1991).
|
|
678
|
+
* - An extracted field resolves to its key by the data source's `name`.
|
|
679
|
+
* A name no extracted field has means the field was not extracted. Only
|
|
680
|
+
* with no name, or one two fields share, does the label decide, with ei's
|
|
681
|
+
* owner prefixes stripped (`elementum_app_<display name>_`, the namespace,
|
|
682
|
+
* the owner's label), as the widget decodes another owner's field.
|
|
683
|
+
* - A field pull did not extract fails closed with `unextractedFieldId`'s
|
|
684
|
+
* report, naming `site` and that key (or the name, when the label's key
|
|
685
|
+
* is another, extracted field's). `failClosed` is false for views, which fail
|
|
686
|
+
* closed only in a clone; in pull they keep dropping it (#1978).
|
|
687
|
+
* Undefined for any other value, a data source whose owner is another or
|
|
688
|
+
* unknown, or an unextracted field in a pull view: the caller's existing
|
|
689
|
+
* handling stands.
|
|
690
|
+
*/
|
|
691
|
+
function ownDataFieldRef(v, owner, ctx, site, failClosed) {
|
|
692
|
+
if (!isTfExpr(v) || v.$expr !== "data-attr" || v.type !== "elementum_field" || v.path.length !== 1 || v.path[0] !== "id")
|
|
693
|
+
return undefined;
|
|
694
|
+
if (owner.fieldKeys === undefined)
|
|
695
|
+
return undefined;
|
|
696
|
+
const address = `${owner.type}.${owner.label}`;
|
|
697
|
+
const ownerId = platformIdOf(ctx.cloning !== undefined ? ctx.cloning.sourceImportId(address) : ctx.importId(address));
|
|
698
|
+
if (fieldBlockOwner(ctx.dataAttrs?.(v.type, v.label)?.["object_id"], owner, ctx, ownerId) !== "own")
|
|
699
|
+
return undefined;
|
|
700
|
+
const field = ownDataFieldKey(v.label, owner, ctx);
|
|
701
|
+
if (field.extracted)
|
|
702
|
+
return field.key;
|
|
703
|
+
if (!failClosed && ctx.cloning === undefined)
|
|
704
|
+
return undefined;
|
|
705
|
+
// Not `unextractedFieldId`: with an unmatched name, the label's key may be
|
|
706
|
+
// an extracted field's, which that check would read as extracted. Such a
|
|
707
|
+
// key would misname the field, so the blocker names the data source's name.
|
|
708
|
+
const named = field.name !== undefined && owner.fieldKeys.has(field.key);
|
|
709
|
+
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");
|
|
710
|
+
return FAILED_CLOSED;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* `ViewOwner.fieldKeysByName` from the extracted fields: lower-cased display
|
|
714
|
+
* name → key, or null for a name two fields share (it names neither).
|
|
715
|
+
*/
|
|
716
|
+
export function fieldKeysByDisplayName(fields) {
|
|
717
|
+
const byName = new Map();
|
|
718
|
+
for (const { key, field } of fields) {
|
|
719
|
+
const name = field.name.toLowerCase();
|
|
720
|
+
const prior = byName.get(name);
|
|
721
|
+
byName.set(name, prior === undefined ? key : prior === key ? key : null);
|
|
722
|
+
}
|
|
723
|
+
return byName;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* The field an own-app `data.elementum_field.<label>` names (see
|
|
727
|
+
* `ownDataFieldRef`). The provider looks the field up by `name`, so a name
|
|
728
|
+
* is authoritative: one extracted field's name gives its key, and a name no
|
|
729
|
+
* extracted field has means the field was not extracted, whatever the label
|
|
730
|
+
* says. Only with no name, or one two extracted fields share, does the
|
|
731
|
+
* label decide, with ei's owner prefixes stripped. `key` names the field in
|
|
732
|
+
* a blocker; `extracted` says whether to author it.
|
|
733
|
+
*/
|
|
734
|
+
function ownDataFieldKey(label, owner, ctx) {
|
|
735
|
+
const name = ctx.dataName("elementum_field", label);
|
|
736
|
+
const byName = name === undefined ? undefined : owner.fieldKeysByName?.get(name.toLowerCase());
|
|
737
|
+
if (typeof byName === "string")
|
|
738
|
+
return { key: byName, extracted: true };
|
|
739
|
+
const attrs = ctx.resourceByAddress?.(`${owner.type}.${owner.label}`)?.attrs;
|
|
740
|
+
const ownerName = attrs?.["name"];
|
|
741
|
+
const ownerNamespace = attrs?.["namespace"];
|
|
742
|
+
const key = fieldKeyFromForeignDataLabel(label, {
|
|
743
|
+
key: tfLabelToTsLabel(owner.label),
|
|
744
|
+
kind: owner.scope ?? "app",
|
|
745
|
+
...(typeof ownerName === "string" && { name: ownerName }),
|
|
746
|
+
...(typeof ownerNamespace === "string" && { namespace: ownerNamespace }),
|
|
747
|
+
}) ?? tfLabelToTsLabel(label);
|
|
748
|
+
// A name no extracted field has: never let the label pick another field.
|
|
749
|
+
if (name !== undefined && byName === undefined && owner.fieldKeysByName !== undefined)
|
|
750
|
+
return { key, extracted: false, name };
|
|
751
|
+
return { key, extracted: owner.fieldKeys?.has(key) === true || isOwnerSystemFieldKey(key, owner) };
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* `ownDataFieldRef` for a caller outside this module (a widget column, a
|
|
755
|
+
* relationship's related field on its own app): the key to author, or
|
|
756
|
+
* "failedClosed" once the blocker naming `site` is recorded. Undefined when
|
|
757
|
+
* `v` is not an own-app data source lookup; the caller's handling stands.
|
|
758
|
+
*/
|
|
759
|
+
export function resolveOwnDataFieldRef(v, owner, ctx, site) {
|
|
760
|
+
if (v === undefined)
|
|
761
|
+
return undefined;
|
|
762
|
+
const ref = ownDataFieldRef(v, owner, ctx, site, true);
|
|
763
|
+
return ref === FAILED_CLOSED ? "failedClosed" : ref === undefined ? undefined : { key: ref };
|
|
764
|
+
}
|
|
765
|
+
/** How a field reference that isn't an id or a resource reference reads in a blocker. */
|
|
766
|
+
function unkeptFieldAddress(v) {
|
|
767
|
+
if (isTfExpr(v) && v.$expr === "data-attr")
|
|
768
|
+
return `data.${v.type}.${v.label}`;
|
|
769
|
+
if (isTfExpr(v) && v.$expr === "local")
|
|
770
|
+
return `local.${v.name}`;
|
|
771
|
+
return "a reference with no platform id";
|
|
772
|
+
}
|
|
773
|
+
function platformIdOf(importId) {
|
|
774
|
+
const canonical = importId === undefined ? undefined : canonicalImportId(importId);
|
|
775
|
+
return canonical !== undefined && PLATFORM_ID.test(canonical) ? canonical : undefined;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* The id a clone keeps for a reference to a field it does not copy (#1990):
|
|
779
|
+
* the export's platform id, only when the field's block names another app,
|
|
780
|
+
* element or task as its owner, so the field exists without the clone. A
|
|
781
|
+
* field of the source app itself (or of no owner the clone can name) would
|
|
782
|
+
* leave the clone pointing at the source app or at nothing, so it fails
|
|
783
|
+
* with the reason instead.
|
|
784
|
+
*/
|
|
785
|
+
function cloneKeptFieldId(v, field, owner, ctx) {
|
|
786
|
+
const sourceId = isTfExpr(v) && v.$expr === "resource-attr" ? platformIdOf(ctx.cloning?.sourceImportId(field)) : undefined;
|
|
787
|
+
const block = isTfExpr(v) && v.$expr === "resource-attr" ? ctx.resourceByAddress?.(field) : undefined;
|
|
788
|
+
if (block === undefined) {
|
|
789
|
+
return {
|
|
790
|
+
reason: sourceId !== undefined
|
|
791
|
+
? `which the source app's export imports as ${sourceId} but has no field block for, so its owner is unknown`
|
|
792
|
+
: "which the source app's export does not include and has no platform id for",
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
const ownerId = platformIdOf(ctx.cloning?.sourceImportId(`${owner.type}.${owner.label}`));
|
|
796
|
+
switch (fieldBlockOwner(block.attrs["object_id"], owner, ctx, ownerId)) {
|
|
797
|
+
case "own":
|
|
798
|
+
return { reason: "which is a field of the source app that its export did not extract, so the clone would not have it" };
|
|
799
|
+
case "unresolved":
|
|
800
|
+
return { reason: "whose owner the clone cannot identify from its object_id" };
|
|
801
|
+
case "foreign":
|
|
802
|
+
return sourceId ?? { reason: "which belongs to another app, element or task but has no platform id in the source app's export" };
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
const UNRESOLVABLE_UNEXTRACTED_FIELD_REMEDY = "Pull keeps a reference to a field it did not extract only by that field's platform id (#1966). " +
|
|
806
|
+
"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.";
|
|
807
|
+
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). " +
|
|
808
|
+
"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
809
|
const ELEMENT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
|
|
603
810
|
function isOwnerSystemFieldKey(fieldKey, owner) {
|
|
604
811
|
return (owner.scope === "element" ? ELEMENT_SYSTEM_FIELD_KEY_SET : SYSTEM_FIELD_KEY_SET).has(fieldKey);
|
|
@@ -608,7 +815,7 @@ function isOwnerSystemFieldKey(fieldKey, owner) {
|
|
|
608
815
|
* that pull did not extract: a re-pull of an id #1736 kept. Undefined
|
|
609
816
|
* otherwise.
|
|
610
817
|
*/
|
|
611
|
-
function importedUnextractedFieldId(v, owner, ctx, site) {
|
|
818
|
+
function importedUnextractedFieldId(v, owner, ctx, site, failClosed = false) {
|
|
612
819
|
if (!PLATFORM_ID.test(v))
|
|
613
820
|
return undefined;
|
|
614
821
|
const imported = ctx.importedResource?.(v);
|
|
@@ -618,7 +825,135 @@ function importedUnextractedFieldId(v, owner, ctx, site) {
|
|
|
618
825
|
const importedKey = fieldKeyFromTfValue(importedRef, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
619
826
|
if (importedKey === undefined)
|
|
620
827
|
return undefined;
|
|
621
|
-
return unextractedFieldId(importedRef, importedKey, owner, ctx, site) === v ? v : undefined;
|
|
828
|
+
return unextractedFieldId(importedRef, importedKey, owner, ctx, site, failClosed) === v ? v : undefined;
|
|
829
|
+
}
|
|
830
|
+
/** The kept id, else the caller's key; undefined, never the key, when this reference failed closed. */
|
|
831
|
+
function keptIdOrKey(kept, fieldKey) {
|
|
832
|
+
return kept === FAILED_CLOSED ? undefined : kept ?? fieldKey;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* The value to author for a field reference outside views (#1966):
|
|
836
|
+
* `fieldKey` is what the caller resolved the reference to, if anything. A
|
|
837
|
+
* field pull did not extract keeps its platform id; otherwise the caller's
|
|
838
|
+
* key stands. Undefined when nothing resolves, or when this reference failed
|
|
839
|
+
* closed: no id is known, which fails the pull with an authoring blocker
|
|
840
|
+
* naming `site`, which must start with the holding resource's address (#1978).
|
|
841
|
+
* The result never depends on another reference's blocker at the same site.
|
|
842
|
+
* Clone drops import blocks, so it keeps the export's dropped id only for
|
|
843
|
+
* another owner's field and fails the same way for any other (#1990). A kept
|
|
844
|
+
* id is reported once per field, naming every site.
|
|
845
|
+
*/
|
|
846
|
+
export function unextractedFieldRefId(v, fieldKey, owner, ctx, site) {
|
|
847
|
+
if (fieldKey !== undefined)
|
|
848
|
+
return keptIdOrKey(unextractedFieldId(v, fieldKey, owner, ctx, site, true), fieldKey);
|
|
849
|
+
const ownData = ownDataFieldRef(v, owner, ctx, site, true);
|
|
850
|
+
if (ownData !== undefined)
|
|
851
|
+
return authoredRef(ownData);
|
|
852
|
+
return typeof v === "string" && PLATFORM_ID.test(v) ? authoredRef(bareFieldIdRef(v, owner, ctx, site)) : undefined;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* A bare platform-id field reference no key resolves: what an export writes
|
|
856
|
+
* when it can't name the field (#1991). It resolves through the import that
|
|
857
|
+
* names the id (in a clone, the source export's dropped one) to the field's
|
|
858
|
+
* key, or to the kept id of a field pull did not extract (another owner's,
|
|
859
|
+
* in a clone). Anything else fails the pull or clone with an authoring
|
|
860
|
+
* blocker naming `site` and the id, instead of dropping the entry or, in a
|
|
861
|
+
* clone, leaving the source app's id in place. Views outside a clone keep
|
|
862
|
+
* a bare id as is (#1178) and don't come here.
|
|
863
|
+
*/
|
|
864
|
+
function bareFieldIdRef(v, owner, ctx, site) {
|
|
865
|
+
const imported = ctx.importedResource?.(v);
|
|
866
|
+
if (imported !== undefined) {
|
|
867
|
+
const ref = expr.resourceAttr(imported.type, imported.label, ["id"]);
|
|
868
|
+
const key = fieldKeyFromTfValue(ref, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope ?? "app", ctx);
|
|
869
|
+
if (key !== undefined) {
|
|
870
|
+
// A reference that failed closed never hands back the key, so nothing
|
|
871
|
+
// can author a field the clone doesn't have. Only this call's own
|
|
872
|
+
// result decides it, not blockers other references left at the site.
|
|
873
|
+
const kept = unextractedFieldId(ref, key, owner, ctx, site, true);
|
|
874
|
+
return kept === FAILED_CLOSED ? FAILED_CLOSED : kept ?? key;
|
|
875
|
+
}
|
|
876
|
+
if (ctx.cloning !== undefined) {
|
|
877
|
+
const kept = cloneKeptFieldId(ref, `${imported.type}.${imported.label}`, owner, ctx);
|
|
878
|
+
if (typeof kept === "string") {
|
|
879
|
+
reportUnextractedField(ctx, `${imported.type}.${imported.label}`, kept, site, true);
|
|
880
|
+
owner.unextractedFieldIds?.add(kept);
|
|
881
|
+
return kept;
|
|
882
|
+
}
|
|
883
|
+
reportUnresolvableUnextractedField(ctx, `${imported.type}.${imported.label}`, site, kept.reason);
|
|
884
|
+
return FAILED_CLOSED;
|
|
885
|
+
}
|
|
886
|
+
// Pull: the export names the id, so it is the platform's own; keep it.
|
|
887
|
+
ctx.diagnostics.push(`${site}: field id ${v} is imported as ${imported.type}.${imported.label}, not a field of this owner; kept as is`);
|
|
888
|
+
return v;
|
|
889
|
+
}
|
|
890
|
+
reportUnimportedBareFieldId(v, ctx, site);
|
|
891
|
+
return FAILED_CLOSED;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* A bare platform-id field reference on another owner's side: a widget column
|
|
895
|
+
* whose target is another app or element, or a relationship's related field
|
|
896
|
+
* (#1991). `foreignOwner` names that owner when it is not this one, so the id
|
|
897
|
+
* is its field and keeps its platform id (Dax, 11:45). An id the export
|
|
898
|
+
* imports is checked through its field block instead: in a clone, a field of
|
|
899
|
+
* the source app fails and another owner's keeps its id (#1990); in pull, it
|
|
900
|
+
* is the platform's own and stays as is. With no foreign owner and no import,
|
|
901
|
+
* it fails like `bareFieldIdRef`, naming `site` and the id.
|
|
902
|
+
*/
|
|
903
|
+
export function bareForeignFieldIdRef(v, owner, ctx, site, foreignOwner) {
|
|
904
|
+
const imported = ctx.importedResource?.(v);
|
|
905
|
+
if (imported !== undefined) {
|
|
906
|
+
const field = `${imported.type}.${imported.label}`;
|
|
907
|
+
if (ctx.cloning !== undefined) {
|
|
908
|
+
const kept = cloneKeptFieldId(expr.resourceAttr(imported.type, imported.label, ["id"]), field, owner, ctx);
|
|
909
|
+
if (typeof kept === "string") {
|
|
910
|
+
reportUnextractedField(ctx, field, kept, site, true);
|
|
911
|
+
owner.unextractedFieldIds?.add(kept);
|
|
912
|
+
return kept;
|
|
913
|
+
}
|
|
914
|
+
reportUnresolvableUnextractedField(ctx, field, site, kept.reason);
|
|
915
|
+
return undefined;
|
|
916
|
+
}
|
|
917
|
+
ctx.diagnostics.push(`${site}: field id ${v} is imported as ${field}, not a field of ${foreignOwner ?? "this owner"}; kept as is`);
|
|
918
|
+
return v;
|
|
919
|
+
}
|
|
920
|
+
if (foreignOwner !== undefined) {
|
|
921
|
+
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`);
|
|
922
|
+
owner.unextractedFieldIds?.add(v);
|
|
923
|
+
return v;
|
|
924
|
+
}
|
|
925
|
+
reportUnimportedBareFieldId(v, ctx, site);
|
|
926
|
+
return undefined;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* The blocker for a bare field id no import names (#1991). In a clone whose
|
|
930
|
+
* live system-field read failed, the id may be one of the source app's
|
|
931
|
+
* system fields, so the message names that read instead (#1492).
|
|
932
|
+
*/
|
|
933
|
+
function reportUnimportedBareFieldId(v, ctx, site) {
|
|
934
|
+
const address = site.split(".").slice(0, 2).join(".");
|
|
935
|
+
const readFailure = ctx.cloning?.systemFieldReadFailure;
|
|
936
|
+
const description = ctx.cloning === undefined
|
|
937
|
+
? `${site} references field id ${v}, which no import in the export names, so pull cannot resolve it to a field`
|
|
938
|
+
: readFailure !== undefined
|
|
939
|
+
? `${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})`
|
|
940
|
+
: `${site} references field id ${v}, which no import in the source app's export names, so the clone cannot tell whose field it is`;
|
|
941
|
+
if (ctx.authoringBlockers?.some((blocker) => blocker.description === description) === true)
|
|
942
|
+
return;
|
|
943
|
+
const remedy = ctx.cloning === undefined
|
|
944
|
+
? UNRESOLVABLE_UNEXTRACTED_FIELD_REMEDY
|
|
945
|
+
: readFailure !== undefined
|
|
946
|
+
? "Fix the failed system-field read (check the profile's access to the source app) and run the clone again."
|
|
947
|
+
: UNRESOLVABLE_CLONE_FIELD_REMEDY;
|
|
948
|
+
reportAuthoringBlocker(ctx, { address, description, remedy });
|
|
949
|
+
}
|
|
950
|
+
/** Whether `v` is a bare platform id, the shape an export writes for a field it can't name (#1991). */
|
|
951
|
+
export function isBarePlatformId(v) {
|
|
952
|
+
return PLATFORM_ID.test(v);
|
|
953
|
+
}
|
|
954
|
+
/** Whether `fieldKey` names a field of this owner that pull did not extract (system keys never count). */
|
|
955
|
+
export function isUnextractedFieldKey(fieldKey, owner) {
|
|
956
|
+
return owner.fieldKeys !== undefined && !owner.fieldKeys.has(fieldKey) && !isOwnerSystemFieldKey(fieldKey, owner);
|
|
622
957
|
}
|
|
623
958
|
/**
|
|
624
959
|
* Records a raw platform id that a caller keeps as is (a sort order, a blocks
|
|
@@ -634,9 +969,34 @@ function noteRawUnextractedFieldId(v, owner, ctx, site) {
|
|
|
634
969
|
else
|
|
635
970
|
importedUnextractedFieldId(v, owner, ctx, site);
|
|
636
971
|
}
|
|
637
|
-
/**
|
|
972
|
+
/**
|
|
973
|
+
* The key of this owner's own field a raw platform id names, when pull
|
|
974
|
+
* extracted it (#2155): by its state identity, else by the import that names
|
|
975
|
+
* it. A system field counts only with `systemKeys` (it has no import), and
|
|
976
|
+
* not when a custom field of the owner shares its key. Any other id is
|
|
977
|
+
* undefined, and so is every id in a clone, whose ids are the
|
|
978
|
+
* source app's.
|
|
979
|
+
*/
|
|
980
|
+
function ownExtractedFieldKey(v, owner, ctx, systemKeys) {
|
|
981
|
+
if (ctx.cloning !== undefined || !PLATFORM_ID.test(v))
|
|
982
|
+
return undefined;
|
|
983
|
+
const ownerRefName = tfLabelToTsLabel(owner.label);
|
|
984
|
+
const scope = owner.scope ?? "app";
|
|
985
|
+
const imported = ctx.importedResource?.(v);
|
|
986
|
+
const key = fieldKeyFromTfValue(v, ownerRefName, owner.ownerTfLabel, scope, ctx)
|
|
987
|
+
?? (imported === undefined ? undefined : fieldKeyFromTfValue(expr.resourceAttr(imported.type, imported.label, ["id"]), ownerRefName, owner.ownerTfLabel, scope, ctx));
|
|
988
|
+
if (key === undefined)
|
|
989
|
+
return undefined;
|
|
990
|
+
// A custom field may own a system key (an element's createdAt); build
|
|
991
|
+
// resolves that key to the platform field, which would retarget the
|
|
992
|
+
// reference, so its id stays raw (as selfSystemField does).
|
|
993
|
+
if (isOwnerSystemFieldKey(key, owner))
|
|
994
|
+
return systemKeys && imported === undefined && !ownerMayHaveCustomField(owner, key, ctx) ? key : undefined;
|
|
995
|
+
return owner.fieldKeys?.has(key) === true ? key : undefined;
|
|
996
|
+
}
|
|
997
|
+
/** One diagnostic per unextracted field per pull, naming every site that references it (#1736, #1966). */
|
|
638
998
|
const unextractedFieldReports = new WeakMap();
|
|
639
|
-
function reportUnextractedField(ctx, field, id, site) {
|
|
999
|
+
function reportUnextractedField(ctx, field, id, site, outsideViews) {
|
|
640
1000
|
let byField = unextractedFieldReports.get(ctx.diagnostics);
|
|
641
1001
|
if (byField === undefined) {
|
|
642
1002
|
byField = new Map();
|
|
@@ -644,16 +1004,28 @@ function reportUnextractedField(ctx, field, id, site) {
|
|
|
644
1004
|
}
|
|
645
1005
|
let report = byField.get(field);
|
|
646
1006
|
if (report === undefined) {
|
|
647
|
-
report = { index: ctx.diagnostics.length, sites: [] };
|
|
1007
|
+
report = { index: ctx.diagnostics.length, sites: [], outsideViews: false };
|
|
648
1008
|
byField.set(field, report);
|
|
649
1009
|
ctx.diagnostics.push("");
|
|
650
1010
|
}
|
|
651
1011
|
if (!report.sites.includes(site))
|
|
652
1012
|
report.sites.push(site);
|
|
1013
|
+
report.outsideViews ||= outsideViews;
|
|
653
1014
|
const sites = report.sites.join(", ");
|
|
1015
|
+
// Views and dashboard widget sorts share this report, so name what holds
|
|
1016
|
+
// the reference: a view, a dashboard widget, or several kinds of site.
|
|
1017
|
+
const onDashboard = report.sites.filter((s) => s.startsWith(`${DASHBOARD_WIDGET_RESOURCE_TYPE}.`)).length;
|
|
1018
|
+
const holder = report.outsideViews || (onDashboard > 0 && onDashboard < report.sites.length)
|
|
1019
|
+
? undefined
|
|
1020
|
+
: onDashboard > 0 ? "dashboard widget" : "view";
|
|
654
1021
|
ctx.diagnostics[report.index] = id !== undefined
|
|
655
|
-
?
|
|
656
|
-
|
|
1022
|
+
? ctx.cloning !== undefined
|
|
1023
|
+
// A clone keeps only another owner's field, which exists without it (#1990).
|
|
1024
|
+
? `field ${field} belongs to another app, element or task, so the clone does not copy it; kept as its platform id ${id} at ${sites}`
|
|
1025
|
+
: `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)`
|
|
1026
|
+
// Only a view or dashboard widget sort outside a clone gets here;
|
|
1027
|
+
// anywhere else, and in a clone, that fails (#1978, #1990).
|
|
1028
|
+
: `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
1029
|
}
|
|
658
1030
|
function listViewFromTf(block, owner, ctx) {
|
|
659
1031
|
const label = block.label;
|
|
@@ -742,9 +1114,11 @@ export function managedViewSortFromTf(value, owner, where, ctx) {
|
|
|
742
1114
|
}
|
|
743
1115
|
const rawField = order["field"];
|
|
744
1116
|
const site = `${where} sort.orders[${index}].field`;
|
|
745
|
-
|
|
1117
|
+
// A clone resolves a bare id like any field reference (#1991).
|
|
1118
|
+
const cloningBareId = typeof rawField === "string" && ctx.cloning !== undefined && PLATFORM_ID.test(rawField);
|
|
1119
|
+
if (typeof rawField === "string" && !cloningBareId)
|
|
746
1120
|
noteRawUnextractedFieldId(rawField, owner, ctx, site);
|
|
747
|
-
const field = typeof rawField === "string"
|
|
1121
|
+
const field = typeof rawField === "string" && !cloningBareId
|
|
748
1122
|
? (PLATFORM_ID.test(rawField) ? rawField : undefined)
|
|
749
1123
|
: fieldRefFromTf(rawField, owner, ctx, site);
|
|
750
1124
|
if (field === undefined) {
|
|
@@ -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,11 @@ export const viewModule = {
|
|
|
55
56
|
stubRef: (refName, parent) => ({ __kind: "view", refName, name: refName, parent }),
|
|
56
57
|
refFromAuthoring: () => undefined,
|
|
57
58
|
},
|
|
59
|
+
portable: {
|
|
60
|
+
leaveOut: [
|
|
61
|
+
{ resourceType: LIST_VIEW_RESOURCE_TYPE, select: selectPlatformDefaultViews, reason: "the platform creates it with its app or element" },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
58
64
|
};
|
|
59
65
|
/**
|
|
60
66
|
* `elementum_managed_view_order` is a singleton per aspect with no identity
|
|
@@ -80,9 +86,18 @@ export const managedViewOrderModule = {
|
|
|
80
86
|
// The provider leaves the platform's default "List" view out of an order
|
|
81
87
|
// whose state doesn't list it (#1598); the export always lists it (#1658).
|
|
82
88
|
stateScopedPlatformEntries: [{ attribute: "view_ids", name: PLATFORM_DEFAULT_LIST_VIEW_NAME }],
|
|
89
|
+
// The platform has no record of the request to delete its default "List"
|
|
90
|
+
// view, so the export never carries it. A re-pull fills it from state only
|
|
91
|
+
// while it is `true` (set in source); omitted means `false` and is not
|
|
92
|
+
// printed. A fresh adopt has no state, so it drops from source (#1773).
|
|
93
|
+
unreadableAttributes: ["delete_platform_default_list_view"],
|
|
83
94
|
},
|
|
84
95
|
data: NO_DATA,
|
|
85
96
|
lifecycle: NO_LIFECYCLE,
|
|
86
97
|
canvas: NO_CANVAS,
|
|
87
98
|
catalog: NO_CATALOG,
|
|
99
|
+
// Build writes no order when the owner has no authored views.
|
|
100
|
+
portable: {
|
|
101
|
+
leaveOutWhenEmptied: [{ resourceType: MANAGED_VIEW_ORDER_RESOURCE_TYPE, attribute: "view_ids", reason: "it only ordered the left-out view" }],
|
|
102
|
+
},
|
|
88
103
|
};
|
|
@@ -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
|
}
|