@zerocarbon/erp-config-sdk 1.0.12 → 1.0.13
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 +40 -24
- package/dist/index.esm.js +79 -79
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +79 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -186,6 +186,7 @@ interface Pagination {
|
|
|
186
186
|
}
|
|
187
187
|
type BusinessTravelEmission = StrapiItem<BusinessTravelEmissionAttributes>;
|
|
188
188
|
type TransportationEmission = StrapiItem<TransportationEmissionAttributes>;
|
|
189
|
+
type EmissionData$3 = StrapiItem<EmissionsDataAttributes>;
|
|
189
190
|
type VehicleEmission = StrapiItem<VehicleEmissionAttributes>;
|
|
190
191
|
interface ProcessedScope3Data {
|
|
191
192
|
name: string;
|
|
@@ -207,6 +208,10 @@ interface BaseRequest {
|
|
|
207
208
|
month?: number;
|
|
208
209
|
plant?: string;
|
|
209
210
|
}
|
|
211
|
+
interface EmissionData$2 {
|
|
212
|
+
value: number;
|
|
213
|
+
bills: number;
|
|
214
|
+
}
|
|
210
215
|
interface Emissions$j {
|
|
211
216
|
scope1: number;
|
|
212
217
|
scope2: number;
|
|
@@ -324,7 +329,7 @@ interface CarbonIntensityResponse {
|
|
|
324
329
|
units: Record<string, string>;
|
|
325
330
|
calculations: Calculations$1;
|
|
326
331
|
}
|
|
327
|
-
interface ErrorResponse {
|
|
332
|
+
interface ErrorResponse$1 {
|
|
328
333
|
success: false;
|
|
329
334
|
message: string;
|
|
330
335
|
data?: {
|
|
@@ -341,7 +346,7 @@ interface ErrorResponse {
|
|
|
341
346
|
error?: string;
|
|
342
347
|
}
|
|
343
348
|
type IndustryType = "steel" | "pharma" | "chemical" | "aluminium" | "alloy" | "textile" | "automobile" | "aviation" | "shipping" | "food_beverages" | "hospitality" | "logistics" | "manufacturing" | "metal_energy" | "packaging" | "petrochemical" | "real_estate" | "telecommunication" | "utilities";
|
|
344
|
-
type ApiResponse<T = CarbonIntensityResponse> = T | ErrorResponse;
|
|
349
|
+
type ApiResponse<T = CarbonIntensityResponse> = T | ErrorResponse$1;
|
|
345
350
|
interface FormData {
|
|
346
351
|
industryType: IndustryType;
|
|
347
352
|
year: number;
|
|
@@ -881,6 +886,17 @@ interface UtilitiesResponse extends BaseResponse {
|
|
|
881
886
|
};
|
|
882
887
|
}
|
|
883
888
|
type DetailedCarbonIntensityResponse = SteelResponse | PharmaResponse | ChemicalResponse | AluminiumResponse | AlloyResponse | TextileResponse | AutomobileResponse | AviationResponse | ShippingResponse | FoodBeveragesResponse | HospitalityResponse | LogisticsResponse | ManufacturingResponse | MetalEnergyResponse | PackagingResponse | PetrochemicalResponse | RealEstateResponse | TelecommunicationResponse | UtilitiesResponse;
|
|
889
|
+
interface ErrorResponse {
|
|
890
|
+
success: false;
|
|
891
|
+
message: string;
|
|
892
|
+
data?: {
|
|
893
|
+
year?: number;
|
|
894
|
+
month?: number | null;
|
|
895
|
+
plant?: string | null;
|
|
896
|
+
billsFound?: BillsAnalyzed;
|
|
897
|
+
};
|
|
898
|
+
error?: string;
|
|
899
|
+
}
|
|
884
900
|
declare function hasIntensities(response: any): response is DetailedCarbonIntensityResponse;
|
|
885
901
|
declare const INTENSITY_FIELD_LABELS: Record<string, string>;
|
|
886
902
|
|
|
@@ -951,27 +967,6 @@ type Scope3Item$2 = {
|
|
|
951
967
|
desc: string;
|
|
952
968
|
};
|
|
953
969
|
|
|
954
|
-
/**
|
|
955
|
-
* Format emission values to handle small numbers properly while keeping UI clean
|
|
956
|
-
*/
|
|
957
|
-
declare const formatEmissionValue: (value: number, options?: {
|
|
958
|
-
unit?: string;
|
|
959
|
-
showUnit?: boolean;
|
|
960
|
-
forceDecimals?: number;
|
|
961
|
-
}) => string;
|
|
962
|
-
/**
|
|
963
|
-
* Format emission values specifically for monthly display (show small values properly)
|
|
964
|
-
*/
|
|
965
|
-
declare const formatMonthlyEmission: (value: number) => string;
|
|
966
|
-
/**
|
|
967
|
-
* Format percentage values
|
|
968
|
-
*/
|
|
969
|
-
declare const formatPercentage: (value: number) => string;
|
|
970
|
-
/**
|
|
971
|
-
* Format large emission values for KPI cards
|
|
972
|
-
*/
|
|
973
|
-
declare const formatKPIEmission: (value: number) => string;
|
|
974
|
-
|
|
975
970
|
interface BillFilterOptions {
|
|
976
971
|
category?: string;
|
|
977
972
|
year?: number;
|
|
@@ -1020,6 +1015,27 @@ declare const sanitizeNumber: (value: any) => number;
|
|
|
1020
1015
|
declare const cleanValue: (value: any) => string;
|
|
1021
1016
|
declare const createBillManager: (bills: Bill[], matchingConfig?: BillMatchingConfig) => BillManager;
|
|
1022
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* Format emission values to handle small numbers properly while keeping UI clean
|
|
1020
|
+
*/
|
|
1021
|
+
declare const formatEmissionValue: (value: number, options?: {
|
|
1022
|
+
unit?: string;
|
|
1023
|
+
showUnit?: boolean;
|
|
1024
|
+
forceDecimals?: number;
|
|
1025
|
+
}) => string;
|
|
1026
|
+
/**
|
|
1027
|
+
* Format emission values specifically for monthly display (show small values properly)
|
|
1028
|
+
*/
|
|
1029
|
+
declare const formatMonthlyEmission: (value: number) => string;
|
|
1030
|
+
/**
|
|
1031
|
+
* Format percentage values
|
|
1032
|
+
*/
|
|
1033
|
+
declare const formatPercentage: (value: number) => string;
|
|
1034
|
+
/**
|
|
1035
|
+
* Format large emission values for KPI cards
|
|
1036
|
+
*/
|
|
1037
|
+
declare const formatKPIEmission: (value: number) => string;
|
|
1038
|
+
|
|
1023
1039
|
interface EmissionSource {
|
|
1024
1040
|
id: string;
|
|
1025
1041
|
itemName: string;
|
|
@@ -4009,4 +4025,4 @@ declare namespace index {
|
|
|
4009
4025
|
}
|
|
4010
4026
|
|
|
4011
4027
|
export { 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, getApiIndustryType, getAvailableFieldsForIndustry, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, sanitizeNumber, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
4012
|
-
export type { AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BaseRequest, BaseResponse, Bill, BillCalculationConfig, BillFilterOptions, BillMatchingConfig, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, DetailedCarbonIntensityResponse, EditableItem, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FieldConfig, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, FrontendIndustryConfig, HospitalityRequest, HospitalityResponse, 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, ScopeConfig, ScopeProduct, ShippingRequest, ShippingResponse, SteelRequest, SteelResponse, StrapiItem, StrapiResponse, TelecommunicationRequest, TelecommunicationResponse, TextileRequest, TextileResponse, TransportationEmission, TransportationEmissionAttributes, TransportationEmissionsResponse, UserData, UtilitiesRequest, UtilitiesResponse, ValidationError, VehicleEmission, VehicleEmissionAttributes, VehicleEmissionsResponse };
|
|
4028
|
+
export type { AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, 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, 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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -34580,85 +34580,6 @@ const getIndustryConfig = (industry, username) => {
|
|
|
34580
34580
|
return defaultConfig;
|
|
34581
34581
|
};
|
|
34582
34582
|
|
|
34583
|
-
/**
|
|
34584
|
-
* Format emission values to handle small numbers properly while keeping UI clean
|
|
34585
|
-
*/
|
|
34586
|
-
const formatEmissionValue = (value, options) => {
|
|
34587
|
-
const { unit = "tonne CO₂e", showUnit = false, forceDecimals, } = options || {};
|
|
34588
|
-
if (value === 0)
|
|
34589
|
-
return showUnit ? `0 ${unit}` : "0";
|
|
34590
|
-
let formatted;
|
|
34591
|
-
if (forceDecimals !== undefined) {
|
|
34592
|
-
formatted = value.toFixed(forceDecimals);
|
|
34593
|
-
}
|
|
34594
|
-
else if (value >= 1000) {
|
|
34595
|
-
// Large values: show 1 decimal place
|
|
34596
|
-
formatted = value.toFixed(1);
|
|
34597
|
-
}
|
|
34598
|
-
else if (value >= 10) {
|
|
34599
|
-
// Medium values: show 1 decimal place
|
|
34600
|
-
formatted = value.toFixed(1);
|
|
34601
|
-
}
|
|
34602
|
-
else if (value >= 1) {
|
|
34603
|
-
// Values between 1-10: show 2 decimal places
|
|
34604
|
-
formatted = value.toFixed(2);
|
|
34605
|
-
}
|
|
34606
|
-
else if (value >= 0.01) {
|
|
34607
|
-
// Small values: show 3 decimal places
|
|
34608
|
-
formatted = value.toFixed(3);
|
|
34609
|
-
}
|
|
34610
|
-
else if (value >= 0.001) {
|
|
34611
|
-
// Very small values: show 5 decimal places to preserve precision
|
|
34612
|
-
formatted = value.toFixed(5);
|
|
34613
|
-
}
|
|
34614
|
-
else {
|
|
34615
|
-
// Extremely small values: show 6 decimal places
|
|
34616
|
-
formatted = value.toFixed(6);
|
|
34617
|
-
}
|
|
34618
|
-
// Remove trailing zeros after decimal point
|
|
34619
|
-
formatted = formatted.replace(/\.?0+$/, "");
|
|
34620
|
-
return showUnit ? `${formatted} ${unit}` : formatted;
|
|
34621
|
-
};
|
|
34622
|
-
/**
|
|
34623
|
-
* Format emission values specifically for monthly display (show small values properly)
|
|
34624
|
-
*/
|
|
34625
|
-
const formatMonthlyEmission = (value) => {
|
|
34626
|
-
if (value === 0)
|
|
34627
|
-
return "0";
|
|
34628
|
-
// Format with maximum 5 decimal places, removing trailing zeros
|
|
34629
|
-
const formatted = value.toFixed(5).replace(/\.?0+$/, "");
|
|
34630
|
-
return formatted;
|
|
34631
|
-
};
|
|
34632
|
-
/**
|
|
34633
|
-
* Format percentage values
|
|
34634
|
-
*/
|
|
34635
|
-
const formatPercentage = (value) => {
|
|
34636
|
-
if (value === 0)
|
|
34637
|
-
return "0 %";
|
|
34638
|
-
if (Math.abs(value) >= 1) {
|
|
34639
|
-
return `${Math.abs(value).toFixed(0)} %`;
|
|
34640
|
-
}
|
|
34641
|
-
else {
|
|
34642
|
-
return `${Math.abs(value).toFixed(1)} %`;
|
|
34643
|
-
}
|
|
34644
|
-
};
|
|
34645
|
-
/**
|
|
34646
|
-
* Format large emission values for KPI cards
|
|
34647
|
-
*/
|
|
34648
|
-
const formatKPIEmission = (value) => {
|
|
34649
|
-
if (value === 0)
|
|
34650
|
-
return "0.0";
|
|
34651
|
-
if (value >= 1000) {
|
|
34652
|
-
return value.toFixed(1);
|
|
34653
|
-
}
|
|
34654
|
-
else if (value >= 1) {
|
|
34655
|
-
return value.toFixed(1);
|
|
34656
|
-
}
|
|
34657
|
-
else {
|
|
34658
|
-
return formatEmissionValue(value);
|
|
34659
|
-
}
|
|
34660
|
-
};
|
|
34661
|
-
|
|
34662
34583
|
// Default calculation configurations
|
|
34663
34584
|
const BILL_CALCULATION_CONFIGS = [
|
|
34664
34585
|
{
|
|
@@ -34887,6 +34808,85 @@ const createBillManager = (bills, matchingConfig) => {
|
|
|
34887
34808
|
return new BillManager(bills, matchingConfig);
|
|
34888
34809
|
};
|
|
34889
34810
|
|
|
34811
|
+
/**
|
|
34812
|
+
* Format emission values to handle small numbers properly while keeping UI clean
|
|
34813
|
+
*/
|
|
34814
|
+
const formatEmissionValue = (value, options) => {
|
|
34815
|
+
const { unit = "tonne CO₂e", showUnit = false, forceDecimals, } = options || {};
|
|
34816
|
+
if (value === 0)
|
|
34817
|
+
return showUnit ? `0 ${unit}` : "0";
|
|
34818
|
+
let formatted;
|
|
34819
|
+
if (forceDecimals !== undefined) {
|
|
34820
|
+
formatted = value.toFixed(forceDecimals);
|
|
34821
|
+
}
|
|
34822
|
+
else if (value >= 1000) {
|
|
34823
|
+
// Large values: show 1 decimal place
|
|
34824
|
+
formatted = value.toFixed(1);
|
|
34825
|
+
}
|
|
34826
|
+
else if (value >= 10) {
|
|
34827
|
+
// Medium values: show 1 decimal place
|
|
34828
|
+
formatted = value.toFixed(1);
|
|
34829
|
+
}
|
|
34830
|
+
else if (value >= 1) {
|
|
34831
|
+
// Values between 1-10: show 2 decimal places
|
|
34832
|
+
formatted = value.toFixed(2);
|
|
34833
|
+
}
|
|
34834
|
+
else if (value >= 0.01) {
|
|
34835
|
+
// Small values: show 3 decimal places
|
|
34836
|
+
formatted = value.toFixed(3);
|
|
34837
|
+
}
|
|
34838
|
+
else if (value >= 0.001) {
|
|
34839
|
+
// Very small values: show 5 decimal places to preserve precision
|
|
34840
|
+
formatted = value.toFixed(5);
|
|
34841
|
+
}
|
|
34842
|
+
else {
|
|
34843
|
+
// Extremely small values: show 6 decimal places
|
|
34844
|
+
formatted = value.toFixed(6);
|
|
34845
|
+
}
|
|
34846
|
+
// Remove trailing zeros after decimal point
|
|
34847
|
+
formatted = formatted.replace(/\.?0+$/, "");
|
|
34848
|
+
return showUnit ? `${formatted} ${unit}` : formatted;
|
|
34849
|
+
};
|
|
34850
|
+
/**
|
|
34851
|
+
* Format emission values specifically for monthly display (show small values properly)
|
|
34852
|
+
*/
|
|
34853
|
+
const formatMonthlyEmission = (value) => {
|
|
34854
|
+
if (value === 0)
|
|
34855
|
+
return "0";
|
|
34856
|
+
// Format with maximum 5 decimal places, removing trailing zeros
|
|
34857
|
+
const formatted = value.toFixed(5).replace(/\.?0+$/, "");
|
|
34858
|
+
return formatted;
|
|
34859
|
+
};
|
|
34860
|
+
/**
|
|
34861
|
+
* Format percentage values
|
|
34862
|
+
*/
|
|
34863
|
+
const formatPercentage = (value) => {
|
|
34864
|
+
if (value === 0)
|
|
34865
|
+
return "0 %";
|
|
34866
|
+
if (Math.abs(value) >= 1) {
|
|
34867
|
+
return `${Math.abs(value).toFixed(0)} %`;
|
|
34868
|
+
}
|
|
34869
|
+
else {
|
|
34870
|
+
return `${Math.abs(value).toFixed(1)} %`;
|
|
34871
|
+
}
|
|
34872
|
+
};
|
|
34873
|
+
/**
|
|
34874
|
+
* Format large emission values for KPI cards
|
|
34875
|
+
*/
|
|
34876
|
+
const formatKPIEmission = (value) => {
|
|
34877
|
+
if (value === 0)
|
|
34878
|
+
return "0.0";
|
|
34879
|
+
if (value >= 1000) {
|
|
34880
|
+
return value.toFixed(1);
|
|
34881
|
+
}
|
|
34882
|
+
else if (value >= 1) {
|
|
34883
|
+
return value.toFixed(1);
|
|
34884
|
+
}
|
|
34885
|
+
else {
|
|
34886
|
+
return formatEmissionValue(value);
|
|
34887
|
+
}
|
|
34888
|
+
};
|
|
34889
|
+
|
|
34890
34890
|
class EmissionSourceGenerator {
|
|
34891
34891
|
constructor(billManager) {
|
|
34892
34892
|
this.billManager = billManager;
|