@zerocarbon/erp-config-sdk 1.0.0 → 1.0.2
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 +8 -1
- package/dist/index.esm.js +42 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +42 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1255,6 +1255,13 @@ declare const UI_FEATURES: {
|
|
|
1255
1255
|
readonly INTEGRATION_FEATURES: "advanced.integrationFeatures";
|
|
1256
1256
|
};
|
|
1257
1257
|
};
|
|
1258
|
+
/**
|
|
1259
|
+
* Helper function to get feature value using the constant paths
|
|
1260
|
+
* @param featureConstant - Use UI_FEATURES constants (e.g., UI_FEATURES.DASHBOARD_CARDS.GHG_INTENSITY)
|
|
1261
|
+
* @param username - The username to check
|
|
1262
|
+
* @returns boolean - true if feature is enabled, false if disabled
|
|
1263
|
+
*/
|
|
1264
|
+
declare const isUIFeatureEnabled: (featureConstant: string, username?: string) => boolean;
|
|
1258
1265
|
|
|
1259
1266
|
type FieldType = "text" | "number" | "dropdown" | "multiDropdown" | "country";
|
|
1260
1267
|
interface FieldOption {
|
|
@@ -3993,5 +4000,5 @@ declare namespace index {
|
|
|
3993
4000
|
};
|
|
3994
4001
|
}
|
|
3995
4002
|
|
|
3996
|
-
export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, CARBON_INTENSITY_FIELD_MAPPINGS, 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, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, index as Industries, UI_FEATURES, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getAvailableFieldsForIndustry, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getNestedValue, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, mapIndustryToApiType, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
4003
|
+
export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, CARBON_INTENSITY_FIELD_MAPPINGS, 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, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, index as Industries, UI_FEATURES, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getAvailableFieldsForIndustry, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getNestedValue, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
3997
4004
|
export type { AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BaseRequest, BaseResponse, Bill, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, CarbonIntensityApiMapping, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, DetailedCarbonIntensityResponse, EditableItem, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FieldConfig, FieldOption, FieldType, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, HospitalityRequest, HospitalityResponse, IndustryFieldConfig, IndustryFieldSection, IndustryType, IntensityCalculation, IntensityValue, LogisticsRequest, LogisticsResponse, ManufacturingRequest, ManufacturingResponse, Meta, MetalEnergyRequest, MetalEnergyResponse, PackagingRequest, PackagingResponse, Pagination, PetrochemicalRequest, PetrochemicalResponse, PharmaRequest, PharmaResponse, PlantNameConfig, ProcessedEmissionCategory, ProcessedEmissionItem, ProcessedScope3Data, ProductionData, RealEstateRequest, RealEstateResponse, 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
|
@@ -35008,17 +35008,23 @@ const UI_FEATURES = {
|
|
|
35008
35008
|
INTEGRATION_FEATURES: "advanced.integrationFeatures",
|
|
35009
35009
|
},
|
|
35010
35010
|
};
|
|
35011
|
+
// ==================== DEFAULT CONFIGURATION ====================
|
|
35012
|
+
// All features are enabled by default
|
|
35013
|
+
const DEFAULT_FEATURES = {};
|
|
35011
35014
|
// Auto-populate all features as true by default
|
|
35012
35015
|
const populateDefaults = (obj, prefix = "") => {
|
|
35013
35016
|
for (const [key, value] of Object.entries(obj)) {
|
|
35014
35017
|
if (typeof value === "object" && value !== null) {
|
|
35015
35018
|
populateDefaults(value, prefix ? `${prefix}.${key}` : key);
|
|
35016
35019
|
}
|
|
35020
|
+
else if (typeof value === "string") {
|
|
35021
|
+
DEFAULT_FEATURES[value] = true;
|
|
35022
|
+
}
|
|
35017
35023
|
}
|
|
35018
35024
|
};
|
|
35019
35025
|
populateDefaults(UI_FEATURES);
|
|
35020
35026
|
// ==================== USER-SPECIFIC OVERRIDES ====================
|
|
35021
|
-
|
|
35027
|
+
const USER_OVERRIDES = {
|
|
35022
35028
|
// Example: Gas Lab user with specific features disabled
|
|
35023
35029
|
"gas lab": {
|
|
35024
35030
|
[UI_FEATURES.DASHBOARD_CARDS.GHG_INTENSITY]: false,
|
|
@@ -35043,7 +35049,40 @@ populateDefaults(UI_FEATURES);
|
|
|
35043
35049
|
[UI_FEATURES.ADVANCED.CUSTOM_REPORTS]: false,
|
|
35044
35050
|
[UI_FEATURES.ADVANCED.API_ACCESS]: false,
|
|
35045
35051
|
[UI_FEATURES.GRI.BLOCKCHAIN_PUBLISHING]: false,
|
|
35046
|
-
}
|
|
35052
|
+
},
|
|
35053
|
+
// Example: Admin user with all features enabled (explicitly showing override pattern)
|
|
35054
|
+
admin: {
|
|
35055
|
+
// All features remain true (default), but you could override specific ones to false if needed
|
|
35056
|
+
},
|
|
35057
|
+
};
|
|
35058
|
+
// ==================== UTILITY FUNCTIONS ====================
|
|
35059
|
+
/**
|
|
35060
|
+
* Check if a specific feature is enabled for a user
|
|
35061
|
+
* @param featurePath - The dot notation path to the feature (e.g., 'dashboard.cards.ghgIntensity')
|
|
35062
|
+
* @param username - The username to check (case-insensitive)
|
|
35063
|
+
* @returns boolean - true if feature is enabled, false if disabled
|
|
35064
|
+
*/
|
|
35065
|
+
const isFeatureEnabled = (featurePath, username) => {
|
|
35066
|
+
var _a, _b, _c;
|
|
35067
|
+
if (!username) {
|
|
35068
|
+
return (_a = DEFAULT_FEATURES[featurePath]) !== null && _a !== void 0 ? _a : true;
|
|
35069
|
+
}
|
|
35070
|
+
const normalizedUsername = username.toLowerCase().trim();
|
|
35071
|
+
const userOverrides = USER_OVERRIDES[normalizedUsername];
|
|
35072
|
+
if (userOverrides && userOverrides.hasOwnProperty(featurePath)) {
|
|
35073
|
+
return (_b = userOverrides[featurePath]) !== null && _b !== void 0 ? _b : true;
|
|
35074
|
+
}
|
|
35075
|
+
return (_c = DEFAULT_FEATURES[featurePath]) !== null && _c !== void 0 ? _c : true;
|
|
35076
|
+
};
|
|
35077
|
+
/**
|
|
35078
|
+
* Helper function to get feature value using the constant paths
|
|
35079
|
+
* @param featureConstant - Use UI_FEATURES constants (e.g., UI_FEATURES.DASHBOARD_CARDS.GHG_INTENSITY)
|
|
35080
|
+
* @param username - The username to check
|
|
35081
|
+
* @returns boolean - true if feature is enabled, false if disabled
|
|
35082
|
+
*/
|
|
35083
|
+
const isUIFeatureEnabled = (featureConstant, username) => {
|
|
35084
|
+
return isFeatureEnabled(featureConstant, username);
|
|
35085
|
+
};
|
|
35047
35086
|
// ==================== FEATURE GROUPS FOR EASY ACCESS ====================
|
|
35048
35087
|
({
|
|
35049
35088
|
DASHBOARD: [
|
|
@@ -40261,5 +40300,5 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
40261
40300
|
getUserNameScope3Config: getUserNameScope3Config
|
|
40262
40301
|
});
|
|
40263
40302
|
|
|
40264
|
-
export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, CARBON_INTENSITY_FIELD_MAPPINGS, 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, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, index as Industries, UI_FEATURES, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getAvailableFieldsForIndustry, getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getNestedValue, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, mapIndustryToApiType, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
40303
|
+
export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, CARBON_INTENSITY_FIELD_MAPPINGS, 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, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, index as Industries, UI_FEATURES, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getAvailableFieldsForIndustry, getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getNestedValue, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, supportsIntensityCalculations, validateCarbonIntensityData };
|
|
40265
40304
|
//# sourceMappingURL=index.esm.js.map
|