@pubid/pubid 0.1.3 → 0.1.4
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/artifact/corpus.json.gz +0 -0
- package/dist/conformance/cli.js +5 -1
- package/dist/flavors/amca/grammar.d.ts +4 -0
- package/dist/flavors/amca/grammar.js +87 -0
- package/dist/flavors/amca/index.d.ts +4 -0
- package/dist/flavors/amca/index.js +76 -0
- package/dist/flavors/amca/model.d.ts +29 -0
- package/dist/flavors/amca/model.js +146 -0
- package/dist/flavors/ansi/index.d.ts +24 -0
- package/dist/flavors/ansi/index.js +147 -0
- package/dist/flavors/api/grammar.d.ts +4 -0
- package/dist/flavors/api/grammar.js +79 -0
- package/dist/flavors/api/index.d.ts +4 -0
- package/dist/flavors/api/index.js +71 -0
- package/dist/flavors/api/model.d.ts +27 -0
- package/dist/flavors/api/model.js +114 -0
- package/dist/flavors/ashrae/grammar.d.ts +2 -0
- package/dist/flavors/ashrae/grammar.js +667 -0
- package/dist/flavors/ashrae/index.d.ts +4 -0
- package/dist/flavors/ashrae/index.js +306 -0
- package/dist/flavors/ashrae/model.d.ts +87 -0
- package/dist/flavors/ashrae/model.js +335 -0
- package/dist/flavors/ashrae/preprocessor.d.ts +7 -0
- package/dist/flavors/ashrae/preprocessor.js +44 -0
- package/dist/flavors/asme/grammar.d.ts +2 -0
- package/dist/flavors/asme/grammar.js +200 -0
- package/dist/flavors/asme/index.d.ts +4 -0
- package/dist/flavors/asme/index.js +138 -0
- package/dist/flavors/asme/model.d.ts +34 -0
- package/dist/flavors/asme/model.js +123 -0
- package/dist/flavors/astm/grammar.d.ts +2 -0
- package/dist/flavors/astm/grammar.js +110 -0
- package/dist/flavors/astm/index.d.ts +2 -0
- package/dist/flavors/astm/index.js +127 -0
- package/dist/flavors/astm/model.d.ts +42 -0
- package/dist/flavors/astm/model.js +263 -0
- package/dist/flavors/bipm/index.d.ts +30 -0
- package/dist/flavors/bipm/index.js +434 -0
- package/dist/flavors/bsi/grammar.d.ts +4 -0
- package/dist/flavors/bsi/grammar.js +535 -0
- package/dist/flavors/bsi/index.d.ts +4 -0
- package/dist/flavors/bsi/index.js +941 -0
- package/dist/flavors/bsi/model.d.ts +127 -0
- package/dist/flavors/bsi/model.js +863 -0
- package/dist/flavors/calconnect/index.d.ts +21 -0
- package/dist/flavors/calconnect/index.js +113 -0
- package/dist/flavors/cen_cenelec/grammar.d.ts +4 -0
- package/dist/flavors/cen_cenelec/grammar.js +107 -0
- package/dist/flavors/cen_cenelec/index.d.ts +5 -0
- package/dist/flavors/cen_cenelec/index.js +263 -0
- package/dist/flavors/cen_cenelec/model.d.ts +45 -0
- package/dist/flavors/cen_cenelec/model.js +490 -0
- package/dist/flavors/cie/grammar.d.ts +5 -0
- package/dist/flavors/cie/grammar.js +127 -0
- package/dist/flavors/cie/index.d.ts +2 -0
- package/dist/flavors/cie/index.js +311 -0
- package/dist/flavors/cie/model.d.ts +122 -0
- package/dist/flavors/cie/model.js +464 -0
- package/dist/flavors/csa/grammar.d.ts +6 -0
- package/dist/flavors/csa/grammar.js +239 -0
- package/dist/flavors/csa/index.d.ts +2 -0
- package/dist/flavors/csa/index.js +634 -0
- package/dist/flavors/csa/model.d.ts +33 -0
- package/dist/flavors/csa/model.js +505 -0
- package/dist/flavors/doi/index.d.ts +13 -0
- package/dist/flavors/doi/index.js +65 -0
- package/dist/flavors/easc/index.d.ts +4 -0
- package/dist/flavors/easc/index.js +107 -0
- package/dist/flavors/ecma/index.d.ts +4 -0
- package/dist/flavors/ecma/index.js +117 -0
- package/dist/flavors/etsi/index.d.ts +14 -0
- package/dist/flavors/etsi/index.js +307 -0
- package/dist/flavors/evs/grammar.d.ts +2 -0
- package/dist/flavors/evs/grammar.js +22 -0
- package/dist/flavors/evs/index.d.ts +2 -0
- package/dist/flavors/evs/index.js +24 -0
- package/dist/flavors/evs/model.d.ts +19 -0
- package/dist/flavors/evs/model.js +36 -0
- package/dist/flavors/gb/index.d.ts +24 -0
- package/dist/flavors/gb/index.js +111 -0
- package/dist/flavors/gost/grammar.d.ts +2 -0
- package/dist/flavors/gost/grammar.js +46 -0
- package/dist/flavors/gost/index.d.ts +2 -0
- package/dist/flavors/gost/index.js +165 -0
- package/dist/flavors/gost/model.d.ts +61 -0
- package/dist/flavors/gost/model.js +147 -0
- package/dist/flavors/gost/prefix_routes.d.ts +15 -0
- package/dist/flavors/gost/prefix_routes.js +192 -0
- package/dist/flavors/iala/index.d.ts +32 -0
- package/dist/flavors/iala/index.js +300 -0
- package/dist/flavors/iana/index.d.ts +19 -0
- package/dist/flavors/iana/index.js +71 -0
- package/dist/flavors/idf/grammar.d.ts +2 -0
- package/dist/flavors/idf/grammar.js +71 -0
- package/dist/flavors/idf/index.d.ts +2 -0
- package/dist/flavors/idf/index.js +100 -0
- package/dist/flavors/idf/model.d.ts +54 -0
- package/dist/flavors/idf/model.js +359 -0
- package/dist/flavors/iec/grammar.d.ts +3 -0
- package/dist/flavors/iec/grammar.js +187 -0
- package/dist/flavors/iec/index.d.ts +4 -0
- package/dist/flavors/iec/index.js +507 -0
- package/dist/flavors/iec/model.d.ts +54 -0
- package/dist/flavors/iec/model.js +437 -0
- package/dist/flavors/ieee/grammar.d.ts +2 -0
- package/dist/flavors/ieee/grammar.js +626 -0
- package/dist/flavors/ieee/index.d.ts +3 -0
- package/dist/flavors/ieee/index.js +1186 -0
- package/dist/flavors/ieee/model.d.ts +142 -0
- package/dist/flavors/ieee/model.js +1148 -0
- package/dist/flavors/ieee/preprocessor.d.ts +8 -0
- package/dist/flavors/ieee/preprocessor.js +410 -0
- package/dist/flavors/ieee/update_codes.d.ts +8 -0
- package/dist/flavors/ieee/update_codes.js +191 -0
- package/dist/flavors/ietf/index.d.ts +30 -0
- package/dist/flavors/ietf/index.js +151 -0
- package/dist/flavors/iho/index.d.ts +4 -0
- package/dist/flavors/iho/index.js +126 -0
- package/dist/flavors/index.d.ts +9 -0
- package/dist/flavors/index.js +136 -0
- package/dist/flavors/isbn/index.d.ts +13 -0
- package/dist/flavors/isbn/index.js +97 -0
- package/dist/flavors/iso/grammar.d.ts +2 -0
- package/dist/flavors/iso/grammar.js +207 -0
- package/dist/flavors/iso/index.d.ts +2 -0
- package/dist/flavors/iso/index.js +343 -0
- package/dist/flavors/iso/model.d.ts +159 -0
- package/dist/flavors/iso/model.js +802 -0
- package/dist/flavors/iso/stages.generated.d.ts +13 -0
- package/dist/flavors/iso/stages.generated.js +391 -0
- package/dist/flavors/itu/grammar.d.ts +4 -0
- package/dist/flavors/itu/grammar.js +205 -0
- package/dist/flavors/itu/index.d.ts +2 -0
- package/dist/flavors/itu/index.js +224 -0
- package/dist/flavors/itu/model.d.ts +184 -0
- package/dist/flavors/itu/model.js +599 -0
- package/dist/flavors/jcgm/index.d.ts +7 -0
- package/dist/flavors/jcgm/index.js +300 -0
- package/dist/flavors/jis/index.d.ts +4 -0
- package/dist/flavors/jis/index.js +267 -0
- package/dist/flavors/nist/grammar.d.ts +2 -0
- package/dist/flavors/nist/grammar.js +287 -0
- package/dist/flavors/nist/index.d.ts +2 -0
- package/dist/flavors/nist/index.js +1244 -0
- package/dist/flavors/nist/model.d.ts +155 -0
- package/dist/flavors/nist/model.js +823 -0
- package/dist/flavors/nist/preprocessor.d.ts +11 -0
- package/dist/flavors/nist/preprocessor.js +281 -0
- package/dist/flavors/oasis/index.d.ts +23 -0
- package/dist/flavors/oasis/index.js +110 -0
- package/dist/flavors/ogc/index.d.ts +20 -0
- package/dist/flavors/ogc/index.js +75 -0
- package/dist/flavors/oiml/grammar.d.ts +2 -0
- package/dist/flavors/oiml/grammar.js +180 -0
- package/dist/flavors/oiml/implementation.d.ts +9 -0
- package/dist/flavors/oiml/implementation.js +16 -0
- package/dist/flavors/oiml/model.d.ts +4 -0
- package/dist/flavors/oiml/model.js +462 -0
- package/dist/flavors/omg/index.d.ts +14 -0
- package/dist/flavors/omg/index.js +73 -0
- package/dist/flavors/plateau/index.d.ts +4 -0
- package/dist/flavors/plateau/index.js +97 -0
- package/dist/flavors/tgpp/index.d.ts +4 -0
- package/dist/flavors/tgpp/index.js +122 -0
- package/dist/flavors/un/index.d.ts +13 -0
- package/dist/flavors/un/index.js +90 -0
- package/dist/flavors/w3c/index.d.ts +14 -0
- package/dist/flavors/w3c/index.js +148 -0
- package/dist/flavors/xsf/index.d.ts +18 -0
- package/dist/flavors/xsf/index.js +65 -0
- package/dist/grammar/engine.d.ts +78 -0
- package/dist/grammar/engine.js +351 -0
- package/dist/model/attribute.d.ts +54 -0
- package/dist/model/attribute.js +53 -0
- package/dist/model/builder.d.ts +39 -0
- package/dist/model/builder.js +124 -0
- package/dist/model/component.d.ts +70 -0
- package/dist/model/component.js +170 -0
- package/dist/model/identifier.d.ts +83 -0
- package/dist/model/identifier.js +270 -0
- package/dist/model/urn-generator.d.ts +27 -0
- package/dist/model/urn-generator.js +91 -0
- package/package.json +1 -1
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { BaseIdentifier, registerType } from "../../model/identifier.js";
|
|
2
|
+
import { extendAttributes, keyValue } from "../../model/attribute.js";
|
|
3
|
+
import { Language, PubidDate, Iteration } from "../../model/component.js";
|
|
4
|
+
const TS = (code, stageCode, typeCode, abbr, harmonized, tokens) => ({ code, stageCode, typeCode, abbr, harmonized, tokens });
|
|
5
|
+
export const TYPED_STAGES = [
|
|
6
|
+
TS("is", "published", "is", ""),
|
|
7
|
+
TS("tr", "published", "tr", "TR"),
|
|
8
|
+
TS("ts", "published", "ts", "TS"),
|
|
9
|
+
TS("pas", "published", "pas", "PAS"),
|
|
10
|
+
TS("srd", "published", "srd", "SRD"),
|
|
11
|
+
TS("od", "published", "od", "OD"),
|
|
12
|
+
TS("guide", "published", "guide", "GUIDE", undefined, ["GUIDE", "Guide"]),
|
|
13
|
+
TS("ish", "published", "ish", "ISH"),
|
|
14
|
+
TS("frag", "published", "frag", "FRAG"),
|
|
15
|
+
TS("trf", "published", "trf", "TRF"),
|
|
16
|
+
TS("amd", "published", "amd", "AMD"),
|
|
17
|
+
TS("cor", "published", "cor", "COR"),
|
|
18
|
+
TS("np", "np", "is", "NP", "10.20"),
|
|
19
|
+
TS("pnw", "pnw", "is", "PNW", "10.20"),
|
|
20
|
+
TS("pwi", "pwi", "is", "PWI", "00.00"),
|
|
21
|
+
TS("anw", "anw", "is", "ANW"),
|
|
22
|
+
TS("wd", "wd", "is", "WD"),
|
|
23
|
+
TS("cd", "cd", "is", "CD", "30.20"),
|
|
24
|
+
TS("cdv", "cdv", "is", "CDV", "40.20"),
|
|
25
|
+
TS("fdis", "fdis", "is", "FDIS", "50.00"),
|
|
26
|
+
TS("prf", "prf", "is", "PRF"),
|
|
27
|
+
TS("bpub", "bpub", "is", "BPUB"),
|
|
28
|
+
TS("ppub", "ppub", "is", "PPUB"),
|
|
29
|
+
TS("dtr", "dtr", "tr", "DTR"),
|
|
30
|
+
TS("adtr", "adtr", "tr", "ADTR"),
|
|
31
|
+
TS("cdtr", "cdtr", "tr", "CDTR"),
|
|
32
|
+
TS("ndtr", "ndtr", "tr", "NDTR"),
|
|
33
|
+
TS("dts", "dts", "ts", "DTS"),
|
|
34
|
+
TS("adts", "adts", "ts", "ADTS"),
|
|
35
|
+
TS("cdts", "cdts", "ts", "CDTS"),
|
|
36
|
+
TS("ndts", "ndts", "ts", "NDTS"),
|
|
37
|
+
TS("dpas", "dpas", "pas", "DPAS"),
|
|
38
|
+
TS("cdpas", "cdpas", "pas", "CDPAS"),
|
|
39
|
+
TS("dam", "dam", "amd", "DAM"),
|
|
40
|
+
TS("fdam", "fdam", "amd", "FDAM"),
|
|
41
|
+
TS("dcor", "dcor", "cor", "DCOR"),
|
|
42
|
+
TS("fdcor", "fdcor", "cor", "FDCOR"),
|
|
43
|
+
TS("cdish", "cdish", "ish", "CDISH"),
|
|
44
|
+
TS("dish", "dish", "ish", "DISH"),
|
|
45
|
+
];
|
|
46
|
+
export function stageTokens() {
|
|
47
|
+
return TYPED_STAGES.flatMap((t) => t.tokens ?? [t.abbr]);
|
|
48
|
+
}
|
|
49
|
+
export function locateStage(token) {
|
|
50
|
+
const needle = token.trim();
|
|
51
|
+
return (TYPED_STAGES.find((t) => (t.tokens ?? [t.abbr]).includes(needle)) ??
|
|
52
|
+
TYPED_STAGES.find((t) => t.abbr.toUpperCase() === needle.toUpperCase()));
|
|
53
|
+
}
|
|
54
|
+
const TYPE_NAMES = {
|
|
55
|
+
is: "international-standard",
|
|
56
|
+
tr: "technical-report",
|
|
57
|
+
ts: "technical-specification",
|
|
58
|
+
pas: "publicly-available-specification",
|
|
59
|
+
srd: "systems-reference-document",
|
|
60
|
+
od: "operational-document",
|
|
61
|
+
guide: "guide",
|
|
62
|
+
ish: "interpretation-sheet",
|
|
63
|
+
frag: "fragment-identifier",
|
|
64
|
+
trf: "test-report-form",
|
|
65
|
+
amd: "amendment",
|
|
66
|
+
cor: "corrigendum",
|
|
67
|
+
tec: undefined,
|
|
68
|
+
wp: undefined,
|
|
69
|
+
sttr: undefined,
|
|
70
|
+
};
|
|
71
|
+
// The shared single-document attribute table (SingleIdentifier seam).
|
|
72
|
+
const SINGLE_ATTRS = {
|
|
73
|
+
number: { type: "string" },
|
|
74
|
+
part: { type: "string" },
|
|
75
|
+
subpart: { type: "string" },
|
|
76
|
+
date: { type: PubidDate },
|
|
77
|
+
undated: { type: "boolean", default: false },
|
|
78
|
+
edition: { type: "string" },
|
|
79
|
+
languages: { type: Language, collection: true, initializeEmpty: true },
|
|
80
|
+
publisher: { type: "string", default: "IEC" },
|
|
81
|
+
copublishers: { type: "string", collection: true, initializeEmpty: true },
|
|
82
|
+
stage: { type: "string" },
|
|
83
|
+
stage_iteration: { type: Iteration },
|
|
84
|
+
all_parts: { type: "boolean", default: false },
|
|
85
|
+
database: { type: "boolean", default: false },
|
|
86
|
+
};
|
|
87
|
+
// The Identifier-level whitelist: date flat, publisher only when it is
|
|
88
|
+
// not the IEC default, copublishers as a body list, stage only for drafts.
|
|
89
|
+
const BASE_MAPPINGS = keyValue({ wire: "stage_iteration", to: "stage_iteration" }, {
|
|
90
|
+
wire: "year",
|
|
91
|
+
to: "date",
|
|
92
|
+
toWire: (m) => m["date"]?.year,
|
|
93
|
+
fromWire: (h) => h["year"] === undefined || h["year"] === null
|
|
94
|
+
? undefined
|
|
95
|
+
: new PubidDate({
|
|
96
|
+
year: String(h["year"]),
|
|
97
|
+
month: h["month"],
|
|
98
|
+
day: h["day"],
|
|
99
|
+
undated: h["undated"] === true,
|
|
100
|
+
}),
|
|
101
|
+
}, { wire: "month", to: "date", toWire: (m) => m["date"]?.month, fromWire: () => undefined }, { wire: "day", to: "date", toWire: (m) => m["date"]?.day, fromWire: () => undefined }, {
|
|
102
|
+
wire: "undated",
|
|
103
|
+
to: "date",
|
|
104
|
+
toWire: (m) => (m["date"]?.undated ? true : undefined),
|
|
105
|
+
fromWire: (h) => (h["undated"] === true ? new PubidDate({ undated: true }) : undefined),
|
|
106
|
+
}, { wire: "edition", to: "edition" }, { wire: "languages", to: "languages" }, {
|
|
107
|
+
wire: "publisher",
|
|
108
|
+
to: "publisher",
|
|
109
|
+
toWire: (m) => (m["publisher"] === "IEC" ? undefined : m["publisher"]),
|
|
110
|
+
fromWire: (h) => (h["publisher"] === undefined || h["publisher"] === null ? undefined : String(h["publisher"])),
|
|
111
|
+
}, {
|
|
112
|
+
wire: "copublishers",
|
|
113
|
+
to: "copublishers",
|
|
114
|
+
toWire: (m) => {
|
|
115
|
+
const list = m["copublishers"];
|
|
116
|
+
return list !== undefined && list.length > 0 ? list : undefined;
|
|
117
|
+
},
|
|
118
|
+
fromWire: (h) => (Array.isArray(h["copublishers"]) ? h["copublishers"].map(String) : undefined),
|
|
119
|
+
}, { wire: "stage", to: "stage" }, { wire: "all_parts", to: "all_parts" }, { wire: "database", to: "database" });
|
|
120
|
+
export class IecIdentifier extends BaseIdentifier {
|
|
121
|
+
/** Walk the supplement chain to the base document (BSI's URN
|
|
122
|
+
* generator reaches the root identity of adopted bases). */
|
|
123
|
+
root() {
|
|
124
|
+
const base = this["base"];
|
|
125
|
+
return base instanceof IecIdentifier ? base.root() : this;
|
|
126
|
+
}
|
|
127
|
+
/** The runtime typed stage — never serialized directly. */
|
|
128
|
+
typedStage;
|
|
129
|
+
/** Ruby SingleIdentifier#publisher_portion. */
|
|
130
|
+
publisherPortion() {
|
|
131
|
+
const publishers = this.copublishers.length > 0
|
|
132
|
+
? [this.publisher ?? "IEC", ...this.copublishers]
|
|
133
|
+
: [this.publisher ?? "IEC"];
|
|
134
|
+
let pub = publishers.join("/");
|
|
135
|
+
const abbr = this.typedStage?.abbr ?? "";
|
|
136
|
+
if (abbr !== "")
|
|
137
|
+
pub += ` ${abbr}`;
|
|
138
|
+
return pub;
|
|
139
|
+
}
|
|
140
|
+
/** Ruby SingleIdentifier#number_portion. */
|
|
141
|
+
numberPortion() {
|
|
142
|
+
return [
|
|
143
|
+
this.number !== undefined ? String(this.number) : "",
|
|
144
|
+
this.part !== undefined ? `-${this.part}` : "",
|
|
145
|
+
this.subpart !== undefined ? `-${this.subpart}` : "",
|
|
146
|
+
this.stageIterationValue() !== undefined ? `.${this.stageIterationValue()}` : "",
|
|
147
|
+
this.date !== undefined ? `:${this.date.render()}` : "",
|
|
148
|
+
].join("");
|
|
149
|
+
}
|
|
150
|
+
stageIterationValue() {
|
|
151
|
+
return this.stage_iteration?.string;
|
|
152
|
+
}
|
|
153
|
+
languagePortion() {
|
|
154
|
+
if (this.languages.length === 0)
|
|
155
|
+
return "";
|
|
156
|
+
return `(${this.languages.map((l) => l.code).join(",")})`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function iecSingleClass(kind) {
|
|
160
|
+
const name = TYPE_NAMES[kind];
|
|
161
|
+
if (name === undefined)
|
|
162
|
+
throw new Error(`no type name for ${kind}`);
|
|
163
|
+
class IecSingleIdentifier extends IecIdentifier {
|
|
164
|
+
static polymorphicName = `pubid:iec:${name}`;
|
|
165
|
+
static attributes = extendAttributes(BaseIdentifier, SINGLE_ATTRS);
|
|
166
|
+
// Ruby: number/part/subpart live on the SingleIdentifier key_value seam.
|
|
167
|
+
static mappings = keyValue({ wire: "number", to: "number" }, { wire: "part", to: "part" }, { wire: "subpart", to: "subpart" }, ...BASE_MAPPINGS);
|
|
168
|
+
render() {
|
|
169
|
+
let result = `${this.publisherPortion()} ${this.numberPortion()}`;
|
|
170
|
+
if (this.edition !== undefined)
|
|
171
|
+
result += ` ED${this.edition}`;
|
|
172
|
+
if (this.database === true)
|
|
173
|
+
result += " DB";
|
|
174
|
+
if (this.all_parts === true)
|
|
175
|
+
result += " (all parts)";
|
|
176
|
+
result += this.languagePortion();
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
registerType(IecSingleIdentifier);
|
|
181
|
+
return IecSingleIdentifier;
|
|
182
|
+
}
|
|
183
|
+
/** Working documents: the TC/wd fields are runtime-only (hash is bare). */
|
|
184
|
+
function iecWorkingDocumentClass() {
|
|
185
|
+
class IecWorkingDocument extends IecIdentifier {
|
|
186
|
+
static polymorphicName = "pubid:iec:working-document";
|
|
187
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
188
|
+
...SINGLE_ATTRS,
|
|
189
|
+
wp_stage: { type: "string" },
|
|
190
|
+
wp_type: { type: "string" },
|
|
191
|
+
technical_committee: { type: "string" },
|
|
192
|
+
wd_number: { type: "string" },
|
|
193
|
+
wd_language: { type: "string" },
|
|
194
|
+
wd_stage: { type: "string" },
|
|
195
|
+
});
|
|
196
|
+
static mappings = keyValue({ wire: "number", to: "number" }, { wire: "part", to: "part" }, { wire: "subpart", to: "subpart" }, { wire: "edition", to: "edition" });
|
|
197
|
+
render() {
|
|
198
|
+
if (this.wp_stage !== undefined) {
|
|
199
|
+
const parts = [this.wp_stage];
|
|
200
|
+
if (this.wp_type !== undefined && this.wp_type.trim() !== "") {
|
|
201
|
+
parts.push(` ${this.wp_type.trim()}`);
|
|
202
|
+
}
|
|
203
|
+
if (this.number !== undefined) {
|
|
204
|
+
let numStr = String(this.number);
|
|
205
|
+
if (this.part !== undefined && this.part !== "")
|
|
206
|
+
numStr += `-${this.part}`;
|
|
207
|
+
if (this.subpart !== undefined && this.subpart !== "")
|
|
208
|
+
numStr += `-${this.subpart}`;
|
|
209
|
+
parts.push(` ${numStr}`);
|
|
210
|
+
}
|
|
211
|
+
if (this.edition !== undefined)
|
|
212
|
+
parts.push(` ED${this.edition}`);
|
|
213
|
+
return parts.join("");
|
|
214
|
+
}
|
|
215
|
+
const parts = [];
|
|
216
|
+
if (this.technical_committee !== undefined)
|
|
217
|
+
parts.push(this.technical_committee);
|
|
218
|
+
if (this.wd_number !== undefined) {
|
|
219
|
+
let numPart = this.wd_number;
|
|
220
|
+
if (this.wd_language !== undefined)
|
|
221
|
+
numPart += `(${this.wd_language})`;
|
|
222
|
+
parts.push(numPart);
|
|
223
|
+
}
|
|
224
|
+
if (this.wd_stage !== undefined)
|
|
225
|
+
parts.push(this.wd_stage);
|
|
226
|
+
return parts.join("/");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
registerType(IecWorkingDocument);
|
|
230
|
+
return IecWorkingDocument;
|
|
231
|
+
}
|
|
232
|
+
const yearFromWire = BASE_MAPPINGS.find((x) => x.wire === "year").fromWire;
|
|
233
|
+
/** Test report forms: IECEE/IECQ/CISPR documents with an optional embedded CISPR id. */
|
|
234
|
+
function iecTrfClass() {
|
|
235
|
+
class IecTestReportForm extends IecIdentifier {
|
|
236
|
+
static polymorphicName = "pubid:iec:test-report-form";
|
|
237
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
238
|
+
...SINGLE_ATTRS,
|
|
239
|
+
cispr_number: { type: "string" },
|
|
240
|
+
cispr_part: { type: "string" },
|
|
241
|
+
trf_info: { type: "string" },
|
|
242
|
+
});
|
|
243
|
+
static mappings = keyValue({ wire: "number", to: "number" }, { wire: "part", to: "part" }, { wire: "subpart", to: "subpart" }, { wire: "year", to: "date", toWire: (m) => m["date"]?.year, fromWire: yearFromWire }, { wire: "month", to: "date", toWire: (m) => m["date"]?.month, fromWire: () => undefined }, { wire: "day", to: "date", toWire: (m) => m["date"]?.day, fromWire: () => undefined }, {
|
|
244
|
+
wire: "publisher",
|
|
245
|
+
to: "publisher",
|
|
246
|
+
toWire: (m) => (m["publisher"] === "IEC" ? undefined : m["publisher"]),
|
|
247
|
+
fromWire: (h) => (h["publisher"] === undefined || h["publisher"] === null ? undefined : String(h["publisher"])),
|
|
248
|
+
}, {
|
|
249
|
+
wire: "copublishers",
|
|
250
|
+
to: "copublishers",
|
|
251
|
+
toWire: (m) => {
|
|
252
|
+
const list = m["copublishers"];
|
|
253
|
+
return list !== undefined && list.length > 0 ? list : undefined;
|
|
254
|
+
},
|
|
255
|
+
fromWire: (h) => (Array.isArray(h["copublishers"]) ? h["copublishers"].map(String) : undefined),
|
|
256
|
+
});
|
|
257
|
+
render() {
|
|
258
|
+
let result = this.publisherPortion() + " ";
|
|
259
|
+
if (this.cispr_number !== undefined) {
|
|
260
|
+
let numStr = this.cispr_number;
|
|
261
|
+
if (this.cispr_part !== undefined && this.cispr_part !== "")
|
|
262
|
+
numStr += `-${this.cispr_part}`;
|
|
263
|
+
let cisprStr = `CISPR ${numStr}`;
|
|
264
|
+
if (this.date !== undefined)
|
|
265
|
+
cisprStr += `:${this.date.render()}`;
|
|
266
|
+
result += cisprStr;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
result += this.numberPortion();
|
|
270
|
+
}
|
|
271
|
+
if (this.trf_info !== undefined && this.trf_info !== "")
|
|
272
|
+
result += ` ${this.trf_info}`;
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
registerType(IecTestReportForm);
|
|
277
|
+
return IecTestReportForm;
|
|
278
|
+
}
|
|
279
|
+
/** Supplements: amendment / corrigendum / interpretation sheet. */
|
|
280
|
+
function iecSupplementClass(kind) {
|
|
281
|
+
const notation = kind === "amendment" ? "amd" : kind === "corrigendum" ? "cor" : "ish";
|
|
282
|
+
const abbr = kind === "amendment" ? "AMD" : kind === "corrigendum" ? "COR" : "ISH";
|
|
283
|
+
class IecSupplementIdentifier extends IecIdentifier {
|
|
284
|
+
static polymorphicName = `pubid:iec:${kind}`;
|
|
285
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
286
|
+
base: { type: IecIdentifier },
|
|
287
|
+
number: { type: "string" },
|
|
288
|
+
synthetic_base: { type: "boolean", default: false },
|
|
289
|
+
});
|
|
290
|
+
static mappings = keyValue({ wire: "number", to: "number" }, { wire: "year", to: "date", toWire: (m) => m["date"]?.year, fromWire: yearFromWire }, { wire: "month", to: "date", toWire: (m) => m["date"]?.month, fromWire: () => undefined }, { wire: "day", to: "date", toWire: (m) => m["date"]?.day, fromWire: () => undefined }, { wire: "edition", to: "edition" }, {
|
|
291
|
+
wire: "publisher",
|
|
292
|
+
to: "publisher",
|
|
293
|
+
toWire: (m) => (m["publisher"] === "IEC" ? undefined : m["publisher"]),
|
|
294
|
+
fromWire: (h) => (h["publisher"] === undefined || h["publisher"] === null ? undefined : String(h["publisher"])),
|
|
295
|
+
}, {
|
|
296
|
+
wire: "copublishers",
|
|
297
|
+
to: "copublishers",
|
|
298
|
+
toWire: (m) => {
|
|
299
|
+
const list = m["copublishers"];
|
|
300
|
+
return list !== undefined && list.length > 0 ? list : undefined;
|
|
301
|
+
},
|
|
302
|
+
fromWire: (h) => (Array.isArray(h["copublishers"]) ? h["copublishers"].map(String) : undefined),
|
|
303
|
+
}, { wire: "base", to: "base" });
|
|
304
|
+
render() {
|
|
305
|
+
const base = this.base;
|
|
306
|
+
if (base === undefined || this.synthetic_base === true) {
|
|
307
|
+
// Standalone draft supplement (not in the corpus; Ruby parity shape).
|
|
308
|
+
let result = this.publisherPortion();
|
|
309
|
+
result += ` ${abbr} ${base?.number ?? this.number ?? ""}`;
|
|
310
|
+
if (this.date !== undefined)
|
|
311
|
+
result += `:${this.date.render()}`;
|
|
312
|
+
if (this.edition !== undefined)
|
|
313
|
+
result += ` ED${this.edition}`;
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
let result = base.render();
|
|
317
|
+
result += `/${abbr}${this.number ?? ""}`;
|
|
318
|
+
if (this.date !== undefined)
|
|
319
|
+
result += `:${this.date.render()}`;
|
|
320
|
+
if (this.edition !== undefined)
|
|
321
|
+
result += ` ED${this.edition}`;
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
registerType(IecSupplementIdentifier);
|
|
326
|
+
return IecSupplementIdentifier;
|
|
327
|
+
}
|
|
328
|
+
function iecSheetClass() {
|
|
329
|
+
class IecSheetIdentifier extends IecIdentifier {
|
|
330
|
+
static polymorphicName = "pubid:iec:sheet-identifier";
|
|
331
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
332
|
+
base: { type: IecIdentifier },
|
|
333
|
+
sheet_number: { type: "string" },
|
|
334
|
+
sheet_year: { type: "string" },
|
|
335
|
+
});
|
|
336
|
+
static mappings = keyValue({ wire: "base", to: "base" }, { wire: "sheet_number", to: "sheet_number" }, { wire: "sheet_year", to: "sheet_year" });
|
|
337
|
+
render() {
|
|
338
|
+
let result = this.base?.render() ?? "";
|
|
339
|
+
result += `/${this.sheet_number}`;
|
|
340
|
+
if (this.sheet_year !== undefined && this.sheet_year !== "")
|
|
341
|
+
result += `:${this.sheet_year}`;
|
|
342
|
+
return result;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
registerType(IecSheetIdentifier);
|
|
346
|
+
return IecSheetIdentifier;
|
|
347
|
+
}
|
|
348
|
+
function iecVapClass() {
|
|
349
|
+
class IecVapIdentifier extends IecIdentifier {
|
|
350
|
+
static polymorphicName = "pubid:iec:vap-identifier";
|
|
351
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
352
|
+
base: { type: IecIdentifier },
|
|
353
|
+
vap: { type: "string", collection: true, initializeEmpty: true },
|
|
354
|
+
edition: { type: "string" },
|
|
355
|
+
});
|
|
356
|
+
static mappings = keyValue({ wire: "base", to: "base" }, { wire: "vap", to: "vap" }, { wire: "edition", to: "edition" });
|
|
357
|
+
render() {
|
|
358
|
+
let result = this.base?.render() ?? "";
|
|
359
|
+
if (this.vap.length > 0)
|
|
360
|
+
result += ` ${this.vap.join("-")}`;
|
|
361
|
+
if (this.edition !== undefined)
|
|
362
|
+
result += ` ED${this.edition}`;
|
|
363
|
+
return result;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
registerType(IecVapIdentifier);
|
|
367
|
+
return IecVapIdentifier;
|
|
368
|
+
}
|
|
369
|
+
function iecConsolidatedClass() {
|
|
370
|
+
class IecConsolidatedIdentifier extends IecIdentifier {
|
|
371
|
+
static polymorphicName = "pubid:iec:consolidated-identifier";
|
|
372
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
373
|
+
identifiers: { type: IecIdentifier, collection: true, initializeEmpty: true },
|
|
374
|
+
});
|
|
375
|
+
static mappings = keyValue({ wire: "identifiers", to: "identifiers" });
|
|
376
|
+
render() {
|
|
377
|
+
return this.identifiers
|
|
378
|
+
.map((id, idx) => {
|
|
379
|
+
if (idx === 0)
|
|
380
|
+
return id.render();
|
|
381
|
+
const kind = id.constructor.polymorphicName.slice("pubid:iec:".length);
|
|
382
|
+
const date = id.date?.render();
|
|
383
|
+
if (kind === "amendment")
|
|
384
|
+
return date !== undefined && date !== "" ? `+AMD${id.number}:${date}` : `+AMD${id.number}`;
|
|
385
|
+
if (kind === "corrigendum")
|
|
386
|
+
return date !== undefined && date !== "" ? `+COR${id.number}:${date}` : `+COR${id.number}`;
|
|
387
|
+
return `+${id.render()}`;
|
|
388
|
+
})
|
|
389
|
+
.join("");
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
registerType(IecConsolidatedIdentifier);
|
|
393
|
+
return IecConsolidatedIdentifier;
|
|
394
|
+
}
|
|
395
|
+
function iecFragmentClass() {
|
|
396
|
+
class IecFragmentIdentifier extends IecIdentifier {
|
|
397
|
+
static polymorphicName = "pubid:iec:fragment-identifier";
|
|
398
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
399
|
+
base: { type: IecIdentifier },
|
|
400
|
+
fragment_number: { type: "string" },
|
|
401
|
+
edition: { type: "string" },
|
|
402
|
+
});
|
|
403
|
+
static mappings = keyValue({ wire: "base", to: "base" }, { wire: "edition", to: "edition" }, { wire: "fragment_number", to: "fragment_number" });
|
|
404
|
+
render() {
|
|
405
|
+
const base = this.base;
|
|
406
|
+
let result = base?.render() ?? "";
|
|
407
|
+
const isCorr = base?.constructor.polymorphicName === "pubid:iec:corrigendum";
|
|
408
|
+
result += isCorr ? `/FRAGC${this.fragment_number}` : `/FRAG${this.fragment_number}`;
|
|
409
|
+
if (this.edition !== undefined)
|
|
410
|
+
result += ` ED${this.edition}`;
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
registerType(IecFragmentIdentifier);
|
|
415
|
+
return IecFragmentIdentifier;
|
|
416
|
+
}
|
|
417
|
+
const SINGLE_KINDS = ["is", "tr", "ts", "pas", "srd", "od", "guide"];
|
|
418
|
+
const KIND_CLASSES = {};
|
|
419
|
+
for (const kind of SINGLE_KINDS) {
|
|
420
|
+
KIND_CLASSES[kind] = iecSingleClass(kind);
|
|
421
|
+
}
|
|
422
|
+
KIND_CLASSES["wp"] = iecWorkingDocumentClass();
|
|
423
|
+
KIND_CLASSES["trf"] = iecTrfClass();
|
|
424
|
+
KIND_CLASSES["amd"] = iecSupplementClass("amendment");
|
|
425
|
+
KIND_CLASSES["cor"] = iecSupplementClass("corrigendum");
|
|
426
|
+
KIND_CLASSES["ish"] = iecSupplementClass("interpretation-sheet");
|
|
427
|
+
const SHEET_CLASS = iecSheetClass();
|
|
428
|
+
const VAP_CLASS = iecVapClass();
|
|
429
|
+
const CONSOLIDATED_CLASS = iecConsolidatedClass();
|
|
430
|
+
const FRAGMENT_CLASS = iecFragmentClass();
|
|
431
|
+
export const IEC_CLASSES = {
|
|
432
|
+
KIND_CLASSES,
|
|
433
|
+
SHEET_CLASS,
|
|
434
|
+
VAP_CLASS,
|
|
435
|
+
CONSOLIDATED_CLASS,
|
|
436
|
+
FRAGMENT_CLASS,
|
|
437
|
+
};
|