@pubid/pubid 0.1.52 → 0.1.54

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.
Binary file
@@ -4,11 +4,13 @@ import { BaseIdentifier, registerType } from "../../model/identifier.js";
4
4
  import { extendAttributes, keyValue } from "../../model/attribute.js";
5
5
  import { BaseUrnGenerator } from "../../model/urn-generator.js";
6
6
  /**
7
- * 1:1 port of lib/pubid/iala/ — 706 corpus rows. Typed prefixes
8
- * (S/R/G/M/C/A/GA/L/X/P), class-driven zero-padding (4 for S/R/G/M/C,
9
- * 2+2 dotted for GA, verbatim for the rest), "Ed 2.0" and ":ed2.0"
10
- * edition forms, (F) languages, and Annex wrappers. URN is the MRN
11
- * form: urn:mrn:iala:pub:<lower-code>[:ed<n>][:<lang>].
7
+ * 1:1 port of lib/pubid/iala/ — 702 corpus rows. Typed prefixes
8
+ * (S/R/G/M/C/GA/L/X/P plus the legacy A session letter, which routes to
9
+ * GeneralAssembly — there is no Advice type, pubid#734), class-driven
10
+ * zero-padding (4 for S/R/G/M/C, 2+2 dotted for GA, verbatim for the
11
+ * rest), "Ed 2.0" and ":ed2.0" edition forms, (F) languages, and Annex
12
+ * wrappers. URN is the MRN form:
13
+ * urn:mrn:iala:pub:<lower-code>[:ed<n>][:<lang>].
12
14
  */
13
15
  function buildRules() {
14
16
  const rules = {};
@@ -104,23 +106,44 @@ const IALA_TYPES = [
104
106
  { kind: "guideline", letter: "G", numberWidth: 4 },
105
107
  { kind: "manual", letter: "M", numberWidth: 4 },
106
108
  { kind: "model-course", letter: "C", numberWidth: 4 },
107
- { kind: "advice", letter: "A" },
108
- { kind: "general-assembly", letter: "GA", numberWidth: 2, dottedSegmentWidth: 2 },
109
+ // The A letter is GeneralAssembly's legacy session form, not a
110
+ // separate series: all 11 A-shaped primary docidentifiers in
111
+ // relaton-data-iala (A12-01, A13-01 through A13-04) are GA
112
+ // resolutions, the covers read "GA Resolution A12-01", and no
113
+ // Advice-series document exists in the catalogue (pubid#734).
114
+ { kind: "general-assembly", letter: "GA", numberWidth: 2, dottedSegmentWidth: 2, typeLetterAliases: ["A"] },
109
115
  { kind: "letter", letter: "L" },
110
116
  { kind: "report", letter: "X" },
111
117
  { kind: "resolution", letter: "P" },
112
118
  ];
113
- const TYPE_SPECS = new Map(IALA_TYPES.map((t) => [t.letter, t]));
119
+ const TYPE_SPECS = new Map(IALA_TYPES.flatMap((t) => [[t.letter, t]]
120
+ .concat((t.typeLetterAliases ?? []).map((a) => [a, t]))));
114
121
  function ialaClass(spec) {
115
122
  class IalaTypeIdentifier extends IalaIdentifier {
116
123
  static polymorphicName = `pubid:iala:${spec.kind}`;
117
124
  static urnGenerator = IalaUrnGenerator;
118
125
  static typeLetter = spec.letter;
126
+ static typeLetterAliases = spec.typeLetterAliases ?? [];
127
+ }
128
+ if (spec.typeLetterAliases !== undefined) {
129
+ // The legacy A-session letter renders for dashed numbers (A12-01);
130
+ // dotted numbers carry the canonical GA letter. Derived from the
131
+ // number shape, no extra attribute is stored — mirrors the Ruby
132
+ // GeneralAssembly#type_letter override (pubid#734).
133
+ IalaTypeIdentifier.prototype.typeLetter = function () {
134
+ return (this.number ?? "").includes("-")
135
+ ? spec.typeLetterAliases[0]
136
+ : this.constructor.typeLetter;
137
+ };
119
138
  }
120
139
  registerType(IalaTypeIdentifier);
121
140
  return IalaTypeIdentifier;
122
141
  }
123
- const KIND_CLASSES = new Map(IALA_TYPES.map((spec) => [spec.letter, ialaClass(spec)]));
142
+ const KIND_CLASSES = new Map(IALA_TYPES.flatMap((spec) => {
143
+ const klass = ialaClass(spec);
144
+ return [[spec.letter, klass]]
145
+ .concat((spec.typeLetterAliases ?? []).map((a) => [a, klass]));
146
+ }));
124
147
  export class IalaAnnex extends IalaIdentifier {
125
148
  static polymorphicName = "pubid:iala:annex";
126
149
  static attributes = extendAttributes(IalaIdentifier, {
@@ -11,7 +11,6 @@ export const ialaSchema = define("iala", (s) => {
11
11
  s.atom("language", "lang");
12
12
  s.atom("annex_form", "annexform");
13
13
  s.atom("letter", "letter");
14
- s.type("pubid:iala:advice", "advice");
15
14
  s.type("pubid:iala:annex", "annex");
16
15
  s.type("pubid:iala:general-assembly", "ga");
17
16
  s.type("pubid:iala:guideline", "g");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubid/pubid",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
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",
@@ -19,7 +19,7 @@
19
19
  "doc:api": "node scripts/api-reference.mjs"
20
20
  },
21
21
  "dependencies": {
22
- "parsanol": "0.10.51",
22
+ "parsanol": "1.5.0",
23
23
  "yaml": "^2.5.0"
24
24
  },
25
25
  "devDependencies": {