@intlayer/config 9.2.0 → 9.3.1
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 +24 -24
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/cjs/bundle/index.cjs.map +1 -1
- package/dist/cjs/callers/base.cjs +0 -1
- package/dist/cjs/callers/base.cjs.map +1 -1
- package/dist/cjs/callers/compat/i18next.cjs +0 -1
- package/dist/cjs/callers/compat/i18next.cjs.map +1 -1
- package/dist/cjs/callers/compat/lingui.cjs +0 -1
- package/dist/cjs/callers/compat/lingui.cjs.map +1 -1
- package/dist/cjs/callers/compat/nextIntl.cjs +0 -1
- package/dist/cjs/callers/compat/nextIntl.cjs.map +1 -1
- package/dist/cjs/callers/compat/reactI18next.cjs +0 -1
- package/dist/cjs/callers/compat/reactI18next.cjs.map +1 -1
- package/dist/cjs/callers/compat/reactIntl.cjs +0 -1
- package/dist/cjs/callers/compat/reactIntl.cjs.map +1 -1
- package/dist/cjs/callers/compat/useIntl.cjs +0 -1
- package/dist/cjs/callers/compat/useIntl.cjs.map +1 -1
- package/dist/cjs/callers/compat/vueI18n.cjs +0 -1
- package/dist/cjs/callers/compat/vueI18n.cjs.map +1 -1
- package/dist/cjs/callers/transform.cjs +0 -1
- package/dist/cjs/callers/transform.cjs.map +1 -1
- package/dist/cjs/colors.cjs +0 -1
- package/dist/cjs/colors.cjs.map +1 -1
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs +10 -11
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/buildConfigurationFields.cjs +2 -7
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs +5 -12
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
- package/dist/cjs/defaultValues/analytics.cjs +0 -1
- package/dist/cjs/defaultValues/analytics.cjs.map +1 -1
- package/dist/cjs/defaultValues/build.cjs +0 -1
- package/dist/cjs/defaultValues/build.cjs.map +1 -1
- package/dist/cjs/defaultValues/compiler.cjs +0 -1
- package/dist/cjs/defaultValues/compiler.cjs.map +1 -1
- package/dist/cjs/defaultValues/content.cjs +0 -1
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/dictionary.cjs +0 -1
- package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
- package/dist/cjs/defaultValues/editor.cjs +0 -1
- package/dist/cjs/defaultValues/editor.cjs.map +1 -1
- package/dist/cjs/defaultValues/internationalization.cjs +0 -1
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/routing.cjs +0 -1
- package/dist/cjs/defaultValues/routing.cjs.map +1 -1
- package/dist/cjs/defaultValues/system.cjs +0 -1
- package/dist/cjs/defaultValues/system.cjs.map +1 -1
- package/dist/cjs/envVars/envVars.cjs +23 -1
- package/dist/cjs/envVars/envVars.cjs.map +1 -1
- package/dist/cjs/envVars/index.cjs +1 -0
- package/dist/cjs/loadEnvFile.cjs +8 -6
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs +4 -2
- package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +4 -2
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +4 -2
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
- package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
- package/dist/cjs/utils/alias.cjs +41 -6
- package/dist/cjs/utils/alias.cjs.map +1 -1
- package/dist/cjs/utils/builtConfigKeys.cjs +0 -1
- package/dist/cjs/utils/builtConfigKeys.cjs.map +1 -1
- package/dist/cjs/utils/cacheDisk.cjs +4 -2
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
- package/dist/cjs/utils/compareVersions.cjs +0 -1
- package/dist/cjs/utils/compareVersions.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs +0 -1
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
- package/dist/cjs/utils/getDictionarySelectorUsage.cjs +0 -1
- package/dist/cjs/utils/getDictionarySelectorUsage.cjs.map +1 -1
- package/dist/cjs/utils/getExtension.cjs +0 -1
- package/dist/cjs/utils/getExtension.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
- package/dist/cjs/utils/getStorageAttributes.cjs +1 -1
- package/dist/cjs/utils/getStorageAttributes.cjs.map +1 -1
- package/dist/cjs/utils/normalizePath.cjs +0 -1
- package/dist/cjs/utils/normalizePath.cjs.map +1 -1
- package/dist/cjs/utils/parseFilePathPattern.cjs +0 -1
- package/dist/cjs/utils/parseFilePathPattern.cjs.map +1 -1
- package/dist/cjs/utils/pathSecurity.cjs.map +1 -1
- package/dist/cjs/utils/retryManager.cjs +12 -1
- package/dist/cjs/utils/retryManager.cjs.map +1 -1
- package/dist/cjs/utils/setIntlayerIdentifier.cjs +0 -1
- package/dist/cjs/utils/setIntlayerIdentifier.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs +0 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs +0 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs +0 -1
- package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs +0 -1
- package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
- package/dist/esm/configFile/buildBrowserConfiguration.mjs +10 -11
- package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs +2 -7
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +5 -12
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/envVars/envVars.mjs +23 -1
- package/dist/esm/envVars/envVars.mjs.map +1 -1
- package/dist/esm/envVars/index.mjs +2 -2
- package/dist/esm/loadEnvFile.mjs +8 -6
- package/dist/esm/loadEnvFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleFile.mjs +4 -2
- package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +4 -2
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +4 -2
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
- package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
- package/dist/esm/utils/alias.mjs +41 -6
- package/dist/esm/utils/alias.mjs.map +1 -1
- package/dist/esm/utils/cacheDisk.mjs +4 -2
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/esm/utils/getStorageAttributes.mjs +1 -1
- package/dist/esm/utils/getStorageAttributes.mjs.map +1 -1
- package/dist/esm/utils/retryManager.mjs +12 -1
- package/dist/esm/utils/retryManager.mjs.map +1 -1
- package/dist/types/configFile/buildBrowserConfiguration.d.ts +8 -9
- package/dist/types/configFile/buildBrowserConfiguration.d.ts.map +1 -1
- package/dist/types/configFile/buildConfigurationFields.d.ts +1 -6
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/envVars/envVars.d.ts +23 -1
- package/dist/types/envVars/envVars.d.ts.map +1 -1
- package/dist/types/envVars/index.d.ts +2 -2
- package/dist/types/loadExternalFile/bundleJSFile.d.ts +1 -0
- package/dist/types/loadExternalFile/bundleJSFile.d.ts.map +1 -1
- package/dist/types/utils/retryManager.d.ts +7 -1
- package/dist/types/utils/retryManager.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStorageAttributes.mjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedCookieAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: ProcessedCookieAttributes;\n};\n\n/** Number of seconds in a day, used to convert a `number` of days. */\nconst SECONDS_PER_DAY = 60 * 60 * 24;\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Merges the user-facing `expires` and `maxAge` into a single, normalized and\n * serialization-safe expiry consumed by the client runtime.\n *\n * Precedence and normalization:\n * - `maxAge` (seconds) wins when set and is the internal unit (relative);\n * - `expires` as a `number` is interpreted as **days** and converted to\n * seconds (relative);\n * - `expires` as a `Date` (possibly a cross-realm instance, since config files\n * run in a `node:vm` sandbox) or an ISO string becomes an ISO **string**\n * (absolute). Strings survive `JSON.stringify`, unlike a `Date`.\n *\n * The result is therefore: a `number` = seconds from creation, a `string` =\n * absolute ISO date, or `undefined` for a session cookie.\n */\nconst normalizeCookieExpiry = (\n expires: CookiesAttributes['expires'],\n maxAge: CookiesAttributes['maxAge']\n): number | string | undefined => {\n if (typeof maxAge === 'number') return maxAge;\n if (expires === undefined) return undefined;\n if (\n expires instanceof Date ||\n Object.prototype.toString.call(expires) === '[object Date]'\n ) {\n return (expires as Date).toISOString();\n }\n if (typeof expires === 'string') return expires;\n return expires * SECONDS_PER_DAY;\n};\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const {\n name,\n path = '/',\n expires,\n maxAge,\n domain,\n secure,\n sameSite,\n httpOnly,\n } = options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: {\n path,\n expires: normalizeCookieExpiry(expires, maxAge),\n domain,\n secure,\n sameSite,\n httpOnly,\n },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...(accumulated.cookies ?? []), ...(partial.cookies ?? [])],\n localStorage: [\n ...(accumulated.localStorage ?? []),\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...(accumulated.sessionStorage ?? []),\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...(accumulated.headers ?? []), ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return {};\n\n const result = Array.isArray(options)\n ? options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult)\n : mergeStorageAttributes(emptyResult, processStorageEntry(options));\n\n // Remove empty arrays\n const cleanedResult: ProcessedStorageAttributes = {};\n\n if (result.cookies && result.cookies.length > 0) {\n cleanedResult.cookies = result.cookies;\n }\n\n if (result.localStorage && result.localStorage.length > 0) {\n cleanedResult.localStorage = result.localStorage;\n }\n\n if (result.sessionStorage && result.sessionStorage.length > 0) {\n cleanedResult.sessionStorage = result.sessionStorage;\n }\n\n if (result.headers && result.headers.length > 0) {\n cleanedResult.headers = result.headers;\n }\n\n return cleanedResult;\n};\n"],"mappings":";;;;AAuBA,MAAM,kBAAkB,OAAU;;;;;;;;;;;;;;;;AAqClC,MAAM,yBACJ,SACA,WACgC;CAChC,IAAI,OAAO,WAAW,UAAU,OAAO;CACvC,IAAI,YAAY,QAAW,OAAO;CAClC,IACE,mBAAmB,QACnB,OAAO,UAAU,SAAS,KAAK,OAAO,MAAM,iBAE5C,OAAQ,QAAiB,YAAY;CAEvC,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,OAAO,UAAU;AACnB;AAEA,MAAM,qBACJ,YACgB;CAChB,MAAM,EACJ,MACA,OAAO,KACP,SACA,QACA,QACA,QACA,UACA,aACE,WAAW,CAAC;CAChB,OAAO;EACL,MAAM;EACN,YAAY;GACV;GACA,SAAS,sBAAsB,SAAS,MAAM;GAC9C;GACA;GACA;GACA;EACF;CACF;AACF;AAEA,MAAM,yBACJ,aACqB,EACrB,MAAM,SAAS,0BACjB;AAEA,MAAM,qBACJ,aACiB,EACjB,MAAM,SAAS,4BACjB;AAEA,MAAM,iBAAiB,UAA4B;CACjD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,IAAI;CACV,OACE,EAAE,YAAY,YACd,cAAc,KACd,cAAc,KACd,YAAY;AAEhB;AAEA,MAAM,iBACJ,UAEA,UAAU,YACV,UAAU,kBACV,UAAU,oBACV,UAAU;AAMZ,MAAM,uBACJ,UACwC;CACxC,IAAI,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d,GAAI,YAAY,kBAAkB,CAAC,GACnC,GAAI,QAAQ,kBAAkB,CAAC,CACjC;CACA,SAAS,CAAC,GAAI,YAAY,WAAW,CAAC,GAAI,GAAI,QAAQ,WAAW,CAAC,CAAE;AACtE;;;;;;;;AASA,MAAa,wBACX,YAC+B;CAC/B,MAAM,cAA0C;EAC9C,SAAS,CAAC;EACV,cAAc,CAAC;EACf,gBAAgB,CAAC;EACjB,SAAS,CAAC;CACZ;CAEA,IAAI,YAAY,SAAS,YAAY,QAAW,OAAO,CAAC;CAExD,MAAM,SAAS,MAAM,QAAQ,OAAO,IAChC,QAAQ,QAAoC,KAAK,UAAU;EACzD,MAAM,UAAU,oBAAoB,KAAK;EACzC,OAAO,uBAAuB,KAAK,OAAO;CAC5C,GAAG,WAAW,IACd,uBAAuB,aAAa,oBAAoB,OAAO,CAAC;CAGpE,MAAM,gBAA4C,CAAC;CAEnD,IAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,GAC5C,cAAc,UAAU,OAAO;CAGjC,IAAI,OAAO,gBAAgB,OAAO,aAAa,SAAS,GACtD,cAAc,eAAe,OAAO;CAGtC,IAAI,OAAO,kBAAkB,OAAO,eAAe,SAAS,GAC1D,cAAc,iBAAiB,OAAO;CAGxC,IAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,GAC5C,cAAc,UAAU,OAAO;CAGjC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"getStorageAttributes.mjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedCookieAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: ProcessedCookieAttributes;\n};\n\n/** Number of seconds in a day, used to convert a `number` of days. */\nconst SECONDS_PER_DAY = 60 * 60 * 24;\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Merges the user-facing `expires` and `maxAge` into a single, normalized and\n * serialization-safe expiry consumed by the client runtime.\n *\n * Precedence and normalization:\n * - `maxAge` (seconds) wins when set and is the internal unit (relative);\n * - `expires` as a `number` is interpreted as **days** and converted to\n * seconds (relative);\n * - `expires` as a `Date` (possibly a cross-realm instance, since config files\n * run in a `node:vm` sandbox) or an ISO string becomes an ISO **string**\n * (absolute). Strings survive `JSON.stringify`, unlike a `Date`.\n *\n * The result is therefore: a `number` = seconds from creation, a `string` =\n * absolute ISO date, or `undefined` for a session cookie.\n */\nconst normalizeCookieExpiry = (\n expires: CookiesAttributes['expires'],\n maxAge: CookiesAttributes['maxAge']\n): number | string | undefined => {\n if (typeof maxAge === 'number') return maxAge;\n if (expires === undefined) return undefined;\n if (\n expires instanceof Date ||\n Object.prototype.toString.call(expires) === '[object Date]'\n ) {\n return (expires as Date).toISOString();\n }\n if (typeof expires === 'string') return expires;\n return expires * SECONDS_PER_DAY;\n};\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const {\n name,\n path = '/',\n expires,\n maxAge,\n domain,\n secure,\n sameSite,\n httpOnly,\n } = options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: {\n path,\n expires: normalizeCookieExpiry(expires, maxAge),\n domain,\n secure,\n sameSite,\n httpOnly,\n },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...(accumulated.cookies ?? []), ...(partial.cookies ?? [])],\n localStorage: [\n ...(accumulated.localStorage ?? []),\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...(accumulated.sessionStorage ?? []),\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...(accumulated.headers ?? []), ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return {};\n\n const result = Array.isArray(options)\n ? options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult)\n : mergeStorageAttributes(emptyResult, processStorageEntry(options));\n\n // Remove empty arrays\n const cleanedResult: ProcessedStorageAttributes = {};\n\n if (result.cookies && result.cookies.length > 0) {\n cleanedResult.cookies = result.cookies;\n }\n\n if (result.localStorage && result.localStorage.length > 0) {\n cleanedResult.localStorage = result.localStorage;\n }\n\n if (result.sessionStorage && result.sessionStorage.length > 0) {\n cleanedResult.sessionStorage = result.sessionStorage;\n }\n\n if (result.headers && result.headers.length > 0) {\n cleanedResult.headers = result.headers;\n }\n\n return cleanedResult;\n};\n"],"mappings":";;;;AAuBA,MAAM,kBAAkB;;;;;;;;;;;;;;;;AAqCxB,MAAM,yBACJ,SACA,WACgC;CAChC,IAAI,OAAO,WAAW,UAAU,OAAO;CACvC,IAAI,YAAY,QAAW,OAAO;CAClC,IACE,mBAAmB,QACnB,OAAO,UAAU,SAAS,KAAK,OAAO,MAAM,iBAE5C,OAAQ,QAAiB,YAAY;CAEvC,IAAI,OAAO,YA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AGjC,IAAI,OAAO,gBAAgB,OAAO,aAAa,SAAS,GACtD,cAAc,eAAe,OAAO;CAGtC,IAAI,OAAO,kBAAkB,OAAO,eAAe,SAAS,GAC1D,cAAc,iBAAiB,OAAO;CAGxC,IAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,GAC5C,cAAc,UAAU,OAAO;CAGjC,OAAO;AACT"}
|
|
@@ -11,13 +11,24 @@ const DEFAULT_DELAY = 0;
|
|
|
11
11
|
* @param options { maxRetry, delay }
|
|
12
12
|
* @returns A new function with the same signature as `fn`
|
|
13
13
|
*/
|
|
14
|
-
const retryManager = (fn, { maxRetry = DEFAULT_MAX_RETRY, delay = DEFAULT_DELAY, onError, onMaxTryReached } = {}) => async (...args) => {
|
|
14
|
+
const retryManager = (fn, { maxRetry = DEFAULT_MAX_RETRY, delay = DEFAULT_DELAY, shouldRetry, onError, onMaxTryReached } = {}) => async (...args) => {
|
|
15
15
|
let lastError;
|
|
16
16
|
for (let attempt = 0; attempt <= maxRetry; attempt++) try {
|
|
17
17
|
return await fn(...args);
|
|
18
18
|
} catch (err) {
|
|
19
19
|
lastError = err;
|
|
20
20
|
const error = extractErrorMessage(err);
|
|
21
|
+
if (shouldRetry && !shouldRetry(err)) {
|
|
22
|
+
if (onMaxTryReached) {
|
|
23
|
+
onMaxTryReached({
|
|
24
|
+
error,
|
|
25
|
+
attempt,
|
|
26
|
+
maxRetry
|
|
27
|
+
});
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
21
32
|
if (attempt >= maxRetry) {
|
|
22
33
|
if (onMaxTryReached) {
|
|
23
34
|
onMaxTryReached?.({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryManager.mjs","names":[],"sources":["../../../src/utils/retryManager.ts"],"sourcesContent":["import { logger } from '../logger';\nimport { extractErrorMessage } from './extractErrorMessage';\n\nexport type RetryManagerOptions = {\n /** maximum number of retries before giving up */\n maxRetry?: number;\n /** delay between attempts, in milliseconds */\n delay?: number;\n /** function to call when an error occurs */\n onError?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n /** function to call when the maximum number of retries is reached */\n onMaxTryReached?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n};\n\nconst DEFAULT_MAX_RETRY = 3;\nconst DEFAULT_DELAY = 0;\n\n/**\n * Wrap an async function `fn` so it’s retried on failure.\n *\n * @param fn The async function to wrap\n * @param options { maxRetry, delay }\n * @returns A new function with the same signature as `fn`\n */\nexport const retryManager =\n <Args extends any[], R>(\n fn: (...args: Args) => Promise<R>,\n {\n maxRetry = DEFAULT_MAX_RETRY,\n delay = DEFAULT_DELAY,\n onError,\n onMaxTryReached,\n }: RetryManagerOptions = {}\n ): ((...args: Args) => Promise<R>) =>\n // ───────────────────────────────^ returned wrapper function\n async (...args: Args): Promise<R> => {\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetry; attempt++) {\n try {\n return await fn(...args);\n } catch (err) {\n lastError = err;\n const error = extractErrorMessage(err);\n\n // If this was the last attempt, handle max retry reached\n if (attempt >= maxRetry) {\n if (onMaxTryReached) {\n onMaxTryReached?.({ error, attempt, maxRetry });\n return null as R;\n }\n\n // Otherwise, throw the error\n throw err;\n }\n\n if (onError) {\n onError?.({ error, attempt, maxRetry });\n } else {\n logger(error, {\n level: 'error',\n });\n }\n\n // Wait before retrying\n if (delay > 0) {\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n }\n\n // This should never be reached, but TypeScript needs it\n throw (\n lastError ?? new Error('Unexpected: retry loop completed without result')\n );\n };\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"retryManager.mjs","names":[],"sources":["../../../src/utils/retryManager.ts"],"sourcesContent":["import { logger } from '../logger';\nimport { extractErrorMessage } from './extractErrorMessage';\n\nexport type RetryManagerOptions = {\n /** maximum number of retries before giving up */\n maxRetry?: number;\n /** delay between attempts, in milliseconds */\n delay?: number;\n /**\n * Decides whether a given error is worth another attempt. Returning `false`\n * gives up immediately, which avoids replaying a request that can only fail\n * again (ex: a `404`). Every error is retried when omitted.\n */\n shouldRetry?: (error: unknown) => boolean;\n /** function to call when an error occurs */\n onError?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n /** function to call when the maximum number of retries is reached */\n onMaxTryReached?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n};\n\nconst DEFAULT_MAX_RETRY = 3;\nconst DEFAULT_DELAY = 0;\n\n/**\n * Wrap an async function `fn` so it’s retried on failure.\n *\n * @param fn The async function to wrap\n * @param options { maxRetry, delay }\n * @returns A new function with the same signature as `fn`\n */\nexport const retryManager =\n <Args extends any[], R>(\n fn: (...args: Args) => Promise<R>,\n {\n maxRetry = DEFAULT_MAX_RETRY,\n delay = DEFAULT_DELAY,\n shouldRetry,\n onError,\n onMaxTryReached,\n }: RetryManagerOptions = {}\n ): ((...args: Args) => Promise<R>) =>\n // ───────────────────────────────^ returned wrapper function\n async (...args: Args): Promise<R> => {\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetry; attempt++) {\n try {\n return await fn(...args);\n } catch (err) {\n lastError = err;\n const error = extractErrorMessage(err);\n\n // Give up right away on an error that another attempt cannot fix\n if (shouldRetry && !shouldRetry(err)) {\n if (onMaxTryReached) {\n onMaxTryReached({ error, attempt, maxRetry });\n return null as R;\n }\n\n throw err;\n }\n\n // If this was the last attempt, handle max retry reached\n if (attempt >= maxRetry) {\n if (onMaxTryReached) {\n onMaxTryReached?.({ error, attempt, maxRetry });\n return null as R;\n }\n\n // Otherwise, throw the error\n throw err;\n }\n\n if (onError) {\n onError?.({ error, attempt, maxRetry });\n } else {\n logger(error, {\n level: 'error',\n });\n }\n\n // Wait before retrying\n if (delay > 0) {\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n }\n\n // This should never be reached, but TypeScript needs it\n throw (\n lastError ?? new Error('Unexpected: retry loop completed without result')\n );\n };\n"],"mappings":";;;;AA4BA,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;;;;;;;;AAStB,MAAa,gBAET,IACA,EACE,WAAW,mBACX,QAAQ,eACR,aACA,SACA,oBACuB,CAAC,MAG5B,OAAO,GAAG,SAA2B;CACnC,IAAI;CAEJ,KAAK,IAAI,UAAU,GAAG,WAAW,UAAU,WACzC,IAAI;EACF,OAAO,MAAM,GAAG,GAAG,IAAI;CACzB,SAAS,KAAK;EACZ,YAAY;EACZ,MAAM,QAAQ,oBAAoB,GAAG;EAGrC,IAAI,eAAe,CAAC,YAAY,GAAG,GAAG;GACpC,IAAI,iBAAiB;IACnB,gBAAgB;KAAE;KAAO;KAAS;IAAS,CAAC;IAC5C,OAAO;GACT;GAEA,MAAM;EACR;EAGA,IAAI,WAAW,UAAU;GACvB,IAAI,iBAAiB;IACnB,kBAAkB;KAAE;KAAO;KAAS;IAAS,CAAC;IAC9C,OAAO;GACT;GAGA,MAAM;EACR;EAEA,IAAI,SACF,UAAU;GAAE;GAAO;GAAS;EAAS,CAAC;OAEtC,OAAO,OAAO,EACZ,OAAO,QACT,CAAC;EAIH,IAAI,QAAQ,GACV,MAAM,IAAI,SAAS,QAAQ,WAAW,KAAK,KAAK,CAAC;CAErD;CAIF,MACE,6BAAa,IAAI,MAAM,iDAAiD;AAE5E"}
|
|
@@ -41,19 +41,18 @@ declare const buildRoutingFields: (customConfiguration?: Partial<CustomRoutingCo
|
|
|
41
41
|
* (`clientId`, `clientSecret`). The browser-safe {@link BrowserIntlayerConfig}
|
|
42
42
|
* omits those fields when exposing config to the client.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
* configuration file
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
44
|
+
* `clientId` / `clientSecret` are never inferred from the environment: the
|
|
45
|
+
* configuration file is the single source of truth. A project that wants to
|
|
46
|
+
* authenticate from its `.env` file must wire the variables explicitly, e.g.
|
|
47
|
+
* `clientId: process.env.INTLAYER_CLIENT_ID`. Commenting those lines out is
|
|
48
|
+
* therefore enough to disable every credentialed behaviour (remote dictionary
|
|
49
|
+
* fetching, CMS access) even when the variables remain defined in the
|
|
50
|
+
* environment.
|
|
50
51
|
*
|
|
51
52
|
* @param customConfiguration - Partial user-supplied editor config.
|
|
52
|
-
* @param env - Environment variables used to resolve credential fallbacks.
|
|
53
|
-
* Defaults to `process.env`.
|
|
54
53
|
* @returns A fully-defaulted {@link EditorConfig}.
|
|
55
54
|
*/
|
|
56
|
-
declare const buildEditorFields: (customConfiguration?: Partial<EditorConfig
|
|
55
|
+
declare const buildEditorFields: (customConfiguration?: Partial<EditorConfig>) => EditorConfig;
|
|
57
56
|
/**
|
|
58
57
|
* Build the analytics section of the Intlayer configuration.
|
|
59
58
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBrowserConfiguration.d.ts","names":[],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"mappings":";;;;;;;;;KAqDY;EACV,sBAAsB,KACpB;EAGF,SAAS;EACT,QAAQ,KAAK;EACb,WAAW;EACX,KAAK,KAAK;;QAGJ;YACI;;IAER,kBAAkB;;;;;;;;;cAiBT,kCAA+B,sBACpB,QAAQ,gCAC7B;;;;;;;cA+CU,qBAAkB,sBACP,QAAQ,yBAC7B
|
|
1
|
+
{"version":3,"file":"buildBrowserConfiguration.d.ts","names":[],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"mappings":";;;;;;;;;KAqDY;EACV,sBAAsB,KACpB;EAGF,SAAS;EACT,QAAQ,KAAK;EACb,WAAW;EACX,KAAK,KAAK;;QAGJ;YACI;;IAER,kBAAkB;;;;;;;;;cAiBT,kCAA+B,sBACpB,QAAQ,gCAC7B;;;;;;;cA+CU,qBAAkB,sBACP,QAAQ,yBAC7B;;;;;;;;;;;;;;;;;;;cA4HU,oBAAiB,sBACN,QAAQ,kBAC7B;;;;;;;;;;;cAsIU,uBAAoB,sBACT,QAAQ,qBAC7B;;;;;;;;cA8BU,iBAAc,sBACH,QAAQ,YAAU,eACzB,iBACd;;;;;;;;;;;;;;;;;;;;;;;cAwDU,4BAAyB,eACrB,yBACd;;;;;;;;;;;;cAiCU,8BAA2B,QAC9B,mBACP"}
|
|
@@ -17,14 +17,9 @@ import { CustomIntlayerConfig, IntlayerConfig, LogFunctions } from "@intlayer/ty
|
|
|
17
17
|
* @param customConfiguration - Optional user-supplied configuration object.
|
|
18
18
|
* @param baseDir - Project root directory. Defaults to `process.cwd()`.
|
|
19
19
|
* @param logFunctions - Optional custom logging functions.
|
|
20
|
-
* @param env - Environment variables used to resolve credential fallbacks
|
|
21
|
-
* (e.g. `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET`). Defaults to
|
|
22
|
-
* `process.env`. Callers loading a custom env file (such as the CLI
|
|
23
|
-
* `--env-file` flag) should pass the merged env so credentials defined there
|
|
24
|
-
* are picked up without polluting `process.env`.
|
|
25
20
|
* @returns A fully-built {@link IntlayerConfig}.
|
|
26
21
|
*/
|
|
27
|
-
declare const buildConfigurationFields: (customConfiguration?: CustomIntlayerConfig, baseDir?: string, logFunctions?: LogFunctions
|
|
22
|
+
declare const buildConfigurationFields: (customConfiguration?: CustomIntlayerConfig, baseDir?: string, logFunctions?: LogFunctions) => IntlayerConfig;
|
|
28
23
|
//#endregion
|
|
29
24
|
export { type BrowserIntlayerConfig, buildAnalyticsFields, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration };
|
|
30
25
|
//# sourceMappingURL=buildConfigurationFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;cA4uBa,2BAAwB,sBACb,sBAAoB,kBAC1B,eACD,iBACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"mappings":";;;;KAcY;EACV;EACA,WAAW;EAEX;EACA;EAEA,eAAe;EAEf,UAAU,OAAO;EAEjB;EAEA,eAAe;IACb,KAAK;KAEG;EACV,eAAe;EACf,qBAAqB;EACrB;EACA;;;;;cAMW,8BAA2B,UAC5B,4BACT;;;;cAqGU,mBAAgB,UACjB,4BACT"}
|
|
@@ -31,6 +31,28 @@ declare const formatNodeTypeToEnvVar: (nodeTypes: string[], wrapKey?: (key: stri
|
|
|
31
31
|
* // { 'process.env.INTLAYER_DICTIONARY_SELECTOR': '"false"' }
|
|
32
32
|
*/
|
|
33
33
|
declare const formatDictionarySelectorEnvVar: (hasDictionarySelector: boolean, wrapKey?: (key: string) => string, wrapValue?: (value: string) => string) => Record<string, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the env-var definition selecting the local `nest()` resolver, which
|
|
36
|
+
* reads the nest targets the optimizer attached to each dictionary instead of
|
|
37
|
+
* looking them up in the global registry.
|
|
38
|
+
*
|
|
39
|
+
* Emit it only when the optimize transform actually runs, since it is that
|
|
40
|
+
* transform which injects the attachment. Setting it to `"true"` lets bundlers
|
|
41
|
+
* dead-code-eliminate the registry-based resolver, and with it the
|
|
42
|
+
* `@intlayer/dictionaries-entry` import — which is what allows the dictionaries
|
|
43
|
+
* entry to be emptied while nesting keeps working.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* formatOptimizedNestingEnvVar(true)
|
|
47
|
+
* // { INTLAYER_OPTIMIZED_NESTING: '"true"' }
|
|
48
|
+
*
|
|
49
|
+
* formatOptimizedNestingEnvVar(false)
|
|
50
|
+
* // {}
|
|
51
|
+
*
|
|
52
|
+
* formatOptimizedNestingEnvVar(true, (k) => `process.env.${k}`, (v) => `"${v}"`)
|
|
53
|
+
* // { 'process.env.INTLAYER_OPTIMIZED_NESTING': '"true"' }
|
|
54
|
+
*/
|
|
55
|
+
declare const formatOptimizedNestingEnvVar: (isOptimized: boolean, wrapKey?: (key: string) => string, wrapValue?: (value: string) => string) => Record<string, string>;
|
|
34
56
|
/**
|
|
35
57
|
* Returns env-var definitions for the full Intlayer config to be injected at
|
|
36
58
|
* build time. Allows bundlers to dead-code-eliminate unused routing modes,
|
|
@@ -45,5 +67,5 @@ declare const formatDictionarySelectorEnvVar: (hasDictionarySelector: boolean, w
|
|
|
45
67
|
*/
|
|
46
68
|
declare const getConfigEnvVars: (config: IntlayerConfig, wrapKey?: (key: string) => string, wrapValue?: (value: string) => string) => Record<string, string>;
|
|
47
69
|
//#endregion
|
|
48
|
-
export { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars };
|
|
70
|
+
export { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, formatOptimizedNestingEnvVar, getConfigEnvVars };
|
|
49
71
|
//# sourceMappingURL=envVars.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envVars.d.ts","names":[],"sources":["../../../src/envVars/envVars.ts"],"mappings":";;;;;;;;;;;;;cA2Ba,yBAAsB,qBACd,WAAA,wBACG,aAAA,6BAErB;;;;;;;;;;;;;;;;;;;cA4BU,iCAA8B,gCACX,WAAA,wBACR,aAAA,6BAErB;;;;;;;;;;;;;cAiBU,mBAAgB,QACnB,gBAAc,WAAA,wBACA,aAAA,6BAErB"}
|
|
1
|
+
{"version":3,"file":"envVars.d.ts","names":[],"sources":["../../../src/envVars/envVars.ts"],"mappings":";;;;;;;;;;;;;cA2Ba,yBAAsB,qBACd,WAAA,wBACG,aAAA,6BAErB;;;;;;;;;;;;;;;;;;;cA4BU,iCAA8B,gCACX,WAAA,wBACR,aAAA,6BAErB;;;;;;;;;;;;;;;;;;;;;;cA0BU,+BAA4B,sBACnB,WAAA,wBACE,aAAA,6BAErB;;;;;;;;;;;;;cAiBU,mBAAgB,QACnB,gBAAc,WAAA,wBACA,aAAA,6BAErB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars } from "./envVars.js";
|
|
2
|
-
export { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars };
|
|
1
|
+
import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, formatOptimizedNestingEnvVar, getConfigEnvVars } from "./envVars.js";
|
|
2
|
+
export { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, formatOptimizedNestingEnvVar, getConfigEnvVars };
|
|
@@ -35,6 +35,7 @@ declare const bundleJSFile: (buildOptions: BuildOptions) => Promise<import("esbu
|
|
|
35
35
|
color?: boolean;
|
|
36
36
|
logLimit?: number;
|
|
37
37
|
logOverride?: Record<string, import("esbuild").LogLevel>;
|
|
38
|
+
logStyle?: import("esbuild").LogStyle;
|
|
38
39
|
tsconfigRaw?: string | import("esbuild").TsconfigRaw;
|
|
39
40
|
splitting?: boolean;
|
|
40
41
|
preserveSymlinks?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleJSFile.d.ts","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"mappings":";;cAyBa,eAAY,cAAwB,iBAAY,0BAAA
|
|
1
|
+
{"version":3,"file":"bundleJSFile.d.ts","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"mappings":";;cAyBa,eAAY,cAAwB,iBAAY,0BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAZlD;aACC;aACA;aACD;aACC;aACA;aACC;aACF;aACC"}
|
|
@@ -4,6 +4,12 @@ type RetryManagerOptions = {
|
|
|
4
4
|
maxRetry?: number;
|
|
5
5
|
/** delay between attempts, in milliseconds */
|
|
6
6
|
delay?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Decides whether a given error is worth another attempt. Returning `false`
|
|
9
|
+
* gives up immediately, which avoids replaying a request that can only fail
|
|
10
|
+
* again (ex: a `404`). Every error is retried when omitted.
|
|
11
|
+
*/
|
|
12
|
+
shouldRetry?: (error: unknown) => boolean;
|
|
7
13
|
/** function to call when an error occurs */
|
|
8
14
|
onError?: (details: {
|
|
9
15
|
error: string;
|
|
@@ -24,7 +30,7 @@ type RetryManagerOptions = {
|
|
|
24
30
|
* @param options { maxRetry, delay }
|
|
25
31
|
* @returns A new function with the same signature as `fn`
|
|
26
32
|
*/
|
|
27
|
-
declare const retryManager: <Args extends any[], R>(fn: (...args: Args) => Promise<R>, { maxRetry, delay, onError, onMaxTryReached }?: RetryManagerOptions) => ((...args: Args) => Promise<R>);
|
|
33
|
+
declare const retryManager: <Args extends any[], R>(fn: (...args: Args) => Promise<R>, { maxRetry, delay, shouldRetry, onError, onMaxTryReached }?: RetryManagerOptions) => ((...args: Args) => Promise<R>);
|
|
28
34
|
//#endregion
|
|
29
35
|
export { RetryManagerOptions, retryManager };
|
|
30
36
|
//# sourceMappingURL=retryManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryManager.d.ts","names":[],"sources":["../../../src/utils/retryManager.ts"],"mappings":";KAGY;;EAEV;;EAEA;;
|
|
1
|
+
{"version":3,"file":"retryManager.d.ts","names":[],"sources":["../../../src/utils/retryManager.ts"],"mappings":";KAGY;;EAEV;;EAEA;;;;;;EAMA,eAAe;;EAEf,WAAW;IACT;IACA;IACA;;;EAGF,mBAAmB;IACjB;IACA;IACA;;;;;;;;;;cAcS,eACV,oBAAoB,GAAC,QACZ,MAAM,SAAS,QAAQ,MAAE,UAAA,OAAA,aAAA,SAAA,oBAO9B,6BACG,MAAM,SAAS,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.1",
|
|
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": [
|
|
@@ -164,15 +164,15 @@
|
|
|
164
164
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
165
165
|
},
|
|
166
166
|
"dependencies": {
|
|
167
|
-
"@intlayer/types": "9.
|
|
167
|
+
"@intlayer/types": "9.3.1",
|
|
168
168
|
"defu": "6.1.7",
|
|
169
169
|
"dotenv": "17.4.2",
|
|
170
|
-
"esbuild": "0.28.
|
|
170
|
+
"esbuild": "0.28.2",
|
|
171
171
|
"json5": "2.2.3",
|
|
172
172
|
"zod": "4.4.3"
|
|
173
173
|
},
|
|
174
174
|
"devDependencies": {
|
|
175
|
-
"@types/node": "26.
|
|
175
|
+
"@types/node": "26.2.0",
|
|
176
176
|
"@utils/ts-config": "1.0.4",
|
|
177
177
|
"@utils/ts-config-types": "1.0.4",
|
|
178
178
|
"@utils/tsdown-config": "1.0.4",
|