@intlayer/config 1.0.2 → 1.2.1

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