@zerocarbon/erp-config-sdk 1.0.21 → 1.0.22
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/dist/index.d.ts +42 -2
- package/dist/index.esm.js +56 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34640,6 +34640,61 @@ const getApiIndustryType = (erpIndustry) => {
|
|
|
34640
34640
|
return INDUSTRY_MAPPING[erpIndustry] || "manufacturing";
|
|
34641
34641
|
};
|
|
34642
34642
|
|
|
34643
|
+
const getItemsForUser = async (apiClient, options = {}) => {
|
|
34644
|
+
const params = new URLSearchParams();
|
|
34645
|
+
if (options.industry)
|
|
34646
|
+
params.set("industry", options.industry);
|
|
34647
|
+
const query = params.toString();
|
|
34648
|
+
const data = await apiClient
|
|
34649
|
+
.get(`erp-config/items${query ? `?${query}` : ""}`)
|
|
34650
|
+
.json();
|
|
34651
|
+
return data.items || [];
|
|
34652
|
+
};
|
|
34653
|
+
const addItemForUser = async (apiClient, options) => {
|
|
34654
|
+
const data = await apiClient
|
|
34655
|
+
.post("erp-config/items/bulk", {
|
|
34656
|
+
json: {
|
|
34657
|
+
industry: options.industry,
|
|
34658
|
+
scope: options.scope,
|
|
34659
|
+
category: options.category,
|
|
34660
|
+
source: "bulk-upload-review",
|
|
34661
|
+
items: options.items,
|
|
34662
|
+
},
|
|
34663
|
+
})
|
|
34664
|
+
.json();
|
|
34665
|
+
return data.items || [];
|
|
34666
|
+
};
|
|
34667
|
+
const mergeUserItemsIntoIndustryConfig = (baseConfig, userItems = []) => {
|
|
34668
|
+
const config = JSON.parse(JSON.stringify(baseConfig));
|
|
34669
|
+
for (const item of userItems) {
|
|
34670
|
+
if (item.scope === "scope3") {
|
|
34671
|
+
const scope = config.scope3.find((entry) => entry.name === item.category);
|
|
34672
|
+
const group = scope === null || scope === void 0 ? void 0 : scope.subProducts.find((entry) => entry.category === item.subCategory);
|
|
34673
|
+
if (group && !group.items.some((entry) => entry.item === item.itemName)) {
|
|
34674
|
+
group.items.push({
|
|
34675
|
+
item: item.itemName,
|
|
34676
|
+
unit: item.unit,
|
|
34677
|
+
emissionFactor: item.emissionFactor,
|
|
34678
|
+
requiresMassData: item.requiresMassData,
|
|
34679
|
+
});
|
|
34680
|
+
}
|
|
34681
|
+
continue;
|
|
34682
|
+
}
|
|
34683
|
+
const scopeList = item.scope === "scope2" ? config.scope2 : config.scope1;
|
|
34684
|
+
const scope = scopeList.find((entry) => entry.name === item.category);
|
|
34685
|
+
if (scope && !scope.subProducts.some((entry) => entry.name === item.itemName)) {
|
|
34686
|
+
scope.subProducts.push({
|
|
34687
|
+
name: item.itemName,
|
|
34688
|
+
type: item.subCategory,
|
|
34689
|
+
unit: item.unit,
|
|
34690
|
+
emissionFactor: item.emissionFactor,
|
|
34691
|
+
calorificValue: 0,
|
|
34692
|
+
});
|
|
34693
|
+
}
|
|
34694
|
+
}
|
|
34695
|
+
return config;
|
|
34696
|
+
};
|
|
34697
|
+
|
|
34643
34698
|
// Scope 3 categories configuration for cement industry using API data
|
|
34644
34699
|
const API_SCOPE3_CEMENT_CONFIG = [
|
|
34645
34700
|
{
|
|
@@ -40168,6 +40223,7 @@ exports.ISO_CATEGORIES_PACKAGING = ISO_CATEGORIES_PACKAGING;
|
|
|
40168
40223
|
exports.Industries = index;
|
|
40169
40224
|
exports.UI_FEATURES = UI_FEATURES;
|
|
40170
40225
|
exports.WATER_PRODUCTS = WATER_PRODUCTS$1;
|
|
40226
|
+
exports.addItemForUser = addItemForUser;
|
|
40171
40227
|
exports.calculateCCTSEmission = calculateCCTSEmission;
|
|
40172
40228
|
exports.calculateIntensityMetrics = calculateIntensityMetrics;
|
|
40173
40229
|
exports.categorizeApiItem = categorizeApiItem;
|
|
@@ -40191,6 +40247,7 @@ exports.getIndustryBackendConfig = getIndustryBackendConfig;
|
|
|
40191
40247
|
exports.getIndustryConfig = getIndustryConfig;
|
|
40192
40248
|
exports.getIndustryFieldConfig = getIndustryFieldConfig;
|
|
40193
40249
|
exports.getIntensityFormulas = getIntensityFormulas;
|
|
40250
|
+
exports.getItemsForUser = getItemsForUser;
|
|
40194
40251
|
exports.getPlantNameConfig = getPlantNameConfig;
|
|
40195
40252
|
exports.getRCOConfigByName = getRCOConfigByName;
|
|
40196
40253
|
exports.getScope3ConfigByName = getScope3ConfigByName;
|
|
@@ -40199,6 +40256,7 @@ exports.getUserNameScopeConfig = getUserNameScopeConfig;
|
|
|
40199
40256
|
exports.hasIntensities = hasIntensities;
|
|
40200
40257
|
exports.isUIFeatureEnabled = isUIFeatureEnabled;
|
|
40201
40258
|
exports.mapIndustryToApiType = mapIndustryToApiType;
|
|
40259
|
+
exports.mergeUserItemsIntoIndustryConfig = mergeUserItemsIntoIndustryConfig;
|
|
40202
40260
|
exports.sanitizeNumber = sanitizeNumber;
|
|
40203
40261
|
exports.supportsIntensityCalculations = supportsIntensityCalculations;
|
|
40204
40262
|
exports.validateCarbonIntensityData = validateCarbonIntensityData;
|