@intlayer/config 5.0.5 → 5.1.0
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/cjs/appLoggerClient.cjs.map +1 -1
- package/dist/cjs/appLoggerServer.cjs.map +1 -1
- package/dist/cjs/configFile/loadConfigurationFile.cjs +1 -1
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/getSandboxContext.cjs +1 -1
- package/dist/cjs/getSandboxContext.cjs.map +1 -1
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/esm/appLoggerClient.mjs.map +1 -1
- package/dist/esm/appLoggerServer.mjs.map +1 -1
- package/dist/esm/configFile/loadConfigurationFile.mjs +1 -1
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/getSandboxContext.mjs +4 -2
- package/dist/esm/getSandboxContext.mjs.map +1 -1
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/types/appLoggerClient.d.ts +1 -1
- package/dist/types/appLoggerClient.d.ts.map +1 -1
- package/dist/types/appLoggerServer.d.ts +1 -1
- package/dist/types/appLoggerServer.d.ts.map +1 -1
- package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
- package/dist/types/getSandboxContext.d.ts +2 -2
- package/dist/types/getSandboxContext.d.ts.map +1 -1
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/logger.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/appLoggerClient.ts"],"sourcesContent":["import { getConfiguration } from './client';\nimport { Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,
|
|
1
|
+
{"version":3,"sources":["../../src/appLoggerClient.ts"],"sourcesContent":["import { getConfiguration } from './client';\nimport { type Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,oBAAoC;AAE7B,MAAM,YAAoB,CAAC,SAAS,gBACzC,sBAAO,SAAS;AAAA,EACd,GAAI,WAAW,CAAC;AAAA,EAChB,QAAQ,EAAE,OAAG,gCAAiB,EAAE,KAAK,GAAI,SAAS,UAAU,CAAC,EAAG;AAClE,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/appLoggerServer.ts"],"sourcesContent":["import { getConfiguration } from './configFile/getConfiguration';\nimport { Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,
|
|
1
|
+
{"version":3,"sources":["../../src/appLoggerServer.ts"],"sourcesContent":["import { getConfiguration } from './configFile/getConfiguration';\nimport { type Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,oBAAoC;AAE7B,MAAM,YAAoB,CAAC,SAAS,gBACzC,sBAAO,SAAS;AAAA,EACd,GAAI,WAAW,CAAC;AAAA,EAChB,QAAQ,EAAE,OAAG,0CAAiB,EAAE,KAAK,GAAI,SAAS,UAAU,CAAC,EAAG;AAClE,CAAC;","names":[]}
|
|
@@ -23,9 +23,9 @@ __export(loadConfigurationFile_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(loadConfigurationFile_exports);
|
|
24
24
|
var import_vm = require("vm");
|
|
25
25
|
var import_esbuild = require("esbuild");
|
|
26
|
+
var import_getSandboxContext = require('../getSandboxContext.cjs');
|
|
26
27
|
var import_logger = require('../logger.cjs');
|
|
27
28
|
var import_ESMxCJSRequire = require('../utils/ESMxCJSRequire.cjs');
|
|
28
|
-
var import_getSandboxContext = require('../getSandboxContext.cjs');
|
|
29
29
|
const getTransformationOptions = () => {
|
|
30
30
|
const define = {};
|
|
31
31
|
for (const k in process.env) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { type LoadEnvFileOptions } from '../envVariables/loadEnvFile';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { type LoadEnvFileOptions } from '../envVariables/loadEnvFile';\nimport { getSandBoxContext } from '../getSandboxContext';\nimport { logger } from '../logger';\nimport type { CustomIntlayerConfig } from '../types/config';\nimport { ESMxCJSRequire } from '../utils/ESMxCJSRequire';\n\nconst getTransformationOptions = (): BuildOptions => {\n const define: Record<string, string> = {};\n\n for (const k in process.env) {\n define[`process.env.${k}`] = JSON.stringify(process.env[k]);\n }\n\n const transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n define,\n };\n\n return transformationOption;\n};\n\nconst filterValidConfiguration = (\n configuration: CustomIntlayerConfig\n): CustomIntlayerConfig => {\n // @TODO Implement filtering of valid configuration\n return configuration;\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n envVarOptions?: LoadEnvFileOptions\n): CustomIntlayerConfig | undefined => {\n let customConfiguration: CustomIntlayerConfig | undefined = undefined;\n\n const configFileExtension = configFilePath.split('.').pop() ?? '';\n\n try {\n if (configFileExtension === 'json') {\n // Assume JSON\n\n return ESMxCJSRequire(configFilePath);\n }\n\n const sandboxContext = getSandBoxContext(envVarOptions);\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [configFilePath],\n ...getTransformationOptions(),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('Configuration file could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n customConfiguration = sandboxContext.module.exports;\n }\n\n if (typeof customConfiguration === 'undefined') {\n logger('Configuration file could not be loaded.');\n return undefined;\n }\n\n return filterValidConfiguration(customConfiguration);\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAgC;AAChC,qBAA+D;AA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B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,4BAAsB,eAAe,OAAO,QAAQ;AAAA,IACtD,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,4BAAsB,eAAe,OAAO,QAAQ;AAAA,IACtD,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,4BAAsB,eAAe,OAAO;AAAA,IAC9C;AAEA,QAAI,OAAO,wBAAwB,aAAa;AAC9C,gCAAO,yCAAyC;AAChD,aAAO;AAAA,IACT;AAEA,WAAO,yBAAyB,mBAAmB;AAAA,EACrD,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -31,9 +31,9 @@ __export(getSandboxContext_exports, {
|
|
|
31
31
|
getSandBoxContext: () => getSandBoxContext
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(getSandboxContext_exports);
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
34
35
|
var import_loadEnvFile = require('./envVariables/loadEnvFile.cjs');
|
|
35
36
|
var import_ESMxCJSRequire = require('./utils/ESMxCJSRequire.cjs');
|
|
36
|
-
var import_react = __toESM(require("react"));
|
|
37
37
|
const getSandBoxContext = (envVarOptions) => {
|
|
38
38
|
const sandboxContext = {
|
|
39
39
|
exports: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getSandboxContext.ts"],"sourcesContent":["import { Context } from 'vm';\nimport { loadEnvFile
|
|
1
|
+
{"version":3,"sources":["../../src/getSandboxContext.ts"],"sourcesContent":["import type { Context } from 'vm';\nimport React from 'react';\nimport {\n type LoadEnvFileOptions,\n loadEnvFile,\n} from './envVariables/loadEnvFile';\nimport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\n\nexport const getSandBoxContext = (\n envVarOptions?: LoadEnvFileOptions\n): Context => {\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n React,\n process: { ...process, env: loadEnvFile(envVarOptions) },\n console,\n require: ESMxCJSRequire,\n };\n\n return sandboxContext;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,yBAGO;AACP,4BAA+B;AAExB,MAAM,oBAAoB,CAC/B,kBACY;AACZ,QAAM,iBAA0B;AAAA,IAC9B,SAAS;AAAA,MACP,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,oBAAAA;AAAA,IACA,SAAS,EAAE,GAAG,SAAS,SAAK,gCAAY,aAAa,EAAE;AAAA,IACvD;AAAA,IACA,SAAS;AAAA,EACX;AAEA,SAAO;AACT;","names":["React"]}
|
package/dist/cjs/logger.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["import type { IntlayerConfig } from './types/config';\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: Partial<IntlayerConfig['log']>;\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nexport const logger: Logger = (\n content,\n details = {\n isVerbose: false,\n level: undefined,\n config: { mode: 'default', prefix: '' },\n }\n) => {\n const mode = details.config?.mode ?? 'default';\n const prefix = details.config?.prefix ?? '';\n\n if (mode === 'disabled') return;\n\n if (details.isVerbose && mode !== 'verbose') return;\n\n if (details.level === 'debug') {\n return console.debug(`${prefix}${content}`);\n }\n\n if (details.level === 'info') {\n return console.info(`${prefix}${content}`);\n }\n\n if (details.level === 'warn') {\n return console.warn(`${prefix}${content}`);\n }\n\n if (details.level === 'error') {\n return console.error(`${prefix}${content}`);\n }\n\n console.log(`${prefix}${content}`);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,SAAiB,CAC5B,SACA,UAAU;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ,EAAE,MAAM,WAAW,QAAQ,GAAG;AACxC,MACG;AACH,QAAM,OAAO,QAAQ,QAAQ,QAAQ;AACrC,QAAM,SAAS,QAAQ,QAAQ,UAAU;AAEzC,MAAI,SAAS,WAAY;AAEzB,MAAI,QAAQ,aAAa,SAAS,UAAW;AAE7C,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC5C;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC3C;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC3C;AAEA,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC5C;AAEA,UAAQ,IAAI,GAAG,MAAM,GAAG,OAAO,EAAE;AACnC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/appLoggerClient.ts"],"sourcesContent":["import { getConfiguration } from './client';\nimport { Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,
|
|
1
|
+
{"version":3,"sources":["../../src/appLoggerClient.ts"],"sourcesContent":["import { getConfiguration } from './client';\nimport { type Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAsB,cAAc;AAE7B,MAAM,YAAoB,CAAC,SAAS,YACzC,OAAO,SAAS;AAAA,EACd,GAAI,WAAW,CAAC;AAAA,EAChB,QAAQ,EAAE,GAAG,iBAAiB,EAAE,KAAK,GAAI,SAAS,UAAU,CAAC,EAAG;AAClE,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/appLoggerServer.ts"],"sourcesContent":["import { getConfiguration } from './configFile/getConfiguration';\nimport { Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,
|
|
1
|
+
{"version":3,"sources":["../../src/appLoggerServer.ts"],"sourcesContent":["import { getConfiguration } from './configFile/getConfiguration';\nimport { type Logger, logger } from './logger';\n\nexport const appLogger: Logger = (content, details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...getConfiguration().log, ...(details?.config ?? {}) },\n });\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAsB,cAAc;AAE7B,MAAM,YAAoB,CAAC,SAAS,YACzC,OAAO,SAAS;AAAA,EACd,GAAI,WAAW,CAAC;AAAA,EAChB,QAAQ,EAAE,GAAG,iBAAiB,EAAE,KAAK,GAAI,SAAS,UAAU,CAAC,EAAG;AAClE,CAAC;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { runInNewContext } from "vm";
|
|
2
2
|
import { buildSync } from "esbuild";
|
|
3
|
+
import { getSandBoxContext } from "../getSandboxContext.mjs";
|
|
3
4
|
import { logger } from "../logger.mjs";
|
|
4
5
|
import { ESMxCJSRequire } from "../utils/ESMxCJSRequire.mjs";
|
|
5
|
-
import { getSandBoxContext } from "../getSandboxContext.mjs";
|
|
6
6
|
const getTransformationOptions = () => {
|
|
7
7
|
const define = {};
|
|
8
8
|
for (const k in process.env) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { type LoadEnvFileOptions } from '../envVariables/loadEnvFile';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { type LoadEnvFileOptions } from '../envVariables/loadEnvFile';\nimport { getSandBoxContext } from '../getSandboxContext';\nimport { logger } from '../logger';\nimport type { CustomIntlayerConfig } from '../types/config';\nimport { ESMxCJSRequire } from '../utils/ESMxCJSRequire';\n\nconst getTransformationOptions = (): BuildOptions => {\n const define: Record<string, string> = {};\n\n for (const k in process.env) {\n define[`process.env.${k}`] = JSON.stringify(process.env[k]);\n }\n\n const transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n define,\n };\n\n return transformationOption;\n};\n\nconst filterValidConfiguration = (\n configuration: CustomIntlayerConfig\n): CustomIntlayerConfig => {\n // @TODO Implement filtering of valid configuration\n return configuration;\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n envVarOptions?: LoadEnvFileOptions\n): CustomIntlayerConfig | undefined => {\n let customConfiguration: CustomIntlayerConfig | undefined = undefined;\n\n const configFileExtension = configFilePath.split('.').pop() ?? '';\n\n try {\n if (configFileExtension === 'json') {\n // Assume JSON\n\n return ESMxCJSRequire(configFilePath);\n }\n\n const sandboxContext = getSandBoxContext(envVarOptions);\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [configFilePath],\n ...getTransformationOptions(),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('Configuration file could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n customConfiguration = sandboxContext.module.exports;\n }\n\n if (typeof customConfiguration === 'undefined') {\n logger('Configuration file could not be loaded.');\n return undefined;\n }\n\n return filterValidConfiguration(customConfiguration);\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAA4B,iBAAmC;AAE/D,SAAS,yBAAyB;AAClC,SAAS,cAAc;AAEvB,SAAS,sBAAsB;AAE/B,MAAM,2BAA2B,MAAoB;AACnD,QAAM,SAAiC,CAAC;AAExC,aAAW,KAAK,QAAQ,KAAK;AAC3B,WAAO,eAAe,CAAC,EAAE,IAAI,KAAK,UAAU,QAAQ,IAAI,CAAC,CAAC;AAAA,EAC5D;AAEA,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AAA,IACtD,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,4BAAsB,eAAe,OAAO;AAAA,IAC9C;AAEA,QAAI,OAAO,wBAAwB,aAAa;AAC9C,aAAO,yCAAyC;AAChD,aAAO;AAAA,IACT;AAEA,WAAO,yBAAyB,mBAAmB;AAAA,EACrD,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { loadEnvFile } from "./envVariables/loadEnvFile.mjs";
|
|
2
|
-
import { ESMxCJSRequire } from "./utils/ESMxCJSRequire.mjs";
|
|
3
1
|
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
loadEnvFile
|
|
4
|
+
} from "./envVariables/loadEnvFile.mjs";
|
|
5
|
+
import { ESMxCJSRequire } from "./utils/ESMxCJSRequire.mjs";
|
|
4
6
|
const getSandBoxContext = (envVarOptions) => {
|
|
5
7
|
const sandboxContext = {
|
|
6
8
|
exports: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getSandboxContext.ts"],"sourcesContent":["import { Context } from 'vm';\nimport { loadEnvFile
|
|
1
|
+
{"version":3,"sources":["../../src/getSandboxContext.ts"],"sourcesContent":["import type { Context } from 'vm';\nimport React from 'react';\nimport {\n type LoadEnvFileOptions,\n loadEnvFile,\n} from './envVariables/loadEnvFile';\nimport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\n\nexport const getSandBoxContext = (\n envVarOptions?: LoadEnvFileOptions\n): Context => {\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n React,\n process: { ...process, env: loadEnvFile(envVarOptions) },\n console,\n require: ESMxCJSRequire,\n };\n\n return sandboxContext;\n};\n"],"mappings":"AACA,OAAO,WAAW;AAClB;AAAA,EAEE;AAAA,OACK;AACP,SAAS,sBAAsB;AAExB,MAAM,oBAAoB,CAC/B,kBACY;AACZ,QAAM,iBAA0B;AAAA,IAC9B,SAAS;AAAA,MACP,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,CAAC;AAAA,IACZ;AAAA,IACA;AAAA,IACA,SAAS,EAAE,GAAG,SAAS,KAAK,YAAY,aAAa,EAAE;AAAA,IACvD;AAAA,IACA,SAAS;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
package/dist/esm/logger.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["import type { IntlayerConfig } from './types/config';\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: Partial<IntlayerConfig['log']>;\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nexport const logger: Logger = (\n content,\n details = {\n isVerbose: false,\n level: undefined,\n config: { mode: 'default', prefix: '' },\n }\n) => {\n const mode = details.config?.mode ?? 'default';\n const prefix = details.config?.prefix ?? '';\n\n if (mode === 'disabled') return;\n\n if (details.isVerbose && mode !== 'verbose') return;\n\n if (details.level === 'debug') {\n return console.debug(`${prefix}${content}`);\n }\n\n if (details.level === 'info') {\n return console.info(`${prefix}${content}`);\n }\n\n if (details.level === 'warn') {\n return console.warn(`${prefix}${content}`);\n }\n\n if (details.level === 'error') {\n return console.error(`${prefix}${content}`);\n }\n\n console.log(`${prefix}${content}`);\n};\n"],"mappings":"AAUO,MAAM,SAAiB,CAC5B,SACA,UAAU;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ,EAAE,MAAM,WAAW,QAAQ,GAAG;AACxC,MACG;AACH,QAAM,OAAO,QAAQ,QAAQ,QAAQ;AACrC,QAAM,SAAS,QAAQ,QAAQ,UAAU;AAEzC,MAAI,SAAS,WAAY;AAEzB,MAAI,QAAQ,aAAa,SAAS,UAAW;AAE7C,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC5C;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC3C;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC3C;AAEA,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE;AAAA,EAC5C;AAEA,UAAQ,IAAI,GAAG,MAAM,GAAG,OAAO,EAAE;AACnC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appLoggerClient.d.ts","sourceRoot":"","sources":["../../src/appLoggerClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAU,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"appLoggerClient.d.ts","sourceRoot":"","sources":["../../src/appLoggerClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,SAAS,EAAE,MAIpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appLoggerServer.d.ts","sourceRoot":"","sources":["../../src/appLoggerServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAU,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"appLoggerServer.d.ts","sourceRoot":"","sources":["../../src/appLoggerServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,SAAS,EAAE,MAIpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfigurationFile.d.ts","sourceRoot":"","sources":["../../../src/configFile/loadConfigurationFile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"loadConfigurationFile.d.ts","sourceRoot":"","sources":["../../../src/configFile/loadConfigurationFile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsC5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,mBAChB,MAAM,kBACN,kBAAkB,KACjC,oBAAoB,GAAG,SAsEzB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from 'vm';
|
|
2
|
-
import { LoadEnvFileOptions } from './envVariables/loadEnvFile';
|
|
1
|
+
import type { Context } from 'vm';
|
|
2
|
+
import { type LoadEnvFileOptions } from './envVariables/loadEnvFile';
|
|
3
3
|
export declare const getSandBoxContext: (envVarOptions?: LoadEnvFileOptions) => Context;
|
|
4
4
|
//# sourceMappingURL=getSandboxContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSandboxContext.d.ts","sourceRoot":"","sources":["../../src/getSandboxContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"getSandboxContext.d.ts","sourceRoot":"","sources":["../../src/getSandboxContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAElC,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,4BAA4B,CAAC;AAGpC,eAAO,MAAM,iBAAiB,mBACZ,kBAAkB,KACjC,OAeF,CAAC"}
|
package/dist/types/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAE/D,eAAO,MAAM,MAAM,EAAE,MAgCpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
|
|
6
6
|
"keywords": [
|
|
@@ -68,23 +68,23 @@
|
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/node": "^22.10.6",
|
|
71
|
-
"@types/react": "^
|
|
72
|
-
"@typescript-eslint/parser": "^8.
|
|
71
|
+
"@types/react": "^19.0.0",
|
|
72
|
+
"@typescript-eslint/parser": "^8.24.0",
|
|
73
73
|
"concurrently": "^9.1.2",
|
|
74
|
-
"eslint": "^9.
|
|
75
|
-
"prettier": "^3.
|
|
74
|
+
"eslint": "^9.20.0",
|
|
75
|
+
"prettier": "^3.5.0",
|
|
76
76
|
"rimraf": "^6.0.1",
|
|
77
77
|
"tsc-alias": "^1.8.10",
|
|
78
78
|
"tsup": "^8.3.5",
|
|
79
79
|
"typescript": "^5.7.3",
|
|
80
|
+
"@utils/ts-config": "1.0.4",
|
|
80
81
|
"@utils/eslint-config": "1.0.4",
|
|
81
|
-
"@utils/ts-config-types": "1.0.4",
|
|
82
82
|
"@utils/tsup-config": "1.0.4",
|
|
83
|
-
"@utils/ts-config": "1.0.4"
|
|
83
|
+
"@utils/ts-config-types": "1.0.4"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"react": ">=16.0.0",
|
|
87
|
-
"intlayer": "5.0
|
|
87
|
+
"intlayer": "5.1.0"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=14.18"
|