@hestia-earth/glossary 0.98.3 → 0.100.0

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/index.js CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  getDefaultModels: () => getDefaultModels,
38
38
  getEcoalimMapping: () => getEcoalimMapping,
39
39
  getEcoinventMapping: () => getEcoinventMapping,
40
+ getElcd32Mapping: () => getElcd32Mapping,
40
41
  getEmissionGroupings: () => getEmissionGroupings,
41
42
  getModelGroup: () => getModelGroup,
42
43
  getTermModelRestrictions: () => getTermModelRestrictions,
@@ -62,6 +63,7 @@ var import_blankNodesGroup = __toESM(require("./resources/blankNodesGroup.json")
62
63
  var import_defaultModelId = __toESM(require("./resources/defaultModelId.json"), 1);
63
64
  var import_ecoalimMapping = __toESM(require("./resources/ecoalimMapping.json"), 1);
64
65
  var import_ecoinventMapping = __toESM(require("./resources/ecoinventMapping.json"), 1);
66
+ var import_elcd32Mapping = __toESM(require("./resources/elcd32Mapping.json"), 1);
65
67
  var import_emission_groupings = __toESM(require("./resources/emission-groupings.json"), 1);
66
68
  var import_id_to_iso3166_2 = __toESM(require("./resources/id-to-iso3166-2.json"), 1);
67
69
  var import_inHestiaDefaultSystemBoundary = __toESM(require("./resources/inHestiaDefaultSystemBoundary.json"), 1);
@@ -82,6 +84,7 @@ const RESOURCES = {
82
84
  "defaultModelId.json": import_defaultModelId.default,
83
85
  "ecoalimMapping.json": import_ecoalimMapping.default,
84
86
  "ecoinventMapping.json": import_ecoinventMapping.default,
87
+ "elcd32Mapping.json": import_elcd32Mapping.default,
85
88
  "emission-groupings.json": import_emission_groupings.default,
86
89
  "id-to-iso3166-2.json": import_id_to_iso3166_2.default,
87
90
  "inHestiaDefaultSystemBoundary.json": import_inHestiaDefaultSystemBoundary.default,
@@ -130,6 +133,7 @@ const getEcoalimMapping = (id) => import_ecoalimMapping.default[id];
130
133
  const getEcoinventMapping = (id) => import_ecoinventMapping.default[id];
131
134
  const getWorldSteelMapping = (id) => import_worldsteelMapping.default[id];
132
135
  const getBafuMapping = (id) => import_bafuMapping.default[id];
136
+ const getElcd32Mapping = (id) => import_elcd32Mapping.default[id];
133
137
  const getBlankNodesGroup = (id) => import_blankNodesGroup.default[id];
134
138
  const getEmissionGroupings = (id) => import_emission_groupings.default[id];
135
139
  const isCoverCrop = (id) => getBlankNodesGroup(id) === "Cover crops";
@@ -147,6 +151,7 @@ const termOrder = ({ "@id": id, termType }) => termType ? id ? import_term_order
147
151
  getDefaultModels,
148
152
  getEcoalimMapping,
149
153
  getEcoinventMapping,
154
+ getElcd32Mapping,
150
155
  getEmissionGroupings,
151
156
  getModelGroup,
152
157
  getTermModelRestrictions,
package/index.mjs CHANGED
@@ -6,6 +6,7 @@ import blankNodesGroup from "./resources/blankNodesGroup.json" with { type: "jso
6
6
  import defaultModelId from "./resources/defaultModelId.json" with { type: "json" };
7
7
  import ecoalimMapping from "./resources/ecoalimMapping.json" with { type: "json" };
8
8
  import ecoinventMapping from "./resources/ecoinventMapping.json" with { type: "json" };
9
+ import elcd32Mapping from "./resources/elcd32Mapping.json" with { type: "json" };
9
10
  import emissionGroupings from "./resources/emission-groupings.json" with { type: "json" };
10
11
  import idToIso31662Map from "./resources/id-to-iso3166-2.json" with { type: "json" };
11
12
  import inHestiaDefaultSystemBoundary from "./resources/inHestiaDefaultSystemBoundary.json" with { type: "json" };
@@ -30,6 +31,7 @@ const RESOURCES = {
30
31
  "defaultModelId.json": defaultModelId,
31
32
  "ecoalimMapping.json": ecoalimMapping,
32
33
  "ecoinventMapping.json": ecoinventMapping,
34
+ "elcd32Mapping.json": elcd32Mapping,
33
35
  "emission-groupings.json": emissionGroupings,
34
36
  "id-to-iso3166-2.json": idToIso31662Map,
35
37
  "inHestiaDefaultSystemBoundary.json": inHestiaDefaultSystemBoundary,
@@ -44,103 +46,42 @@ const RESOURCES = {
44
46
  };
45
47
 
46
48
  /**
47
- * Get a value from a resource by filename.
48
- *
49
- * Prefer the dedicated getters below when possible: using this generic helper
49
+ * Get a value from a resource by filename. Prefer the dedicated getters below: this one
50
50
  * defeats tree-shaking, as it can reference any bundled resource.
51
- *
52
- * @param {string} filename The name of the file containing the resources.
53
- * @param {string} key The key in the resource file.
54
- * @returns {any} The data associated with the `key`.
55
51
  */
56
52
  export const loadResourceKey = (filename, key) => {
57
53
  const resource = RESOURCES[filename];
58
54
  return key ? resource?.[key] : resource;
59
55
  };
60
56
 
61
- /**
62
- * Converts the iso31662 code to the [term.name](https://hestia.earth/schema/Term#name) from the HESTIA Glossary.
63
- *
64
- * @param {string} code The [iso31662 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
65
- * @returns {string} The HESTIA country [name](https://hestia.earth/schema/Term#name).
66
- */
57
+ /** Converts an ISO 3166-2 code to the HESTIA region name. */
67
58
  export const iso31662ToName = (code = "") =>
68
59
  iso31662ToNameMap[code.toUpperCase()];
69
60
 
70
- /**
71
- * Converts the iso31662 code to the [term.id](https://hestia.earth/schema/Term#id) from the HESTIA Glossary.
72
- *
73
- * @param {string} code The [iso31662 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
74
- * @returns {string} The HESTIA country [id](https://hestia.earth/schema/Term#id).
75
- */
61
+ /** Converts an ISO 3166-2 code to the HESTIA region id. */
76
62
  export const iso31662ToId = (code = "") => iso31662ToIdMap[code.toUpperCase()];
77
63
 
78
- /**
79
- * Converts the [term.id](https://hestia.earth/schema/Term#id) from the HESTIA Glossary to a iso31662 code.
80
- *
81
- * @param {string} id The HESTIA country [id](https://hestia.earth/schema/Term#id).
82
- * @returns {string} The [iso31662 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
83
- */
64
+ /** Converts a HESTIA region id to its ISO 3166-2 code. */
84
65
  export const idToIso31662 = (id = "") => idToIso31662Map[id.toUpperCase()];
85
66
 
86
- /**
87
- * Determines how an array of values should be handled (if summed up, or averaged, etc.).
88
- *
89
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
90
- * @returns {string} Possible values are: `mean`, `mode` and `sum`.
91
- */
67
+ /** How an array of values is combined: `mean`, `mode` or `sum` (the default). */
92
68
  export const getArrayTreatment = (id) => arrayTreatment[id] || "sum";
93
69
 
94
- /**
95
- * Returns the `@id` of the default model that should be used for display of this Term.
96
- *
97
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
98
- * @returns {string} The `@id` of the model if set.
99
- */
100
70
  export const getDefaultModelId = (id) => defaultModelId[id];
101
71
 
102
- /**
103
- * Returns the list of `@id` of the default models that should be used for display.
104
- *
105
- * @returns {string[]} The list of default `@id`.
106
- */
107
72
  export const getDefaultModels = () =>
108
73
  Object.entries(defaultModelId)
109
74
  .filter(([, value]) => !!value)
110
75
  .map(([key]) => key);
111
76
 
112
- /**
113
- * Returns the list of restrictions of the Term.
114
- *
115
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
116
- * @returns A list of restrictions as an object.
117
- */
118
77
  export const getTermRestrictions = (id) => termRestrictions[id];
119
78
 
120
- /**
121
- * Returns the list of restrictions of the Term/Model mapping.
122
- *
123
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
124
- * @param {string} modelId The HESTIA term [id](https://hestia.earth/schema/Term#id).
125
- * @returns A list of restrictions as an object.
126
- */
127
79
  export const getTermModelRestrictions = (id, modelId) =>
128
80
  (termRestrictions[id] || {})[modelId];
129
81
 
130
- /**
131
- * Returns the list of restrictions of the Term/Model mapping.
132
- *
133
- * @param {string} termType The HESTIA term [termType](https://hestia.earth/schema/Term#termType).
134
- * @returns A list of lookups.
135
- */
136
82
  export const getTermTypeLookups = (termType) => termTypeLookups[termType];
137
83
 
138
- /**
139
- * Checks whether the emission is in the HESTIA System Boundary.
140
- *
141
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
142
- * @returns {boolean} True if the Term is included.
143
- */
84
+ /** A Term with no `inHestiaDefaultSystemBoundary` value counts as in the boundary. */
144
85
  export const isInSystemBoundary = (id) => {
145
86
  const value = inHestiaDefaultSystemBoundary[id];
146
87
  return !value || value === "true";
@@ -149,29 +90,12 @@ export const isInSystemBoundary = (id) => {
149
90
  // built once, so repeated checks do not scan the list
150
91
  const backgroundEmissions = new Set(backgroundEmissionTermIds);
151
92
 
152
- /**
153
- * Checks whether the emission or resource use is a background one - attributed to producing an
154
- * input rather than to the Cycle itself, and carried by a background emissions lookup.
155
- *
156
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
157
- * @returns {boolean} True if a background emissions lookup carries a value for the Term.
158
- */
93
+ /** True when a background emissions lookup carries a value for the Term. */
159
94
  export const isBackgroundEmission = (id) => backgroundEmissions.has(id);
160
95
 
161
- /**
162
- * Returns every Term a background emissions lookup carries a value for, across every dataset.
163
- *
164
- * @returns {string[]} The HESTIA term [ids](https://hestia.earth/schema/Term#id).
165
- */
166
96
  export const getBackgroundEmissionTerms = () => [...backgroundEmissionTermIds];
167
97
 
168
- /**
169
- * Returns the Terms one background emissions dataset carries a value for, by indicator
170
- * (`emission` and `resourceUse`).
171
- *
172
- * @param {string} modelId The `@id` of the model whose lookups carry the values.
173
- * @returns {{emission: string[], resourceUse: string[]}} The HESTIA term [ids](https://hestia.earth/schema/Term#id).
174
- */
98
+ /** The Terms one background emissions dataset carries a value for, by `emission` and `resourceUse`. */
175
99
  export const getBackgroundEmissionTermsByModel = (modelId) =>
176
100
  backgroundEmissionTermsByModel[modelId];
177
101
 
@@ -188,15 +112,9 @@ const backgroundEmissionModels = Object.entries(
188
112
  }, {});
189
113
 
190
114
  /**
191
- * Returns the models whose background emissions lookups carry a value for the Term.
192
- *
193
- * This is not which model produced a given emission - several datasets carry the same Term, so
194
- * only the blank node's `methodModel` says which one ran. Models deriving their values from
195
- * these datasets rather than carrying their own lookups (`linkedImpactAssessment`, `hestia`)
196
- * are not listed here; `@hestia-earth/engine-models` links those per Term.
197
- *
198
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
199
- * @returns {string[]} The `@id` of each model.
115
+ * The models whose background emissions lookups carry a value for the Term - not which one
116
+ * produced a given emission, which only the blank node's `methodModel` says. Models deriving
117
+ * their values from these datasets (`linkedImpactAssessment`, `hestia`) are not listed.
200
118
  */
201
119
  export const getBackgroundEmissionModels = (id) =>
202
120
  backgroundEmissionModels[id] ?? [];
@@ -204,13 +122,6 @@ export const getBackgroundEmissionModels = (id) =>
204
122
  // built once, so repeated checks do not scan the list
205
123
  const plantations = new Set(plantationIds);
206
124
 
207
- /**
208
- * Checks whether the crop is grown as a plantation - a permanent crop that produces over several
209
- * years, rather than one planted and harvested within a Cycle.
210
- *
211
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
212
- * @returns {boolean} True if the Term is a plantation crop.
213
- */
214
125
  export const isPlantation = (id) => plantations.has(id);
215
126
 
216
127
  export const getEcoalimMapping = (id) => ecoalimMapping[id];
@@ -221,38 +132,17 @@ export const getWorldSteelMapping = (id) => worldsteelMapping[id];
221
132
 
222
133
  export const getBafuMapping = (id) => bafuMapping[id];
223
134
 
135
+ export const getElcd32Mapping = (id) => elcd32Mapping[id];
136
+
224
137
  export const getBlankNodesGroup = (id) => blankNodesGroup[id];
225
138
 
226
- /**
227
- * Get the groupings for the Emission.
228
- *
229
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
230
- * @returns {object} Different groupings types and values.
231
- */
232
139
  export const getEmissionGroupings = (id) => emissionGroupings[id];
233
140
 
234
- /**
235
- * Determines if the property is identifying a cover crop.
236
- *
237
- * @param {*} id The property `@id`
238
- * @returns `true` if the property represents a cover crop.
239
- */
240
141
  export const isCoverCrop = (id) => getBlankNodesGroup(id) === "Cover crops";
241
142
 
242
- /**
243
- * Return the group for this term with a specific model.
244
- *
245
- * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
246
- * @param {string} modelId The HESTIA term [id](https://hestia.earth/schema/Term#id).
247
- * @returns {string} The HESTIA term [id](https://hestia.earth/schema/Term#id) of the group.
248
- */
249
143
  export const getModelGroup = (id, modelId) => (modelGroups[id] || {})[modelId];
250
144
 
251
- /**
252
- *
253
- * @param {object} term The HESTIA term, providing `@id` and/or `termType`.
254
- * @returns {number|list} The index if searching for a specific Term by `@id`, or the ordered list of ids if search by `termType`.
255
- */
145
+ /** The Term's index when given an `@id`, or the ordered ids when given only a `termType`. */
256
146
  export const termOrder = ({ "@id": id, termType }) =>
257
147
  termType
258
148
  ? id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/glossary",
3
- "version": "0.98.3",
3
+ "version": "0.100.0",
4
4
  "description": "HESTIA Earth Glossary library",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",