@intlayer/config 2.0.0 → 2.0.2

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.
Files changed (58) hide show
  1. package/dist/cjs/configFile/buildConfigurationFields.cjs +21 -1
  2. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  3. package/dist/cjs/defaultValues/editor.cjs +3 -0
  4. package/dist/cjs/defaultValues/editor.cjs.map +1 -1
  5. package/dist/cjs/defaultValues/editor.d.ts +2 -1
  6. package/dist/cjs/envVariables/extractEnvVariable/next.cjs +2 -1
  7. package/dist/cjs/envVariables/extractEnvVariable/next.cjs.map +1 -1
  8. package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs +2 -1
  9. package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs.map +1 -1
  10. package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs +2 -1
  11. package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs.map +1 -1
  12. package/dist/cjs/envVariables/extractEnvVariable/vite.cjs +2 -1
  13. package/dist/cjs/envVariables/extractEnvVariable/vite.cjs.map +1 -1
  14. package/dist/cjs/envVariables/getConfiguration.cjs +2 -1
  15. package/dist/cjs/envVariables/getConfiguration.cjs.map +1 -1
  16. package/dist/cjs/types/config.cjs.map +1 -1
  17. package/dist/cjs/types/config.d.ts +20 -0
  18. package/dist/esm/configFile/buildConfigurationFields.mjs +21 -1
  19. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  20. package/dist/esm/defaultValues/editor.d.mts +2 -1
  21. package/dist/esm/defaultValues/editor.mjs +2 -0
  22. package/dist/esm/defaultValues/editor.mjs.map +1 -1
  23. package/dist/esm/envVariables/extractEnvVariable/next.mjs +2 -1
  24. package/dist/esm/envVariables/extractEnvVariable/next.mjs.map +1 -1
  25. package/dist/esm/envVariables/extractEnvVariable/react_app.mjs +2 -1
  26. package/dist/esm/envVariables/extractEnvVariable/react_app.mjs.map +1 -1
  27. package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs +2 -1
  28. package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs.map +1 -1
  29. package/dist/esm/envVariables/extractEnvVariable/vite.mjs +2 -1
  30. package/dist/esm/envVariables/extractEnvVariable/vite.mjs.map +1 -1
  31. package/dist/esm/envVariables/getConfiguration.mjs +2 -1
  32. package/dist/esm/envVariables/getConfiguration.mjs.map +1 -1
  33. package/dist/esm/types/config.d.mts +20 -0
  34. package/package.json +9 -10
  35. package/src/client.ts +0 -11
  36. package/src/configFile/buildConfigurationFields.ts +0 -503
  37. package/src/configFile/getConfiguration.ts +0 -78
  38. package/src/configFile/index.ts +0 -2
  39. package/src/configFile/loadConfigurationFile.ts +0 -115
  40. package/src/configFile/searchConfigurationFile.ts +0 -59
  41. package/src/defaultValues/editor.ts +0 -1
  42. package/src/defaultValues/internationalization.ts +0 -8
  43. package/src/defaultValues/middleware.ts +0 -11
  44. package/src/defaultValues/server.ts +0 -28
  45. package/src/envVariables/detectPlatform.ts +0 -41
  46. package/src/envVariables/extractEnvVariable/index.ts +0 -20
  47. package/src/envVariables/extractEnvVariable/next.ts +0 -64
  48. package/src/envVariables/extractEnvVariable/react_app.ts +0 -64
  49. package/src/envVariables/extractEnvVariable/types.ts +0 -10
  50. package/src/envVariables/extractEnvVariable/undefined_platform.ts +0 -59
  51. package/src/envVariables/extractEnvVariable/vite.ts +0 -72
  52. package/src/envVariables/extractEnvVariable/vite_env.d.ts +0 -9
  53. package/src/envVariables/formatEnvVariable.ts +0 -39
  54. package/src/envVariables/getConfiguration.ts +0 -109
  55. package/src/envVariables/index.ts +0 -2
  56. package/src/envVariables/utils.ts +0 -64
  57. package/src/types/config.ts +0 -395
  58. package/src/types/locales.ts +0 -469
@@ -1,395 +0,0 @@
1
- import type { Locales } from './locales';
2
-
3
- export type StrictMode = 'strict' | 'required_only' | 'loose';
4
-
5
- /**
6
- * Configuration for internationalization settings
7
- */
8
- export type InternationalizationConfig = {
9
- /**
10
- * Locales available in the application
11
- *
12
- * Default: [Locales.ENGLISH]
13
- *
14
- * You can define a list of available locales to support in the application.
15
- */
16
- locales: Locales[];
17
-
18
- /**
19
- * Ensure strong implementations of internationalized content using typescript.
20
- * - 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.
21
- * - If set to "required_only", 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.
22
- * - If set to "loose", the translation `t` function will accept any existing locale.
23
- *
24
- * Default: "required_only"
25
- */
26
- strictMode: StrictMode;
27
- /**
28
- * Default locale of the application for fallback
29
- *
30
- * Default: Locales.ENGLISH
31
- *
32
- * Used to specify a fallback locale in case no other locale is set.
33
- */
34
- defaultLocale: Locales;
35
- };
36
-
37
- export type ServerSetCookieRule = 'always' | 'never';
38
-
39
- /**
40
- * Configuration for middleware behaviors
41
- */
42
- export type MiddlewareConfig = {
43
- /**
44
- * Header name to get the locale from the request
45
- *
46
- * Default: 'x-intlayer-locale'
47
- *
48
- * The HTTP header key used to determine the current locale.
49
- */
50
- headerName: string;
51
-
52
- /**
53
- * Cookie name to store the locale information
54
- *
55
- * Default: 'NEXT_LOCALE'
56
- *
57
- * The cookie key where the locale information is stored.
58
- */
59
- cookieName: string;
60
-
61
- /**
62
- * Whether to prefix the default locale in the URL
63
- *
64
- * Default: false
65
- *
66
- * When set to true, the default locale is prefixed in the URL for localization purposes.
67
- */
68
- prefixDefault: boolean;
69
-
70
- /**
71
- * Base path for application URLs
72
- *
73
- * Default: ''
74
- *
75
- * Defines the base path where the application is accessible from.
76
- */
77
- basePath: string;
78
-
79
- /**
80
- * Strategy for setting the locale cookie on the server
81
- *
82
- * Default: 'always'
83
- *
84
- * This setting controls when the server sets the locale cookie. It can either set the cookie on every request or never set it.
85
- */
86
- serverSetCookie: ServerSetCookieRule;
87
-
88
- /**
89
- * Indicates if no prefix should be used in the URL for locale
90
- *
91
- * Default: false
92
- *
93
- * If true, no locale-based prefix is used in the URL.
94
- */
95
- noPrefix: boolean;
96
- };
97
-
98
- /**
99
- * Configuration for intlayer editor
100
- */
101
- export type EditorConfig = {
102
- /**
103
- * Port number for the editor server
104
- *
105
- * Default: 4000
106
- *
107
- * The port number where the editor server runs.
108
- */
109
- port: number;
110
- };
111
-
112
- /**
113
- * Custom configuration that can be provided to override default settings
114
- */
115
- export type CustomIntlayerConfig = {
116
- /**
117
- * Custom internationalization configuration
118
- */
119
- internationalization?: Partial<InternationalizationConfig>;
120
-
121
- /**
122
- * Custom middleware configuration
123
- */
124
- middleware?: Partial<MiddlewareConfig>;
125
-
126
- /**
127
- * Custom content configuration
128
- */
129
- content?: Partial<ContentConfig>;
130
-
131
- /**
132
- * Custom editor configuration
133
- */
134
- editor?: Partial<EditorConfig>;
135
- };
136
-
137
- /**
138
- * Combined configuration for internationalization, middleware, and content
139
- */
140
- export type IntlayerConfig = {
141
- /**
142
- * Internationalization configuration
143
- */
144
- internationalization: InternationalizationConfig;
145
-
146
- /**
147
- * Middleware configuration
148
- */
149
- middleware: MiddlewareConfig;
150
-
151
- /**
152
- * Content configuration
153
- */
154
- content: ContentConfig;
155
-
156
- /**
157
- * Intlayer editor configuration
158
- */
159
- editor: EditorConfig;
160
- };
161
-
162
- /**
163
- * Base configuration for content handling
164
- */
165
- export type BaseContentConfig = {
166
- /**
167
- * File extensions of content to look for
168
- *
169
- * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']
170
- *
171
- * List of file extensions to scan for content.
172
- */
173
- fileExtensions: string[];
174
-
175
- /**
176
- * Absolute path of the project's base directory
177
- *
178
- * Default: process.cwd()
179
- *
180
- * The root directory of the project, typically used for resolving other paths.
181
- */
182
- baseDir: string;
183
-
184
- /**
185
- * Name of the directory where the content is stored
186
- *
187
- * Default: 'src'
188
- *
189
- * Specifies the directory where the primary content is stored.
190
- */
191
- contentDirName: string;
192
-
193
- /**
194
- * Directories to be excluded from content processing
195
- *
196
- * Default: ['node_modules']
197
- *
198
- * A list of directories to exclude from content processing.
199
- */
200
- excludedPath: string[];
201
-
202
- /**
203
- * Name of the directory where results are stored
204
- *
205
- * Default: '.intlayer'
206
- *
207
- * The directory for storing intermediate or output results.
208
- */
209
- resultDirName: string;
210
-
211
- /**
212
- * Name of the directory for module augmentation
213
- *
214
- * Default: 'types'
215
- *
216
- * Defines the directory for additional module types.
217
- */
218
- moduleAugmentationDirName: string;
219
-
220
- /**
221
- * Name of the directory where dictionaries are stored
222
- *
223
- * Default: 'dictionary'
224
- *
225
- * The directory for storing localization dictionaries.
226
- *
227
- * Note:
228
- * - Ensure the dictionaries output includes intlayer to build the dictionaries for intlayer
229
- */
230
- dictionariesDirName: string;
231
-
232
- /**
233
- * Name of the directory where dictionaries are stored
234
- *
235
- * Default: 'i18n_dictionary'
236
- *
237
- * The directory for storing localization dictionaries.
238
- *
239
- * Note:
240
- * - Ensure the dictionaries output includes 'i18next' to build the dictionaries for i18next
241
- */
242
- i18nDictionariesDirName: string;
243
-
244
- /**
245
- * Name of the directory where dictionary types are stored
246
- *
247
- * Default: 'types'
248
- *
249
- * The directory for storing dictionary type definitions.
250
- */
251
- typeDirName: string;
252
-
253
- /**
254
- * Name of the directory where the main files are stored
255
- *
256
- * Default: 'main'
257
- *
258
- * Specifies the directory for storing main application files.
259
- */
260
- mainDirName: string;
261
- };
262
-
263
- export type DictionaryOutput = 'intlayer' | 'i18next';
264
-
265
- /**
266
- * Configuration derived based on the base content configuration
267
- */
268
- export type BaseDerivedConfig = {
269
- /**
270
- * Directory where the content is stored, relative to the base directory
271
- *
272
- * Default: {{baseDir}} / {{contentDirName}}
273
- *
274
- * Derived content directory based on the base configuration.
275
- */
276
- contentDir: string;
277
-
278
- /**
279
- * Directory where the results are stored, relative to the base directory
280
- *
281
- * Default: {{baseDir}} / {{resultDirName}}
282
- *
283
- * Derived results directory based on the base configuration.
284
- */
285
- resultDir: string;
286
-
287
- /**
288
- * Directory for module augmentation, relative to the base directory
289
- *
290
- * Default: {{baseDir}} / {{moduleAugmentationDirName}}
291
- *
292
- * Defines the derived path for module augmentation.
293
- */
294
- moduleAugmentationDir: string;
295
-
296
- /**
297
- * Type of dictionary to use as an output
298
- *
299
- * Default: ['intlayer']
300
- *
301
- * The type of dictionary to use as an output. It can be either 'intlayer' or 'i18next'.
302
- *
303
- * Note:
304
- * - 'i18next' is not yet ensure a 1:1 mapping with the i18next library.
305
- * - Removing 'intlayer' will break the compatibility with react-intlayer or next-intlayer
306
- *
307
- */
308
- dictionaryOutput: DictionaryOutput[];
309
- };
310
-
311
- /**
312
- * Configuration derived based on the result directory
313
- */
314
- export type ResultDirDerivedConfig = {
315
- /**
316
- * Directory where dictionaries are stored, relative to the result directory
317
- *
318
- * Default: {{resultDir}} / {{dictionariesDirName}}
319
- *
320
- * Specifies the derived path for dictionaries relative to the result directory.
321
- */
322
- dictionariesDir: string;
323
-
324
- /**
325
- *
326
- * Directory where dictionaries are stored, relative to the result directory
327
- *
328
- * Default: {{resultDir}} / {{i18nDictionariesDirName}}
329
- *
330
- * Specifies the derived path for dictionaries relative to the result directory.
331
- *
332
- * Note:
333
- * - Ensure the i18n dictionaries output includes i18next to build the dictionaries for i18next
334
- */
335
- i18nDictionariesDir: string;
336
-
337
- /**
338
- * Directory where dictionary types are stored, relative to the result directory
339
- *
340
- * Default: {{resultDir}} / {{typeDirName}}
341
- *
342
- * Specifies the derived path for dictionary types relative to the result directory.
343
- */
344
- typesDir: string;
345
-
346
- /**
347
- * Directory where the main files are stored, relative to the result directory
348
- *
349
- * Default: {{resultDir}} / {{mainDirName}}
350
- *
351
- * Specifies the derived path for the main files relative to the result directory.
352
- */
353
- mainDir: string;
354
- };
355
-
356
- /**
357
- * Configuration for content patterns
358
- */
359
- export type PatternsContentConfig = {
360
- /**
361
- * Patterns of files to watch for changes
362
- *
363
- * Default: ['/**\/*.content.ts', '/**\/*.content.js', '/**\/*.content.json', '/**\/*.content.cjs', '/**\/*.content.mjs', '/**\/*.content.tsx', '/**\/*.content.jsx']
364
- *
365
- * Defines file patterns for content to watch for changes.
366
- */
367
- watchedFilesPattern: string[];
368
-
369
- /**
370
- * Patterns of files to watch for changes including the relative path
371
- *
372
- * Default: ['{{contentDir}}/**\/*.content.ts', '{{contentDir}}/**\/*.content.js', '{{contentDir}}/**\/*.content.json', '{{contentDir}}/**\/*.content.cjs', '{{contentDir}}/**\/*.content.mjs', '{{contentDir}}/**\/*.content.tsx', '{{contentDir}}/**\/*.content.jsx']
373
- *
374
- * Specifies the file patterns for content to watch, including relative paths.
375
- */
376
- watchedFilesPatternWithPath: string[];
377
-
378
- /**
379
- * Pattern for output files including the relative path
380
- *
381
- * Default: '{{dictionariesDir}}/**\/*.json'
382
- *
383
- * Defines the pattern for output files, including the relative path.
384
- */
385
- outputFilesPatternWithPath: string;
386
- };
387
-
388
- // @TODO: Implement exclusion of non configurable fields, to not allow them to be set in the config
389
- /**
390
- * General configuration derived from the config file
391
- */
392
- export type ContentConfig = BaseContentConfig &
393
- BaseDerivedConfig &
394
- ResultDirDerivedConfig &
395
- PatternsContentConfig;