@pubid/pubid 0.1.46 → 0.1.48
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.
|
@@ -603,8 +603,12 @@ export function iecToUrn(identifier) {
|
|
|
603
603
|
const dateSlot = date !== undefined ? (date.render() ?? "") : "";
|
|
604
604
|
const ts = docWithNumber.typedStage;
|
|
605
605
|
const typeToken = ts !== undefined && TYPE_SLOT_CODES.has(ts.typeCode) ? ts.typeCode : "";
|
|
606
|
-
|
|
607
|
-
|
|
606
|
+
// The gem's stage_token (urn_generator.rb): nil when the stage is
|
|
607
|
+
// published OR when the typed stage carries no harmonized code — there
|
|
608
|
+
// is NO stage-code fallback, so a harmonized-less draft row (BPUB,
|
|
609
|
+
// the draft-supplement rows) leaves the slot empty (#187).
|
|
610
|
+
const stageToken = ts !== undefined && ts.stageCode !== "published" && ts.harmonized !== undefined
|
|
611
|
+
? `stage-${ts.harmonized}`
|
|
608
612
|
: "";
|
|
609
613
|
const stageOrType = [typeToken, stageToken].filter((t) => t !== "").join("-");
|
|
610
614
|
const vap = findDown(identifier, "vap");
|
|
@@ -650,6 +654,46 @@ for (const klass of [
|
|
|
650
654
|
klass.urnGenerator = IecUrnGenerator;
|
|
651
655
|
}
|
|
652
656
|
}
|
|
657
|
+
// --- the standalone no-part dotted face reject (pubid#727) --------------
|
|
658
|
+
// A supplement's OWN dotted sub-number has nowhere to print on the
|
|
659
|
+
// standalone (no-part, self-base) face: the standalone renderer prints
|
|
660
|
+
// the base number and the supplement number only, so the parsed dot was
|
|
661
|
+
// dropped at render and parse(render) != parse. No IEC source prints a
|
|
662
|
+
// no-part standalone face with a dotted number — the facet is attested
|
|
663
|
+
// only on the on-base draft faces ("IEC 60038-2/DAM 2.3:2022") — so the
|
|
664
|
+
// shape is rejected at parse instead of being built unrenderable (the
|
|
665
|
+
// #726 ruling for unattested dotted shapes; the TS mirror of the gem's
|
|
666
|
+
// reject_standalone_dotted_supplement walk over the built base chain).
|
|
667
|
+
// The check is the SHAPE, not a grammar route: one condition covers the
|
|
668
|
+
// standalone branch ("IEC/AMD 1.2:2017"), the publisher-less plain route
|
|
669
|
+
// ("AMD 1.2:2017") and a dotted layer under an undotted second
|
|
670
|
+
// supplement ("IEC/AMD 1.2:2017/COR 1:2018"). The single-document draft
|
|
671
|
+
// faces ("IEC CD 1.2:2017"), the DAM-family decodes ("IEC/DAM 1.2") and
|
|
672
|
+
// the on-base faces (a real base) keep their dot on a printable layer
|
|
673
|
+
// and pass. from_hash deliberately still deserializes the shape (no
|
|
674
|
+
// stored row carries it; residue pinned).
|
|
675
|
+
const STANDALONE_DOTTED_SUPPLEMENT_MESSAGE = 'the standalone no-part supplement face carries a dotted sub-number ' +
|
|
676
|
+
'(e.g. "IEC/AMD 1.2:2017"): no IEC source prints one, and the ' +
|
|
677
|
+
"standalone face has no layer to print the dot on, so the stored " +
|
|
678
|
+
"sub-number would be dropped at render — the dotted sub-number is " +
|
|
679
|
+
"attested only on the on-base draft forms";
|
|
680
|
+
const SUPPLEMENT_POLYMORPHIC_NAMES = new Set([
|
|
681
|
+
"pubid:iec:amendment",
|
|
682
|
+
"pubid:iec:corrigendum",
|
|
683
|
+
"pubid:iec:interpretation-sheet",
|
|
684
|
+
]);
|
|
685
|
+
function rejectStandaloneDottedSupplement(id) {
|
|
686
|
+
let node = id;
|
|
687
|
+
while (node !== undefined && SUPPLEMENT_POLYMORPHIC_NAMES.has(node.constructor.polymorphicName)) {
|
|
688
|
+
const layer = node;
|
|
689
|
+
const iteration = layer["stage_iteration"];
|
|
690
|
+
const base = layer["base"];
|
|
691
|
+
if (iteration !== undefined && (base === undefined || layer["synthetic_base"] === true)) {
|
|
692
|
+
throw new ParseFailed(STANDALONE_DOTTED_SUPPLEMENT_MESSAGE, 0);
|
|
693
|
+
}
|
|
694
|
+
node = base;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
653
697
|
export function iecGrammarImplementation() {
|
|
654
698
|
const builder = new IecBuilder();
|
|
655
699
|
return {
|
|
@@ -693,7 +737,12 @@ export function iecGrammarImplementation() {
|
|
|
693
737
|
catch {
|
|
694
738
|
throw new ParseFailed("IEC: parse failed", 0);
|
|
695
739
|
}
|
|
696
|
-
|
|
740
|
+
const built = builder.build(tree);
|
|
741
|
+
// The shape check runs on the BUILT object (ruby Identifier.parse
|
|
742
|
+
// walks the base chain after ensure_base) — BSI's delegation and
|
|
743
|
+
// every parse route raise through this entry; from_hash stays open.
|
|
744
|
+
rejectStandaloneDottedSupplement(built);
|
|
745
|
+
return built;
|
|
697
746
|
},
|
|
698
747
|
};
|
|
699
748
|
}
|
|
@@ -12,7 +12,13 @@ export interface TypedStage {
|
|
|
12
12
|
stageCode: string;
|
|
13
13
|
typeCode: IecTypeCode;
|
|
14
14
|
abbr: string;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The typed stage's lead harmonized code — the gem's
|
|
17
|
+
* `harmonized_stages.first`, which the official URN's stage slot writes
|
|
18
|
+
* ("stage-30.00") and the URN parser resolves back by (type, code).
|
|
19
|
+
* Absent = the gem's empty `harmonized_stages`: the slot stays EMPTY,
|
|
20
|
+
* never a stage-code fallback (#187).
|
|
21
|
+
*/
|
|
16
22
|
harmonized?: string | undefined;
|
|
17
23
|
/** Grammar tokens that resolve to this stage (defaults to [abbr]). */
|
|
18
24
|
tokens?: string[] | undefined;
|
|
@@ -21,29 +21,48 @@ export const TYPED_STAGES = [
|
|
|
21
21
|
// ComponentSpecification/ConformityAssessment.
|
|
22
22
|
TS("cs", "published", "cs", "CS"),
|
|
23
23
|
TS("ca", "published", "ca", "CA"),
|
|
24
|
+
// The `harmonized` column is the gem's harmonized_stages.first (pubid
|
|
25
|
+
// 2.0.32, verified in-process — issue #187): the official URN stage slot
|
|
26
|
+
// writes `stage-<lead code>` and the URN parser resolves the slot back
|
|
27
|
+
// by (type, lead code). The draft supplement rows (dcor/fdcor/cdish/
|
|
28
|
+
// dish) stay code-less: their stages ride the supplement layer, and the
|
|
29
|
+
// official URN reads the ROOT's stage — a published base or a
|
|
30
|
+
// stage-less synthetic one — so the gem never writes these codes into
|
|
31
|
+
// the slot.
|
|
24
32
|
// PNW owns harmonized 10.20 (gem: NP stages are 10.00/10.60/… — the
|
|
25
33
|
// URN "stage-10.20" slot resolves to PNW, not NP).
|
|
26
|
-
TS("np", "np", "is", "NP"),
|
|
34
|
+
TS("np", "np", "is", "NP", "10.00"),
|
|
27
35
|
TS("pnw", "pnw", "is", "PNW", "10.20"),
|
|
28
36
|
TS("pwi", "pwi", "is", "PWI", "00.00"),
|
|
29
|
-
TS("anw", "anw", "is", "ANW"),
|
|
30
|
-
TS("wd", "wd", "is", "WD"),
|
|
31
|
-
TS("cd", "cd", "is", "CD", "30.
|
|
32
|
-
TS("cdv", "cdv", "is", "CDV", "40.
|
|
37
|
+
TS("anw", "anw", "is", "ANW", "10.99"),
|
|
38
|
+
TS("wd", "wd", "is", "WD", "20.20"),
|
|
39
|
+
TS("cd", "cd", "is", "CD", "30.00"),
|
|
40
|
+
TS("cdv", "cdv", "is", "CDV", "40.00"),
|
|
33
41
|
TS("fdis", "fdis", "is", "FDIS", "50.00"),
|
|
34
|
-
|
|
42
|
+
// The gem registers PRF as an abbreviation of :fdis (lead 50.00) — it
|
|
43
|
+
// has no typed stage of its own; the row stays for the render face and
|
|
44
|
+
// takes fdis's lead code (the gem's parse even renders FDIS).
|
|
45
|
+
TS("prf", "prf", "is", "PRF", "50.00"),
|
|
46
|
+
// BPUB/PPUB are publication-lifecycle abbreviations of the published
|
|
47
|
+
// IS in the gem (stage_code published, slot suppressed) — the rows
|
|
48
|
+
// stay for the render face and carry no harmonized, so the slot
|
|
49
|
+
// falls through empty.
|
|
35
50
|
TS("bpub", "bpub", "is", "BPUB"),
|
|
36
51
|
TS("ppub", "ppub", "is", "PPUB"),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
TS("
|
|
42
|
-
TS("
|
|
43
|
-
TS("
|
|
44
|
-
TS("
|
|
45
|
-
TS("
|
|
46
|
-
TS("
|
|
52
|
+
// The gem folds the whole draft-spelling family of each typed
|
|
53
|
+
// deliverable onto ONE typed stage (ADTR/CDTR/NDTR are :dtr
|
|
54
|
+
// abbreviations, lead 50.00) — every row takes that lead code; the
|
|
55
|
+
// spellings stay for the render face.
|
|
56
|
+
TS("dtr", "dtr", "tr", "DTR", "50.00"),
|
|
57
|
+
TS("adtr", "adtr", "tr", "ADTR", "50.00"),
|
|
58
|
+
TS("cdtr", "cdtr", "tr", "CDTR", "50.00"),
|
|
59
|
+
TS("ndtr", "ndtr", "tr", "NDTR", "50.00"),
|
|
60
|
+
TS("dts", "dts", "ts", "DTS", "50.00"),
|
|
61
|
+
TS("adts", "adts", "ts", "ADTS", "50.00"),
|
|
62
|
+
TS("cdts", "cdts", "ts", "CDTS", "50.00"),
|
|
63
|
+
TS("ndts", "ndts", "ts", "NDTS", "50.00"),
|
|
64
|
+
TS("dpas", "dpas", "pas", "DPAS", "50.00"),
|
|
65
|
+
TS("cdpas", "cdpas", "pas", "CDPAS", "30.00"),
|
|
47
66
|
// The DAM family's ballot stages carry the CIRCULATION slots as the
|
|
48
67
|
// lead harmonized code (30.20/50.20), not ISO's 30.00/50.00 — CDAM/
|
|
49
68
|
// FDAM keep those (type, leading code) URN keys (gem Amendment
|
|
@@ -186,8 +205,13 @@ export class IecIdentifier extends BaseIdentifier {
|
|
|
186
205
|
typedStage;
|
|
187
206
|
/** Ruby SingleIdentifier#publisher_portion. */
|
|
188
207
|
publisherPortion() {
|
|
189
|
-
|
|
190
|
-
|
|
208
|
+
// The supplement table does not materialize the empty copublishers
|
|
209
|
+
// collection (the single table's initializeEmpty does) — ruby
|
|
210
|
+
// nil-guards the same read (`copublishers&.any?`, pubid#727: the
|
|
211
|
+
// standalone faces crashed here instead of rendering).
|
|
212
|
+
const copublishers = this.copublishers ?? [];
|
|
213
|
+
const publishers = copublishers.length > 0
|
|
214
|
+
? [this.publisher ?? "IEC", ...copublishers]
|
|
191
215
|
: [this.publisher ?? "IEC"];
|
|
192
216
|
let pub = publishers.join("/");
|
|
193
217
|
const abbr = this.typedStage?.abbr ?? "";
|
|
@@ -400,9 +424,34 @@ function iecSupplementClass(kind) {
|
|
|
400
424
|
render() {
|
|
401
425
|
const base = this.base;
|
|
402
426
|
if (base === undefined || this.synthetic_base === true) {
|
|
403
|
-
// Standalone draft supplement (not in the corpus; Ruby parity
|
|
404
|
-
|
|
405
|
-
|
|
427
|
+
// Standalone draft supplement (not in the corpus; Ruby parity
|
|
428
|
+
// shape). Ruby render_supplement_standalone: the publisher join
|
|
429
|
+
// with NO stage abbreviation (the slash stays the copublisher
|
|
430
|
+
// separator), then the stage token over the self-base number and
|
|
431
|
+
// the supplement's own number ("IEC Amd 1-1:2017"). The published
|
|
432
|
+
// stages print the capitalized abbreviation ("Amd"), the draft
|
|
433
|
+
// stages their own token ("DCOR") — the ruby typed_stage.abbr
|
|
434
|
+
// first element. The publisher rides the attribute default ("IEC"
|
|
435
|
+
// fills it on every parse and from_hash route; ruby renders the
|
|
436
|
+
// nil-publisher hand-built case with no publisher part, a shape
|
|
437
|
+
// no parse or deserialization route reaches).
|
|
438
|
+
const parts = [];
|
|
439
|
+
const copublishers = this.copublishers ?? [];
|
|
440
|
+
const publishers = [this.publisher ?? "IEC", ...copublishers];
|
|
441
|
+
parts.push(publishers.join("/"));
|
|
442
|
+
const stageAbbr = this.typedStage?.abbr ?? abbr;
|
|
443
|
+
const leadAbbr = this.typedStage?.stageCode === "published"
|
|
444
|
+
? stageAbbr.charAt(0) + stageAbbr.slice(1).toLowerCase()
|
|
445
|
+
: stageAbbr;
|
|
446
|
+
// The self-base holds the supplement's own number (ruby's
|
|
447
|
+
// synthetic base stores it before the render reads it).
|
|
448
|
+
let numberStr = String(base?.number ?? this.number ?? "");
|
|
449
|
+
if (this.number !== undefined)
|
|
450
|
+
numberStr += `-${this.number}`;
|
|
451
|
+
if (this.subpart !== undefined)
|
|
452
|
+
numberStr += `-${this.subpart}`;
|
|
453
|
+
parts.push(`${leadAbbr} ${numberStr}`);
|
|
454
|
+
let result = parts.join(" ");
|
|
406
455
|
if (this.date !== undefined)
|
|
407
456
|
result += `:${this.date.render()}`;
|
|
408
457
|
if (this.edition !== undefined)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
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",
|