@pubid/pubid 0.1.60 → 0.1.62

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.
@@ -1,37 +1,42 @@
1
1
  import { BaseIdentifier, registerType } from "../../model/identifier.js";
2
2
  import { keyValue, extendAttributes } from "../../model/attribute.js";
3
3
  /**
4
- * The wmo identifier model — lib/pubid/wmo/identifier.rb plus its
5
- * Identifiers::* leaves. Registration lives HERE (parg-free) so the
6
- * worker manifest (src/flavors/register-types.ts) can import it without
7
- * reaching the artifact runtime; the parse entry (./index.js) is the
8
- * parg-backed half.
9
- *
10
- * Two series share the flavor (pubid#763):
11
- *
12
- * WMO-No. <number>[, <year> edition] the WMO-No. publication
13
- * series; editions are calendar
14
- * years
15
- * S-<number>[ <x.y.z>] the WMO-published S-100 product
16
- * specifications; editions are
17
- * dotted x.y.z (the IHO lexical
18
- * form, WMO as the assigning
19
- * authority - the S-201-of-IALA
20
- * ruling)
21
- * S-<number> [Annex|ANNEX] [<letter>] [<x.y.z>] annex wrapper
22
- *
23
- * The edition is ONE string attribute carrying a type-driven face:
24
- * "2025" on a Publication, "1.2.1" on a Standard or Annex. The
25
- * renderer and the MRN URN generator key the face off the type.
4
+ * The publication series beyond the WMO-No. default (the widening
5
+ * prefix law: every head token names its publisher, so the model
6
+ * carries the short key and derives the citation face and the MRN
7
+ * slug from this table). The default row stays out of the table:
8
+ * series is undefined for WMO-No., so existing rows serialize without
9
+ * the key.
26
10
  */
11
+ const WMO_SERIES = {
12
+ TD: { face: "WMO/TD-No.", mrn: "wmo-td" },
13
+ JCOMM: { face: "JCOMM Technical Report No.", mrn: "jcomm-tr" },
14
+ GAW: { face: "GAW Report No.", mrn: "gaw" },
15
+ };
16
+ /** The WMO-No. series itself: the face the grammar matches and the MRN
17
+ * slug prefix of the default series (series undefined). */
18
+ const WMO_DEFAULT_SERIES = { face: "WMO-No.", mrn: "wmo" };
19
+ function wmoSeriesConfig(series) {
20
+ const found = series === undefined ? undefined : WMO_SERIES[series];
21
+ return found ?? WMO_DEFAULT_SERIES;
22
+ }
27
23
  /**
28
24
  * The MRN URN generator (lib/pubid/wmo/urn_generator.rb) — the WMO
29
25
  * assigning authority of the IANA-registered mrn namespace, following
30
26
  * the IALA pattern (pubid#763 proposed form):
31
27
  *
32
- * urn:mrn:wmo:pub:wmo-<number>[:ed<year>] the WMO-No. series
28
+ * urn:mrn:wmo:pub:wmo-<number>[:vol-<v>][:status-<s>][:ed<year>]
29
+ * [:updated-<year>] the WMO-No. series
30
+ * urn:mrn:wmo:pub:wmo-td-<number> the TD series
31
+ * urn:mrn:wmo:pub:jcomm-tr-<number> the joint WMO/IOC series
32
+ * urn:mrn:wmo:pub:gaw-<number> the GAW series
33
33
  * urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
34
34
  * urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
35
+ *
36
+ * The segment order mirrors the human face order (volume, status,
37
+ * edition, updated-in); the volume and status values are caseless
38
+ * (downcased, re-cased by the parser). The year pair keeps its slash
39
+ * out of the NSS as a hyphen ("2021/2018" rides as "ed2021-2018").
35
40
  */
36
41
  class WmoUrnGenerator {
37
42
  identifier;
@@ -41,22 +46,31 @@ class WmoUrnGenerator {
41
46
  generate() {
42
47
  const id = this.identifier;
43
48
  if (id instanceof WmoAnnex) {
49
+ // The base specification's code, then an "annex" segment (lettered
50
+ // form for the "ANNEX A" style, bare for "Annex" without a
51
+ // letter), then the annex's own edition.
44
52
  const parts = ["urn:mrn:wmo:pub", `s-${id.base?.number ?? ""}`];
45
- // Lettered form for the "ANNEX A" style, bare for "Annex"
46
- // without a letter.
47
53
  parts.push(id.letter !== undefined ? `annex-${id.letter.toLowerCase()}` : "annex");
48
54
  if (id.edition !== undefined)
49
55
  parts.push(`ed${id.edition}`);
50
56
  return parts.join(":");
51
57
  }
52
- // The WMO-No. series codes as "wmo-<number>"; the S-100 specs keep
58
+ // The publication series codes via its SERIES slug ("wmo-1364",
59
+ // "wmo-td-196", "jcomm-tr-14", "gaw-312"); the S-100 specs keep
53
60
  // their lexical form lowercased ("s-411").
54
61
  const code = id instanceof WmoPublication
55
- ? `wmo-${id.number ?? ""}`
62
+ ? `${wmoSeriesConfig(id.series).mrn}-${id.number ?? ""}`
56
63
  : `s-${id.number ?? ""}`;
57
64
  const parts = ["urn:mrn:wmo:pub", code];
65
+ if (id.volume !== undefined)
66
+ parts.push(`vol-${id.volume.toLowerCase()}`);
67
+ if (id.edition_status !== undefined) {
68
+ parts.push(`status-${id.edition_status.toLowerCase()}`);
69
+ }
58
70
  if (id.edition !== undefined)
59
- parts.push(`ed${id.edition}`);
71
+ parts.push(`ed${id.edition.replaceAll("/", "-")}`);
72
+ if (id.updated_in !== undefined)
73
+ parts.push(`updated-${id.updated_in}`);
60
74
  return parts.join(":");
61
75
  }
62
76
  }
@@ -65,19 +79,67 @@ export class WmoIdentifier extends BaseIdentifier {
65
79
  static polymorphicName = "pubid:wmo:identifier";
66
80
  static attributes = extendAttributes(BaseIdentifier, {
67
81
  publisher: { type: "string", default: "WMO" },
68
- number: { type: "string" },
69
- // One edition column, type-driven face.
82
+ number: { type: "string" }, // "1364", "411"
83
+ // The publication series key: undefined (the WMO-No. default),
84
+ // "TD", "JCOMM" or "GAW". The citation face and the MRN slug
85
+ // prefix derive from WMO_SERIES.
86
+ series: { type: "string" },
87
+ // One edition column, type-driven face: "2025" or the year pair
88
+ // "2021/2018" (the WMO-No. series' calendar-year edition) or
89
+ // "1.2.1" (the S-100 dotted edition).
70
90
  edition: { type: "string" },
91
+ // The publication volume face ("I", "I.1", "D"); publication-only.
92
+ volume: { type: "string" },
93
+ // The edition status word ("Provisional"); publication-only.
94
+ edition_status: { type: "string" },
95
+ // The year the edition was updated in ("2025"); publication-only.
96
+ updated_in: { type: "string" },
71
97
  });
72
- // The gem's key_value whitelist: _type, number, edition (the
73
- // defaulted publisher never serializes).
74
- static mappings = keyValue({ wire: "number", to: "number" }, { wire: "edition", to: "edition" });
98
+ // The gem's key_value whitelist: _type, number, series, edition,
99
+ // volume, edition_status, updated_in (the defaulted publisher never
100
+ // serializes).
101
+ static mappings = keyValue({ wire: "number", to: "number" }, { wire: "series", to: "series" }, { wire: "edition", to: "edition" }, { wire: "volume", to: "volume" }, { wire: "edition_status", to: "edition_status" }, { wire: "updated_in", to: "updated_in" });
75
102
  static urnGenerator = WmoUrnGenerator;
76
- /** The edition is a plain string (the string-edition flavors precede
77
- * this); the base mr_edition reads edition.number of a
78
- * Components::Edition, which would crash on the string. */
103
+ /** The series config (face + MRN slug prefix) of a series key,
104
+ * defaulting to the WMO-No. row. */
105
+ static seriesConfig(series) {
106
+ return wmoSeriesConfig(series);
107
+ }
108
+ /** The series config of this identifier's own series. */
109
+ seriesConfig() {
110
+ return wmoSeriesConfig(this.series);
111
+ }
112
+ /**
113
+ * The MR-slug identity hooks of the gem (lib/pubid/wmo/
114
+ * identifier.rb) — mirrors with no TS consumer yet (to_mr_string has
115
+ * no TS counterpart), kept faithful to the ruby bodies. The compound
116
+ * faces ride the edition segment so distinct identifiers never
117
+ * collide on the slug: the year pair keeps its slash out of the MR
118
+ * charset as a hyphen ("2021/2018" rides as "ed2021-2018"), the
119
+ * status word and the updated-in year suffix it.
120
+ */
79
121
  mrEdition() {
80
- return this.edition === undefined ? undefined : `ed${this.edition}`;
122
+ if (this.edition === undefined)
123
+ return undefined;
124
+ let segment = `ed${this.edition.replaceAll("/", "-")}`;
125
+ if (this.edition_status !== undefined) {
126
+ segment += `-${this.edition_status.toLowerCase()}`;
127
+ }
128
+ if (this.updated_in !== undefined)
129
+ segment += `-updated${this.updated_in}`;
130
+ return segment;
131
+ }
132
+ /** The series is the type discriminator of the publication series:
133
+ * "WMO/TD-No. 196" and "WMO-No. 196" are two documents. Downcased
134
+ * per the MR charset; undefined (no segment) on the WMO-No. default. */
135
+ mrType() {
136
+ return this.series === undefined ? undefined : this.series.toLowerCase();
137
+ }
138
+ /** The volume is an identity discriminator (the ECMA law): Volume I
139
+ * and Volume II of WMO-No. 8 are two documents sharing one
140
+ * docidentifier. Downcased per the MR charset. */
141
+ mrVolume() {
142
+ return this.volume === undefined ? undefined : `vol-${this.volume.toLowerCase()}`;
81
143
  }
82
144
  /** "WMO-No." and the S-number are designations, not publisher tokens:
83
145
  * the canonical faces carry no publisher prefix. */
@@ -86,13 +148,24 @@ export class WmoIdentifier extends BaseIdentifier {
86
148
  (this.edition !== undefined ? ` ${this.edition}` : "");
87
149
  }
88
150
  }
89
- /** Identifiers::Publication — the WMO-No. series. */
151
+ /** Identifiers::Publication — the WMO-No. publication series and its
152
+ * widened siblings (TD, JCOMM, GAW). Editions are calendar years —
153
+ * "2025 edition" — never version ordinals; the face order is the
154
+ * widening ruling's: volume first, then the edition face (the status
155
+ * word inside it), then the updated-in year. */
90
156
  export class WmoPublication extends WmoIdentifier {
91
157
  static polymorphicName = "pubid:wmo:publication";
92
158
  render() {
93
- let rendered = `WMO-No. ${this.number ?? ""}`;
94
- if (this.edition !== undefined)
95
- rendered += `, ${this.edition} edition`;
159
+ let rendered = `${this.seriesConfig().face} ${this.number ?? ""}`;
160
+ if (this.volume !== undefined)
161
+ rendered += `, Volume ${this.volume}`;
162
+ if (this.edition !== undefined) {
163
+ rendered += this.edition_status !== undefined
164
+ ? `, ${this.edition_status} ${this.edition} edition`
165
+ : `, ${this.edition} edition`;
166
+ if (this.updated_in !== undefined)
167
+ rendered += `, updated in ${this.updated_in}`;
168
+ }
96
169
  return rendered;
97
170
  }
98
171
  }
@@ -18,6 +18,7 @@ export const ialaSchema = define("iala", (s) => {
18
18
  s.type("pubid:iala:letter", "letter");
19
19
  s.type("pubid:iala:manual", "manual");
20
20
  s.type("pubid:iala:model-course", "mc");
21
+ s.type("pubid:iala:publication", "pub");
21
22
  s.type("pubid:iala:recommendation", "rec");
22
23
  s.type("pubid:iala:report", "rpt");
23
24
  s.type("pubid:iala:resolution", "r");
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { define } from "../index.js";
9
9
  export const ihoSchema = define("iho", (s) => {
10
+ s.atom("checks_for", "checks");
10
11
  s.atom("edition", "ed");
11
12
  s.atom("year", "year");
12
13
  s.atom("supplement", "sup");
@@ -7,7 +7,11 @@
7
7
  */
8
8
  import { define } from "../index.js";
9
9
  export const wmoSchema = define("wmo", (s) => {
10
+ s.atom("series", "series");
11
+ s.atom("volume", "vol");
10
12
  s.atom("edition", "ed");
13
+ s.atom("edition_status", "status");
14
+ s.atom("updated_in", "updated");
11
15
  s.atom("annex_form", "annexform");
12
16
  s.atom("letter", "letter");
13
17
  s.type("pubid:wmo:publication", "pub");