fastify-intlayer 7.5.13 → 7.5.14
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/index.cjs.map +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["fastifyIntlayer: FastifyPluginAsync","negotiatorHeaders: Record<string, string>","getIntlayerWrapped: typeof getIntlayerFunction","getDictionaryWrapped: typeof getDictionaryFunction","t","getIntlayer: typeof getIntlayerFunction","getDictionary: typeof getDictionaryFunction"],"sources":["../../src/index.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n getLocaleFromStorage,\n getTranslation,\n localeDetector,\n} from '@intlayer/core';\nimport type { Locale, StrictModeLocaleMap } from '@intlayer/types';\nimport { createNamespace } from 'cls-hooked';\nimport type { FastifyPluginAsync, FastifyRequest } from 'fastify';\nimport fp from 'fastify-plugin';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * Retrieves the locale from storage (cookies, headers).\n * Note: req.cookies requires @fastify/cookie to be registered.\n * We cast req to any to avoid hard dependency on @fastify/cookie types.\n */\nconst getStorageLocale = (req: FastifyRequest): Locale | undefined =>\n getLocaleFromStorage({\n getCookie: (name: string) => (req as any).cookies?.[name],\n getHeader: (name: string) => req.headers?.[name] as string | undefined,\n });\n\nconst appNamespace = createNamespace('app');\n\nprepareIntlayer(configuration);\n\n// Module augmentation to type the request decoration\ndeclare module 'fastify' {\n interface FastifyRequest {\n intlayer: {\n locale: Locale;\n defaultLocale: Locale;\n locale_storage?: Locale;\n locale_detected?: Locale;\n t: <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ) => T;\n getIntlayer: typeof getIntlayerFunction;\n getDictionary: typeof getDictionaryFunction;\n };\n }\n}\n\nexport const translateFunction =\n (req: FastifyRequest) =>\n <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ): T => {\n // Access the decorated state from the request\n const { locale: currentLocale, defaultLocale } = req.intlayer;\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[\n targetLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Fastify Plugin to detect locale and load it into request context\n */\nconst fastifyIntlayer: FastifyPluginAsync = async (fastify, _opts) => {\n // Decorate the request object to ensure types are stable.\n // We use 'null as any' to bypass the initial type check, knowing\n // the preHandler will populate it before any route handler runs.\n if (!fastify.hasRequestDecorator('intlayer')) {\n fastify.decorateRequest('intlayer', null as any);\n }\n\n fastify.addHook('preHandler', (req, _reply, done) => {\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeFromStorage = getStorageLocale(req);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n if (req && typeof req.headers === 'object') {\n for (const key in req.headers) {\n const val = req.headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n // Handle array headers (unlikely for accept-language but possible in Fastify)\n negotiatorHeaders[key] = val.join(',');\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n const defaultLocale = internationalization.defaultLocale;\n\n // Helper functions bound to the current request context\n const getIntlayerWrapped: typeof getIntlayerFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionaryWrapped: typeof getDictionaryFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Assign data to request decoration\n req.intlayer = {\n locale_storage: localeFromStorage,\n locale_detected: localeDetected,\n locale,\n defaultLocale,\n getIntlayer: getIntlayerWrapped,\n getDictionary: getDictionaryWrapped,\n t: undefined as unknown as any, // Placeholder\n };\n\n // Now bind t using the updated req\n const t = translateFunction(req);\n req.intlayer.t = t;\n\n // Run CLS context\n appNamespace.run(() => {\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayerWrapped);\n appNamespace.set('getDictionary', getDictionaryWrapped);\n\n done();\n });\n });\n};\n\n// Export as a Fastify Plugin (wrapped in fp to skip encapsulation)\nexport const intlayer = fp(fastifyIntlayer, {\n name: 'fastify-intlayer',\n fastify: '5.x',\n});\n\n// Global exports that rely on CLS (Async Local Storage)\nexport const t = <Content = string>(\n content: StrictModeLocaleMap<Content>,\n locale?: Locale\n): Content => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('t') !== 'function') {\n throw new Error(\n 'Using the import { t } from \"fastify-intlayer\" is not supported in your environment outside of a request context or proper setup. Use req.intlayer.t instead.'\n );\n }\n\n return appNamespace.get('t')(content, locale);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n\n return getTranslation(\n content,\n locale ?? internationalization.defaultLocale\n );\n }\n};\n\nexport const getIntlayer: typeof getIntlayerFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getIntlayer') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getIntlayer')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getIntlayerFunction(...args);\n }\n};\n\nexport const getDictionary: typeof getDictionaryFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getDictionary') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getDictionary')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getDictionaryFunction(...args);\n }\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,wDAAkC;AACxC,MAAM,EAAE,yBAAyB;;;;;;AAOjC,MAAM,oBAAoB,iDACH;CACnB,YAAY,SAAkB,IAAY,UAAU;CACpD,YAAY,SAAiB,IAAI,UAAU;CAC5C,CAAC;AAEJ,MAAM,+CAA+B,MAAM;wCAE3B,cAAc;AAoB9B,MAAa,qBACV,SAEC,SACA,WACM;CAEN,MAAM,EAAE,QAAQ,eAAe,kBAAkB,IAAI;CAErD,MAAM,eAAe,UAAU;AAE/B,KAAI,OAAO,YAAY,YACrB,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO;AAGT,KACE,OAAO,UACL,kBACI,YAEN,KACE,OAAO,UACL,mBACI,YAEN,QAAO;KAEP,2CAAsB,SAAS,cAAc;AAIjD,2CAAsB,SAAS,aAAa;;;;;AAMhD,MAAMA,kBAAsC,OAAO,SAAS,UAAU;AAIpE,KAAI,CAAC,QAAQ,oBAAoB,WAAW,CAC1C,SAAQ,gBAAgB,YAAY,KAAY;AAGlD,SAAQ,QAAQ,eAAe,KAAK,QAAQ,SAAS;EAEnD,MAAM,oBAAoB,iBAAiB,IAAI;EAE/C,MAAMC,oBAA4C,EAAE;AA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O,iBAAiB,YAC1B,OAAM,IAAI,MACR,iFACD;AAGH,MAAI,OAAO,aAAa,IAAI,cAAc,KAAK,WAC7C,OAAM,IAAI,MACR,oEACD;AAGH,SAAO,aAAa,IAAI,cAAc,CAAC,GAAG,KAAK;UACxC,OAAO;AACd,MAAI,QAAQ,IAAI,aAAa,cAC3B,SAAQ,MAAO,MAAgB,QAAQ;AAEzC,yCAA2B,GAAG,KAAK;;;AAIvC,MAAaC,iBAA+C,GAAG,SAAS;AACtE,KAAI;AACF,MAAI,OAAO,iBAAiB,YAC1B,OAAM,IAAI,MACR,iFACD;AAGH,MAAI,OAAO,aAAa,IAAI,gBAAgB,KAAK,WAC/C,OAAM,IAAI,MACR,oEACD;AAGH,SAAO,aAAa,IAAI,gBAAgB,CAAC,GAAG,KAAK;UAC1C,OAAO;AACd,MAAI,QAAQ,IAAI,aAAa,cAC3B,SAAQ,MAAO,MAAgB,QAAQ;AAEzC,2CAA6B,GAAG,KAAK"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["t"],"sources":["../../src/index.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n getLocaleFromStorage,\n getTranslation,\n localeDetector,\n} from '@intlayer/core';\nimport type { Locale, StrictModeLocaleMap } from '@intlayer/types';\nimport { createNamespace } from 'cls-hooked';\nimport type { FastifyPluginAsync, FastifyRequest } from 'fastify';\nimport fp from 'fastify-plugin';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * Retrieves the locale from storage (cookies, headers).\n * Note: req.cookies requires @fastify/cookie to be registered.\n * We cast req to any to avoid hard dependency on @fastify/cookie types.\n */\nconst getStorageLocale = (req: FastifyRequest): Locale | undefined =>\n getLocaleFromStorage({\n getCookie: (name: string) => (req as any).cookies?.[name],\n getHeader: (name: string) => req.headers?.[name] as string | undefined,\n });\n\nconst appNamespace = createNamespace('app');\n\nprepareIntlayer(configuration);\n\n// Module augmentation to type the request decoration\ndeclare module 'fastify' {\n interface FastifyRequest {\n intlayer: {\n locale: Locale;\n defaultLocale: Locale;\n locale_storage?: Locale;\n locale_detected?: Locale;\n t: <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ) => T;\n getIntlayer: typeof getIntlayerFunction;\n getDictionary: typeof getDictionaryFunction;\n };\n }\n}\n\nexport const translateFunction =\n (req: FastifyRequest) =>\n <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ): T => {\n // Access the decorated state from the request\n const { locale: currentLocale, defaultLocale } = req.intlayer;\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[\n targetLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Fastify Plugin to detect locale and load it into request context\n */\nconst fastifyIntlayer: FastifyPluginAsync = async (fastify, _opts) => {\n // Decorate the request object to ensure types are stable.\n // We use 'null as any' to bypass the initial type check, knowing\n // the preHandler will populate it before any route handler runs.\n if (!fastify.hasRequestDecorator('intlayer')) {\n fastify.decorateRequest('intlayer', null as any);\n }\n\n fastify.addHook('preHandler', (req, _reply, done) => {\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeFromStorage = getStorageLocale(req);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n if (req && typeof req.headers === 'object') {\n for (const key in req.headers) {\n const val = req.headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n // Handle array headers (unlikely for accept-language but possible in Fastify)\n negotiatorHeaders[key] = val.join(',');\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n const defaultLocale = internationalization.defaultLocale;\n\n // Helper functions bound to the current request context\n const getIntlayerWrapped: typeof getIntlayerFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionaryWrapped: typeof getDictionaryFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Assign data to request decoration\n req.intlayer = {\n locale_storage: localeFromStorage,\n locale_detected: localeDetected,\n locale,\n defaultLocale,\n getIntlayer: getIntlayerWrapped,\n getDictionary: getDictionaryWrapped,\n t: undefined as unknown as any, // Placeholder\n };\n\n // Now bind t using the updated req\n const t = translateFunction(req);\n req.intlayer.t = t;\n\n // Run CLS context\n appNamespace.run(() => {\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayerWrapped);\n appNamespace.set('getDictionary', getDictionaryWrapped);\n\n done();\n });\n });\n};\n\n// Export as a Fastify Plugin (wrapped in fp to skip encapsulation)\nexport const intlayer = fp(fastifyIntlayer, {\n name: 'fastify-intlayer',\n fastify: '5.x',\n});\n\n// Global exports that rely on CLS (Async Local Storage)\nexport const t = <Content = string>(\n content: StrictModeLocaleMap<Content>,\n locale?: Locale\n): Content => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('t') !== 'function') {\n throw new Error(\n 'Using the import { t } from \"fastify-intlayer\" is not supported in your environment outside of a request context or proper setup. Use req.intlayer.t instead.'\n );\n }\n\n return appNamespace.get('t')(content, locale);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n\n return getTranslation(\n content,\n locale ?? internationalization.defaultLocale\n );\n }\n};\n\nexport const getIntlayer: typeof getIntlayerFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getIntlayer') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getIntlayer')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getIntlayerFunction(...args);\n }\n};\n\nexport const getDictionary: typeof getDictionaryFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getDictionary') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getDictionary')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getDictionaryFunction(...args);\n }\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,wDAAkC;AACxC,MAAM,EAAE,yBAAyB;;;;;;AAOjC,MAAM,oBAAoB,iDACH;CACnB,YAAY,SAAkB,IAAY,UAAU;CACpD,YAAY,SAAiB,IAAI,UAAU;CAC5C,CAAC;AAEJ,MAAM,+CAA+B,MAAM;wCAE3B,cAAc;AAoB9B,MAAa,qBACV,SAEC,SACA,WACM;CAEN,MAAM,EAAE,QAAQ,eAAe,kBAAkB,IAAI;CAErD,MAAM,eAAe,UAAU;AAE/B,KAAI,OAAO,YAAY,YACrB,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO;AAGT,KACE,OAAO,UACL,kBACI,YAEN,KACE,OAAO,UACL,mBACI,YAEN,QAAO;KAEP,2CAAsB,SAAS,cAAc;AAIjD,2CAAsB,SAAS,aAAa;;;;;AAMh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H,SAAO,aAAa,IAAI,IAAI,CAAC,SAAS,OAAO;UACtC,OAAO;AACd,MAAI,QAAQ,IAAI,aAAa,cAC3B,SAAQ,MAAO,MAAgB,QAAQ;AAGzC,4CACE,SACA,UAAU,qBAAqB,cAChC;;;AAIL,MAAa,eAA2C,GAAG,SAAS;AAClE,KAAI;AACF,MAAI,OAAO,iBAAiB,YAC1B,OAAM,IAAI,MACR,iFACD;AAGH,MAAI,OAAO,aAAa,IAAI,cAAc,KAAK,WAC7C,OAAM,IAAI,MACR,oEACD;AAGH,SAAO,aAAa,IAAI,cAAc,CAAC,GAAG,KAAK;UACxC,OAAO;AACd,MAAI,QAAQ,IAAI,aAAa,cAC3B,SAAQ,MAAO,MAAgB,QAAQ;AAEzC,yCAA2B,GAAG,KAAK;;;AAIvC,MAAa,iBAA+C,GAAG,SAAS;AACtE,KAAI;AACF,MAAI,OAAO,iBAAiB,YAC1B,OAAM,IAAI,MACR,iFACD;AAGH,MAAI,OAAO,aAAa,IAAI,gBAAgB,KAAK,WAC/C,OAAM,IAAI,MACR,oEACD;AAGH,SAAO,aAAa,IAAI,gBAAgB,CAAC,GAAG,KAAK;UAC1C,OAAO;AACd,MAAI,QAAQ,IAAI,aAAa,cAC3B,SAAQ,MAAO,MAAgB,QAAQ;AAEzC,2CAA6B,GAAG,KAAK"}
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["fastifyIntlayer: FastifyPluginAsync","negotiatorHeaders: Record<string, string>","getIntlayerWrapped: typeof getIntlayerFunction","getIntlayerFunction","getDictionaryWrapped: typeof getDictionaryFunction","getDictionaryFunction","t","getIntlayer: typeof getIntlayerFunction","getDictionary: typeof getDictionaryFunction"],"sources":["../../src/index.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n getLocaleFromStorage,\n getTranslation,\n localeDetector,\n} from '@intlayer/core';\nimport type { Locale, StrictModeLocaleMap } from '@intlayer/types';\nimport { createNamespace } from 'cls-hooked';\nimport type { FastifyPluginAsync, FastifyRequest } from 'fastify';\nimport fp from 'fastify-plugin';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * Retrieves the locale from storage (cookies, headers).\n * Note: req.cookies requires @fastify/cookie to be registered.\n * We cast req to any to avoid hard dependency on @fastify/cookie types.\n */\nconst getStorageLocale = (req: FastifyRequest): Locale | undefined =>\n getLocaleFromStorage({\n getCookie: (name: string) => (req as any).cookies?.[name],\n getHeader: (name: string) => req.headers?.[name] as string | undefined,\n });\n\nconst appNamespace = createNamespace('app');\n\nprepareIntlayer(configuration);\n\n// Module augmentation to type the request decoration\ndeclare module 'fastify' {\n interface FastifyRequest {\n intlayer: {\n locale: Locale;\n defaultLocale: Locale;\n locale_storage?: Locale;\n locale_detected?: Locale;\n t: <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ) => T;\n getIntlayer: typeof getIntlayerFunction;\n getDictionary: typeof getDictionaryFunction;\n };\n }\n}\n\nexport const translateFunction =\n (req: FastifyRequest) =>\n <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ): T => {\n // Access the decorated state from the request\n const { locale: currentLocale, defaultLocale } = req.intlayer;\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[\n targetLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Fastify Plugin to detect locale and load it into request context\n */\nconst fastifyIntlayer: FastifyPluginAsync = async (fastify, _opts) => {\n // Decorate the request object to ensure types are stable.\n // We use 'null as any' to bypass the initial type check, knowing\n // the preHandler will populate it before any route handler runs.\n if (!fastify.hasRequestDecorator('intlayer')) {\n fastify.decorateRequest('intlayer', null as any);\n }\n\n fastify.addHook('preHandler', (req, _reply, done) => {\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeFromStorage = getStorageLocale(req);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n if (req && typeof req.headers === 'object') {\n for (const key in req.headers) {\n const val = req.headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n // Handle array headers (unlikely for accept-language but possible in Fastify)\n negotiatorHeaders[key] = val.join(',');\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n const defaultLocale = internationalization.defaultLocale;\n\n // Helper functions bound to the current request context\n const getIntlayerWrapped: typeof getIntlayerFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionaryWrapped: typeof getDictionaryFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Assign data to request decoration\n req.intlayer = {\n locale_storage: localeFromStorage,\n locale_detected: localeDetected,\n locale,\n defaultLocale,\n getIntlayer: getIntlayerWrapped,\n getDictionary: getDictionaryWrapped,\n t: undefined as unknown as any, // Placeholder\n };\n\n // Now bind t using the updated req\n const t = translateFunction(req);\n req.intlayer.t = t;\n\n // Run CLS context\n appNamespace.run(() => {\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayerWrapped);\n appNamespace.set('getDictionary', getDictionaryWrapped);\n\n done();\n });\n });\n};\n\n// Export as a Fastify Plugin (wrapped in fp to skip encapsulation)\nexport const intlayer = fp(fastifyIntlayer, {\n name: 'fastify-intlayer',\n fastify: '5.x',\n});\n\n// Global exports that rely on CLS (Async Local Storage)\nexport const t = <Content = string>(\n content: StrictModeLocaleMap<Content>,\n locale?: Locale\n): Content => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('t') !== 'function') {\n throw new Error(\n 'Using the import { t } from \"fastify-intlayer\" is not supported in your environment outside of a request context or proper setup. Use req.intlayer.t instead.'\n );\n }\n\n return appNamespace.get('t')(content, locale);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n\n return getTranslation(\n content,\n locale ?? internationalization.defaultLocale\n );\n }\n};\n\nexport const getIntlayer: typeof getIntlayerFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getIntlayer') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getIntlayer')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getIntlayerFunction(...args);\n }\n};\n\nexport const getDictionary: typeof getDictionaryFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getDictionary') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getDictionary')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getDictionaryFunction(...args);\n }\n};\n"],"mappings":";;;;;;;AAcA,MAAM,gBAAgB,kBAAkB;AACxC,MAAM,EAAE,yBAAyB;;;;;;AAOjC,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SAAOH,gBAAsB,GAAG,KAAK"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["getIntlayerFunction","getDictionaryFunction","t"],"sources":["../../src/index.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n getLocaleFromStorage,\n getTranslation,\n localeDetector,\n} from '@intlayer/core';\nimport type { Locale, StrictModeLocaleMap } from '@intlayer/types';\nimport { createNamespace } from 'cls-hooked';\nimport type { FastifyPluginAsync, FastifyRequest } from 'fastify';\nimport fp from 'fastify-plugin';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * Retrieves the locale from storage (cookies, headers).\n * Note: req.cookies requires @fastify/cookie to be registered.\n * We cast req to any to avoid hard dependency on @fastify/cookie types.\n */\nconst getStorageLocale = (req: FastifyRequest): Locale | undefined =>\n getLocaleFromStorage({\n getCookie: (name: string) => (req as any).cookies?.[name],\n getHeader: (name: string) => req.headers?.[name] as string | undefined,\n });\n\nconst appNamespace = createNamespace('app');\n\nprepareIntlayer(configuration);\n\n// Module augmentation to type the request decoration\ndeclare module 'fastify' {\n interface FastifyRequest {\n intlayer: {\n locale: Locale;\n defaultLocale: Locale;\n locale_storage?: Locale;\n locale_detected?: Locale;\n t: <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ) => T;\n getIntlayer: typeof getIntlayerFunction;\n getDictionary: typeof getDictionaryFunction;\n };\n }\n}\n\nexport const translateFunction =\n (req: FastifyRequest) =>\n <T extends string>(\n content: StrictModeLocaleMap<T> | string,\n locale?: Locale\n ): T => {\n // Access the decorated state from the request\n const { locale: currentLocale, defaultLocale } = req.intlayer;\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[\n targetLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof StrictModeLocaleMap<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Fastify Plugin to detect locale and load it into request context\n */\nconst fastifyIntlayer: FastifyPluginAsync = async (fastify, _opts) => {\n // Decorate the request object to ensure types are stable.\n // We use 'null as any' to bypass the initial type check, knowing\n // the preHandler will populate it before any route handler runs.\n if (!fastify.hasRequestDecorator('intlayer')) {\n fastify.decorateRequest('intlayer', null as any);\n }\n\n fastify.addHook('preHandler', (req, _reply, done) => {\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeFromStorage = getStorageLocale(req);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n if (req && typeof req.headers === 'object') {\n for (const key in req.headers) {\n const val = req.headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n // Handle array headers (unlikely for accept-language but possible in Fastify)\n negotiatorHeaders[key] = val.join(',');\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n const defaultLocale = internationalization.defaultLocale;\n\n // Helper functions bound to the current request context\n const getIntlayerWrapped: typeof getIntlayerFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionaryWrapped: typeof getDictionaryFunction = (\n key,\n localeArg = localeDetected as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Assign data to request decoration\n req.intlayer = {\n locale_storage: localeFromStorage,\n locale_detected: localeDetected,\n locale,\n defaultLocale,\n getIntlayer: getIntlayerWrapped,\n getDictionary: getDictionaryWrapped,\n t: undefined as unknown as any, // Placeholder\n };\n\n // Now bind t using the updated req\n const t = translateFunction(req);\n req.intlayer.t = t;\n\n // Run CLS context\n appNamespace.run(() => {\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayerWrapped);\n appNamespace.set('getDictionary', getDictionaryWrapped);\n\n done();\n });\n });\n};\n\n// Export as a Fastify Plugin (wrapped in fp to skip encapsulation)\nexport const intlayer = fp(fastifyIntlayer, {\n name: 'fastify-intlayer',\n fastify: '5.x',\n});\n\n// Global exports that rely on CLS (Async Local Storage)\nexport const t = <Content = string>(\n content: StrictModeLocaleMap<Content>,\n locale?: Locale\n): Content => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('t') !== 'function') {\n throw new Error(\n 'Using the import { t } from \"fastify-intlayer\" is not supported in your environment outside of a request context or proper setup. Use req.intlayer.t instead.'\n );\n }\n\n return appNamespace.get('t')(content, locale);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n\n return getTranslation(\n content,\n locale ?? internationalization.defaultLocale\n );\n }\n};\n\nexport const getIntlayer: typeof getIntlayerFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getIntlayer') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getIntlayer')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getIntlayerFunction(...args);\n }\n};\n\nexport const getDictionary: typeof getDictionaryFunction = (...args) => {\n try {\n if (typeof appNamespace === 'undefined') {\n throw new Error(\n 'Intlayer is not initialized. Register the plugin `fastify.register(intlayer)`.'\n );\n }\n\n if (typeof appNamespace.get('getDictionary') !== 'function') {\n throw new Error(\n 'Context not found. Ensure you are inside a request handling flow.'\n );\n }\n\n return appNamespace.get('getDictionary')(...args);\n } catch (error) {\n if (process.env.NODE_ENV === 'development') {\n console.error((error as Error).message);\n }\n return getDictionaryFunction(...args);\n }\n};\n"],"mappings":";;;;;;;AAcA,MAAM,gBAAgB,kBAAkB;AACxC,MAAM,EAAE,yBAAyB;;;;;;AAOjC,MAAM,oBAAoB,QACxB,qBAAqB;CACnB,YAAY,SAAkB,IAAY,UAAU;CACpD,YAAY,SAAiB,IAAI,UAAU;CAC5C,CAAC;AAEJ,MAAM,eAAe,gBAAgB,MAAM;AAE3C,gBAAgB,cAAc;AAoB9B,MAAa,qBACV,SAEC,SACA,WACM;CAEN,MAAM,EAAE,QAAQ,eAAe,kBAAkB,IAAI;CAErD,MAAM,eAAe,UAAU;AAE/B,KAAI,OAAO,YAAY,YACrB,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO;AAGT,KACE,OAAO,UACL,kBACI,YAEN,KACE,OAAO,UACL,mBACI,YAEN,QAAO;KAEP,QAAO,eAAe,SAAS,cAAc;AAIjD,QAAO,eAAe,SAAS,aAAa;;;;;AAMhD,MAAM,kBAAsC,OAAO,SAAS,UAAU;AAIpE,KAAI,CAAC,QAAQ,oBAAoB,WAAW,CAC1C,SAAQ,gBAAgB,YAAY,KAAY;AAGlD,SAAQ,QAAQ,eAAe,KAAK,QAAQ,SAAS;EAEnD,MAAM,oBAAoB,iBAAiB,IAAI;EAE/C,MAAM,oBAA4C,EAAE;AAGpD,MAAI,OAAO,OAAO,IAAI,YAAY,SAChC,MAAK,MAAM,OAAO,IAAI,SAAS;GAC7B,MAAM,MAAM,IAAI,QAAQ;AACxB,OAAI,OAAO,QAAQ,SACjB,mBAAkB,OAAO;YAChB,MAAM,QAAQ,IAAI,CAE3B,mBAAkB,OAAO,IAAI,KAAK,IAAI;;EAK5C,MAAM,iBAAiB,eACrB,mBACA,qBAAqB,SACrB,qBAAqB,cACtB;EAED,MAAM,SA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MAAI,OAAO,iBAAiB,YAC1B,OAAM,IAAI,MACR,iFACD;AAGH,MAAI,OAAO,aAAa,IAAI,gBAAgB,KAAK,WAC/C,OAAM,IAAI,MACR,oEACD;AAGH,SAAO,aAAa,IAAI,gBAAgB,CAAC,GAAG,KAAK;UAC1C,OAAO;AAEZ,UAAQ,MAAO,MAAgB,QAAQ;AAEzC,SAAOC,gBAAsB,GAAG,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-intlayer",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Manage internationalization i18n in a simple way for Fastify applications.",
|
|
6
6
|
"keywords": [
|
|
@@ -76,25 +76,25 @@
|
|
|
76
76
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@intlayer/chokidar": "7.5.
|
|
80
|
-
"@intlayer/config": "7.5.
|
|
81
|
-
"@intlayer/core": "7.5.
|
|
82
|
-
"@intlayer/types": "7.5.
|
|
79
|
+
"@intlayer/chokidar": "7.5.14",
|
|
80
|
+
"@intlayer/config": "7.5.14",
|
|
81
|
+
"@intlayer/core": "7.5.14",
|
|
82
|
+
"@intlayer/types": "7.5.14",
|
|
83
83
|
"cls-hooked": "4.2.2",
|
|
84
84
|
"fastify-plugin": "^5.0.0",
|
|
85
|
-
"intlayer": "7.5.
|
|
85
|
+
"intlayer": "7.5.14"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/cls-hooked": "4.3.9",
|
|
89
|
-
"@types/node": "25.0.
|
|
89
|
+
"@types/node": "25.0.6",
|
|
90
90
|
"@utils/ts-config": "1.0.4",
|
|
91
91
|
"@utils/ts-config-types": "1.0.4",
|
|
92
92
|
"@utils/tsdown-config": "1.0.4",
|
|
93
93
|
"fastify": "^5.0.0",
|
|
94
94
|
"rimraf": "6.1.2",
|
|
95
|
-
"tsdown": "0.
|
|
95
|
+
"tsdown": "0.19.0",
|
|
96
96
|
"typescript": "5.9.3",
|
|
97
|
-
"vitest": "4.0.
|
|
97
|
+
"vitest": "4.0.17"
|
|
98
98
|
},
|
|
99
99
|
"engines": {
|
|
100
100
|
"node": ">=14.18"
|