@pubid/pubid 0.1.3 → 0.1.5
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 +31 -0
- package/dist/flavors/gb/index.js +159 -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 +697 -0
- package/dist/flavors/ieee/index.d.ts +3 -0
- package/dist/flavors/ieee/index.js +1258 -0
- package/dist/flavors/ieee/model.d.ts +144 -0
- package/dist/flavors/ieee/model.js +1237 -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 +197 -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 +206 -0
- package/dist/flavors/oiml/implementation.d.ts +9 -0
- package/dist/flavors/oiml/implementation.js +45 -0
- package/dist/flavors/oiml/model.d.ts +23 -0
- package/dist/flavors/oiml/model.js +592 -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/index.d.ts +1 -0
- package/dist/index.js +3 -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 +84 -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,306 @@
|
|
|
1
|
+
import { parseGrammar } from "../../grammar/engine.js";
|
|
2
|
+
import { ashraeGrammar } from "./grammar.js";
|
|
3
|
+
import { preprocessAshrae } from "./preprocessor.js";
|
|
4
|
+
import { PubidDate } from "../../model/component.js";
|
|
5
|
+
import { AddendaPackage, Addendum, CombinedAddenda, Errata, Guideline, Interpretation, Standard, } from "./model.js";
|
|
6
|
+
/**
|
|
7
|
+
* Port of lib/pubid/ashrae/builder.rb — attribute extraction, class
|
|
8
|
+
* selection, and the five supplement build paths.
|
|
9
|
+
*/
|
|
10
|
+
const MONTH_NAMES = [
|
|
11
|
+
"January", "February", "March", "April", "May", "June", "July",
|
|
12
|
+
"August", "September", "October", "November", "December",
|
|
13
|
+
];
|
|
14
|
+
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
15
|
+
function flatten(data) {
|
|
16
|
+
return Array.isArray(data) ? Object.assign({}, ...data) : data;
|
|
17
|
+
}
|
|
18
|
+
function value(v) {
|
|
19
|
+
if (v === undefined || v === null)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (Array.isArray(v)) {
|
|
22
|
+
if (v.length === 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
const joined = v.join("");
|
|
25
|
+
return joined.length > 0 ? joined : undefined;
|
|
26
|
+
}
|
|
27
|
+
const s = String(v).trim();
|
|
28
|
+
return s.length > 0 ? s : undefined;
|
|
29
|
+
}
|
|
30
|
+
function leafClass(type) {
|
|
31
|
+
return type === "Guideline" ? Guideline : Standard;
|
|
32
|
+
}
|
|
33
|
+
function buildLeaf(attrs) {
|
|
34
|
+
return new (leafClass(attrs["type"]))(attrs);
|
|
35
|
+
}
|
|
36
|
+
function extractAttributes(parsed) {
|
|
37
|
+
const attributes = {};
|
|
38
|
+
const publisher = value(parsed["publisher"]);
|
|
39
|
+
if (publisher !== undefined)
|
|
40
|
+
attributes["publisher"] = publisher;
|
|
41
|
+
attributes["type"] = value(parsed["type"]) ?? "Standard";
|
|
42
|
+
const codeWithYear = parsed["code_with_year"];
|
|
43
|
+
if (isObj(codeWithYear)) {
|
|
44
|
+
const code = value(codeWithYear["code"]);
|
|
45
|
+
if (code !== undefined)
|
|
46
|
+
attributes["number"] = code;
|
|
47
|
+
const year = value(codeWithYear["year"]);
|
|
48
|
+
if (year !== undefined)
|
|
49
|
+
attributes["year"] = year;
|
|
50
|
+
}
|
|
51
|
+
else if (codeWithYear === undefined) {
|
|
52
|
+
const code = value(parsed["code"]);
|
|
53
|
+
if (code !== undefined)
|
|
54
|
+
attributes["number"] = code;
|
|
55
|
+
}
|
|
56
|
+
if (attributes["year"] === undefined) {
|
|
57
|
+
const year = value(parsed["year"]);
|
|
58
|
+
if (year !== undefined)
|
|
59
|
+
attributes["year"] = year;
|
|
60
|
+
}
|
|
61
|
+
const suffix = value(parsed["suffix"]);
|
|
62
|
+
if (suffix !== undefined)
|
|
63
|
+
attributes["suffix"] = suffix;
|
|
64
|
+
const reaffirmed = value(parsed["reaffirmed"]);
|
|
65
|
+
if (reaffirmed !== undefined)
|
|
66
|
+
attributes["reaffirmed"] = reaffirmed;
|
|
67
|
+
const copublisher = value(parsed["copublisher"]);
|
|
68
|
+
if (copublisher !== undefined)
|
|
69
|
+
attributes["copublisher"] = copublisher;
|
|
70
|
+
return attributes;
|
|
71
|
+
}
|
|
72
|
+
function extractBaseAttributes(parsed) {
|
|
73
|
+
// Unwrap the :base subtree the supplement grammars nest the base
|
|
74
|
+
// document under.
|
|
75
|
+
const data = isObj(parsed["base"]) ? parsed["base"] : parsed;
|
|
76
|
+
const attributes = {};
|
|
77
|
+
const publisher = value(data["publisher"]);
|
|
78
|
+
if (publisher !== undefined)
|
|
79
|
+
attributes["publisher"] = publisher;
|
|
80
|
+
const copublisher = value(data["copublisher"]);
|
|
81
|
+
if (copublisher !== undefined)
|
|
82
|
+
attributes["copublisher"] = copublisher;
|
|
83
|
+
attributes["type"] = value(data["type"]) ?? "Standard";
|
|
84
|
+
const codeWithYear = data["code_with_year"];
|
|
85
|
+
if (isObj(codeWithYear)) {
|
|
86
|
+
const code = value(codeWithYear["code"]);
|
|
87
|
+
if (code !== undefined)
|
|
88
|
+
attributes["number"] = code;
|
|
89
|
+
const year = value(codeWithYear["year"]);
|
|
90
|
+
if (year !== undefined)
|
|
91
|
+
attributes["year"] = year;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const code = value(data["code"]);
|
|
95
|
+
if (code !== undefined)
|
|
96
|
+
attributes["number"] = code;
|
|
97
|
+
const year = value(data["year"]);
|
|
98
|
+
if (year !== undefined)
|
|
99
|
+
attributes["year"] = year;
|
|
100
|
+
}
|
|
101
|
+
const suffix = value(data["suffix"]);
|
|
102
|
+
if (suffix !== undefined)
|
|
103
|
+
attributes["suffix"] = suffix;
|
|
104
|
+
const reaffirmed = value(data["reaffirmed"]);
|
|
105
|
+
if (reaffirmed !== undefined)
|
|
106
|
+
attributes["reaffirmed"] = reaffirmed;
|
|
107
|
+
return attributes;
|
|
108
|
+
}
|
|
109
|
+
function pad2(v) {
|
|
110
|
+
return String(Number(v)).padStart(2, "0");
|
|
111
|
+
}
|
|
112
|
+
function errataDateOf(errataDate) {
|
|
113
|
+
if (!isObj(errataDate))
|
|
114
|
+
return undefined;
|
|
115
|
+
const numeric = value(errataDate["numeric_date"]);
|
|
116
|
+
if (numeric !== undefined) {
|
|
117
|
+
const [month, day, year] = numeric.replaceAll(" ", "").split("-");
|
|
118
|
+
return new PubidDate({ year, month: pad2(month), day: pad2(day) });
|
|
119
|
+
}
|
|
120
|
+
const monthName = value(errataDate["month"]);
|
|
121
|
+
const month = monthName === undefined ? undefined : MONTH_NAMES.indexOf(monthName) + 1;
|
|
122
|
+
const day = value(errataDate["day"]);
|
|
123
|
+
if (month === undefined || month === 0 || day === undefined)
|
|
124
|
+
return undefined;
|
|
125
|
+
return new PubidDate({
|
|
126
|
+
year: value(errataDate["errata_year"]),
|
|
127
|
+
month: pad2(String(month)),
|
|
128
|
+
day: pad2(day),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function buildErrata(parsed) {
|
|
132
|
+
const base = buildLeaf(extractBaseAttributes(parsed));
|
|
133
|
+
return new Errata({ base, date: errataDateOf(parsed["errata_date"]) });
|
|
134
|
+
}
|
|
135
|
+
function buildAddendum(parsed) {
|
|
136
|
+
const base = buildLeaf(extractBaseAttributes(parsed));
|
|
137
|
+
return new Addendum({
|
|
138
|
+
base,
|
|
139
|
+
addendum_code: value(parsed["addendum_code"]),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function buildPublisherAddendum(parsed) {
|
|
143
|
+
// The copublisher rides BOTH the addendum and its base (the gem
|
|
144
|
+
// records it at both levels).
|
|
145
|
+
const copublisher = value(parsed["copublisher"]);
|
|
146
|
+
const base = buildLeaf({
|
|
147
|
+
type: value(parsed["type"]),
|
|
148
|
+
number: value(parsed["code"]),
|
|
149
|
+
year: value(parsed["year"]),
|
|
150
|
+
...(copublisher !== undefined ? { copublisher } : {}),
|
|
151
|
+
});
|
|
152
|
+
return new Addendum({
|
|
153
|
+
base,
|
|
154
|
+
addendum_code: value(parsed["addendum_code"]),
|
|
155
|
+
...(copublisher !== undefined ? { copublisher } : {}),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function codeWithYearBaseAttrs(parsed) {
|
|
159
|
+
const baseAttrs = { type: "Standard" };
|
|
160
|
+
const copublisher = value(parsed["copublisher"]);
|
|
161
|
+
if (copublisher !== undefined)
|
|
162
|
+
baseAttrs["copublisher"] = copublisher;
|
|
163
|
+
const codeWithYear = parsed["code_with_year"];
|
|
164
|
+
if (isObj(codeWithYear)) {
|
|
165
|
+
const code = value(codeWithYear["code"]);
|
|
166
|
+
if (code !== undefined)
|
|
167
|
+
baseAttrs["number"] = code;
|
|
168
|
+
const year = value(codeWithYear["year"]);
|
|
169
|
+
if (year !== undefined)
|
|
170
|
+
baseAttrs["year"] = year;
|
|
171
|
+
}
|
|
172
|
+
return baseAttrs;
|
|
173
|
+
}
|
|
174
|
+
function buildCombinedAddenda(parsed) {
|
|
175
|
+
const baseAttrs = {};
|
|
176
|
+
if (isObj(parsed["code_with_year"])) {
|
|
177
|
+
const code = value(parsed["code_with_year"]["code"]);
|
|
178
|
+
if (code !== undefined)
|
|
179
|
+
baseAttrs["number"] = code;
|
|
180
|
+
const year = value(parsed["code_with_year"]["year"]);
|
|
181
|
+
if (year !== undefined)
|
|
182
|
+
baseAttrs["year"] = year;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
baseAttrs["type"] = value(parsed["type"]) ?? "Standard";
|
|
186
|
+
const code = value(parsed["code"]);
|
|
187
|
+
if (code !== undefined)
|
|
188
|
+
baseAttrs["number"] = code;
|
|
189
|
+
const year = value(parsed["year"]);
|
|
190
|
+
if (year !== undefined)
|
|
191
|
+
baseAttrs["year"] = year;
|
|
192
|
+
}
|
|
193
|
+
const copublisher = value(parsed["copublisher"]);
|
|
194
|
+
if (copublisher !== undefined)
|
|
195
|
+
baseAttrs["copublisher"] = copublisher;
|
|
196
|
+
const publisher = value(parsed["publisher"]);
|
|
197
|
+
if (publisher !== undefined)
|
|
198
|
+
baseAttrs["publisher"] = publisher;
|
|
199
|
+
const base = buildLeaf(baseAttrs);
|
|
200
|
+
const firstCode = value(parsed["addendum_code"]);
|
|
201
|
+
// The "a through z" range form yields a single object, not an array.
|
|
202
|
+
const additionalRaw = parsed["additional_codes"];
|
|
203
|
+
const additionalCodes = Array.isArray(additionalRaw)
|
|
204
|
+
? additionalRaw
|
|
205
|
+
: additionalRaw !== undefined && additionalRaw !== null
|
|
206
|
+
? [additionalRaw]
|
|
207
|
+
: undefined;
|
|
208
|
+
let addendumCodes;
|
|
209
|
+
if (firstCode !== undefined || additionalCodes !== undefined) {
|
|
210
|
+
const codeList = [];
|
|
211
|
+
if (Array.isArray(additionalCodes)) {
|
|
212
|
+
// The repetition subtrees nest (iteration arrays around the
|
|
213
|
+
// captured objects); flatten before extracting each code.
|
|
214
|
+
for (const code of additionalCodes.flat(Infinity)) {
|
|
215
|
+
const codeStr = isObj(code)
|
|
216
|
+
? value(code["addendum_code"])
|
|
217
|
+
: value(code);
|
|
218
|
+
if (codeStr !== undefined && codeStr !== "and")
|
|
219
|
+
codeList.push(codeStr);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
addendumCodes = firstCode ?? "";
|
|
223
|
+
if (codeList.length > 0) {
|
|
224
|
+
addendumCodes += `, ${codeList.join(", ")}`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return new CombinedAddenda({ base, addendum_codes: addendumCodes });
|
|
228
|
+
}
|
|
229
|
+
function buildAddendaPackage(parsed) {
|
|
230
|
+
const base = buildLeaf(extractBaseAttributes(parsed));
|
|
231
|
+
return new AddendaPackage({
|
|
232
|
+
base,
|
|
233
|
+
package_description: value(parsed["package_description"]),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
export function buildAshraeIdentifier(tree) {
|
|
237
|
+
let parsed = flatten(tree);
|
|
238
|
+
if (parsed["errata_keyword"] !== undefined) {
|
|
239
|
+
return buildErrata(parsed);
|
|
240
|
+
}
|
|
241
|
+
if (parsed["interpretation_identifier"] !== undefined) {
|
|
242
|
+
const data = flatten(parsed["interpretation_identifier"]);
|
|
243
|
+
const baseAttrs = extractBaseAttributes(flatten(data["base"]));
|
|
244
|
+
const base = buildLeaf(baseAttrs);
|
|
245
|
+
return new Interpretation({ base });
|
|
246
|
+
}
|
|
247
|
+
if (parsed["combined_addenda"] !== undefined) {
|
|
248
|
+
return buildCombinedAddenda(flatten(parsed["combined_addenda"]));
|
|
249
|
+
}
|
|
250
|
+
if (parsed["addenda_package"] !== undefined) {
|
|
251
|
+
return buildAddendaPackage(flatten(parsed["addenda_package"]));
|
|
252
|
+
}
|
|
253
|
+
if (parsed["addendum_identifier"] !== undefined) {
|
|
254
|
+
return buildAddendum(flatten(parsed["addendum_identifier"]));
|
|
255
|
+
}
|
|
256
|
+
if (parsed["publisher_addendum"] !== undefined) {
|
|
257
|
+
return buildPublisherAddendum(flatten(parsed["publisher_addendum"]));
|
|
258
|
+
}
|
|
259
|
+
if (parsed["publisher_addendum_copublisher"] !== undefined) {
|
|
260
|
+
const data = flatten(parsed["publisher_addendum_copublisher"]);
|
|
261
|
+
return buildPublisherAddendum({
|
|
262
|
+
copublisher: data["copublisher"],
|
|
263
|
+
type: value(data["type"]) ?? "Standard",
|
|
264
|
+
code: data["code"],
|
|
265
|
+
year: data["year"],
|
|
266
|
+
addendum_code: data["addendum_code"],
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (parsed["publisher_addendum_copublisher_no_type"] !== undefined) {
|
|
270
|
+
return buildAddendumFromCodeWithYear(flatten(parsed["publisher_addendum_copublisher_no_type"]));
|
|
271
|
+
}
|
|
272
|
+
if (parsed["addendum_no_type"] !== undefined) {
|
|
273
|
+
const data = flatten(parsed["addendum_no_type"]);
|
|
274
|
+
return buildAddendumFromCodeWithYear(data);
|
|
275
|
+
}
|
|
276
|
+
if (parsed["standard_addendum"] !== undefined) {
|
|
277
|
+
return buildAddendum(flatten(parsed["standard_addendum"]));
|
|
278
|
+
}
|
|
279
|
+
if (parsed["addendum"] !== undefined) {
|
|
280
|
+
return buildAddendum(flatten(parsed["addendum"]));
|
|
281
|
+
}
|
|
282
|
+
if (parsed["publisher_base_addendum"] !== undefined) {
|
|
283
|
+
return buildAddendum(flatten(parsed["publisher_base_addendum"]));
|
|
284
|
+
}
|
|
285
|
+
if (isObj(parsed["base"])) {
|
|
286
|
+
parsed = parsed["base"];
|
|
287
|
+
}
|
|
288
|
+
const attributes = extractAttributes(parsed);
|
|
289
|
+
return buildLeaf(attributes);
|
|
290
|
+
}
|
|
291
|
+
function buildAddendumFromCodeWithYear(data) {
|
|
292
|
+
const base = buildLeaf(codeWithYearBaseAttrs(data));
|
|
293
|
+
return new Addendum({
|
|
294
|
+
base,
|
|
295
|
+
addendum_code: value(data["addendum_code"]),
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
export function ashraeGrammarImplementation() {
|
|
299
|
+
return {
|
|
300
|
+
parse(input) {
|
|
301
|
+
const cleaned = preprocessAshrae(input);
|
|
302
|
+
const tree = parseGrammar(ashraeGrammar, cleaned);
|
|
303
|
+
return buildAshraeIdentifier(tree);
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
2
|
+
import { type FieldMapping } from "../../model/attribute.js";
|
|
3
|
+
import { PubidDate } from "../../model/component.js";
|
|
4
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
5
|
+
declare class AshraeUrnGenerator extends BaseUrnGenerator<AshraeIdentifier> {
|
|
6
|
+
generate(): string;
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class AshraeIdentifier extends BaseIdentifier {
|
|
9
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
10
|
+
static mappings: FieldMapping[];
|
|
11
|
+
readonly publisher: string | undefined;
|
|
12
|
+
readonly copublisher: string | undefined;
|
|
13
|
+
readonly type: string | undefined;
|
|
14
|
+
readonly suffix: string | undefined;
|
|
15
|
+
readonly amendment: string | undefined;
|
|
16
|
+
readonly reaffirmed: string | undefined;
|
|
17
|
+
readonly year: string | undefined;
|
|
18
|
+
root(): AshraeIdentifier;
|
|
19
|
+
}
|
|
20
|
+
export declare class Standard extends AshraeIdentifier {
|
|
21
|
+
static polymorphicName: string;
|
|
22
|
+
static urnGenerator: typeof AshraeUrnGenerator;
|
|
23
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
24
|
+
static mappings: FieldMapping[];
|
|
25
|
+
readonly number: string | undefined;
|
|
26
|
+
constructor(attrs?: Record<string, unknown>);
|
|
27
|
+
render(): string;
|
|
28
|
+
}
|
|
29
|
+
export declare class Guideline extends AshraeIdentifier {
|
|
30
|
+
static polymorphicName: string;
|
|
31
|
+
static urnGenerator: typeof AshraeUrnGenerator;
|
|
32
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
33
|
+
static mappings: FieldMapping[];
|
|
34
|
+
readonly number: string | undefined;
|
|
35
|
+
constructor(attrs?: Record<string, unknown>);
|
|
36
|
+
render(): string;
|
|
37
|
+
}
|
|
38
|
+
export declare abstract class SupplementIdentifier extends AshraeIdentifier {
|
|
39
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
40
|
+
static mappings: FieldMapping[];
|
|
41
|
+
readonly base: AshraeIdentifier | undefined;
|
|
42
|
+
root(): AshraeIdentifier;
|
|
43
|
+
}
|
|
44
|
+
declare function delegatedCopublisher(model: BaseIdentifier, hash: Record<string, unknown>): void;
|
|
45
|
+
export declare class Addendum extends SupplementIdentifier {
|
|
46
|
+
static polymorphicName: string;
|
|
47
|
+
static urnGenerator: typeof AshraeUrnGenerator;
|
|
48
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
49
|
+
static mappings: FieldMapping[];
|
|
50
|
+
static compactHash: typeof delegatedCopublisher;
|
|
51
|
+
readonly addendum_code: string | undefined;
|
|
52
|
+
readonly addendum_date: string | undefined;
|
|
53
|
+
render(): string;
|
|
54
|
+
}
|
|
55
|
+
export declare class CombinedAddenda extends SupplementIdentifier {
|
|
56
|
+
static polymorphicName: string;
|
|
57
|
+
static urnGenerator: typeof AshraeUrnGenerator;
|
|
58
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
59
|
+
static mappings: FieldMapping[];
|
|
60
|
+
static compactHash: typeof delegatedCopublisher;
|
|
61
|
+
readonly addendum_codes: string | undefined;
|
|
62
|
+
readonly connector: string | undefined;
|
|
63
|
+
render(): string;
|
|
64
|
+
}
|
|
65
|
+
export declare class AddendaPackage extends SupplementIdentifier {
|
|
66
|
+
static polymorphicName: string;
|
|
67
|
+
static urnGenerator: typeof AshraeUrnGenerator;
|
|
68
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
69
|
+
static mappings: FieldMapping[];
|
|
70
|
+
static compactHash: typeof delegatedCopublisher;
|
|
71
|
+
readonly package_description: string | undefined;
|
|
72
|
+
render(): string;
|
|
73
|
+
}
|
|
74
|
+
export declare class Errata extends SupplementIdentifier {
|
|
75
|
+
static polymorphicName: string;
|
|
76
|
+
static urnGenerator: typeof AshraeUrnGenerator;
|
|
77
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
78
|
+
static mappings: FieldMapping[];
|
|
79
|
+
readonly date: PubidDate | undefined;
|
|
80
|
+
render(): string;
|
|
81
|
+
}
|
|
82
|
+
export declare class Interpretation extends SupplementIdentifier {
|
|
83
|
+
static polymorphicName: string;
|
|
84
|
+
static urnGenerator: typeof AshraeUrnGenerator;
|
|
85
|
+
render(): string;
|
|
86
|
+
}
|
|
87
|
+
export {};
|