@pubid/pubid 0.1.67 → 0.1.69
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/flavors/iec/index.js +59 -0
- package/dist/flavors/iec/model.d.ts +46 -0
- package/dist/flavors/iec/model.js +232 -3
- package/package.json +1 -1
|
@@ -700,6 +700,64 @@ function rejectStandaloneDottedSupplement(id) {
|
|
|
700
700
|
node = base;
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
|
+
// --- the un-renderable trailing-edition chain reject (pubid#788) --------
|
|
704
|
+
// The bare consolidated chain with a trailing edition
|
|
705
|
+
// ("IEC 60068:2005+AMD1:2012 ED2") parses, and then cannot render: the
|
|
706
|
+
// edition rides the base member, so the composition prints it onto the
|
|
707
|
+
// base designation ("IEC 60068:2005 ED2+AMD1:2012") — a face no IEC
|
|
708
|
+
// source prints (0 of the 33,070 primary docidentifiers in
|
|
709
|
+
// relaton-data-iec carry an edition facet on a chain) and the grammar
|
|
710
|
+
// rejects, so parse(render) raises. The consolidated edition IS the CSV
|
|
711
|
+
// product ("IEC 60034-18-41:2014+AMD1:2019 CSV", the OBP PDF named
|
|
712
|
+
// {ed1.1}); where the printed edition appears at all it is the CSV
|
|
713
|
+
// face's own facet ("IEC 60068:2005+AMD1:2012 CSV ED1" — the Vap carries
|
|
714
|
+
// the edition after the deliverable code and renders back parseably).
|
|
715
|
+
// So the shape is rejected at parse — the #727 ruling for unattested,
|
|
716
|
+
// un-renderable faces — rather than built unrenderable. The check is the
|
|
717
|
+
// SHAPE on the built object, not a grammar route (the same ruling as
|
|
718
|
+
// rejectStandaloneDottedSupplement): a bare ConsolidatedIdentifier with
|
|
719
|
+
// an edition on any member, found by the gem's descend_wrapper walk (a
|
|
720
|
+
// node with a `base` attribute descends to it, a node with `identifiers`
|
|
721
|
+
// to its first member). from_hash stays open (stored-data
|
|
722
|
+
// compatibility): parse can no longer produce the shape and no stored
|
|
723
|
+
// row carries it. The edition-bearing face that DOES round-trip is the
|
|
724
|
+
// CSV one ("IEC 60068:2005+AMD1:2012 CSV ED1" — the edition rides the
|
|
725
|
+
// Vap after the deliverable code).
|
|
726
|
+
const CONSOLIDATED_EDITION_MESSAGE = 'the bare consolidated chain carries a trailing edition ' +
|
|
727
|
+
'(e.g. "IEC 60068:2005+AMD1:2012 ED2"): no IEC source prints one — ' +
|
|
728
|
+
"0 of the 33,070 primary docidentifiers in relaton-data-iec carry an " +
|
|
729
|
+
"edition facet on a chain — and the canonical render prints the " +
|
|
730
|
+
'edition onto the base designation ("IEC 60068:2005 ED2+AMD1:2012"), ' +
|
|
731
|
+
"which cannot be re-parsed. The consolidated edition is the CSV face " +
|
|
732
|
+
'("IEC 60034-18-41:2014+AMD1:2019 CSV", the OBP PDF named {ed1.1}); ' +
|
|
733
|
+
'where the printed edition appears it rides the CSV face ("IEC ' +
|
|
734
|
+
'60068:2005+AMD1:2012 CSV ED1"), which parses and round-trips';
|
|
735
|
+
function rejectUnrenderableConsolidatedEdition(id) {
|
|
736
|
+
let node = id;
|
|
737
|
+
while (node !== undefined) {
|
|
738
|
+
if (node.constructor.polymorphicName === "pubid:iec:consolidated-identifier") {
|
|
739
|
+
const members = node.identifiers ?? [];
|
|
740
|
+
if (members.some((member) => member["edition"] !== undefined &&
|
|
741
|
+
member["edition"] !== null)) {
|
|
742
|
+
throw new ParseFailed(CONSOLIDATED_EDITION_MESSAGE, 0);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
// Ruby descend_wrapper: a node whose class declares a `base`
|
|
746
|
+
// attribute descends to it; a node with `identifiers` to its first
|
|
747
|
+
// member; a leaf ends the walk.
|
|
748
|
+
const attrs = node.constructor
|
|
749
|
+
.attributes;
|
|
750
|
+
if (attrs !== undefined && "base" in attrs) {
|
|
751
|
+
node = node["base"];
|
|
752
|
+
}
|
|
753
|
+
else if (attrs !== undefined && "identifiers" in attrs) {
|
|
754
|
+
node = node.identifiers?.[0];
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
node = undefined;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
703
761
|
export function iecGrammarImplementation() {
|
|
704
762
|
const builder = new IecBuilder();
|
|
705
763
|
return {
|
|
@@ -748,6 +806,7 @@ export function iecGrammarImplementation() {
|
|
|
748
806
|
// walks the base chain after ensure_base) — BSI's delegation and
|
|
749
807
|
// every parse route raise through this entry; from_hash stays open.
|
|
750
808
|
rejectStandaloneDottedSupplement(built);
|
|
809
|
+
rejectUnrenderableConsolidatedEdition(built);
|
|
751
810
|
return built;
|
|
752
811
|
},
|
|
753
812
|
};
|
|
@@ -50,6 +50,52 @@ export declare abstract class IecIdentifier extends BaseIdentifier {
|
|
|
50
50
|
numberPortion(): string;
|
|
51
51
|
stageIterationValue(): string | undefined;
|
|
52
52
|
languagePortion(): string;
|
|
53
|
+
/** The supplement/wrapper suffix hook (ruby Identifier#mr_supplement_suffix):
|
|
54
|
+
* `{type}.{number}.{year}` for supplements, nil for every other class. The
|
|
55
|
+
* base returns nil; the IEC supplement class carries the override. */
|
|
56
|
+
mrSupplementSuffix(): string | undefined;
|
|
57
|
+
/** The machine-readable slug (ruby Identifier#to_mr_string): the flat MR
|
|
58
|
+
* segments joined with ".". Wrapper classes override to compose their
|
|
59
|
+
* chain (Consolidated/Vap/Supplement); every other class takes this path,
|
|
60
|
+
* which is byte-identical with what the shared renderer produces for it.
|
|
61
|
+
* The all-parts form has no MR (ruby Pubid::AllParts#render raises
|
|
62
|
+
* NotImplementedError — the all-parts TS boolean is that wrapper). */
|
|
63
|
+
toMrString(): string;
|
|
64
|
+
/** Ruby Identifier#mr_publisher: the publisher, lowercased, "/" dash-joined
|
|
65
|
+
* ("iso-iec"). The copublishers are a separate attribute and contribute no
|
|
66
|
+
* segment (the shared hook reads the publisher only). */
|
|
67
|
+
protected mrPublisher(): string | undefined;
|
|
68
|
+
/** Ruby Identifier#mr_type: the typed stage's type code, lowercased; nil for
|
|
69
|
+
* the international standard (the default face carries no type token). */
|
|
70
|
+
protected mrType(): string | undefined;
|
|
71
|
+
/** Ruby Identifier#mr_number_with_part: number-part-subpart, dash-joined,
|
|
72
|
+
* lowercased; nil without a number (a hook returning "" would gain a blank
|
|
73
|
+
* segment and a double dot in the slug). */
|
|
74
|
+
protected mrNumberWithPart(): string | undefined;
|
|
75
|
+
/** Ruby Identifier#mr_year: the year, month/day dash-extended; "--" when the
|
|
76
|
+
* date is undated; nil without a date. */
|
|
77
|
+
protected mrYear(): string | undefined;
|
|
78
|
+
/** Ruby Identifier#mr_edition: "ed{number}" — the IEC edition is the
|
|
79
|
+
* Components::Edition component, and the hook reads its number. */
|
|
80
|
+
protected mrEdition(): string | undefined;
|
|
81
|
+
/** Ruby Identifier#mr_languages: the language codes, hyphen-joined, no
|
|
82
|
+
* parens (parens are shell-/URL-unsafe). */
|
|
83
|
+
protected mrLanguages(): string | undefined;
|
|
84
|
+
/** The standard this identifier supplements, dropping its own supplement
|
|
85
|
+
* layer (one level). The base supplements nothing, so it is returned
|
|
86
|
+
* unchanged; the consolidated chain overrides to yield its leading member. */
|
|
87
|
+
dropSupplements(): IecIdentifier;
|
|
88
|
+
/** Excluded attributes are dropped; every other value passes through
|
|
89
|
+
* excludeFromNested so the exclusion also propagates into nested
|
|
90
|
+
* identifiers (wrapper types store their identity on an inner member).
|
|
91
|
+
* :amendment / :supplement are structural, not attributes — they reduce a
|
|
92
|
+
* supplemented identifier to the standard it wraps (#dropSupplements). */
|
|
93
|
+
exclude(...args: string[]): IecIdentifier;
|
|
94
|
+
/** Fuzz-level equality: two identifiers match when they are equal after
|
|
95
|
+
* excluding the given aspects. `ignore` accepts the same symbols as
|
|
96
|
+
* #exclude (e.g. "date", "edition", "amendment"). The primitive relaton
|
|
97
|
+
* uses to match a reference against catalogue hits at varying strictness. */
|
|
98
|
+
matches(other: IecIdentifier, ignore?: string[]): boolean;
|
|
53
99
|
}
|
|
54
100
|
export declare const IEC_CLASSES: {
|
|
55
101
|
readonly KIND_CLASSES: Partial<Record<IecTypeCode, IdentifierStatic>>;
|
|
@@ -77,7 +77,12 @@ export const TYPED_STAGES = [
|
|
|
77
77
|
TS("pnw", "pnw", "is", "PNW", "10.20"),
|
|
78
78
|
TS("anw", "anw", "is", "ANW", "10.99", ["ANW"]),
|
|
79
79
|
TS("wd", "wd", "is", "WD", "20.20"),
|
|
80
|
-
|
|
80
|
+
// The CD-family rows lead the correspondence table's own CD code,
|
|
81
|
+
// 30.20 ("Draft circulated as CD", data/iec/stage-codes.md) — what the
|
|
82
|
+
// official URN stage slot carries (pubid#787, the pubid-ts#187 parity
|
|
83
|
+
// round). The gem's IS/TR/TS :cd/:cd_tr/:cd_ts rows flipped the same
|
|
84
|
+
// way; 30.00 sits in no row of the table.
|
|
85
|
+
TS("cd", "cd", "is", "CD", "30.20", [
|
|
81
86
|
"CD", "2CD", "3CD", "4CD", "5CD", "6CD", "7CD", "8CD", "9CD",
|
|
82
87
|
"ACD", "A2CD", "A3CD", "A4CD", "A5CD", "A6CD", "A7CD", "A8CD", "A9CD",
|
|
83
88
|
"CDM",
|
|
@@ -93,7 +98,7 @@ export const TYPED_STAGES = [
|
|
|
93
98
|
TS("np_tr", "np", "tr", "NP TR", "10.00"),
|
|
94
99
|
TS("anw_tr", "anw", "tr", "ANW TR", "10.99"),
|
|
95
100
|
TS("wd_tr", "wd", "tr", "WD TR", "20.20"),
|
|
96
|
-
TS("cd_tr", "cd", "tr", "CD TR", "30.
|
|
101
|
+
TS("cd_tr", "cd", "tr", "CD TR", "30.20"),
|
|
97
102
|
// Plain DTR keeps the folded 50.00 ladder (the registration step); the
|
|
98
103
|
// point spellings below are rows of their own, each with the exact
|
|
99
104
|
// code IEC's stage-code correspondence table gives it (pubid#733, gem
|
|
@@ -111,7 +116,7 @@ export const TYPED_STAGES = [
|
|
|
111
116
|
TS("np_ts", "np", "ts", "NP TS", "10.00"),
|
|
112
117
|
TS("anw_ts", "anw", "ts", "ANW TS", "10.99"),
|
|
113
118
|
TS("wd_ts", "wd", "ts", "WD TS", "20.20"),
|
|
114
|
-
TS("cd_ts", "cd", "ts", "CD TS", "30.
|
|
119
|
+
TS("cd_ts", "cd", "ts", "CD TS", "30.20"),
|
|
115
120
|
TS("dts", "draft", "ts", "DTS", "50.00"),
|
|
116
121
|
TS("adts", "draft", "ts", "ADTS", "40.99"),
|
|
117
122
|
TS("cdts", "draft", "ts", "CDTS", "50.20"),
|
|
@@ -314,6 +319,142 @@ export class IecIdentifier extends BaseIdentifier {
|
|
|
314
319
|
return "";
|
|
315
320
|
return `(${this.languages.map((l) => l.code).join(",")})`;
|
|
316
321
|
}
|
|
322
|
+
// --- MR string (ruby to_mr_string, Renderers::MrString) ---------------------
|
|
323
|
+
/** The supplement/wrapper suffix hook (ruby Identifier#mr_supplement_suffix):
|
|
324
|
+
* `{type}.{number}.{year}` for supplements, nil for every other class. The
|
|
325
|
+
* base returns nil; the IEC supplement class carries the override. */
|
|
326
|
+
mrSupplementSuffix() {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
/** The machine-readable slug (ruby Identifier#to_mr_string): the flat MR
|
|
330
|
+
* segments joined with ".". Wrapper classes override to compose their
|
|
331
|
+
* chain (Consolidated/Vap/Supplement); every other class takes this path,
|
|
332
|
+
* which is byte-identical with what the shared renderer produces for it.
|
|
333
|
+
* The all-parts form has no MR (ruby Pubid::AllParts#render raises
|
|
334
|
+
* NotImplementedError — the all-parts TS boolean is that wrapper). */
|
|
335
|
+
toMrString() {
|
|
336
|
+
if (this.all_parts === true) {
|
|
337
|
+
throw new Error("an all-parts identifier has no mr_string form yet");
|
|
338
|
+
}
|
|
339
|
+
return [
|
|
340
|
+
this.mrPublisher(),
|
|
341
|
+
this.mrType(),
|
|
342
|
+
this.mrNumberWithPart(),
|
|
343
|
+
this.mrYear(),
|
|
344
|
+
this.mrEdition(),
|
|
345
|
+
this.mrLanguages(),
|
|
346
|
+
]
|
|
347
|
+
.filter((segment) => segment !== undefined)
|
|
348
|
+
.join(".");
|
|
349
|
+
}
|
|
350
|
+
/** Ruby Identifier#mr_publisher: the publisher, lowercased, "/" dash-joined
|
|
351
|
+
* ("iso-iec"). The copublishers are a separate attribute and contribute no
|
|
352
|
+
* segment (the shared hook reads the publisher only). */
|
|
353
|
+
mrPublisher() {
|
|
354
|
+
return this.publisher?.toLowerCase().replaceAll("/", "-");
|
|
355
|
+
}
|
|
356
|
+
/** Ruby Identifier#mr_type: the typed stage's type code, lowercased; nil for
|
|
357
|
+
* the international standard (the default face carries no type token). */
|
|
358
|
+
mrType() {
|
|
359
|
+
const code = this.typedStage?.typeCode;
|
|
360
|
+
return code === undefined || code === "is" ? undefined : code.toLowerCase();
|
|
361
|
+
}
|
|
362
|
+
/** Ruby Identifier#mr_number_with_part: number-part-subpart, dash-joined,
|
|
363
|
+
* lowercased; nil without a number (a hook returning "" would gain a blank
|
|
364
|
+
* segment and a double dot in the slug). */
|
|
365
|
+
mrNumberWithPart() {
|
|
366
|
+
if (this.number === undefined)
|
|
367
|
+
return undefined;
|
|
368
|
+
return [this.number, this.part, this.subpart]
|
|
369
|
+
.filter((v) => v !== undefined)
|
|
370
|
+
.join("-")
|
|
371
|
+
.toLowerCase();
|
|
372
|
+
}
|
|
373
|
+
/** Ruby Identifier#mr_year: the year, month/day dash-extended; "--" when the
|
|
374
|
+
* date is undated; nil without a date. */
|
|
375
|
+
mrYear() {
|
|
376
|
+
const date = this.date;
|
|
377
|
+
if (date === undefined)
|
|
378
|
+
return undefined;
|
|
379
|
+
if (date.undated)
|
|
380
|
+
return "--";
|
|
381
|
+
if (date.year === undefined || date.year === "")
|
|
382
|
+
return undefined;
|
|
383
|
+
let result = String(date.year);
|
|
384
|
+
if (date.month !== undefined && date.month !== "")
|
|
385
|
+
result += `-${date.month}`;
|
|
386
|
+
if (date.day !== undefined && date.day !== "")
|
|
387
|
+
result += `-${date.day}`;
|
|
388
|
+
return result;
|
|
389
|
+
}
|
|
390
|
+
/** Ruby Identifier#mr_edition: "ed{number}" — the IEC edition is the
|
|
391
|
+
* Components::Edition component, and the hook reads its number. */
|
|
392
|
+
mrEdition() {
|
|
393
|
+
return this.edition === undefined ? undefined : `ed${this.edition}`;
|
|
394
|
+
}
|
|
395
|
+
/** Ruby Identifier#mr_languages: the language codes, hyphen-joined, no
|
|
396
|
+
* parens (parens are shell-/URL-unsafe). */
|
|
397
|
+
mrLanguages() {
|
|
398
|
+
if (this.languages.length === 0)
|
|
399
|
+
return undefined;
|
|
400
|
+
return this.languages.map((l) => l.code.toLowerCase()).join("-");
|
|
401
|
+
}
|
|
402
|
+
// --- the supplement-peeling algebra (ruby Identifier#drop_supplements /
|
|
403
|
+
// #exclude / #matches?, the relaton-api-js citation-validation primitive)
|
|
404
|
+
/** The standard this identifier supplements, dropping its own supplement
|
|
405
|
+
* layer (one level). The base supplements nothing, so it is returned
|
|
406
|
+
* unchanged; the consolidated chain overrides to yield its leading member. */
|
|
407
|
+
dropSupplements() {
|
|
408
|
+
return this;
|
|
409
|
+
}
|
|
410
|
+
/** Excluded attributes are dropped; every other value passes through
|
|
411
|
+
* excludeFromNested so the exclusion also propagates into nested
|
|
412
|
+
* identifiers (wrapper types store their identity on an inner member).
|
|
413
|
+
* :amendment / :supplement are structural, not attributes — they reduce a
|
|
414
|
+
* supplemented identifier to the standard it wraps (#dropSupplements). */
|
|
415
|
+
exclude(...args) {
|
|
416
|
+
const supplementKeys = args.filter((a) => a === "amendment" || a === "supplement");
|
|
417
|
+
if (supplementKeys.length > 0) {
|
|
418
|
+
return this.dropSupplements().exclude(...args.filter((a) => !supplementKeys.includes(a)));
|
|
419
|
+
}
|
|
420
|
+
const excluded = new Set(args);
|
|
421
|
+
// Map :year to :date (year-in-date flavors), but ALSO keep :year so a
|
|
422
|
+
// flavor that models the edition as a plain `year` attribute has it
|
|
423
|
+
// excluded too (ruby's own comment).
|
|
424
|
+
if (excluded.has("year"))
|
|
425
|
+
excluded.add("date");
|
|
426
|
+
const attrs = {};
|
|
427
|
+
for (const [name] of Object.entries(this.constructor.attributes)) {
|
|
428
|
+
const value = excluded.has(name)
|
|
429
|
+
? undefined
|
|
430
|
+
: this[name];
|
|
431
|
+
attrs[name] = excludeFromNested(value, args);
|
|
432
|
+
}
|
|
433
|
+
const rebuilt = new this.constructor(attrs);
|
|
434
|
+
// The runtime typed stage is not an attribute (ruby's rebuild carries it
|
|
435
|
+
// as one), so it rides the copy explicitly.
|
|
436
|
+
rebuilt.typedStage = this.typedStage;
|
|
437
|
+
return rebuilt;
|
|
438
|
+
}
|
|
439
|
+
/** Fuzz-level equality: two identifiers match when they are equal after
|
|
440
|
+
* excluding the given aspects. `ignore` accepts the same symbols as
|
|
441
|
+
* #exclude (e.g. "date", "edition", "amendment"). The primitive relaton
|
|
442
|
+
* uses to match a reference against catalogue hits at varying strictness. */
|
|
443
|
+
matches(other, ignore = []) {
|
|
444
|
+
return this.exclude(...ignore).equals(other.exclude(...ignore));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
/** Propagate an #exclude into a nested attribute value: recurse when it is
|
|
448
|
+
* (or contains) another identifier, otherwise return it unchanged. Passes
|
|
449
|
+
* the original args so nested identifiers re-apply the same :year->:date
|
|
450
|
+
* mapping themselves (ruby Identifier#exclude_from_nested). */
|
|
451
|
+
function excludeFromNested(value, args) {
|
|
452
|
+
if (value instanceof BaseIdentifier) {
|
|
453
|
+
return value.exclude(...args);
|
|
454
|
+
}
|
|
455
|
+
if (Array.isArray(value))
|
|
456
|
+
return value.map((item) => excludeFromNested(item, args));
|
|
457
|
+
return value;
|
|
317
458
|
}
|
|
318
459
|
function iecSingleClass(kind) {
|
|
319
460
|
const name = TYPE_NAMES[kind];
|
|
@@ -571,6 +712,41 @@ function iecSupplementClass(kind) {
|
|
|
571
712
|
return "";
|
|
572
713
|
return " ";
|
|
573
714
|
}
|
|
715
|
+
/** Ruby IEC SupplementIdentifier#mr_supplement_suffix:
|
|
716
|
+
* `/{type}.{number}.{year}` (e.g. "/amd.1.2016") — the segments the
|
|
717
|
+
* MrString renderer and the consolidated composition append so the
|
|
718
|
+
* full supplement chain round-trips losslessly (gem issue #142). */
|
|
719
|
+
mrSupplementSuffix() {
|
|
720
|
+
const segments = [];
|
|
721
|
+
const type = this.mrType();
|
|
722
|
+
if (type !== undefined)
|
|
723
|
+
segments.push(type);
|
|
724
|
+
if (this.number !== undefined)
|
|
725
|
+
segments.push(String(this.number));
|
|
726
|
+
const year = this.date?.year;
|
|
727
|
+
if (year !== undefined && year !== "")
|
|
728
|
+
segments.push(String(year));
|
|
729
|
+
return segments.length === 0 ? undefined : segments.join(".");
|
|
730
|
+
}
|
|
731
|
+
/** Ruby IEC SupplementIdentifier#to_mr_string: the chain head routes
|
|
732
|
+
* through the BASE's own #toMrString, not a flat renderer recursion —
|
|
733
|
+
* the flat path renders the wrapped document without a wrapper class's
|
|
734
|
+
* own composition, so a corrigendum over a consolidated version
|
|
735
|
+
* ("IEC 60335-1:2010+AMD1:2013 CSV/COR1:2014") dropped the part and the
|
|
736
|
+
* whole chain behind its suffix. For every class without a #toMrString
|
|
737
|
+
* override the base's own path produces the string the renderer would,
|
|
738
|
+
* so the standalone supplement chains are unchanged; where a wrapper
|
|
739
|
+
* carries one (the Vap) the full chain survives. */
|
|
740
|
+
toMrString() {
|
|
741
|
+
const suffix = this.mrSupplementSuffix();
|
|
742
|
+
if (suffix === undefined)
|
|
743
|
+
return super.toMrString();
|
|
744
|
+
const base = this.base;
|
|
745
|
+
if (base === undefined)
|
|
746
|
+
return suffix;
|
|
747
|
+
const head = base.toMrString();
|
|
748
|
+
return head === "" ? suffix : `${head}_${suffix}`;
|
|
749
|
+
}
|
|
574
750
|
static fromHash(hash) {
|
|
575
751
|
// The supplement restores its type's published stage when no stage
|
|
576
752
|
// code rode the hash (ruby restores Amendment -> Amd — the glued
|
|
@@ -619,6 +795,25 @@ function iecVapClass() {
|
|
|
619
795
|
result += ` ED${this.edition}`;
|
|
620
796
|
return result;
|
|
621
797
|
}
|
|
798
|
+
/** Ruby VapIdentifier#to_mr_string: the wrapped chain's MR with the VAP
|
|
799
|
+
* code (or codes — the multi-deliverable face prints `EXV-CMV`) appended
|
|
800
|
+
* as the final segment. Without it the VAP renders the generic flat slug
|
|
801
|
+
* through its delegated number, which drops the part and shares one slug
|
|
802
|
+
* with the bare base document ("IEC 60601-1:2005+AMD1:2012 CSV" keyed
|
|
803
|
+
* "iec.60601.2005", the same slug as the part 2 chain and — for a
|
|
804
|
+
* part-less base — the base itself; the #142 collision one layer down).
|
|
805
|
+
* The corrigendum-over-VAP face composes on top of this through the
|
|
806
|
+
* supplement's base-routed head. */
|
|
807
|
+
toMrString() {
|
|
808
|
+
const head = this.base?.toMrString();
|
|
809
|
+
if (head === undefined || head === "")
|
|
810
|
+
return "";
|
|
811
|
+
const codes = this.vap
|
|
812
|
+
.map((code) => code.toLowerCase().trim())
|
|
813
|
+
.filter((code) => code !== "")
|
|
814
|
+
.join("-");
|
|
815
|
+
return codes === "" ? head : `${head}_${codes}`;
|
|
816
|
+
}
|
|
622
817
|
}
|
|
623
818
|
registerType(IecVapIdentifier);
|
|
624
819
|
return IecVapIdentifier;
|
|
@@ -630,6 +825,40 @@ function iecConsolidatedClass() {
|
|
|
630
825
|
identifiers: { type: IecIdentifier, collection: true, initializeEmpty: true },
|
|
631
826
|
});
|
|
632
827
|
static mappings = keyValue({ wire: "identifiers", to: "identifiers" });
|
|
828
|
+
/** Dropping the supplement layer yields the leading member — the base
|
|
829
|
+
* standard alone (the CEN counterpart's shape). This is what makes the
|
|
830
|
+
* structural exclusions reach a consolidated chain: exclude("amendment")
|
|
831
|
+
* / exclude("supplement") and their matches(ignore) forms peel the
|
|
832
|
+
* composition to the document it supplements, so a consolidated
|
|
833
|
+
* reference matches the bare base record (the primitive
|
|
834
|
+
* relaton-api-js's citation-validation uses to resolve a consolidated
|
|
835
|
+
* docid onto the edition it amends). */
|
|
836
|
+
dropSupplements() {
|
|
837
|
+
return this.identifiers[0] ?? this;
|
|
838
|
+
}
|
|
839
|
+
/** Ruby ConsolidatedIdentifier#to_mr_string: the base member's own MR
|
|
840
|
+
* (its part/subpart ride on the member, so the slug keeps the full
|
|
841
|
+
* designation), then each supplement member behind a `plus-` marker —
|
|
842
|
+
* the CEN counterpart's composition. Without it the chain rendered the
|
|
843
|
+
* generic flat slug, which both dropped the part and shared one slug
|
|
844
|
+
* with the bare base document ("IEC 60601-1:2005+AMD1:2012 CSV" keyed
|
|
845
|
+
* "iec.60601.2005", colliding with the part-less rendering of the
|
|
846
|
+
* part 2 chain and with the base itself). The `plus-` marker keeps the
|
|
847
|
+
* consolidated slug distinct from the standalone supplement chain's
|
|
848
|
+
* ("iec.60601-1.2005_amd.1.2012"), mirroring the CEN ruling that a
|
|
849
|
+
* consolidated form must not share a slug with the document it composes. */
|
|
850
|
+
toMrString() {
|
|
851
|
+
const [base, ...supplements] = this.identifiers;
|
|
852
|
+
if (base === undefined)
|
|
853
|
+
return "";
|
|
854
|
+
const parts = [base.toMrString()];
|
|
855
|
+
for (const member of supplements) {
|
|
856
|
+
const suffix = member.mrSupplementSuffix();
|
|
857
|
+
if (suffix !== undefined)
|
|
858
|
+
parts.push(`plus-${suffix}`);
|
|
859
|
+
}
|
|
860
|
+
return parts.join("_");
|
|
861
|
+
}
|
|
633
862
|
render() {
|
|
634
863
|
return this.identifiers
|
|
635
864
|
.map((id, idx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.69",
|
|
4
4
|
"description": "TypeScript PubID identifiers: resolution, normalization and canonical hashes for every identifier in the pubid-testsuite corpus (41 standards bodies), with a conformance runner mirroring the Ruby reference",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|