@parcha/agentrun-dsl 0.1.0-beta.211 → 0.1.0-beta.213
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/dist/edit.js +13 -9
- package/package.json +1 -1
package/dist/edit.js
CHANGED
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
// scope that mention the old key (or one of its `<key>$...` keys) are listed in `mentions`, for the caller to
|
|
67
67
|
// show. So is a renamed code node's own code when it names the old key: a record it returns with that key still
|
|
68
68
|
// writes the old name. The validator does not see a read inside code, so that list is the only warning.
|
|
69
|
-
// - rename refuses a name another node's label or key holds, or that a reference (as `<name>$...`
|
|
70
|
-
// or a code source in scope already uses. It also refuses to rename a key another node in scope or the input also writes, since it
|
|
69
|
+
// - rename refuses a name another node's label or key holds in its workflow, or that a reference (as `<name>$...`
|
|
70
|
+
// too), an input or a code source in scope already uses. A label in another workflow (a sibling child's) is free. It also refuses to rename a key another node in scope or the input also writes, since it
|
|
71
71
|
// can't tell whose readers are whose.
|
|
72
72
|
// - renameKey renames the key a node writes: its `as` when it has one (any kind, a map's and a decision node's
|
|
73
73
|
// included), else its label when that is the key, where it gives the document rename gives; with
|
|
@@ -774,16 +774,17 @@ const inputKeys = (doc, entries, scope) => {
|
|
|
774
774
|
keys.add(key);
|
|
775
775
|
return keys;
|
|
776
776
|
};
|
|
777
|
-
/** Every name a key of the scope could clash with: labels (all but `self`'s), keys written, input keys, the
|
|
778
|
-
* references and of the output path, the words of code and shell sources (the key a `<key>$...` head or word
|
|
779
|
-
* included), and the engine's own keys.
|
|
777
|
+
/** Every name a key of the scope could clash with: the scope's labels (all but `self`'s), keys written, input keys, the
|
|
778
|
+
* heads of references and of the output path, the words of code and shell sources (the key a `<key>$...` head or word
|
|
779
|
+
* names included), and the engine's own keys. Another workflow's labels are not among them: a child runs on state of
|
|
780
|
+
* its own, and a run names its steps `<child>/<step>`. */
|
|
780
781
|
const namesUsed = (doc, entries, scope, self) => {
|
|
781
782
|
const used = new Set([...RESERVED_KEYS, ...inputKeys(doc, entries, scope)]);
|
|
782
783
|
for (const entry of entries) {
|
|
783
|
-
if (typeof entry.node.label === "string" && entry !== self)
|
|
784
|
-
used.add(entry.node.label);
|
|
785
784
|
if (entry.scope !== scope)
|
|
786
785
|
continue;
|
|
786
|
+
if (typeof entry.node.label === "string" && entry !== self)
|
|
787
|
+
used.add(entry.node.label);
|
|
787
788
|
for (const key of keysWritten(entry.node))
|
|
788
789
|
used.add(key);
|
|
789
790
|
for (const head of headsRead(entry.node))
|
|
@@ -1120,6 +1121,9 @@ export function setField(doc, path, field, value) {
|
|
|
1120
1121
|
const draft = new Draft();
|
|
1121
1122
|
return finish(draft, before, draft.update(before, [...entry.keys, field], () => value === undefined ? DELETE : clone(value)));
|
|
1122
1123
|
}
|
|
1124
|
+
/** Another node of `entry`'s workflow labelled `name`. A label is unique in its workflow: a child workflow's labels are
|
|
1125
|
+
* its own (a run names its steps `<child>/<step>`). */
|
|
1126
|
+
const labelHolder = (entries, entry, name) => entries.find((other) => other !== entry && other.scope === entry.scope && other.node.label === name);
|
|
1123
1127
|
/** Refuse a key another node of the scope or the scope's input also writes: a rename cannot tell whose readers are whose. */
|
|
1124
1128
|
const checkUnshared = (doc, entries, entry, key) => {
|
|
1125
1129
|
const others = entries.filter((other) => other !== entry && other.scope === entry.scope && keysWritten(other.node).includes(key));
|
|
@@ -1146,7 +1150,7 @@ export function rename(doc, path, name) {
|
|
|
1146
1150
|
const keyed = labelIsKey(node) && typeof node.label === "string";
|
|
1147
1151
|
if (keyed && !KEY_NAME.test(name))
|
|
1148
1152
|
throw new EditError("NAME_INVALID", path, `the label of ${path} is the key it writes, so it takes letters, digits and "_" only: ${JSON.stringify(name)}`);
|
|
1149
|
-
const holder = entries
|
|
1153
|
+
const holder = labelHolder(entries, entry, name);
|
|
1150
1154
|
if (holder)
|
|
1151
1155
|
throw new EditError("NAME_TAKEN", path, `${holder.path} is labelled "${name}"`, [holder.path]);
|
|
1152
1156
|
const relabel = () => draft.update(before, [...entry.keys, "label"], () => name);
|
|
@@ -1189,7 +1193,7 @@ export function renameKey(doc, path, name, options = {}) {
|
|
|
1189
1193
|
throw new EditError("NAME_INVALID", path, `a state key takes letters, digits and "_" only: ${JSON.stringify(name)}`);
|
|
1190
1194
|
refusePrototypeName(name, path);
|
|
1191
1195
|
// The node's own label is a name, not a key: its key may take it.
|
|
1192
|
-
const holder = entries
|
|
1196
|
+
const holder = labelHolder(entries, entry, name);
|
|
1193
1197
|
if (holder)
|
|
1194
1198
|
throw new EditError("NAME_TAKEN", path, `${holder.path} is labelled "${name}"`, [holder.path]);
|
|
1195
1199
|
if (namesUsed(before, entries, entry.scope, entry).has(name))
|