@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,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,173 @@ 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.json']
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
+ */
53
171
  dictionariesDirName: string;
172
+ /**
173
+ * Name of the directory where dictionary types are stored
174
+ *
175
+ * Default: 'types'
176
+ *
177
+ * The directory for storing dictionary type definitions.
178
+ */
54
179
  typeDirName: string;
180
+ /**
181
+ * Name of the directory where the main files are stored
182
+ *
183
+ * Default: 'main'
184
+ *
185
+ * Specifies the directory for storing main application files.
186
+ */
55
187
  mainDirName: string;
56
188
  };
189
+ /**
190
+ * Configuration derived based on the base content configuration
191
+ */
57
192
  type BaseDerivedConfig = {
193
+ /**
194
+ * Directory where the content is stored, relative to the base directory
195
+ *
196
+ * Default: {{baseDir}} / {{contentDirName}}
197
+ *
198
+ * Derived content directory based on the base configuration.
199
+ */
58
200
  contentDir: string;
201
+ /**
202
+ * Directory where the results are stored, relative to the base directory
203
+ *
204
+ * Default: {{baseDir}} / {{resultDirName}}
205
+ *
206
+ * Derived results directory based on the base configuration.
207
+ */
59
208
  resultDir: string;
209
+ /**
210
+ * Directory for module augmentation, relative to the base directory
211
+ *
212
+ * Default: {{baseDir}} / {{moduleAugmentationDirName}}
213
+ *
214
+ * Defines the derived path for module augmentation.
215
+ */
60
216
  moduleAugmentationDir: string;
61
217
  };
218
+ /**
219
+ * Configuration derived based on the result directory
220
+ */
62
221
  type ResultDirDerivedConfig = {
63
- bundleDir: string;
222
+ /**
223
+ * Directory where dictionaries are stored, relative to the result directory
224
+ *
225
+ * Default: {{resultDir}} / {{dictionariesDirName}}
226
+ *
227
+ * Specifies the derived path for dictionaries relative to the result directory.
228
+ */
64
229
  dictionariesDir: string;
230
+ /**
231
+ * Directory where dictionary types are stored, relative to the result directory
232
+ *
233
+ * Default: {{resultDir}} / {{typeDirName}}
234
+ *
235
+ * Specifies the derived path for dictionary types relative to the result directory.
236
+ */
65
237
  typesDir: string;
238
+ /**
239
+ * Directory where the main files are stored, relative to the result directory
240
+ *
241
+ * Default: {{resultDir}} / {{mainDirName}}
242
+ *
243
+ * Specifies the derived path for the main files relative to the result directory.
244
+ */
66
245
  mainDir: string;
67
246
  };
247
+ /**
248
+ * Configuration for content patterns
249
+ */
68
250
  type PatternsContentConfig = {
251
+ /**
252
+ * Patterns of files to watch for changes
253
+ *
254
+ * Default: ['/**\/*.content.ts', '/**\/*.content.js', '/**\/*.content.json']
255
+ *
256
+ * Defines file patterns for content to watch for changes.
257
+ */
69
258
  watchedFilesPattern: string[];
259
+ /**
260
+ * Patterns of files to watch for changes including the relative path
261
+ *
262
+ * Default: ['{{contentDir}}/**\/*.content.ts', '{{contentDir}}/**\/*.content.js', '{{contentDir}}/**\/*.content.json']
263
+ *
264
+ * Specifies the file patterns for content to watch, including relative paths.
265
+ */
70
266
  watchedFilesPatternWithPath: string[];
267
+ /**
268
+ * Pattern for output files including the relative path
269
+ *
270
+ * Default: '{{dictionariesDir}}/**\/*.json'
271
+ *
272
+ * Defines the pattern for output files, including the relative path.
273
+ */
71
274
  outputFilesPatternWithPath: string;
72
275
  };
276
+ /**
277
+ * General configuration derived from the config file
278
+ */
73
279
  type ContentConfig = BaseContentConfig & BaseDerivedConfig & ResultDirDerivedConfig & PatternsContentConfig;
74
280
 
75
281
  export type { BaseContentConfig, BaseDerivedConfig, ContentConfig, CustomIntlayerConfig, InternationalizationConfig, IntlayerConfig, MiddlewareConfig, PatternsContentConfig, ResultDirDerivedConfig, ServerSetCookieRule };