@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.d.ts
CHANGED
|
@@ -1209,6 +1209,46 @@ declare const createEmissionSourceGenerator: (billManager: BillManager) => Emiss
|
|
|
1209
1209
|
declare const INDUSTRY_MAPPING: Record<string, IndustryType>;
|
|
1210
1210
|
declare const getApiIndustryType: (erpIndustry: string) => IndustryType;
|
|
1211
1211
|
|
|
1212
|
+
type JsonResponse<T> = {
|
|
1213
|
+
json: () => Promise<T>;
|
|
1214
|
+
};
|
|
1215
|
+
type UserConfigApiClient = {
|
|
1216
|
+
get: <T = any>(path: string) => JsonResponse<T>;
|
|
1217
|
+
post: <T = any>(path: string, options: {
|
|
1218
|
+
json: unknown;
|
|
1219
|
+
}) => JsonResponse<T>;
|
|
1220
|
+
};
|
|
1221
|
+
type UserConfigItem = {
|
|
1222
|
+
id?: string;
|
|
1223
|
+
industry: string;
|
|
1224
|
+
scope: "scope1" | "scope2" | "scope3" | string;
|
|
1225
|
+
category: string;
|
|
1226
|
+
subCategory: string;
|
|
1227
|
+
itemName: string;
|
|
1228
|
+
unit: string;
|
|
1229
|
+
emissionFactor: number;
|
|
1230
|
+
emissionFactorSource?: {
|
|
1231
|
+
name?: string;
|
|
1232
|
+
url?: string;
|
|
1233
|
+
unit?: string;
|
|
1234
|
+
confidence?: number;
|
|
1235
|
+
notes?: string;
|
|
1236
|
+
};
|
|
1237
|
+
requiresMassData?: boolean;
|
|
1238
|
+
aliases?: string[];
|
|
1239
|
+
source?: string;
|
|
1240
|
+
};
|
|
1241
|
+
declare const getItemsForUser: (apiClient: UserConfigApiClient, options?: {
|
|
1242
|
+
industry?: string;
|
|
1243
|
+
}) => Promise<UserConfigItem[]>;
|
|
1244
|
+
declare const addItemForUser: (apiClient: UserConfigApiClient, options: {
|
|
1245
|
+
industry: string;
|
|
1246
|
+
scope: string;
|
|
1247
|
+
category: string;
|
|
1248
|
+
items: Partial<UserConfigItem>[];
|
|
1249
|
+
}) => Promise<UserConfigItem[]>;
|
|
1250
|
+
declare const mergeUserItemsIntoIndustryConfig: <T extends BackendIndustryConfig>(baseConfig: T, userItems?: UserConfigItem[]) => T;
|
|
1251
|
+
|
|
1212
1252
|
interface MappingRules {
|
|
1213
1253
|
includeIfCategoryContains?: string[];
|
|
1214
1254
|
includeIfSubCategoryContains?: string[];
|
|
@@ -4208,5 +4248,5 @@ declare namespace index {
|
|
|
4208
4248
|
};
|
|
4209
4249
|
}
|
|
4210
4250
|
|
|
4211
|
-
export { ALL_SCOPES_3_RCO, API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getAllConfig, getApiIndustryType, getAvailableFieldsForIndustry, getCombinedBackendConfig, getIndustryBackendConfig, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getPlantNameConfig, getRCOConfigByName, getScope3ConfigByName, getUserNameBackendConfig, getUserNameScopeConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, sanitizeNumber, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
4212
|
-
export type { AllConfigurations, AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BackendAdditionalScopeItem, BackendEmissionItem, BackendEmissions, BackendEquipmentCategory, BackendIndustries, BackendIndustryConfig, BackendProduct, BackendScope, BackendScope3Item, BackendUserConfig, BackendUserConfigs, BaseRequest, BaseResponse, Bill, BillCalculationConfig, BillFilterOptions, BillMatchingConfig, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, BillsAnalyzed$1 as CarbonIntensityBillsAnalyzed, Calculations$1 as CarbonIntensityCalculations, EmissionData$2 as CarbonIntensityEmissionData, ErrorResponse$1 as CarbonIntensityErrorResponse, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, DetailedCarbonIntensityResponse, EditableItem, EmissionData$3 as EmissionData, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FieldConfig, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, FrontendIndustryConfig, HospitalityRequest, HospitalityResponse, IndustryConfig$1 as IndustryConfig, EmissionData as IndustryEmissionData, IndustryFieldConfig, IndustryFieldSection, ProductionData as IndustryProductionData, IndustryType, IntensityCalculation, IntensityValue, LogisticsRequest, LogisticsResponse, ManufacturingRequest, ManufacturingResponse, Meta, MetalEnergyRequest, MetalEnergyResponse, PackagingRequest, PackagingResponse, Pagination, PetrochemicalRequest, PetrochemicalResponse, PharmaRequest, PharmaResponse, PlantNameConfig, ProcessedEmissionCategory, ProcessedEmissionItem, ProcessedScope3Data, RealEstateRequest, RealEstateResponse, BillsAnalyzed as ResponseBillsAnalyzed, Calculations as ResponseCalculations, EmissionData$1 as ResponseEmissionData, ErrorResponse as ResponseErrorResponse, ScopeConfig, ScopeProduct, ShippingRequest, ShippingResponse, SteelRequest, SteelResponse, StrapiItem, StrapiResponse, TelecommunicationRequest, TelecommunicationResponse, TextileRequest, TextileResponse, TransportationEmission, TransportationEmissionAttributes, TransportationEmissionsResponse, UserData, UtilitiesRequest, UtilitiesResponse, ValidationError, VehicleEmission, VehicleEmissionAttributes, VehicleEmissionsResponse };
|
|
4251
|
+
export { ALL_SCOPES_3_RCO, API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS, addItemForUser, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getAllConfig, getApiIndustryType, getAvailableFieldsForIndustry, getCombinedBackendConfig, getIndustryBackendConfig, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getItemsForUser, getPlantNameConfig, getRCOConfigByName, getScope3ConfigByName, getUserNameBackendConfig, getUserNameScopeConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, mergeUserItemsIntoIndustryConfig, sanitizeNumber, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
4252
|
+
export type { AllConfigurations, AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BackendAdditionalScopeItem, BackendEmissionItem, BackendEmissions, BackendEquipmentCategory, BackendIndustries, BackendIndustryConfig, BackendProduct, BackendScope, BackendScope3Item, BackendUserConfig, BackendUserConfigs, BaseRequest, BaseResponse, Bill, BillCalculationConfig, BillFilterOptions, BillMatchingConfig, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, BillsAnalyzed$1 as CarbonIntensityBillsAnalyzed, Calculations$1 as CarbonIntensityCalculations, EmissionData$2 as CarbonIntensityEmissionData, ErrorResponse$1 as CarbonIntensityErrorResponse, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, DetailedCarbonIntensityResponse, EditableItem, EmissionData$3 as EmissionData, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FieldConfig, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, FrontendIndustryConfig, HospitalityRequest, HospitalityResponse, IndustryConfig$1 as IndustryConfig, EmissionData as IndustryEmissionData, IndustryFieldConfig, IndustryFieldSection, ProductionData as IndustryProductionData, IndustryType, IntensityCalculation, IntensityValue, LogisticsRequest, LogisticsResponse, ManufacturingRequest, ManufacturingResponse, Meta, MetalEnergyRequest, MetalEnergyResponse, PackagingRequest, PackagingResponse, Pagination, PetrochemicalRequest, PetrochemicalResponse, PharmaRequest, PharmaResponse, PlantNameConfig, ProcessedEmissionCategory, ProcessedEmissionItem, ProcessedScope3Data, RealEstateRequest, RealEstateResponse, BillsAnalyzed as ResponseBillsAnalyzed, Calculations as ResponseCalculations, EmissionData$1 as ResponseEmissionData, ErrorResponse as ResponseErrorResponse, ScopeConfig, ScopeProduct, ShippingRequest, ShippingResponse, SteelRequest, SteelResponse, StrapiItem, StrapiResponse, TelecommunicationRequest, TelecommunicationResponse, TextileRequest, TextileResponse, TransportationEmission, TransportationEmissionAttributes, TransportationEmissionsResponse, UserConfigApiClient, UserConfigItem, UserData, UtilitiesRequest, UtilitiesResponse, ValidationError, VehicleEmission, VehicleEmissionAttributes, VehicleEmissionsResponse };
|
package/dist/index.esm.js
CHANGED
|
@@ -34638,6 +34638,61 @@ const getApiIndustryType = (erpIndustry) => {
|
|
|
34638
34638
|
return INDUSTRY_MAPPING[erpIndustry] || "manufacturing";
|
|
34639
34639
|
};
|
|
34640
34640
|
|
|
34641
|
+
const getItemsForUser = async (apiClient, options = {}) => {
|
|
34642
|
+
const params = new URLSearchParams();
|
|
34643
|
+
if (options.industry)
|
|
34644
|
+
params.set("industry", options.industry);
|
|
34645
|
+
const query = params.toString();
|
|
34646
|
+
const data = await apiClient
|
|
34647
|
+
.get(`erp-config/items${query ? `?${query}` : ""}`)
|
|
34648
|
+
.json();
|
|
34649
|
+
return data.items || [];
|
|
34650
|
+
};
|
|
34651
|
+
const addItemForUser = async (apiClient, options) => {
|
|
34652
|
+
const data = await apiClient
|
|
34653
|
+
.post("erp-config/items/bulk", {
|
|
34654
|
+
json: {
|
|
34655
|
+
industry: options.industry,
|
|
34656
|
+
scope: options.scope,
|
|
34657
|
+
category: options.category,
|
|
34658
|
+
source: "bulk-upload-review",
|
|
34659
|
+
items: options.items,
|
|
34660
|
+
},
|
|
34661
|
+
})
|
|
34662
|
+
.json();
|
|
34663
|
+
return data.items || [];
|
|
34664
|
+
};
|
|
34665
|
+
const mergeUserItemsIntoIndustryConfig = (baseConfig, userItems = []) => {
|
|
34666
|
+
const config = JSON.parse(JSON.stringify(baseConfig));
|
|
34667
|
+
for (const item of userItems) {
|
|
34668
|
+
if (item.scope === "scope3") {
|
|
34669
|
+
const scope = config.scope3.find((entry) => entry.name === item.category);
|
|
34670
|
+
const group = scope === null || scope === void 0 ? void 0 : scope.subProducts.find((entry) => entry.category === item.subCategory);
|
|
34671
|
+
if (group && !group.items.some((entry) => entry.item === item.itemName)) {
|
|
34672
|
+
group.items.push({
|
|
34673
|
+
item: item.itemName,
|
|
34674
|
+
unit: item.unit,
|
|
34675
|
+
emissionFactor: item.emissionFactor,
|
|
34676
|
+
requiresMassData: item.requiresMassData,
|
|
34677
|
+
});
|
|
34678
|
+
}
|
|
34679
|
+
continue;
|
|
34680
|
+
}
|
|
34681
|
+
const scopeList = item.scope === "scope2" ? config.scope2 : config.scope1;
|
|
34682
|
+
const scope = scopeList.find((entry) => entry.name === item.category);
|
|
34683
|
+
if (scope && !scope.subProducts.some((entry) => entry.name === item.itemName)) {
|
|
34684
|
+
scope.subProducts.push({
|
|
34685
|
+
name: item.itemName,
|
|
34686
|
+
type: item.subCategory,
|
|
34687
|
+
unit: item.unit,
|
|
34688
|
+
emissionFactor: item.emissionFactor,
|
|
34689
|
+
calorificValue: 0,
|
|
34690
|
+
});
|
|
34691
|
+
}
|
|
34692
|
+
}
|
|
34693
|
+
return config;
|
|
34694
|
+
};
|
|
34695
|
+
|
|
34641
34696
|
// Scope 3 categories configuration for cement industry using API data
|
|
34642
34697
|
const API_SCOPE3_CEMENT_CONFIG = [
|
|
34643
34698
|
{
|
|
@@ -40135,5 +40190,5 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
40135
40190
|
getRCOConfigByName: getRCOConfigByName
|
|
40136
40191
|
});
|
|
40137
40192
|
|
|
40138
|
-
export { ALL_SCOPES_3_RCO, API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS$1 as WATER_PRODUCTS, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getAllConfig, getApiIndustryType, getAvailableFieldsForIndustry, getCombinedBackendConfig, getIndustryBackendConfig, getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getPlantNameConfig, getRCOConfigByName, getScope3ConfigByName, getUserNameBackendConfig, getUserNameScopeConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, sanitizeNumber, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
40193
|
+
export { ALL_SCOPES_3_RCO, API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS$1 as WATER_PRODUCTS, addItemForUser, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getAllConfig, getApiIndustryType, getAvailableFieldsForIndustry, getCombinedBackendConfig, getIndustryBackendConfig, getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getItemsForUser, getPlantNameConfig, getRCOConfigByName, getScope3ConfigByName, getUserNameBackendConfig, getUserNameScopeConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, mergeUserItemsIntoIndustryConfig, sanitizeNumber, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
40139
40194
|
//# sourceMappingURL=index.esm.js.map
|