@intlayer/config 4.0.2 → 4.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/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  </a>
18
18
  </div>
19
19
 
20
- # @intlayer/config: NPM Package to retrieve Intlayer configuration
20
+ # @intlayer/config: Retrieve Intlayer configuration
21
21
 
22
22
  **Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
23
23
 
@@ -23,6 +23,7 @@ __export(formatEnvVariable_exports, {
23
23
  module.exports = __toCommonJS(formatEnvVariable_exports);
24
24
  var import_getConfiguration = require('../configFile/getConfiguration.cjs');
25
25
  var import_detectPlatform = require('./detectPlatform.cjs');
26
+ var import_removeUndefinedValueObject = require('./removeUndefinedValueObject.cjs');
26
27
  const formatEnvName = (key, prefix) => prefix + key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
27
28
  const formatEnvVariable = (platform) => {
28
29
  const intlayerConfig = (0, import_getConfiguration.getConfiguration)();
@@ -40,7 +41,7 @@ const formatEnvVariable = (platform) => {
40
41
  env[formatEnvName(key, prefix)] = JSON.stringify(value);
41
42
  }
42
43
  }
43
- return env;
44
+ return (0, import_removeUndefinedValueObject.removeUndefinedValueObject)(env);
44
45
  };
45
46
  // Annotate the CommonJS export names for ESM import in node:
46
47
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/envVariables/formatEnvVariable.ts"],"sourcesContent":["import { getConfiguration } from '../configFile/getConfiguration';\nimport { getPrefix, type Platform } from './detectPlatform';\n\n/**\n * Format a key to corresponding environment variable name\n *\n * Example:\n * toEnvVariable('mainDir') => 'INTLAYER_MAIN_DIR'\n */\nconst formatEnvName = (key: string, prefix: string): string =>\n prefix + key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();\n\n/**\n * Format all configuration values as environment variables\n */\nexport const formatEnvVariable = (\n platform: Platform\n): Record<string, string> => {\n const intlayerConfig = getConfiguration();\n\n const prefix = getPrefix(platform);\n\n // Set all configuration values as environment variables\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries({\n ...intlayerConfig.content,\n ...intlayerConfig.internationalization,\n ...intlayerConfig.middleware,\n ...intlayerConfig.editor,\n })) {\n if (typeof value === 'string') {\n env[formatEnvName(key, prefix)] = value;\n } else {\n env[formatEnvName(key, prefix)] = JSON.stringify(value);\n }\n }\n\n return env;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,4BAAyC;AAQzC,MAAM,gBAAgB,CAAC,KAAa,WAClC,SAAS,IAAI,QAAQ,sBAAsB,OAAO,EAAE,YAAY;AAK3D,MAAM,oBAAoB,CAC/B,aAC2B;AAC3B,QAAM,qBAAiB,0CAAiB;AAExC,QAAM,aAAS,iCAAU,QAAQ;AAGjC,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,EACpB,CAAC,GAAG;AACF,QAAI,OAAO,UAAU,UAAU;AAC7B,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI;AAAA,IACpC,OAAO;AACL,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI,KAAK,UAAU,KAAK;AAAA,IACxD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/envVariables/formatEnvVariable.ts"],"sourcesContent":["import { getConfiguration } from '../configFile/getConfiguration';\nimport { getPrefix, type Platform } from './detectPlatform';\nimport { removeUndefinedValueObject } from './removeUndefinedValueObject';\n\n/**\n * Format a key to corresponding environment variable name\n *\n * Example:\n * toEnvVariable('mainDir') => 'INTLAYER_MAIN_DIR'\n */\nconst formatEnvName = (key: string, prefix: string): string =>\n prefix + key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();\n\n/**\n * Format all configuration values as environment variables\n */\nexport const formatEnvVariable = (\n platform: Platform\n): Record<string, string> => {\n const intlayerConfig = getConfiguration();\n\n const prefix = getPrefix(platform);\n\n // Set all configuration values as environment variables\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries({\n ...intlayerConfig.content,\n ...intlayerConfig.internationalization,\n ...intlayerConfig.middleware,\n ...intlayerConfig.editor,\n })) {\n if (typeof value === 'string') {\n env[formatEnvName(key, prefix)] = value;\n } else {\n env[formatEnvName(key, prefix)] = JSON.stringify(value);\n }\n }\n\n return removeUndefinedValueObject(env);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,4BAAyC;AACzC,wCAA2C;AAQ3C,MAAM,gBAAgB,CAAC,KAAa,WAClC,SAAS,IAAI,QAAQ,sBAAsB,OAAO,EAAE,YAAY;AAK3D,MAAM,oBAAoB,CAC/B,aAC2B;AAC3B,QAAM,qBAAiB,0CAAiB;AAExC,QAAM,aAAS,iCAAU,QAAQ;AAGjC,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,EACpB,CAAC,GAAG;AACF,QAAI,OAAO,UAAU,UAAU;AAC7B,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI;AAAA,IACpC,OAAO;AACL,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI,KAAK,UAAU,KAAK;AAAA,IACxD;AAAA,EACF;AAEA,aAAO,8DAA2B,GAAG;AACvC;","names":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var removeUndefinedValueObject_exports = {};
20
+ __export(removeUndefinedValueObject_exports, {
21
+ removeUndefinedValueObject: () => removeUndefinedValueObject
22
+ });
23
+ module.exports = __toCommonJS(removeUndefinedValueObject_exports);
24
+ const removeUndefinedValueObject = (obj) => {
25
+ const newObj = {};
26
+ for (const key in obj) {
27
+ if (obj[key] !== void 0) {
28
+ newObj[key] = obj[key];
29
+ }
30
+ }
31
+ Object.freeze(newObj);
32
+ return newObj;
33
+ };
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ removeUndefinedValueObject
37
+ });
38
+ //# sourceMappingURL=removeUndefinedValueObject.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/envVariables/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import { getConfiguration } from '../configFile/getConfiguration.mjs';
2
2
  import { getPrefix } from './detectPlatform.mjs';
3
+ import { removeUndefinedValueObject } from './removeUndefinedValueObject.mjs';
3
4
  const formatEnvName = (key, prefix) => prefix + key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
4
5
  const formatEnvVariable = (platform) => {
5
6
  const intlayerConfig = getConfiguration();
@@ -17,7 +18,7 @@ const formatEnvVariable = (platform) => {
17
18
  env[formatEnvName(key, prefix)] = JSON.stringify(value);
18
19
  }
19
20
  }
20
- return env;
21
+ return removeUndefinedValueObject(env);
21
22
  };
22
23
  export {
23
24
  formatEnvVariable
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/envVariables/formatEnvVariable.ts"],"sourcesContent":["import { getConfiguration } from '../configFile/getConfiguration';\nimport { getPrefix, type Platform } from './detectPlatform';\n\n/**\n * Format a key to corresponding environment variable name\n *\n * Example:\n * toEnvVariable('mainDir') => 'INTLAYER_MAIN_DIR'\n */\nconst formatEnvName = (key: string, prefix: string): string =>\n prefix + key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();\n\n/**\n * Format all configuration values as environment variables\n */\nexport const formatEnvVariable = (\n platform: Platform\n): Record<string, string> => {\n const intlayerConfig = getConfiguration();\n\n const prefix = getPrefix(platform);\n\n // Set all configuration values as environment variables\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries({\n ...intlayerConfig.content,\n ...intlayerConfig.internationalization,\n ...intlayerConfig.middleware,\n ...intlayerConfig.editor,\n })) {\n if (typeof value === 'string') {\n env[formatEnvName(key, prefix)] = value;\n } else {\n env[formatEnvName(key, prefix)] = JSON.stringify(value);\n }\n }\n\n return env;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,iBAAgC;AAQzC,MAAM,gBAAgB,CAAC,KAAa,WAClC,SAAS,IAAI,QAAQ,sBAAsB,OAAO,EAAE,YAAY;AAK3D,MAAM,oBAAoB,CAC/B,aAC2B;AAC3B,QAAM,iBAAiB,iBAAiB;AAExC,QAAM,SAAS,UAAU,QAAQ;AAGjC,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,EACpB,CAAC,GAAG;AACF,QAAI,OAAO,UAAU,UAAU;AAC7B,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI;AAAA,IACpC,OAAO;AACL,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI,KAAK,UAAU,KAAK;AAAA,IACxD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/envVariables/formatEnvVariable.ts"],"sourcesContent":["import { getConfiguration } from '../configFile/getConfiguration';\nimport { getPrefix, type Platform } from './detectPlatform';\nimport { removeUndefinedValueObject } from './removeUndefinedValueObject';\n\n/**\n * Format a key to corresponding environment variable name\n *\n * Example:\n * toEnvVariable('mainDir') => 'INTLAYER_MAIN_DIR'\n */\nconst formatEnvName = (key: string, prefix: string): string =>\n prefix + key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();\n\n/**\n * Format all configuration values as environment variables\n */\nexport const formatEnvVariable = (\n platform: Platform\n): Record<string, string> => {\n const intlayerConfig = getConfiguration();\n\n const prefix = getPrefix(platform);\n\n // Set all configuration values as environment variables\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries({\n ...intlayerConfig.content,\n ...intlayerConfig.internationalization,\n ...intlayerConfig.middleware,\n ...intlayerConfig.editor,\n })) {\n if (typeof value === 'string') {\n env[formatEnvName(key, prefix)] = value;\n } else {\n env[formatEnvName(key, prefix)] = JSON.stringify(value);\n }\n }\n\n return removeUndefinedValueObject(env);\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,iBAAgC;AACzC,SAAS,kCAAkC;AAQ3C,MAAM,gBAAgB,CAAC,KAAa,WAClC,SAAS,IAAI,QAAQ,sBAAsB,OAAO,EAAE,YAAY;AAK3D,MAAM,oBAAoB,CAC/B,aAC2B;AAC3B,QAAM,iBAAiB,iBAAiB;AAExC,QAAM,SAAS,UAAU,QAAQ;AAGjC,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,EACpB,CAAC,GAAG;AACF,QAAI,OAAO,UAAU,UAAU;AAC7B,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI;AAAA,IACpC,OAAO;AACL,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI,KAAK,UAAU,KAAK;AAAA,IACxD;AAAA,EACF;AAEA,SAAO,2BAA2B,GAAG;AACvC;","names":[]}
@@ -0,0 +1,14 @@
1
+ const removeUndefinedValueObject = (obj) => {
2
+ const newObj = {};
3
+ for (const key in obj) {
4
+ if (obj[key] !== void 0) {
5
+ newObj[key] = obj[key];
6
+ }
7
+ }
8
+ Object.freeze(newObj);
9
+ return newObj;
10
+ };
11
+ export {
12
+ removeUndefinedValueObject
13
+ };
14
+ //# sourceMappingURL=removeUndefinedValueObject.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/envVariables/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":"AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"formatEnvVariable.d.ts","sourceRoot":"","sources":["../../../src/envVariables/formatEnvVariable.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5D;;GAEG;AACH,eAAO,MAAM,iBAAiB,aAClB,QAAQ,KACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBvB,CAAC"}
1
+ {"version":3,"file":"formatEnvVariable.d.ts","sourceRoot":"","sources":["../../../src/envVariables/formatEnvVariable.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAY5D;;GAEG;AACH,eAAO,MAAM,iBAAiB,aAClB,QAAQ,KACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const removeUndefinedValueObject: <T extends Record<string, unknown>>(obj: T) => T;
2
+ //# sourceMappingURL=removeUndefinedValueObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeUndefinedValueObject.d.ts","sourceRoot":"","sources":["../../../src/envVariables/removeUndefinedValueObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OACrE,CAAC,KACL,CAYF,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@intlayer/config",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "private": false,
5
- "description": "Shared configuration package for IntLayer - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
5
+ "description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
6
6
  "keywords": [
7
7
  "intlayer",
8
8
  "layer",
@@ -77,14 +77,14 @@
77
77
  "tsc-alias": "^1.8.10",
78
78
  "tsup": "^8.3.5",
79
79
  "typescript": "^5.7.3",
80
- "@utils/eslint-config": "1.0.4",
81
80
  "@utils/ts-config": "1.0.4",
82
- "@utils/tsup-config": "1.0.4",
83
- "@utils/ts-config-types": "1.0.4"
81
+ "@utils/ts-config-types": "1.0.4",
82
+ "@utils/eslint-config": "1.0.4",
83
+ "@utils/tsup-config": "1.0.4"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "react": ">=16.0.0",
87
- "intlayer": "4.0.2"
87
+ "intlayer": "4.0.3"
88
88
  },
89
89
  "engines": {
90
90
  "node": ">=14.18"