@sigloch/graph-api-core 5.9.0 → 5.10.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/dist/format-e-codec.js
CHANGED
|
@@ -390,11 +390,17 @@ export class FormatECodec {
|
|
|
390
390
|
// CR-SM-324: no legality verdict while parsing — the parser knows neither label nor
|
|
391
391
|
// the kinds of existing nodes. The write path judges with the one rule (gate R-18,
|
|
392
392
|
// GraphService.validateAndApplyEdge).
|
|
393
|
+
// ITEM-2026-604: `~` an einer Kante ist ein PATCH (update_edge) — symmetrisch zu `~` am Knoten.
|
|
394
|
+
// Vorher fiel `~` hier auf add_edge; ein Typwechsel liess sich nur als Loeschen + Anlegen
|
|
395
|
+
// schreiben und verlor dabei die Attribute der Kante. Typwechsel/Flip reisen als reservierte
|
|
396
|
+
// Attribute `__edgeType` / `__flip` (wie `__name` am Knoten); der Konsument bildet sie ab.
|
|
393
397
|
const opType = action === 'remove'
|
|
394
398
|
? 'remove_edge'
|
|
395
399
|
: action === 'strict_add'
|
|
396
400
|
? 'strict_add_edge'
|
|
397
|
-
: '
|
|
401
|
+
: action === 'update'
|
|
402
|
+
? 'update_edge'
|
|
403
|
+
: 'add_edge';
|
|
398
404
|
const op = {
|
|
399
405
|
type: opType,
|
|
400
406
|
semanticId: `${sourceId}->${targetId}`,
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* update-node `~ uid[|beschreibung]` — ein Patch: ohne Pipe bleibt die Beschreibung, wie sie ist
|
|
10
10
|
* delete-node `- uid` unter dem Typabschnitt (die Sprache verlangt ihn fuer jede Knotenzeile)
|
|
11
11
|
* delete-edge `- A -t-> B`
|
|
12
|
-
* update-edge
|
|
12
|
+
* update-edge `~ A -t-> B [__edgeType:…,__flip:true,k:v]` — ein Patch: die Kante behaelt ihre
|
|
13
|
+
* Attribute (Loeschen + Anlegen verlore sie); Typwechsel und Flip als reservierte Attribute
|
|
13
14
|
* merge-nodes `M quelle + ziel`
|
|
14
15
|
*
|
|
15
16
|
* Den Typ eines Knotens, den der Batch nicht anlegt, kennt nur der Bestand — `typeOf` liefert ihn.
|
|
@@ -21,6 +21,7 @@ export function commandsToFormatE(commands, typeOf = () => undefined) {
|
|
|
21
21
|
return z;
|
|
22
22
|
};
|
|
23
23
|
const loeschKanten = [];
|
|
24
|
+
const patchKanten = [];
|
|
24
25
|
const neueKanten = [];
|
|
25
26
|
const merges = [];
|
|
26
27
|
for (const c of commands) {
|
|
@@ -46,18 +47,16 @@ export function commandsToFormatE(commands, typeOf = () => undefined) {
|
|
|
46
47
|
case 'delete-edge':
|
|
47
48
|
loeschKanten.push(`- ${c.edge.sourceId} -${c.edge.edgeType}-> ${c.edge.targetId}`);
|
|
48
49
|
break;
|
|
49
|
-
case 'update-edge':
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
attributes: c.set.attributes ?? {},
|
|
50
|
+
case 'update-edge':
|
|
51
|
+
patchKanten.push({
|
|
52
|
+
...c.edge,
|
|
53
|
+
attributes: {
|
|
54
|
+
...(c.set.attributes ?? {}),
|
|
55
|
+
...(c.set.edgeType !== undefined ? { __edgeType: c.set.edgeType } : {}),
|
|
56
|
+
...(c.set.flip === true ? { __flip: true } : {}),
|
|
57
|
+
},
|
|
58
58
|
});
|
|
59
59
|
break;
|
|
60
|
-
}
|
|
61
60
|
case 'merge-nodes':
|
|
62
61
|
merges.push(`M ${c.sourceUid} + ${c.targetUid}`);
|
|
63
62
|
break;
|
|
@@ -69,12 +68,14 @@ export function commandsToFormatE(commands, typeOf = () => undefined) {
|
|
|
69
68
|
}
|
|
70
69
|
// OHNE roundTrip: dessen Validierung verlangt jeden Endpunkt als Knoten im selben Graphen —
|
|
71
70
|
// ein Batch haengt aber an Knoten, die im Bestand stehen.
|
|
72
|
-
const
|
|
73
|
-
? SE_FORMAT_E_CODEC.serialize({ nodes: [], edges:
|
|
71
|
+
const kantenZeilen = (kanten) => kanten.length
|
|
72
|
+
? SE_FORMAT_E_CODEC.serialize({ nodes: [], edges: kanten }).trim().split('\n').filter((z) => z !== '## Edges')
|
|
74
73
|
: [];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
const anlegen = kantenZeilen(neueKanten);
|
|
75
|
+
const patchen = kantenZeilen(patchKanten).map((z) => z.replace(/^\+ /, '~ '));
|
|
76
|
+
if (loeschKanten.length + patchen.length + anlegen.length > 0) {
|
|
77
|
+
teile.push(['## Edges', ...loeschKanten, ...patchen, ...anlegen].join('\n'));
|
|
78
|
+
}
|
|
78
79
|
if (merges.length > 0)
|
|
79
80
|
teile.push(['## Merges', ...merges].join('\n'));
|
|
80
81
|
return teile.join('\n\n');
|