@pubid/pubid 0.1.61 → 0.1.63

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
@@ -27,5 +27,7 @@ export interface Identifier {
27
27
  /** Ruby ==: canonical equality skipping equalityIgnored attributes
28
28
  * (the (E) position is spelling, the language itself is not). */
29
29
  equals?(other: Identifier): boolean;
30
+ /** The pubid-scheme URN (urn:pubid:...) from the flavor schema table; BaseIdentifier provides it. */
31
+ toPubidUrn?(): string;
30
32
  }
31
33
  export type ImplementationRegistry = Map<string, FlavorImplementation>;
@@ -16,6 +16,7 @@ export declare class IalaIdentifier extends BaseIdentifier {
16
16
  }
17
17
  declare class IalaUrnGenerator extends BaseUrnGenerator<IalaIdentifier> {
18
18
  generate(): string;
19
+ private baseCode;
19
20
  }
20
21
  export declare class IalaAnnex extends IalaIdentifier {
21
22
  static polymorphicName: string;
@@ -28,5 +29,30 @@ export declare class IalaAnnex extends IalaIdentifier {
28
29
  typeLetter(): string | undefined;
29
30
  render(): string;
30
31
  }
32
+ /**
33
+ * The S-100-family product specification — the IHO-granted S-201..S-299
34
+ * range (pubid#777). The hyphenated code face is rendered by the
35
+ * renderer/URN generator directly; there is no type letter (an "S"
36
+ * short would collide with Standard's). The canonical face is bare —
37
+ * the designation carries no publisher token (the WMO S-100 rule).
38
+ */
39
+ export declare class IalaProductSpecification extends IalaIdentifier {
40
+ static polymorphicName: string;
41
+ static urnGenerator: typeof IalaUrnGenerator;
42
+ typeLetter(): string | undefined;
43
+ render(): string;
44
+ }
45
+ /**
46
+ * The codeless slug publication (gem #772): iala.int reports and
47
+ * proceedings with no code, named by their product-URL slug. The slug
48
+ * is held in the inherited `number` attribute — the index key — and no
49
+ * padding applies. There is no type letter: "IALA <slug>".
50
+ */
51
+ export declare class IalaPublication extends IalaIdentifier {
52
+ static polymorphicName: string;
53
+ static urnGenerator: typeof IalaUrnGenerator;
54
+ typeLetter(): string | undefined;
55
+ toUrn(): string;
56
+ }
31
57
  export declare function ialaGrammarImplementation(): FlavorImplementation;
32
58
  export {};
@@ -4,13 +4,34 @@ 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/ — 702 corpus rows. Typed prefixes
7
+ * 1:1 port of lib/pubid/iala/ — 880 corpus rows. Typed prefixes
8
8
  * (S/R/G/M/C/GA/L/X/P plus the legacy A session letter, which routes to
9
9
  * GeneralAssembly — there is no Advice type, pubid#734), class-driven
10
10
  * zero-padding (4 for S/R/G/M/C, 2+2 dotted for GA, verbatim for the
11
11
  * rest), "Ed 2.0" and ":ed2.0" edition forms, (F) languages, and Annex
12
12
  * wrappers. URN is the MRN form:
13
13
  * urn:mrn:iala:pub:<lower-code>[:ed<n>][:<lang>].
14
+ *
15
+ * The S-100-family product specifications (pubid#777, grammar#146): the
16
+ * IHO-granted S-201..S-299 range hyphenated ("S-201"), the dotted x.y.z
17
+ * edition on the BARE designation face ("S-201 2.0.0", iala.int's own
18
+ * citation form) with "Ed 2.0.0" and the compact ":ed2.0.0" as
19
+ * normalizing aliases; the hundreds digit is fixed to 2 by the grant and
20
+ * S-200 is excluded, so WMO's S-4xx and IHO's S-1xx never parse here.
21
+ * The annex wrapper rides the same class (the S-201 package's
22
+ * sub-numbered letters "ANNEX B2" widen the shared letter rule to an
23
+ * optional trailing digit); the annex edition face follows the base's
24
+ * family (bare for S-100, "Ed" for the legacy series).
25
+ *
26
+ * The codeless slug publications (gem #772, relaton#604): iala.int
27
+ * reports/proceedings with no code, named by their product-URL slug
28
+ * ("IALA arctic-seminar-report (E)"). The slug is two or more
29
+ * hyphen-joined [a-z0-9] runs whose FIRST run must not look like a code
30
+ * (0-2 letters then digits), so a lower-case or letterless typo of a
31
+ * typed code ("IALA s1070", "IALA 1070 Ed 2.0") still fails; the
32
+ * "IALA " prefix is mandatory for a slug (optional for a typed code).
33
+ * The slug is `number` — the index key — and the type has no MRN URN
34
+ * (the gem's Publication#to_urn → nil).
14
35
  */
15
36
  function buildRules() {
16
37
  const rules = {};
@@ -44,15 +65,52 @@ function buildRules() {
44
65
  .as("language_group"));
45
66
  rule("publisher", () => str("IALA").then(space).maybe());
46
67
  // The letter's absent-lowercase guard keeps "Ed 1"'s E from being
47
- // mis-captured as an annex letter.
68
+ // mis-captured as an annex letter. The letter takes an optional
69
+ // trailing digit (the S-201 package's sub-numbered annexes "Annex B2"
70
+ // / "Annex D1"), grammar#146.
71
+ const annexLetter = () => space
72
+ .then(match("[A-Z]").then(match("[0-9]").maybe()).as("annex_letter"), match("[a-z]").absent())
73
+ .maybe();
48
74
  rule("annex_identifier", () => rules["publisher"]
49
75
  .then(rules["type_letter"], rules["number_with_dots"], rules["subpart"].maybe())
50
76
  .as("base")
51
- .then(space, str("Annex").or(str("ANNEX")).as("annex_marker"), space
52
- .then(match("[A-Z]").as("annex_letter"), match("[a-z]").absent())
53
- .maybe(), rules["edition"].maybe(), rules["language"].maybe()));
54
- rule("identifier", () => rules["annex_identifier"].or(rules["publisher"]
55
- .then(rules["code"], rules["edition"].maybe(), rules["language"].maybe())));
77
+ .then(space, str("Annex").or(str("ANNEX")).as("annex_marker"), annexLetter(), rules["edition"].maybe(), rules["language"].maybe()));
78
+ rule("plain_identifier", () => rules["publisher"]
79
+ .then(rules["code"], rules["edition"].maybe(), rules["language"].maybe()));
80
+ // The S-100-family code: the hyphenated grant ("S-201"), the hundreds
81
+ // digit fixed to 2 and exactly "200" excluded ("spans from S-201"),
82
+ // so WMO's S-4xx and IHO's S-1xx never parse here.
83
+ rule("s100_number", () => str("200")
84
+ .absent()
85
+ .then(str("2").then(match("[0-9]"), match("[0-9]")))
86
+ .as("s100_number"));
87
+ // The lower-case code spelling ("IALA s-201", the site-URL shape)
88
+ // binds the typed form, never the codeless slug.
89
+ rule("s100_code", () => str("S").or(str("s")).then(dash, rules["s100_number"]));
90
+ // The bare dotted edition is canonical; "Ed 2.0.0" is the alias.
91
+ rule("s100_edition", () => space.then(str("Ed").then(space).maybe(), editionValue()).as("edition"));
92
+ rule("s100_annex_identifier", () => rules["publisher"]
93
+ .then(rules["s100_code"])
94
+ .then(space, str("Annex").or(str("ANNEX")).as("annex_marker"), annexLetter(), rules["edition"].or(rules["s100_edition"]).maybe(), rules["language"].maybe()));
95
+ rule("s100_identifier", () => rules["publisher"]
96
+ .then(rules["s100_code"])
97
+ .then(rules["edition"].or(rules["s100_edition"]).maybe(), rules["language"].maybe()));
98
+ // The codeless slug (gem #772): two or more hyphen-joined [a-z0-9]
99
+ // runs, the first run NOT code-like (0-2 letters then digits — "s1070",
100
+ // "ga01", "1070"), so a typed-code typo still fails. Last alternative:
101
+ // every typed code keeps priority, and the mandatory "IALA " prefix
102
+ // keeps any lower-case word from parsing.
103
+ rule("slug_segment", () => match("[a-z0-9]").repeat(1, Infinity));
104
+ rule("slug_code_like", () => match("[a-z]")
105
+ .repeat(0, 2)
106
+ .then(match("[0-9]").repeat(1, Infinity), match("[a-z0-9]").absent()));
107
+ rule("slug", () => rules["slug_code_like"]
108
+ .absent()
109
+ .then(rules["slug_segment"], dash.then(rules["slug_segment"]).repeat(1, Infinity))
110
+ .as("slug"));
111
+ rule("slug_identifier", () => str("IALA ")
112
+ .then(rules["slug"], rules["edition_human"].maybe(), rules["language"].maybe()));
113
+ rule("identifier", () => rules["annex_identifier"].or(rules["plain_identifier"], rules["s100_annex_identifier"], rules["s100_identifier"], rules["slug_identifier"]));
56
114
  rule("root", () => rules["identifier"]);
57
115
  return rules;
58
116
  }
@@ -83,22 +141,28 @@ export class IalaIdentifier extends BaseIdentifier {
83
141
  class IalaUrnGenerator extends BaseUrnGenerator {
84
142
  generate() {
85
143
  const id = this.identifier;
144
+ const parts = ["urn:mrn:iala:pub"];
86
145
  if (id instanceof IalaAnnex) {
87
- const parts = ["urn:mrn:iala:pub", `${id.base.typeLetter()?.toLowerCase()}${id.base.number}`];
146
+ parts.push(this.baseCode(id.base));
88
147
  parts.push(id.letter !== undefined ? `annex-${id.letter.toLowerCase()}` : "annex");
89
- if (id.edition !== undefined)
90
- parts.push(`ed${id.edition}`);
91
- if (id.language !== undefined)
92
- parts.push(id.language.toLowerCase());
93
- return parts.join(":");
94
148
  }
95
- const parts = ["urn:mrn:iala:pub", `${id.typeLetter()?.toLowerCase()}${id.number}`];
149
+ else {
150
+ parts.push(this.baseCode(id));
151
+ }
96
152
  if (id.edition !== undefined)
97
153
  parts.push(`ed${id.edition}`);
98
154
  if (id.language !== undefined)
99
155
  parts.push(id.language.toLowerCase());
100
156
  return parts.join(":");
101
157
  }
158
+ // The lowercase document identifier in IALA's managed namespace
159
+ // (G1143 §5.1.3): the legacy series codes join letter and number
160
+ // ("s1070"), the S-100-family codes hyphenate ("s-201").
161
+ baseCode(base) {
162
+ if (base instanceof IalaProductSpecification)
163
+ return `s-${base.number}`;
164
+ return `${base.typeLetter()?.toLowerCase()}${base.number}`;
165
+ }
102
166
  }
103
167
  const IALA_TYPES = [
104
168
  { kind: "standard", letter: "S", numberWidth: 4 },
@@ -159,17 +223,66 @@ export class IalaAnnex extends IalaIdentifier {
159
223
  return undefined;
160
224
  }
161
225
  render() {
162
- let rendered = `${this.base?.toHuman() ?? ""} ${this.annex_form ?? ""}`;
226
+ const baseStr = this.base?.toHuman() ?? "";
227
+ const s100Base = this.base instanceof IalaProductSpecification;
228
+ let rendered = `${baseStr} ${this.annex_form ?? ""}`;
163
229
  if (this.letter !== undefined)
164
230
  rendered += ` ${this.letter}`;
165
- if (this.edition !== undefined)
166
- rendered += ` Ed ${this.edition}`;
231
+ if (this.edition !== undefined) {
232
+ // The edition face follows the base's family: bare for an
233
+ // S-100-family base ("S-201 Annex A 1.0.0"), "Ed" for the legacy
234
+ // series ("G1128 ANNEX A Ed 1.6").
235
+ rendered += s100Base ? ` ${this.edition}` : ` Ed ${this.edition}`;
236
+ }
167
237
  if (this.language !== undefined)
168
238
  rendered += ` (${this.language})`;
169
239
  return rendered;
170
240
  }
171
241
  }
172
242
  registerType(IalaAnnex);
243
+ /**
244
+ * The S-100-family product specification — the IHO-granted S-201..S-299
245
+ * range (pubid#777). The hyphenated code face is rendered by the
246
+ * renderer/URN generator directly; there is no type letter (an "S"
247
+ * short would collide with Standard's). The canonical face is bare —
248
+ * the designation carries no publisher token (the WMO S-100 rule).
249
+ */
250
+ export class IalaProductSpecification extends IalaIdentifier {
251
+ static polymorphicName = "pubid:iala:product-specification";
252
+ static urnGenerator = IalaUrnGenerator;
253
+ typeLetter() {
254
+ return undefined;
255
+ }
256
+ render() {
257
+ let rendered = `S-${this.number ?? ""}`;
258
+ if (this.edition !== undefined)
259
+ rendered += ` ${this.edition}`;
260
+ if (this.language !== undefined)
261
+ rendered += ` (${this.language})`;
262
+ return rendered;
263
+ }
264
+ }
265
+ registerType(IalaProductSpecification);
266
+ /**
267
+ * The codeless slug publication (gem #772): iala.int reports and
268
+ * proceedings with no code, named by their product-URL slug. The slug
269
+ * is held in the inherited `number` attribute — the index key — and no
270
+ * padding applies. There is no type letter: "IALA <slug>".
271
+ */
272
+ export class IalaPublication extends IalaIdentifier {
273
+ static polymorphicName = "pubid:iala:publication";
274
+ static urnGenerator = IalaUrnGenerator;
275
+ typeLetter() {
276
+ return undefined;
277
+ }
278
+ // IALA assigns no MRN to a codeless publication, so it has no
279
+ // official URN (the gem's Publication#to_urn → nil); to_pubid_urn
280
+ // still names it.
281
+ toUrn() {
282
+ return undefined;
283
+ }
284
+ }
285
+ registerType(IalaPublication);
173
286
  // ---------------------------------------------------------------------------
174
287
  // Builder
175
288
  // ---------------------------------------------------------------------------
@@ -220,6 +333,10 @@ class IalaBuilder {
220
333
  const hash = flatten(data);
221
334
  if (hash["annex_marker"] !== undefined)
222
335
  return this.buildAnnex(hash);
336
+ if (hash["s100_number"] !== undefined)
337
+ return this.buildProductSpec(hash);
338
+ if (hash["slug"] !== undefined)
339
+ return this.buildPublication(hash);
223
340
  return this.buildFlat(hash);
224
341
  }
225
342
  buildFlat(hash) {
@@ -242,9 +359,51 @@ class IalaBuilder {
242
359
  attrs["language"] = language;
243
360
  return new klass(attrs);
244
361
  }
362
+ // The S-100-family product specification: the s100_number capture
363
+ // (the digits after "S-", e.g. "201") is the whole identity; the
364
+ // hyphen and the S are the code face the renderer and the URN
365
+ // generator add. The edition is the S-100 dotted x.y.z, verbatim.
366
+ buildProductSpec(hash) {
367
+ const attrs = {};
368
+ const number = s(hash["s100_number"]);
369
+ if (number !== undefined)
370
+ attrs["number"] = number;
371
+ const editionHash = isObj(hash["edition"]) ? flatten(hash["edition"]) : undefined;
372
+ const edition = editionHash !== undefined ? s(editionHash["edition_value"]) : undefined;
373
+ if (edition !== undefined)
374
+ attrs["edition"] = edition;
375
+ const languageHash = isObj(hash["language_group"]) ? flatten(hash["language_group"]) : undefined;
376
+ const language = languageHash !== undefined ? s(languageHash["language"])?.toUpperCase() : undefined;
377
+ if (language !== undefined)
378
+ attrs["language"] = language;
379
+ return new IalaProductSpecification(attrs);
380
+ }
381
+ // The codeless publication: the slug is its whole identity and goes
382
+ // into `number`, verbatim (no padding applies).
383
+ buildPublication(hash) {
384
+ const attrs = {};
385
+ const number = s(hash["slug"]);
386
+ if (number !== undefined)
387
+ attrs["number"] = number;
388
+ const editionHash = isObj(hash["edition"]) ? flatten(hash["edition"]) : undefined;
389
+ const edition = editionHash !== undefined ? s(editionHash["edition_value"]) : undefined;
390
+ if (edition !== undefined)
391
+ attrs["edition"] = edition;
392
+ const languageHash = isObj(hash["language_group"]) ? flatten(hash["language_group"]) : undefined;
393
+ const language = languageHash !== undefined ? s(languageHash["language"])?.toUpperCase() : undefined;
394
+ if (language !== undefined)
395
+ attrs["language"] = language;
396
+ return new IalaPublication(attrs);
397
+ }
245
398
  buildAnnex(hash) {
246
- const baseHash = flatten(hash["base"]);
247
- const base = this.buildFlat(baseHash);
399
+ // The S-100 annex stays flat (the grammar's base composite is
400
+ // unbound there — the s100_number capture is the only occurrence of
401
+ // its name on the annex path); the legacy annex nests its base
402
+ // composite under "base".
403
+ const s100Number = s(hash["s100_number"]);
404
+ const base = s100Number !== undefined
405
+ ? new IalaProductSpecification({ number: s100Number })
406
+ : this.buildFlat(flatten(hash["base"]));
248
407
  const attrs = {
249
408
  base,
250
409
  annex_form: s(hash["annex_marker"]),
@@ -291,7 +450,11 @@ export function ialaGrammarImplementation() {
291
450
  let annexForm;
292
451
  let annexLetter;
293
452
  for (const seg of parts.slice(1)) {
294
- const annexMatch = /^annex(-([a-z]))?$/i.exec(seg);
453
+ // The letter carries the sub-numbered S-100 annex letters
454
+ // ("annex-b2"); the generator emits "annex" (bare) for the
455
+ // Annex-without-letter form and "annex-X" for the uppercase
456
+ // ANNEX form — mirror it so the round-trip is exact.
457
+ const annexMatch = /^annex(-([a-z]\d?))?$/i.exec(seg);
295
458
  if (annexMatch !== null) {
296
459
  annexLetter = annexMatch[2]?.toUpperCase();
297
460
  annexForm = annexLetter !== undefined ? "ANNEX" : "Annex";
@@ -24,8 +24,12 @@ function buildRules() {
24
24
  const seriesLetter = str("S").or(str("P"), str("M"), str("B"), str("C"));
25
25
  const year4 = str("19").or(str("20")).then(match("[0-9]").repeat(2));
26
26
  rule("series", () => seriesLetter.as("type"));
27
- rule("number_suffix", () => str(":").then(digits));
28
- rule("number", () => digits.then(rules["number_suffix"].maybe()).as("number"));
27
+ // The colon member captures SEPARATELY ("S-158:102" → number "158" +
28
+ // colon_suffix "102"): the builder re-keys the S-158 member into
29
+ // checks_for and re-glues every other series' member into the number
30
+ // (the C-16:2 opaque face, pubid#637).
31
+ rule("number_suffix", () => str(":").then(digits.as("colon_suffix")));
32
+ rule("number", () => digits.as("number").then(rules["number_suffix"].maybe()));
29
33
  // The compact part face, hyphenated onto the code: S-5-B (lettered),
30
34
  // S-100-1 (numbered) and S-158-S-102 (series reference).
31
35
  rule("compact_part", () => dash.then(seriesLetter
@@ -119,12 +123,76 @@ function padEditionShorthand(value) {
119
123
  segments.push("0");
120
124
  return segments.join(".");
121
125
  }
126
+ /**
127
+ * The S-158 alias unification on the deserialization path (the gem's
128
+ * Builder.normalize_checks_alias, pubid#774). A hash carrying the
129
+ * draft-era part model on the standard family — a series reference
130
+ * ("S-102") or the bare member number ("102") riding number 158 with
131
+ * no checks_for — rebinding onto checks_for; the edition/year that
132
+ * followed the part face are the BASE ones. Pure function: returns the
133
+ * hash untouched when it carries no draft-era part face, a normalized
134
+ * copy otherwise. The face is not restored (the canonical colon form).
135
+ */
136
+ function normalizeChecksAlias(data) {
137
+ const part = data["part"];
138
+ const number = data["number"];
139
+ const typeKey = data["_type"];
140
+ if (typeof part !== "string" ||
141
+ number !== "158" ||
142
+ data["checks_for"] !== undefined ||
143
+ (typeKey !== undefined && !String(typeKey).endsWith("standard"))) {
144
+ return data;
145
+ }
146
+ const seriesRef = /^([SPMBC])-(\d+)$/.exec(part);
147
+ const digits = seriesRef !== null ? seriesRef[2] : /^\d+$/.test(part) ? part : undefined;
148
+ if (digits === undefined)
149
+ return data;
150
+ const out = { ...data };
151
+ const edition = out["part_edition"];
152
+ const year = out["part_year"];
153
+ if (out["edition"] !== undefined && edition !== undefined) {
154
+ throw new ParseFailed(`IHO: duplicate edition: the base edition and the member edition ${String(edition)} cannot both ride S-158:${digits}`, 0);
155
+ }
156
+ delete out["part"];
157
+ delete out["part_edition"];
158
+ delete out["part_year"];
159
+ out["checks_for"] = digits;
160
+ if (out["edition"] === undefined && edition !== undefined)
161
+ out["edition"] = edition;
162
+ if (out["year"] === undefined && year !== undefined)
163
+ out["year"] = year;
164
+ return out;
165
+ }
122
166
  function ihoClass(kind) {
123
167
  const letter = KIND_LETTERS[kind];
124
168
  class IhoKindIdentifier extends BaseIdentifier {
125
169
  static polymorphicName = `pubid:iho:${kind}`;
170
+ /** The deserialization path applies the same S-158 alias unification
171
+ * the parse path applies (the gem's Builder.normalize_checks_alias):
172
+ * a stored row or a legacy URN carrying the draft-era part model
173
+ * (part: "S-102", part_edition: "0.2.0") decodes to the checks_for
174
+ * identity, so no construction path yields the two-identity disease
175
+ * of issue #775. The spelling face is NOT restored — a deserialized
176
+ * identifier renders the canonical colon designator. */
177
+ static fromHash(hash) {
178
+ return super.fromHash(normalizeChecksAlias(hash));
179
+ }
126
180
  static attributes = extendAttributes(BaseIdentifier, {
127
181
  number: { type: "string" },
182
+ // The S-158 family facet (pubid#774): the S-100 product number
183
+ // whose validation checks this publication specifies. The colon
184
+ // designator form "S-158:102" is the primary face; the legacy
185
+ // draft-era part spellings bind the SAME identity.
186
+ checks_for: { type: "string" },
187
+ // The face the input spelled checks_for with: undefined = the
188
+ // primary colon face ("S-158:102"), otherwise the draft-era part
189
+ // value as written ("S-102" of "Part S-102"/"S-158-S-102", "102"
190
+ // of "Part 102") — it prints in the Part slot verbatim.
191
+ // Spelling-only: outside the mappings whitelist it never
192
+ // serializes, and equality skips it — render keeps the input
193
+ // spelling, equality/URN use the canonical shape. URN
194
+ // deserialization restores no face (the canonical colon form).
195
+ checks_face: { type: "string", equalityIgnored: true },
128
196
  part: { type: "string" },
129
197
  part_edition: { type: "string" },
130
198
  part_year: { type: "string" },
@@ -152,9 +220,16 @@ function ihoClass(kind) {
152
220
  spec_sub: { type: "string" },
153
221
  spec_variant: { type: "string" },
154
222
  });
155
- static mappings = keyValue({ wire: "number", to: "number" }, { wire: "part", to: "part" }, { wire: "part_edition", to: "part_edition" }, { wire: "part_year", to: "part_year" }, { wire: "annex", to: "annex" }, { wire: "annex_edition", to: "annex_edition" }, { wire: "annex_year", to: "annex_year" }, { wire: "appendix", to: "appendix" }, { wire: "appendix_subnumber", to: "appendix_subnumber" }, { wire: "appendix_edition", to: "appendix_edition" }, { wire: "appendix_year", to: "appendix_year" }, { wire: "supplement", to: "supplement" }, { wire: "supplement_edition", to: "supplement_edition" }, { wire: "supplement_year", to: "supplement_year" }, { wire: "edition", to: "edition" }, { wire: "year", to: "year" }, { wire: "volume", to: "volume" }, { wire: "volume_edition", to: "volume_edition" }, { wire: "volume_year", to: "volume_year" }, { wire: "issue", to: "issue" }, { wire: "spec", to: "spec" }, { wire: "spec_sub", to: "spec_sub" }, { wire: "spec_variant", to: "spec_variant" });
223
+ static mappings = keyValue({ wire: "number", to: "number" }, { wire: "checks_for", to: "checks_for" }, { wire: "part", to: "part" }, { wire: "part_edition", to: "part_edition" }, { wire: "part_year", to: "part_year" }, { wire: "annex", to: "annex" }, { wire: "annex_edition", to: "annex_edition" }, { wire: "annex_year", to: "annex_year" }, { wire: "appendix", to: "appendix" }, { wire: "appendix_subnumber", to: "appendix_subnumber" }, { wire: "appendix_edition", to: "appendix_edition" }, { wire: "appendix_year", to: "appendix_year" }, { wire: "supplement", to: "supplement" }, { wire: "supplement_edition", to: "supplement_edition" }, { wire: "supplement_year", to: "supplement_year" }, { wire: "edition", to: "edition" }, { wire: "year", to: "year" }, { wire: "volume", to: "volume" }, { wire: "volume_edition", to: "volume_edition" }, { wire: "volume_year", to: "volume_year" }, { wire: "issue", to: "issue" }, { wire: "spec", to: "spec" }, { wire: "spec_sub", to: "spec_sub" }, { wire: "spec_variant", to: "spec_variant" });
156
224
  render() {
157
225
  let result = `IHO ${letter}-${this.number}`;
226
+ // The S-158 checks face: the primary colon form rides the code
227
+ // ("S-158:102"); the draft-era part face keeps its spelling and
228
+ // prints in the Part slot — after the edition ("S-158 0.2.0
229
+ // Part S-102"). The compact face renders expanded (the S-5A law).
230
+ if (this.checks_for !== undefined && this.checks_face === undefined) {
231
+ result += `:${this.checks_for}`;
232
+ }
158
233
  if (this.edition !== undefined)
159
234
  result += ` ${this.edition}`;
160
235
  if (this.supplement !== undefined) {
@@ -174,6 +249,11 @@ function ihoClass(kind) {
174
249
  if (this.spec_variant !== undefined)
175
250
  result += `(${this.spec_variant})`;
176
251
  }
252
+ else if (this.checks_face !== undefined) {
253
+ // The draft-era member face prints in the Part slot, the part
254
+ // value as written ("Part S-102", "Part 102").
255
+ result += ` Part ${this.checks_face}`;
256
+ }
177
257
  else if (this.part !== undefined) {
178
258
  result += ` Part ${this.part}`;
179
259
  if (this.part_edition !== undefined)
@@ -214,12 +294,94 @@ function ihoClass(kind) {
214
294
  }
215
295
  }
216
296
  class IhoUrnGenerator extends BaseUrnGenerator {
297
+ // The guidance publication type per series letter (the gem's
298
+ // MRN_TYPES): S = Standards and Specifications -> spec, P = the
299
+ // periodic publications -> per, M = Miscellaneous (Base Regulatory
300
+ // Publications) -> reg. B and C have no guidance type code — they
301
+ // keep the legacy positional emission until IHO assigns one.
302
+ static MRN_TYPES = { S: "spec", P: "per", M: "reg" };
217
303
  generate() {
304
+ const mrnType = IhoUrnGenerator.MRN_TYPES[letter];
305
+ if (mrnType === undefined)
306
+ return this.generateLegacy();
307
+ const id = this.identifier;
308
+ // The IHO MRN guidance (S-100WG4, the gem's generate_mrn): the
309
+ // publications namespace urn:mrn:iho:pub:, the type token, the
310
+ // name segment, the bare dotted edition, then the trailing
311
+ // marker atoms in containment order.
312
+ const parts = ["urn:mrn:iho:pub", mrnType, this.mrnName(id)];
313
+ if (id.edition !== undefined)
314
+ parts.push(id.edition);
315
+ if (id.year !== undefined)
316
+ parts.push(`year-${id.year}`);
317
+ if (id.supplement !== undefined) {
318
+ parts.push(`sup-${id.supplement}`);
319
+ if (id.supplement_edition !== undefined)
320
+ parts.push(`ed-${id.supplement_edition}`);
321
+ if (id.supplement_year !== undefined)
322
+ parts.push(`year-${id.supplement_year}`);
323
+ }
324
+ if (id.part !== undefined) {
325
+ parts.push(`part-${id.part}`);
326
+ if (id.part_edition !== undefined)
327
+ parts.push(`ed-${id.part_edition}`);
328
+ if (id.part_year !== undefined)
329
+ parts.push(`year-${id.part_year}`);
330
+ }
331
+ // The S-4 spec citation: a child of its part (the citation letter
332
+ // rides the part- atom); the SECTION is NOT emitted — derivable
333
+ // from the spec's hundreds digit.
334
+ if (id.spec !== undefined) {
335
+ parts.push(`spec-${id.spec}`);
336
+ if (id.spec_sub !== undefined)
337
+ parts.push(`specsub-${id.spec_sub}`);
338
+ if (id.spec_variant !== undefined)
339
+ parts.push(`specvar-${id.spec_variant}`);
340
+ }
341
+ if (id.annex !== undefined) {
342
+ parts.push(`annex-${id.annex}`);
343
+ if (id.annex_edition !== undefined)
344
+ parts.push(`ed-${id.annex_edition}`);
345
+ if (id.annex_year !== undefined)
346
+ parts.push(`year-${id.annex_year}`);
347
+ }
348
+ if (id.appendix !== undefined) {
349
+ // The subnumber hyphen-joins its appendix (one compound
350
+ // segment, RFC 3986-safe).
351
+ let segment = `appendix-${id.appendix}`;
352
+ if (id.appendix_subnumber !== undefined)
353
+ segment += `-${id.appendix_subnumber}`;
354
+ parts.push(segment);
355
+ if (id.appendix_edition !== undefined)
356
+ parts.push(`ed-${id.appendix_edition}`);
357
+ if (id.appendix_year !== undefined)
358
+ parts.push(`year-${id.appendix_year}`);
359
+ }
360
+ if (id.volume !== undefined) {
361
+ parts.push(`vol-${id.volume}`);
362
+ if (id.issue !== undefined)
363
+ parts.push(`issue-${id.issue}`);
364
+ if (id.volume_edition !== undefined)
365
+ parts.push(`ed-${id.volume_edition}`);
366
+ if (id.volume_year !== undefined)
367
+ parts.push(`year-${id.volume_year}`);
368
+ }
369
+ return parts.join(":");
370
+ }
371
+ /** The lowercase name form: sNNN, the S-158 member joining
372
+ * hyphenated (s158-102) so the edition stays in its canonical 4th
373
+ * position. */
374
+ mrnName(id) {
375
+ let name = `${letter.toLowerCase()}${id.number}`;
376
+ if (id.checks_for !== undefined)
377
+ name += `-${id.checks_for}`;
378
+ return name;
379
+ }
380
+ /** The legacy positional form (the B/C emission today; the shape
381
+ * every legacy urn:iho: URN decodes from). */
382
+ generateLegacy() {
218
383
  const id = this.identifier;
219
384
  const parts = ["urn", "iho", letter.toLowerCase(), id.number];
220
- // Each component is a marker-prefixed segment; its own edition
221
- // (ed-) and year (year-) follow it directly. The base edition
222
- // and year come first (they attach to the base node).
223
385
  if (id.edition !== undefined)
224
386
  parts.push(`ed-${id.edition}`);
225
387
  if (id.year !== undefined)
@@ -238,10 +400,6 @@ function ihoClass(kind) {
238
400
  if (id.part_year !== undefined)
239
401
  parts.push(`year-${id.part_year}`);
240
402
  }
241
- // The S-4 spec citation: a child of its part (the citation letter
242
- // rides the part- atom), the dotted sub and the parenthesized
243
- // variant its own children. The spelled SECTION is NOT emitted —
244
- // derivable from the spec's hundreds digit.
245
403
  if (id.spec !== undefined) {
246
404
  parts.push(`spec-${id.spec}`);
247
405
  if (id.spec_sub !== undefined)
@@ -259,7 +417,7 @@ function ihoClass(kind) {
259
417
  if (id.appendix !== undefined) {
260
418
  parts.push(`appendix-${id.appendix}`);
261
419
  // The subnumber is a bare child segment directly after the
262
- // appendix ("appendix-D:2").
420
+ // appendix (the legacy emission's only bare atom).
263
421
  if (id.appendix_subnumber !== undefined)
264
422
  parts.push(id.appendix_subnumber);
265
423
  if (id.appendix_edition !== undefined)
@@ -296,6 +454,20 @@ class IhoBuilder extends BaseBuilder {
296
454
  // resolves through (bare "B-401" carries it implicitly).
297
455
  static S4_TYPE = "S";
298
456
  static S4_NUMBER = "4";
457
+ // The S-158 framework publication: its series members (the colon
458
+ // designator and the series-reference part faces) re-key into
459
+ // checks_for (pubid#774).
460
+ static S158_NUMBER = "158";
461
+ // The two publication modes are mutually exclusive (the gem's
462
+ // assert_edition_mode!): a base edition and any component edition
463
+ // cannot ride together.
464
+ static COMPONENT_EDITIONS = [
465
+ "part_edition",
466
+ "supplement_edition",
467
+ "annex_edition",
468
+ "appendix_edition",
469
+ "volume_edition",
470
+ ];
299
471
  // A citation letter is one of S-4's lettered Parts; the section
300
472
  // vocabulary (100-600, Part C 100-500) is theirs.
301
473
  static SPEC_LETTERS = ["A", "B", "C"];
@@ -333,6 +505,67 @@ class IhoBuilder extends BaseBuilder {
333
505
  delete flat[yearKey];
334
506
  }
335
507
  }
508
+ // The S-158 family re-key (pubid#774, the gem's Builder). The colon
509
+ // designator "S-158:<NNN>" is the PRIMARY face: number stays 158,
510
+ // the member binds checks_for. The member designator is the S-158
511
+ // series device — a colon form on any other anchor rejects
512
+ // ("S-44:5", "C-16:2"). A draft-era part face on the S-158 family —
513
+ // a series reference ("Part S-102"), the compact face
514
+ // ("S-158-S-102") or the bare member number ("Part 102") — rebinds
515
+ // onto checks_for while checks_for is UNBOUND (a bound member keeps
516
+ // a genuine part: "S-158:100 Part 2"); a lettered or compound part
517
+ // value ("Part A", "Part 4a") never rebinds. The edition/year that
518
+ // follow the draft-era part face are the BASE ones (the pubid#775
519
+ // mis-bind fix), and the spelling face records the part value as
520
+ // written so the render keeps the input's spelling (equality/URN
521
+ // canonical). The two publication modes are mutually exclusive: a
522
+ // base edition and any component edition cannot ride together.
523
+ const colonSuffix = flat["colon_suffix"];
524
+ delete flat["colon_suffix"];
525
+ if (colonSuffix !== undefined) {
526
+ const type = flat["type"];
527
+ if (flat["number"] === IhoBuilder.S158_NUMBER && (type === undefined || type === "S")) {
528
+ if (flat["checks_for"] !== undefined && flat["checks_for"] !== colonSuffix) {
529
+ throw new ParseFailed(`IHO: checks_for ${String(flat["checks_for"])} conflicts with the colon member ${String(colonSuffix)}`, 0);
530
+ }
531
+ flat["checks_for"] = colonSuffix;
532
+ }
533
+ else {
534
+ throw new ParseFailed(`IHO: the checks_for member designator is the S-158 series device: ${String(type ?? "S")}-${String(flat["number"])}:${String(colonSuffix)} cannot carry it`, 0);
535
+ }
536
+ }
537
+ if (flat["number"] === IhoBuilder.S158_NUMBER &&
538
+ flat["checks_for"] === undefined &&
539
+ typeof flat["part"] === "string") {
540
+ const partValue = flat["part"];
541
+ const seriesRef = /^([SPMBC])-(\d+)$/.exec(partValue);
542
+ const digits = seriesRef !== null ? seriesRef[2] : /^\d+$/.test(partValue) ? partValue : undefined;
543
+ if (digits !== undefined) {
544
+ flat["checks_for"] = digits;
545
+ flat["checks_face"] = partValue;
546
+ delete flat["part"];
547
+ const edition = flat["part_edition"];
548
+ const year = flat["part_year"];
549
+ delete flat["part_edition"];
550
+ delete flat["part_year"];
551
+ if (flat["edition"] !== undefined && edition !== undefined) {
552
+ throw new ParseFailed(`IHO: duplicate edition: the base edition ${String(flat["edition"])} and the member edition ${String(edition)} cannot both ride S-158:${digits}`, 0);
553
+ }
554
+ if (flat["year"] !== undefined && year !== undefined) {
555
+ throw new ParseFailed(`IHO: duplicate year: the base year ${String(flat["year"])} and the member year ${String(year)} cannot both ride S-158:${digits}`, 0);
556
+ }
557
+ if (flat["edition"] === undefined && edition !== undefined)
558
+ flat["edition"] = edition;
559
+ if (flat["year"] === undefined && year !== undefined)
560
+ flat["year"] = year;
561
+ }
562
+ }
563
+ if (flat["edition"] !== undefined) {
564
+ const owned = IhoBuilder.COMPONENT_EDITIONS.filter((k) => flat[k] !== undefined);
565
+ if (owned.length > 0) {
566
+ throw new ParseFailed(`IHO: a base edition and a component edition are mutually exclusive: ${owned.join(", ")} cannot ride edition ${String(flat["edition"])}`, 0);
567
+ }
568
+ }
336
569
  // The S-4 spec citation resolution (ruby resolve_spec_citation!):
337
570
  // the citation letter folds into `part` (a Part-rule capture must
338
571
  // agree), and the long form's spelled section becomes the spec