@intlayer/config 8.3.4 → 8.4.0-canary.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.
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../logger.cjs`),n=require(`./parseFileContent.cjs`),r=require(`./transpileTSToCJS.cjs`);let i=require(`node:fs`),a=require(`node:path`),o=require(`node:fs/promises`),s=require(`json5`);s=e.__toESM(s);const c=(e,o)=>{let c=(0,a.extname)(e)||`.json`;try{if(c===`.json`||c===`.json5`||c===`.jsonc`)return s.default.parse((0,i.readFileSync)(e,`utf-8`));let a=r.transpileTSToCJSSync((0,i.readFileSync)(e,`utf-8`),e);if(!a){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(a,{projectRequire:o?.projectRequire,envVarOptions:o?.envVarOptions,additionalEnvVars:o?.additionalEnvVars,mocks:o?.mocks,aliases:o?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${e}`);return}return l}catch(e){t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},l=async(e,i)=>{let c=(0,a.extname)(e);try{if(c===`.json`||c===`.json5`||c===`.jsonc`){let t=await(0,o.readFile)(e,`utf-8`);return s.default.parse(t)}let a=await r.transpileTSToCJS(await(0,o.readFile)(e,`utf-8`),e,i?.buildOptions);if(!a){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(a,{projectRequire:i?.projectRequire,envVarOptions:i?.envVarOptions,additionalEnvVars:i?.additionalEnvVars,mocks:i?.mocks,aliases:i?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${t.colorizePath(e)}`);return}return l}catch(e){(i?.logError??!0)&&t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};exports.loadExternalFile=l,exports.loadExternalFileSync=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../logger.cjs`),n=require(`./parseFileContent.cjs`),r=require(`./transpileTSToCJS.cjs`);let i=require(`node:fs`),a=require(`node:path`),o=require(`node:fs/promises`),s=require(`json5`);s=e.__toESM(s);const c=s.parse||s.default?.parse,l=(e,o)=>{let s=(0,a.extname)(e)||`.json`;try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return c((0,i.readFileSync)(e,`utf-8`));let a=r.transpileTSToCJSSync((0,i.readFileSync)(e,`utf-8`),e);if(!a){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(a,{projectRequire:o?.projectRequire,envVarOptions:o?.envVarOptions,additionalEnvVars:o?.additionalEnvVars,mocks:o?.mocks,aliases:o?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${e}`);return}return l}catch(e){t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},u=async(e,i)=>{let s=(0,a.extname)(e);try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return c(await(0,o.readFile)(e,`utf-8`));let a=await r.transpileTSToCJS(await(0,o.readFile)(e,`utf-8`),e,i?.buildOptions);if(!a){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(a,{projectRequire:i?.projectRequire,envVarOptions:i?.envVarOptions,additionalEnvVars:i?.additionalEnvVars,mocks:i?.mocks,aliases:i?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${t.colorizePath(e)}`);return}return l}catch(e){(i?.logError??!0)&&t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};exports.loadExternalFile=u,exports.loadExternalFileSync=l;
2
2
  //# sourceMappingURL=loadExternalFile.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { BuildOptions } from 'esbuild';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return JSON5.parse(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return JSON5.parse(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":"2UAwBA,MAAa,GACX,EACA,IACoB,CACpB,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAOA,EAAAA,QAAM,OAAA,EAAA,EAAA,cAAmB,EAAU,QAAQ,CAAC,CAMrD,IAAM,EAAyCC,EAAAA,sBAAAA,EAAAA,EAAAA,cAFrB,EAAU,QAAQ,CAI1C,EACD,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcC,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAClB,CAEA,IAAM,EAAc,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CACrD,OAAOF,EAAAA,QAAM,MAAM,EAAY,CAMjC,IAAM,EAAyC,MAAMG,EAAAA,iBAFxC,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcD,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoCE,EAAAA,aAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,EACV,GAAS,UAAY,KACvB,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
1
+ {"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { BuildOptions } from 'esbuild';\nimport * as JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":"2UAcA,MAAM,EAAaA,EAAM,OAAUA,EAAc,SAAS,MAa7C,GACX,EACA,IACoB,CACpB,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAO,GAAA,EAAA,EAAA,cAAwB,EAAU,QAAQ,CAAC,CAMpD,IAAM,EAAyCC,EAAAA,sBAAAA,EAAAA,EAAAA,cAFrB,EAAU,QAAQ,CAI1C,EACD,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcC,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAIlB,OAAO,EADa,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CACvB,CAMhC,IAAM,EAAyC,MAAMC,EAAAA,iBAFxC,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcD,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoCE,EAAAA,aAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,EACV,GAAS,UAAY,KACvB,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
@@ -1,2 +1,2 @@
1
- import{colorizePath as e,logger as t}from"../logger.mjs";import{parseFileContent as n}from"./parseFileContent.mjs";import{transpileTSToCJS as r,transpileTSToCJSSync as i}from"./transpileTSToCJS.mjs";import{readFileSync as a}from"node:fs";import{extname as o}from"node:path";import{readFile as s}from"node:fs/promises";import c from"json5";const l=(e,r)=>{let s=o(e)||`.json`;try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return c.parse(a(e,`utf-8`));let o=i(a(e,`utf-8`),e);if(!o){t(`File could not be loaded.`,{level:`error`});return}let l=n(o,{projectRequire:r?.projectRequire,envVarOptions:r?.envVarOptions,additionalEnvVars:r?.additionalEnvVars,mocks:r?.mocks,aliases:r?.aliases});if(l===void 0){t(`File could not be loaded. Path : ${e}`);return}return l}catch(e){t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},u=async(i,a)=>{let l=o(i);try{if(l===`.json`||l===`.json5`||l===`.jsonc`){let e=await s(i,`utf-8`);return c.parse(e)}let o=await r(await s(i,`utf-8`),i,a?.buildOptions);if(!o){t(`File could not be loaded.`,{level:`error`});return}let u=n(o,{projectRequire:a?.projectRequire,envVarOptions:a?.envVarOptions,additionalEnvVars:a?.additionalEnvVars,mocks:a?.mocks,aliases:a?.aliases});if(u===void 0){t(`File could not be loaded. Path : ${e(i)}`);return}return u}catch(e){(a?.logError??!0)&&t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};export{u as loadExternalFile,l as loadExternalFileSync};
1
+ import{colorizePath as e,logger as t}from"../logger.mjs";import{parseFileContent as n}from"./parseFileContent.mjs";import{transpileTSToCJS as r,transpileTSToCJSSync as i}from"./transpileTSToCJS.mjs";import{readFileSync as a}from"node:fs";import{extname as o}from"node:path";import{readFile as s}from"node:fs/promises";import*as c from"json5";const l=c.parse||c.default?.parse,u=(e,r)=>{let s=o(e)||`.json`;try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return l(a(e,`utf-8`));let o=i(a(e,`utf-8`),e);if(!o){t(`File could not be loaded.`,{level:`error`});return}let c=n(o,{projectRequire:r?.projectRequire,envVarOptions:r?.envVarOptions,additionalEnvVars:r?.additionalEnvVars,mocks:r?.mocks,aliases:r?.aliases});if(c===void 0){t(`File could not be loaded. Path : ${e}`);return}return c}catch(e){t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},d=async(i,a)=>{let c=o(i);try{if(c===`.json`||c===`.json5`||c===`.jsonc`)return l(await s(i,`utf-8`));let o=await r(await s(i,`utf-8`),i,a?.buildOptions);if(!o){t(`File could not be loaded.`,{level:`error`});return}let u=n(o,{projectRequire:a?.projectRequire,envVarOptions:a?.envVarOptions,additionalEnvVars:a?.additionalEnvVars,mocks:a?.mocks,aliases:a?.aliases});if(u===void 0){t(`File could not be loaded. Path : ${e(i)}`);return}return u}catch(e){(a?.logError??!0)&&t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};export{d as loadExternalFile,u as loadExternalFileSync};
2
2
  //# sourceMappingURL=loadExternalFile.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { BuildOptions } from 'esbuild';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return JSON5.parse(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return JSON5.parse(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":"mVAwBA,MAAa,GACX,EACA,IACoB,CACpB,IAAM,EAAgB,EAAQ,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAO,EAAM,MAAM,EAAa,EAAU,QAAQ,CAAC,CAMrD,IAAM,EAAyC,EAFlC,EAAa,EAAU,QAAQ,CAI1C,EACD,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,EAAgB,EAAQ,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAClB,CAEA,IAAM,EAAc,MAAM,EAAS,EAAU,QAAQ,CACrD,OAAO,EAAM,MAAM,EAAY,CAMjC,IAAM,EAAyC,MAAM,EAFxC,MAAM,EAAS,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,EAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,EACV,GAAS,UAAY,KACvB,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
1
+ {"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { BuildOptions } from 'esbuild';\nimport * as JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":"sVAcA,MAAM,EAAa,EAAM,OAAU,EAAc,SAAS,MAa7C,GACX,EACA,IACoB,CACpB,IAAM,EAAgB,EAAQ,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAO,EAAW,EAAa,EAAU,QAAQ,CAAC,CAMpD,IAAM,EAAyC,EAFlC,EAAa,EAAU,QAAQ,CAI1C,EACD,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,EAAgB,EAAQ,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAIlB,OAAO,EADa,MAAM,EAAS,EAAU,QAAQ,CACvB,CAMhC,IAAM,EAAyC,MAAM,EAFxC,MAAM,EAAS,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,EAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,EACV,GAAS,UAAY,KACvB,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
@@ -20,9 +20,9 @@ declare const cookiesAttributesSchema: z.ZodObject<{
20
20
  secure: z.ZodOptional<z.ZodBoolean>;
21
21
  httpOnly: z.ZodOptional<z.ZodBoolean>;
22
22
  sameSite: z.ZodOptional<z.ZodEnum<{
23
+ none: "none";
23
24
  strict: "strict";
24
25
  lax: "lax";
25
- none: "none";
26
26
  }>>;
27
27
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
28
28
  }, z.core.$strip>;
@@ -47,9 +47,9 @@ declare const storageSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodEnum
47
47
  secure: z.ZodOptional<z.ZodBoolean>;
48
48
  httpOnly: z.ZodOptional<z.ZodBoolean>;
49
49
  sameSite: z.ZodOptional<z.ZodEnum<{
50
+ none: "none";
50
51
  strict: "strict";
51
52
  lax: "lax";
52
- none: "none";
53
53
  }>>;
54
54
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
55
55
  }, z.core.$strip>, z.ZodObject<{
@@ -72,9 +72,9 @@ declare const storageSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodEnum
72
72
  secure: z.ZodOptional<z.ZodBoolean>;
73
73
  httpOnly: z.ZodOptional<z.ZodBoolean>;
74
74
  sameSite: z.ZodOptional<z.ZodEnum<{
75
+ none: "none";
75
76
  strict: "strict";
76
77
  lax: "lax";
77
- none: "none";
78
78
  }>>;
79
79
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
80
80
  }, z.core.$strip>, z.ZodObject<{
@@ -155,9 +155,9 @@ declare const routingSchema: z.ZodObject<{
155
155
  secure: z.ZodOptional<z.ZodBoolean>;
156
156
  httpOnly: z.ZodOptional<z.ZodBoolean>;
157
157
  sameSite: z.ZodOptional<z.ZodEnum<{
158
+ none: "none";
158
159
  strict: "strict";
159
160
  lax: "lax";
160
- none: "none";
161
161
  }>>;
162
162
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
163
163
  }, z.core.$strip>, z.ZodObject<{
@@ -180,9 +180,9 @@ declare const routingSchema: z.ZodObject<{
180
180
  secure: z.ZodOptional<z.ZodBoolean>;
181
181
  httpOnly: z.ZodOptional<z.ZodBoolean>;
182
182
  sameSite: z.ZodOptional<z.ZodEnum<{
183
+ none: "none";
183
184
  strict: "strict";
184
185
  lax: "lax";
185
- none: "none";
186
186
  }>>;
187
187
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
188
188
  }, z.core.$strip>, z.ZodObject<{
@@ -352,9 +352,9 @@ declare const intlayerConfigSchema: z.ZodObject<{
352
352
  secure: z.ZodOptional<z.ZodBoolean>;
353
353
  httpOnly: z.ZodOptional<z.ZodBoolean>;
354
354
  sameSite: z.ZodOptional<z.ZodEnum<{
355
+ none: "none";
355
356
  strict: "strict";
356
357
  lax: "lax";
357
- none: "none";
358
358
  }>>;
359
359
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
360
360
  }, z.core.$strip>, z.ZodObject<{
@@ -377,9 +377,9 @@ declare const intlayerConfigSchema: z.ZodObject<{
377
377
  secure: z.ZodOptional<z.ZodBoolean>;
378
378
  httpOnly: z.ZodOptional<z.ZodBoolean>;
379
379
  sameSite: z.ZodOptional<z.ZodEnum<{
380
+ none: "none";
380
381
  strict: "strict";
381
382
  lax: "lax";
382
- none: "none";
383
383
  }>>;
384
384
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
385
385
  }, z.core.$strip>, z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"loadExternalFile.d.ts","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"mappings":";;;;;KAaY,uBAAA;EACV,aAAA,GAAgB,cAAA;EAChB,YAAA,GAAe,YAAA;EACf,QAAA;AAAA,IACE,qBAAA;;;;;;cAOS,oBAAA,GACX,QAAA,UACA,OAAA,GAAU,uBAAA;;;;;;cA2DC,gBAAA,GACX,QAAA,UACA,OAAA,GAAU,uBAAA,KACT,OAAA"}
1
+ {"version":3,"file":"loadExternalFile.d.ts","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"mappings":";;;;;KAgBY,uBAAA;EACV,aAAA,GAAgB,cAAA;EAChB,YAAA,GAAe,YAAA;EACf,QAAA;AAAA,IACE,qBAAA;;;;;;cAOS,oBAAA,GACX,QAAA,UACA,OAAA,GAAU,uBAAA;;;;;;cA2DC,gBAAA,GACX,QAAA,UACA,OAAA,GAAU,uBAAA,KACT,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/config",
3
- "version": "8.3.4",
3
+ "version": "8.4.0-canary.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": [
@@ -127,7 +127,7 @@
127
127
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
128
128
  },
129
129
  "dependencies": {
130
- "@intlayer/types": "8.3.4",
130
+ "@intlayer/types": "8.4.0-canary.0",
131
131
  "defu": "6.1.4",
132
132
  "dotenv": "17.3.1",
133
133
  "esbuild": "0.27.4",