@hestia-earth/glossary 0.93.1 → 0.93.3
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 +123 -174
- package/index.mjs +207 -0
- package/package.json +16 -1
- package/resources/arrayTreatment.json +1 -1
- package/resources/bafuMapping.json +1 -1
- package/resources/ecoalimMapping.json +1 -1
- package/resources/term-order.json +1 -1
- package/resources/term-restrictions.json +1 -1
- package/resources/termType-lookups.json +1 -1
- package/resources/worldsteelMapping.json +1 -1
package/index.js
CHANGED
|
@@ -1,185 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
100
|
-
* @returns {boolean} True if the Term is included.
|
|
101
|
-
*/
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var index_exports = {};
|
|
29
|
+
__export(index_exports, {
|
|
30
|
+
getArrayTreatment: () => getArrayTreatment,
|
|
31
|
+
getBafuMapping: () => getBafuMapping,
|
|
32
|
+
getBlankNodesGroup: () => getBlankNodesGroup,
|
|
33
|
+
getDefaultModelId: () => getDefaultModelId,
|
|
34
|
+
getDefaultModels: () => getDefaultModels,
|
|
35
|
+
getEcoalimMapping: () => getEcoalimMapping,
|
|
36
|
+
getEcoinventMapping: () => getEcoinventMapping,
|
|
37
|
+
getEmissionGroupings: () => getEmissionGroupings,
|
|
38
|
+
getModelGroup: () => getModelGroup,
|
|
39
|
+
getTermModelRestrictions: () => getTermModelRestrictions,
|
|
40
|
+
getTermRestrictions: () => getTermRestrictions,
|
|
41
|
+
getTermTypeLookups: () => getTermTypeLookups,
|
|
42
|
+
getWorldSteelMapping: () => getWorldSteelMapping,
|
|
43
|
+
idToIso31662: () => idToIso31662,
|
|
44
|
+
isCoverCrop: () => isCoverCrop,
|
|
45
|
+
isInSystemBoundary: () => isInSystemBoundary,
|
|
46
|
+
iso31662ToId: () => iso31662ToId,
|
|
47
|
+
iso31662ToName: () => iso31662ToName,
|
|
48
|
+
loadResourceKey: () => loadResourceKey,
|
|
49
|
+
termOrder: () => termOrder
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(index_exports);
|
|
52
|
+
var import_arrayTreatment = __toESM(require("./resources/arrayTreatment.json"), 1);
|
|
53
|
+
var import_bafuMapping = __toESM(require("./resources/bafuMapping.json"), 1);
|
|
54
|
+
var import_blankNodesGroup = __toESM(require("./resources/blankNodesGroup.json"), 1);
|
|
55
|
+
var import_defaultModelId = __toESM(require("./resources/defaultModelId.json"), 1);
|
|
56
|
+
var import_ecoalimMapping = __toESM(require("./resources/ecoalimMapping.json"), 1);
|
|
57
|
+
var import_ecoinventMapping = __toESM(require("./resources/ecoinventMapping.json"), 1);
|
|
58
|
+
var import_emission_groupings = __toESM(require("./resources/emission-groupings.json"), 1);
|
|
59
|
+
var import_id_to_iso3166_2 = __toESM(require("./resources/id-to-iso3166-2.json"), 1);
|
|
60
|
+
var import_inHestiaDefaultSystemBoundary = __toESM(require("./resources/inHestiaDefaultSystemBoundary.json"), 1);
|
|
61
|
+
var import_iso3166_2_to_id = __toESM(require("./resources/iso3166-2-to-id.json"), 1);
|
|
62
|
+
var import_iso3166_2_to_name = __toESM(require("./resources/iso3166-2-to-name.json"), 1);
|
|
63
|
+
var import_modelGroups = __toESM(require("./resources/modelGroups.json"), 1);
|
|
64
|
+
var import_term_order = __toESM(require("./resources/term-order.json"), 1);
|
|
65
|
+
var import_term_restrictions = __toESM(require("./resources/term-restrictions.json"), 1);
|
|
66
|
+
var import_termType_lookups = __toESM(require("./resources/termType-lookups.json"), 1);
|
|
67
|
+
var import_worldsteelMapping = __toESM(require("./resources/worldsteelMapping.json"), 1);
|
|
68
|
+
const RESOURCES = {
|
|
69
|
+
"arrayTreatment.json": import_arrayTreatment.default,
|
|
70
|
+
"bafuMapping.json": import_bafuMapping.default,
|
|
71
|
+
"blankNodesGroup.json": import_blankNodesGroup.default,
|
|
72
|
+
"defaultModelId.json": import_defaultModelId.default,
|
|
73
|
+
"ecoalimMapping.json": import_ecoalimMapping.default,
|
|
74
|
+
"ecoinventMapping.json": import_ecoinventMapping.default,
|
|
75
|
+
"emission-groupings.json": import_emission_groupings.default,
|
|
76
|
+
"id-to-iso3166-2.json": import_id_to_iso3166_2.default,
|
|
77
|
+
"inHestiaDefaultSystemBoundary.json": import_inHestiaDefaultSystemBoundary.default,
|
|
78
|
+
"iso3166-2-to-id.json": import_iso3166_2_to_id.default,
|
|
79
|
+
"iso3166-2-to-name.json": import_iso3166_2_to_name.default,
|
|
80
|
+
"modelGroups.json": import_modelGroups.default,
|
|
81
|
+
"term-order.json": import_term_order.default,
|
|
82
|
+
"term-restrictions.json": import_term_restrictions.default,
|
|
83
|
+
"termType-lookups.json": import_termType_lookups.default,
|
|
84
|
+
"worldsteelMapping.json": import_worldsteelMapping.default
|
|
85
|
+
};
|
|
86
|
+
const loadResourceKey = (filename, key) => {
|
|
87
|
+
const resource = RESOURCES[filename];
|
|
88
|
+
return key ? resource?.[key] : resource;
|
|
89
|
+
};
|
|
90
|
+
const iso31662ToName = (code = "") => import_iso3166_2_to_name.default[code.toUpperCase()];
|
|
91
|
+
const iso31662ToId = (code = "") => import_iso3166_2_to_id.default[code.toUpperCase()];
|
|
92
|
+
const idToIso31662 = (id = "") => import_id_to_iso3166_2.default[id.toUpperCase()];
|
|
93
|
+
const getArrayTreatment = (id) => import_arrayTreatment.default[id] || "sum";
|
|
94
|
+
const getDefaultModelId = (id) => import_defaultModelId.default[id];
|
|
95
|
+
const getDefaultModels = () => Object.entries(import_defaultModelId.default).filter(([, value]) => !!value).map(([key]) => key);
|
|
96
|
+
const getTermRestrictions = (id) => import_term_restrictions.default[id];
|
|
97
|
+
const getTermModelRestrictions = (id, modelId) => (import_term_restrictions.default[id] || {})[modelId];
|
|
98
|
+
const getTermTypeLookups = (termType) => import_termType_lookups.default[termType];
|
|
102
99
|
const isInSystemBoundary = (id) => {
|
|
103
|
-
const value =
|
|
100
|
+
const value = import_inHestiaDefaultSystemBoundary.default[id];
|
|
104
101
|
return !value || value === "true";
|
|
105
102
|
};
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const getWorldSteelMapping = (id) =>
|
|
113
|
-
loadResourceKey("worldsteelMapping.json", id);
|
|
114
|
-
|
|
115
|
-
const getBafuMapping = (id) => loadResourceKey("bafuMapping.json", id);
|
|
116
|
-
|
|
117
|
-
const getBlankNodesGroup = (id) => loadResourceKey("blankNodesGroup.json", id);
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Get the groupings for the Emission.
|
|
121
|
-
*
|
|
122
|
-
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
123
|
-
* @returns {object} Different groupings types and values.
|
|
124
|
-
*/
|
|
125
|
-
const getEmissionGroupings = (id) =>
|
|
126
|
-
loadResourceKey("emission-groupings.json", id);
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Determines if the property is identifying a cover crop.
|
|
130
|
-
*
|
|
131
|
-
* @param {*} id The property `@id`
|
|
132
|
-
* @returns `true` if the property represents a cover crop.
|
|
133
|
-
*/
|
|
103
|
+
const getEcoalimMapping = (id) => import_ecoalimMapping.default[id];
|
|
104
|
+
const getEcoinventMapping = (id) => import_ecoinventMapping.default[id];
|
|
105
|
+
const getWorldSteelMapping = (id) => import_worldsteelMapping.default[id];
|
|
106
|
+
const getBafuMapping = (id) => import_bafuMapping.default[id];
|
|
107
|
+
const getBlankNodesGroup = (id) => import_blankNodesGroup.default[id];
|
|
108
|
+
const getEmissionGroupings = (id) => import_emission_groupings.default[id];
|
|
134
109
|
const isCoverCrop = (id) => getBlankNodesGroup(id) === "Cover crops";
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
140
|
-
* @param {string} modelId The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
141
|
-
* @returns {string} The HESTIA term [id](https://hestia.earth/schema/Term#id) of the group.
|
|
142
|
-
*/
|
|
143
|
-
const getModelGroup = (id, modelId) =>
|
|
144
|
-
(loadResourceKey("modelGroups.json", id) || {})[modelId];
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
*
|
|
148
|
-
* @param {object} term The HESTIA term, providing `@id` and/or `termType`.
|
|
149
|
-
* @returns {number|list} The index if searching for a specific Term by `@id`, or the ordered list of ids if search by `termType`.
|
|
150
|
-
*/
|
|
151
|
-
const termOrder = ({ "@id": id, termType }) => {
|
|
152
|
-
const data = loadResource("term-order.json");
|
|
153
|
-
return termType
|
|
154
|
-
? id
|
|
155
|
-
? data[termType].indexOf(id)
|
|
156
|
-
: data[termType]
|
|
157
|
-
: id
|
|
158
|
-
? Object.values(data)
|
|
159
|
-
.find((values) => values.includes(id))
|
|
160
|
-
?.indexOf(id)
|
|
161
|
-
: -1;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
module.exports = {
|
|
165
|
-
loadResourceKey,
|
|
166
|
-
iso31662ToName,
|
|
167
|
-
iso31662ToId,
|
|
168
|
-
idToIso31662,
|
|
110
|
+
const getModelGroup = (id, modelId) => (import_modelGroups.default[id] || {})[modelId];
|
|
111
|
+
const termOrder = ({ "@id": id, termType }) => termType ? id ? import_term_order.default[termType].indexOf(id) : import_term_order.default[termType] : id ? Object.values(import_term_order.default).find((values) => values.includes(id))?.indexOf(id) : -1;
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
169
114
|
getArrayTreatment,
|
|
115
|
+
getBafuMapping,
|
|
116
|
+
getBlankNodesGroup,
|
|
170
117
|
getDefaultModelId,
|
|
171
118
|
getDefaultModels,
|
|
172
|
-
getTermRestrictions,
|
|
173
|
-
getTermModelRestrictions,
|
|
174
|
-
getTermTypeLookups,
|
|
175
|
-
isInSystemBoundary,
|
|
176
119
|
getEcoalimMapping,
|
|
177
120
|
getEcoinventMapping,
|
|
178
|
-
getWorldSteelMapping,
|
|
179
|
-
getBafuMapping,
|
|
180
|
-
getBlankNodesGroup,
|
|
181
121
|
getEmissionGroupings,
|
|
182
|
-
isCoverCrop,
|
|
183
122
|
getModelGroup,
|
|
184
|
-
|
|
185
|
-
|
|
123
|
+
getTermModelRestrictions,
|
|
124
|
+
getTermRestrictions,
|
|
125
|
+
getTermTypeLookups,
|
|
126
|
+
getWorldSteelMapping,
|
|
127
|
+
idToIso31662,
|
|
128
|
+
isCoverCrop,
|
|
129
|
+
isInSystemBoundary,
|
|
130
|
+
iso31662ToId,
|
|
131
|
+
iso31662ToName,
|
|
132
|
+
loadResourceKey,
|
|
133
|
+
termOrder
|
|
134
|
+
});
|
package/index.mjs
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// Tree-shakeable ESM entry point — the single source of truth for the public
|
|
2
|
+
// API. The CommonJS entry (`index.js`, used by Node `require`) is GENERATED from
|
|
3
|
+
// this file by `npm run build:index` (run automatically via the `prepare` hook
|
|
4
|
+
// on install/publish), so edit this file only — never `index.js`.
|
|
5
|
+
//
|
|
6
|
+
// Every resource is imported statically so that bundlers (webpack, rollup,
|
|
7
|
+
// esbuild, …) can statically determine which JSON files each export depends on
|
|
8
|
+
// and drop the rest. Combined with `"sideEffects": false` in package.json, a
|
|
9
|
+
// consumer importing a single getter only pulls in the one resource it needs,
|
|
10
|
+
// instead of the whole `resources/` directory.
|
|
11
|
+
//
|
|
12
|
+
// To add a resource getter: add its static `import` below, the matching
|
|
13
|
+
// `export const`, and (only if it should be reachable via the generic
|
|
14
|
+
// `loadResourceKey`) an entry in the `RESOURCES` map.
|
|
15
|
+
|
|
16
|
+
import arrayTreatment from "./resources/arrayTreatment.json" with { type: "json" };
|
|
17
|
+
import bafuMapping from "./resources/bafuMapping.json" with { type: "json" };
|
|
18
|
+
import blankNodesGroup from "./resources/blankNodesGroup.json" with { type: "json" };
|
|
19
|
+
import defaultModelId from "./resources/defaultModelId.json" with { type: "json" };
|
|
20
|
+
import ecoalimMapping from "./resources/ecoalimMapping.json" with { type: "json" };
|
|
21
|
+
import ecoinventMapping from "./resources/ecoinventMapping.json" with { type: "json" };
|
|
22
|
+
import emissionGroupings from "./resources/emission-groupings.json" with { type: "json" };
|
|
23
|
+
import idToIso31662Map from "./resources/id-to-iso3166-2.json" with { type: "json" };
|
|
24
|
+
import inHestiaDefaultSystemBoundary from "./resources/inHestiaDefaultSystemBoundary.json" with { type: "json" };
|
|
25
|
+
import iso31662ToIdMap from "./resources/iso3166-2-to-id.json" with { type: "json" };
|
|
26
|
+
import iso31662ToNameMap from "./resources/iso3166-2-to-name.json" with { type: "json" };
|
|
27
|
+
import modelGroups from "./resources/modelGroups.json" with { type: "json" };
|
|
28
|
+
import termOrderData from "./resources/term-order.json" with { type: "json" };
|
|
29
|
+
import termRestrictions from "./resources/term-restrictions.json" with { type: "json" };
|
|
30
|
+
import termTypeLookups from "./resources/termType-lookups.json" with { type: "json" };
|
|
31
|
+
import worldsteelMapping from "./resources/worldsteelMapping.json" with { type: "json" };
|
|
32
|
+
|
|
33
|
+
// Map only used by the generic `loadResourceKey`/`loadResource` API below. It is
|
|
34
|
+
// referenced solely by that escape hatch, so bundlers can eliminate it (and the
|
|
35
|
+
// resources only it references) when a consumer never imports those helpers.
|
|
36
|
+
const RESOURCES = {
|
|
37
|
+
"arrayTreatment.json": arrayTreatment,
|
|
38
|
+
"bafuMapping.json": bafuMapping,
|
|
39
|
+
"blankNodesGroup.json": blankNodesGroup,
|
|
40
|
+
"defaultModelId.json": defaultModelId,
|
|
41
|
+
"ecoalimMapping.json": ecoalimMapping,
|
|
42
|
+
"ecoinventMapping.json": ecoinventMapping,
|
|
43
|
+
"emission-groupings.json": emissionGroupings,
|
|
44
|
+
"id-to-iso3166-2.json": idToIso31662Map,
|
|
45
|
+
"inHestiaDefaultSystemBoundary.json": inHestiaDefaultSystemBoundary,
|
|
46
|
+
"iso3166-2-to-id.json": iso31662ToIdMap,
|
|
47
|
+
"iso3166-2-to-name.json": iso31662ToNameMap,
|
|
48
|
+
"modelGroups.json": modelGroups,
|
|
49
|
+
"term-order.json": termOrderData,
|
|
50
|
+
"term-restrictions.json": termRestrictions,
|
|
51
|
+
"termType-lookups.json": termTypeLookups,
|
|
52
|
+
"worldsteelMapping.json": worldsteelMapping,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get a value from a resource by filename.
|
|
57
|
+
*
|
|
58
|
+
* Prefer the dedicated getters below when possible: using this generic helper
|
|
59
|
+
* defeats tree-shaking, as it can reference any bundled resource.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} filename The name of the file containing the resources.
|
|
62
|
+
* @param {string} key The key in the resource file.
|
|
63
|
+
* @returns {any} The data associated with the `key`.
|
|
64
|
+
*/
|
|
65
|
+
export const loadResourceKey = (filename, key) => {
|
|
66
|
+
const resource = RESOURCES[filename];
|
|
67
|
+
return key ? resource?.[key] : resource;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Converts the iso31662 code to the [term.name](https://hestia.earth/schema/Term#name) 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 [name](https://hestia.earth/schema/Term#name).
|
|
75
|
+
*/
|
|
76
|
+
export const iso31662ToName = (code = "") =>
|
|
77
|
+
iso31662ToNameMap[code.toUpperCase()];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Converts the iso31662 code to the [term.id](https://hestia.earth/schema/Term#id) from the HESTIA Glossary.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} code The [iso31662 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
|
|
83
|
+
* @returns {string} The HESTIA country [id](https://hestia.earth/schema/Term#id).
|
|
84
|
+
*/
|
|
85
|
+
export const iso31662ToId = (code = "") => iso31662ToIdMap[code.toUpperCase()];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Converts the [term.id](https://hestia.earth/schema/Term#id) from the HESTIA Glossary to a iso31662 code.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} id The HESTIA country [id](https://hestia.earth/schema/Term#id).
|
|
91
|
+
* @returns {string} The [iso31662 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
|
|
92
|
+
*/
|
|
93
|
+
export const idToIso31662 = (id = "") => idToIso31662Map[id.toUpperCase()];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Determines how an array of values should be handled (if summed up, or averaged, etc.).
|
|
97
|
+
*
|
|
98
|
+
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
99
|
+
* @returns {string} Possible values are: `mean`, `mode` and `sum`.
|
|
100
|
+
*/
|
|
101
|
+
export const getArrayTreatment = (id) => arrayTreatment[id] || "sum";
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the `@id` of the default model that should be used for display of this Term.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
107
|
+
* @returns {string} The `@id` of the model if set.
|
|
108
|
+
*/
|
|
109
|
+
export const getDefaultModelId = (id) => defaultModelId[id];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns the list of `@id` of the default models that should be used for display.
|
|
113
|
+
*
|
|
114
|
+
* @returns {string[]} The list of default `@id`.
|
|
115
|
+
*/
|
|
116
|
+
export const getDefaultModels = () =>
|
|
117
|
+
Object.entries(defaultModelId)
|
|
118
|
+
.filter(([, value]) => !!value)
|
|
119
|
+
.map(([key]) => key);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns the list of restrictions of the Term.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
125
|
+
* @returns A list of restrictions as an object.
|
|
126
|
+
*/
|
|
127
|
+
export const getTermRestrictions = (id) => termRestrictions[id];
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Returns the list of restrictions of the Term/Model mapping.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
133
|
+
* @param {string} modelId The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
134
|
+
* @returns A list of restrictions as an object.
|
|
135
|
+
*/
|
|
136
|
+
export const getTermModelRestrictions = (id, modelId) =>
|
|
137
|
+
(termRestrictions[id] || {})[modelId];
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Returns the list of restrictions of the Term/Model mapping.
|
|
141
|
+
*
|
|
142
|
+
* @param {string} termType The HESTIA term [termType](https://hestia.earth/schema/Term#termType).
|
|
143
|
+
* @returns A list of lookups.
|
|
144
|
+
*/
|
|
145
|
+
export const getTermTypeLookups = (termType) => termTypeLookups[termType];
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Checks whether the emission is in the HESTIA System Boundary.
|
|
149
|
+
*
|
|
150
|
+
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
151
|
+
* @returns {boolean} True if the Term is included.
|
|
152
|
+
*/
|
|
153
|
+
export const isInSystemBoundary = (id) => {
|
|
154
|
+
const value = inHestiaDefaultSystemBoundary[id];
|
|
155
|
+
return !value || value === "true";
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const getEcoalimMapping = (id) => ecoalimMapping[id];
|
|
159
|
+
|
|
160
|
+
export const getEcoinventMapping = (id) => ecoinventMapping[id];
|
|
161
|
+
|
|
162
|
+
export const getWorldSteelMapping = (id) => worldsteelMapping[id];
|
|
163
|
+
|
|
164
|
+
export const getBafuMapping = (id) => bafuMapping[id];
|
|
165
|
+
|
|
166
|
+
export const getBlankNodesGroup = (id) => blankNodesGroup[id];
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Get the groupings for the Emission.
|
|
170
|
+
*
|
|
171
|
+
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
172
|
+
* @returns {object} Different groupings types and values.
|
|
173
|
+
*/
|
|
174
|
+
export const getEmissionGroupings = (id) => emissionGroupings[id];
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Determines if the property is identifying a cover crop.
|
|
178
|
+
*
|
|
179
|
+
* @param {*} id The property `@id`
|
|
180
|
+
* @returns `true` if the property represents a cover crop.
|
|
181
|
+
*/
|
|
182
|
+
export const isCoverCrop = (id) => getBlankNodesGroup(id) === "Cover crops";
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Return the group for this term with a specific model.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
188
|
+
* @param {string} modelId The HESTIA term [id](https://hestia.earth/schema/Term#id).
|
|
189
|
+
* @returns {string} The HESTIA term [id](https://hestia.earth/schema/Term#id) of the group.
|
|
190
|
+
*/
|
|
191
|
+
export const getModelGroup = (id, modelId) => (modelGroups[id] || {})[modelId];
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
*
|
|
195
|
+
* @param {object} term The HESTIA term, providing `@id` and/or `termType`.
|
|
196
|
+
* @returns {number|list} The index if searching for a specific Term by `@id`, or the ordered list of ids if search by `termType`.
|
|
197
|
+
*/
|
|
198
|
+
export const termOrder = ({ "@id": id, termType }) =>
|
|
199
|
+
termType
|
|
200
|
+
? id
|
|
201
|
+
? termOrderData[termType].indexOf(id)
|
|
202
|
+
: termOrderData[termType]
|
|
203
|
+
: id
|
|
204
|
+
? Object.values(termOrderData)
|
|
205
|
+
.find((values) => values.includes(id))
|
|
206
|
+
?.indexOf(id)
|
|
207
|
+
: -1;
|
package/package.json
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hestia-earth/glossary",
|
|
3
|
-
"version": "0.93.
|
|
3
|
+
"version": "0.93.3",
|
|
4
4
|
"description": "HESTIA Earth Glossary library",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"module": "index.mjs",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./index.mjs",
|
|
11
|
+
"require": "./index.js"
|
|
12
|
+
},
|
|
13
|
+
"./resources/*": "./resources/*",
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
"./*.js": "./*.js",
|
|
16
|
+
"./*": "./*"
|
|
17
|
+
},
|
|
6
18
|
"scripts": {
|
|
7
19
|
"gen:impact-assessment": "node scripts/node/generate-impact-assessment-data.js",
|
|
8
20
|
"gen:emission-grouping": "node scripts/node/generate-emission-groupings.js",
|
|
@@ -12,6 +24,8 @@
|
|
|
12
24
|
"gen:term-restrictions": "node scripts/node/generate-term-restrictions.js",
|
|
13
25
|
"gen:termType-lookups": "node scripts/node/generate-termType-lookups.js",
|
|
14
26
|
"generate:all": "npm-run-all --parallel \"gen:*\"",
|
|
27
|
+
"build:index": "esbuild index.mjs --format=cjs --platform=node --outfile=index.js",
|
|
28
|
+
"prepare": "npm run build:index",
|
|
15
29
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
30
|
"release": "standard-version -a",
|
|
17
31
|
"postrelease": "git push origin master --follow-tags"
|
|
@@ -41,6 +55,7 @@
|
|
|
41
55
|
"axios": "^1.2.1",
|
|
42
56
|
"csvtojson": "^2.0.10",
|
|
43
57
|
"dotenv": "^16.0.3",
|
|
58
|
+
"esbuild": "^0.28.1",
|
|
44
59
|
"husky": "^4.2.5",
|
|
45
60
|
"npm-run-all": "^4.1.5",
|
|
46
61
|
"standard-version": "^9.5.0"
|