@hestia-earth/glossary 0.104.0 → 0.106.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 +10 -0
- package/index.mjs +12 -0
- package/package.json +2 -1
- package/resources/arrayTreatment.json +1 -1
- package/resources/bafuMapping.json +1 -1
- package/resources/defaultModelId.json +1 -1
- package/resources/ecoinventMapping.json +1 -1
- package/resources/impactAssessment.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/uniqueUseGroups.json +1 -0
package/index.js
CHANGED
|
@@ -43,6 +43,7 @@ __export(index_exports, {
|
|
|
43
43
|
getTermModelRestrictions: () => getTermModelRestrictions,
|
|
44
44
|
getTermRestrictions: () => getTermRestrictions,
|
|
45
45
|
getTermTypeLookups: () => getTermTypeLookups,
|
|
46
|
+
getUniqueUseGroupTerms: () => getUniqueUseGroupTerms,
|
|
46
47
|
getWorldSteelMapping: () => getWorldSteelMapping,
|
|
47
48
|
idToIso31662: () => idToIso31662,
|
|
48
49
|
isBackgroundEmission: () => isBackgroundEmission,
|
|
@@ -74,6 +75,7 @@ var import_modelGroups = __toESM(require("./resources/modelGroups.json"), 1);
|
|
|
74
75
|
var import_term_order = __toESM(require("./resources/term-order.json"), 1);
|
|
75
76
|
var import_term_restrictions = __toESM(require("./resources/term-restrictions.json"), 1);
|
|
76
77
|
var import_termType_lookups = __toESM(require("./resources/termType-lookups.json"), 1);
|
|
78
|
+
var import_uniqueUseGroups = __toESM(require("./resources/uniqueUseGroups.json"), 1);
|
|
77
79
|
var import_worldsteelMapping = __toESM(require("./resources/worldsteelMapping.json"), 1);
|
|
78
80
|
const RESOURCES = {
|
|
79
81
|
"arrayTreatment.json": import_arrayTreatment.default,
|
|
@@ -95,6 +97,7 @@ const RESOURCES = {
|
|
|
95
97
|
"term-order.json": import_term_order.default,
|
|
96
98
|
"term-restrictions.json": import_term_restrictions.default,
|
|
97
99
|
"termType-lookups.json": import_termType_lookups.default,
|
|
100
|
+
"uniqueUseGroups.json": import_uniqueUseGroups.default,
|
|
98
101
|
"worldsteelMapping.json": import_worldsteelMapping.default
|
|
99
102
|
};
|
|
100
103
|
const loadResourceKey = (filename, key) => {
|
|
@@ -110,6 +113,12 @@ const getDefaultModels = () => Object.entries(import_defaultModelId.default).fil
|
|
|
110
113
|
const getTermRestrictions = (id) => import_term_restrictions.default[id];
|
|
111
114
|
const getTermModelRestrictions = (id, modelId) => (import_term_restrictions.default[id] || {})[modelId];
|
|
112
115
|
const getTermTypeLookups = (termType) => import_termType_lookups.default[termType];
|
|
116
|
+
const uniqueUseGroupTerms = Object.fromEntries(
|
|
117
|
+
Object.values(import_uniqueUseGroups.default).flatMap(
|
|
118
|
+
(terms) => terms.map((term) => [term["@id"], terms])
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
const getUniqueUseGroupTerms = (id) => uniqueUseGroupTerms[id] ?? [];
|
|
113
122
|
const isInSystemBoundary = (id) => {
|
|
114
123
|
const value = import_inHestiaDefaultSystemBoundary.default[id];
|
|
115
124
|
return !value || value === "true";
|
|
@@ -157,6 +166,7 @@ const termOrder = ({ "@id": id, termType }) => termType ? id ? import_term_order
|
|
|
157
166
|
getTermModelRestrictions,
|
|
158
167
|
getTermRestrictions,
|
|
159
168
|
getTermTypeLookups,
|
|
169
|
+
getUniqueUseGroupTerms,
|
|
160
170
|
getWorldSteelMapping,
|
|
161
171
|
idToIso31662,
|
|
162
172
|
isBackgroundEmission,
|
package/index.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import modelGroups from "./resources/modelGroups.json" with { type: "json" };
|
|
|
17
17
|
import termOrderData from "./resources/term-order.json" with { type: "json" };
|
|
18
18
|
import termRestrictions from "./resources/term-restrictions.json" with { type: "json" };
|
|
19
19
|
import termTypeLookups from "./resources/termType-lookups.json" with { type: "json" };
|
|
20
|
+
import uniqueUseGroups from "./resources/uniqueUseGroups.json" with { type: "json" };
|
|
20
21
|
import worldsteelMapping from "./resources/worldsteelMapping.json" with { type: "json" };
|
|
21
22
|
|
|
22
23
|
// Map only used by the generic `loadResourceKey`/`loadResource` API below. It is
|
|
@@ -42,6 +43,7 @@ const RESOURCES = {
|
|
|
42
43
|
"term-order.json": termOrderData,
|
|
43
44
|
"term-restrictions.json": termRestrictions,
|
|
44
45
|
"termType-lookups.json": termTypeLookups,
|
|
46
|
+
"uniqueUseGroups.json": uniqueUseGroups,
|
|
45
47
|
"worldsteelMapping.json": worldsteelMapping,
|
|
46
48
|
};
|
|
47
49
|
|
|
@@ -81,6 +83,16 @@ export const getTermModelRestrictions = (id, modelId) =>
|
|
|
81
83
|
|
|
82
84
|
export const getTermTypeLookups = (termType) => termTypeLookups[termType];
|
|
83
85
|
|
|
86
|
+
// built once, so repeated lookups do not scan every group
|
|
87
|
+
const uniqueUseGroupTerms = Object.fromEntries(
|
|
88
|
+
Object.values(uniqueUseGroups).flatMap((terms) =>
|
|
89
|
+
terms.map((term) => [term["@id"], terms]),
|
|
90
|
+
),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
/** The Terms sharing the Term's `uniqueUseGroup`, itself included, with their `name` and `units`. */
|
|
94
|
+
export const getUniqueUseGroupTerms = (id) => uniqueUseGroupTerms[id] ?? [];
|
|
95
|
+
|
|
84
96
|
/** A Term with no `inHestiaDefaultSystemBoundary` value counts as in the boundary. */
|
|
85
97
|
export const isInSystemBoundary = (id) => {
|
|
86
98
|
const value = inHestiaDefaultSystemBoundary[id];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hestia-earth/glossary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.106.0",
|
|
4
4
|
"description": "HESTIA Earth Glossary library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"gen:term-order": "node scripts/node/generate-term-order.js",
|
|
30
30
|
"gen:term-restrictions": "node scripts/node/generate-term-restrictions.js",
|
|
31
31
|
"gen:termType-lookups": "node scripts/node/generate-termType-lookups.js",
|
|
32
|
+
"gen:unique-use-groups": "node scripts/node/generate-unique-use-groups.js",
|
|
32
33
|
"generate:all": "npm-run-all --parallel \"gen:*\"",
|
|
33
34
|
"build:index": "esbuild index.mjs --format=cjs --platform=node --outfile=index.js",
|
|
34
35
|
"prepare": "npm run build:index",
|