@pubid/pubid 0.1.24 → 0.1.26
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/artifact/corpus.json.gz +0 -0
- package/dist/flavors/iso/index.js +37 -7
- package/dist/flavors/iso/model.js +15 -18
- package/package.json +1 -1
package/artifact/corpus.json.gz
CHANGED
|
Binary file
|
|
@@ -426,6 +426,11 @@ function parseIsoUrn(urn) {
|
|
|
426
426
|
if (parts[0] !== undefined && URN_TYPE_TOKENS.has(parts[0].toLowerCase())) {
|
|
427
427
|
typeCode = parts.shift().toLowerCase();
|
|
428
428
|
}
|
|
429
|
+
// RFC 5141 requires docnumber -- "urn:iso:std:iso" is not a valid
|
|
430
|
+
// NSS, and building it silently produced the identity-free "ISO "
|
|
431
|
+
// (mirrors lib/pubid/iso/urn_parser.rb)
|
|
432
|
+
if (parts.length === 0)
|
|
433
|
+
throw new Error(`missing docnumber: ${urn}`);
|
|
429
434
|
let [number, part, subpart] = parseUrnNumberPart(parts.shift());
|
|
430
435
|
let year;
|
|
431
436
|
if (/^\d{4}$/.test(parts[0] ?? ""))
|
|
@@ -506,12 +511,25 @@ function parseIsoUrn(urn) {
|
|
|
506
511
|
else
|
|
507
512
|
supp.number = parts.shift();
|
|
508
513
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
514
|
+
// The legacy year-overloaded wire ("amd:2007:v2" -- the number rode
|
|
515
|
+
// the version slot): a v-token with no preceding number carries the
|
|
516
|
+
// NUMBER. The RFC 5141-bis order ("amd:1:2007:v2") keeps the number
|
|
517
|
+
// in its own slot, so a v-token after a number is the true
|
|
518
|
+
// <supplversion>.
|
|
519
|
+
const consumeV = () => {
|
|
520
|
+
if ((parts[0] ?? "").startsWith("v")) {
|
|
521
|
+
const value = parts.shift().slice(1).split(".")[0];
|
|
522
|
+
if (supp.number === undefined)
|
|
523
|
+
supp.number = value;
|
|
524
|
+
else
|
|
525
|
+
supp.version = value;
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
consumeV();
|
|
513
529
|
if (supp.year === undefined && /^\d{4}$/.test(parts[0] ?? ""))
|
|
514
530
|
supp.year = parts.shift();
|
|
531
|
+
// a v-token after the year would otherwise start a type-less wrap
|
|
532
|
+
consumeV();
|
|
515
533
|
if (parts[0] !== undefined && !/^\d+$/.test(parts[0]) &&
|
|
516
534
|
!/^(amd|cor|sup|add|v\d+|stage-)/i.test(parts[0])) {
|
|
517
535
|
supp.languages = parts.shift().split(",").map((l) => l.toUpperCase()).join("/");
|
|
@@ -577,18 +595,30 @@ function parseIsoUrn(urn) {
|
|
|
577
595
|
}
|
|
578
596
|
const suppTree = {};
|
|
579
597
|
if (supp.stage !== undefined) {
|
|
580
|
-
|
|
598
|
+
// A harmonized code resolves within the supplement's own type
|
|
599
|
+
// family -- the IS-family default would turn a staged Corrigendum
|
|
600
|
+
// into a plain IS (mirrors the gem's build_identifier).
|
|
601
|
+
const stage = /^\d\d\.\d\d$/.test(supp.stage)
|
|
602
|
+
? ISO_TYPED_STAGES.find((st) => st.harmonized?.includes(supp.stage) && st.typeKey === supp.type) ??
|
|
603
|
+
ISO_TYPED_STAGES.find((st) => st.harmonized?.includes(supp.stage) && st.typeKey === "is")
|
|
604
|
+
: ISO_TYPED_STAGES.find((st) => st.stageCode === supp.stage);
|
|
581
605
|
suppTree["type_with_stage"] = stage !== undefined
|
|
582
606
|
? stage.abbr[0] ?? ""
|
|
583
|
-
: supp.stage.toUpperCase();
|
|
607
|
+
: supp.type?.toUpperCase() ?? supp.stage.toUpperCase();
|
|
584
608
|
}
|
|
585
609
|
if (supp.type !== undefined && suppTree["type_with_stage"] === undefined) {
|
|
586
|
-
|
|
610
|
+
// "sup" is the generic Supplement (type key "suppl") -- the raw
|
|
611
|
+
// "SUP" resolves the Directives Supplement row, whose render needs
|
|
612
|
+
// the supplement_publisher a guide chain never has
|
|
613
|
+
const typeToken = supp.type === "sup" ? "SUPPL" : supp.type.toUpperCase();
|
|
614
|
+
suppTree["type_with_stage"] = typeToken;
|
|
587
615
|
}
|
|
588
616
|
if (supp.number !== undefined)
|
|
589
617
|
suppTree["number"] = supp.number;
|
|
590
618
|
if (supp.year !== undefined)
|
|
591
619
|
suppTree["date"] = supp.year;
|
|
620
|
+
if (supp.version !== undefined)
|
|
621
|
+
suppTree["supplement_version"] = supp.version;
|
|
592
622
|
if (supp.languages !== undefined)
|
|
593
623
|
suppTree["languages"] = supp.languages;
|
|
594
624
|
tree = { base: tree, ...suppTree };
|
|
@@ -465,14 +465,9 @@ class IsoUrnGenerator extends BaseUrnGenerator {
|
|
|
465
465
|
const stageCode = ts.entry.stageCode;
|
|
466
466
|
if (stageCode === "published")
|
|
467
467
|
return undefined;
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (stageAbbrUrn !== undefined) {
|
|
472
|
-
if (id.stage_iteration !== undefined)
|
|
473
|
-
return `${stageAbbrUrn}.${id.stage_iteration.render() ?? ""}`;
|
|
474
|
-
return stageAbbrUrn;
|
|
475
|
-
}
|
|
468
|
+
// RFC 5141 carries the stage as the harmonized code only; the typed
|
|
469
|
+
// abbreviations live in the human face. Legacy abbreviation URNs are
|
|
470
|
+
// accepted on ingestion and re-canonicalized here.
|
|
476
471
|
const harmonized = ts.entry.harmonized;
|
|
477
472
|
if (harmonized === undefined || harmonized.length === 0)
|
|
478
473
|
return undefined;
|
|
@@ -558,17 +553,15 @@ class IsoUrnGenerator extends BaseUrnGenerator {
|
|
|
558
553
|
parts.push(stageComp);
|
|
559
554
|
parts.push(supp.typeKey() === "suppl" || supp.typeKey() === "add" ? "sup" : supp.typeKey());
|
|
560
555
|
const iter = supp.typeKey() === "suppl" || supp.stage_iteration === undefined ? undefined : supp.stage_iteration.render();
|
|
556
|
+
// RFC 5141 supplement slots in order: number, year (the bis
|
|
557
|
+
// additive extension), then the published version.
|
|
558
|
+
if (supp.number !== undefined)
|
|
559
|
+
parts.push(supp.number);
|
|
561
560
|
const d = urnDate(supp);
|
|
562
|
-
if (d !== undefined)
|
|
561
|
+
if (d !== undefined)
|
|
563
562
|
parts.push(d);
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
if (supp.number !== undefined)
|
|
569
|
-
parts.push(supp.number);
|
|
570
|
-
parts.push(iter !== undefined ? `v1.${iter}` : "v1");
|
|
571
|
-
}
|
|
563
|
+
const version = supp.supplement_version ?? 1;
|
|
564
|
+
parts.push(iter !== undefined ? `v${version}.${iter}` : `v${version}`);
|
|
572
565
|
if (supp.languages !== undefined && supp.languages.length > 0) {
|
|
573
566
|
parts.push(supp.languages.map((l) => l.code).join(","));
|
|
574
567
|
}
|
|
@@ -616,10 +609,14 @@ const supplementPublisherMappings = () => [
|
|
|
616
609
|
},
|
|
617
610
|
},
|
|
618
611
|
];
|
|
619
|
-
const SUPPLEMENT_MAPPINGS = keyValue(...ISO_MAPPINGS, ...supplementPublisherMappings(), stageMapping(), { wire: "base", to: "base" }
|
|
612
|
+
const SUPPLEMENT_MAPPINGS = keyValue(...ISO_MAPPINGS, ...supplementPublisherMappings(), stageMapping(), { wire: "base", to: "base" },
|
|
613
|
+
// omitted when unset, so parsed human faces keep their hashes
|
|
614
|
+
{ wire: "supplement_version", to: "supplement_version" });
|
|
620
615
|
export class IsoSupplementIdentifier extends IsoSingleIdentifier {
|
|
621
616
|
static attributes = extendAttributes(IsoSingleIdentifier, {
|
|
622
617
|
base: { type: IsoIdentifier },
|
|
618
|
+
// The RFC 5141 <supplversion> (corrected version of the supplement).
|
|
619
|
+
supplement_version: { type: "string" },
|
|
623
620
|
});
|
|
624
621
|
static mappings = SUPPLEMENT_MAPPINGS;
|
|
625
622
|
render() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
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",
|