@zerocarbon/erp-config-sdk 1.0.1 → 1.0.3

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.js CHANGED
@@ -9032,7 +9032,7 @@ const WATER_MANAGEMENT_GAS_LAB = {
9032
9032
  desc: "Water withdrawal, consumption, and discharge tracking for gas lab operations",
9033
9033
  };
9034
9034
 
9035
- const WATER_PRODUCTS = [
9035
+ const WATER_PRODUCTS$1 = [
9036
9036
  // Water Withdrawal by Source
9037
9037
  {
9038
9038
  name: "Surface Water",
@@ -11199,7 +11199,7 @@ const WATER_MANAGEMENT_SCOPE = {
11199
11199
  icon: gi.GiElectric,
11200
11200
  scope: "other",
11201
11201
  unit: "kilolitres",
11202
- subProducts: WATER_PRODUCTS,
11202
+ subProducts: WATER_PRODUCTS$1,
11203
11203
  desc: "Water withdrawal, consumption, and discharge tracking",
11204
11204
  };
11205
11205
  // Helper function to clean values
@@ -20776,6 +20776,65 @@ const FIRE_EXTINGUISHER_PRODUCTS$8 = [
20776
20776
  emissionFactor: 1,
20777
20777
  },
20778
20778
  ];
20779
+ // WATER PRODUCTS
20780
+ const WATER_PRODUCTS = [
20781
+ {
20782
+ name: "Discharged to Surface Water",
20783
+ unit: "m^3",
20784
+ type: "direct",
20785
+ calorificValue: 1,
20786
+ emissionFactor: 0,
20787
+ },
20788
+ {
20789
+ name: "Ground Water",
20790
+ unit: "m^3",
20791
+ type: "direct",
20792
+ calorificValue: 1,
20793
+ emissionFactor: 0,
20794
+ },
20795
+ {
20796
+ name: "Rain Water",
20797
+ unit: "m^3",
20798
+ type: "direct",
20799
+ calorificValue: 1,
20800
+ emissionFactor: 0,
20801
+ },
20802
+ {
20803
+ name: "Municipal Water",
20804
+ unit: "m^3",
20805
+ type: "direct",
20806
+ calorificValue: 1,
20807
+ emissionFactor: 0,
20808
+ },
20809
+ {
20810
+ name: "Tanker Water",
20811
+ unit: "m^3",
20812
+ type: "direct",
20813
+ calorificValue: 1,
20814
+ emissionFactor: 0,
20815
+ },
20816
+ {
20817
+ name: "Recycled Water",
20818
+ unit: "m^3",
20819
+ type: "direct",
20820
+ calorificValue: 1,
20821
+ emissionFactor: 0,
20822
+ },
20823
+ {
20824
+ name: "Surface Water",
20825
+ unit: "m^3",
20826
+ type: "direct",
20827
+ calorificValue: 1,
20828
+ emissionFactor: 0,
20829
+ },
20830
+ {
20831
+ name: "Desalinated Water",
20832
+ unit: "m^3",
20833
+ type: "direct",
20834
+ calorificValue: 1,
20835
+ emissionFactor: 0,
20836
+ },
20837
+ ];
20779
20838
  const FUEL_COMBUSTION_PRODUCTS$6 = [
20780
20839
  {
20781
20840
  name: "Diesel",
@@ -35010,17 +35069,23 @@ const UI_FEATURES = {
35010
35069
  INTEGRATION_FEATURES: "advanced.integrationFeatures",
35011
35070
  },
35012
35071
  };
35072
+ // ==================== DEFAULT CONFIGURATION ====================
35073
+ // All features are enabled by default
35074
+ const DEFAULT_FEATURES = {};
35013
35075
  // Auto-populate all features as true by default
35014
35076
  const populateDefaults = (obj, prefix = "") => {
35015
35077
  for (const [key, value] of Object.entries(obj)) {
35016
35078
  if (typeof value === "object" && value !== null) {
35017
35079
  populateDefaults(value, prefix ? `${prefix}.${key}` : key);
35018
35080
  }
35081
+ else if (typeof value === "string") {
35082
+ DEFAULT_FEATURES[value] = true;
35083
+ }
35019
35084
  }
35020
35085
  };
35021
35086
  populateDefaults(UI_FEATURES);
35022
35087
  // ==================== USER-SPECIFIC OVERRIDES ====================
35023
- ({
35088
+ const USER_OVERRIDES = {
35024
35089
  // Example: Gas Lab user with specific features disabled
35025
35090
  "gas lab": {
35026
35091
  [UI_FEATURES.DASHBOARD_CARDS.GHG_INTENSITY]: false,
@@ -35045,7 +35110,40 @@ populateDefaults(UI_FEATURES);
35045
35110
  [UI_FEATURES.ADVANCED.CUSTOM_REPORTS]: false,
35046
35111
  [UI_FEATURES.ADVANCED.API_ACCESS]: false,
35047
35112
  [UI_FEATURES.GRI.BLOCKCHAIN_PUBLISHING]: false,
35048
- }});
35113
+ },
35114
+ // Example: Admin user with all features enabled (explicitly showing override pattern)
35115
+ admin: {
35116
+ // All features remain true (default), but you could override specific ones to false if needed
35117
+ },
35118
+ };
35119
+ // ==================== UTILITY FUNCTIONS ====================
35120
+ /**
35121
+ * Check if a specific feature is enabled for a user
35122
+ * @param featurePath - The dot notation path to the feature (e.g., 'dashboard.cards.ghgIntensity')
35123
+ * @param username - The username to check (case-insensitive)
35124
+ * @returns boolean - true if feature is enabled, false if disabled
35125
+ */
35126
+ const isFeatureEnabled = (featurePath, username) => {
35127
+ var _a, _b, _c;
35128
+ if (!username) {
35129
+ return (_a = DEFAULT_FEATURES[featurePath]) !== null && _a !== void 0 ? _a : true;
35130
+ }
35131
+ const normalizedUsername = username.toLowerCase().trim();
35132
+ const userOverrides = USER_OVERRIDES[normalizedUsername];
35133
+ if (userOverrides && userOverrides.hasOwnProperty(featurePath)) {
35134
+ return (_b = userOverrides[featurePath]) !== null && _b !== void 0 ? _b : true;
35135
+ }
35136
+ return (_c = DEFAULT_FEATURES[featurePath]) !== null && _c !== void 0 ? _c : true;
35137
+ };
35138
+ /**
35139
+ * Helper function to get feature value using the constant paths
35140
+ * @param featureConstant - Use UI_FEATURES constants (e.g., UI_FEATURES.DASHBOARD_CARDS.GHG_INTENSITY)
35141
+ * @param username - The username to check
35142
+ * @returns boolean - true if feature is enabled, false if disabled
35143
+ */
35144
+ const isUIFeatureEnabled = (featureConstant, username) => {
35145
+ return isFeatureEnabled(featureConstant, username);
35146
+ };
35049
35147
  // ==================== FEATURE GROUPS FOR EASY ACCESS ====================
35050
35148
  ({
35051
35149
  DASHBOARD: [
@@ -40287,8 +40385,10 @@ exports.INDUSTRIES_CONFIG = INDUSTRIES_CONFIG;
40287
40385
  exports.INDUSTRY_MAPPING = INDUSTRY_MAPPING;
40288
40386
  exports.INDUSTRY_SPECIFIC_FIELDS = INDUSTRY_SPECIFIC_FIELDS;
40289
40387
  exports.INTENSITY_FIELD_LABELS = INTENSITY_FIELD_LABELS;
40388
+ exports.ISO_CATEGORIES_PACKAGING = ISO_CATEGORIES_PACKAGING;
40290
40389
  exports.Industries = index;
40291
40390
  exports.UI_FEATURES = UI_FEATURES;
40391
+ exports.WATER_PRODUCTS = WATER_PRODUCTS;
40292
40392
  exports.calculateCCTSEmission = calculateCCTSEmission;
40293
40393
  exports.calculateIntensityMetrics = calculateIntensityMetrics;
40294
40394
  exports.categorizeApiItem = categorizeApiItem;
@@ -40312,6 +40412,7 @@ exports.getPlantNameConfig = getPlantNameConfig;
40312
40412
  exports.getScope3ConfigByName = getScope3ConfigByName;
40313
40413
  exports.getUserNameWaterManagementConfig = getUserNameWaterManagementConfig;
40314
40414
  exports.hasIntensities = hasIntensities;
40415
+ exports.isUIFeatureEnabled = isUIFeatureEnabled;
40315
40416
  exports.mapIndustryToApiType = mapIndustryToApiType;
40316
40417
  exports.supportsIntensityCalculations = supportsIntensityCalculations;
40317
40418
  exports.validateCarbonIntensityData = validateCarbonIntensityData;