@intlayer/types 9.0.0-canary.17 → 9.0.0-canary.18

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.
@@ -2,12 +2,11 @@ import { Locale } from "./allLocales.js";
2
2
  import { LocalesValues, StrictModeLocaleMap } from "./module_augmentation.js";
3
3
  import { ContentAutoTransformation, DictionaryFormat, DictionaryLocation, Fill } from "./dictionary.js";
4
4
  import { Plugin } from "./plugin.js";
5
-
6
5
  //#region src/config.d.ts
7
6
  /**
8
- * Structural type for schema validation, compatible with Zod and other
9
- * schema libraries that implement safeParse. Avoids a hard dependency on Zod.
10
- */
7
+ * Structural type for schema validation, compatible with Zod and other
8
+ * schema libraries that implement safeParse. Avoids a hard dependency on Zod.
9
+ */
11
10
  type ConfigSchema = {
12
11
  safeParse(data: unknown): {
13
12
  success: boolean;
@@ -24,155 +23,155 @@ type IPUrl = `${Protocol}://${number}.${string}${OptionalURLPath}` | `${Protocol
24
23
  type DomainURL = `${Protocol}://${string}.${string}${OptionalURLPath}`;
25
24
  type URLType = LocalhostURL | IPUrl | DomainURL | (string & {});
26
25
  /**
27
- * Configuration for internationalization settings
28
- */
26
+ * Configuration for internationalization settings
27
+ */
29
28
  type InternationalizationConfig = {
30
29
  /**
31
- * Locales available in the application
32
- *
33
- * Default: [Locales.ENGLISH]
34
- *
35
- * You can define a list of available locales to support in the application.
36
- */
30
+ * Locales available in the application
31
+ *
32
+ * Default: [Locales.ENGLISH]
33
+ *
34
+ * You can define a list of available locales to support in the application.
35
+ */
37
36
  locales: Locale[];
38
37
  /**
39
- * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.
40
- *
41
- * Default: []
42
- *
43
- * If empty, all locales are required in `strict` mode.
44
- *
45
- * Ensure required locales are also defined in the `locales` field.
46
- */
38
+ * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.
39
+ *
40
+ * Default: []
41
+ *
42
+ * If empty, all locales are required in `strict` mode.
43
+ *
44
+ * Ensure required locales are also defined in the `locales` field.
45
+ */
47
46
  requiredLocales: Locale[];
48
47
  /**
49
- * Ensure strong implementations of internationalized content using typescript.
50
- * - If set to "strict", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.
51
- * - If set to "inclusive", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.
52
- * - If set to "loose", the translation `t` function will accept any existing locale.
53
- *
54
- * Default: "inclusive"
55
- */
48
+ * Ensure strong implementations of internationalized content using typescript.
49
+ * - If set to "strict", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.
50
+ * - If set to "inclusive", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.
51
+ * - If set to "loose", the translation `t` function will accept any existing locale.
52
+ *
53
+ * Default: "inclusive"
54
+ */
56
55
  strictMode: StrictMode;
57
56
  /**
58
- * Default locale of the application for fallback
59
- *
60
- * Default: Locales.ENGLISH
61
- *
62
- * Used to specify a fallback locale in case no other locale is set.
63
- */
57
+ * Default locale of the application for fallback
58
+ *
59
+ * Default: Locales.ENGLISH
60
+ *
61
+ * Used to specify a fallback locale in case no other locale is set.
62
+ */
64
63
  defaultLocale: Locale;
65
64
  };
66
65
  type CookiesAttributes = {
67
66
  /**
68
- * Type of the storage
69
- *
70
- * The type of the storage. It can be 'cookie'.
71
- */
67
+ * Type of the storage
68
+ *
69
+ * The type of the storage. It can be 'cookie'.
70
+ */
72
71
  type: "cookie";
73
72
  /**
74
- * Cookie name to store the locale information
75
- *
76
- * Default: 'INTLAYER_LOCALE'
77
- *
78
- * The cookie key where the locale information is stored.
79
- */
73
+ * Cookie name to store the locale information
74
+ *
75
+ * Default: 'INTLAYER_LOCALE'
76
+ *
77
+ * The cookie key where the locale information is stored.
78
+ */
80
79
  name?: string;
81
80
  /**
82
- * Cookie domain to store the locale information
83
- *
84
- * Default: undefined
85
- *
86
- * Define the domain where the cookie is available. Defaults to
87
- * the domain of the page where the cookie was created.
88
- */
81
+ * Cookie domain to store the locale information
82
+ *
83
+ * Default: undefined
84
+ *
85
+ * Define the domain where the cookie is available. Defaults to
86
+ * the domain of the page where the cookie was created.
87
+ */
89
88
  domain?: string;
90
89
  /**
91
- * Cookie path to store the locale information
92
- *
93
- * Default: undefined
94
- *
95
- * Define the path where the cookie is available. Defaults to '/'
96
- */
90
+ * Cookie path to store the locale information
91
+ *
92
+ * Default: undefined
93
+ *
94
+ * Define the path where the cookie is available. Defaults to '/'
95
+ */
97
96
  path?: string;
98
97
  /**
99
- * Cookie secure to store the locale information
100
- *
101
- * Default: undefined
102
- *
103
- * A Boolean indicating if the cookie transmission requires a
104
- * secure protocol (https). Defaults to false.
105
- */
98
+ * Cookie secure to store the locale information
99
+ *
100
+ * Default: undefined
101
+ *
102
+ * A Boolean indicating if the cookie transmission requires a
103
+ * secure protocol (https). Defaults to false.
104
+ */
106
105
  secure?: boolean;
107
106
  /**
108
- * Cookie httpOnly to store the locale information
109
- *
110
- * Default: undefined
111
- *
112
- * The cookie httpOnly where the locale information is stored.
113
- */
107
+ * Cookie httpOnly to store the locale information
108
+ *
109
+ * Default: undefined
110
+ *
111
+ * The cookie httpOnly where the locale information is stored.
112
+ */
114
113
  httpOnly?: boolean;
115
114
  /**
116
- * Cookie sameSite to store the locale information
117
- *
118
- * Default: undefined
119
- *
120
- * Asserts that a cookie must not be sent with cross-origin requests,
121
- * providing some protection against cross-site request forgery
122
- * attacks (CSRF)
123
- */
115
+ * Cookie sameSite to store the locale information
116
+ *
117
+ * Default: undefined
118
+ *
119
+ * Asserts that a cookie must not be sent with cross-origin requests,
120
+ * providing some protection against cross-site request forgery
121
+ * attacks (CSRF)
122
+ */
124
123
  sameSite?: "strict" | "lax" | "none";
125
124
  /**
126
- * Cookie expires to store the locale information
127
- *
128
- * Default: undefined
129
- *
130
- * Define when the cookie will be removed:
131
- * - a `number` is interpreted as **days from the time of creation**;
132
- * - a `Date` instance (or an ISO date string, e.g. produced when the
133
- * configuration is serialized) is interpreted as an **absolute moment**.
134
- *
135
- * If omitted, the cookie becomes a session cookie. When `maxAge` is set it
136
- * takes precedence over `expires`.
137
- */
125
+ * Cookie expires to store the locale information
126
+ *
127
+ * Default: undefined
128
+ *
129
+ * Define when the cookie will be removed:
130
+ * - a `number` is interpreted as **days from the time of creation**;
131
+ * - a `Date` instance (or an ISO date string, e.g. produced when the
132
+ * configuration is serialized) is interpreted as an **absolute moment**.
133
+ *
134
+ * If omitted, the cookie becomes a session cookie. When `maxAge` is set it
135
+ * takes precedence over `expires`.
136
+ */
138
137
  expires?: Date | number | string | undefined;
139
138
  /**
140
- * Cookie max-age to store the locale information
141
- *
142
- * Default: undefined
143
- *
144
- * Define the cookie lifetime in seconds from the time of creation
145
- * (e.g. `60 * 60 * 24 * 365` for one year). Takes precedence over
146
- * `expires` when both are set.
147
- */
139
+ * Cookie max-age to store the locale information
140
+ *
141
+ * Default: undefined
142
+ *
143
+ * Define the cookie lifetime in seconds from the time of creation
144
+ * (e.g. `60 * 60 * 24 * 365` for one year). Takes precedence over
145
+ * `expires` when both are set.
146
+ */
148
147
  maxAge?: number;
149
148
  };
150
149
  type StorageAttributes = {
151
150
  /**
152
- * Storage type where the locale is stored
153
- *
154
- * Determines whether the locale is persisted in `localStorage` (across sessions)
155
- * or `sessionStorage` (cleared when the browser session ends) or `header` (from the request header).
156
- */
151
+ * Storage type where the locale is stored
152
+ *
153
+ * Determines whether the locale is persisted in `localStorage` (across sessions)
154
+ * or `sessionStorage` (cleared when the browser session ends) or `header` (from the request header).
155
+ */
157
156
  type: "localStorage" | "sessionStorage" | "header";
158
157
  /**
159
- * Storage key to store the locale information
160
- *
161
- * Default: 'INTLAYER_LOCALE'
162
- *
163
- * The key name used in the client storage to save the locale.
164
- */
158
+ * Storage key to store the locale information
159
+ *
160
+ * Default: 'INTLAYER_LOCALE'
161
+ *
162
+ * The key name used in the client storage to save the locale.
163
+ */
165
164
  name?: string;
166
165
  };
167
166
  /**
168
- * Cookie attributes after the config-build normalization step.
169
- *
170
- * The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)
171
- * are merged into a single, serialization-safe `expires` field so the client
172
- * runtime stays minimal:
173
- * - `number` → seconds from cookie creation (relative);
174
- * - `string` → an absolute expiry as an ISO date string.
175
- */
167
+ * Cookie attributes after the config-build normalization step.
168
+ *
169
+ * The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)
170
+ * are merged into a single, serialization-safe `expires` field so the client
171
+ * runtime stays minimal:
172
+ * - `number` → seconds from cookie creation (relative);
173
+ * - `string` → an absolute expiry as an ISO date string.
174
+ */
176
175
  type ProcessedCookieAttributes = {
177
176
  domain?: string;
178
177
  path?: string;
@@ -182,9 +181,9 @@ type ProcessedCookieAttributes = {
182
181
  expires?: number | string;
183
182
  };
184
183
  /**
185
- * Pre-computed storage attributes derived from `RoutingConfig.storage`.
186
- * Computed at config-build time to avoid repeated processing at runtime.
187
- */
184
+ * Pre-computed storage attributes derived from `RoutingConfig.storage`.
185
+ * Computed at config-build time to avoid repeated processing at runtime.
186
+ */
188
187
  type ProcessedStorageAttributes = {
189
188
  cookies?: {
190
189
  name: string;
@@ -209,271 +208,271 @@ type RewriteRules = {
209
208
  };
210
209
  type RewriteObject = {
211
210
  /**
212
- * Used for client-side URL generation (e.g., getLocalizedUrl).
213
- * Patterns are usually stripped of locale prefixes as the core logic handles prefixing.
214
- */
211
+ * Used for client-side URL generation (e.g., getLocalizedUrl).
212
+ * Patterns are usually stripped of locale prefixes as the core logic handles prefixing.
213
+ */
215
214
  url: RewriteRules;
216
215
  /**
217
- * Used for Next.js middleware / proxy.
218
- * Patterns usually include [locale] or :locale to match incoming full URLs.
219
- */
216
+ * Used for Next.js middleware / proxy.
217
+ * Patterns usually include [locale] or :locale to match incoming full URLs.
218
+ */
220
219
  nextjs?: RewriteRules;
221
220
  /**
222
- * Used for Vite proxy middleware.
223
- */
221
+ * Used for Vite proxy middleware.
222
+ */
224
223
  vite?: RewriteRules;
225
224
  };
226
225
  /**
227
- * Configuration for routing behaviors
228
- */
226
+ * Configuration for routing behaviors
227
+ */
229
228
  type RoutingConfig = {
230
229
  /**
231
- * Rewrite the URLs to a localized path
232
- *
233
- * Example:
234
- * ```ts
235
- * // ...
236
- * routing: {
237
- * rewrite: nextjsRewrite({
238
- * '[locale]/about': {
239
- * fr: '[locale]/a-propos'
240
- * }
241
- * })
242
- * }
243
- * ```
244
- */
230
+ * Rewrite the URLs to a localized path
231
+ *
232
+ * Example:
233
+ * ```ts
234
+ * // ...
235
+ * routing: {
236
+ * rewrite: nextjsRewrite({
237
+ * '[locale]/about': {
238
+ * fr: '[locale]/a-propos'
239
+ * }
240
+ * })
241
+ * }
242
+ * ```
243
+ */
245
244
  rewrite?: Record<URLPath, StrictModeLocaleMap<URLPath>> | RewriteObject;
246
245
  /**
247
- * URL routing mode for locale handling
248
- *
249
- * Controls how locales are represented in application URLs:
250
- * - 'prefix-no-default': Prefix all locales except the default locale
251
- * - 'prefix-all': Prefix all locales including the default locale
252
- * - 'no-prefix': No locale prefixing in URLs
253
- * - 'search-params': Use search parameters for locale handling
254
- *
255
- * Examples with defaultLocale = 'en':
256
- * - 'prefix-no-default': /dashboard (en) or /fr/dashboard (fr)
257
- * - 'prefix-all': /en/dashboard (en) or /fr/dashboard (fr)
258
- * - 'no-prefix': /dashboard (locale handled via other means)
259
- * - 'search-params': /dashboard?locale=fr
260
- *
261
- * Note: This setting do not impact the cookie, or locale storage management.
262
- *
263
- * Default: 'prefix-no-default'
264
- */
246
+ * URL routing mode for locale handling
247
+ *
248
+ * Controls how locales are represented in application URLs:
249
+ * - 'prefix-no-default': Prefix all locales except the default locale
250
+ * - 'prefix-all': Prefix all locales including the default locale
251
+ * - 'no-prefix': No locale prefixing in URLs
252
+ * - 'search-params': Use search parameters for locale handling
253
+ *
254
+ * Examples with defaultLocale = 'en':
255
+ * - 'prefix-no-default': /dashboard (en) or /fr/dashboard (fr)
256
+ * - 'prefix-all': /en/dashboard (en) or /fr/dashboard (fr)
257
+ * - 'no-prefix': /dashboard (locale handled via other means)
258
+ * - 'search-params': /dashboard?locale=fr
259
+ *
260
+ * Note: This setting do not impact the cookie, or locale storage management.
261
+ *
262
+ * Default: 'prefix-no-default'
263
+ */
265
264
  mode: "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params";
266
265
  /**
267
- * Enables the Intlayer locale-routing proxy (middleware).
268
- *
269
- * When enabled, the build-tool integration (e.g. the `intlayer()` Vite plugin)
270
- * automatically wires the locale-detection / redirect / rewrite middleware in
271
- * development, preview, and production SSR. Disable it when you want to handle
272
- * locale routing yourself, or when your routing mode does not require a proxy.
273
- *
274
- * Default: true
275
- */
266
+ * Enables the Intlayer locale-routing proxy (middleware).
267
+ *
268
+ * When enabled, the build-tool integration (e.g. the `intlayer()` Vite plugin)
269
+ * automatically wires the locale-detection / redirect / rewrite middleware in
270
+ * development, preview, and production SSR. Disable it when you want to handle
271
+ * locale routing yourself, or when your routing mode does not require a proxy.
272
+ *
273
+ * Default: true
274
+ */
276
275
  enableProxy: boolean;
277
276
  /**
278
- * Pre-computed storage attributes derived from the raw `storage` input.
279
- * Populated at config-build time by `getStorageAttributes(rawStorage)`.
280
- * Use this at runtime instead of re-processing the raw storage config.
281
- */
277
+ * Pre-computed storage attributes derived from the raw `storage` input.
278
+ * Populated at config-build time by `getStorageAttributes(rawStorage)`.
279
+ * Use this at runtime instead of re-processing the raw storage config.
280
+ */
282
281
  storage: ProcessedStorageAttributes;
283
282
  /**
284
- * Base path for application URLs
285
- *
286
- * Default: ''
287
- *
288
- * Defines the base path where the application is accessible from.
289
- */
283
+ * Base path for application URLs
284
+ *
285
+ * Default: ''
286
+ *
287
+ * Defines the base path where the application is accessible from.
288
+ */
290
289
  basePath?: string;
291
290
  /**
292
- * Maps locales to specific domain hostnames for domain-based routing.
293
- * When a locale is mapped to a domain, URLs generated for that locale
294
- * will use that domain as the base URL (absolute URL), and no locale
295
- * prefix will be added to the path (the domain itself implies the locale).
296
- *
297
- * Default: undefined
298
- *
299
- * Example:
300
- * ```ts
301
- * domains: {
302
- * en: 'intlayer.org',
303
- * zh: 'intlayer.cn',
304
- * }
305
- * ```
306
- */
291
+ * Maps locales to specific domain hostnames for domain-based routing.
292
+ * When a locale is mapped to a domain, URLs generated for that locale
293
+ * will use that domain as the base URL (absolute URL), and no locale
294
+ * prefix will be added to the path (the domain itself implies the locale).
295
+ *
296
+ * Default: undefined
297
+ *
298
+ * Example:
299
+ * ```ts
300
+ * domains: {
301
+ * en: 'intlayer.org',
302
+ * zh: 'intlayer.cn',
303
+ * }
304
+ * ```
305
+ */
307
306
  domains?: Partial<Record<LocalesValues, string>>;
308
307
  };
309
308
  /**
310
- * Raw storage input accepted in the user-facing config (`intlayer.config.ts`).
311
- * Converted to {@link ProcessedStorageAttributes} during config build.
312
- *
313
- * Configuration for storing the locale in the client (localStorage or sessionStorage)
314
- *
315
- * If false, the locale will not be stored by the middleware.
316
- * If true, the locale storage will consider all default values.
317
- *
318
- * Default: ['cookie', 'header]
319
- *
320
- * Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/
321
- * Note: useLocale hook includes a prop to disable the cookie storage.
322
- * Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).
323
- *
324
- * Recommendation:
325
- * - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.
326
- * - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.
327
- */
309
+ * Raw storage input accepted in the user-facing config (`intlayer.config.ts`).
310
+ * Converted to {@link ProcessedStorageAttributes} during config build.
311
+ *
312
+ * Configuration for storing the locale in the client (localStorage or sessionStorage)
313
+ *
314
+ * If false, the locale will not be stored by the middleware.
315
+ * If true, the locale storage will consider all default values.
316
+ *
317
+ * Default: ['cookie', 'header]
318
+ *
319
+ * Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/
320
+ * Note: useLocale hook includes a prop to disable the cookie storage.
321
+ * Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).
322
+ *
323
+ * Recommendation:
324
+ * - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.
325
+ * - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.
326
+ */
328
327
  type RoutingStorageInput = false | "cookie" | "localStorage" | "sessionStorage" | "header" | CookiesAttributes | StorageAttributes | ("cookie" | "localStorage" | "sessionStorage" | "header" | CookiesAttributes | StorageAttributes)[];
329
328
  /**
330
- * User-facing routing configuration (accepted in `intlayer.config.ts`).
331
- */
329
+ * User-facing routing configuration (accepted in `intlayer.config.ts`).
330
+ */
332
331
  type CustomRoutingConfig = Omit<RoutingConfig, "storage"> & {
333
332
  storage?: RoutingStorageInput;
334
333
  };
335
334
  /**
336
- * Configuration for intlayer editor
337
- */
335
+ * Configuration for intlayer editor
336
+ */
338
337
  type EditorConfig = {
339
338
  /**
340
- * URL of the application. Used to restrict the origin of the editor for security reasons.
341
- *
342
- * Default: ''
343
- */
339
+ * URL of the application. Used to restrict the origin of the editor for security reasons.
340
+ *
341
+ * Default: ''
342
+ */
344
343
  applicationURL?: URLType;
345
344
  /**
346
- * Public URL for the editor.
347
- * Default: "http://localhost:8000"
348
- */
345
+ * Public URL for the editor.
346
+ * Default: "http://localhost:8000"
347
+ */
349
348
  editorURL?: URLType;
350
349
  /**
351
- * Intlayer CMS URL.
352
- * Default: "https://app.intlayer.org"
353
- */
350
+ * Intlayer CMS URL.
351
+ * Default: "https://app.intlayer.org"
352
+ */
354
353
  cmsURL?: URLType;
355
354
  /**
356
- * Backend API URL.
357
- * Default: "https://back.intlayer.org"
358
- */
355
+ * Backend API URL.
356
+ * Default: "https://back.intlayer.org"
357
+ */
359
358
  backendURL?: URLType;
360
359
  /**
361
- * Indicates if the application interact with the visual editor
362
- *
363
- * Default: false;
364
- *
365
- * If true, the editor will be able to interact with the application.
366
- * If false, the editor will not be able to interact with the application.
367
- * In any case, the editor can only be enabled by the visual editor.
368
- * Disabling the editor for specific environments is a way to enforce the security.
369
- *
370
- * Usage:
371
- * ```js
372
- * {
373
- * // Other configurations
374
- * editor: {
375
- * enabled: process.env.NODE_ENV !== 'production',
376
- * }
377
- * };
378
- * ```
379
- *
380
- */
360
+ * Indicates if the application interact with the visual editor
361
+ *
362
+ * Default: false;
363
+ *
364
+ * If true, the editor will be able to interact with the application.
365
+ * If false, the editor will not be able to interact with the application.
366
+ * In any case, the editor can only be enabled by the visual editor.
367
+ * Disabling the editor for specific environments is a way to enforce the security.
368
+ *
369
+ * Usage:
370
+ * ```js
371
+ * {
372
+ * // Other configurations
373
+ * editor: {
374
+ * enabled: process.env.NODE_ENV !== 'production',
375
+ * }
376
+ * };
377
+ * ```
378
+ *
379
+ */
381
380
  enabled: boolean;
382
381
  /** Port of the editor server
383
- *
384
- * Default: 8000
385
- */
382
+ *
383
+ * Default: 8000
384
+ */
386
385
  port: number;
387
386
  /**
388
- * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
389
- * An access token is use to authenticate the user related to the project.
390
- * To get an access token, go to https://app.intlayer.org/project and create an account.
391
- *
392
- * Default: undefined
393
- *
394
- * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
395
- */
387
+ * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
388
+ * An access token is use to authenticate the user related to the project.
389
+ * To get an access token, go to https://app.intlayer.org/project and create an account.
390
+ *
391
+ * Default: undefined
392
+ *
393
+ * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
394
+ */
396
395
  clientId?: string;
397
396
  /**
398
- * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
399
- * An access token is use to authenticate the user related to the project.
400
- * To get an access token, go to https://app.intlayer.org/project and create an account.
401
- *
402
- * Default: undefined
403
- *
404
- * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
405
- */
397
+ * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
398
+ * An access token is use to authenticate the user related to the project.
399
+ * To get an access token, go to https://app.intlayer.org/project and create an account.
400
+ *
401
+ * Default: undefined
402
+ *
403
+ * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
404
+ */
406
405
  clientSecret?: string;
407
406
  /**
408
- * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.
409
- * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.
410
- *
411
- * Default: 'local_first'
412
- *
413
- * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.
414
- * - 'local_first': The first dictionary found in the locale is used.
415
- * - 'distant_first': The first dictionary found in the distant locales is used.
416
- */
407
+ * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.
408
+ * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.
409
+ *
410
+ * Default: 'local_first'
411
+ *
412
+ * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.
413
+ * - 'local_first': The first dictionary found in the locale is used.
414
+ * - 'distant_first': The first dictionary found in the distant locales is used.
415
+ */
417
416
  dictionaryPriorityStrategy: "local_first" | "distant_first";
418
417
  /**
419
- * Indicates if the application should hot reload the locale configurations when a change is detected.
420
- * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.
421
- *
422
- * Default: true
423
- */
418
+ * Indicates if the application should hot reload the locale configurations when a change is detected.
419
+ * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.
420
+ *
421
+ * Default: true
422
+ */
424
423
  liveSync: boolean;
425
424
  /**
426
- * Port of the live sync server
427
- *
428
- * Default: 4000
429
- */
425
+ * Port of the live sync server
426
+ *
427
+ * Default: 4000
428
+ */
430
429
  liveSyncPort: number;
431
430
  /**
432
- * URL of the live sync server in case of remote live sync server
433
- *
434
- * Default: `http://localhost:${liveSyncPort}`
435
- */
431
+ * URL of the live sync server in case of remote live sync server
432
+ *
433
+ * Default: `http://localhost:${liveSyncPort}`
434
+ */
436
435
  liveSyncURL: URLType;
437
436
  };
438
437
  /**
439
- * Configuration for Intlayer analytics (`@intlayer/analytics`).
440
- *
441
- * Analytics is strictly **opt-in**: nothing is collected unless `enabled` is
442
- * explicitly set to `true` AND a project key (`editor.clientId`) is configured
443
- * for attribution.
444
- */
438
+ * Configuration for Intlayer analytics (`@intlayer/analytics`).
439
+ *
440
+ * Analytics is strictly **opt-in**: nothing is collected unless `enabled` is
441
+ * explicitly set to `true` AND a project key (`editor.clientId`) is configured
442
+ * for attribution.
443
+ */
445
444
  type AnalyticsConfig = {
446
445
  /**
447
- * Enables analytics collection (page views, content exposures, A/B events).
448
- *
449
- * Default: false
450
- *
451
- * When `false` (the default), the whole `@intlayer/analytics` integration is
452
- * dead-code-eliminated from the application bundle.
453
- *
454
- * Usage:
455
- * ```js
456
- * {
457
- * // Other configurations
458
- * analytics: {
459
- * enabled: process.env.NODE_ENV === 'production',
460
- * }
461
- * };
462
- * ```
463
- */
446
+ * Enables analytics collection (page views, content exposures, A/B events).
447
+ *
448
+ * Default: false
449
+ *
450
+ * When `false` (the default), the whole `@intlayer/analytics` integration is
451
+ * dead-code-eliminated from the application bundle.
452
+ *
453
+ * Usage:
454
+ * ```js
455
+ * {
456
+ * // Other configurations
457
+ * analytics: {
458
+ * enabled: process.env.NODE_ENV === 'production',
459
+ * }
460
+ * };
461
+ * ```
462
+ */
464
463
  enabled: boolean;
465
464
  /**
466
- * Milliseconds between automatic batched flushes to the backend.
467
- *
468
- * Default: 20000
469
- */
465
+ * Milliseconds between automatic batched flushes to the backend.
466
+ *
467
+ * Default: 20000
468
+ */
470
469
  flushInterval: number;
471
470
  /**
472
- * Fraction of sessions to record, from 0 (none) to 1 (all). Sampling is
473
- * deterministic per session so recorded sessions report all of their events.
474
- *
475
- * Default: 1
476
- */
471
+ * Fraction of sessions to record, from 0 (none) to 1 (all). Sampling is
472
+ * deterministic per session so recorded sessions report all of their events.
473
+ *
474
+ * Default: 1
475
+ */
477
476
  sampleRate: number;
478
477
  };
479
478
  declare enum AiProviders {
@@ -496,818 +495,818 @@ declare enum AiProviders {
496
495
  }
497
496
  type CommonAiConfig = {
498
497
  /**
499
- * API model
500
- *
501
- * The model to use for the AI features of Intlayer.
502
- *
503
- * Example: 'gpt-4o-2024-11-20'
504
- *
505
- */
498
+ * API model
499
+ *
500
+ * The model to use for the AI features of Intlayer.
501
+ *
502
+ * Example: 'gpt-4o-2024-11-20'
503
+ *
504
+ */
506
505
  model?: string;
507
506
  /**
508
- * temperature
509
- *
510
- * The temperature to use for the AI features of Intlayer.
511
- * The temperature controls the randomness of the AI's responses.
512
- * A higher temperature will make the AI more creative and less predictable.
513
- *
514
- * Example: 0.1
515
- */
507
+ * temperature
508
+ *
509
+ * The temperature to use for the AI features of Intlayer.
510
+ * The temperature controls the randomness of the AI's responses.
511
+ * A higher temperature will make the AI more creative and less predictable.
512
+ *
513
+ * Example: 0.1
514
+ */
516
515
  temperature?: number;
517
516
  /**
518
- * API key
519
- *
520
- * Use your own OpenAI API key to use the AI features of Intlayer.
521
- * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.
522
- *
523
- */
517
+ * API key
518
+ *
519
+ * Use your own OpenAI API key to use the AI features of Intlayer.
520
+ * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.
521
+ *
522
+ */
524
523
  apiKey?: string;
525
524
  /**
526
- * Application context
527
- *
528
- * The context of the application to use for the AI features of Intlayer.
529
- *
530
- * Example: 'This is a website for a company that sells products online.'
531
- */
525
+ * Application context
526
+ *
527
+ * The context of the application to use for the AI features of Intlayer.
528
+ *
529
+ * Example: 'This is a website for a company that sells products online.'
530
+ */
532
531
  applicationContext?: string;
533
532
  /**
534
- * Base URL
535
- *
536
- * The base URL to use for the AI features of Intlayer.
537
- *
538
- * Example: 'https://api.openai.com/v1'
539
- */
533
+ * Base URL
534
+ *
535
+ * The base URL to use for the AI features of Intlayer.
536
+ *
537
+ * Example: 'https://api.openai.com/v1'
538
+ */
540
539
  baseURL?: string;
541
540
  /**
542
- * Data serialization
543
- *
544
- * The data serialization format to use for the AI features of Intlayer.
545
- *
546
- * Default: 'json'
547
- */
541
+ * Data serialization
542
+ *
543
+ * The data serialization format to use for the AI features of Intlayer.
544
+ *
545
+ * Default: 'json'
546
+ */
548
547
  dataSerialization?: "json" | "toon";
549
548
  };
550
549
  type AiProviderConfigMap = {};
551
550
  type AiConfigUnion = { [P in keyof AiProviderConfigMap]: {
552
551
  provider: P | `${P}`;
553
- } & AiProviderConfigMap[P] }[keyof AiProviderConfigMap];
552
+ } & AiProviderConfigMap[P]; }[keyof AiProviderConfigMap];
554
553
  type AiConfig = CommonAiConfig & (AiConfigUnion | {
555
554
  provider?: AiProviders | `${AiProviders}`;
556
555
  });
557
556
  type BuildConfig = {
558
557
  /**
559
- * Indicates the mode of the build
560
- *
561
- * Default: 'auto'
562
- *
563
- * If 'auto', the build will be enabled automatically when the application is built.
564
- * If 'manual', the build will be set only when the build command is executed.
565
- *
566
- * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.
567
- */
558
+ * Indicates the mode of the build
559
+ *
560
+ * Default: 'auto'
561
+ *
562
+ * If 'auto', the build will be enabled automatically when the application is built.
563
+ * If 'manual', the build will be set only when the build command is executed.
564
+ *
565
+ * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.
566
+ */
568
567
  mode: "auto" | "manual";
569
568
  /**
570
- * Indicates if the build should be optimized
571
- *
572
- * Default: undefined
573
- *
574
- * If true, the build will be optimized.
575
- * If false, the build will not be optimized.
576
- *
577
- * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.
578
- * All imports will stay as static import to avoid async processing when loading the dictionaries.
579
- *
580
- * Note:
581
- * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.
582
- * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.
583
- * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
584
- * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
585
- */
569
+ * Indicates if the build should be optimized
570
+ *
571
+ * Default: undefined
572
+ *
573
+ * If true, the build will be optimized.
574
+ * If false, the build will not be optimized.
575
+ *
576
+ * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.
577
+ * All imports will stay as static import to avoid async processing when loading the dictionaries.
578
+ *
579
+ * Note:
580
+ * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.
581
+ * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.
582
+ * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
583
+ * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
584
+ */
586
585
  optimize?: boolean;
587
586
  /**
588
- * Indicates the mode of import to use for the dictionaries.
589
- *
590
- * Available modes:
591
- * - "static": The dictionaries are imported statically.
592
- * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
593
- * - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
594
- * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
595
- * - "fetch": The dictionaries are imported dynamically using the live sync API.
596
- * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
597
- * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as "dynamic" mode.
598
- *
599
- * Default: "static"
600
- *
601
- * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
602
- *
603
- * Note:
604
- * - Dynamic imports rely on Suspense and may slightly impact rendering performance.
605
- * - If desabled all locales will be loaded at once, even if they are not used.
606
- * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
607
- * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
608
- * - This option will be ignored if `optimize` is disabled.
609
- * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.
610
- * - The "fetch" allows to sync the dictionaries to the live sync server.
611
- * - Require static key to work. Example of invalid code: `const navbarKey = "my-key"; useIntlayer(navbarKey)`.
612
- *
613
- * @deprecated Use `dictionary.importMode` instead.
614
- */
587
+ * Indicates the mode of import to use for the dictionaries.
588
+ *
589
+ * Available modes:
590
+ * - "static": The dictionaries are imported statically.
591
+ * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
592
+ * - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
593
+ * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
594
+ * - "fetch": The dictionaries are imported dynamically using the live sync API.
595
+ * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
596
+ * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as "dynamic" mode.
597
+ *
598
+ * Default: "static"
599
+ *
600
+ * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
601
+ *
602
+ * Note:
603
+ * - Dynamic imports rely on Suspense and may slightly impact rendering performance.
604
+ * - If desabled all locales will be loaded at once, even if they are not used.
605
+ * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
606
+ * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
607
+ * - This option will be ignored if `optimize` is disabled.
608
+ * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.
609
+ * - The "fetch" allows to sync the dictionaries to the live sync server.
610
+ * - Require static key to work. Example of invalid code: `const navbarKey = "my-key"; useIntlayer(navbarKey)`.
611
+ *
612
+ * @deprecated Use `dictionary.importMode` instead.
613
+ */
615
614
  importMode?: "static" | "dynamic" | "fetch";
616
615
  /**
617
- * Minify the dictionaries to reduce the bundle size.
618
- *
619
- * Default: false
620
- *
621
- * Note:
622
- * - This option will be ignored if `optimize` is disabled.
623
- * - This option will be ignore if `editor.enabled` is true.
624
- * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.
625
- */
616
+ * Minify the dictionaries to reduce the bundle size.
617
+ *
618
+ * Default: false
619
+ *
620
+ * Note:
621
+ * - This option will be ignored if `optimize` is disabled.
622
+ * - This option will be ignore if `editor.enabled` is true.
623
+ * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.
624
+ */
626
625
  minify: boolean;
627
626
  /**
628
- * Purge the unused keys in a dictionaries
629
- *
630
- * Default: false
631
- *
632
- * Note:
633
- * - This option will be ignored if `optimize` is disabled.
634
- */
627
+ * Purge the unused keys in a dictionaries
628
+ *
629
+ * Default: false
630
+ *
631
+ * Note:
632
+ * - This option will be ignored if `optimize` is disabled.
633
+ */
635
634
  purge: boolean;
636
635
  /**
637
- * Pattern to traverse the code to optimize.
638
- *
639
- * Allows to avoid to traverse the code that is not relevant to the optimization.
640
- * Improve build performance.
641
- *
642
- * Default: ['**\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\/node_modules/**']
643
- *
644
- * Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**\/node_modules/**']`
645
- *
646
- * Note:
647
- * - This option will be ignored if `optimize` is disabled.
648
- * - Use glob pattern.
649
- */
636
+ * Pattern to traverse the code to optimize.
637
+ *
638
+ * Allows to avoid to traverse the code that is not relevant to the optimization.
639
+ * Improve build performance.
640
+ *
641
+ * Default: ['**\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\/node_modules/**']
642
+ *
643
+ * Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**\/node_modules/**']`
644
+ *
645
+ * Note:
646
+ * - This option will be ignored if `optimize` is disabled.
647
+ * - Use glob pattern.
648
+ */
650
649
  traversePattern: string[];
651
650
  /**
652
- * Output format of the dictionaries
653
- *
654
- * Default: ['cjs', 'esm']
655
- *
656
- * The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.
657
- * This function will use the output format defined using this option.
658
- * The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.
659
- */
651
+ * Output format of the dictionaries
652
+ *
653
+ * Default: ['cjs', 'esm']
654
+ *
655
+ * The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.
656
+ * This function will use the output format defined using this option.
657
+ * The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.
658
+ */
660
659
  outputFormat: ("cjs" | "esm")[];
661
660
  /**
662
- * Indicates if the cache should be enabled
663
- *
664
- * Default: true
665
- *
666
- * If true, the cache will be enabled.
667
- * If false, the cache will not be enabled.
668
- */
661
+ * Indicates if the cache should be enabled
662
+ *
663
+ * Default: true
664
+ *
665
+ * If true, the cache will be enabled.
666
+ * If false, the cache will not be enabled.
667
+ */
669
668
  cache: boolean;
670
669
  /**
671
- * Require function
672
- *
673
- * In some environments, as VSCode extension, the require function should be set relatively to the project root to work properly.
674
- *
675
- * Default: undefined
676
- *
677
- * If undefined, the require function will be set to the default require function.
678
- * If defined, the require function will be set to the defined require function.
679
- *
680
- * Example:
681
- * ```js
682
- * {
683
- * require: require
684
- * }
685
- * ```
686
- */
670
+ * Require function
671
+ *
672
+ * In some environments, as VSCode extension, the require function should be set relatively to the project root to work properly.
673
+ *
674
+ * Default: undefined
675
+ *
676
+ * If undefined, the require function will be set to the default require function.
677
+ * If defined, the require function will be set to the defined require function.
678
+ *
679
+ * Example:
680
+ * ```js
681
+ * {
682
+ * require: require
683
+ * }
684
+ * ```
685
+ */
687
686
  require?: NodeJS.Require;
688
687
  /**
689
- * Indicates if the build should check TypeScript types
690
- *
691
- * Default: false
692
- *
693
- * If true, the build will check TypeScript types and log errors.
694
- * Note: This can slow down the build.
695
- */
688
+ * Indicates if the build should check TypeScript types
689
+ *
690
+ * Default: false
691
+ *
692
+ * If true, the build will check TypeScript types and log errors.
693
+ * Note: This can slow down the build.
694
+ */
696
695
  checkTypes: boolean;
697
696
  };
698
697
  type CompilerConfig = {
699
698
  /**
700
- * Indicates if the compiler should be enabled.
701
- * If 'build-only', the compiler will be skipped during development mode to speed up start times.
702
- */
699
+ * Indicates if the compiler should be enabled.
700
+ * If 'build-only', the compiler will be skipped during development mode to speed up start times.
701
+ */
703
702
  enabled: boolean | "build-only";
704
703
  /**
705
- * Prefix for the extracted dictionary keys.
706
- * Default: ''
707
- */
704
+ * Prefix for the extracted dictionary keys.
705
+ * Default: ''
706
+ */
708
707
  dictionaryKeyPrefix?: string;
709
708
  /**
710
- * Pattern to traverse the code to optimize.
711
- *
712
- * Allows to avoid to traverse the code that is not relevant to the optimization.
713
- * Improve build performance.
714
- *
715
- * Default: ['**\/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**\/node_modules/**']
716
- *
717
- * Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**\/node_modules/**']`
718
- *
719
- * Note:
720
- * - This option will be ignored if `optimize` is disabled.
721
- * - Use glob pattern.
722
- *
723
- * @deprecated use build.traversePattern instead
724
- */
709
+ * Pattern to traverse the code to optimize.
710
+ *
711
+ * Allows to avoid to traverse the code that is not relevant to the optimization.
712
+ * Improve build performance.
713
+ *
714
+ * Default: ['**\/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**\/node_modules/**']
715
+ *
716
+ * Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**\/node_modules/**']`
717
+ *
718
+ * Note:
719
+ * - This option will be ignored if `optimize` is disabled.
720
+ * - Use glob pattern.
721
+ *
722
+ * @deprecated use build.traversePattern instead
723
+ */
725
724
  transformPattern?: string | string[];
726
725
  /**
727
- * Pattern to exclude from the optimization.
728
- *
729
- * Allows to exclude files from the optimization.
730
- *
731
- * Default: ['**\/node_modules/**']
732
- *
733
- * Example: `['**\/node_modules/**', '!**\/node_modules/react/**']`
734
- *
735
- * @deprecated use build.traversePattern instead
736
- */
726
+ * Pattern to exclude from the optimization.
727
+ *
728
+ * Allows to exclude files from the optimization.
729
+ *
730
+ * Default: ['**\/node_modules/**']
731
+ *
732
+ * Example: `['**\/node_modules/**', '!**\/node_modules/react/**']`
733
+ *
734
+ * @deprecated use build.traversePattern instead
735
+ */
737
736
  excludePattern?: string | string[];
738
737
  /**
739
- * Defines the output files path. Replaces `outputDir`.
740
- *
741
- * - `./` paths are resolved relative to the component directory.
742
- * - `/` paths are resolved relative to the project root (`baseDir`).
743
- *
744
- * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
745
- *
746
- * Example:
747
- * ```ts
748
- * {
749
- * // Create Multilingual .content.ts files close to the component
750
- * output: ({ fileName, extension }) => `./${fileName}${extension}`,
751
- *
752
- * // output: './{{fileName}}{{extension}}', // Equivalent using template string
753
- * }
754
- * ```
755
- *
756
- * ```ts
757
- * {
758
- * // Create centralize per-locale JSON at the root of the project
759
- * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
760
- *
761
- * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
762
- * }
763
- * ```
764
- *
765
- * ```ts
766
- * {
767
- * // Create per-locale JSON files with locale-specific output paths
768
- * output: {
769
- * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,
770
- * fr: '{{fileName}}.{{locale}}.content.json',
771
- * es: false, // skip this locale
772
- * },
773
- * }
774
- * ```
775
- *
776
- * Variable list:
777
- * - `fileName`: The name of the file.
778
- * - `key`: The key of the content.
779
- * - `locale`: The locale of the content.
780
- * - `extension`: The extension of the file.
781
- * - `componentFileName`: The name of the component file.
782
- * - `componentExtension`: The extension of the component file.
783
- * - `format`: The format of the dictionary.
784
- * - `componentFormat`: The format of the component dictionary.
785
- * - `componentDirPath`: The directory path of the component.
786
- */
738
+ * Defines the output files path. Replaces `outputDir`.
739
+ *
740
+ * - `./` paths are resolved relative to the component directory.
741
+ * - `/` paths are resolved relative to the project root (`baseDir`).
742
+ *
743
+ * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
744
+ *
745
+ * Example:
746
+ * ```ts
747
+ * {
748
+ * // Create Multilingual .content.ts files close to the component
749
+ * output: ({ fileName, extension }) => `./${fileName}${extension}`,
750
+ *
751
+ * // output: './{{fileName}}{{extension}}', // Equivalent using template string
752
+ * }
753
+ * ```
754
+ *
755
+ * ```ts
756
+ * {
757
+ * // Create centralize per-locale JSON at the root of the project
758
+ * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
759
+ *
760
+ * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
761
+ * }
762
+ * ```
763
+ *
764
+ * ```ts
765
+ * {
766
+ * // Create per-locale JSON files with locale-specific output paths
767
+ * output: {
768
+ * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,
769
+ * fr: '{{fileName}}.{{locale}}.content.json',
770
+ * es: false, // skip this locale
771
+ * },
772
+ * }
773
+ * ```
774
+ *
775
+ * Variable list:
776
+ * - `fileName`: The name of the file.
777
+ * - `key`: The key of the content.
778
+ * - `locale`: The locale of the content.
779
+ * - `extension`: The extension of the file.
780
+ * - `componentFileName`: The name of the component file.
781
+ * - `componentExtension`: The extension of the component file.
782
+ * - `format`: The format of the dictionary.
783
+ * - `componentFormat`: The format of the component dictionary.
784
+ * - `componentDirPath`: The directory path of the component.
785
+ */
787
786
  output?: Fill;
788
787
  /**
789
- * Indicates if the metadata should be saved in the file.
790
- *
791
- * If true, the compiler will not save the metadata of the dictionaries.
792
- *
793
- * If true:
794
- *
795
- * ```json
796
- * {
797
- * "key": "value"
798
- * }
799
- * ```
800
- *
801
- * If false:
802
- *
803
- * ```json
804
- * {
805
- * "key": "value",
806
- * "content": {
807
- * "key": "value"
808
- * }
809
- * }
810
- * ```
811
- *
812
- * Default: false
813
- *
814
- * Note: Useful if used with loadJSON plugin
815
- *
816
- */
788
+ * Indicates if the metadata should be saved in the file.
789
+ *
790
+ * If true, the compiler will not save the metadata of the dictionaries.
791
+ *
792
+ * If true:
793
+ *
794
+ * ```json
795
+ * {
796
+ * "key": "value"
797
+ * }
798
+ * ```
799
+ *
800
+ * If false:
801
+ *
802
+ * ```json
803
+ * {
804
+ * "key": "value",
805
+ * "content": {
806
+ * "key": "value"
807
+ * }
808
+ * }
809
+ * ```
810
+ *
811
+ * Default: false
812
+ *
813
+ * Note: Useful if used with loadJSON plugin
814
+ *
815
+ */
817
816
  noMetadata?: boolean;
818
817
  /**
819
- * Indicates if the components should be saved after being transformed.
820
- *
821
- * If true, the compiler will replace the original files with the transformed files.
822
- * That way, the compiler can be run only once to transform the app, and then it can be removed.
823
- *
824
- * Default: false
825
- */
818
+ * Indicates if the components should be saved after being transformed.
819
+ *
820
+ * If true, the compiler will replace the original files with the transformed files.
821
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
822
+ *
823
+ * Default: false
824
+ */
826
825
  saveComponents: boolean;
827
826
  };
828
827
  /**
829
- * Custom configuration that can be provided to override default settings
830
- */
828
+ * Custom configuration that can be provided to override default settings
829
+ */
831
830
  type CustomIntlayerConfig = {
832
831
  /**
833
- * Custom internationalization configuration
834
- */
832
+ * Custom internationalization configuration
833
+ */
835
834
  internationalization?: Partial<InternationalizationConfig>;
836
835
  /**
837
- * Custom dictionary configuration
838
- */
836
+ * Custom dictionary configuration
837
+ */
839
838
  dictionary?: Partial<DictionaryConfig>;
840
839
  /**
841
- * Custom routing configuration
842
- */
840
+ * Custom routing configuration
841
+ */
843
842
  routing?: Partial<CustomRoutingConfig>;
844
843
  /**
845
- * Custom content configuration
846
- */
844
+ * Custom content configuration
845
+ */
847
846
  content?: Partial<ContentConfig>;
848
847
  /**
849
- * Custom editor configuration
850
- */
848
+ * Custom editor configuration
849
+ */
851
850
  editor?: Partial<EditorConfig>;
852
851
  /**
853
- * Custom analytics configuration
854
- */
852
+ * Custom analytics configuration
853
+ */
855
854
  analytics?: Partial<AnalyticsConfig>;
856
855
  /**
857
- * Custom log configuration
858
- */
856
+ * Custom log configuration
857
+ */
859
858
  log?: Partial<LogConfig>;
860
859
  /**
861
- * Custom AI configuration
862
- */
860
+ * Custom AI configuration
861
+ */
863
862
  ai?: Partial<AiConfig>;
864
863
  /**
865
- * Custom build configuration
866
- */
864
+ * Custom build configuration
865
+ */
867
866
  build?: Partial<BuildConfig>;
868
867
  /**
869
- * Custom compiler configuration
870
- */
868
+ * Custom compiler configuration
869
+ */
871
870
  compiler?: Partial<CompilerConfig>;
872
871
  /**
873
- * Custom system configuration
874
- */
872
+ * Custom system configuration
873
+ */
875
874
  system?: Partial<SystemConfig>;
876
875
  /**
877
- * Custom schemas to validate the dictionaries content.
878
- *
879
- * Example:
880
- * ```ts
881
- * {
882
- * schemas: {
883
- * 'my-schema': z.object({
884
- * title: z.string(),
885
- * description: z.string(),
886
- * }),
887
- * }
888
- * }
889
- * ```
890
- */
876
+ * Custom schemas to validate the dictionaries content.
877
+ *
878
+ * Example:
879
+ * ```ts
880
+ * {
881
+ * schemas: {
882
+ * 'my-schema': z.object({
883
+ * title: z.string(),
884
+ * description: z.string(),
885
+ * }),
886
+ * }
887
+ * }
888
+ * ```
889
+ */
891
890
  schemas?: Record<string, ConfigSchema>;
892
891
  /**
893
- * Custom plugins configuration
894
- */
892
+ * Custom plugins configuration
893
+ */
895
894
  plugins?: (Plugin | Promise<Plugin>)[];
896
895
  };
897
896
  type DictionaryConfig = {
898
897
  /**
899
- * Indicate how the dictionary should be filled using AI.
900
- *
901
- * Default: `true`
902
- *
903
- * - If `true`, will consider the `compiler.output` field.
904
- * - If `false`, will skip the fill process.
905
- *
906
- * - `./` paths are resolved relative to the component directory.
907
- * - `/` paths are resolved relative to the project root (`baseDir`).
908
- *
909
- * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.
910
- *
911
- * Example:
912
- * ```ts
913
- * {
914
- * // Create Multilingual .content.ts files close to the component
915
- * fill: ({ fileName, extension }) => `./${fileName}${extension}`,
916
- *
917
- * // fill: './{{fileName}}{{extension}}', // Equivalent using template string
918
- * }
919
- * ```
920
- *
921
- * ```ts
922
- * {
923
- * // Create centralize per-locale JSON at the root of the project
924
- * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
925
- *
926
- * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
927
- * }
928
- * ```
929
- *
930
- * ```ts
931
- * {
932
- * // Create custom output based on the locale
933
- * fill: {
934
- * en: ({ key }) => `/locales/en/${key}.content.json`,
935
- * fr: '/locales/fr/{{key}}.content.json',
936
- * es: false,
937
- * de: true,
938
- * },
939
- * }
940
- * ```
941
- *
942
- *
943
- * Variable list:
944
- * - `fileName`: The name of the file.
945
- * - `key`: The key of the content.
946
- * - `locale`: The locale of the content.
947
- * - `extension`: The extension of the file.
948
- * - `componentFileName`: The name of the component file.
949
- * - `componentExtension`: The extension of the component file.
950
- * - `format`: The format of the dictionary.
951
- * - `componentFormat`: The format of the component dictionary.
952
- * - `componentDirPath`: The directory path of the component.
953
- */
898
+ * Indicate how the dictionary should be filled using AI.
899
+ *
900
+ * Default: `true`
901
+ *
902
+ * - If `true`, will consider the `compiler.output` field.
903
+ * - If `false`, will skip the fill process.
904
+ *
905
+ * - `./` paths are resolved relative to the component directory.
906
+ * - `/` paths are resolved relative to the project root (`baseDir`).
907
+ *
908
+ * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.
909
+ *
910
+ * Example:
911
+ * ```ts
912
+ * {
913
+ * // Create Multilingual .content.ts files close to the component
914
+ * fill: ({ fileName, extension }) => `./${fileName}${extension}`,
915
+ *
916
+ * // fill: './{{fileName}}{{extension}}', // Equivalent using template string
917
+ * }
918
+ * ```
919
+ *
920
+ * ```ts
921
+ * {
922
+ * // Create centralize per-locale JSON at the root of the project
923
+ * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
924
+ *
925
+ * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
926
+ * }
927
+ * ```
928
+ *
929
+ * ```ts
930
+ * {
931
+ * // Create custom output based on the locale
932
+ * fill: {
933
+ * en: ({ key }) => `/locales/en/${key}.content.json`,
934
+ * fr: '/locales/fr/{{key}}.content.json',
935
+ * es: false,
936
+ * de: true,
937
+ * },
938
+ * }
939
+ * ```
940
+ *
941
+ *
942
+ * Variable list:
943
+ * - `fileName`: The name of the file.
944
+ * - `key`: The key of the content.
945
+ * - `locale`: The locale of the content.
946
+ * - `extension`: The extension of the file.
947
+ * - `componentFileName`: The name of the component file.
948
+ * - `componentExtension`: The extension of the component file.
949
+ * - `format`: The format of the dictionary.
950
+ * - `componentFormat`: The format of the component dictionary.
951
+ * - `componentDirPath`: The directory path of the component.
952
+ */
954
953
  fill?: Fill;
955
954
  /**
956
- * The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.
957
- * The description is also used as context for translations generation.
958
- *
959
- * Example:
960
- * ```ts
961
- * {
962
- * "key": "about-page-meta",
963
- * "description":[
964
- * "This dictionary is manage the metadata of the About Page",
965
- * "Consider good practices for SEO:",
966
- * "- The title should be between 50 and 60 characters",
967
- * "- The description should be between 150 and 160 characters",
968
- * ].join('\n'),
969
- * "content": { ... }
970
- * }
971
- * ```
972
- */
955
+ * The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.
956
+ * The description is also used as context for translations generation.
957
+ *
958
+ * Example:
959
+ * ```ts
960
+ * {
961
+ * "key": "about-page-meta",
962
+ * "description":[
963
+ * "This dictionary is manage the metadata of the About Page",
964
+ * "Consider good practices for SEO:",
965
+ * "- The title should be between 50 and 60 characters",
966
+ * "- The description should be between 150 and 160 characters",
967
+ * ].join('\n'),
968
+ * "content": { ... }
969
+ * }
970
+ * ```
971
+ */
973
972
  description?: string;
974
973
  /**
975
- * Transform the dictionary in a per-locale dictionary.
976
- * Each field declared in a per-locale dictionary will be transformed in a translation node.
977
- * If missing, the dictionary will be treated as a multilingual dictionary.
978
- * If declared, do not use translation nodes in the content.
979
- *
980
- * Example:
981
- * ```json
982
- * {
983
- * "key": "about-page",
984
- * "locale": "en",
985
- * "content": {
986
- * "multilingualContent": "English content"
987
- * }
988
- * }
989
- * ```
990
- */
974
+ * Transform the dictionary in a per-locale dictionary.
975
+ * Each field declared in a per-locale dictionary will be transformed in a translation node.
976
+ * If missing, the dictionary will be treated as a multilingual dictionary.
977
+ * If declared, do not use translation nodes in the content.
978
+ *
979
+ * Example:
980
+ * ```json
981
+ * {
982
+ * "key": "about-page",
983
+ * "locale": "en",
984
+ * "content": {
985
+ * "multilingualContent": "English content"
986
+ * }
987
+ * }
988
+ * ```
989
+ */
991
990
  locale?: LocalesValues;
992
991
  /**
993
- * Indicators if the content of the dictionary should be automatically transformed.
994
- * If true, the content will be transformed to the corresponding node type.
995
- * - Markdown: `### Title` -> `md('### Title')`
996
- * - HTML: `<div>Title</div>` -> `html('<div>Title</div>')`
997
- * - Insertion: `Hello {{name}}` -> `insert('Hello {{name}}')`
998
- *
999
- * If an object is provided, you can specify which transformations should be enabled.
1000
- *
1001
- * Default: false
1002
- */
992
+ * Indicators if the content of the dictionary should be automatically transformed.
993
+ * If true, the content will be transformed to the corresponding node type.
994
+ * - Markdown: `### Title` -> `md('### Title')`
995
+ * - HTML: `<div>Title</div>` -> `html('<div>Title</div>')`
996
+ * - Insertion: `Hello {{name}}` -> `insert('Hello {{name}}')`
997
+ *
998
+ * If an object is provided, you can specify which transformations should be enabled.
999
+ *
1000
+ * Default: false
1001
+ */
1003
1002
  contentAutoTransformation?: ContentAutoTransformation;
1004
1003
  /**
1005
- * Indicates the priority of the dictionary.
1006
- * In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.
1007
- */
1004
+ * Indicates the priority of the dictionary.
1005
+ * In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.
1006
+ */
1008
1007
  priority?: number;
1009
1008
  /**
1010
- * Indicates the mode of import to use for the dictionaries.
1011
- *
1012
- * Available modes:
1013
- * - "static": The dictionaries are imported statically.
1014
- * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
1015
- * - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
1016
- * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
1017
- * - "fetch": The dictionaries are imported dynamically using the live sync API.
1018
- * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
1019
- * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as "dynamic" mode.
1020
- *
1021
- * Default: "static"
1022
- *
1023
- * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
1024
- *
1025
- * Note:
1026
- * - Dynamic imports rely on Suspense and may slightly impact rendering performance.
1027
- * - If disabled all locales will be loaded at once, even if they are not used.
1028
- * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
1029
- * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
1030
- * - This option will be ignored if `optimize` is disabled.
1031
- * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.
1032
- * - The "fetch" allows to sync the dictionaries to the live sync server.
1033
- * - Require static key to work. Example of invalid code: `const navbarKey = "my-key"; useIntlayer(navbarKey)`.
1034
- */
1009
+ * Indicates the mode of import to use for the dictionaries.
1010
+ *
1011
+ * Available modes:
1012
+ * - "static": The dictionaries are imported statically.
1013
+ * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
1014
+ * - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
1015
+ * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
1016
+ * - "fetch": The dictionaries are imported dynamically using the live sync API.
1017
+ * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
1018
+ * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as "dynamic" mode.
1019
+ *
1020
+ * Default: "static"
1021
+ *
1022
+ * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
1023
+ *
1024
+ * Note:
1025
+ * - Dynamic imports rely on Suspense and may slightly impact rendering performance.
1026
+ * - If disabled all locales will be loaded at once, even if they are not used.
1027
+ * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
1028
+ * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
1029
+ * - This option will be ignored if `optimize` is disabled.
1030
+ * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.
1031
+ * - The "fetch" allows to sync the dictionaries to the live sync server.
1032
+ * - Require static key to work. Example of invalid code: `const navbarKey = "my-key"; useIntlayer(navbarKey)`.
1033
+ */
1035
1034
  importMode?: "static" | "dynamic" | "fetch";
1036
1035
  /**
1037
- * The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.
1038
- *
1039
- * Example:
1040
- * ```json
1041
- * {
1042
- * "key": "about-page-meta",
1043
- * "title": "About Page",
1044
- * "content": { ... }
1045
- * }
1046
- * ```
1047
- */
1036
+ * The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.
1037
+ *
1038
+ * Example:
1039
+ * ```json
1040
+ * {
1041
+ * "key": "about-page-meta",
1042
+ * "title": "About Page",
1043
+ * "content": { ... }
1044
+ * }
1045
+ * ```
1046
+ */
1048
1047
  title?: string;
1049
1048
  /**
1050
- * Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.
1051
- *
1052
- * Example:
1053
- * ```json
1054
- * {
1055
- * "key": "about-page-meta",
1056
- * "tags": ["metadata","about-page"]
1057
- * }
1058
- * ```
1059
- */
1049
+ * Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.
1050
+ *
1051
+ * Example:
1052
+ * ```json
1053
+ * {
1054
+ * "key": "about-page-meta",
1055
+ * "tags": ["metadata","about-page"]
1056
+ * }
1057
+ * ```
1058
+ */
1060
1059
  tags?: string[];
1061
1060
  /**
1062
- * Indicates the location of the dictionary and controls how it synchronizes with the CMS.
1063
- *
1064
- * - 'hybrid': The dictionary is managed locally and remotely. Once pushed on the CMS, it will be synchronized from the local one. The local dictionary will be pulled from the CMS.
1065
- * - 'remote': The dictionary is managed remotely only. Once pushed on the CMS, it will be detached from the local one. At content load time, the remote dictionary will be pulled from the CMS. A '.content' file with remote location will be ignored.
1066
- * - 'local': The dictionary is managed locally. It will not be pushed to the remote CMS.
1067
- * - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.
1068
- */
1061
+ * Indicates the location of the dictionary and controls how it synchronizes with the CMS.
1062
+ *
1063
+ * - 'hybrid': The dictionary is managed locally and remotely. Once pushed on the CMS, it will be synchronized from the local one. The local dictionary will be pulled from the CMS.
1064
+ * - 'remote': The dictionary is managed remotely only. Once pushed on the CMS, it will be detached from the local one. At content load time, the remote dictionary will be pulled from the CMS. A '.content' file with remote location will be ignored.
1065
+ * - 'local': The dictionary is managed locally. It will not be pushed to the remote CMS.
1066
+ * - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.
1067
+ */
1069
1068
  location?: DictionaryLocation;
1070
1069
  /**
1071
- * The default message format for all dictionaries in the project.
1072
- *
1073
- * Controls how dictionary content strings are interpreted at runtime.
1074
- *
1075
- * - 'intlayer': Native intlayer format (default).
1076
- * - 'icu': ICU message format (used by next-intl, react-intl, etc.).
1077
- * - 'i18next': i18next interpolation format (used by i18next, react-i18next, next-i18next).
1078
- * - 'vue-i18n': Vue I18n format (used by vue-i18n).
1079
- * - 'po': GNU Gettext PO format.
1080
- *
1081
- * Default: 'intlayer'
1082
- */
1070
+ * The default message format for all dictionaries in the project.
1071
+ *
1072
+ * Controls how dictionary content strings are interpreted at runtime.
1073
+ *
1074
+ * - 'intlayer': Native intlayer format (default).
1075
+ * - 'icu': ICU message format (used by next-intl, react-intl, etc.).
1076
+ * - 'i18next': i18next interpolation format (used by i18next, react-i18next, next-i18next).
1077
+ * - 'vue-i18n': Vue I18n format (used by vue-i18n).
1078
+ * - 'po': GNU Gettext PO format.
1079
+ *
1080
+ * Default: 'intlayer'
1081
+ */
1083
1082
  format?: DictionaryFormat;
1084
1083
  };
1085
1084
  /**
1086
- * Combined configuration for internationalization, middleware, and content
1087
- */
1085
+ * Combined configuration for internationalization, middleware, and content
1086
+ */
1088
1087
  type IntlayerConfig = {
1089
1088
  /**
1090
- * Internationalization configuration
1091
- */
1089
+ * Internationalization configuration
1090
+ */
1092
1091
  internationalization: InternationalizationConfig;
1093
1092
  /**
1094
- * Default dictionary configuration
1095
- */
1093
+ * Default dictionary configuration
1094
+ */
1096
1095
  dictionary?: Partial<DictionaryConfig>;
1097
1096
  /**
1098
- * Routing configuration
1099
- */
1097
+ * Routing configuration
1098
+ */
1100
1099
  routing: RoutingConfig;
1101
1100
  /**
1102
- * Content configuration
1103
- */
1101
+ * Content configuration
1102
+ */
1104
1103
  content: ContentConfig;
1105
1104
  /**
1106
- * System configuration
1107
- */
1105
+ * System configuration
1106
+ */
1108
1107
  system: SystemConfig;
1109
1108
  /**
1110
- * Intlayer editor configuration
1111
- */
1109
+ * Intlayer editor configuration
1110
+ */
1112
1111
  editor: EditorConfig;
1113
1112
  /**
1114
- * Intlayer analytics configuration
1115
- */
1113
+ * Intlayer analytics configuration
1114
+ */
1116
1115
  analytics?: AnalyticsConfig;
1117
1116
  /**
1118
- * Logger configuration
1119
- */
1117
+ * Logger configuration
1118
+ */
1120
1119
  log: LogConfig;
1121
1120
  /**
1122
- * AI configuration
1123
- */
1121
+ * AI configuration
1122
+ */
1124
1123
  ai?: Partial<AiConfig>;
1125
1124
  /**
1126
- * Build configuration
1127
- */
1125
+ * Build configuration
1126
+ */
1128
1127
  build: BuildConfig;
1129
1128
  /**
1130
- * Compiler configuration
1131
- */
1129
+ * Compiler configuration
1130
+ */
1132
1131
  compiler: CompilerConfig;
1133
1132
  /**
1134
- * Custom schemas to validate the dictionaries content.
1135
- */
1133
+ * Custom schemas to validate the dictionaries content.
1134
+ */
1136
1135
  schemas?: Record<string, ConfigSchema>;
1137
1136
  /**
1138
- * Plugins configuration
1139
- */
1137
+ * Plugins configuration
1138
+ */
1140
1139
  plugins?: Plugin[];
1141
1140
  };
1142
1141
  /**
1143
- * Configuration for content handling
1144
- */
1142
+ * Configuration for content handling
1143
+ */
1145
1144
  type ContentConfig = {
1146
1145
  /**
1147
- * File extensions of content to look for
1148
- *
1149
- * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']
1150
- *
1151
- * List of file extensions to scan for content.
1152
- */
1146
+ * File extensions of content to look for
1147
+ *
1148
+ * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']
1149
+ *
1150
+ * List of file extensions to scan for content.
1151
+ */
1153
1152
  fileExtensions: string[];
1154
1153
  /**
1155
- * Directory where the content is stored, relative to the base directory
1156
- *
1157
- * Default: ['.']
1158
- *
1159
- * Derived content directory based on the base configuration.
1160
- *
1161
- * Note: This is used to watch for content files.
1162
- */
1154
+ * Directory where the content is stored, relative to the base directory
1155
+ *
1156
+ * Default: ['.']
1157
+ *
1158
+ * Derived content directory based on the base configuration.
1159
+ *
1160
+ * Note: This is used to watch for content files.
1161
+ */
1163
1162
  contentDir: string[];
1164
1163
  /**
1165
- * Directory where the code is stored, relative to the base directory
1166
- *
1167
- * Default: ['.']
1168
- *
1169
- * Derived code directory based on the base configuration.
1170
- *
1171
- * Note: This is used to watch for code files to transform.
1172
- */
1164
+ * Directory where the code is stored, relative to the base directory
1165
+ *
1166
+ * Default: ['.']
1167
+ *
1168
+ * Derived code directory based on the base configuration.
1169
+ *
1170
+ * Note: This is used to watch for code files to transform.
1171
+ */
1173
1172
  codeDir: string[];
1174
1173
  /**
1175
- * Directories to be excluded from content processing
1176
- *
1177
- * Default: ['node_modules', '.intlayer']
1178
- *
1179
- * A list of directories to exclude from content processing.
1180
- */
1174
+ * Directories to be excluded from content processing
1175
+ *
1176
+ * Default: ['node_modules', '.intlayer']
1177
+ *
1178
+ * A list of directories to exclude from content processing.
1179
+ */
1181
1180
  excludedPath: string[];
1182
1181
  /**
1183
- * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.
1184
- *
1185
- * Default: process.env.NODE_ENV === 'development'
1186
- */
1182
+ * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.
1183
+ *
1184
+ * Default: process.env.NODE_ENV === 'development'
1185
+ */
1187
1186
  watch: boolean;
1188
1187
  /**
1189
- * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.
1190
- *
1191
- * Example:
1192
- *
1193
- * ```bash
1194
- * npx prettier --write {{file}}
1195
- * ```
1196
- *
1197
- * ```bash
1198
- * bunx biome format {{file}}
1199
- * ```
1200
- *
1201
- * ```bash
1202
- * bun format {{file}}
1203
- * ```
1204
- *
1205
- * ```bash
1206
- * npx eslint --fix {{file}}
1207
- * ```
1208
- *
1209
- * Intlayer will replace the {{file}} with the path of the file to format.
1210
- *
1211
- * Default: undefined
1212
- */
1188
+ * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.
1189
+ *
1190
+ * Example:
1191
+ *
1192
+ * ```bash
1193
+ * npx prettier --write {{file}}
1194
+ * ```
1195
+ *
1196
+ * ```bash
1197
+ * bunx biome format {{file}}
1198
+ * ```
1199
+ *
1200
+ * ```bash
1201
+ * bun format {{file}}
1202
+ * ```
1203
+ *
1204
+ * ```bash
1205
+ * npx eslint --fix {{file}}
1206
+ * ```
1207
+ *
1208
+ * Intlayer will replace the {{file}} with the path of the file to format.
1209
+ *
1210
+ * Default: undefined
1211
+ */
1213
1212
  formatCommand: string | undefined;
1214
1213
  };
1215
1214
  type SystemConfig = {
1216
1215
  /**
1217
- * Absolute path of the project's base directory
1218
- *
1219
- * Default: process.cwd()
1220
- *
1221
- * The root directory of the project, typically used for resolving other paths.
1222
- */
1216
+ * Absolute path of the project's base directory
1217
+ *
1218
+ * Default: process.cwd()
1219
+ *
1220
+ * The root directory of the project, typically used for resolving other paths.
1221
+ */
1223
1222
  baseDir: string;
1224
1223
  /**
1225
- * Directory for module augmentation, relative to the base directory
1226
- *
1227
- * Default: .intlayer/types
1228
- *
1229
- * Defines the derived path for module augmentation.
1230
- */
1224
+ * Directory for module augmentation, relative to the base directory
1225
+ *
1226
+ * Default: .intlayer/types
1227
+ *
1228
+ * Defines the derived path for module augmentation.
1229
+ */
1231
1230
  moduleAugmentationDir: string;
1232
1231
  /**
1233
- * Directory where unmerged dictionaries are stored, relative to the result directory
1234
- *
1235
- * Default: .intlayer/unmerged_dictionary
1236
- *
1237
- * Specifies the derived path for unmerged dictionaries relative to the result directory.
1238
- */
1232
+ * Directory where unmerged dictionaries are stored, relative to the result directory
1233
+ *
1234
+ * Default: .intlayer/unmerged_dictionary
1235
+ *
1236
+ * Specifies the derived path for unmerged dictionaries relative to the result directory.
1237
+ */
1239
1238
  unmergedDictionariesDir: string;
1240
1239
  /**
1241
- * Directory where remote dictionaries are stored, relative to the result directory
1242
- *
1243
- * Default: .intlayer/remote_dictionary
1244
- *
1245
- * Specifies the derived path for remote dictionaries relative to the result directory.
1246
- */
1240
+ * Directory where remote dictionaries are stored, relative to the result directory
1241
+ *
1242
+ * Default: .intlayer/remote_dictionary
1243
+ *
1244
+ * Specifies the derived path for remote dictionaries relative to the result directory.
1245
+ */
1247
1246
  remoteDictionariesDir: string;
1248
1247
  /**
1249
- * Directory where final dictionaries are stored, relative to the result directory
1250
- *
1251
- * Default: .intlayer/dictionary
1252
- *
1253
- * Specifies the derived path for dictionaries relative to the result directory.
1254
- */
1248
+ * Directory where final dictionaries are stored, relative to the result directory
1249
+ *
1250
+ * Default: .intlayer/dictionary
1251
+ *
1252
+ * Specifies the derived path for dictionaries relative to the result directory.
1253
+ */
1255
1254
  dictionariesDir: string;
1256
1255
  /**
1257
- * Directory where dynamic dictionaries are stored, relative to the result directory
1258
- *
1259
- * Default: .intlayer/dynamic_dictionary
1260
- *
1261
- * Specifies the derived path for dynamic dictionaries relative to the result directory.
1262
- */
1256
+ * Directory where dynamic dictionaries are stored, relative to the result directory
1257
+ *
1258
+ * Default: .intlayer/dynamic_dictionary
1259
+ *
1260
+ * Specifies the derived path for dynamic dictionaries relative to the result directory.
1261
+ */
1263
1262
  dynamicDictionariesDir: string;
1264
1263
  /**
1265
- * Directory where fetch dictionaries are stored, relative to the result directory
1266
- *
1267
- * Default: .intlayer/fetch_dictionary
1268
- *
1269
- * Specifies the derived path for fetch dictionaries relative to the result directory.
1270
- */
1264
+ * Directory where fetch dictionaries are stored, relative to the result directory
1265
+ *
1266
+ * Default: .intlayer/fetch_dictionary
1267
+ *
1268
+ * Specifies the derived path for fetch dictionaries relative to the result directory.
1269
+ */
1271
1270
  fetchDictionariesDir: string;
1272
1271
  /**
1273
- * Directory where dictionary types are stored, relative to the result directory
1274
- *
1275
- * Default: .intlayer/types
1276
- *
1277
- * Specifies the derived path for dictionary types relative to the result directory.
1278
- */
1272
+ * Directory where dictionary types are stored, relative to the result directory
1273
+ *
1274
+ * Default: .intlayer/types
1275
+ *
1276
+ * Specifies the derived path for dictionary types relative to the result directory.
1277
+ */
1279
1278
  typesDir: string;
1280
1279
  /**
1281
- * Directory where the main files are stored, relative to the result directory
1282
- *
1283
- * Default: .intlayer/main
1284
- *
1285
- * Specifies the derived path for the main files relative to the result directory.
1286
- */
1280
+ * Directory where the main files are stored, relative to the result directory
1281
+ *
1282
+ * Default: .intlayer/main
1283
+ *
1284
+ * Specifies the derived path for the main files relative to the result directory.
1285
+ */
1287
1286
  mainDir: string;
1288
1287
  /**
1289
- * Directory where the configuration files are stored, relative to the result directory
1290
- *
1291
- * Default: .intlayer/config
1292
- *
1293
- * Specifies the derived path for the configuration files relative to the result directory.
1294
- */
1288
+ * Directory where the configuration files are stored, relative to the result directory
1289
+ *
1290
+ * Default: .intlayer/config
1291
+ *
1292
+ * Specifies the derived path for the configuration files relative to the result directory.
1293
+ */
1295
1294
  configDir: string;
1296
1295
  /**
1297
- * Directory where the cache files are stored, relative to the result directory
1298
- *
1299
- * Default: .intlayer/cache
1300
- *
1301
- * Specifies the derived path for the cache files relative to the result directory.
1302
- */
1296
+ * Directory where the cache files are stored, relative to the result directory
1297
+ *
1298
+ * Default: .intlayer/cache
1299
+ *
1300
+ * Specifies the derived path for the cache files relative to the result directory.
1301
+ */
1303
1302
  cacheDir: string;
1304
1303
  /**
1305
- * Directory where the temp files are stored, relative to the result directory
1306
- *
1307
- * Default: .intlayer/tmp
1308
- *
1309
- * Specifies the derived path for the tmp files relative to the result directory.
1310
- */
1304
+ * Directory where the temp files are stored, relative to the result directory
1305
+ *
1306
+ * Default: .intlayer/tmp
1307
+ *
1308
+ * Specifies the derived path for the tmp files relative to the result directory.
1309
+ */
1311
1310
  tempDir: string;
1312
1311
  };
1313
1312
  type LogFunctions = {
@@ -1318,26 +1317,26 @@ type LogFunctions = {
1318
1317
  };
1319
1318
  type LogConfig = {
1320
1319
  /**
1321
- * Indicates if the logger is enabled
1322
- *
1323
- * Default: true
1324
- *
1325
- * If 'default', the logger is enabled and can be used.
1326
- * If 'verbose', the logger will be enabled and can be used, but will log more information.
1327
- * If 'disabled', the logger is disabled and cannot be used.
1328
- */
1320
+ * Indicates if the logger is enabled
1321
+ *
1322
+ * Default: true
1323
+ *
1324
+ * If 'default', the logger is enabled and can be used.
1325
+ * If 'verbose', the logger will be enabled and can be used, but will log more information.
1326
+ * If 'disabled', the logger is disabled and cannot be used.
1327
+ */
1329
1328
  mode: "default" | "verbose" | "disabled";
1330
1329
  /**
1331
- * Prefix of the logger
1332
- *
1333
- * Default: '[intlayer]'
1334
- *
1335
- * The prefix of the logger.
1336
- */
1330
+ * Prefix of the logger
1331
+ *
1332
+ * Default: '[intlayer]'
1333
+ *
1334
+ * The prefix of the logger.
1335
+ */
1337
1336
  prefix: string;
1338
1337
  /**
1339
- * Functions to log
1340
- */
1338
+ * Functions to log
1339
+ */
1341
1340
  error?: typeof console.error;
1342
1341
  log?: typeof console.log;
1343
1342
  info?: typeof console.info;