@pubid/pubid 0.1.58 → 0.1.60
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.
- package/README.md +3 -3
- package/artifact/corpus.json.gz +0 -0
- package/dist/flavors/ansi/index.d.ts +1 -22
- package/dist/flavors/ansi/index.js +106 -132
- package/dist/flavors/ansi/model.d.ts +60 -0
- package/dist/flavors/ansi/model.js +107 -0
- package/dist/flavors/eu/index.js +37 -5
- package/dist/flavors/eu/model.d.ts +10 -1
- package/dist/flavors/eu/model.js +8 -4
- package/dist/flavors/index.js +3 -0
- package/dist/flavors/itu/grammar.js +12 -3
- package/dist/flavors/itu/index.js +5 -1
- package/dist/flavors/itu/model.d.ts +6 -0
- package/dist/flavors/itu/model.js +23 -0
- package/dist/flavors/register-types.d.ts +2 -1
- package/dist/flavors/register-types.js +2 -1
- package/dist/flavors/wmo/index.d.ts +3 -0
- package/dist/flavors/wmo/index.js +47 -0
- package/dist/flavors/wmo/model.d.ts +82 -0
- package/dist/flavors/wmo/model.js +135 -0
- package/dist/pubid-urn/schemas/ansi.js +3 -0
- package/dist/pubid-urn/schemas/eu.js +1 -0
- package/dist/pubid-urn/schemas/index.js +2 -0
- package/dist/pubid-urn/schemas/itu.js +1 -0
- package/dist/pubid-urn/schemas/wmo.d.ts +8 -0
- package/dist/pubid-urn/schemas/wmo.js +16 -0
- package/dist/urn/parsers.js +76 -0
- package/package.json +1 -1
- package/vendor/parg/ansi.json +1 -1
- package/vendor/parg/itu.json +1 -1
- package/vendor/parg/wmo.json +1 -0
|
@@ -5,8 +5,8 @@ import { match, str } from "../../grammar/engine.js";
|
|
|
5
5
|
* succeeded alternative, so neighbour order in `identifier` is pinned
|
|
6
6
|
* by the Ruby comments):
|
|
7
7
|
* annex_to | special_publication | supplement | annex | appendix |
|
|
8
|
-
* report | handbook | numeric_question | letter_question |
|
|
9
|
-
* contribution | series_code | without_series
|
|
8
|
+
* report | resolution | handbook | numeric_question | letter_question |
|
|
9
|
+
* with_series | contribution | series_code | without_series
|
|
10
10
|
* and supplement chains precede supplement_with_base (which would
|
|
11
11
|
* otherwise strand "/Technical Cor. 1" trailing input).
|
|
12
12
|
*/
|
|
@@ -154,6 +154,15 @@ function buildRules() {
|
|
|
154
154
|
.then(space, rules["itu_prefix"], rules["sector"], space, rules["report_body"])
|
|
155
155
|
.or(rules["itu_prefix"].then(rules["sector"], space, rules["report_word"], space, rules["report_body"])));
|
|
156
156
|
rule("report_identifier", () => rules["base_report"].then(rules["language"].maybe()));
|
|
157
|
+
// ITU-R Resolution ("Resolution ITU-R 1-9 (2023)"): a number and its
|
|
158
|
+
// revision, never a series. Like the Report marker, the word is
|
|
159
|
+
// captured, and both the leading and the infix spelling are accepted.
|
|
160
|
+
rule("resolution_word", () => str("Resolution").or(str("Res.")).as("resolution_marker"));
|
|
161
|
+
rule("resolution_body", () => rules["code"].then(rules["document_date"].maybe()));
|
|
162
|
+
rule("base_resolution", () => rules["resolution_word"]
|
|
163
|
+
.then(space, rules["itu_prefix"], rules["sector"], space, rules["resolution_body"])
|
|
164
|
+
.or(rules["itu_prefix"].then(rules["sector"], space, rules["resolution_word"], space, rules["resolution_body"])));
|
|
165
|
+
rule("resolution_identifier", () => rules["base_resolution"].then(rules["language"].maybe()));
|
|
157
166
|
rule("base", () => rules["base_report"].or(rules["base_with_series"], rules["base_without_series"], rules["base_series_code"]));
|
|
158
167
|
// Annex label: one letter, optional number and/or "+" ("F3", "C+").
|
|
159
168
|
rule("annex_label", () => letter.then(digits.maybe(), str("+").maybe()));
|
|
@@ -254,7 +263,7 @@ function buildRules() {
|
|
|
254
263
|
rule("radio_regulations", () => rules["itu_prefix"]
|
|
255
264
|
.then(str("R").as("sector"), space, str("RR").as("radio_regulations"), rules["date_part"].or(dash.then(digit.repeat(4, 4).as("year"))).maybe(), rules["language"].maybe(), match(".").absent()));
|
|
256
265
|
rule("identifier", () => rules["annex_to_identifier"]
|
|
257
|
-
.or(rules["special_publication"], rules["supplement_identifier"], rules["annex_identifier"], rules["appendix_identifier"], rules["report_identifier"], rules["handbook"], rules["numeric_question"], rules["letter_question"], rules["radio_regulations"], rules["with_series"], rules["contribution"], rules["series_code_identifier"], rules["without_series"], rules["publication_id"]));
|
|
266
|
+
.or(rules["special_publication"], rules["supplement_identifier"], rules["annex_identifier"], rules["appendix_identifier"], rules["report_identifier"], rules["resolution_identifier"], rules["handbook"], rules["numeric_question"], rules["letter_question"], rules["radio_regulations"], rules["with_series"], rules["contribution"], rules["series_code_identifier"], rules["without_series"], rules["publication_id"]));
|
|
258
267
|
rule("root", () => rules["identifier"]
|
|
259
268
|
.then(rules["common_text_twin"])
|
|
260
269
|
.or(rules["identifier"]));
|
|
@@ -79,7 +79,11 @@ class ItuBuilder {
|
|
|
79
79
|
combined: this.buildDesignations(tree["combined"]),
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
const klass = tree["report_marker"] !== undefined
|
|
82
|
+
const klass = tree["report_marker"] !== undefined
|
|
83
|
+
? ITU_CLASSES["report"]
|
|
84
|
+
: tree["resolution_marker"] !== undefined
|
|
85
|
+
? ITU_CLASSES["resolution"]
|
|
86
|
+
: ITU_CLASSES["recommendation"];
|
|
83
87
|
return new klass({ ...common });
|
|
84
88
|
}
|
|
85
89
|
withTwin(identifier, twin) {
|
|
@@ -72,6 +72,11 @@ export declare class ItuReport extends ItuIdentifier {
|
|
|
72
72
|
static mappings: FieldMapping[];
|
|
73
73
|
renderBase(): string;
|
|
74
74
|
}
|
|
75
|
+
export declare class ItuResolution extends ItuIdentifier {
|
|
76
|
+
static polymorphicName: string;
|
|
77
|
+
static mappings: FieldMapping[];
|
|
78
|
+
renderBase(): string;
|
|
79
|
+
}
|
|
75
80
|
export declare class ItuHandbook extends ItuIdentifier {
|
|
76
81
|
static polymorphicName: string;
|
|
77
82
|
static mappings: FieldMapping[];
|
|
@@ -174,6 +179,7 @@ export declare class ItuAnnex extends ItuIdentifier {
|
|
|
174
179
|
export declare const ITU_CLASSES: {
|
|
175
180
|
readonly recommendation: typeof ItuRecommendation;
|
|
176
181
|
readonly report: typeof ItuReport;
|
|
182
|
+
readonly resolution: typeof ItuResolution;
|
|
177
183
|
readonly handbook: typeof ItuHandbook;
|
|
178
184
|
readonly special_publication: typeof ItuSpecialPublication;
|
|
179
185
|
readonly radio_regulations: typeof ItuRadioRegulations;
|
|
@@ -271,6 +271,10 @@ export class ItuUrnGenerator extends BaseUrnGenerator {
|
|
|
271
271
|
// reach the URN or the two same-numbered documents collide.
|
|
272
272
|
if (id instanceof ItuReport)
|
|
273
273
|
parts.push("report");
|
|
274
|
+
// A Resolution numbers independently too ("1-9" is also a
|
|
275
|
+
// Recommendation number), so it gets its own segment.
|
|
276
|
+
if (id instanceof ItuResolution)
|
|
277
|
+
parts.push("resolution");
|
|
274
278
|
if (id.series !== undefined) {
|
|
275
279
|
if (id.code !== undefined) {
|
|
276
280
|
const join = id.series_dash === true ? "-" : ".";
|
|
@@ -347,6 +351,24 @@ export class ItuReport extends ItuIdentifier {
|
|
|
347
351
|
}
|
|
348
352
|
registerType(ItuReport);
|
|
349
353
|
attachUrn(ItuReport);
|
|
354
|
+
// The ITU-R Resolution, adopted by the Radiocommunication Assembly
|
|
355
|
+
// ("Resolution ITU-R 1-9 (2023)"). A Resolution has a number and a
|
|
356
|
+
// revision (code.parts, as for a Recommendation edition), never a
|
|
357
|
+
// series. Resolutions number independently of Recommendations, so the
|
|
358
|
+
// leading word is part of the identity: it reaches to_s and the URN,
|
|
359
|
+
// and the class-strict == keeps "Resolution ITU-R 1-9" unequal to
|
|
360
|
+
// "ITU-R 1-9" in both directions. The grammar also reads "ITU-R Res.
|
|
361
|
+
// 1-9", "ITU-R Resolution 1-9" and "Res. ITU-R 1-9"; all render ITU's
|
|
362
|
+
// leading form.
|
|
363
|
+
export class ItuResolution extends ItuIdentifier {
|
|
364
|
+
static polymorphicName = "pubid:itu:resolution";
|
|
365
|
+
static mappings = STANDARD_MAPPINGS;
|
|
366
|
+
renderBase() {
|
|
367
|
+
return `Resolution ${super.renderBase()}`;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
registerType(ItuResolution);
|
|
371
|
+
attachUrn(ItuResolution);
|
|
350
372
|
export class ItuHandbook extends ItuIdentifier {
|
|
351
373
|
static polymorphicName = "pubid:itu:handbook";
|
|
352
374
|
static mappings = STANDARD_MAPPINGS;
|
|
@@ -629,6 +651,7 @@ attachUrn(ItuAnnex);
|
|
|
629
651
|
export const ITU_CLASSES = {
|
|
630
652
|
recommendation: ItuRecommendation,
|
|
631
653
|
report: ItuReport,
|
|
654
|
+
resolution: ItuResolution,
|
|
632
655
|
handbook: ItuHandbook,
|
|
633
656
|
special_publication: ItuSpecialPublication,
|
|
634
657
|
radio_regulations: ItuRadioRegulations,
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
* codec with no node-only module in the graph.
|
|
35
35
|
*/
|
|
36
36
|
import "./amca/model.js";
|
|
37
|
+
import "./ansi/model.js";
|
|
37
38
|
import "./api/model.js";
|
|
38
39
|
import "./arxiv/model.js";
|
|
39
40
|
import "./ashrae/model.js";
|
|
@@ -53,7 +54,7 @@ import "./iso/model.js";
|
|
|
53
54
|
import "./itu/model.js";
|
|
54
55
|
import "./nist/model.js";
|
|
55
56
|
import "./oiml/model.js";
|
|
56
|
-
import "./
|
|
57
|
+
import "./wmo/model.js";
|
|
57
58
|
import "./bipm/index.js";
|
|
58
59
|
import "./calconnect/index.js";
|
|
59
60
|
import "./ccsds/model.js";
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
// Model-registrant flavors: registration lives in <flavor>/model.js.
|
|
37
37
|
import "./amca/model.js";
|
|
38
|
+
import "./ansi/model.js";
|
|
38
39
|
import "./api/model.js";
|
|
39
40
|
import "./arxiv/model.js";
|
|
40
41
|
import "./ashrae/model.js";
|
|
@@ -54,8 +55,8 @@ import "./iso/model.js";
|
|
|
54
55
|
import "./itu/model.js";
|
|
55
56
|
import "./nist/model.js";
|
|
56
57
|
import "./oiml/model.js";
|
|
58
|
+
import "./wmo/model.js";
|
|
57
59
|
// Index-registrant flavors: registration lives in <flavor>/index.js.
|
|
58
|
-
import "./ansi/index.js";
|
|
59
60
|
import "./bipm/index.js";
|
|
60
61
|
import "./calconnect/index.js";
|
|
61
62
|
// ccsds (pubid-ts#178): the registration classes live on ccsds/model.js
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ParseFailed } from "../../grammar/engine.js";
|
|
2
|
+
import { PubidRuntime } from "../../parg/runtime.js";
|
|
3
|
+
import { WmoAnnex, WmoPublication, WmoStandard } from "./model.js";
|
|
4
|
+
export * from "./model.js";
|
|
5
|
+
/**
|
|
6
|
+
* The wmo parse entry — the same baked artifact the Ruby flavor runs
|
|
7
|
+
* (pubid-grammar grammars/wmo.parg -> artifacts/wmo.json, sealed at
|
|
8
|
+
* parsanol 1.5.1.0), loaded through the artifact runtime. The builder
|
|
9
|
+
* mirrors Pubid::Wmo::Builder: the grammar carries exactly one
|
|
10
|
+
* doc_number and edition_value per alternative path, so one flat bound
|
|
11
|
+
* map serves all three types and the dispatch keys off `annex_marker`
|
|
12
|
+
* and `wmomarker`.
|
|
13
|
+
*/
|
|
14
|
+
function buildWmo(data) {
|
|
15
|
+
const number = data["doc_number"] === undefined ? undefined : String(data["doc_number"]);
|
|
16
|
+
const edition = data["edition_value"] === undefined ? undefined : String(data["edition_value"]);
|
|
17
|
+
const annexMarker = data["annex_marker"] === undefined ? undefined : String(data["annex_marker"]);
|
|
18
|
+
const annexLetter = data["annex_letter"] === undefined ? undefined : String(data["annex_letter"]);
|
|
19
|
+
if (annexMarker !== undefined) {
|
|
20
|
+
const attrs = {
|
|
21
|
+
base: new WmoStandard({ number }),
|
|
22
|
+
annex_form: annexMarker,
|
|
23
|
+
};
|
|
24
|
+
if (annexLetter !== undefined)
|
|
25
|
+
attrs["letter"] = annexLetter;
|
|
26
|
+
if (edition !== undefined)
|
|
27
|
+
attrs["edition"] = edition;
|
|
28
|
+
return new WmoAnnex(attrs);
|
|
29
|
+
}
|
|
30
|
+
if (data["wmomarker"] !== undefined) {
|
|
31
|
+
return new WmoPublication(edition !== undefined ? { number, edition } : { number });
|
|
32
|
+
}
|
|
33
|
+
return new WmoStandard(edition !== undefined ? { number, edition } : { number });
|
|
34
|
+
}
|
|
35
|
+
let cachedRuntime;
|
|
36
|
+
export function wmoGrammarImplementation() {
|
|
37
|
+
return {
|
|
38
|
+
parse(input) {
|
|
39
|
+
cachedRuntime ??= PubidRuntime.load("wmo");
|
|
40
|
+
const bound = cachedRuntime.parseAndBind(input);
|
|
41
|
+
if (bound === null || typeof bound !== "object" || Array.isArray(bound)) {
|
|
42
|
+
throw new ParseFailed("wmo: the artifact rejected the input", 0);
|
|
43
|
+
}
|
|
44
|
+
return buildWmo(bound);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
2
|
+
/**
|
|
3
|
+
* The wmo identifier model — lib/pubid/wmo/identifier.rb plus its
|
|
4
|
+
* Identifiers::* leaves. Registration lives HERE (parg-free) so the
|
|
5
|
+
* worker manifest (src/flavors/register-types.ts) can import it without
|
|
6
|
+
* reaching the artifact runtime; the parse entry (./index.js) is the
|
|
7
|
+
* parg-backed half.
|
|
8
|
+
*
|
|
9
|
+
* Two series share the flavor (pubid#763):
|
|
10
|
+
*
|
|
11
|
+
* WMO-No. <number>[, <year> edition] the WMO-No. publication
|
|
12
|
+
* series; editions are calendar
|
|
13
|
+
* years
|
|
14
|
+
* S-<number>[ <x.y.z>] the WMO-published S-100 product
|
|
15
|
+
* specifications; editions are
|
|
16
|
+
* dotted x.y.z (the IHO lexical
|
|
17
|
+
* form, WMO as the assigning
|
|
18
|
+
* authority - the S-201-of-IALA
|
|
19
|
+
* ruling)
|
|
20
|
+
* S-<number> [Annex|ANNEX] [<letter>] [<x.y.z>] annex wrapper
|
|
21
|
+
*
|
|
22
|
+
* The edition is ONE string attribute carrying a type-driven face:
|
|
23
|
+
* "2025" on a Publication, "1.2.1" on a Standard or Annex. The
|
|
24
|
+
* renderer and the MRN URN generator key the face off the type.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* The MRN URN generator (lib/pubid/wmo/urn_generator.rb) — the WMO
|
|
28
|
+
* assigning authority of the IANA-registered mrn namespace, following
|
|
29
|
+
* the IALA pattern (pubid#763 proposed form):
|
|
30
|
+
*
|
|
31
|
+
* urn:mrn:wmo:pub:wmo-<number>[:ed<year>] the WMO-No. series
|
|
32
|
+
* urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
|
|
33
|
+
* urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
|
|
34
|
+
*/
|
|
35
|
+
declare class WmoUrnGenerator {
|
|
36
|
+
private readonly identifier;
|
|
37
|
+
constructor(identifier: WmoIdentifier);
|
|
38
|
+
generate(): string;
|
|
39
|
+
}
|
|
40
|
+
/** The base WMO identifier (Pubid::Wmo::Identifier). */
|
|
41
|
+
export declare class WmoIdentifier extends BaseIdentifier {
|
|
42
|
+
static polymorphicName: string;
|
|
43
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
44
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
45
|
+
static urnGenerator: typeof WmoUrnGenerator;
|
|
46
|
+
readonly number: string | undefined;
|
|
47
|
+
readonly edition: string | undefined;
|
|
48
|
+
readonly publisher: string | undefined;
|
|
49
|
+
/** The edition is a plain string (the string-edition flavors precede
|
|
50
|
+
* this); the base mr_edition reads edition.number of a
|
|
51
|
+
* Components::Edition, which would crash on the string. */
|
|
52
|
+
mrEdition(): string | undefined;
|
|
53
|
+
/** "WMO-No." and the S-number are designations, not publisher tokens:
|
|
54
|
+
* the canonical faces carry no publisher prefix. */
|
|
55
|
+
render(): string;
|
|
56
|
+
}
|
|
57
|
+
/** Identifiers::Publication — the WMO-No. series. */
|
|
58
|
+
export declare class WmoPublication extends WmoIdentifier {
|
|
59
|
+
static polymorphicName: string;
|
|
60
|
+
render(): string;
|
|
61
|
+
}
|
|
62
|
+
/** Identifiers::Standard — the WMO-published S-100 specifications. */
|
|
63
|
+
export declare class WmoStandard extends WmoIdentifier {
|
|
64
|
+
static polymorphicName: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Identifiers::Annex — an annex to a WMO-published S-100 product
|
|
68
|
+
* specification: "S-411 Annex A" (the DCEG docidentifier). The marker
|
|
69
|
+
* case is preserved (Annex vs ANNEX) for round-trip fidelity; the
|
|
70
|
+
* optional edition applies to the annex itself, not the base.
|
|
71
|
+
*/
|
|
72
|
+
export declare class WmoAnnex extends WmoIdentifier {
|
|
73
|
+
static polymorphicName: string;
|
|
74
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
75
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
76
|
+
readonly base: WmoIdentifier | undefined;
|
|
77
|
+
readonly annex_form: string | undefined;
|
|
78
|
+
readonly letter: string | undefined;
|
|
79
|
+
readonly edition: string | undefined;
|
|
80
|
+
render(): string;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { BaseIdentifier, registerType } from "../../model/identifier.js";
|
|
2
|
+
import { keyValue, extendAttributes } from "../../model/attribute.js";
|
|
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.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The MRN URN generator (lib/pubid/wmo/urn_generator.rb) — the WMO
|
|
29
|
+
* assigning authority of the IANA-registered mrn namespace, following
|
|
30
|
+
* the IALA pattern (pubid#763 proposed form):
|
|
31
|
+
*
|
|
32
|
+
* urn:mrn:wmo:pub:wmo-<number>[:ed<year>] the WMO-No. series
|
|
33
|
+
* urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
|
|
34
|
+
* urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
|
|
35
|
+
*/
|
|
36
|
+
class WmoUrnGenerator {
|
|
37
|
+
identifier;
|
|
38
|
+
constructor(identifier) {
|
|
39
|
+
this.identifier = identifier;
|
|
40
|
+
}
|
|
41
|
+
generate() {
|
|
42
|
+
const id = this.identifier;
|
|
43
|
+
if (id instanceof WmoAnnex) {
|
|
44
|
+
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
|
+
parts.push(id.letter !== undefined ? `annex-${id.letter.toLowerCase()}` : "annex");
|
|
48
|
+
if (id.edition !== undefined)
|
|
49
|
+
parts.push(`ed${id.edition}`);
|
|
50
|
+
return parts.join(":");
|
|
51
|
+
}
|
|
52
|
+
// The WMO-No. series codes as "wmo-<number>"; the S-100 specs keep
|
|
53
|
+
// their lexical form lowercased ("s-411").
|
|
54
|
+
const code = id instanceof WmoPublication
|
|
55
|
+
? `wmo-${id.number ?? ""}`
|
|
56
|
+
: `s-${id.number ?? ""}`;
|
|
57
|
+
const parts = ["urn:mrn:wmo:pub", code];
|
|
58
|
+
if (id.edition !== undefined)
|
|
59
|
+
parts.push(`ed${id.edition}`);
|
|
60
|
+
return parts.join(":");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** The base WMO identifier (Pubid::Wmo::Identifier). */
|
|
64
|
+
export class WmoIdentifier extends BaseIdentifier {
|
|
65
|
+
static polymorphicName = "pubid:wmo:identifier";
|
|
66
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
67
|
+
publisher: { type: "string", default: "WMO" },
|
|
68
|
+
number: { type: "string" },
|
|
69
|
+
// One edition column, type-driven face.
|
|
70
|
+
edition: { type: "string" },
|
|
71
|
+
});
|
|
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" });
|
|
75
|
+
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. */
|
|
79
|
+
mrEdition() {
|
|
80
|
+
return this.edition === undefined ? undefined : `ed${this.edition}`;
|
|
81
|
+
}
|
|
82
|
+
/** "WMO-No." and the S-number are designations, not publisher tokens:
|
|
83
|
+
* the canonical faces carry no publisher prefix. */
|
|
84
|
+
render() {
|
|
85
|
+
return `S-${this.number ?? ""}` +
|
|
86
|
+
(this.edition !== undefined ? ` ${this.edition}` : "");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Identifiers::Publication — the WMO-No. series. */
|
|
90
|
+
export class WmoPublication extends WmoIdentifier {
|
|
91
|
+
static polymorphicName = "pubid:wmo:publication";
|
|
92
|
+
render() {
|
|
93
|
+
let rendered = `WMO-No. ${this.number ?? ""}`;
|
|
94
|
+
if (this.edition !== undefined)
|
|
95
|
+
rendered += `, ${this.edition} edition`;
|
|
96
|
+
return rendered;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Identifiers::Standard — the WMO-published S-100 specifications. */
|
|
100
|
+
export class WmoStandard extends WmoIdentifier {
|
|
101
|
+
static polymorphicName = "pubid:wmo:standard";
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Identifiers::Annex — an annex to a WMO-published S-100 product
|
|
105
|
+
* specification: "S-411 Annex A" (the DCEG docidentifier). The marker
|
|
106
|
+
* case is preserved (Annex vs ANNEX) for round-trip fidelity; the
|
|
107
|
+
* optional edition applies to the annex itself, not the base.
|
|
108
|
+
*/
|
|
109
|
+
export class WmoAnnex extends WmoIdentifier {
|
|
110
|
+
static polymorphicName = "pubid:wmo:annex";
|
|
111
|
+
static attributes = extendAttributes(WmoIdentifier, {
|
|
112
|
+
// The specification this annex supplements. Always present;
|
|
113
|
+
// carries the S-number (e.g. S-411).
|
|
114
|
+
base: { type: WmoIdentifier },
|
|
115
|
+
// "Annex" or "ANNEX" — preserved verbatim for exact round-trip.
|
|
116
|
+
annex_form: { type: "string" },
|
|
117
|
+
// "A", "B", … or undefined for the bare form.
|
|
118
|
+
letter: { type: "string" },
|
|
119
|
+
});
|
|
120
|
+
static mappings = keyValue(...WmoIdentifier.mappings, { wire: "base", to: "base" }, { wire: "annex_form", to: "annex_form" }, { wire: "letter", to: "letter" });
|
|
121
|
+
render() {
|
|
122
|
+
let rendered = `S-${this.base?.number ?? ""} ${this.annex_form ?? ""}`;
|
|
123
|
+
if (this.letter !== undefined)
|
|
124
|
+
rendered += ` ${this.letter}`;
|
|
125
|
+
if (this.edition !== undefined)
|
|
126
|
+
rendered += ` ${this.edition}`;
|
|
127
|
+
return rendered;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// The WMO_TYPE_MAP role: the base plus the three concrete leaves (the
|
|
131
|
+
// schema's pubid:wmo:{identifier,publication,standard,annex}).
|
|
132
|
+
registerType(WmoIdentifier);
|
|
133
|
+
registerType(WmoPublication);
|
|
134
|
+
registerType(WmoStandard);
|
|
135
|
+
registerType(WmoAnnex);
|
|
@@ -12,6 +12,7 @@ export const ansiSchema = define("ansi", (s) => {
|
|
|
12
12
|
s.atom("type.abbr", "type");
|
|
13
13
|
s.atom("part", "part");
|
|
14
14
|
s.atom("subpart", "subpart");
|
|
15
|
+
s.atom("revision", "rev");
|
|
15
16
|
s.atom("year", "year");
|
|
16
17
|
s.atom("date.year", "dateyear");
|
|
17
18
|
s.atom("date.month", "datemonth");
|
|
@@ -24,6 +25,8 @@ export const ansiSchema = define("ansi", (s) => {
|
|
|
24
25
|
s.atom("locality.value", "loc");
|
|
25
26
|
s.facet("languages.*.original_code", "langsrc");
|
|
26
27
|
s.facet("edition.original_text", "edsrc");
|
|
28
|
+
s.facet("date_separator", "datesep");
|
|
29
|
+
s.facet("number_separator", "numsep");
|
|
27
30
|
s.type("pubid:ansi:standard", "std");
|
|
28
31
|
s.type("pubid:ansi:american-national-standard", "ans");
|
|
29
32
|
s.type("pubid:ansi:identifier", "id");
|
|
@@ -9,6 +9,7 @@ import { define } from "../index.js";
|
|
|
9
9
|
export const euSchema = define("eu", (s) => {
|
|
10
10
|
s.atom("family", "family");
|
|
11
11
|
s.facet("number_first", "numberfirst", "bool");
|
|
12
|
+
s.facet("subtype", "subtype");
|
|
12
13
|
s.type("pubid:eu:regulation", "reg", { core: ["year", "number"] });
|
|
13
14
|
s.type("pubid:eu:directive", "dir", { core: ["year", "number"] });
|
|
14
15
|
s.type("pubid:eu:decision", "dec", { core: ["year", "number"] });
|
|
@@ -53,6 +53,7 @@ import { saeSchema } from "./sae.js";
|
|
|
53
53
|
import { tgppSchema } from "./tgpp.js";
|
|
54
54
|
import { unSchema } from "./un.js";
|
|
55
55
|
import { w3cSchema } from "./w3c.js";
|
|
56
|
+
import { wmoSchema } from "./wmo.js";
|
|
56
57
|
import { xsfSchema } from "./xsf.js";
|
|
57
58
|
/** All flavor schemas, in the ruby registry order (alphabetical by module). */
|
|
58
59
|
export const PUBID_URN_SCHEMAS = [
|
|
@@ -105,5 +106,6 @@ export const PUBID_URN_SCHEMAS = [
|
|
|
105
106
|
tgppSchema,
|
|
106
107
|
unSchema,
|
|
107
108
|
w3cSchema,
|
|
109
|
+
wmoSchema,
|
|
108
110
|
xsfSchema,
|
|
109
111
|
];
|
|
@@ -43,6 +43,7 @@ export const ituSchema = define("itu", (s) => {
|
|
|
43
43
|
s.facet("slash_joined", "slashjoined", "bool");
|
|
44
44
|
s.type("pubid:itu:recommendation", "rec");
|
|
45
45
|
s.type("pubid:itu:report", "rpt");
|
|
46
|
+
s.type("pubid:itu:resolution", "res");
|
|
46
47
|
s.type("pubid:itu:combined-identifier", "comb");
|
|
47
48
|
s.type("pubid:itu:question", "q");
|
|
48
49
|
s.type("pubid:itu:handbook", "hb");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pubid-scheme URN schema of WMO — the transcription
|
|
3
|
+
* of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
|
|
4
|
+
* #670; design in docs/URN-SCHEMES.adoc). GENERATED by
|
|
5
|
+
* scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
|
|
6
|
+
* schema and regenerate, never this table by hand.
|
|
7
|
+
*/
|
|
8
|
+
export declare const wmoSchema: import("../schema.js").FlavorSchema;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pubid-scheme URN schema of WMO — the transcription
|
|
3
|
+
* of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
|
|
4
|
+
* #670; design in docs/URN-SCHEMES.adoc). GENERATED by
|
|
5
|
+
* scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
|
|
6
|
+
* schema and regenerate, never this table by hand.
|
|
7
|
+
*/
|
|
8
|
+
import { define } from "../index.js";
|
|
9
|
+
export const wmoSchema = define("wmo", (s) => {
|
|
10
|
+
s.atom("edition", "ed");
|
|
11
|
+
s.atom("annex_form", "annexform");
|
|
12
|
+
s.atom("letter", "letter");
|
|
13
|
+
s.type("pubid:wmo:publication", "pub");
|
|
14
|
+
s.type("pubid:wmo:standard", "std");
|
|
15
|
+
s.type("pubid:wmo:annex", "annex");
|
|
16
|
+
});
|
package/dist/urn/parsers.js
CHANGED
|
@@ -732,6 +732,82 @@ export const URN_PARSERS = {
|
|
|
732
732
|
return parse(text);
|
|
733
733
|
},
|
|
734
734
|
},
|
|
735
|
+
// lib/pubid/wmo/urn_parser.rb — the MRN segments: a "wmo-<digits>" code
|
|
736
|
+
// rebuilds the compact year edition (the text parser normalizes to the
|
|
737
|
+
// comma face); an "s-<digits>" code takes a caseless annex segment (at
|
|
738
|
+
// most one, rebuilt as the attested "Annex" face) then the dotted
|
|
739
|
+
// edition. Every non-annex segment must be "ed" + the shape the code
|
|
740
|
+
// declares (a year for a publication, dotted for a standard) — per the
|
|
741
|
+
// ISO urn_parser strictness.
|
|
742
|
+
wmo: {
|
|
743
|
+
prefix: "urn:mrn:wmo:pub:",
|
|
744
|
+
reconstruct(body, parse) {
|
|
745
|
+
const parts = splitParts(body);
|
|
746
|
+
const code = parts[0];
|
|
747
|
+
if (code === undefined) {
|
|
748
|
+
throw new Error(`Invalid WMO URN code segment: ${JSON.stringify(code)}`);
|
|
749
|
+
}
|
|
750
|
+
const segments = parts.slice(1);
|
|
751
|
+
const editionValue = (seg, shape) => {
|
|
752
|
+
if (!/^ed/i.test(seg)) {
|
|
753
|
+
throw new Error(`Invalid WMO URN segment: ${JSON.stringify(seg)}`);
|
|
754
|
+
}
|
|
755
|
+
const edition = seg.replace(/^ed/i, "");
|
|
756
|
+
if (!shape.test(edition)) {
|
|
757
|
+
throw new Error(`Invalid WMO URN segment: ${JSON.stringify(seg)}`);
|
|
758
|
+
}
|
|
759
|
+
return edition;
|
|
760
|
+
};
|
|
761
|
+
const publication = /^wmo-(\d+)$/i.exec(code);
|
|
762
|
+
if (publication !== null) {
|
|
763
|
+
let edition;
|
|
764
|
+
for (const seg of segments) {
|
|
765
|
+
if (edition !== undefined) {
|
|
766
|
+
throw new Error(`Invalid WMO URN segment (duplicate edition): ${JSON.stringify(seg)}`);
|
|
767
|
+
}
|
|
768
|
+
edition = editionValue(seg, /^\d{4}$/);
|
|
769
|
+
}
|
|
770
|
+
let text = `WMO-No. ${publication[1]}`;
|
|
771
|
+
if (edition !== undefined)
|
|
772
|
+
text += `:ed${edition}`;
|
|
773
|
+
return parse(text);
|
|
774
|
+
}
|
|
775
|
+
const standard = /^s-(\d+)$/i.exec(code);
|
|
776
|
+
if (standard !== null) {
|
|
777
|
+
let annexLetter;
|
|
778
|
+
let edition;
|
|
779
|
+
let hasAnnex = false;
|
|
780
|
+
for (const seg of segments) {
|
|
781
|
+
const annex = /^annex(-([a-z]))?$/i.exec(seg);
|
|
782
|
+
if (annex !== null) {
|
|
783
|
+
if (hasAnnex) {
|
|
784
|
+
throw new Error(`Invalid WMO URN segment (duplicate annex): ${JSON.stringify(seg)}`);
|
|
785
|
+
}
|
|
786
|
+
hasAnnex = true;
|
|
787
|
+
annexLetter = annex[2]?.toUpperCase();
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
if (edition !== undefined) {
|
|
791
|
+
throw new Error(`Invalid WMO URN segment: ${JSON.stringify(seg)}`);
|
|
792
|
+
}
|
|
793
|
+
edition = editionValue(seg, /^\d+(\.\d+)+$/);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
// The annex segment is caseless in the MRN, so the rebuild picks
|
|
797
|
+
// the attested WMO face "Annex" (the DCEG docidentifier); the
|
|
798
|
+
// uppercase "ANNEX" form stays a parse-only human alias.
|
|
799
|
+
let text = `S-${standard[1]}`;
|
|
800
|
+
if (hasAnnex)
|
|
801
|
+
text += " Annex";
|
|
802
|
+
if (annexLetter !== undefined)
|
|
803
|
+
text += ` ${annexLetter}`;
|
|
804
|
+
if (edition !== undefined)
|
|
805
|
+
text += ` ${edition}`;
|
|
806
|
+
return parse(text);
|
|
807
|
+
}
|
|
808
|
+
throw new Error(`Invalid WMO URN code segment: ${JSON.stringify(code)}`);
|
|
809
|
+
},
|
|
810
|
+
},
|
|
735
811
|
};
|
|
736
812
|
export function lookupUrnParser(flavor) {
|
|
737
813
|
return URN_PARSERS[flavor];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.60",
|
|
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",
|