@elementumai/edk 0.10.4 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -13
- package/dist-sdk/src/catalog/token.js +2 -1
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
- package/dist-sdk/src/core/triggers/on-demand.js +3 -0
- package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +7 -0
- package/dist-sdk/src/engine/coverage-gaps.js +12 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
- package/dist-sdk/src/engine/ei/run.d.ts +42 -1
- package/dist-sdk/src/engine/ei/run.js +201 -32
- package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
- package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
- package/dist-sdk/src/engine/ei/state.d.ts +1 -1
- package/dist-sdk/src/engine/ei/state.js +17 -4
- package/dist-sdk/src/engine/progress.d.ts +3 -1
- package/dist-sdk/src/engine/progress.js +7 -3
- package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
- package/dist-sdk/src/engine/pull/authored-address.js +180 -29
- package/dist-sdk/src/engine/pull/context.d.ts +37 -2
- package/dist-sdk/src/engine/pull/context.js +7 -4
- package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
- package/dist-sdk/src/engine/pull/ref-only.js +52 -0
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
- package/dist-sdk/src/engine/tf/labels.js +50 -0
- package/dist-sdk/src/engine/tf/model.d.ts +2 -0
- package/dist-sdk/src/engine/tf/model.js +26 -0
- package/dist-sdk/src/engine/validation.d.ts +2 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +18 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +58 -24
- package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
- package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
- package/dist-sdk/src/entities/access-policy/module.js +10 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
- package/dist-sdk/src/entities/agent/build.js +7 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +13 -3
- package/dist-sdk/src/entities/agent/to-tf.js +11 -5
- package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
- package/dist-sdk/src/entities/agent/tools.js +6 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
- package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
- package/dist-sdk/src/entities/agent-tool/types.js +13 -9
- package/dist-sdk/src/entities/app/build.d.ts +12 -1
- package/dist-sdk/src/entities/app/build.js +80 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
- package/dist-sdk/src/entities/app/from-tf.js +17 -12
- package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
- package/dist-sdk/src/entities/app/stage-keys.js +40 -6
- package/dist-sdk/src/entities/app/to-tf.js +7 -4
- package/dist-sdk/src/entities/automation/build.d.ts +52 -31
- package/dist-sdk/src/entities/automation/build.js +59 -20
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +39 -14
- package/dist-sdk/src/entities/automation/from-tf.d.ts +35 -2
- package/dist-sdk/src/entities/automation/from-tf.js +721 -93
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +22 -2
- package/dist-sdk/src/entities/automation/module.js +244 -57
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
- package/dist-sdk/src/entities/automation/run-target.d.ts +61 -0
- package/dist-sdk/src/entities/automation/run-target.js +104 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +11 -1
- package/dist-sdk/src/entities/automation/script-code.js +106 -4
- package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
- package/dist-sdk/src/entities/automation/script-lint.js +418 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -1
- package/dist-sdk/src/entities/automation/task-output-labels.js +58 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +67 -22
- package/dist-sdk/src/entities/automation/tasks.js +18 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
- package/dist-sdk/src/entities/automation/to-tf.js +354 -64
- package/dist-sdk/src/entities/automation/triggers.d.ts +63 -11
- package/dist-sdk/src/entities/automation/triggers.js +45 -5
- package/dist-sdk/src/entities/automation/types.d.ts +21 -0
- package/dist-sdk/src/entities/automation/types.js +26 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +25 -1
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/printer.js +5 -2
- package/dist-sdk/src/entities/chart/to-tf.js +19 -1
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +8 -2
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +66 -20
- package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
- package/dist-sdk/src/entities/element/build.d.ts +10 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +14 -9
- package/dist-sdk/src/entities/element/to-tf.js +7 -4
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +79 -1
- package/dist-sdk/src/entities/field/module.js +14 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +38 -3
- package/dist-sdk/src/entities/field/to-tf.js +108 -34
- package/dist-sdk/src/entities/file-reader/module.js +3 -3
- package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
- package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
- package/dist-sdk/src/entities/file-reader/types.js +7 -0
- package/dist-sdk/src/entities/org/group.d.ts +1 -0
- package/dist-sdk/src/entities/org/group.js +2 -1
- package/dist-sdk/src/entities/org/role.js +5 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
- package/dist-sdk/src/entities/role/from-tf.js +24 -7
- package/dist-sdk/src/entities/role/to-tf.js +25 -7
- package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
- package/dist-sdk/src/entities/service-account/module.js +20 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
- package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
- package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
- package/dist-sdk/src/entities/skill/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill/module.js +18 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/skill/to-tf.js +23 -14
- package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
- package/dist-sdk/src/entities/task/to-tf.js +1 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
- package/dist-sdk/src/entities/view/from-tf.d.ts +68 -4
- package/dist-sdk/src/entities/view/from-tf.js +394 -22
- package/dist-sdk/src/entities/view/module.js +20 -0
- package/dist-sdk/src/entities/view/portable.d.ts +11 -0
- package/dist-sdk/src/entities/view/portable.js +47 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
- package/dist-sdk/src/entities/view/to-tf.js +25 -7
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +4 -3
- package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/widget/from-tf.js +100 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
- package/dist-sdk/src/entities/widget/to-tf.js +77 -14
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +30 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/field-resource-types.js +11 -0
- package/dist-sdk/src/graph/index.d.ts +41 -3
- package/dist-sdk/src/graph/index.js +24 -2
- package/dist-sdk/src/graph/types.d.ts +195 -5
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FIELD_RESOURCE_TYPE_SET } from "../../graph/field-resource-types.js";
|
|
1
2
|
import { sanitizeName, tsLabelToTfLabel } from "../tf/labels.js";
|
|
2
3
|
import { isTfExpr } from "../tf/model.js";
|
|
3
4
|
/** The platform id an import id ends with (`<parent>/<id>` and `<a>:<id>` forms included). */
|
|
@@ -5,9 +6,15 @@ export function canonicalImportId(importId) {
|
|
|
5
6
|
const last = importId.split(/[:/]/).at(-1);
|
|
6
7
|
return last === undefined || last === "" ? importId : last;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
/** The key {@link authoredAddressesById} binds a resource type + platform id under. */
|
|
10
|
+
export function typedIdentity(type, id) {
|
|
9
11
|
return `${type}\u0000${canonicalImportId(id)}`;
|
|
10
12
|
}
|
|
13
|
+
/** Inverse of {@link typedIdentity}. */
|
|
14
|
+
export function parseTypedIdentity(identity) {
|
|
15
|
+
const separator = identity.indexOf("\u0000");
|
|
16
|
+
return { type: identity.slice(0, separator), id: identity.slice(separator + 1) };
|
|
17
|
+
}
|
|
11
18
|
function addressType(address) {
|
|
12
19
|
const dot = address.indexOf(".");
|
|
13
20
|
return dot === -1 ? undefined : address.slice(0, dot);
|
|
@@ -27,6 +34,11 @@ export function authoredAddressesById(resources) {
|
|
|
27
34
|
typeof resource.name !== "string") {
|
|
28
35
|
continue;
|
|
29
36
|
}
|
|
37
|
+
// A failed adoption parks objects at `edk_adopt_move_tmp_*` (#1997). That
|
|
38
|
+
// name is not an authored address; keeping it would make the next pull
|
|
39
|
+
// adopt the temporary label instead of moving the object back.
|
|
40
|
+
if (resource.name.startsWith("edk_adopt_move_tmp_"))
|
|
41
|
+
continue;
|
|
30
42
|
const address = `${resource.type}.${resource.name}`;
|
|
31
43
|
for (const instance of resource.instances ?? []) {
|
|
32
44
|
const id = instance.attributes?.id;
|
|
@@ -132,20 +144,54 @@ export function staleAuthoredFieldReferences(unmatched, otherSources) {
|
|
|
132
144
|
return otherSources.some((text) => ref.test(text));
|
|
133
145
|
});
|
|
134
146
|
}
|
|
147
|
+
/** The pull warning for an {@link AuthoredAddressAmbiguity}. */
|
|
148
|
+
export function authoredAddressAmbiguityWarning(ambiguity) {
|
|
149
|
+
const targets = new Set(ambiguity.authoredTargets);
|
|
150
|
+
if (targets.size === 1) {
|
|
151
|
+
return (`could not preserve authored address ${ambiguity.authoredTargets[0]}: ` +
|
|
152
|
+
`the current export binds that identity at ${ambiguity.from.join(" and ")}; keeping export labels`);
|
|
153
|
+
}
|
|
154
|
+
const pairs = ambiguity.from.map((from, i) => `${ambiguity.authoredTargets[i]} for ${from}`);
|
|
155
|
+
return `could not preserve authored addresses ${pairs.join(" and ")}: those fields would print under one key; keeping export labels`;
|
|
156
|
+
}
|
|
135
157
|
/**
|
|
136
158
|
* Join export addresses to the addresses state already binds, by platform id.
|
|
137
159
|
*
|
|
138
160
|
* ei numbers same-named resources `_1`, `_2` in its export order, so a label
|
|
139
161
|
* can change hands between pulls (#1658). An authored target the export gives
|
|
140
162
|
* to another identity is still taken back when that occupant moves to its own
|
|
141
|
-
* authored address, or when the occupant is new to state and
|
|
142
|
-
*
|
|
163
|
+
* authored address, or when the occupant is new to state and a label is free
|
|
164
|
+
* at the end of the chain of moves that starts there: the occupant takes that
|
|
165
|
+
* label instead. For one move that is a swap. When a live add and a live
|
|
166
|
+
* remove shift every later positional label by one (#2053), the chain is the
|
|
167
|
+
* whole shift: every managed identity keeps its authored address and the new
|
|
168
|
+
* identity takes the label the last move leaves. Managed identities whose
|
|
169
|
+
* authored labels rotate among themselves all take them back. A label is
|
|
170
|
+
* free when no move claims it and no identity in this export is authored
|
|
171
|
+
* there; a label whose authored identity is absent from the export (deleted
|
|
172
|
+
* live) is free, and adoption releases that dead binding before the import
|
|
173
|
+
* (#1898).
|
|
143
174
|
* An occupant counts as new only when `inState` (every managed identity state
|
|
144
175
|
* holds) is given and doesn't contain it. Anything else stays at its export
|
|
145
176
|
* address and is reported.
|
|
177
|
+
*
|
|
178
|
+
* Occupancy is by {@link labelSlot}: an owner's fields print as one bag keyed
|
|
179
|
+
* by label, so a field of one type holds its label against every field type
|
|
180
|
+
* (#1859). When the result would still put two fields at one label, the
|
|
181
|
+
* join throws rather than print one key twice.
|
|
146
182
|
*/
|
|
147
183
|
function resolveAuthoredAddresses(importIds, authoredById, inState) {
|
|
148
|
-
const
|
|
184
|
+
const exportAtSlot = new Map();
|
|
185
|
+
for (const address of importIds.keys()) {
|
|
186
|
+
const slot = labelSlot(address);
|
|
187
|
+
const held = exportAtSlot.get(slot);
|
|
188
|
+
if (held === undefined)
|
|
189
|
+
exportAtSlot.set(slot, [address]);
|
|
190
|
+
else
|
|
191
|
+
held.push(address);
|
|
192
|
+
}
|
|
193
|
+
const occupantsOf = (slot, except) => (exportAtSlot.get(slot) ?? []).filter((address) => address !== except);
|
|
194
|
+
const claimsBySlot = new Map();
|
|
149
195
|
for (const [from, id] of importIds) {
|
|
150
196
|
const type = addressType(from);
|
|
151
197
|
if (type === undefined)
|
|
@@ -153,66 +199,171 @@ function resolveAuthoredAddresses(importIds, authoredById, inState) {
|
|
|
153
199
|
const to = authoredById.get(typedIdentity(type, id));
|
|
154
200
|
if (to === undefined || to === from)
|
|
155
201
|
continue;
|
|
156
|
-
const claims =
|
|
202
|
+
const claims = claimsBySlot.get(labelSlot(to));
|
|
157
203
|
if (claims === undefined)
|
|
158
|
-
|
|
159
|
-
else
|
|
160
|
-
claims.push(
|
|
204
|
+
claimsBySlot.set(labelSlot(to), { target: to, targets: [to], from: [from] });
|
|
205
|
+
else {
|
|
206
|
+
claims.targets.push(to);
|
|
207
|
+
claims.from.push(from);
|
|
208
|
+
}
|
|
161
209
|
}
|
|
162
210
|
const ambiguities = [];
|
|
163
211
|
const pending = new Map();
|
|
164
|
-
for (const
|
|
212
|
+
for (const { target, targets, from } of claimsBySlot.values()) {
|
|
165
213
|
if (from.length > 1)
|
|
166
|
-
ambiguities.push({
|
|
214
|
+
ambiguities.push({ authoredTargets: targets, from });
|
|
167
215
|
else
|
|
168
|
-
pending.set(from[0],
|
|
216
|
+
pending.set(from[0], target);
|
|
169
217
|
}
|
|
170
|
-
const
|
|
218
|
+
const exportIdentities = new Set();
|
|
219
|
+
for (const [address, id] of importIds) {
|
|
220
|
+
const type = addressType(address);
|
|
221
|
+
if (type !== undefined)
|
|
222
|
+
exportIdentities.add(typedIdentity(type, id));
|
|
223
|
+
}
|
|
224
|
+
// Authored labels of identities this export still has. One whose identity
|
|
225
|
+
// is absent from the export was deleted live and does not hold its label.
|
|
226
|
+
const liveAuthoredSlots = new Set([...authoredById].filter(([identity]) => exportIdentities.has(identity)).map(([, address]) => labelSlot(address)));
|
|
171
227
|
const accepted = new Map();
|
|
172
|
-
const
|
|
228
|
+
const acceptedSlots = new Set();
|
|
173
229
|
const aliases = [];
|
|
174
230
|
const accept = (from, to) => {
|
|
175
231
|
accepted.set(from, to);
|
|
176
|
-
|
|
232
|
+
acceptedSlots.add(labelSlot(to));
|
|
177
233
|
aliases.push({ from, to });
|
|
178
234
|
};
|
|
235
|
+
// The label left free at the end of the chain of pending moves that vacates
|
|
236
|
+
// `from`: each pending move into the label just vacated leaves its own
|
|
237
|
+
// export label, until no move claims one. Undefined when that label is
|
|
238
|
+
// claimed, ambiguous, already taken, or authored to an identity this export
|
|
239
|
+
// still has.
|
|
240
|
+
const freeLabelAfterChain = (from) => {
|
|
241
|
+
const seen = new Set([from]);
|
|
242
|
+
let vacated = from;
|
|
243
|
+
for (;;) {
|
|
244
|
+
const claims = claimsBySlot.get(labelSlot(vacated));
|
|
245
|
+
if (claims === undefined)
|
|
246
|
+
break;
|
|
247
|
+
const mover = claims.from.length === 1 ? claims.from[0] : undefined;
|
|
248
|
+
if (mover === undefined || pending.get(mover) !== claims.target || seen.has(mover))
|
|
249
|
+
return undefined;
|
|
250
|
+
seen.add(mover);
|
|
251
|
+
vacated = mover;
|
|
252
|
+
}
|
|
253
|
+
const slot = labelSlot(vacated);
|
|
254
|
+
if (liveAuthoredSlots.has(slot) || acceptedSlots.has(slot) || occupantsOf(slot, vacated).length > 0)
|
|
255
|
+
return undefined;
|
|
256
|
+
return vacated;
|
|
257
|
+
};
|
|
258
|
+
// Managed identities whose pending moves each target the label the next one
|
|
259
|
+
// leaves, closing back on `from`: the whole rotation can be taken at once.
|
|
260
|
+
const rotationFrom = (from) => {
|
|
261
|
+
const members = [from];
|
|
262
|
+
let mover = from;
|
|
263
|
+
for (;;) {
|
|
264
|
+
const occupants = occupantsOf(labelSlot(pending.get(mover)), mover);
|
|
265
|
+
if (occupants.length !== 1)
|
|
266
|
+
return undefined;
|
|
267
|
+
const next = occupants[0];
|
|
268
|
+
if (next === from)
|
|
269
|
+
return members;
|
|
270
|
+
if (!pending.has(next) || members.includes(next))
|
|
271
|
+
return undefined;
|
|
272
|
+
members.push(next);
|
|
273
|
+
mover = next;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
179
276
|
// A move whose target is held by another moving identity waits for that move.
|
|
180
277
|
for (let progressed = true; progressed && pending.size > 0;) {
|
|
181
278
|
progressed = false;
|
|
182
279
|
for (const [from, to] of pending) {
|
|
183
|
-
const occupiedById = importIds.get(to);
|
|
184
280
|
const sourceId = importIds.get(from);
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
|
|
281
|
+
const occupants = occupantsOf(labelSlot(to), from);
|
|
282
|
+
const free = occupants.every((address) => canonicalImportId(importIds.get(address)) === canonicalImportId(sourceId));
|
|
283
|
+
const vacated = occupants.length > 0 && occupants.every((address) => accepted.has(address));
|
|
284
|
+
const occupant = occupants.length === 1 ? occupants[0] : undefined;
|
|
285
|
+
const occupantIdentity = occupant === undefined ? undefined : typedIdentity(addressType(occupant), importIds.get(occupant));
|
|
286
|
+
const occupantNew = occupantIdentity !== undefined && inState !== undefined && !inState.has(occupantIdentity) && !authoredById.has(occupantIdentity);
|
|
287
|
+
const rotation = occupant !== undefined && pending.has(occupant) ? rotationFrom(from) : undefined;
|
|
288
|
+
const occupantLabel = occupantNew ? freeLabelAfterChain(from) : undefined;
|
|
289
|
+
if (free || vacated) {
|
|
190
290
|
accept(from, to);
|
|
291
|
+
pending.delete(from);
|
|
191
292
|
}
|
|
192
|
-
else if (
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
293
|
+
else if (rotation !== undefined) {
|
|
294
|
+
// Managed identities whose labels traded places (two of them: a swap).
|
|
295
|
+
for (const member of rotation) {
|
|
296
|
+
accept(member, pending.get(member));
|
|
297
|
+
pending.delete(member);
|
|
298
|
+
}
|
|
197
299
|
}
|
|
198
|
-
else if (
|
|
300
|
+
else if (occupant !== undefined && occupantLabel !== undefined) {
|
|
301
|
+
// The rest of the chain follows on later passes: each target is then
|
|
302
|
+
// held by an identity that has already moved.
|
|
199
303
|
accept(from, to);
|
|
200
|
-
accept(
|
|
304
|
+
accept(occupant, withLabelOf(occupant, occupantLabel));
|
|
305
|
+
pending.delete(from);
|
|
201
306
|
}
|
|
202
307
|
else {
|
|
203
308
|
continue;
|
|
204
309
|
}
|
|
205
|
-
pending.delete(from);
|
|
206
310
|
progressed = true;
|
|
207
311
|
}
|
|
208
312
|
}
|
|
209
313
|
const conflicts = [...pending].map(([from, authoredTarget]) => ({
|
|
210
314
|
from,
|
|
211
315
|
authoredTarget,
|
|
212
|
-
occupiedById: importIds.get(authoredTarget) ?? "",
|
|
316
|
+
occupiedById: importIds.get(occupantsOf(labelSlot(authoredTarget), from)[0] ?? "") ?? "",
|
|
213
317
|
}));
|
|
318
|
+
assertOneAddressPerSlot(importIds, accepted);
|
|
214
319
|
return { aliases, ambiguities, conflicts };
|
|
215
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* The key space an address takes its label in: one per label for every field
|
|
323
|
+
* type, since an owner's fields print as one bag keyed by label alone; the
|
|
324
|
+
* address itself otherwise.
|
|
325
|
+
*/
|
|
326
|
+
function labelSlot(address) {
|
|
327
|
+
const type = addressType(address);
|
|
328
|
+
return type !== undefined && FIELD_RESOURCE_TYPE_SET.has(type) ? `\u0000field.${address.slice(type.length + 1)}` : address;
|
|
329
|
+
}
|
|
330
|
+
/** `address`'s resource type at `labelSource`'s label. */
|
|
331
|
+
function withLabelOf(address, labelSource) {
|
|
332
|
+
return `${addressType(address)}.${labelSource.slice(labelSource.indexOf(".") + 1)}`;
|
|
333
|
+
}
|
|
334
|
+
/** Whether `slot` (a {@link labelSlot}) is an owner's shared field key space. */
|
|
335
|
+
function isFieldSlot(slot) {
|
|
336
|
+
return slot.startsWith("\u0000field.");
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Two fields at one label would print one bag key twice, and the build would
|
|
340
|
+
* keep only the second, planning to replace the other's live field (#1859).
|
|
341
|
+
* Fail closed instead of printing that.
|
|
342
|
+
*/
|
|
343
|
+
function assertOneAddressPerSlot(importIds, accepted) {
|
|
344
|
+
const bySlot = new Map();
|
|
345
|
+
for (const from of importIds.keys()) {
|
|
346
|
+
const to = accepted.get(from) ?? from;
|
|
347
|
+
const held = bySlot.get(labelSlot(to));
|
|
348
|
+
if (held === undefined)
|
|
349
|
+
bySlot.set(labelSlot(to), [{ from, to }]);
|
|
350
|
+
else
|
|
351
|
+
held.push({ from, to });
|
|
352
|
+
}
|
|
353
|
+
for (const [slot, moves] of bySlot) {
|
|
354
|
+
if (moves.length < 2)
|
|
355
|
+
continue;
|
|
356
|
+
const named = moves.map(({ from, to }) => (from === to ? from : `${from} (as ${to})`)).join(" and ");
|
|
357
|
+
if (!isFieldSlot(slot)) {
|
|
358
|
+
throw new Error(`pull would print ${named} at one address, and the next plan would replace one of those live resources. ` +
|
|
359
|
+
"Pull stopped instead. Rename one of them in Elementum, then pull again.");
|
|
360
|
+
}
|
|
361
|
+
throw new Error(`pull would print fields ${named} under one field key, and the next plan would replace one of those live fields. ` +
|
|
362
|
+
'Pull stopped instead. This usually means the export numbered a repeated name with a _N suffix (two fields named "Notes" ' +
|
|
363
|
+
'export as notes and notes_1) and a third field named "Notes 1", "Notes_1" or "Notes-1" takes the same key. ' +
|
|
364
|
+
"Rename one of these fields in Elementum, then pull again.");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
216
367
|
/**
|
|
217
368
|
* Resolve export addresses to addresses already bound in authored state.
|
|
218
369
|
*
|
|
@@ -16,6 +16,11 @@ export interface ImportedResourceRef {
|
|
|
16
16
|
readonly attrs: Readonly<Record<string, TfValue>>;
|
|
17
17
|
}
|
|
18
18
|
/** Extraction context: stream lookups + the diagnostics sink. */
|
|
19
|
+
/** An automation the export left out, as omitted-automations.json names it. */
|
|
20
|
+
export interface OmittedAutomationIdentity {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
}
|
|
19
24
|
export interface FromTfContext {
|
|
20
25
|
/** Lookup-attr value of a data block in the same stream: ("elementum_category", "experiments") → "Experiments". */
|
|
21
26
|
dataName(type: string, label: string): string | undefined;
|
|
@@ -56,6 +61,11 @@ export interface FromTfContext {
|
|
|
56
61
|
readonly columnRefNamesByName?: ReadonlyMap<string, string>;
|
|
57
62
|
readonly columnRefNamesById?: ReadonlyMap<string, string>;
|
|
58
63
|
}>;
|
|
64
|
+
/** Platform file-reader id → its owning app and reader key, bound exactly by workspace state. */
|
|
65
|
+
readonly foreignFileReaderRefsById?: ReadonlyMap<string, {
|
|
66
|
+
readonly ownerRefName: string;
|
|
67
|
+
readonly refName: string;
|
|
68
|
+
}>;
|
|
59
69
|
/** Namespace → refName for portable ref-only app/element catalogs. */
|
|
60
70
|
readonly foreignAppRefNamespaces?: ReadonlyMap<string, string>;
|
|
61
71
|
readonly foreignElementRefNamespaces?: ReadonlyMap<string, string>;
|
|
@@ -74,6 +84,23 @@ export interface FromTfContext {
|
|
|
74
84
|
readonly name: string;
|
|
75
85
|
readonly namespace?: string;
|
|
76
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Set by `clone app`, which drops the export's import blocks before
|
|
89
|
+
* extraction. `sourceImportId` reads the dropped ones (by resource
|
|
90
|
+
* address): a reference to a field clone does not copy keeps that id when
|
|
91
|
+
* the field's block names another app, element or task as its owner, and fails
|
|
92
|
+
* the clone otherwise, naming the field and the reference (#1990).
|
|
93
|
+
* `sourceImportedAddress` is the reverse: the address a dropped import
|
|
94
|
+
* gave a bare platform id, so `importedResource` still resolves the bare
|
|
95
|
+
* ids an export writes when it can't name a field (#1991).
|
|
96
|
+
* `systemFieldReadFailure` is why the live read of the source app's system
|
|
97
|
+
* fields failed, if it did, so an unmapped id's error names it (#1492).
|
|
98
|
+
*/
|
|
99
|
+
readonly cloning?: {
|
|
100
|
+
readonly sourceImportId: (address: string) => string | undefined;
|
|
101
|
+
readonly sourceImportedAddress?: (id: string) => string | undefined;
|
|
102
|
+
readonly systemFieldReadFailure?: string;
|
|
103
|
+
};
|
|
77
104
|
/** `data.<field-type>.<label>` → generated ref-only catalog member. */
|
|
78
105
|
readonly foreignFieldRefsByDataAddress?: ReadonlyMap<string, {
|
|
79
106
|
readonly ownerRefName: string;
|
|
@@ -107,6 +134,14 @@ export interface FromTfContext {
|
|
|
107
134
|
* ei writes a service account owned by another app as a bare id.
|
|
108
135
|
*/
|
|
109
136
|
readonly serviceAccountsById?: ReadonlyMap<string, ServiceAccountIdentity>;
|
|
137
|
+
/**
|
|
138
|
+
* The automations the export left out (omitted-automations.json), by
|
|
139
|
+
* platform id (#1877). A run-automation widget whose raw automation id is
|
|
140
|
+
* listed here warns, naming the automation and the export's reason; any
|
|
141
|
+
* other raw id (such as another app's automation) is a valid reference and
|
|
142
|
+
* stays silent. Undefined: no listed id, so only an empty id warns.
|
|
143
|
+
*/
|
|
144
|
+
readonly omittedAutomationsById?: ReadonlyMap<string, OmittedAutomationIdentity>;
|
|
110
145
|
/**
|
|
111
146
|
* Foreign app/element display names this stream saw referenced (currently:
|
|
112
147
|
* a RELATION field's `related_object_id` as a `data.elementum_app`/
|
|
@@ -238,8 +273,8 @@ export interface AuthoringBlocker {
|
|
|
238
273
|
*/
|
|
239
274
|
readonly ownFileKind?: string;
|
|
240
275
|
}
|
|
241
|
-
/** The pull-abort message for one or more authoring blockers. */
|
|
242
|
-
export declare function authoringBlockedMessage(blockers: readonly AuthoringBlocker[]): string;
|
|
276
|
+
/** The pull-abort (or, for `clone app`, clone-abort) message for one or more authoring blockers. */
|
|
277
|
+
export declare function authoringBlockedMessage(blockers: readonly AuthoringBlocker[], command?: "pull" | "clone"): string;
|
|
243
278
|
/**
|
|
244
279
|
* Record an authoring blocker. Without a sink (a caller outside the stream
|
|
245
280
|
* pipeline) it throws, so a blocker is never silently dropped.
|
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { EntityTfError } from "../entity.js";
|
|
8
8
|
import { isTfExpr, tfLabelToTsLabel } from "../tf/index.js";
|
|
9
|
-
/** The pull-abort message for one or more authoring blockers. */
|
|
10
|
-
export function authoringBlockedMessage(blockers) {
|
|
9
|
+
/** The pull-abort (or, for `clone app`, clone-abort) message for one or more authoring blockers. */
|
|
10
|
+
export function authoringBlockedMessage(blockers, command = "pull") {
|
|
11
11
|
const remedies = [...new Set(blockers.map((blocker) => blocker.remedy))];
|
|
12
|
-
|
|
13
|
-
"
|
|
12
|
+
const head = command === "clone"
|
|
13
|
+
? "Clone aborted: the clone cannot reproduce this configuration of the source app, so no clone source was written:\n"
|
|
14
|
+
: "Pull aborted: authored source cannot reproduce this live configuration, " +
|
|
15
|
+
"and printing the rest would change it on the next apply:\n";
|
|
16
|
+
return (head +
|
|
14
17
|
blockers.map((blocker) => ` - ${blocker.description}`).join("\n") +
|
|
15
18
|
remedies.map((remedy) => `\n${remedy}`).join(""));
|
|
16
19
|
}
|
|
@@ -58,3 +58,21 @@ export declare function fieldDataReferenceMap(doc: TfDocument, roots: readonly D
|
|
|
58
58
|
readonly fieldName?: string;
|
|
59
59
|
readonly fieldType?: string;
|
|
60
60
|
}>;
|
|
61
|
+
/** A field identity an earlier pull recorded for a managed app or element. */
|
|
62
|
+
export interface ManagedFieldNameIdentity {
|
|
63
|
+
readonly ownerRefName: string;
|
|
64
|
+
readonly fieldKey: string;
|
|
65
|
+
readonly fieldName?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Point a managed root's ref-only fields at the keys its source authors.
|
|
69
|
+
*
|
|
70
|
+
* The export keys a field by its current display name. A managed root keeps
|
|
71
|
+
* the authored key across a UI rename, and build addresses that key. A
|
|
72
|
+
* system-tagged field already carries its canonical key (`title`, `id`, …),
|
|
73
|
+
* which a display-name lookup must not replace. A display name that belongs
|
|
74
|
+
* to more than one field on that owner is left on the export key: the name
|
|
75
|
+
* index is last-write-wins and would otherwise stamp one survivor onto both.
|
|
76
|
+
* `refOnly:` guesses are not identities, so they do not count.
|
|
77
|
+
*/
|
|
78
|
+
export declare function withManagedRefOnlyIdentity<T extends DirectReferenceRoot>(root: T, managedRefName: string, fieldRefsById: ReadonlyMap<string, ManagedFieldNameIdentity> | undefined): T;
|
|
@@ -283,3 +283,55 @@ export function fieldDataReferenceMap(doc, roots) {
|
|
|
283
283
|
}
|
|
284
284
|
return out;
|
|
285
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Point a managed root's ref-only fields at the keys its source authors.
|
|
288
|
+
*
|
|
289
|
+
* The export keys a field by its current display name. A managed root keeps
|
|
290
|
+
* the authored key across a UI rename, and build addresses that key. A
|
|
291
|
+
* system-tagged field already carries its canonical key (`title`, `id`, …),
|
|
292
|
+
* which a display-name lookup must not replace. A display name that belongs
|
|
293
|
+
* to more than one field on that owner is left on the export key: the name
|
|
294
|
+
* index is last-write-wins and would otherwise stamp one survivor onto both.
|
|
295
|
+
* `refOnly:` guesses are not identities, so they do not count.
|
|
296
|
+
*/
|
|
297
|
+
export function withManagedRefOnlyIdentity(root, managedRefName, fieldRefsById) {
|
|
298
|
+
const authoredKeyByName = uniqueAuthoredFieldKeys(fieldRefsById, managedRefName);
|
|
299
|
+
return {
|
|
300
|
+
...root,
|
|
301
|
+
refName: managedRefName,
|
|
302
|
+
fields: root.fields.map((field) => {
|
|
303
|
+
const authoredKey = systemFieldTag(field) === undefined
|
|
304
|
+
? authoredKeyByName.get(field.name.toLowerCase())
|
|
305
|
+
: undefined;
|
|
306
|
+
return {
|
|
307
|
+
...field,
|
|
308
|
+
parent: managedRefName,
|
|
309
|
+
...(authoredKey !== undefined ? { refName: authoredKey } : {}),
|
|
310
|
+
};
|
|
311
|
+
}),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function uniqueAuthoredFieldKeys(fieldRefsById, ownerRefName) {
|
|
315
|
+
const counts = new Map();
|
|
316
|
+
const keys = new Map();
|
|
317
|
+
if (fieldRefsById === undefined)
|
|
318
|
+
return keys;
|
|
319
|
+
for (const [id, identity] of fieldRefsById) {
|
|
320
|
+
if (id.startsWith("refOnly:"))
|
|
321
|
+
continue;
|
|
322
|
+
if (identity.ownerRefName !== ownerRefName)
|
|
323
|
+
continue;
|
|
324
|
+
const name = identity.fieldName;
|
|
325
|
+
if (name === undefined || name === "")
|
|
326
|
+
continue;
|
|
327
|
+
const lower = name.toLowerCase();
|
|
328
|
+
counts.set(lower, (counts.get(lower) ?? 0) + 1);
|
|
329
|
+
if (!keys.has(lower))
|
|
330
|
+
keys.set(lower, identity.fieldKey);
|
|
331
|
+
}
|
|
332
|
+
for (const [lower, count] of counts) {
|
|
333
|
+
if (count !== 1)
|
|
334
|
+
keys.delete(lower);
|
|
335
|
+
}
|
|
336
|
+
return keys;
|
|
337
|
+
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* toHcl emitters produce TfBlock rendered by renderDocument.
|
|
5
5
|
*/
|
|
6
6
|
export type { PathSeg, TfBlock, TfBlockKind, TfDocument, TfExpr, TfLifecycle, TfValue, TfVariableValidation } from "./model.js";
|
|
7
|
-
export { expr, isTfExpr } from "./model.js";
|
|
7
|
+
export { expr, forEachExpr, isTfExpr } from "./model.js";
|
|
8
8
|
export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./escape.js";
|
|
9
9
|
export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
|
|
10
10
|
export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, parseHclDocuments, TfParseError, type BackendHclInspection, } from "./parse.js";
|
|
11
11
|
export { renderBlock, renderDocument } from "./render.js";
|
|
12
12
|
export { hclCodeLines, hclDepthDelta, hclStatementEnd, type HclCodeLine } from "./scan.js";
|
|
13
|
-
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stageHandleTfLabel, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, taskResourceLabelPrefix, type ChildResourceScope, type FieldOwnerScope, } from "./labels.js";
|
|
13
|
+
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, collisionLabelSuffixes, elementResourceLabelPrefix, elementScopedResourceLabel, exportLabelSuffix, isCanonicalTsLabel, isTfLabel, isUuid, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stageHandleTfLabel, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, taskResourceLabelPrefix, type ChildResourceScope, type FieldOwnerScope, } from "./labels.js";
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* A second dialect must not exist: extractors consume TfBlock from parseHcl;
|
|
4
4
|
* toHcl emitters produce TfBlock rendered by renderDocument.
|
|
5
5
|
*/
|
|
6
|
-
export { expr, isTfExpr } from "./model.js";
|
|
6
|
+
export { expr, forEachExpr, isTfExpr } from "./model.js";
|
|
7
7
|
export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./escape.js";
|
|
8
8
|
export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
|
|
9
9
|
export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, parseHclDocuments, TfParseError, } from "./parse.js";
|
|
10
10
|
export { renderBlock, renderDocument } from "./render.js";
|
|
11
11
|
export { hclCodeLines, hclDepthDelta, hclStatementEnd } from "./scan.js";
|
|
12
|
-
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, elementResourceLabelPrefix, elementScopedResourceLabel, isCanonicalTsLabel, isTfLabel, isUuid, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stageHandleTfLabel, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, taskResourceLabelPrefix, } from "./labels.js";
|
|
12
|
+
export { appResourceLabelPrefix, appScopedResourceLabel, bareChildResourceLabel, childPartFromScopedLabel, collisionLabelSuffixes, elementResourceLabelPrefix, elementScopedResourceLabel, exportLabelSuffix, isCanonicalTsLabel, isTfLabel, isUuid, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, snakeSlug, splitCamelCase, stageHandleTfLabel, stableIdSuffix, tfLabelToTsLabel, tsLabelToTfLabel, taskResourceLabelPrefix, } from "./labels.js";
|
|
@@ -116,3 +116,25 @@ export declare function ownerFromScopedChildLabel(scopedLabel: string): {
|
|
|
116
116
|
export declare function stableIdSuffix(id: string): string;
|
|
117
117
|
/** Scoped terraform label → authoring bag key / ref key. */
|
|
118
118
|
export declare function scopedLabelToBagKey(ownerTfLabel: string, scopedLabel: string, scope?: FieldOwnerScope): string;
|
|
119
|
+
/**
|
|
120
|
+
* The `N` of an export label `<base>_<N>` (N ≥ 1), or undefined when `label`
|
|
121
|
+
* is `base` itself or not derived from it. Pull reads a tool's pinned
|
|
122
|
+
* `labelSuffix` this way (edk#1987). An `N` above `Number.MAX_SAFE_INTEGER`
|
|
123
|
+
* is not a pin either: as a number it would round to a different label, so
|
|
124
|
+
* the tool stays unpinned rather than being silently renumbered.
|
|
125
|
+
*/
|
|
126
|
+
export declare function exportLabelSuffix(base: string, label: string): number | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* `_N` suffixes, by position, for one owner's tools whose labels share a
|
|
129
|
+
* `base` (edk#1987). A tool with a pinned `labelSuffix` keeps exactly that
|
|
130
|
+
* `_N`. Every other tool takes the lowest count its group has not used or
|
|
131
|
+
* pinned, in list order, so the first unpinned one keeps the bare label.
|
|
132
|
+
* ei counts the same way in the platform's order; pull pins every tool ei
|
|
133
|
+
* gave a suffix, so tools ei counted but pull doesn't print (unimplemented
|
|
134
|
+
* kinds, dropped tools) still leave their slots free. `undefined` entries
|
|
135
|
+
* (tools ei doesn't count) get no suffix.
|
|
136
|
+
*/
|
|
137
|
+
export declare function collisionLabelSuffixes(entries: readonly ({
|
|
138
|
+
readonly base: string;
|
|
139
|
+
readonly pinned?: number;
|
|
140
|
+
} | undefined)[]): readonly string[];
|
|
@@ -266,3 +266,53 @@ export function stableIdSuffix(id) {
|
|
|
266
266
|
export function scopedLabelToBagKey(ownerTfLabel, scopedLabel, scope = "app") {
|
|
267
267
|
return tfLabelToTsLabel(childPartFromScopedLabel(ownerTfLabel, scopedLabel, scope));
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* The `N` of an export label `<base>_<N>` (N ≥ 1), or undefined when `label`
|
|
271
|
+
* is `base` itself or not derived from it. Pull reads a tool's pinned
|
|
272
|
+
* `labelSuffix` this way (edk#1987). An `N` above `Number.MAX_SAFE_INTEGER`
|
|
273
|
+
* is not a pin either: as a number it would round to a different label, so
|
|
274
|
+
* the tool stays unpinned rather than being silently renumbered.
|
|
275
|
+
*/
|
|
276
|
+
export function exportLabelSuffix(base, label) {
|
|
277
|
+
if (!label.startsWith(`${base}_`))
|
|
278
|
+
return undefined;
|
|
279
|
+
const rest = label.slice(base.length + 1);
|
|
280
|
+
if (!/^[1-9][0-9]*$/.test(rest))
|
|
281
|
+
return undefined;
|
|
282
|
+
const count = Number(rest);
|
|
283
|
+
return Number.isSafeInteger(count) ? count : undefined;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* `_N` suffixes, by position, for one owner's tools whose labels share a
|
|
287
|
+
* `base` (edk#1987). A tool with a pinned `labelSuffix` keeps exactly that
|
|
288
|
+
* `_N`. Every other tool takes the lowest count its group has not used or
|
|
289
|
+
* pinned, in list order, so the first unpinned one keeps the bare label.
|
|
290
|
+
* ei counts the same way in the platform's order; pull pins every tool ei
|
|
291
|
+
* gave a suffix, so tools ei counted but pull doesn't print (unimplemented
|
|
292
|
+
* kinds, dropped tools) still leave their slots free. `undefined` entries
|
|
293
|
+
* (tools ei doesn't count) get no suffix.
|
|
294
|
+
*/
|
|
295
|
+
export function collisionLabelSuffixes(entries) {
|
|
296
|
+
const taken = new Map();
|
|
297
|
+
const takenFor = (base) => {
|
|
298
|
+
const set = taken.get(base) ?? new Set();
|
|
299
|
+
taken.set(base, set);
|
|
300
|
+
return set;
|
|
301
|
+
};
|
|
302
|
+
for (const entry of entries) {
|
|
303
|
+
if (entry?.pinned !== undefined)
|
|
304
|
+
takenFor(entry.base).add(entry.pinned);
|
|
305
|
+
}
|
|
306
|
+
return entries.map((entry) => {
|
|
307
|
+
if (entry === undefined)
|
|
308
|
+
return "";
|
|
309
|
+
if (entry.pinned !== undefined)
|
|
310
|
+
return `_${entry.pinned}`;
|
|
311
|
+
const used = takenFor(entry.base);
|
|
312
|
+
let count = 0;
|
|
313
|
+
while (used.has(count))
|
|
314
|
+
count++;
|
|
315
|
+
used.add(count);
|
|
316
|
+
return count > 0 ? `_${count}` : "";
|
|
317
|
+
});
|
|
318
|
+
}
|
|
@@ -110,3 +110,5 @@ export declare const expr: {
|
|
|
110
110
|
scopedAttr(name: string, path?: PathSeg[]): TfExpr;
|
|
111
111
|
forObject(variable: string, collection: TfExpr, key: TfExpr, value: TfExpr): TfExpr;
|
|
112
112
|
};
|
|
113
|
+
/** Visits every expression leaf in a value, recursing into nested expressions. */
|
|
114
|
+
export declare function forEachExpr(value: TfValue, visit: (e: TfExpr) => void): void;
|
|
@@ -51,3 +51,29 @@ export const expr = {
|
|
|
51
51
|
return { $expr: "for-object", variable, collection, key, value };
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
+
/** Visits every expression leaf in a value, recursing into nested expressions. */
|
|
55
|
+
export function forEachExpr(value, visit) {
|
|
56
|
+
if (isTfExpr(value)) {
|
|
57
|
+
visit(value);
|
|
58
|
+
if (value.$expr === "jsonencode") {
|
|
59
|
+
forEachExpr(value.value, visit);
|
|
60
|
+
}
|
|
61
|
+
else if (value.$expr === "template") {
|
|
62
|
+
for (const part of value.parts)
|
|
63
|
+
if (typeof part !== "string")
|
|
64
|
+
forEachExpr(part, visit);
|
|
65
|
+
}
|
|
66
|
+
else if (value.$expr === "for-object") {
|
|
67
|
+
forEachExpr(value.collection, visit);
|
|
68
|
+
forEachExpr(value.key, visit);
|
|
69
|
+
forEachExpr(value.value, visit);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(value))
|
|
74
|
+
for (const item of value)
|
|
75
|
+
forEachExpr(item, visit);
|
|
76
|
+
else if (typeof value === "object" && value !== null)
|
|
77
|
+
for (const item of Object.values(value))
|
|
78
|
+
forEachExpr(item, visit);
|
|
79
|
+
}
|
|
@@ -14,6 +14,8 @@ export interface ValidationFailure {
|
|
|
14
14
|
* these to warnings; build/plan/apply keep them fatal.
|
|
15
15
|
*/
|
|
16
16
|
readonly staleReference?: boolean;
|
|
17
|
+
/** What kind of finding this is, when a caller has to treat it specially. */
|
|
18
|
+
readonly code?: "unresolved-task-filter-ref";
|
|
17
19
|
}
|
|
18
20
|
export declare function formatValidationFailure(failure: ValidationFailure): string;
|
|
19
21
|
export declare class ValidationFailureError extends Error {
|
|
@@ -47,8 +47,26 @@ export interface FilterFromTfOptions {
|
|
|
47
47
|
}
|
|
48
48
|
/** Decode one `filter` attribute through the shared exhaustive codec. */
|
|
49
49
|
export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string, ctx?: FromTfContext, options?: FilterFromTfOptions): Filter<RefExpr, RefExpr>;
|
|
50
|
+
/**
|
|
51
|
+
* The EDK ref of the app that owns a service-account block, read from the
|
|
52
|
+
* block's `app_id`: the owner itself when that is the app the ref points at,
|
|
53
|
+
* otherwise a foreign app the workspace knows by name or namespace (a
|
|
54
|
+
* namespace-only `data "elementum_app"` lookup included). Undefined
|
|
55
|
+
* when it doesn't resolve, so the caller drops the member.
|
|
56
|
+
*/
|
|
57
|
+
export declare function serviceAccountAppRefName(appId: TfValue | undefined, owner: {
|
|
58
|
+
readonly scope: ChildResourceScope;
|
|
59
|
+
readonly label: string;
|
|
60
|
+
readonly ownerRefName: string;
|
|
61
|
+
} | undefined, ctx: FromTfContext): string | undefined;
|
|
50
62
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_user", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyUserRef[] | undefined;
|
|
51
63
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_group", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyGroupRef[] | undefined;
|
|
52
64
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_service_account", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyServiceAccountRef[] | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Export file order is not label-suffix order. Build numbers policies by
|
|
67
|
+
* array index (`access_policy`, then `access_policy_1`), so pull must follow
|
|
68
|
+
* the suffix or a later build swaps the addresses (#2088).
|
|
69
|
+
*/
|
|
70
|
+
export declare function accessPolicyBlocksInLabelOrder(blocks: readonly TfBlock[]): readonly TfBlock[];
|
|
53
71
|
/** One `elementum_access_policy` block → its normalized shape, or undefined when it belongs to a different owner. */
|
|
54
72
|
export declare function accessPolicyFromTf(block: TfBlock, owner: AccessPolicyOwner, ctx: FromTfContext): NormalizedAccessPolicy | undefined;
|