@intlayer/config 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/cjs/configFile/buildConfigurationFields.cjs +253 -38
  2. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  3. package/dist/cjs/configFile/buildConfigurationFields.d.ts +3 -0
  4. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  5. package/dist/cjs/configFile/getConfiguration.d.ts +3 -0
  6. package/dist/cjs/configFile/index.cjs +3 -1
  7. package/dist/cjs/configFile/index.cjs.map +1 -1
  8. package/dist/cjs/configFile/index.d.ts +1 -0
  9. package/dist/cjs/configFile/loadConfigurationFile.cjs +8 -1
  10. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  11. package/dist/cjs/configFile/loadConfigurationFile.d.ts +6 -0
  12. package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
  13. package/dist/cjs/configFile/searchConfigurationFile.d.ts +11 -0
  14. package/dist/cjs/defaultValues/internationalization.cjs +1 -5
  15. package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
  16. package/dist/cjs/defaultValues/internationalization.d.ts +1 -1
  17. package/dist/cjs/defaultValues/server.cjs +0 -6
  18. package/dist/cjs/defaultValues/server.cjs.map +1 -1
  19. package/dist/cjs/defaultValues/server.d.ts +1 -3
  20. package/dist/cjs/envVariables/detectPlatform.cjs +53 -0
  21. package/dist/cjs/envVariables/detectPlatform.cjs.map +1 -0
  22. package/dist/cjs/envVariables/detectPlatform.d.ts +11 -0
  23. package/dist/cjs/envVariables/extractEnvVariable.cjs +211 -0
  24. package/dist/cjs/envVariables/extractEnvVariable.cjs.map +1 -0
  25. package/dist/cjs/envVariables/extractEnvVariable.d.ts +13 -0
  26. package/dist/cjs/envVariables/formatEnvVariable.cjs +6 -4
  27. package/dist/cjs/envVariables/formatEnvVariable.cjs.map +1 -1
  28. package/dist/cjs/envVariables/formatEnvVariable.d.ts +6 -1
  29. package/dist/cjs/envVariables/getConfiguration.cjs +37 -38
  30. package/dist/cjs/envVariables/getConfiguration.cjs.map +1 -1
  31. package/dist/cjs/envVariables/getConfiguration.d.ts +5 -0
  32. package/dist/cjs/envVariables/index.d.ts +1 -0
  33. package/dist/cjs/envVariables/utils.cjs +7 -6
  34. package/dist/cjs/envVariables/utils.cjs.map +1 -1
  35. package/dist/cjs/envVariables/utils.d.ts +5 -5
  36. package/dist/cjs/index.d.ts +1 -0
  37. package/dist/cjs/types/config.cjs.map +1 -1
  38. package/dist/cjs/types/config.d.ts +212 -6
  39. package/dist/cjs/types/locales.cjs.map +1 -1
  40. package/dist/cjs/types/locales.d.ts +233 -0
  41. package/dist/esm/configFile/buildConfigurationFields.d.mts +3 -0
  42. package/dist/esm/configFile/buildConfigurationFields.mjs +253 -40
  43. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  44. package/dist/esm/configFile/getConfiguration.d.mts +3 -0
  45. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  46. package/dist/esm/configFile/index.d.mts +1 -0
  47. package/dist/esm/configFile/index.mjs +1 -0
  48. package/dist/esm/configFile/index.mjs.map +1 -1
  49. package/dist/esm/configFile/loadConfigurationFile.d.mts +6 -0
  50. package/dist/esm/configFile/loadConfigurationFile.mjs +8 -1
  51. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  52. package/dist/esm/configFile/searchConfigurationFile.d.mts +11 -0
  53. package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
  54. package/dist/esm/defaultValues/internationalization.d.mts +1 -1
  55. package/dist/esm/defaultValues/internationalization.mjs +1 -5
  56. package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
  57. package/dist/esm/defaultValues/server.d.mts +1 -3
  58. package/dist/esm/defaultValues/server.mjs +0 -4
  59. package/dist/esm/defaultValues/server.mjs.map +1 -1
  60. package/dist/esm/envVariables/detectPlatform.d.mts +11 -0
  61. package/dist/esm/envVariables/detectPlatform.mjs +27 -0
  62. package/dist/esm/envVariables/detectPlatform.mjs.map +1 -0
  63. package/dist/esm/envVariables/extractEnvVariable.d.mts +13 -0
  64. package/dist/esm/envVariables/extractEnvVariable.mjs +186 -0
  65. package/dist/esm/envVariables/extractEnvVariable.mjs.map +1 -0
  66. package/dist/esm/envVariables/formatEnvVariable.d.mts +6 -1
  67. package/dist/esm/envVariables/formatEnvVariable.mjs +6 -4
  68. package/dist/esm/envVariables/formatEnvVariable.mjs.map +1 -1
  69. package/dist/esm/envVariables/getConfiguration.d.mts +5 -0
  70. package/dist/esm/envVariables/getConfiguration.mjs +37 -38
  71. package/dist/esm/envVariables/getConfiguration.mjs.map +1 -1
  72. package/dist/esm/envVariables/index.d.mts +1 -0
  73. package/dist/esm/envVariables/utils.d.mts +5 -5
  74. package/dist/esm/envVariables/utils.mjs +7 -6
  75. package/dist/esm/envVariables/utils.mjs.map +1 -1
  76. package/dist/esm/index.d.mts +1 -0
  77. package/dist/esm/types/config.d.mts +212 -6
  78. package/dist/esm/types/locales.d.mts +233 -0
  79. package/dist/esm/types/locales.mjs.map +1 -1
  80. package/package.json +7 -7
  81. package/src/configFile/buildConfigurationFields.ts +258 -47
  82. package/src/configFile/getConfiguration.ts +3 -0
  83. package/src/configFile/index.ts +1 -0
  84. package/src/configFile/loadConfigurationFile.ts +19 -1
  85. package/src/configFile/searchConfigurationFile.ts +11 -0
  86. package/src/defaultValues/server.ts +0 -4
  87. package/src/envVariables/detectPlatform.ts +37 -0
  88. package/src/envVariables/extractEnvVariable.ts +224 -0
  89. package/src/envVariables/formatEnvVariable.ts +17 -11
  90. package/src/envVariables/getConfiguration.ts +40 -41
  91. package/src/envVariables/utils.ts +30 -14
  92. package/src/types/config.ts +237 -65
  93. package/src/types/locales.ts +233 -233
@@ -1,64 +1,121 @@
1
1
  import type { Locales } from './locales';
2
2
 
3
+ /**
4
+ * Configuration for internationalization settings
5
+ */
3
6
  export type InternationalizationConfig = {
4
- // Available languages in the app
5
- locales: Locales[]; // default [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH]
7
+ /**
8
+ * Locales available in the application
9
+ *
10
+ * Default: [Locales.ENGLISH]
11
+ *
12
+ * You can define a list of available locales to support in the application.
13
+ */
14
+ locales: Locales[];
6
15
 
7
- // Default language
8
- defaultLocale: Locales; // default Locales.ENGLISH
16
+ /**
17
+ * Default locale of the application for fallback
18
+ *
19
+ * Default: Locales.ENGLISH
20
+ *
21
+ * Used to specify a fallback locale in case no other locale is set.
22
+ */
23
+ defaultLocale: Locales;
9
24
  };
10
25
 
11
26
  export type ServerSetCookieRule = 'always' | 'never';
27
+
28
+ /**
29
+ * Configuration for middleware behaviors
30
+ */
12
31
  export type MiddlewareConfig = {
13
- // Header name to get the language
14
- headerName: string; // default 'x-intlayer-locale'
32
+ /**
33
+ * Header name to get the locale from the request
34
+ *
35
+ * Default: 'x-intlayer-locale'
36
+ *
37
+ * The HTTP header key used to determine the current locale.
38
+ */
39
+ headerName: string;
15
40
 
16
- // Cookie name to get the language
17
- cookieName: string; // default 'NEXT_LOCALE'
41
+ /**
42
+ * Cookie name to store the locale information
43
+ *
44
+ * Default: 'NEXT_LOCALE'
45
+ *
46
+ * The cookie key where the locale information is stored.
47
+ */
48
+ cookieName: string;
18
49
 
19
- // Prefix the default language in the URL
20
- prefixDefault: boolean; // default false
50
+ /**
51
+ * Whether to prefix the default locale in the URL
52
+ *
53
+ * Default: false
54
+ *
55
+ * When set to true, the default locale is prefixed in the URL for localization purposes.
56
+ */
57
+ prefixDefault: boolean;
21
58
 
22
- // Base path
23
- basePath: string; // default ''
59
+ /**
60
+ * Base path for application URLs
61
+ *
62
+ * Default: ''
63
+ *
64
+ * Defines the base path where the application is accessible from.
65
+ */
66
+ basePath: string;
24
67
 
25
- // Set cookie on server
26
- serverSetCookie: ServerSetCookieRule; // default 'always'
68
+ /**
69
+ * Strategy for setting the locale cookie on the server
70
+ *
71
+ * Default: 'always'
72
+ *
73
+ * This setting controls when the server sets the locale cookie. It can either set the cookie on every request or never set it.
74
+ */
75
+ serverSetCookie: ServerSetCookieRule;
27
76
 
28
- // No prefix
29
- noPrefix: boolean; // default false;
77
+ /**
78
+ * Indicates if no prefix should be used in the URL for locale
79
+ *
80
+ * Default: false
81
+ *
82
+ * If true, no locale-based prefix is used in the URL.
83
+ */
84
+ noPrefix: boolean;
30
85
  };
31
86
 
87
+ /**
88
+ * Custom configuration that can be provided to override default settings
89
+ */
32
90
  export type CustomIntlayerConfig = {
33
91
  /**
34
- * Internationalization configuration
92
+ * Custom internationalization configuration
35
93
  */
36
-
37
94
  internationalization?: Partial<InternationalizationConfig>;
38
95
 
39
96
  /**
40
- * Middleware configuration
97
+ * Custom middleware configuration
41
98
  */
42
-
43
99
  middleware?: Partial<MiddlewareConfig>;
44
100
 
45
101
  /**
46
- * Content configuration
102
+ * Custom content configuration
47
103
  */
48
104
  content?: Partial<ContentConfig>;
49
105
  };
50
106
 
107
+ /**
108
+ * Combined configuration for internationalization, middleware, and content
109
+ */
51
110
  export type IntlayerConfig = {
52
111
  /**
53
112
  * Internationalization configuration
54
113
  */
55
-
56
114
  internationalization: InternationalizationConfig;
57
115
 
58
116
  /**
59
117
  * Middleware configuration
60
118
  */
61
-
62
119
  middleware: MiddlewareConfig;
63
120
 
64
121
  /**
@@ -67,77 +124,192 @@ export type IntlayerConfig = {
67
124
  content: ContentConfig;
68
125
  };
69
126
 
127
+ /**
128
+ * Base configuration for content handling
129
+ */
70
130
  export type BaseContentConfig = {
71
- // File extensions of content to look for
72
- fileExtensions: string[]; // default ['.content.ts', '.content.js', '.content.json']
73
-
74
- // Directory of the project
75
- baseDir: string; // default process.cwd()
76
-
77
- // Directory name where the content is stored
78
- contentDirName: string; // default 'src'
131
+ /**
132
+ * File extensions of content to look for
133
+ *
134
+ * Default: ['.content.ts', '.content.js', '.content.json']
135
+ *
136
+ * List of file extensions to scan for content.
137
+ */
138
+ fileExtensions: string[];
79
139
 
80
- // Directories to exclude
81
- excludedPath: string[]; // default ['node_modules']
140
+ /**
141
+ * Absolute path of the project's base directory
142
+ *
143
+ * Default: process.cwd()
144
+ *
145
+ * The root directory of the project, typically used for resolving other paths.
146
+ */
147
+ baseDir: string;
82
148
 
83
- // Result directory name
84
- resultDirName: string; // default '.intlayer'
149
+ /**
150
+ * Name of the directory where the content is stored
151
+ *
152
+ * Default: 'src'
153
+ *
154
+ * Specifies the directory where the primary content is stored.
155
+ */
156
+ contentDirName: string;
85
157
 
86
- // Module augmentation directory name
87
- moduleAugmentationDirName: string; // default 'types'
158
+ /**
159
+ * Directories to be excluded from content processing
160
+ *
161
+ * Default: ['node_modules']
162
+ *
163
+ * A list of directories to exclude from content processing.
164
+ */
165
+ excludedPath: string[];
88
166
 
89
- // Bundle directory name
90
- bundleDirName: string; // default 'bundle'
167
+ /**
168
+ * Name of the directory where results are stored
169
+ *
170
+ * Default: '.intlayer'
171
+ *
172
+ * The directory for storing intermediate or output results.
173
+ */
174
+ resultDirName: string;
91
175
 
92
- // Bundle file extension
93
- bundleFileExtension: string; // default '.bundle.js'
176
+ /**
177
+ * Name of the directory for module augmentation
178
+ *
179
+ * Default: 'types'
180
+ *
181
+ * Defines the directory for additional module types.
182
+ */
183
+ moduleAugmentationDirName: string;
94
184
 
95
- // Dictionary directory name
96
- dictionariesDirName: string; // default 'dictionary'
185
+ /**
186
+ * Name of the directory where dictionaries are stored
187
+ *
188
+ * Default: 'dictionary'
189
+ *
190
+ * The directory for storing localization dictionaries.
191
+ */
192
+ dictionariesDirName: string;
97
193
 
98
- // Types directory name
99
- typeDirName: string; // default 'types'
194
+ /**
195
+ * Name of the directory where dictionary types are stored
196
+ *
197
+ * Default: 'types'
198
+ *
199
+ * The directory for storing dictionary type definitions.
200
+ */
201
+ typeDirName: string;
100
202
 
101
- // Main directory name
102
- mainDirName: string; // default 'main'
203
+ /**
204
+ * Name of the directory where the main files are stored
205
+ *
206
+ * Default: 'main'
207
+ *
208
+ * Specifies the directory for storing main application files.
209
+ */
210
+ mainDirName: string;
103
211
  };
104
212
 
213
+ /**
214
+ * Configuration derived based on the base content configuration
215
+ */
105
216
  export type BaseDerivedConfig = {
106
- // Directory to watch - emplacement where the content is stored
107
- contentDir: string; // default {{baseDir}} / {{contentDirName}}
217
+ /**
218
+ * Directory where the content is stored, relative to the base directory
219
+ *
220
+ * Default: {{baseDir}} / {{contentDirName}}
221
+ *
222
+ * Derived content directory based on the base configuration.
223
+ */
224
+ contentDir: string;
108
225
 
109
- // Result directory
110
- resultDir: string; // default {{baseDir}} / {{resultDirName}}
226
+ /**
227
+ * Directory where the results are stored, relative to the base directory
228
+ *
229
+ * Default: {{baseDir}} / {{resultDirName}}
230
+ *
231
+ * Derived results directory based on the base configuration.
232
+ */
233
+ resultDir: string;
111
234
 
112
- // Result directory
113
- moduleAugmentationDir: string; // default {{baseDir}} / {{moduleAugmentationDirName}}
235
+ /**
236
+ * Directory for module augmentation, relative to the base directory
237
+ *
238
+ * Default: {{baseDir}} / {{moduleAugmentationDirName}}
239
+ *
240
+ * Defines the derived path for module augmentation.
241
+ */
242
+ moduleAugmentationDir: string;
114
243
  };
115
244
 
245
+ /**
246
+ * Configuration derived based on the result directory
247
+ */
116
248
  export type ResultDirDerivedConfig = {
117
- // Bundle directory
118
- bundleDir: string; // default {{resultDir}} / {{bundleDirName}}
119
-
120
- // Dictionary directory
121
- dictionariesDir: string; // default {{resultDir}} / {{dictionaryDirName}}
249
+ /**
250
+ * Directory where dictionaries are stored, relative to the result directory
251
+ *
252
+ * Default: {{resultDir}} / {{dictionariesDirName}}
253
+ *
254
+ * Specifies the derived path for dictionaries relative to the result directory.
255
+ */
256
+ dictionariesDir: string;
122
257
 
123
- // Types directory
124
- typesDir: string; // default {{resultDir}} / {{typeDirName}}
258
+ /**
259
+ * Directory where dictionary types are stored, relative to the result directory
260
+ *
261
+ * Default: {{resultDir}} / {{typeDirName}}
262
+ *
263
+ * Specifies the derived path for dictionary types relative to the result directory.
264
+ */
265
+ typesDir: string;
125
266
 
126
- // Main directory
127
- mainDir: string; // default {{resultDir}} / {{mainDirName}}
267
+ /**
268
+ * Directory where the main files are stored, relative to the result directory
269
+ *
270
+ * Default: {{resultDir}} / {{mainDirName}}
271
+ *
272
+ * Specifies the derived path for the main files relative to the result directory.
273
+ */
274
+ mainDir: string;
128
275
  };
129
276
 
277
+ /**
278
+ * Configuration for content patterns
279
+ */
130
280
  export type PatternsContentConfig = {
131
- // Pattern of files to watch
281
+ /**
282
+ * Patterns of files to watch for changes
283
+ *
284
+ * Default: ['/**\/*.content.ts', '/**\/*.content.js', '/**\/*.content.json']
285
+ *
286
+ * Defines file patterns for content to watch for changes.
287
+ */
132
288
  watchedFilesPattern: string[];
133
289
 
134
- // Pattern of files to watch including the relative path
290
+ /**
291
+ * Patterns of files to watch for changes including the relative path
292
+ *
293
+ * Default: ['{{contentDir}}/**\/*.content.ts', '{{contentDir}}/**\/*.content.js', '{{contentDir}}/**\/*.content.json']
294
+ *
295
+ * Specifies the file patterns for content to watch, including relative paths.
296
+ */
135
297
  watchedFilesPatternWithPath: string[];
136
298
 
137
- // Pattern of files to output
299
+ /**
300
+ * Pattern for output files including the relative path
301
+ *
302
+ * Default: '{{dictionariesDir}}/**\/*.json'
303
+ *
304
+ * Defines the pattern for output files, including the relative path.
305
+ */
138
306
  outputFilesPatternWithPath: string;
139
307
  };
140
308
 
309
+ // @TODO: Implement exclusion of non configurable fields, to not allow them to be set in the config
310
+ /**
311
+ * General configuration derived from the config file
312
+ */
141
313
  export type ContentConfig = BaseContentConfig &
142
314
  BaseDerivedConfig &
143
315
  ResultDirDerivedConfig &