@pubid/pubid 0.1.7 → 0.1.8

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.
@@ -77,10 +77,11 @@ class IecBuilder {
77
77
  Object.assign(attrs, numberComponents(tree["number_with_part"]));
78
78
  // Letters-prefixed numbers (IECEE "CAB", "AD") only take digit-first
79
79
  // parts — "CAB-G01" rejects (Ruby parity; digit numbers like 61158-X
80
- // keep letter parts).
80
+ // keep letter parts). "DIR" is the exception: the Directives number
81
+ // is its own grammar branch and takes letter parts ("DIR-IEC-SUP").
81
82
  const number = attrs["number"];
82
83
  const part = attrs["part"];
83
- if (number !== undefined && /^[A-Z]{2,4}$/.test(number) &&
84
+ if (number !== undefined && /^[A-Z]{2,4}$/.test(number) && number !== "DIR" &&
84
85
  part !== undefined && /^[A-Za-z]/.test(part)) {
85
86
  throw new ParseFailed(`IEC: letter part ${part} after letters number ${number}`, 0);
86
87
  }
@@ -501,7 +502,18 @@ export function iecGrammarImplementation() {
501
502
  const parsed = urnToCode(urn);
502
503
  if (!parsed)
503
504
  throw new Error(`Invalid IEC URN: ${urn}`);
504
- const [code, lang, allParts] = parsed;
505
+ let [code, lang, allParts] = parsed;
506
+ // The "ser" slot names every part of the document: the reference
507
+ // wraps via to_all_parts, which strips the part and the date (a
508
+ // series names the document across editions, "IEC 60034 (all
509
+ // parts)"). The part rides dash-joined on the number, the date in
510
+ // its own slot.
511
+ if (allParts) {
512
+ code = code
513
+ .replace(/:[^:]*$/, "")
514
+ .replace(/\s(19|20)\d\d(-\d\d)?$/, "")
515
+ .replace(/-[^\s:-]+$/, "");
516
+ }
505
517
  // The reference parses the unprefixed rebuild and its grammar
506
518
  // defaults the IEC publisher; the ts grammar needs it explicit.
507
519
  const id = this.parse(code);
@@ -6,7 +6,7 @@ import { Language, PubidDate } from "../../model/component.js";
6
6
  * runtime attribute driving type derivation and the URN stage slot; the
7
7
  * wire hash carries only the stage CODE for non-published drafts.
8
8
  */
9
- export type IecTypeCode = "is" | "tr" | "ts" | "pas" | "srd" | "od" | "guide" | "ish" | "frag" | "trf" | "tec" | "wp" | "sttr" | "amd" | "cor";
9
+ export type IecTypeCode = "is" | "tr" | "ts" | "pas" | "srd" | "od" | "guide" | "ish" | "frag" | "trf" | "tec" | "wp" | "sttr" | "amd" | "cor" | "cs" | "ca";
10
10
  export interface TypedStage {
11
11
  code: string;
12
12
  stageCode: string;
@@ -15,7 +15,15 @@ export const TYPED_STAGES = [
15
15
  TS("trf", "published", "trf", "TRF"),
16
16
  TS("amd", "published", "amd", "AMD"),
17
17
  TS("cor", "published", "cor", "COR"),
18
- TS("np", "np", "is", "NP", "10.20"),
18
+ // IEC CS (Component Specifications) and IEC CA (Conformity Assessment):
19
+ // the abbreviation leads the code and the publisher renders as its
20
+ // default ("IEC CS 033200-TW0001", "IEC CA 01") — gem
21
+ // ComponentSpecification/ConformityAssessment.
22
+ TS("cs", "published", "cs", "CS"),
23
+ TS("ca", "published", "ca", "CA"),
24
+ // PNW owns harmonized 10.20 (gem: NP stages are 10.00/10.60/… — the
25
+ // URN "stage-10.20" slot resolves to PNW, not NP).
26
+ TS("np", "np", "is", "NP"),
19
27
  TS("pnw", "pnw", "is", "PNW", "10.20"),
20
28
  TS("pwi", "pwi", "is", "PWI", "00.00"),
21
29
  TS("anw", "anw", "is", "ANW"),
@@ -57,6 +65,8 @@ const TYPE_NAMES = {
57
65
  ts: "technical-specification",
58
66
  pas: "publicly-available-specification",
59
67
  srd: "systems-reference-document",
68
+ cs: "component-specification",
69
+ ca: "conformity-assessment",
60
70
  od: "operational-document",
61
71
  guide: "guide",
62
72
  ish: "interpretation-sheet",
@@ -414,7 +424,7 @@ function iecFragmentClass() {
414
424
  registerType(IecFragmentIdentifier);
415
425
  return IecFragmentIdentifier;
416
426
  }
417
- const SINGLE_KINDS = ["is", "tr", "ts", "pas", "srd", "od", "guide"];
427
+ const SINGLE_KINDS = ["is", "tr", "ts", "pas", "srd", "od", "guide", "cs", "ca"];
418
428
  const KIND_CLASSES = {};
419
429
  for (const kind of SINGLE_KINDS) {
420
430
  KIND_CLASSES[kind] = iecSingleClass(kind);
@@ -534,7 +534,11 @@ export const URN_PARSERS = {
534
534
  const revMatch = stripped.match(/^(.*)\.(r\d+)$/i);
535
535
  const code = revMatch ? revMatch[1] : stripped;
536
536
  const revision = revMatch ? revMatch[2] : undefined;
537
- let text = `NIST ${label} ${code}`;
537
+ // The NBS-era series carry the NBS imprint in their canonical form
538
+ // ("NBS CSM 1") — the rebuild names the publisher the document
539
+ // carries, or the flavor parse rejects its own URN's rebuild.
540
+ const publisher = typeToken.toLowerCase() === "csm" ? "NBS" : "NIST";
541
+ let text = `${publisher} ${label} ${code}`;
538
542
  if (revision)
539
543
  text += revision;
540
544
  return parse(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubid/pubid",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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",