@elementumai/edk 0.12.0 → 0.13.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 +2 -0
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +2 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +10 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +7 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
- package/dist-sdk/src/engine/pull/stream-root.js +563 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +18 -3
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
- package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
- package/dist-sdk/src/entities/agent/from-tf.js +262 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
- package/dist-sdk/src/entities/agent/to-tf.js +158 -14
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +33 -13
- package/dist-sdk/src/entities/app/build.js +14 -12
- package/dist-sdk/src/entities/app/from-tf.js +24 -9
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
- package/dist-sdk/src/entities/app/stage-keys.js +3 -3
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +20 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +593 -101
- package/dist-sdk/src/entities/automation/index.d.ts +1 -0
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +33 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
- package/dist-sdk/src/entities/automation/tasks.js +34 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/automation/to-tf.js +337 -77
- package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
- package/dist-sdk/src/entities/automation/triggers.js +26 -11
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.js +3 -0
- package/dist-sdk/src/entities/chart/to-tf.js +19 -2
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.js +15 -2
- package/dist-sdk/src/entities/element/module.js +3 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
- package/dist-sdk/src/entities/field/from-tf.js +99 -6
- package/dist-sdk/src/entities/field/module.js +4 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/field/to-tf.js +33 -12
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +4 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
- package/dist-sdk/src/entities/shared/filters/index.js +18 -6
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.js +9 -5
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +2 -1
- package/dist-sdk/src/entities/view/from-tf.js +7 -4
- package/dist-sdk/src/entities/widget/from-tf.js +13 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +5 -0
- package/dist-sdk/src/graph/index.js +7 -0
- package/dist-sdk/src/graph/modules.js +11 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +78 -6
- package/package.json +6 -3
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream-root ORCHESTRATOR: the typed blocks of an `ei <verb> export`
|
|
3
|
+
* stream → one extracted stream root (plan §7 M2). Owns traversal,
|
|
4
|
+
* partition, and the stream-level lookups (data-source names, import-block
|
|
5
|
+
* ids); conversion lives on entity modules' lifecycle hooks.
|
|
6
|
+
*
|
|
7
|
+
* Posture (plan §6): resource kinds without extractors are REPORTED as
|
|
8
|
+
* skipped, never fatal. Structural breakage (zero or multiple root
|
|
9
|
+
* resources) is a loud error. Locals are ei's derived lookup maps —
|
|
10
|
+
* extraction never consumes them; build regenerates them.
|
|
11
|
+
*
|
|
12
|
+
* Kind switches live in the entity graph — this file walks TYPE_TO_KIND /
|
|
13
|
+
* lifecycle hooks and must not import entity modules (value or type).
|
|
14
|
+
*/
|
|
15
|
+
import { DATA_FACET_BY_TYPE, ENTITY_KIND_BY_ID, ownFileChildrenOf, } from "../../graph/index.js";
|
|
16
|
+
import { isTfExpr } from "../tf/index.js";
|
|
17
|
+
import { typedCoverageGap } from "../coverage-gaps.js";
|
|
18
|
+
import { authoringBlockedMessage } from "./context.js";
|
|
19
|
+
import { partitionStream } from "./partition.js";
|
|
20
|
+
import { resourcesInSource } from "./source-resources.js";
|
|
21
|
+
/**
|
|
22
|
+
* EDK-only export local listing live bindings the EDK cannot represent, keyed
|
|
23
|
+
* by the bound task's label. The resource carries a provider-valid `""` placeholder that is
|
|
24
|
+
* indistinguishable from a real empty string. Extraction turns each into an
|
|
25
|
+
* authoring blocker; a caller that authors the bound task must refuse with
|
|
26
|
+
* {@link assertAuthorable} rather than write `""` over the binding.
|
|
27
|
+
*/
|
|
28
|
+
const UNSUPPORTED_BINDINGS_LOCAL_PREFIX = "edk_unsupported_bindings_";
|
|
29
|
+
/** Every unsupported binding the export marked, in document order. */
|
|
30
|
+
function unsupportedBindingsInDocument(doc) {
|
|
31
|
+
const bindings = [];
|
|
32
|
+
for (const block of doc.blocks) {
|
|
33
|
+
if (block.kind !== "locals")
|
|
34
|
+
continue;
|
|
35
|
+
for (const [key, value] of Object.entries(block.attrs)) {
|
|
36
|
+
if (!key.startsWith(UNSUPPORTED_BINDINGS_LOCAL_PREFIX))
|
|
37
|
+
continue;
|
|
38
|
+
const taskLabel = key.slice(UNSUPPORTED_BINDINGS_LOCAL_PREFIX.length);
|
|
39
|
+
const entries = Array.isArray(value) ? value : [];
|
|
40
|
+
const parsed = entries.flatMap((entry) => {
|
|
41
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry) || "$expr" in entry)
|
|
42
|
+
return [];
|
|
43
|
+
const text = (name) => (typeof entry[name] === "string" ? entry[name] : "");
|
|
44
|
+
return [{
|
|
45
|
+
taskLabel,
|
|
46
|
+
automation: text("automation"),
|
|
47
|
+
task: text("task"),
|
|
48
|
+
attribute: text("attribute"),
|
|
49
|
+
input: text("input"),
|
|
50
|
+
label: text("label"),
|
|
51
|
+
id: text("id"),
|
|
52
|
+
}];
|
|
53
|
+
});
|
|
54
|
+
// A malformed marker still counts: it only exists when export saw a binding.
|
|
55
|
+
bindings.push(...(parsed.length > 0
|
|
56
|
+
? parsed
|
|
57
|
+
: [{ taskLabel, automation: "", task: taskLabel, attribute: "", input: "", label: "", id: "" }]));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return bindings;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Marker attribute for an execute-script output schema nested deeper than
|
|
64
|
+
* ei export reads (a fixed depth: GraphQL cannot select a recursive type to
|
|
65
|
+
* unbounded depth). Export omits the truncated schema; `input` is the schema
|
|
66
|
+
* path of the node whose children it could not read.
|
|
67
|
+
*/
|
|
68
|
+
const OUTPUT_SCHEMA_DEPTH_ATTRIBUTE = "output_schema";
|
|
69
|
+
function isOutputSchemaDepthBinding(binding) {
|
|
70
|
+
return binding.attribute === OUTPUT_SCHEMA_DEPTH_ATTRIBUTE;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Marker attributes for a variable task whose platform `variables` list has
|
|
74
|
+
* more than one entry (edk#1398): `variables` on the task itself (one entry
|
|
75
|
+
* per variable beyond the first, `input` = its name) and `variable_reference`
|
|
76
|
+
* on a script input bound to one of those extra variables (`label` = the
|
|
77
|
+
* variable's name). The resource holds one variable, so the export would drop
|
|
78
|
+
* the others and an apply would delete them from the platform.
|
|
79
|
+
*/
|
|
80
|
+
const MULTI_VARIABLE_TASK_ATTRIBUTE = "variables";
|
|
81
|
+
const MULTI_VARIABLE_REFERENCE_ATTRIBUTE = "variable_reference";
|
|
82
|
+
function isMultiVariableBinding(binding) {
|
|
83
|
+
return binding.attribute === MULTI_VARIABLE_TASK_ATTRIBUTE || binding.attribute === MULTI_VARIABLE_REFERENCE_ATTRIBUTE;
|
|
84
|
+
}
|
|
85
|
+
/** The remedy every multi-variable variable task blocker shares. */
|
|
86
|
+
const MULTI_VARIABLE_REMEDY = "Variable tasks that create or update more than one variable are not supported yet (elementum-fde/edk#1398). " +
|
|
87
|
+
"Split the task in the Elementum UI into one variable task per variable, then pull again.";
|
|
88
|
+
/** One line per binding: automation, task, input, platform label and id. */
|
|
89
|
+
function describeUnsupportedBinding(binding) {
|
|
90
|
+
if (binding.attribute === MULTI_VARIABLE_TASK_ATTRIBUTE) {
|
|
91
|
+
return `automation ${JSON.stringify(binding.automation)}, variable task ${JSON.stringify(binding.task)}: ` +
|
|
92
|
+
`also sets variable ${JSON.stringify(binding.input)}`;
|
|
93
|
+
}
|
|
94
|
+
if (binding.attribute === MULTI_VARIABLE_REFERENCE_ATTRIBUTE) {
|
|
95
|
+
return `automation ${JSON.stringify(binding.automation)}, task ${JSON.stringify(binding.task)}, ` +
|
|
96
|
+
`input ${JSON.stringify(binding.input)}: bound to variable ${JSON.stringify(binding.label)}, ` +
|
|
97
|
+
"which a variable task sets alongside other variables";
|
|
98
|
+
}
|
|
99
|
+
if (isOutputSchemaDepthBinding(binding)) {
|
|
100
|
+
return `automation ${JSON.stringify(binding.automation)}, task ${JSON.stringify(binding.task)}: ` +
|
|
101
|
+
`output schema node ${JSON.stringify(binding.input)} nests deeper than ei export reads`;
|
|
102
|
+
}
|
|
103
|
+
const boundTo = [
|
|
104
|
+
binding.label === "" ? "a source the EDK cannot represent" : JSON.stringify(binding.label),
|
|
105
|
+
...(binding.id === "" ? [] : [`(value reference id ${JSON.stringify(binding.id)})`]),
|
|
106
|
+
].join(" ");
|
|
107
|
+
return `automation ${JSON.stringify(binding.automation)}, task ${JSON.stringify(binding.task)}, ` +
|
|
108
|
+
`input ${JSON.stringify(binding.input)}: bound to ${boundTo}`;
|
|
109
|
+
}
|
|
110
|
+
/** The own-file kind whose tasks carry unsupported-binding markers. */
|
|
111
|
+
const AUTOMATION_KIND = "automation";
|
|
112
|
+
/** The remedy every unsupported-binding blocker shares. */
|
|
113
|
+
const UNSUPPORTED_BINDING_REMEDY = "Rebind these inputs in the Elementum UI to a supported source, then pull again.";
|
|
114
|
+
/** The remedy every output-schema depth blocker shares. */
|
|
115
|
+
const OUTPUT_SCHEMA_DEPTH_REMEDY = "Flatten these output schemas in the Elementum UI, then pull again.";
|
|
116
|
+
/** Automation task resource label → its address. */
|
|
117
|
+
function taskAddressByLabel(resources, taskTypes) {
|
|
118
|
+
const byLabel = new Map();
|
|
119
|
+
for (const [address, block] of resources) {
|
|
120
|
+
if (block.label !== undefined && taskTypes.has(block.type ?? ""))
|
|
121
|
+
byLabel.set(block.label, address);
|
|
122
|
+
}
|
|
123
|
+
return byLabel;
|
|
124
|
+
}
|
|
125
|
+
/** One unsupported binding as an authoring blocker on its task's resource. */
|
|
126
|
+
function unsupportedBindingBlocker(binding, taskAddressByLabel) {
|
|
127
|
+
const address = taskAddressByLabel.get(binding.taskLabel) ?? binding.taskLabel;
|
|
128
|
+
if (isMultiVariableBinding(binding)) {
|
|
129
|
+
return {
|
|
130
|
+
address,
|
|
131
|
+
description: `${describeUnsupportedBinding(binding)}; the EDK represents one variable per variable task, so pulling ` +
|
|
132
|
+
"would drop the others and the next apply would delete them from the platform",
|
|
133
|
+
remedy: MULTI_VARIABLE_REMEDY,
|
|
134
|
+
ownFileKind: AUTOMATION_KIND,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (isOutputSchemaDepthBinding(binding)) {
|
|
138
|
+
return {
|
|
139
|
+
address,
|
|
140
|
+
description: `${describeUnsupportedBinding(binding)}, so the levels below it are unknown; ` +
|
|
141
|
+
"pulling would author the schema without them, and the next apply would delete them from the platform",
|
|
142
|
+
remedy: OUTPUT_SCHEMA_DEPTH_REMEDY,
|
|
143
|
+
ownFileKind: AUTOMATION_KIND,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
address,
|
|
148
|
+
description: `${describeUnsupportedBinding(binding)}${binding.label === "" ? "" : ", a source the EDK cannot represent"}; ` +
|
|
149
|
+
"pulling would author an empty value in its place, and the next apply would replace the binding with it",
|
|
150
|
+
remedy: UNSUPPORTED_BINDING_REMEDY,
|
|
151
|
+
ownFileKind: AUTOMATION_KIND,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export class StreamRootExtractError extends Error {
|
|
155
|
+
constructor(message) {
|
|
156
|
+
super(message);
|
|
157
|
+
this.name = "StreamRootExtractError";
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Source that cannot be authored without changing live configuration. */
|
|
161
|
+
export class AuthoringBlockedError extends StreamRootExtractError {
|
|
162
|
+
blockers;
|
|
163
|
+
constructor(blockers, command = "pull") {
|
|
164
|
+
super(authoringBlockedMessage(blockers, command));
|
|
165
|
+
this.name = "AuthoringBlockedError";
|
|
166
|
+
this.blockers = blockers;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Refuse to author source over live configuration it cannot reproduce. Call
|
|
171
|
+
* it with the blockers of everything the caller is about to write (usually
|
|
172
|
+
* `extract.authoringBlockers`), before any source is written.
|
|
173
|
+
*/
|
|
174
|
+
export function assertAuthorable(blockers, command = "pull") {
|
|
175
|
+
if (blockers.length > 0)
|
|
176
|
+
throw new AuthoringBlockedError(blockers, command);
|
|
177
|
+
}
|
|
178
|
+
/** Read resource address → platform identity from the export's import blocks. */
|
|
179
|
+
export function importIdsFromDocument(doc) {
|
|
180
|
+
const importIds = new Map();
|
|
181
|
+
for (const block of doc.blocks) {
|
|
182
|
+
if (block.kind !== "import")
|
|
183
|
+
continue;
|
|
184
|
+
const id = block.attrs["id"];
|
|
185
|
+
const to = block.attrs["to"];
|
|
186
|
+
if (typeof id === "string" &&
|
|
187
|
+
isTfExpr(to) &&
|
|
188
|
+
to.$expr === "resource-attr" &&
|
|
189
|
+
to.path.length === 0) {
|
|
190
|
+
importIds.set(`${to.type}.${to.label}`, id);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return importIds;
|
|
194
|
+
}
|
|
195
|
+
export function extractStreamRoot(doc, kindId, opts = {}) {
|
|
196
|
+
const skipped = [];
|
|
197
|
+
const releaseIfManaged = [];
|
|
198
|
+
const requiresExtracted = [];
|
|
199
|
+
const diagnostics = [];
|
|
200
|
+
const reports = [];
|
|
201
|
+
const authoringBlockers = [];
|
|
202
|
+
const dataNames = new Map();
|
|
203
|
+
const dataRefs = new Map();
|
|
204
|
+
const dataAttrs = new Map();
|
|
205
|
+
const importIds = new Map(importIdsFromDocument(doc));
|
|
206
|
+
const resources = new Map();
|
|
207
|
+
const dependsOn = new Map();
|
|
208
|
+
const unresolvedForeignApps = new Set();
|
|
209
|
+
const unresolvedForeignElements = new Set();
|
|
210
|
+
// The provider exposes calculated-field result type as Computed-only. The
|
|
211
|
+
// exporter therefore carries it in EDK-only locals rather than writing an
|
|
212
|
+
// invalid resource attribute. Rehydrate that hint into the extractor's
|
|
213
|
+
// intermediate block; it never reaches Terraform configuration.
|
|
214
|
+
const calculationTypes = new Map();
|
|
215
|
+
const calculationTypePrefix = "edk_calculation_type_";
|
|
216
|
+
const calculationOutputs = new Map();
|
|
217
|
+
const calculationOutputsPrefix = "edk_calculation_outputs_";
|
|
218
|
+
const fieldResource = ENTITY_KIND_BY_ID.get("field")?.resource;
|
|
219
|
+
const calculatedFieldResourceType = fieldResource?.shape === "subTypes"
|
|
220
|
+
? fieldResource.rows.find((row) => row.key === "calculated")?.resourceType
|
|
221
|
+
: undefined;
|
|
222
|
+
const automationResource = ENTITY_KIND_BY_ID.get(AUTOMATION_KIND)?.resource;
|
|
223
|
+
const automationTaskResourceTypes = new Set(automationResource?.shape === "composite"
|
|
224
|
+
? automationResource.members.filter((member) => member.role === "task").map((member) => member.resourceType)
|
|
225
|
+
: []);
|
|
226
|
+
const unsupportedBindings = unsupportedBindingsInDocument(doc);
|
|
227
|
+
for (const block of doc.blocks) {
|
|
228
|
+
if (block.kind !== "locals")
|
|
229
|
+
continue;
|
|
230
|
+
for (const [key, value] of Object.entries(block.attrs)) {
|
|
231
|
+
if (key.startsWith(calculationTypePrefix) && typeof value === "string") {
|
|
232
|
+
calculationTypes.set(key.slice(calculationTypePrefix.length), value);
|
|
233
|
+
}
|
|
234
|
+
if (key.startsWith(calculationOutputsPrefix) && Array.isArray(value)) {
|
|
235
|
+
const outputs = new Map();
|
|
236
|
+
for (const item of value) {
|
|
237
|
+
if (typeof item === "object" && item !== null && !Array.isArray(item) && !("$expr" in item) &&
|
|
238
|
+
typeof item.variable_name === "string") {
|
|
239
|
+
outputs.set(item.variable_name, item);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
calculationOutputs.set(key.slice(calculationOutputsPrefix.length), outputs);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const augmentedDoc = {
|
|
247
|
+
blocks: doc.blocks.map((block) => {
|
|
248
|
+
if (block.kind !== "resource" || block.label === undefined) {
|
|
249
|
+
return block;
|
|
250
|
+
}
|
|
251
|
+
if (block.type === calculatedFieldResourceType) {
|
|
252
|
+
const calculationType = calculationTypes.get(block.label);
|
|
253
|
+
return calculationType === undefined
|
|
254
|
+
? block
|
|
255
|
+
: { ...block, attrs: { ...block.attrs, calculation_type: calculationType } };
|
|
256
|
+
}
|
|
257
|
+
if (automationTaskResourceTypes.has(block.type ?? "") && Array.isArray(block.attrs.calculations)) {
|
|
258
|
+
const outputs = calculationOutputs.get(block.label);
|
|
259
|
+
if (outputs === undefined)
|
|
260
|
+
return block;
|
|
261
|
+
const calculations = block.attrs.calculations.map((calculation) => {
|
|
262
|
+
if (typeof calculation !== "object" || calculation === null || Array.isArray(calculation) ||
|
|
263
|
+
"$expr" in calculation || typeof calculation.variable_name !== "string") {
|
|
264
|
+
return calculation;
|
|
265
|
+
}
|
|
266
|
+
const output = outputs.get(calculation.variable_name);
|
|
267
|
+
return output === undefined ? calculation : {
|
|
268
|
+
...calculation,
|
|
269
|
+
output_type: output.output_type,
|
|
270
|
+
multiple: output.multiple,
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
return { ...block, attrs: { ...block.attrs, calculations } };
|
|
274
|
+
}
|
|
275
|
+
return block;
|
|
276
|
+
}),
|
|
277
|
+
};
|
|
278
|
+
for (const block of augmentedDoc.blocks) {
|
|
279
|
+
switch (block.kind) {
|
|
280
|
+
case "resource": {
|
|
281
|
+
const type = block.type;
|
|
282
|
+
const label = block.label;
|
|
283
|
+
if (type === undefined || label === undefined)
|
|
284
|
+
break;
|
|
285
|
+
resources.set(`${type}.${label}`, block);
|
|
286
|
+
const dependsOnAttr = block.attrs["depends_on"];
|
|
287
|
+
if (!Array.isArray(dependsOnAttr))
|
|
288
|
+
break;
|
|
289
|
+
const refs = [];
|
|
290
|
+
for (const v of dependsOnAttr) {
|
|
291
|
+
if (isTfExpr(v) && v.$expr === "resource-attr" && v.path.length === 0) {
|
|
292
|
+
refs.push(`${v.type}.${v.label}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (refs.length > 0)
|
|
296
|
+
dependsOn.set(`${type}.${label}`, refs);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
case "data": {
|
|
300
|
+
const type = block.type ?? "";
|
|
301
|
+
dataAttrs.set(`${type}.${block.label ?? ""}`, block.attrs);
|
|
302
|
+
const data = DATA_FACET_BY_TYPE.get(type)?.data;
|
|
303
|
+
const lookupAttr = data?.participates === true ? data.lookupAttr : undefined;
|
|
304
|
+
if (lookupAttr === undefined) {
|
|
305
|
+
diagnostics.push(`unknown data source "${type}" in export stream — reference lookups for it are unavailable`);
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
if (lookupAttr === "") {
|
|
309
|
+
dataNames.set(`${type}.${block.label ?? ""}`, block.label ?? "");
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
const v = block.attrs[lookupAttr];
|
|
313
|
+
if (typeof v !== "string") {
|
|
314
|
+
// Some data facets support a more stable alternate selector (for
|
|
315
|
+
// example namespace). Raw attrs remain available to entity
|
|
316
|
+
// extractors; absence of the legacy display-name selector is not a
|
|
317
|
+
// malformed data block.
|
|
318
|
+
if (typeof block.attrs["namespace"] === "string")
|
|
319
|
+
break;
|
|
320
|
+
diagnostics.push(`data "${type}" "${block.label}": expected string attribute "${lookupAttr}", got ${JSON.stringify(v)}`);
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
dataNames.set(`${type}.${block.label ?? ""}`, v);
|
|
324
|
+
const providerRefAttr = data?.participates === true ? data.providerRefAttr : undefined;
|
|
325
|
+
if (providerRefAttr !== undefined) {
|
|
326
|
+
const refValue = block.attrs[providerRefAttr];
|
|
327
|
+
if (isTfExpr(refValue) && refValue.$expr === "data-attr" && refValue.path.length === 1 && refValue.path[0] === "id") {
|
|
328
|
+
dataRefs.set(`${type}.${block.label ?? ""}`, { resourceType: refValue.type, tfLabel: refValue.label });
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
diagnostics.push(`data "${type}" "${block.label}": expected "${providerRefAttr}" to be a data source reference, got ${JSON.stringify(refValue)}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
case "import": {
|
|
337
|
+
const id = block.attrs["id"];
|
|
338
|
+
const to = block.attrs["to"];
|
|
339
|
+
const address = isTfExpr(to) && to.$expr === "resource-attr" && to.path.length === 0
|
|
340
|
+
? `${to.type}.${to.label}`
|
|
341
|
+
: undefined;
|
|
342
|
+
if (typeof id !== "string" || address === undefined) {
|
|
343
|
+
diagnostics.push(`import block with an unrecognized shape (to ${JSON.stringify(to)}); skipped`);
|
|
344
|
+
}
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
default:
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const stream = partitionStream(augmentedDoc);
|
|
352
|
+
skipped.push(...stream.reported, ...stream.unknown);
|
|
353
|
+
// Import ids commonly include a type prefix (`type:id`) or path. Build the
|
|
354
|
+
// reverse index once rather than scanning every import for every decoded
|
|
355
|
+
// reference. Ambiguous leaves are deliberately unresolvable.
|
|
356
|
+
const addressByImportedLeaf = new Map();
|
|
357
|
+
const ambiguousImportedLeaves = new Set();
|
|
358
|
+
for (const [address, importedId] of importIds) {
|
|
359
|
+
const separator = Math.max(importedId.lastIndexOf(":"), importedId.lastIndexOf("/"));
|
|
360
|
+
const leaf = importedId.slice(separator + 1);
|
|
361
|
+
const prior = addressByImportedLeaf.get(leaf);
|
|
362
|
+
if (prior !== undefined && prior !== address) {
|
|
363
|
+
addressByImportedLeaf.delete(leaf);
|
|
364
|
+
ambiguousImportedLeaves.add(leaf);
|
|
365
|
+
}
|
|
366
|
+
else if (!ambiguousImportedLeaves.has(leaf)) {
|
|
367
|
+
addressByImportedLeaf.set(leaf, address);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const resourceAt = (address) => {
|
|
371
|
+
const block = resources.get(address);
|
|
372
|
+
return block?.type !== undefined && block.label !== undefined
|
|
373
|
+
? { type: block.type, label: block.label, attrs: block.attrs }
|
|
374
|
+
: undefined;
|
|
375
|
+
};
|
|
376
|
+
const rootModule = ENTITY_KIND_BY_ID.get(kindId);
|
|
377
|
+
const extractRoot = rootModule?.lifecycle.participates === true
|
|
378
|
+
? rootModule.lifecycle.extractStreamRoot
|
|
379
|
+
: undefined;
|
|
380
|
+
if (extractRoot === undefined) {
|
|
381
|
+
throw new StreamRootExtractError(`stream-root kind "${kindId}" has no lifecycle.extractStreamRoot`);
|
|
382
|
+
}
|
|
383
|
+
const ctx = {
|
|
384
|
+
dataName: (type, label) => dataNames.get(`${type}.${label}`),
|
|
385
|
+
dataRef: (type, label) => dataRefs.get(`${type}.${label}`),
|
|
386
|
+
dataAttrs: (type, label) => dataAttrs.get(`${type}.${label}`),
|
|
387
|
+
importId: (address) => importIds.get(address),
|
|
388
|
+
foreignAppRefNames: opts.appRefNames,
|
|
389
|
+
foreignElementRefNames: opts.elementRefNames,
|
|
390
|
+
foreignTaskRefNames: opts.taskRefNames,
|
|
391
|
+
foreignAppRefNamespaces: opts.appRefNamespaces,
|
|
392
|
+
foreignElementRefNamespaces: opts.elementRefNamespaces,
|
|
393
|
+
foreignTaskRefNamespaces: opts.taskRefNamespaces,
|
|
394
|
+
...(opts.selfAspectRef !== undefined ? { selfAspectRef: opts.selfAspectRef } : {}),
|
|
395
|
+
...(opts.cloning !== undefined ? { cloning: opts.cloning } : {}),
|
|
396
|
+
foreignFieldRefsById: opts.foreignFieldRefsById,
|
|
397
|
+
foreignFieldRefsByDataAddress: opts.foreignFieldRefsByDataAddress,
|
|
398
|
+
foreignSkillRefsByOwnerName: opts.foreignSkillRefsByOwnerName,
|
|
399
|
+
fieldNamesByOwnerRefName: opts.fieldNamesByOwnerRefName,
|
|
400
|
+
// Root and own-file extractors both print group refs (edk#1412).
|
|
401
|
+
groupKeysByName: opts.groupKeysByName,
|
|
402
|
+
...(opts.serviceAccountsById !== undefined && { serviceAccountsById: opts.serviceAccountsById }),
|
|
403
|
+
...(opts.omittedAutomationsById !== undefined && { omittedAutomationsById: opts.omittedAutomationsById }),
|
|
404
|
+
...(opts.platformCreatorPolicyIds !== undefined && { platformCreatorPolicyIds: opts.platformCreatorPolicyIds }),
|
|
405
|
+
unresolvedForeignRefs: { apps: unresolvedForeignApps, elements: unresolvedForeignElements },
|
|
406
|
+
importedResource: (id) => {
|
|
407
|
+
// Clone dropped the import blocks; the source export's still name the id (#1991).
|
|
408
|
+
const address = addressByImportedLeaf.get(id) ?? opts.cloning?.sourceImportedAddress?.(id);
|
|
409
|
+
return address === undefined ? undefined : resourceAt(address);
|
|
410
|
+
},
|
|
411
|
+
resourceByAddress: resourceAt,
|
|
412
|
+
resourcesOfType: (type) => [...resources.values()]
|
|
413
|
+
.filter((block) => block.type === type && block.label !== undefined)
|
|
414
|
+
.map((block) => ({ type: block.type, label: block.label, attrs: block.attrs })),
|
|
415
|
+
diagnostics,
|
|
416
|
+
reports,
|
|
417
|
+
skipped,
|
|
418
|
+
releaseIfManaged,
|
|
419
|
+
requiresExtracted,
|
|
420
|
+
authoringBlockers,
|
|
421
|
+
};
|
|
422
|
+
let root;
|
|
423
|
+
try {
|
|
424
|
+
root = extractRoot(stream, ctx);
|
|
425
|
+
}
|
|
426
|
+
catch (err) {
|
|
427
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
428
|
+
throw new StreamRootExtractError(message);
|
|
429
|
+
}
|
|
430
|
+
let rootInstance = root.instance;
|
|
431
|
+
const rootBlocks = stream.byKind.get(kindId) ?? [];
|
|
432
|
+
const rootLabel = rootBlocks[0]?.label ?? "";
|
|
433
|
+
const extractCtx = {
|
|
434
|
+
...ctx,
|
|
435
|
+
appTfLabel: rootLabel,
|
|
436
|
+
appRefName: rootInstance.refName,
|
|
437
|
+
parentScope: kindId === "element" ? "element" : "app",
|
|
438
|
+
...(opts.foreignFieldRefsById !== undefined && { foreignFieldRefsById: opts.foreignFieldRefsById }),
|
|
439
|
+
...(opts.foreignTableRefsById !== undefined && { foreignTableRefsById: opts.foreignTableRefsById }),
|
|
440
|
+
...(opts.foreignFileReaderRefsById !== undefined && { foreignFileReaderRefsById: opts.foreignFileReaderRefsById }),
|
|
441
|
+
...(opts.picklistOptionsByField !== undefined && { picklistOptionsByField: opts.picklistOptionsByField }),
|
|
442
|
+
...(opts.fieldNamesByOwnerRefName !== undefined && { fieldNamesByOwnerRefName: opts.fieldNamesByOwnerRefName }),
|
|
443
|
+
...(opts.procedureKeysByDiscriminator !== undefined && { procedureKeysByDiscriminator: opts.procedureKeysByDiscriminator }),
|
|
444
|
+
};
|
|
445
|
+
const ownFileByKind = new Map();
|
|
446
|
+
const adoptionAddressAliases = [];
|
|
447
|
+
const quarantineOwnFiles = [];
|
|
448
|
+
const validationFailures = [];
|
|
449
|
+
const settles = [];
|
|
450
|
+
const skippedOwners = new Map();
|
|
451
|
+
for (const child of ownFileChildrenOf(kindId)) {
|
|
452
|
+
const extract = child.lifecycle.participates ? child.lifecycle.extractOwnFile : undefined;
|
|
453
|
+
if (extract === undefined)
|
|
454
|
+
continue;
|
|
455
|
+
const ownBlocks = stream.byKind.get(child.kind) ?? [];
|
|
456
|
+
const result = extract(ownBlocks, stream, extractCtx);
|
|
457
|
+
ownFileByKind.set(child.kind, result.items);
|
|
458
|
+
skipped.push(...result.skipped);
|
|
459
|
+
releaseIfManaged.push(...(result.releaseIfManaged ?? []));
|
|
460
|
+
diagnostics.push(...result.diagnostics);
|
|
461
|
+
validationFailures.push(...(result.validations ?? []));
|
|
462
|
+
adoptionAddressAliases.push(...(result.adoptionAddressAliases ?? []));
|
|
463
|
+
quarantineOwnFiles.push(...(result.quarantineOwnFiles ?? []));
|
|
464
|
+
if (result.settleAfterExtract !== undefined)
|
|
465
|
+
settles.push(result.settleAfterExtract);
|
|
466
|
+
for (const { refName, addresses } of result.skippedOwnFiles ?? []) {
|
|
467
|
+
for (const address of addresses)
|
|
468
|
+
skippedOwners.set(address, { kind: child.kind, refName });
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
rootInstance = dropDependentsOfSkipped(rootInstance, ownFileByKind, requiresExtracted, new Set(resources.keys()), skipped, releaseIfManaged, diagnostics, reports, opts.keptOwnFile);
|
|
472
|
+
if (settles.length > 0) {
|
|
473
|
+
const settledRoot = rootInstance;
|
|
474
|
+
const inSource = resourcesInSource({
|
|
475
|
+
stream, rootKind: kindId, rootLabel, extractedKinds: new Set(ownFileByKind.keys()), skipped: new Set(skipped), skippedOwners,
|
|
476
|
+
...(opts.keptOwnFile !== undefined && { keptOwnFile: (kind, refName) => opts.keptOwnFile?.(settledRoot, kind, refName) === true }),
|
|
477
|
+
});
|
|
478
|
+
for (const settle of settles) {
|
|
479
|
+
const settled = settle(inSource);
|
|
480
|
+
quarantineOwnFiles.push(...settled.quarantineOwnFiles);
|
|
481
|
+
diagnostics.push(...settled.diagnostics);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const taskAddresses = taskAddressByLabel(resources, automationTaskResourceTypes);
|
|
485
|
+
return {
|
|
486
|
+
root: rootInstance,
|
|
487
|
+
ownFileByKind,
|
|
488
|
+
...(root.cloudLinkHandle !== undefined && { cloudLinkHandle: root.cloudLinkHandle }),
|
|
489
|
+
skipped,
|
|
490
|
+
...(releaseIfManaged.length > 0 && { releaseIfManaged }),
|
|
491
|
+
...(quarantineOwnFiles.length > 0 && { quarantineOwnFiles }),
|
|
492
|
+
diagnostics,
|
|
493
|
+
validationFailures,
|
|
494
|
+
reports,
|
|
495
|
+
importIds,
|
|
496
|
+
adoptionAddressAliases,
|
|
497
|
+
dependsOn,
|
|
498
|
+
unresolvedForeignRefs: { apps: [...unresolvedForeignApps], elements: [...unresolvedForeignElements] },
|
|
499
|
+
authoringBlockers: [
|
|
500
|
+
...authoringBlockers,
|
|
501
|
+
...unsupportedBindings.map((binding) => unsupportedBindingBlocker(binding, taskAddresses)),
|
|
502
|
+
],
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
/** App-stream convenience alias — same as `extractStreamRoot(doc, "app")`. */
|
|
506
|
+
export function extractApp(doc, opts = {}) {
|
|
507
|
+
return extractStreamRoot(doc, "app", opts);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* #1731: a resource that cannot be authored without an own-file resource (a
|
|
511
|
+
* chart widget and its chart, a skill tool and the automation it runs) must
|
|
512
|
+
* not stay adopted when the build will not emit it, or the next plan destroys
|
|
513
|
+
* it. It is pruned from the root or its own-file item, skipped, and released from
|
|
514
|
+
* state when its reference is unresolved (a raw id or data source), when the
|
|
515
|
+
* required resource is missing from the export, or when pull skipped that
|
|
516
|
+
* resource and no authored file for it is kept.
|
|
517
|
+
*
|
|
518
|
+
* When pull skipped the required resource but keeps its authored file (a
|
|
519
|
+
* re-pull, where the own-file sweep preserves files while a sibling is
|
|
520
|
+
* skipped), build still emits both, so the dependent stays in source and
|
|
521
|
+
* adoption keeps managing it (SF3). That outcome is reported on the
|
|
522
|
+
* informational `reports` channel, not as a coverage gap: nothing is lost.
|
|
523
|
+
*/
|
|
524
|
+
function dropDependentsOfSkipped(root, ownFileByKind, requirements, streamAddresses, skipped, releaseIfManaged, diagnostics, reports, keptOwnFile) {
|
|
525
|
+
const skippedSet = new Set(skipped);
|
|
526
|
+
let pruned = root;
|
|
527
|
+
for (const requirement of requirements) {
|
|
528
|
+
if (skippedSet.has(requirement.address))
|
|
529
|
+
continue;
|
|
530
|
+
const reason = unbuildableReason(requirement, root, streamAddresses, skippedSet, keptOwnFile, reports);
|
|
531
|
+
if (reason === undefined)
|
|
532
|
+
continue;
|
|
533
|
+
pruned = requirement.prune(pruned);
|
|
534
|
+
const ownFile = requirement.pruneOwnFile;
|
|
535
|
+
if (ownFile !== undefined)
|
|
536
|
+
ownFileByKind.set(ownFile.kind, ownFile.prune(ownFileByKind.get(ownFile.kind) ?? []));
|
|
537
|
+
skipped.push(requirement.address);
|
|
538
|
+
skippedSet.add(requirement.address);
|
|
539
|
+
releaseIfManaged.push(requirement.address);
|
|
540
|
+
diagnostics.push(typedCoverageGap({
|
|
541
|
+
kind: "skipped",
|
|
542
|
+
entity: requirement.address,
|
|
543
|
+
detail: `left out of the pull, skipped: ${reason}`,
|
|
544
|
+
consequence: "it is not written to source or adopted, and adoption releases it if state already manages it; it keeps running on the platform unmanaged until a later pull extracts what it needs, which writes it back to source and adopts it again",
|
|
545
|
+
}));
|
|
546
|
+
}
|
|
547
|
+
return pruned;
|
|
548
|
+
}
|
|
549
|
+
/** Why build will not emit `requirement`'s dependent, or undefined when it will. */
|
|
550
|
+
function unbuildableReason(requirement, root, streamAddresses, skipped, keptOwnFile, reports) {
|
|
551
|
+
if (requirement.unresolved === true)
|
|
552
|
+
return `it needs ${requirement.requires}, which is not a resource this pull extracts`;
|
|
553
|
+
if (!streamAddresses.has(requirement.requires))
|
|
554
|
+
return `it needs ${requirement.requires}, which is not in the export`;
|
|
555
|
+
if (!skipped.has(requirement.requires))
|
|
556
|
+
return undefined;
|
|
557
|
+
const ownFile = requirement.requiresOwnFile;
|
|
558
|
+
if (ownFile !== undefined && keptOwnFile?.(root, ownFile.kind, ownFile.refName) === true) {
|
|
559
|
+
reports.push(`${requirement.address}: kept in source and adoption: ${requirement.requires} was not re-extracted this pull, but its authored ${ownFile.kind} file ${ownFile.refName}.ts is kept, so build still emits both`);
|
|
560
|
+
return undefined;
|
|
561
|
+
}
|
|
562
|
+
return `it needs ${requirement.requires}, which this pull skipped`;
|
|
563
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys the org `@catalog` barrel holds after its app and element getters
|
|
3
|
+
* (src/catalog/org.ts renderBarrel). A later key in an object literal wins,
|
|
4
|
+
* so an app or element whose catalog key is one of these is shadowed:
|
|
5
|
+
* `catalog.users` is the org user lookups, not the element (edk#2839).
|
|
6
|
+
* `tables` is emitted only while the workspace has a table catalog; the
|
|
7
|
+
* others always are.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ORG_CATALOG_KEYS: readonly ["users", "userGroups", "aiProviders", "cloudLinks", "categories", "groups", "phoneProviders", "voiceAuths"];
|
|
10
|
+
/** An org entry the barrel always emits; renderBarrel renders exactly these, in this order. */
|
|
11
|
+
export type OrgCatalogKey = typeof ORG_CATALOG_KEYS[number];
|
|
12
|
+
/**
|
|
13
|
+
* True for every key the barrel can hold. Pull and `elementum new` never mint
|
|
14
|
+
* one of these for a new app or element (it becomes `users2`), so adding a
|
|
15
|
+
* table later can't shadow it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isReservedCatalogKey(refName: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* True when the barrel shadows an app or element getter named `refName` now:
|
|
20
|
+
* an always-emitted key, or `tables` while the workspace has a table catalog.
|
|
21
|
+
* Only a shadowed folder is refused or moved; an existing `tables` element in
|
|
22
|
+
* a workspace with no tables keeps working as `catalog.tables`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isShadowedCatalogKey(refName: string, tablesEmitted: boolean): boolean;
|
|
25
|
+
/** True when `<orgRoot>/tables/` holds a table catalog, which makes the barrel emit `tables`. */
|
|
26
|
+
export declare function orgHasTableCatalogs(orgRoot: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* `base` when it isn't a reserved catalog key, else the first of `<base>2`,
|
|
29
|
+
* `<base>3`, … that isn't `taken` (a folder there that belongs to another
|
|
30
|
+
* root).
|
|
31
|
+
*/
|
|
32
|
+
export declare function unreservedRefName(base: string, taken?: (candidate: string) => boolean): string;
|
|
33
|
+
/** True when `dir` holds nothing but pull's own `generated/` output (a dependency stub). */
|
|
34
|
+
export declare function isGeneratedOnlyFolder(dir: string): boolean;
|
|
35
|
+
/** Pull refuses to write over an authored root whose ref name the barrel shadows. */
|
|
36
|
+
export declare function reservedRefNameError(bag: string, refName: string, suggestion: string): Error;
|
|
37
|
+
/** The barrel leaves out a folder with source that an org entry shadows. */
|
|
38
|
+
export declare function shadowedFolderWarning(bag: string, refName: string, suggestion: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Pure shared allocator: app/element collisions receive disambiguated keys.
|
|
41
|
+
* Apps and elements share the barrel's key space: an element whose folder
|
|
42
|
+
* name an app also uses gets `<name>2` (the first free). The barrel, pull and
|
|
43
|
+
* the reserved-name checks all use this, so they agree on each element's key.
|
|
44
|
+
*/
|
|
45
|
+
export declare function computeElementKeys(appHandles: readonly string[], elementHandles: readonly string[]): Map<string, string>;
|
|
46
|
+
/** The `<bag>/<handle>/` folders that hold a catalog (`generated/catalog.ts`), sorted, as the barrel lists them. */
|
|
47
|
+
export declare function catalogFolders(orgRoot: string, bag: "apps" | "elements"): string[];
|