@sigloch/graph-api-core 6.1.0 → 6.1.1

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.
@@ -7,7 +7,7 @@
7
7
  * family (`TYPE-slug`, `Name.TypeAbbr.Counter`, `cand_<hex>`); typing by spelling made
8
8
  * every foreign convention fail silently instead of loudly.
9
9
  */
10
- import { hydrateAttrValue, attributeTypeOf } from '@sigloch/contracts/se';
10
+ import { hydrateAttrValue, attributeTypeOf, Trace } from '@sigloch/contracts/se';
11
11
  // ---------------------------------------------------------------------------
12
12
  // Regex patterns
13
13
  // ---------------------------------------------------------------------------
@@ -362,11 +362,17 @@ export class FormatECodec {
362
362
  // CR-SM-251: Kanten-Attribute (cardinality/constraint/notes) sind Strings und bleiben es —
363
363
  // `attributeTypeOf` kennt nur Element-Attribute, ohne Typ faellt die Hydrierung auf String
364
364
  // zurueck. Der Typ ist trotzdem `unknown`, damit hier kein zweiter Hydrations-Pfad entsteht.
365
+ // CR-SM-479: einzige Ausnahme `weight` — der Trace-Vertrag (`Trace.shape.weight`) verlangt eine
366
+ // Zahl. Eine Nicht-Zahl ist ein Parse-Fehler mit der Zeile, kein String und kein Default.
365
367
  let inlineAttrs;
366
368
  const attrMatch = INLINE_ATTRS_RE.exec(rest);
367
369
  if (attrMatch) {
368
370
  mainPart = rest.slice(0, attrMatch.index).trim();
369
- inlineAttrs = this.parseInlineAttrs(attrMatch[1]);
371
+ inlineAttrs = this.parseInlineAttrs(attrMatch[1], undefined, 'weight');
372
+ if (inlineAttrs.weight !== undefined && !Trace.shape.weight.safeParse(inlineAttrs.weight).success) {
373
+ errors.push(`Edge attribute "weight" must be a number, got "${String(inlineAttrs.weight)}" in: "${line}"`);
374
+ return;
375
+ }
370
376
  }
371
377
  // Parse: sourceId -arrowType-> targetId[, targetId2, ...]
372
378
  const arrowMatch = /^(\S+)\s+-(\w+)->\s+(.+)$/.exec(mainPart);
@@ -442,13 +448,14 @@ export class FormatECodec {
442
448
  * als String "true" ankam und jede `=== true`-Ausnahme wirkungslos blieb (CR-GC-334 hatte
443
449
  * genau diese Doppelung schon einmal fuer Objekte aufgeloest, nur eine Zeile weiter oben).
444
450
  */
445
- parseInlineAttrs(raw, nodeType) {
451
+ parseInlineAttrs(raw, nodeType, numberKey) {
446
452
  const attrs = {};
447
453
  for (const pair of raw.split(',')) {
448
454
  const colonIdx = pair.indexOf(':');
449
455
  if (colonIdx > 0) {
450
456
  const key = pair.slice(0, colonIdx).trim();
451
- attrs[key] = hydrateAttrValue(pair.slice(colonIdx + 1).trim(), attributeTypeOf(nodeType, key));
457
+ const declared = key === numberKey ? 'number' : attributeTypeOf(nodeType, key);
458
+ attrs[key] = hydrateAttrValue(pair.slice(colonIdx + 1).trim(), declared);
452
459
  }
453
460
  }
454
461
  return attrs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigloch/graph-api-core",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",