@intlayer/config 5.4.2 → 5.5.0-canary.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.
- package/dist/cjs/configFile/buildConfigurationFields.cjs +85 -196
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/defaultValues/content.cjs +27 -27
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/editor.cjs +0 -9
- package/dist/cjs/defaultValues/editor.cjs.map +1 -1
- package/dist/cjs/envVariables/extractEnvVariable/next.cjs +14 -18
- package/dist/cjs/envVariables/extractEnvVariable/next.cjs.map +1 -1
- package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs +12 -16
- package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs.map +1 -1
- package/dist/cjs/envVariables/extractEnvVariable/types.cjs.map +1 -1
- package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs +12 -16
- package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs.map +1 -1
- package/dist/cjs/envVariables/extractEnvVariable/vite.cjs +12 -16
- package/dist/cjs/envVariables/extractEnvVariable/vite.cjs.map +1 -1
- package/dist/cjs/envVariables/getConfiguration.cjs +13 -30
- package/dist/cjs/envVariables/getConfiguration.cjs.map +1 -1
- package/dist/cjs/index.cjs +9 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/logger.cjs +6 -5
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/retryManager.cjs +52 -0
- package/dist/cjs/retryManager.cjs.map +1 -0
- package/dist/cjs/types/config.cjs.map +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs +101 -215
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/defaultValues/content.mjs +18 -18
- package/dist/esm/defaultValues/content.mjs.map +1 -1
- package/dist/esm/defaultValues/editor.mjs +0 -6
- package/dist/esm/defaultValues/editor.mjs.map +1 -1
- package/dist/esm/envVariables/extractEnvVariable/next.mjs +14 -18
- package/dist/esm/envVariables/extractEnvVariable/next.mjs.map +1 -1
- package/dist/esm/envVariables/extractEnvVariable/react_app.mjs +12 -16
- package/dist/esm/envVariables/extractEnvVariable/react_app.mjs.map +1 -1
- package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs +12 -16
- package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs.map +1 -1
- package/dist/esm/envVariables/extractEnvVariable/vite.mjs +12 -16
- package/dist/esm/envVariables/extractEnvVariable/vite.mjs.map +1 -1
- package/dist/esm/envVariables/getConfiguration.mjs +13 -30
- package/dist/esm/envVariables/getConfiguration.mjs.map +1 -1
- package/dist/esm/index.mjs +9 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/logger.mjs +6 -5
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/retryManager.mjs +28 -0
- package/dist/esm/retryManager.mjs.map +1 -0
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/defaultValues/content.d.ts +9 -9
- package/dist/types/defaultValues/content.d.ts.map +1 -1
- package/dist/types/defaultValues/editor.d.ts +0 -3
- package/dist/types/defaultValues/editor.d.ts.map +1 -1
- package/dist/types/envVariables/extractEnvVariable/next.d.ts.map +1 -1
- package/dist/types/envVariables/extractEnvVariable/react_app.d.ts.map +1 -1
- package/dist/types/envVariables/extractEnvVariable/types.d.ts +1 -1
- package/dist/types/envVariables/extractEnvVariable/types.d.ts.map +1 -1
- package/dist/types/envVariables/extractEnvVariable/undefined_platform.d.ts.map +1 -1
- package/dist/types/envVariables/extractEnvVariable/vite.d.ts.map +1 -1
- package/dist/types/envVariables/getConfiguration.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/retryManager.d.ts +17 -0
- package/dist/types/retryManager.d.ts.map +1 -0
- package/dist/types/types/config.d.ts +64 -106
- package/dist/types/types/config.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -140,7 +140,7 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
140
140
|
/**
|
|
141
141
|
* Absolute path of the directory of the project
|
|
142
142
|
* - Default: process.cwd()
|
|
143
|
-
* - Example: '
|
|
143
|
+
* - Example: '
|
|
144
144
|
*
|
|
145
145
|
* Will be used to resolve all intlayer directories
|
|
146
146
|
*
|
|
@@ -149,125 +149,6 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
149
149
|
* - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project
|
|
150
150
|
*/
|
|
151
151
|
baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),
|
|
152
|
-
/**
|
|
153
|
-
* Directory name where the content is stored
|
|
154
|
-
*
|
|
155
|
-
* Default: 'src'
|
|
156
|
-
*
|
|
157
|
-
* Example:
|
|
158
|
-
* - 'data' -> '/path/to/project/data'
|
|
159
|
-
* - 'content' -> '/path/to/project/content'
|
|
160
|
-
* - 'locales' -> '/path/to/project/locales'
|
|
161
|
-
*
|
|
162
|
-
* Note: If this directory is not at the base directory level, update the contentDir field instead
|
|
163
|
-
*/
|
|
164
|
-
contentDirName: customConfiguration?.contentDirName ?? import_content.CONTENT_DIR_NAME,
|
|
165
|
-
/**
|
|
166
|
-
* Directory name where the result will be stored
|
|
167
|
-
*
|
|
168
|
-
* Default: '.intlayer'
|
|
169
|
-
*
|
|
170
|
-
* Example:
|
|
171
|
-
* - '.next'
|
|
172
|
-
* - 'outputOFIntlayer'
|
|
173
|
-
*
|
|
174
|
-
* Note: If this directory is not at the base directory level, update the resultDir field instead
|
|
175
|
-
*/
|
|
176
|
-
resultDirName: customConfiguration?.resultDirName ?? import_content.RESULT_DIR_NAME,
|
|
177
|
-
/**
|
|
178
|
-
*
|
|
179
|
-
* Directory name where the module augmentation will be stored
|
|
180
|
-
*
|
|
181
|
-
* Module augmentation allow better IDE suggestions and type checking
|
|
182
|
-
*
|
|
183
|
-
* Default: 'types'
|
|
184
|
-
*
|
|
185
|
-
* Example: 'intlayer-types'
|
|
186
|
-
*
|
|
187
|
-
* Note:
|
|
188
|
-
* - If this path changed, be sure to include it from the tsconfig.json file
|
|
189
|
-
* - If this directory is not at the base directory level, update the moduleAugmentationDir field instead
|
|
190
|
-
*/
|
|
191
|
-
moduleAugmentationDirName: customConfiguration?.moduleAugmentationDirName ?? import_content.MODULE_AUGMENTATION_DIR_NAME,
|
|
192
|
-
// @TODO: Make Module Augmentation optional by adding a flag in the configuration
|
|
193
|
-
/**
|
|
194
|
-
* Related to the intlayer result directory
|
|
195
|
-
*
|
|
196
|
-
* Directory name where the dictionaries will be stored
|
|
197
|
-
*
|
|
198
|
-
* Default: 'dictionary'
|
|
199
|
-
*
|
|
200
|
-
* Example: 'translations'
|
|
201
|
-
*
|
|
202
|
-
* Note:
|
|
203
|
-
* - If this directory is not at the result directory level, update the dictionariesDir field instead
|
|
204
|
-
*
|
|
205
|
-
*/
|
|
206
|
-
dictionariesDirName: customConfiguration?.dictionariesDirName ?? import_content.DICTIONARIES_DIR_NAME,
|
|
207
|
-
/**
|
|
208
|
-
* Related to the intlayer result directory
|
|
209
|
-
*
|
|
210
|
-
* Directory name where the dictionaries will be stored
|
|
211
|
-
*
|
|
212
|
-
* Default: 'dictionary'
|
|
213
|
-
*
|
|
214
|
-
* Example: 'translations'
|
|
215
|
-
*
|
|
216
|
-
* Note:
|
|
217
|
-
* - If this directory is not at the result directory level, update the dictionariesDir field instead
|
|
218
|
-
*
|
|
219
|
-
*/
|
|
220
|
-
i18nextResourcesDirName: customConfiguration?.i18nextResourcesDirName ?? import_content.I18NEXT_DICTIONARIES_DIR_NAME,
|
|
221
|
-
/**
|
|
222
|
-
* Related to the intlayer result directory
|
|
223
|
-
*
|
|
224
|
-
* Directory name where the dictionaries will be stored
|
|
225
|
-
*
|
|
226
|
-
* Default: 'react-intl_dictionary'
|
|
227
|
-
*
|
|
228
|
-
* Example: 'translations'
|
|
229
|
-
*
|
|
230
|
-
* Note:
|
|
231
|
-
* - If this directory is not at the result directory level, update the dictionariesDir field instead
|
|
232
|
-
*
|
|
233
|
-
*/
|
|
234
|
-
reactIntlMessagesDirName: customConfiguration?.reactIntlMessagesDirName ?? import_content.REACT_INTL_MESSAGES_DIR_NAME,
|
|
235
|
-
/**
|
|
236
|
-
* Related to the intlayer result directory
|
|
237
|
-
*
|
|
238
|
-
* Directory name where the dictionaries types will be stored
|
|
239
|
-
*
|
|
240
|
-
* Default: 'types'
|
|
241
|
-
*
|
|
242
|
-
* Example: 'intlayer-types'
|
|
243
|
-
*
|
|
244
|
-
* Note:
|
|
245
|
-
* - If this directory is not at the result directory level, update the typesDir field instead
|
|
246
|
-
*
|
|
247
|
-
*/
|
|
248
|
-
typeDirName: customConfiguration?.typeDirName ?? import_content.TYPES_DIR_NAME,
|
|
249
|
-
/**
|
|
250
|
-
* Related to the intlayer result directory
|
|
251
|
-
*
|
|
252
|
-
* Directory name where the main files will be stored
|
|
253
|
-
*
|
|
254
|
-
* Default: 'main'
|
|
255
|
-
*
|
|
256
|
-
* Example: 'intlayer-main'
|
|
257
|
-
*
|
|
258
|
-
* Note:
|
|
259
|
-
* - If this directory is not at the result directory level, update the mainDir field instead
|
|
260
|
-
*/
|
|
261
|
-
mainDirName: customConfiguration?.mainDirName ?? import_content.MAIN_DIR_NAME,
|
|
262
|
-
/**
|
|
263
|
-
* Name of the directory where the configuration files are stored
|
|
264
|
-
*
|
|
265
|
-
* Default: 'config'
|
|
266
|
-
*
|
|
267
|
-
* Example: 'intlayer-config'
|
|
268
|
-
*
|
|
269
|
-
*/
|
|
270
|
-
configDirName: customConfiguration?.configDirName ?? import_content.CONFIG_DIR_NAME,
|
|
271
152
|
/**
|
|
272
153
|
* Should exclude some directories from the content search
|
|
273
154
|
*
|
|
@@ -290,34 +171,33 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
290
171
|
*
|
|
291
172
|
* Relative to the base directory of the project
|
|
292
173
|
*
|
|
293
|
-
* Default:
|
|
174
|
+
* Default: ./src
|
|
294
175
|
*
|
|
295
|
-
* Example: '
|
|
176
|
+
* Example: 'src'
|
|
296
177
|
*
|
|
297
178
|
* Note:
|
|
298
179
|
* - Can be changed to a custom directory to externalize the content used in the project
|
|
299
180
|
* - If the content is not at the base directory level, update the contentDirName field instead
|
|
300
181
|
*/
|
|
301
|
-
contentDir: (
|
|
302
|
-
notDerivedContentConfig.baseDir,
|
|
303
|
-
notDerivedContentConfig.contentDirName
|
|
182
|
+
contentDir: (customConfiguration?.contentDir ?? import_content.CONTENT_DIR).map(
|
|
183
|
+
(contentDir) => (0, import_path.join)(notDerivedContentConfig.baseDir, contentDir)
|
|
304
184
|
),
|
|
305
185
|
/**
|
|
306
186
|
* Directory where the result will be stored
|
|
307
187
|
*
|
|
308
188
|
* Relative to the base directory of the project
|
|
309
189
|
*
|
|
310
|
-
* Default:
|
|
190
|
+
* Default: .intlayer/dictionary
|
|
311
191
|
*
|
|
312
|
-
* Example: '
|
|
192
|
+
* Example: '.intlayer'
|
|
313
193
|
*
|
|
314
194
|
* Note:
|
|
315
195
|
* - Can be changed to a custom directory to externalize the intlayer application from the project
|
|
316
|
-
* - If the result is not at the base directory level, update the
|
|
196
|
+
* - If the result is not at the base directory level, update the dictionariesDirName field instead
|
|
317
197
|
*/
|
|
318
|
-
|
|
198
|
+
dictionariesDir: (0, import_path.join)(
|
|
319
199
|
notDerivedContentConfig.baseDir,
|
|
320
|
-
|
|
200
|
+
customConfiguration?.dictionariesDir ?? import_content.DICTIONARIES_DIR
|
|
321
201
|
),
|
|
322
202
|
/**
|
|
323
203
|
* Directory where the module augmentation will be stored
|
|
@@ -326,9 +206,9 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
326
206
|
*
|
|
327
207
|
* Relative to the base directory of the project
|
|
328
208
|
*
|
|
329
|
-
* Default:
|
|
209
|
+
* Default: .intlayer/types
|
|
330
210
|
*
|
|
331
|
-
* Example: '
|
|
211
|
+
* Example: 'types'
|
|
332
212
|
*
|
|
333
213
|
* Note:
|
|
334
214
|
* - If this path changed, be sure to include it from the tsconfig.json file
|
|
@@ -337,7 +217,7 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
337
217
|
*/
|
|
338
218
|
moduleAugmentationDir: (0, import_path.join)(
|
|
339
219
|
notDerivedContentConfig.baseDir,
|
|
340
|
-
|
|
220
|
+
customConfiguration?.moduleAugmentationDir ?? import_content.MODULE_AUGMENTATION_DIR
|
|
341
221
|
),
|
|
342
222
|
/**
|
|
343
223
|
* Output format of the dictionary
|
|
@@ -350,15 +230,27 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
350
230
|
*/
|
|
351
231
|
dictionaryOutput: customConfiguration?.dictionaryOutput ?? import_content.DICTIONARY_OUTPUT
|
|
352
232
|
};
|
|
353
|
-
const
|
|
233
|
+
const dictionariesDirDerivedConfiguration = {
|
|
354
234
|
/**
|
|
355
|
-
* Directory where the dictionaries will be stored
|
|
235
|
+
* Directory where the unmerged dictionaries will be stored
|
|
356
236
|
*
|
|
357
237
|
* Relative to the result directory
|
|
358
238
|
*
|
|
359
|
-
* Default:
|
|
239
|
+
* Default: '.intlayer/unmerged_dictionary'
|
|
360
240
|
*
|
|
361
|
-
|
|
241
|
+
*/
|
|
242
|
+
unmergedDictionariesDir: (0, import_path.join)(
|
|
243
|
+
notDerivedContentConfig.baseDir,
|
|
244
|
+
customConfiguration?.unmergedDictionariesDir ?? import_content.UNMERGED_DICTIONARIES_DIR
|
|
245
|
+
),
|
|
246
|
+
/**
|
|
247
|
+
* Directory where the final dictionaries will be stored
|
|
248
|
+
*
|
|
249
|
+
* Relative to the result directory
|
|
250
|
+
*
|
|
251
|
+
* Default: .intlayer/dictionary
|
|
252
|
+
*
|
|
253
|
+
* Example: '.intlayer/dictionary'
|
|
362
254
|
*
|
|
363
255
|
* Note:
|
|
364
256
|
* - If the types are not at the result directory level, update the dictionariesDirName field instead
|
|
@@ -367,90 +259,90 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
367
259
|
* - The dictionaries are built from the content files
|
|
368
260
|
*/
|
|
369
261
|
dictionariesDir: (0, import_path.join)(
|
|
370
|
-
|
|
371
|
-
|
|
262
|
+
notDerivedContentConfig.baseDir,
|
|
263
|
+
customConfiguration?.dictionariesDir ?? import_content.DICTIONARIES_DIR
|
|
372
264
|
),
|
|
373
265
|
/**
|
|
374
266
|
* Directory where the 18n dictionaries will be stored
|
|
375
267
|
*
|
|
376
268
|
* Relative to the result directory
|
|
377
269
|
*
|
|
378
|
-
* Default:
|
|
270
|
+
* Default: i18next_resources
|
|
379
271
|
*
|
|
380
|
-
* Example: '
|
|
272
|
+
* Example: '.intlayer/dictionary/i18n'
|
|
381
273
|
*
|
|
382
274
|
* Note:
|
|
383
275
|
* - If the types are not at the result directory level, update the i18nextResourcesDirName field instead
|
|
384
276
|
*/
|
|
385
277
|
i18nextResourcesDir: (0, import_path.join)(
|
|
386
|
-
|
|
387
|
-
|
|
278
|
+
notDerivedContentConfig.baseDir,
|
|
279
|
+
customConfiguration?.i18nextResourcesDir ?? import_content.I18NEXT_DICTIONARIES_DIR
|
|
388
280
|
),
|
|
389
281
|
/**
|
|
390
282
|
* Directory where the dictionaries will be stored
|
|
391
283
|
*
|
|
392
284
|
* Relative to the result directory
|
|
393
285
|
*
|
|
394
|
-
* Default:
|
|
286
|
+
* Default: intl_messages
|
|
395
287
|
*
|
|
396
|
-
* Example: '
|
|
288
|
+
* Example: '.intlayer/react-intl_dictionary'
|
|
397
289
|
*
|
|
398
290
|
* Note:
|
|
399
291
|
* - If the types are not at the result directory level, update the dictionariesDirName field instead
|
|
400
292
|
*/
|
|
401
293
|
reactIntlMessagesDir: (0, import_path.join)(
|
|
402
|
-
|
|
403
|
-
|
|
294
|
+
notDerivedContentConfig.baseDir,
|
|
295
|
+
customConfiguration?.reactIntlMessagesDir ?? import_content.REACT_INTL_MESSAGES_DIR
|
|
404
296
|
),
|
|
405
297
|
/**
|
|
406
298
|
* Directory where the dictionaries types will be stored
|
|
407
299
|
*
|
|
408
300
|
* Relative to the result directory
|
|
409
301
|
*
|
|
410
|
-
* Default:
|
|
302
|
+
* Default: .intlayer/types
|
|
411
303
|
*
|
|
412
|
-
* Example: '
|
|
304
|
+
* Example: 'types'
|
|
413
305
|
*
|
|
414
306
|
* Note:
|
|
415
307
|
* - If the types are not at the result directory level, update the typesDirName field instead
|
|
416
308
|
*/
|
|
417
309
|
typesDir: (0, import_path.join)(
|
|
418
|
-
|
|
419
|
-
|
|
310
|
+
notDerivedContentConfig.baseDir,
|
|
311
|
+
customConfiguration?.typesDir ?? import_content.TYPES_DIR
|
|
420
312
|
),
|
|
421
313
|
/**
|
|
422
314
|
* Directory where the main files will be stored
|
|
423
315
|
*
|
|
424
316
|
* Relative to the result directory
|
|
425
317
|
*
|
|
426
|
-
* Default:
|
|
318
|
+
* Default: .intlayer/main
|
|
427
319
|
*
|
|
428
|
-
* Example: '
|
|
320
|
+
* Example: '.intlayer/main'
|
|
429
321
|
*
|
|
430
322
|
* Note:
|
|
431
323
|
*
|
|
432
324
|
* - If the main files are not at the result directory level, update the mainDirName field instead
|
|
433
325
|
*/
|
|
434
326
|
mainDir: (0, import_path.join)(
|
|
435
|
-
|
|
436
|
-
|
|
327
|
+
notDerivedContentConfig.baseDir,
|
|
328
|
+
customConfiguration?.mainDir ?? import_content.MAIN_DIR
|
|
437
329
|
),
|
|
438
330
|
/**
|
|
439
331
|
* Directory where the configuration files are stored
|
|
440
332
|
*
|
|
441
333
|
* Relative to the result directory
|
|
442
334
|
*
|
|
443
|
-
* Default:
|
|
335
|
+
* Default: .intlayer/config
|
|
444
336
|
*
|
|
445
|
-
* Example: '
|
|
337
|
+
* Example: '.intlayer/config'
|
|
446
338
|
*
|
|
447
339
|
* Note:
|
|
448
340
|
*
|
|
449
341
|
* - If the configuration files are not at the result directory level, update the configDirName field instead
|
|
450
342
|
*/
|
|
451
343
|
configDir: (0, import_path.join)(
|
|
452
|
-
|
|
453
|
-
|
|
344
|
+
notDerivedContentConfig.baseDir,
|
|
345
|
+
customConfiguration?.configDir ?? import_content.CONFIG_DIR
|
|
454
346
|
)
|
|
455
347
|
};
|
|
456
348
|
const patternsConfiguration = {
|
|
@@ -465,22 +357,24 @@ const buildContentFields = (customConfiguration, baseDir) => {
|
|
|
465
357
|
/**
|
|
466
358
|
* Pattern of files to watch including the relative path
|
|
467
359
|
*
|
|
468
|
-
* Default: ['
|
|
360
|
+
* Default: ['src/**\/*.content.ts', 'src/**\/*.content.js', 'src/**\/*.content.json', 'src/**\/*.content.cjs', 'src/**\/*.content.mjs', 'src/**\/*.content.tsx', 'src/**\/*.content.jsx']
|
|
469
361
|
*/
|
|
470
|
-
watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.
|
|
471
|
-
(ext) =>
|
|
362
|
+
watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(
|
|
363
|
+
(ext) => baseDirDerivedConfiguration.contentDir.map(
|
|
364
|
+
(contentDir) => `${contentDir}/**/*${ext}`
|
|
365
|
+
)
|
|
472
366
|
),
|
|
473
367
|
/**
|
|
474
368
|
* Pattern of dictionary to interpret
|
|
475
369
|
*
|
|
476
|
-
* Default: '
|
|
370
|
+
* Default: '.intlayer/dictionary/**\/*.json'
|
|
477
371
|
*/
|
|
478
|
-
outputFilesPatternWithPath: `${
|
|
372
|
+
outputFilesPatternWithPath: `${dictionariesDirDerivedConfiguration.dictionariesDir}/**/*.json`
|
|
479
373
|
};
|
|
480
374
|
return {
|
|
481
375
|
...notDerivedContentConfig,
|
|
482
376
|
...baseDirDerivedConfiguration,
|
|
483
|
-
...
|
|
377
|
+
...dictionariesDirDerivedConfiguration,
|
|
484
378
|
...patternsConfiguration
|
|
485
379
|
};
|
|
486
380
|
};
|
|
@@ -576,36 +470,7 @@ const buildEditorFields = (customConfiguration) => ({
|
|
|
576
470
|
*
|
|
577
471
|
* Default: false
|
|
578
472
|
*/
|
|
579
|
-
hotReload: customConfiguration?.hotReload ?? import_editor.HOT_RELOAD
|
|
580
|
-
/**
|
|
581
|
-
* OpenAI API key
|
|
582
|
-
*
|
|
583
|
-
* Use your own OpenAI API key to use the AI features of Intlayer.
|
|
584
|
-
* If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.
|
|
585
|
-
*
|
|
586
|
-
* Default: ''
|
|
587
|
-
*/
|
|
588
|
-
openAiApiKey: customConfiguration?.openAiApiKey ?? import_editor.OPEN_AI_API_KEY,
|
|
589
|
-
/**
|
|
590
|
-
* OpenAI API model
|
|
591
|
-
*
|
|
592
|
-
* The model to use for the AI features of Intlayer.
|
|
593
|
-
*
|
|
594
|
-
* Default: 'gpt-4o-2024-11-20'
|
|
595
|
-
*
|
|
596
|
-
* > Necessitate to define openAiApiKey to use this model
|
|
597
|
-
*/
|
|
598
|
-
openAiApiModel: customConfiguration?.openAiApiModel ?? import_editor.OPEN_AI_API_MODEL,
|
|
599
|
-
/**
|
|
600
|
-
* OpenAI API temperature
|
|
601
|
-
*
|
|
602
|
-
* The temperature to use for the AI features of Intlayer.
|
|
603
|
-
* The temperature controls the randomness of the AI's responses.
|
|
604
|
-
* A higher temperature will make the AI more creative and less predictable.
|
|
605
|
-
*
|
|
606
|
-
* Default: 0.1
|
|
607
|
-
*/
|
|
608
|
-
openAiApiTemperature: customConfiguration?.openAiApiTemperature ?? import_editor.OPEN_AI_API_TEMPERATURE
|
|
473
|
+
hotReload: customConfiguration?.hotReload ?? import_editor.HOT_RELOAD
|
|
609
474
|
});
|
|
610
475
|
const buildLogFields = (customConfiguration) => ({
|
|
611
476
|
/**
|
|
@@ -627,6 +492,28 @@ const buildLogFields = (customConfiguration) => ({
|
|
|
627
492
|
*/
|
|
628
493
|
prefix: customConfiguration?.prefix ?? import_log.PREFIX
|
|
629
494
|
});
|
|
495
|
+
const buildAiFields = (customConfiguration) => ({
|
|
496
|
+
/**
|
|
497
|
+
* AI configuration
|
|
498
|
+
*/
|
|
499
|
+
provider: customConfiguration?.provider,
|
|
500
|
+
/**
|
|
501
|
+
* API key
|
|
502
|
+
*/
|
|
503
|
+
apiKey: customConfiguration?.apiKey,
|
|
504
|
+
/**
|
|
505
|
+
* API model
|
|
506
|
+
*/
|
|
507
|
+
model: customConfiguration?.model,
|
|
508
|
+
/**
|
|
509
|
+
* Temperature
|
|
510
|
+
*/
|
|
511
|
+
temperature: customConfiguration?.temperature,
|
|
512
|
+
/**
|
|
513
|
+
* Application context
|
|
514
|
+
*/
|
|
515
|
+
applicationContext: customConfiguration?.applicationContext
|
|
516
|
+
});
|
|
630
517
|
const buildConfigurationFields = (customConfiguration, baseDir) => {
|
|
631
518
|
const internationalizationConfig = buildInternationalizationFields(
|
|
632
519
|
customConfiguration?.internationalization
|
|
@@ -640,12 +527,14 @@ const buildConfigurationFields = (customConfiguration, baseDir) => {
|
|
|
640
527
|
);
|
|
641
528
|
const editorConfig = buildEditorFields(customConfiguration?.editor);
|
|
642
529
|
const logConfig = buildLogFields(customConfiguration?.log);
|
|
530
|
+
const aiConfig = buildAiFields(customConfiguration?.ai);
|
|
643
531
|
storedConfiguration = {
|
|
644
532
|
internationalization: internationalizationConfig,
|
|
645
533
|
middleware: middlewareConfig,
|
|
646
534
|
content: contentConfig,
|
|
647
535
|
editor: editorConfig,
|
|
648
|
-
log: logConfig
|
|
536
|
+
log: logConfig,
|
|
537
|
+
ai: aiConfig
|
|
649
538
|
};
|
|
650
539
|
return storedConfiguration;
|
|
651
540
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport {\n CONTENT_DIR_NAME,\n DICTIONARIES_DIR_NAME,\n FILE_EXTENSIONS,\n RESULT_DIR_NAME,\n EXCLUDED_PATHS,\n TYPES_DIR_NAME,\n MAIN_DIR_NAME,\n MODULE_AUGMENTATION_DIR_NAME,\n I18NEXT_DICTIONARIES_DIR_NAME,\n DICTIONARY_OUTPUT,\n WATCH,\n REACT_INTL_MESSAGES_DIR_NAME,\n CONFIG_DIR_NAME,\n} from '../defaultValues/content';\nimport {\n APPLICATION_URL,\n EDITOR_URL,\n CMS_URL,\n BACKEND_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n IS_ENABLED,\n PORT,\n HOT_RELOAD,\n OPEN_AI_API_KEY,\n OPEN_AI_API_MODEL,\n OPEN_AI_API_TEMPERATURE,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport type {\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n PatternsContentConfig,\n InternationalizationConfig,\n IntlayerConfig,\n MiddlewareConfig,\n BaseContentConfig,\n ResultDirDerivedConfig,\n EditorConfig,\n LogConfig,\n} from '../types/config';\n\nlet storedConfiguration: IntlayerConfig;\n\n// @TODO - Add possibility of directories configurations to be arrays to allow multiple packages management\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales: customConfiguration?.requiredLocales ?? REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - 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.\n * - 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.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Header name to get the locale\n *\n * Default: 'x-intlayer-locale'\n */\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n /**\n * Cookie name to get the locale\n *\n * Default: 'intlayer-locale'\n */\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n *\n * Default: false\n */\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n /**\n * Rule to set the cookie on the server\n * - 'always': Set the cookie on every request\n * - 'never': Never set the cookie\n */\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n /**\n * No prefix in the URL\n * - true: No prefix in the URL\n * - false: Prefix in the URL\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n * - If no prefix is set, the URL will be https://example.com/en\n * - If the no prefix is set to true, the URL will be https://example.com\n *\n * Default: false\n */\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * File extensions of content to look for to build the dictionaries\n *\n * - Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * - Example: ['.data.ts', '.data.js', '.data.json']\n *\n * Note:\n * - Can exclude unused file extensions to improve performance\n * - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts\n */\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n /**\n * Absolute path of the directory of the project\n * - Default: process.cwd()\n * - Example: '/path/to/project'\n *\n * Will be used to resolve all intlayer directories\n *\n * Note:\n * - The base directory should be the root of the project\n * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project\n */\n baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),\n\n /**\n * Directory name where the content is stored\n *\n * Default: 'src'\n *\n * Example:\n * - 'data' -> '/path/to/project/data'\n * - 'content' -> '/path/to/project/content'\n * - 'locales' -> '/path/to/project/locales'\n *\n * Note: If this directory is not at the base directory level, update the contentDir field instead\n */\n contentDirName: customConfiguration?.contentDirName ?? CONTENT_DIR_NAME,\n\n /**\n * Directory name where the result will be stored\n *\n * Default: '.intlayer'\n *\n * Example:\n * - '.next'\n * - 'outputOFIntlayer'\n *\n * Note: If this directory is not at the base directory level, update the resultDir field instead\n */\n resultDirName: customConfiguration?.resultDirName ?? RESULT_DIR_NAME,\n\n /**\n *\n * Directory name where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Default: 'types'\n *\n * Example: 'intlayer-types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If this directory is not at the base directory level, update the moduleAugmentationDir field instead\n */\n moduleAugmentationDirName:\n customConfiguration?.moduleAugmentationDirName ??\n MODULE_AUGMENTATION_DIR_NAME,\n // @TODO: Make Module Augmentation optional by adding a flag in the configuration\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the dictionaries will be stored\n *\n * Default: 'dictionary'\n *\n * Example: 'translations'\n *\n * Note:\n * - If this directory is not at the result directory level, update the dictionariesDir field instead\n *\n */\n dictionariesDirName:\n customConfiguration?.dictionariesDirName ?? DICTIONARIES_DIR_NAME,\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the dictionaries will be stored\n *\n * Default: 'dictionary'\n *\n * Example: 'translations'\n *\n * Note:\n * - If this directory is not at the result directory level, update the dictionariesDir field instead\n *\n */\n i18nextResourcesDirName:\n customConfiguration?.i18nextResourcesDirName ??\n I18NEXT_DICTIONARIES_DIR_NAME,\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the dictionaries will be stored\n *\n * Default: 'react-intl_dictionary'\n *\n * Example: 'translations'\n *\n * Note:\n * - If this directory is not at the result directory level, update the dictionariesDir field instead\n *\n */\n reactIntlMessagesDirName:\n customConfiguration?.reactIntlMessagesDirName ??\n REACT_INTL_MESSAGES_DIR_NAME,\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the dictionaries types will be stored\n *\n * Default: 'types'\n *\n * Example: 'intlayer-types'\n *\n * Note:\n * - If this directory is not at the result directory level, update the typesDir field instead\n *\n */\n typeDirName: customConfiguration?.typeDirName ?? TYPES_DIR_NAME,\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the main files will be stored\n *\n * Default: 'main'\n *\n * Example: 'intlayer-main'\n *\n * Note:\n * - If this directory is not at the result directory level, update the mainDir field instead\n */\n mainDirName: customConfiguration?.mainDirName ?? MAIN_DIR_NAME,\n\n /**\n * Name of the directory where the configuration files are stored\n *\n * Default: 'config'\n *\n * Example: 'intlayer-config'\n *\n */\n configDirName: customConfiguration?.configDirName ?? CONFIG_DIR_NAME,\n\n /**\n * Should exclude some directories from the content search\n *\n * Default: ['node_modules']\n *\n * Not used yet\n * @TODO Implement the exclusion or remove it\n */\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: customConfiguration?.watch ?? WATCH,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n /**\n * Directory where the content is stored\n *\n * Relative to the base directory of the project\n *\n * Default: {{baseDir}} / {{contentDirName}}\n *\n * Example: '/path/to/project/src'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the content used in the project\n * - If the content is not at the base directory level, update the contentDirName field instead\n */\n contentDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.contentDirName\n ),\n\n /**\n * Directory where the result will be stored\n *\n * Relative to the base directory of the project\n *\n * Default: {{baseDir}} / {{resultDirName}}\n *\n * Example: '/path/to/project/.intlayer'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the intlayer application from the project\n * - If the result is not at the base directory level, update the resultDirName field instead\n */\n resultDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.resultDirName\n ),\n\n /**\n * Directory where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Relative to the base directory of the project\n *\n * Default: {{baseDir}} / {{moduleAugmentationDirName}}\n *\n * Example: '/path/to/project/types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead\n *\n */\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.moduleAugmentationDirName\n ),\n\n /**\n * Output format of the dictionary\n *\n * Default: ['intlayer']\n *\n * Note:\n * - 'i18next' is not yet ensure a 1:1 mapping with the i18next library.\n * - Removing 'intlayer' will break the compatibility with react-intlayer or next-intlayer\n */\n dictionaryOutput:\n customConfiguration?.dictionaryOutput ?? DICTIONARY_OUTPUT,\n };\n\n const resultDirDerivedConfiguration: ResultDirDerivedConfig = {\n /**\n * Directory where the dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{dictionariesDirName}}\n *\n * Example: '/path/to/project/.intlayer/dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n * - The dictionaries are stored in JSON format\n * - The dictionaries are used to translate the content\n * - The dictionaries are built from the content files\n */\n dictionariesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.dictionariesDirName\n ),\n\n /**\n * Directory where the 18n dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{i18nextResourcesDirName}}\n *\n * Example: '/path/to/project/.intlayer/dictionary/i18n'\n *\n * Note:\n * - If the types are not at the result directory level, update the i18nextResourcesDirName field instead\n */\n i18nextResourcesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.i18nextResourcesDirName\n ),\n\n /**\n * Directory where the dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{reactIntlMessagesDirName}}\n *\n * Example: '/path/to/project/.intlayer/react-intl_dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n */\n reactIntlMessagesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.reactIntlMessagesDirName\n ),\n\n /**\n * Directory where the dictionaries types will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{typeDirName}}\n *\n * Example: '/path/to/project/types'\n *\n * Note:\n * - If the types are not at the result directory level, update the typesDirName field instead\n */\n typesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.typeDirName\n ),\n\n /**\n * Directory where the main files will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{mainDirName}}\n *\n * Example: '/path/to/project/.intlayer/main'\n *\n * Note:\n *\n * - If the main files are not at the result directory level, update the mainDirName field instead\n */\n mainDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.mainDirName\n ),\n\n /**\n * Directory where the configuration files are stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{configDirName}}\n *\n * Example: '/path/to/project/.intlayer/config'\n *\n * Note:\n *\n * - If the configuration files are not at the result directory level, update the configDirName field instead\n */\n configDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.configDirName\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n /**\n * Pattern of files to watch\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n */\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n /**\n * Pattern of files to watch including the relative path\n *\n * Default: ['{{contentDir}}/**\\/*.content.ts', '{{contentDir}}/**\\/*.content.js', '{{contentDir}}/**\\/*.content.json', '{{contentDir}}/**\\/*.content.cjs', '{{contentDir}}/**\\/*.content.mjs', '{{contentDir}}/**\\/*.content.tsx', '{{contentDir}}/**\\/*.content.jsx']\n */\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.map(\n (ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`\n ),\n\n /**\n * Pattern of dictionary to interpret\n *\n * Default: '{{dictionariesDir}}/**\\/*.json'\n */\n outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...resultDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nconst buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => ({\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL ?? APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL ?? EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL ?? CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL ?? BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > 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.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > 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.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n hotReload: customConfiguration?.hotReload ?? HOT_RELOAD,\n\n /**\n * OpenAI API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n * Default: ''\n */\n openAiApiKey: customConfiguration?.openAiApiKey ?? OPEN_AI_API_KEY,\n\n /**\n * OpenAI API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Default: 'gpt-4o-2024-11-20'\n *\n * > Necessitate to define openAiApiKey to use this model\n */\n openAiApiModel: customConfiguration?.openAiApiModel ?? OPEN_AI_API_MODEL,\n\n /**\n * OpenAI API temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Default: 0.1\n */\n openAiApiTemperature:\n customConfiguration?.openAiApiTemperature ?? OPEN_AI_API_TEMPERATURE,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,qBAcO;AACP,oBAYO;AACP,kCAKO;AACP,iBAA6B;AAC7B,wBAOO;AAeP,IAAI;AAIJ,MAAM,kCAAkC,CACtC,yBACgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,SAAS,qBAAqB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzC,iBAAiB,qBAAqB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUzD,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/C,eAAe,qBAAqB,iBAAiB;AACvD;AAEA,MAAM,wBAAwB,CAC5B,yBACsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/C,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc/C,eAAe,qBAAqB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarD,UAAU,qBAAqB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3C,iBAAiB,qBAAqB,mBAAmB;AAAA;AAAA;AAAA;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B;AAAA,IACjC,qBAAqB;AAAA,EACvB;AAEA,QAAM,mBAAmB;AAAA,IACvB,qBAAqB;AAAA,EACvB;AAEA,QAAM,gBAAgB;AAAA,IACpB,qBAAqB;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,eAAe,kBAAkB,qBAAqB,MAAM;AAElE,QAAM,YAAY,eAAe,qBAAqB,GAAG;AAEzD,wBAAsB;AAAA,IACpB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport {\n CONFIG_DIR,\n CONTENT_DIR,\n DICTIONARIES_DIR,\n DICTIONARY_OUTPUT,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n I18NEXT_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REACT_INTL_MESSAGES_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n WATCH,\n} from '../defaultValues/content';\nimport {\n APPLICATION_URL,\n BACKEND_URL,\n CMS_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n EDITOR_URL,\n HOT_RELOAD,\n IS_ENABLED,\n PORT,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport type {\n AiConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n MiddlewareConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n} from '../types/config';\n\nlet storedConfiguration: IntlayerConfig;\n\n// @TODO - Add possibility of directories configurations to be arrays to allow multiple packages management\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales: customConfiguration?.requiredLocales ?? REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - 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.\n * - 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.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Header name to get the locale\n *\n * Default: 'x-intlayer-locale'\n */\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n /**\n * Cookie name to get the locale\n *\n * Default: 'intlayer-locale'\n */\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n *\n * Default: false\n */\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n /**\n * Rule to set the cookie on the server\n * - 'always': Set the cookie on every request\n * - 'never': Never set the cookie\n */\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n /**\n * No prefix in the URL\n * - true: No prefix in the URL\n * - false: Prefix in the URL\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n * - If no prefix is set, the URL will be https://example.com/en\n * - If the no prefix is set to true, the URL will be https://example.com\n *\n * Default: false\n */\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * File extensions of content to look for to build the dictionaries\n *\n * - Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * - Example: ['.data.ts', '.data.js', '.data.json']\n *\n * Note:\n * - Can exclude unused file extensions to improve performance\n * - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts\n */\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n /**\n * Absolute path of the directory of the project\n * - Default: process.cwd()\n * - Example: '\n *\n * Will be used to resolve all intlayer directories\n *\n * Note:\n * - The base directory should be the root of the project\n * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project\n */\n baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),\n\n /**\n * Should exclude some directories from the content search\n *\n * Default: ['node_modules']\n *\n * Not used yet\n * @TODO Implement the exclusion or remove it\n */\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: customConfiguration?.watch ?? WATCH,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n /**\n * Directory where the content is stored\n *\n * Relative to the base directory of the project\n *\n * Default: ./src\n *\n * Example: 'src'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the content used in the project\n * - If the content is not at the base directory level, update the contentDirName field instead\n */\n contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n (contentDir) => join(notDerivedContentConfig.baseDir, contentDir)\n ),\n\n /**\n * Directory where the result will be stored\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the intlayer application from the project\n * - If the result is not at the base directory level, update the dictionariesDirName field instead\n */\n dictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead\n *\n */\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n\n /**\n * Output format of the dictionary\n *\n * Default: ['intlayer']\n *\n * Note:\n * - 'i18next' is not yet ensure a 1:1 mapping with the i18next library.\n * - Removing 'intlayer' will break the compatibility with react-intlayer or next-intlayer\n */\n dictionaryOutput:\n customConfiguration?.dictionaryOutput ?? DICTIONARY_OUTPUT,\n };\n\n const dictionariesDirDerivedConfiguration: ResultDirDerivedConfig = {\n /**\n * Directory where the unmerged dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/unmerged_dictionary'\n *\n */\n unmergedDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the final dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer/dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n * - The dictionaries are stored in JSON format\n * - The dictionaries are used to translate the content\n * - The dictionaries are built from the content files\n */\n dictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the 18n dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: i18next_resources\n *\n * Example: '.intlayer/dictionary/i18n'\n *\n * Note:\n * - If the types are not at the result directory level, update the i18nextResourcesDirName field instead\n */\n i18nextResourcesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.i18nextResourcesDir ?? I18NEXT_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: intl_messages\n *\n * Example: '.intlayer/react-intl_dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n */\n reactIntlMessagesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.reactIntlMessagesDir ?? REACT_INTL_MESSAGES_DIR\n ),\n\n /**\n * Directory where the dictionaries types will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If the types are not at the result directory level, update the typesDirName field instead\n */\n typesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.typesDir ?? TYPES_DIR\n ),\n\n /**\n * Directory where the main files will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Example: '.intlayer/main'\n *\n * Note:\n *\n * - If the main files are not at the result directory level, update the mainDirName field instead\n */\n mainDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.mainDir ?? MAIN_DIR\n ),\n\n /**\n * Directory where the configuration files are stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Example: '.intlayer/config'\n *\n * Note:\n *\n * - If the configuration files are not at the result directory level, update the configDirName field instead\n */\n configDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n /**\n * Pattern of files to watch\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n */\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n /**\n * Pattern of files to watch including the relative path\n *\n * Default: ['src/**\\/*.content.ts', 'src/**\\/*.content.js', 'src/**\\/*.content.json', 'src/**\\/*.content.cjs', 'src/**\\/*.content.mjs', 'src/**\\/*.content.tsx', 'src/**\\/*.content.jsx']\n */\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(\n (ext) =>\n baseDirDerivedConfiguration.contentDir.map(\n (contentDir) => `${contentDir}/**/*${ext}`\n )\n ),\n\n /**\n * Pattern of dictionary to interpret\n *\n * Default: '.intlayer/dictionary/**\\/*.json'\n */\n outputFilesPatternWithPath: `${dictionariesDirDerivedConfiguration.dictionariesDir}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...dictionariesDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nconst buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => ({\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL ?? APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL ?? EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL ?? CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL ?? BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > 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.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > 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.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n hotReload: customConfiguration?.hotReload ?? HOT_RELOAD,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n});\n\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n */\n applicationContext: customConfiguration?.applicationContext,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log);\n\n const aiConfig = buildAiFields(customConfiguration?.ai);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,qBAcO;AACP,oBASO;AACP,kCAKO;AACP,iBAA6B;AAC7B,wBAOO;AAgBP,IAAI;AAIJ,MAAM,kCAAkC,CACtC,yBACgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,SAAS,qBAAqB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzC,iBAAiB,qBAAqB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUzD,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/C,eAAe,qBAAqB,iBAAiB;AACvD;AAEA,MAAM,wBAAwB,CAC5B,yBACsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/C,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc/C,eAAe,qBAAqB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarD,UAAU,qBAAqB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3C,iBAAiB,qBAAqB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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