@antongolub/lockfile 0.0.0-snapshot.45 → 0.0.0-snapshot.47
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/SCHEMAS.md +1 -0
- package/dist/{_npm-flat-types-5XRp-_Te.d.ts → _npm-flat-types-BtjAgSy6.d.ts} +5 -1
- package/dist/{_pnpm-flat-core-DtT-PfX-.d.ts → _pnpm-flat-core-u9QE3m8R.d.ts} +5 -1
- package/dist/{_yarn-berry-core-nexIf1L1.d.ts → _yarn-berry-core-tgctDDH2.d.ts} +1 -1
- package/dist/complete.d.ts +1 -1
- package/dist/formats/bun-text.d.ts +1 -1
- package/dist/formats/bun-text.js +53 -14
- package/dist/formats/npm-1.d.ts +1 -1
- package/dist/formats/npm-1.js +50 -14
- package/dist/formats/npm-2.d.ts +2 -2
- package/dist/formats/npm-2.js +306 -29
- package/dist/formats/npm-3.d.ts +2 -2
- package/dist/formats/npm-3.js +306 -29
- package/dist/formats/pnpm-v5.d.ts +1 -1
- package/dist/formats/pnpm-v5.js +92 -18
- package/dist/formats/pnpm-v6.d.ts +2 -2
- package/dist/formats/pnpm-v6.js +241 -98
- package/dist/formats/pnpm-v9.d.ts +2 -2
- package/dist/formats/pnpm-v9.js +241 -98
- package/dist/formats/yarn-berry-v10.d.ts +24 -0
- package/dist/formats/yarn-berry-v10.js +2426 -0
- package/dist/formats/yarn-berry-v4.d.ts +2 -2
- package/dist/formats/yarn-berry-v4.js +167 -34
- package/dist/formats/yarn-berry-v5.d.ts +2 -2
- package/dist/formats/yarn-berry-v5.js +167 -34
- package/dist/formats/yarn-berry-v6.d.ts +2 -2
- package/dist/formats/yarn-berry-v6.js +167 -34
- package/dist/formats/yarn-berry-v7.d.ts +2 -2
- package/dist/formats/yarn-berry-v7.js +167 -34
- package/dist/formats/yarn-berry-v8.d.ts +2 -2
- package/dist/formats/yarn-berry-v8.js +167 -34
- package/dist/formats/yarn-berry-v9.d.ts +2 -2
- package/dist/formats/yarn-berry-v9.js +167 -34
- package/dist/formats/yarn-classic.d.ts +1 -1
- package/dist/formats/yarn-classic.js +50 -14
- package/dist/{graph-DbCmOfBk.d.ts → graph-DlYNIpXt.d.ts} +49 -1
- package/dist/index.d.ts +35 -4
- package/dist/index.js +4121 -3423
- package/dist/{modify-Qsze2kCh.d.ts → modify-DJj58soJ.d.ts} +4 -3
- package/dist/modify.d.ts +2 -2
- package/dist/modify.js +4 -4
- package/dist/optimize-eaNonOKo.d.ts +33 -0
- package/dist/optimize.d.ts +24 -0
- package/dist/optimize.js +132 -0
- package/dist/registry.d.ts +1 -1
- package/package.json +10 -1
package/SCHEMAS.md
CHANGED
|
@@ -33,6 +33,7 @@ berry's `__metadata`.
|
|
|
33
33
|
| `yarn-berry-v6` | `__metadata.version: 6` | yarn `>=3.2 <4` | yarn `>=3.2` |
|
|
34
34
|
| `yarn-berry-v8` | `__metadata.version: 8` | yarn `>=4.0 <4.14` | yarn `>=4` |
|
|
35
35
|
| `yarn-berry-v9` | `__metadata.version: 9` | yarn `>=4.14` | yarn `>=4.14` |
|
|
36
|
+
| `yarn-berry-v10` | `__metadata.version: 10` | yarn 5 (dev branch) | yarn 5+ (preview — reverse-engineered from yarnpkg/berry master) |
|
|
36
37
|
|
|
37
38
|
**Schema numbers that don't exist:**
|
|
38
39
|
- `__metadata.version: 1` and `2` were never used by berry.
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { D as Diagnostic } from './graph-
|
|
1
|
+
import { D as Diagnostic, O as OverrideConstraint } from './graph-DlYNIpXt.js';
|
|
2
2
|
|
|
3
3
|
interface NpmFamilyParseOptions {
|
|
4
4
|
}
|
|
5
5
|
interface NpmFamilyStringifyOptions {
|
|
6
6
|
lineEnding?: 'lf' | 'crlf';
|
|
7
7
|
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
8
|
+
/** Caller-declared overrides (ADR-0025 §4) projected into the root entry's
|
|
9
|
+
* `overrides` block at `packages[""]`. npm-1 (no packages block) cannot
|
|
10
|
+
* carry them — a loss diagnostic fires instead. */
|
|
11
|
+
overrides?: OverrideConstraint[];
|
|
8
12
|
}
|
|
9
13
|
interface NpmFamilyEnrichOptions {
|
|
10
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as Diagnostic } from './graph-
|
|
1
|
+
import { D as Diagnostic, O as OverrideConstraint } from './graph-DlYNIpXt.js';
|
|
2
2
|
|
|
3
3
|
interface PnpmFamilyParseOptions {
|
|
4
4
|
/**
|
|
@@ -15,6 +15,10 @@ interface PnpmFamilyStringifyOptions {
|
|
|
15
15
|
lineEnding?: 'lf' | 'crlf';
|
|
16
16
|
settings?: PnpmSettings;
|
|
17
17
|
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
18
|
+
/** Caller-declared overrides (ADR-0025 §4) overlaid onto the pnpm
|
|
19
|
+
* `overrides:` block. Caller wins per key; pre-existing `patch:` directives
|
|
20
|
+
* (F2) survive on collision. */
|
|
21
|
+
overrides?: OverrideConstraint[];
|
|
18
22
|
}
|
|
19
23
|
interface PnpmManifest {
|
|
20
24
|
name?: string;
|
package/dist/complete.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NodeId, D as Diagnostic, G as Graph, E as EdgeTriple, a as Node, b as EdgeKind } from './graph-
|
|
1
|
+
import { N as NodeId, D as Diagnostic, G as Graph, E as EdgeTriple, a as Node, b as EdgeKind } from './graph-DlYNIpXt.js';
|
|
2
2
|
import { R as RegistryAdapter } from './types-Ci06KZkZ.js';
|
|
3
3
|
|
|
4
4
|
interface CompletionSeed {
|
package/dist/formats/bun-text.js
CHANGED
|
@@ -98,9 +98,13 @@ function tarballKeyInputsOfNode(node) {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
var cmpStr = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
101
|
+
var cmpAlias = (a, b) => a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : cmpStr(a, b);
|
|
101
102
|
var cmpEdgeBy = (end) => (a, b) => {
|
|
102
103
|
const c = cmpStr(end === "dst" ? a.dst : a.src, end === "dst" ? b.dst : b.src);
|
|
103
|
-
|
|
104
|
+
if (c !== 0) return c;
|
|
105
|
+
const k = cmpStr(a.kind, b.kind);
|
|
106
|
+
if (k !== 0) return k;
|
|
107
|
+
return cmpAlias(a.attrs?.alias, b.attrs?.alias);
|
|
104
108
|
};
|
|
105
109
|
function emptyState() {
|
|
106
110
|
return {
|
|
@@ -136,7 +140,7 @@ function removeMatching(arr, pred) {
|
|
|
136
140
|
arr.splice(i, 1);
|
|
137
141
|
return true;
|
|
138
142
|
}
|
|
139
|
-
var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}`;
|
|
143
|
+
var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}\0${e.attrs?.alias ?? ""}`;
|
|
140
144
|
function rebindNodeId(s, oldId, newId, newNode) {
|
|
141
145
|
s.nodes.set(newId, newNode);
|
|
142
146
|
s.nodes.delete(oldId);
|
|
@@ -146,7 +150,9 @@ function rebindNodeId(s, oldId, newId, newNode) {
|
|
|
146
150
|
for (const e of outs) {
|
|
147
151
|
const peerInc = s.incoming.get(e.dst);
|
|
148
152
|
if (peerInc) {
|
|
149
|
-
const idx = peerInc.findIndex(
|
|
153
|
+
const idx = peerInc.findIndex(
|
|
154
|
+
(x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst && x.attrs?.alias === e.attrs?.alias
|
|
155
|
+
);
|
|
150
156
|
if (idx >= 0) peerInc[idx] = e;
|
|
151
157
|
}
|
|
152
158
|
}
|
|
@@ -156,11 +162,25 @@ function rebindNodeId(s, oldId, newId, newNode) {
|
|
|
156
162
|
for (const e of ins) {
|
|
157
163
|
const peerOut = s.outgoing.get(e.src);
|
|
158
164
|
if (peerOut) {
|
|
159
|
-
const idx = peerOut.findIndex(
|
|
165
|
+
const idx = peerOut.findIndex(
|
|
166
|
+
(x) => x.src === e.src && x.kind === e.kind && x.dst === oldId && x.attrs?.alias === e.attrs?.alias
|
|
167
|
+
);
|
|
160
168
|
if (idx >= 0) peerOut[idx] = e;
|
|
161
169
|
}
|
|
162
170
|
}
|
|
163
171
|
}
|
|
172
|
+
function protocolOf(range) {
|
|
173
|
+
const colonIdx = range.indexOf(":");
|
|
174
|
+
if (colonIdx <= 0) return void 0;
|
|
175
|
+
const prefix = range.slice(0, colonIdx);
|
|
176
|
+
return /^[a-z][a-z0-9+.-]*$/i.test(prefix) ? prefix : void 0;
|
|
177
|
+
}
|
|
178
|
+
function isPublishedSelfLink(edge) {
|
|
179
|
+
const range = edge.attrs?.range;
|
|
180
|
+
if (range === void 0) return false;
|
|
181
|
+
const proto = protocolOf(range);
|
|
182
|
+
return proto === void 0 || proto === "npm";
|
|
183
|
+
}
|
|
164
184
|
function validate(s) {
|
|
165
185
|
for (const d of s.diagnostics) {
|
|
166
186
|
if (d.severity === "error") {
|
|
@@ -178,16 +198,26 @@ function validate(s) {
|
|
|
178
198
|
}
|
|
179
199
|
const k = tripleKey(e);
|
|
180
200
|
if (seen.has(k)) {
|
|
181
|
-
|
|
201
|
+
const aliasSuffix = e.attrs?.alias !== void 0 ? ` (alias=${e.attrs.alias})` : "";
|
|
202
|
+
throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}${aliasSuffix}`);
|
|
182
203
|
}
|
|
183
204
|
seen.add(k);
|
|
184
205
|
}
|
|
185
206
|
}
|
|
186
207
|
for (const [id, node] of s.nodes) {
|
|
187
208
|
if (node.workspacePath !== void 0) {
|
|
188
|
-
const inc = s.incoming.get(id);
|
|
189
|
-
|
|
190
|
-
|
|
209
|
+
const inc = s.incoming.get(id) ?? [];
|
|
210
|
+
for (const edge of inc) {
|
|
211
|
+
if (s.nodes.get(edge.src)?.workspacePath !== void 0) continue;
|
|
212
|
+
if (isPublishedSelfLink(edge)) {
|
|
213
|
+
s.diagnostics.push({
|
|
214
|
+
code: "SEAL_PUBLISHED_SELF_LINK",
|
|
215
|
+
subject: id,
|
|
216
|
+
severity: "info",
|
|
217
|
+
message: `published self-link: ${edge.src} \u2192${edge.kind} ${id} (range ${edge.attrs?.range}) \u2014 published dependency resolved to co-located workspace`
|
|
218
|
+
});
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
191
221
|
throw new GraphError("INVARIANT_VIOLATION", `workspace node has incoming edges: ${id}`);
|
|
192
222
|
}
|
|
193
223
|
}
|
|
@@ -195,8 +225,8 @@ function validate(s) {
|
|
|
195
225
|
if (!expected.includes(id)) {
|
|
196
226
|
throw new GraphError("INVARIANT_VIOLATION", `node id ${id} disagrees with derived id ${expected.join(" or ")}`);
|
|
197
227
|
}
|
|
198
|
-
const peerEdgeTargets = (s.outgoing.get(id) ?? []).filter((e) => e.kind === "peer").map((e) => e.dst).sort();
|
|
199
|
-
const peerCtx = node.peerContext.
|
|
228
|
+
const peerEdgeTargets = (s.outgoing.get(id) ?? []).filter((e) => e.kind === "peer").map((e) => stripPeerContextFromNodeId(e.dst)).sort();
|
|
229
|
+
const peerCtx = node.peerContext.map(stripPeerContextFromNodeId).sort();
|
|
200
230
|
if (peerEdgeTargets.length !== peerCtx.length || peerEdgeTargets.some((t, i) => t !== peerCtx[i])) {
|
|
201
231
|
throw new GraphError("INVARIANT_VIOLATION", `peer edges of ${id} disagree with peerContext`);
|
|
202
232
|
}
|
|
@@ -468,8 +498,10 @@ var GraphImpl = class _GraphImpl {
|
|
|
468
498
|
if (!next.nodes.has(src)) throw new GraphError("PATCH_REJECTED", `addEdge: src ${src} missing`);
|
|
469
499
|
if (!next.nodes.has(dst)) throw new GraphError("PATCH_REJECTED", `addEdge: dst ${dst} missing`);
|
|
470
500
|
const existing = next.outgoing.get(src) ?? [];
|
|
471
|
-
|
|
472
|
-
|
|
501
|
+
const newAlias = attrs?.alias;
|
|
502
|
+
if (existing.some((e2) => e2.dst === dst && e2.kind === kind && e2.attrs?.alias === newAlias)) {
|
|
503
|
+
const aliasSuffix = newAlias !== void 0 ? ` (alias=${newAlias})` : "";
|
|
504
|
+
throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}${aliasSuffix}`);
|
|
473
505
|
}
|
|
474
506
|
const e = attrs ? { src, dst, kind, attrs } : { src, dst, kind };
|
|
475
507
|
pushTo(next.outgoing, src, e);
|
|
@@ -478,11 +510,15 @@ var GraphImpl = class _GraphImpl {
|
|
|
478
510
|
},
|
|
479
511
|
removeEdge(src, dst, kind) {
|
|
480
512
|
const outs = next.outgoing.get(src);
|
|
481
|
-
|
|
513
|
+
let removedAlias;
|
|
514
|
+
const found = outs?.findIndex((e) => e.dst === dst && e.kind === kind) ?? -1;
|
|
515
|
+
if (!outs || found < 0) {
|
|
482
516
|
throw new GraphError("PATCH_REJECTED", `removeEdge: ${src} \u2192${kind} ${dst} missing`);
|
|
483
517
|
}
|
|
518
|
+
removedAlias = outs[found]?.attrs?.alias;
|
|
519
|
+
outs.splice(found, 1);
|
|
484
520
|
const ins = next.incoming.get(dst);
|
|
485
|
-
if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind);
|
|
521
|
+
if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind && e.attrs?.alias === removedAlias);
|
|
486
522
|
applied.push({ kind: "edge-removed", subject: { src, dst, kind } });
|
|
487
523
|
},
|
|
488
524
|
replacePeerContext(id, peers) {
|
|
@@ -854,8 +890,11 @@ function parse(input, _options = {}) {
|
|
|
854
890
|
if (srcId === void 0) continue;
|
|
855
891
|
addBlockEdges(builder, diagnostics, srcId, ws.manifest, packageByName, workspaceByPath, peerDeclarations);
|
|
856
892
|
}
|
|
893
|
+
const emittedSrc = /* @__PURE__ */ new Set();
|
|
857
894
|
for (const [packagesKey, entry] of entriesByKey) {
|
|
858
895
|
if (entry.inner === void 0) continue;
|
|
896
|
+
if (emittedSrc.has(entry.id)) continue;
|
|
897
|
+
emittedSrc.add(entry.id);
|
|
859
898
|
const consumerScope = buildConsumerScope(packagesKey, packages, packageByName);
|
|
860
899
|
addBlockEdges(builder, diagnostics, entry.id, entry.inner, consumerScope, void 0, peerDeclarations);
|
|
861
900
|
}
|
package/dist/formats/npm-1.d.ts
CHANGED
package/dist/formats/npm-1.js
CHANGED
|
@@ -99,9 +99,13 @@ function tarballKeyInputsOfNode(node) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
var cmpStr = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
102
|
+
var cmpAlias = (a, b) => a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : cmpStr(a, b);
|
|
102
103
|
var cmpEdgeBy = (end) => (a, b) => {
|
|
103
104
|
const c = cmpStr(end === "dst" ? a.dst : a.src, end === "dst" ? b.dst : b.src);
|
|
104
|
-
|
|
105
|
+
if (c !== 0) return c;
|
|
106
|
+
const k = cmpStr(a.kind, b.kind);
|
|
107
|
+
if (k !== 0) return k;
|
|
108
|
+
return cmpAlias(a.attrs?.alias, b.attrs?.alias);
|
|
105
109
|
};
|
|
106
110
|
function emptyState() {
|
|
107
111
|
return {
|
|
@@ -137,7 +141,7 @@ function removeMatching(arr, pred) {
|
|
|
137
141
|
arr.splice(i, 1);
|
|
138
142
|
return true;
|
|
139
143
|
}
|
|
140
|
-
var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}`;
|
|
144
|
+
var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}\0${e.attrs?.alias ?? ""}`;
|
|
141
145
|
function rebindNodeId(s, oldId, newId, newNode) {
|
|
142
146
|
s.nodes.set(newId, newNode);
|
|
143
147
|
s.nodes.delete(oldId);
|
|
@@ -147,7 +151,9 @@ function rebindNodeId(s, oldId, newId, newNode) {
|
|
|
147
151
|
for (const e of outs) {
|
|
148
152
|
const peerInc = s.incoming.get(e.dst);
|
|
149
153
|
if (peerInc) {
|
|
150
|
-
const idx = peerInc.findIndex(
|
|
154
|
+
const idx = peerInc.findIndex(
|
|
155
|
+
(x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst && x.attrs?.alias === e.attrs?.alias
|
|
156
|
+
);
|
|
151
157
|
if (idx >= 0) peerInc[idx] = e;
|
|
152
158
|
}
|
|
153
159
|
}
|
|
@@ -157,11 +163,25 @@ function rebindNodeId(s, oldId, newId, newNode) {
|
|
|
157
163
|
for (const e of ins) {
|
|
158
164
|
const peerOut = s.outgoing.get(e.src);
|
|
159
165
|
if (peerOut) {
|
|
160
|
-
const idx = peerOut.findIndex(
|
|
166
|
+
const idx = peerOut.findIndex(
|
|
167
|
+
(x) => x.src === e.src && x.kind === e.kind && x.dst === oldId && x.attrs?.alias === e.attrs?.alias
|
|
168
|
+
);
|
|
161
169
|
if (idx >= 0) peerOut[idx] = e;
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
}
|
|
173
|
+
function protocolOf(range) {
|
|
174
|
+
const colonIdx = range.indexOf(":");
|
|
175
|
+
if (colonIdx <= 0) return void 0;
|
|
176
|
+
const prefix = range.slice(0, colonIdx);
|
|
177
|
+
return /^[a-z][a-z0-9+.-]*$/i.test(prefix) ? prefix : void 0;
|
|
178
|
+
}
|
|
179
|
+
function isPublishedSelfLink(edge) {
|
|
180
|
+
const range = edge.attrs?.range;
|
|
181
|
+
if (range === void 0) return false;
|
|
182
|
+
const proto = protocolOf(range);
|
|
183
|
+
return proto === void 0 || proto === "npm";
|
|
184
|
+
}
|
|
165
185
|
function validate(s) {
|
|
166
186
|
for (const d of s.diagnostics) {
|
|
167
187
|
if (d.severity === "error") {
|
|
@@ -179,16 +199,26 @@ function validate(s) {
|
|
|
179
199
|
}
|
|
180
200
|
const k = tripleKey(e);
|
|
181
201
|
if (seen.has(k)) {
|
|
182
|
-
|
|
202
|
+
const aliasSuffix = e.attrs?.alias !== void 0 ? ` (alias=${e.attrs.alias})` : "";
|
|
203
|
+
throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}${aliasSuffix}`);
|
|
183
204
|
}
|
|
184
205
|
seen.add(k);
|
|
185
206
|
}
|
|
186
207
|
}
|
|
187
208
|
for (const [id, node] of s.nodes) {
|
|
188
209
|
if (node.workspacePath !== void 0) {
|
|
189
|
-
const inc = s.incoming.get(id);
|
|
190
|
-
|
|
191
|
-
|
|
210
|
+
const inc = s.incoming.get(id) ?? [];
|
|
211
|
+
for (const edge of inc) {
|
|
212
|
+
if (s.nodes.get(edge.src)?.workspacePath !== void 0) continue;
|
|
213
|
+
if (isPublishedSelfLink(edge)) {
|
|
214
|
+
s.diagnostics.push({
|
|
215
|
+
code: "SEAL_PUBLISHED_SELF_LINK",
|
|
216
|
+
subject: id,
|
|
217
|
+
severity: "info",
|
|
218
|
+
message: `published self-link: ${edge.src} \u2192${edge.kind} ${id} (range ${edge.attrs?.range}) \u2014 published dependency resolved to co-located workspace`
|
|
219
|
+
});
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
192
222
|
throw new GraphError("INVARIANT_VIOLATION", `workspace node has incoming edges: ${id}`);
|
|
193
223
|
}
|
|
194
224
|
}
|
|
@@ -196,8 +226,8 @@ function validate(s) {
|
|
|
196
226
|
if (!expected.includes(id)) {
|
|
197
227
|
throw new GraphError("INVARIANT_VIOLATION", `node id ${id} disagrees with derived id ${expected.join(" or ")}`);
|
|
198
228
|
}
|
|
199
|
-
const peerEdgeTargets = (s.outgoing.get(id) ?? []).filter((e) => e.kind === "peer").map((e) => e.dst).sort();
|
|
200
|
-
const peerCtx = node.peerContext.
|
|
229
|
+
const peerEdgeTargets = (s.outgoing.get(id) ?? []).filter((e) => e.kind === "peer").map((e) => stripPeerContextFromNodeId(e.dst)).sort();
|
|
230
|
+
const peerCtx = node.peerContext.map(stripPeerContextFromNodeId).sort();
|
|
201
231
|
if (peerEdgeTargets.length !== peerCtx.length || peerEdgeTargets.some((t, i) => t !== peerCtx[i])) {
|
|
202
232
|
throw new GraphError("INVARIANT_VIOLATION", `peer edges of ${id} disagree with peerContext`);
|
|
203
233
|
}
|
|
@@ -469,8 +499,10 @@ var GraphImpl = class _GraphImpl {
|
|
|
469
499
|
if (!next.nodes.has(src)) throw new GraphError("PATCH_REJECTED", `addEdge: src ${src} missing`);
|
|
470
500
|
if (!next.nodes.has(dst)) throw new GraphError("PATCH_REJECTED", `addEdge: dst ${dst} missing`);
|
|
471
501
|
const existing = next.outgoing.get(src) ?? [];
|
|
472
|
-
|
|
473
|
-
|
|
502
|
+
const newAlias = attrs?.alias;
|
|
503
|
+
if (existing.some((e2) => e2.dst === dst && e2.kind === kind && e2.attrs?.alias === newAlias)) {
|
|
504
|
+
const aliasSuffix = newAlias !== void 0 ? ` (alias=${newAlias})` : "";
|
|
505
|
+
throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}${aliasSuffix}`);
|
|
474
506
|
}
|
|
475
507
|
const e = attrs ? { src, dst, kind, attrs } : { src, dst, kind };
|
|
476
508
|
pushTo(next.outgoing, src, e);
|
|
@@ -479,11 +511,15 @@ var GraphImpl = class _GraphImpl {
|
|
|
479
511
|
},
|
|
480
512
|
removeEdge(src, dst, kind) {
|
|
481
513
|
const outs = next.outgoing.get(src);
|
|
482
|
-
|
|
514
|
+
let removedAlias;
|
|
515
|
+
const found = outs?.findIndex((e) => e.dst === dst && e.kind === kind) ?? -1;
|
|
516
|
+
if (!outs || found < 0) {
|
|
483
517
|
throw new GraphError("PATCH_REJECTED", `removeEdge: ${src} \u2192${kind} ${dst} missing`);
|
|
484
518
|
}
|
|
519
|
+
removedAlias = outs[found]?.attrs?.alias;
|
|
520
|
+
outs.splice(found, 1);
|
|
485
521
|
const ins = next.incoming.get(dst);
|
|
486
|
-
if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind);
|
|
522
|
+
if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind && e.attrs?.alias === removedAlias);
|
|
487
523
|
applied.push({ kind: "edge-removed", subject: { src, dst, kind } });
|
|
488
524
|
},
|
|
489
525
|
replacePeerContext(id, peers) {
|
package/dist/formats/npm-2.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as Graph, D as Diagnostic } from '../graph-
|
|
2
|
-
import { N as NpmFamilyEnrichOptions, a as NpmFamilyOptimizeOptions, b as NpmFamilyParseOptions, c as NpmFamilyStringifyOptions } from '../_npm-flat-types-
|
|
1
|
+
import { G as Graph, D as Diagnostic } from '../graph-DlYNIpXt.js';
|
|
2
|
+
import { N as NpmFamilyEnrichOptions, a as NpmFamilyOptimizeOptions, b as NpmFamilyParseOptions, c as NpmFamilyStringifyOptions } from '../_npm-flat-types-BtjAgSy6.js';
|
|
3
3
|
|
|
4
4
|
interface Npm2ParseOptions extends NpmFamilyParseOptions {
|
|
5
5
|
}
|