@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.
Files changed (66) hide show
  1. package/dist/cjs/configFile/buildConfigurationFields.cjs +85 -196
  2. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  3. package/dist/cjs/defaultValues/content.cjs +27 -27
  4. package/dist/cjs/defaultValues/content.cjs.map +1 -1
  5. package/dist/cjs/defaultValues/editor.cjs +0 -9
  6. package/dist/cjs/defaultValues/editor.cjs.map +1 -1
  7. package/dist/cjs/envVariables/extractEnvVariable/next.cjs +14 -18
  8. package/dist/cjs/envVariables/extractEnvVariable/next.cjs.map +1 -1
  9. package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs +12 -16
  10. package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs.map +1 -1
  11. package/dist/cjs/envVariables/extractEnvVariable/types.cjs.map +1 -1
  12. package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs +12 -16
  13. package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs.map +1 -1
  14. package/dist/cjs/envVariables/extractEnvVariable/vite.cjs +12 -16
  15. package/dist/cjs/envVariables/extractEnvVariable/vite.cjs.map +1 -1
  16. package/dist/cjs/envVariables/getConfiguration.cjs +13 -30
  17. package/dist/cjs/envVariables/getConfiguration.cjs.map +1 -1
  18. package/dist/cjs/index.cjs +9 -6
  19. package/dist/cjs/index.cjs.map +1 -1
  20. package/dist/cjs/logger.cjs +6 -5
  21. package/dist/cjs/logger.cjs.map +1 -1
  22. package/dist/cjs/retryManager.cjs +52 -0
  23. package/dist/cjs/retryManager.cjs.map +1 -0
  24. package/dist/cjs/types/config.cjs.map +1 -1
  25. package/dist/esm/configFile/buildConfigurationFields.mjs +101 -215
  26. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  27. package/dist/esm/defaultValues/content.mjs +18 -18
  28. package/dist/esm/defaultValues/content.mjs.map +1 -1
  29. package/dist/esm/defaultValues/editor.mjs +0 -6
  30. package/dist/esm/defaultValues/editor.mjs.map +1 -1
  31. package/dist/esm/envVariables/extractEnvVariable/next.mjs +14 -18
  32. package/dist/esm/envVariables/extractEnvVariable/next.mjs.map +1 -1
  33. package/dist/esm/envVariables/extractEnvVariable/react_app.mjs +12 -16
  34. package/dist/esm/envVariables/extractEnvVariable/react_app.mjs.map +1 -1
  35. package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs +12 -16
  36. package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs.map +1 -1
  37. package/dist/esm/envVariables/extractEnvVariable/vite.mjs +12 -16
  38. package/dist/esm/envVariables/extractEnvVariable/vite.mjs.map +1 -1
  39. package/dist/esm/envVariables/getConfiguration.mjs +13 -30
  40. package/dist/esm/envVariables/getConfiguration.mjs.map +1 -1
  41. package/dist/esm/index.mjs +9 -7
  42. package/dist/esm/index.mjs.map +1 -1
  43. package/dist/esm/logger.mjs +6 -5
  44. package/dist/esm/logger.mjs.map +1 -1
  45. package/dist/esm/retryManager.mjs +28 -0
  46. package/dist/esm/retryManager.mjs.map +1 -0
  47. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  48. package/dist/types/defaultValues/content.d.ts +9 -9
  49. package/dist/types/defaultValues/content.d.ts.map +1 -1
  50. package/dist/types/defaultValues/editor.d.ts +0 -3
  51. package/dist/types/defaultValues/editor.d.ts.map +1 -1
  52. package/dist/types/envVariables/extractEnvVariable/next.d.ts.map +1 -1
  53. package/dist/types/envVariables/extractEnvVariable/react_app.d.ts.map +1 -1
  54. package/dist/types/envVariables/extractEnvVariable/types.d.ts +1 -1
  55. package/dist/types/envVariables/extractEnvVariable/types.d.ts.map +1 -1
  56. package/dist/types/envVariables/extractEnvVariable/undefined_platform.d.ts.map +1 -1
  57. package/dist/types/envVariables/extractEnvVariable/vite.d.ts.map +1 -1
  58. package/dist/types/envVariables/getConfiguration.d.ts.map +1 -1
  59. package/dist/types/index.d.ts +8 -7
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/types/logger.d.ts.map +1 -1
  62. package/dist/types/retryManager.d.ts +17 -0
  63. package/dist/types/retryManager.d.ts.map +1 -0
  64. package/dist/types/types/config.d.ts +64 -106
  65. package/dist/types/types/config.d.ts.map +1 -1
  66. package/package.json +5 -5
@@ -1,31 +1,28 @@
1
1
  import { join } from "path";
2
2
  import {
3
- CONTENT_DIR_NAME,
4
- DICTIONARIES_DIR_NAME,
5
- FILE_EXTENSIONS,
6
- RESULT_DIR_NAME,
7
- EXCLUDED_PATHS,
8
- TYPES_DIR_NAME,
9
- MAIN_DIR_NAME,
10
- MODULE_AUGMENTATION_DIR_NAME,
11
- I18NEXT_DICTIONARIES_DIR_NAME,
3
+ CONFIG_DIR,
4
+ CONTENT_DIR,
5
+ DICTIONARIES_DIR,
12
6
  DICTIONARY_OUTPUT,
13
- WATCH,
14
- REACT_INTL_MESSAGES_DIR_NAME,
15
- CONFIG_DIR_NAME
7
+ EXCLUDED_PATHS,
8
+ FILE_EXTENSIONS,
9
+ I18NEXT_DICTIONARIES_DIR,
10
+ MAIN_DIR,
11
+ MODULE_AUGMENTATION_DIR,
12
+ REACT_INTL_MESSAGES_DIR,
13
+ TYPES_DIR,
14
+ UNMERGED_DICTIONARIES_DIR,
15
+ WATCH
16
16
  } from "../defaultValues/content.mjs";
17
17
  import {
18
18
  APPLICATION_URL,
19
- EDITOR_URL,
20
- CMS_URL,
21
19
  BACKEND_URL,
20
+ CMS_URL,
22
21
  DICTIONARY_PRIORITY_STRATEGY,
23
- IS_ENABLED,
24
- PORT,
22
+ EDITOR_URL,
25
23
  HOT_RELOAD,
26
- OPEN_AI_API_KEY,
27
- OPEN_AI_API_MODEL,
28
- OPEN_AI_API_TEMPERATURE
24
+ IS_ENABLED,
25
+ PORT
29
26
  } from "../defaultValues/editor.mjs";
30
27
  import {
31
28
  DEFAULT_LOCALE,
@@ -155,7 +152,7 @@ const buildContentFields = (customConfiguration, baseDir) => {
155
152
  /**
156
153
  * Absolute path of the directory of the project
157
154
  * - Default: process.cwd()
158
- * - Example: '/path/to/project'
155
+ * - Example: '
159
156
  *
160
157
  * Will be used to resolve all intlayer directories
161
158
  *
@@ -164,125 +161,6 @@ const buildContentFields = (customConfiguration, baseDir) => {
164
161
  * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project
165
162
  */
166
163
  baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),
167
- /**
168
- * Directory name where the content is stored
169
- *
170
- * Default: 'src'
171
- *
172
- * Example:
173
- * - 'data' -> '/path/to/project/data'
174
- * - 'content' -> '/path/to/project/content'
175
- * - 'locales' -> '/path/to/project/locales'
176
- *
177
- * Note: If this directory is not at the base directory level, update the contentDir field instead
178
- */
179
- contentDirName: customConfiguration?.contentDirName ?? CONTENT_DIR_NAME,
180
- /**
181
- * Directory name where the result will be stored
182
- *
183
- * Default: '.intlayer'
184
- *
185
- * Example:
186
- * - '.next'
187
- * - 'outputOFIntlayer'
188
- *
189
- * Note: If this directory is not at the base directory level, update the resultDir field instead
190
- */
191
- resultDirName: customConfiguration?.resultDirName ?? RESULT_DIR_NAME,
192
- /**
193
- *
194
- * Directory name where the module augmentation will be stored
195
- *
196
- * Module augmentation allow better IDE suggestions and type checking
197
- *
198
- * Default: 'types'
199
- *
200
- * Example: 'intlayer-types'
201
- *
202
- * Note:
203
- * - If this path changed, be sure to include it from the tsconfig.json file
204
- * - If this directory is not at the base directory level, update the moduleAugmentationDir field instead
205
- */
206
- moduleAugmentationDirName: customConfiguration?.moduleAugmentationDirName ?? MODULE_AUGMENTATION_DIR_NAME,
207
- // @TODO: Make Module Augmentation optional by adding a flag in the configuration
208
- /**
209
- * Related to the intlayer result directory
210
- *
211
- * Directory name where the dictionaries will be stored
212
- *
213
- * Default: 'dictionary'
214
- *
215
- * Example: 'translations'
216
- *
217
- * Note:
218
- * - If this directory is not at the result directory level, update the dictionariesDir field instead
219
- *
220
- */
221
- dictionariesDirName: customConfiguration?.dictionariesDirName ?? DICTIONARIES_DIR_NAME,
222
- /**
223
- * Related to the intlayer result directory
224
- *
225
- * Directory name where the dictionaries will be stored
226
- *
227
- * Default: 'dictionary'
228
- *
229
- * Example: 'translations'
230
- *
231
- * Note:
232
- * - If this directory is not at the result directory level, update the dictionariesDir field instead
233
- *
234
- */
235
- i18nextResourcesDirName: customConfiguration?.i18nextResourcesDirName ?? I18NEXT_DICTIONARIES_DIR_NAME,
236
- /**
237
- * Related to the intlayer result directory
238
- *
239
- * Directory name where the dictionaries will be stored
240
- *
241
- * Default: 'react-intl_dictionary'
242
- *
243
- * Example: 'translations'
244
- *
245
- * Note:
246
- * - If this directory is not at the result directory level, update the dictionariesDir field instead
247
- *
248
- */
249
- reactIntlMessagesDirName: customConfiguration?.reactIntlMessagesDirName ?? REACT_INTL_MESSAGES_DIR_NAME,
250
- /**
251
- * Related to the intlayer result directory
252
- *
253
- * Directory name where the dictionaries types will be stored
254
- *
255
- * Default: 'types'
256
- *
257
- * Example: 'intlayer-types'
258
- *
259
- * Note:
260
- * - If this directory is not at the result directory level, update the typesDir field instead
261
- *
262
- */
263
- typeDirName: customConfiguration?.typeDirName ?? TYPES_DIR_NAME,
264
- /**
265
- * Related to the intlayer result directory
266
- *
267
- * Directory name where the main files will be stored
268
- *
269
- * Default: 'main'
270
- *
271
- * Example: 'intlayer-main'
272
- *
273
- * Note:
274
- * - If this directory is not at the result directory level, update the mainDir field instead
275
- */
276
- mainDirName: customConfiguration?.mainDirName ?? MAIN_DIR_NAME,
277
- /**
278
- * Name of the directory where the configuration files are stored
279
- *
280
- * Default: 'config'
281
- *
282
- * Example: 'intlayer-config'
283
- *
284
- */
285
- configDirName: customConfiguration?.configDirName ?? CONFIG_DIR_NAME,
286
164
  /**
287
165
  * Should exclude some directories from the content search
288
166
  *
@@ -305,34 +183,33 @@ const buildContentFields = (customConfiguration, baseDir) => {
305
183
  *
306
184
  * Relative to the base directory of the project
307
185
  *
308
- * Default: {{baseDir}} / {{contentDirName}}
186
+ * Default: ./src
309
187
  *
310
- * Example: '/path/to/project/src'
188
+ * Example: 'src'
311
189
  *
312
190
  * Note:
313
191
  * - Can be changed to a custom directory to externalize the content used in the project
314
192
  * - If the content is not at the base directory level, update the contentDirName field instead
315
193
  */
316
- contentDir: join(
317
- notDerivedContentConfig.baseDir,
318
- notDerivedContentConfig.contentDirName
194
+ contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map(
195
+ (contentDir) => join(notDerivedContentConfig.baseDir, contentDir)
319
196
  ),
320
197
  /**
321
198
  * Directory where the result will be stored
322
199
  *
323
200
  * Relative to the base directory of the project
324
201
  *
325
- * Default: {{baseDir}} / {{resultDirName}}
202
+ * Default: .intlayer/dictionary
326
203
  *
327
- * Example: '/path/to/project/.intlayer'
204
+ * Example: '.intlayer'
328
205
  *
329
206
  * Note:
330
207
  * - Can be changed to a custom directory to externalize the intlayer application from the project
331
- * - If the result is not at the base directory level, update the resultDirName field instead
208
+ * - If the result is not at the base directory level, update the dictionariesDirName field instead
332
209
  */
333
- resultDir: join(
210
+ dictionariesDir: join(
334
211
  notDerivedContentConfig.baseDir,
335
- notDerivedContentConfig.resultDirName
212
+ customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR
336
213
  ),
337
214
  /**
338
215
  * Directory where the module augmentation will be stored
@@ -341,9 +218,9 @@ const buildContentFields = (customConfiguration, baseDir) => {
341
218
  *
342
219
  * Relative to the base directory of the project
343
220
  *
344
- * Default: {{baseDir}} / {{moduleAugmentationDirName}}
221
+ * Default: .intlayer/types
345
222
  *
346
- * Example: '/path/to/project/types'
223
+ * Example: 'types'
347
224
  *
348
225
  * Note:
349
226
  * - If this path changed, be sure to include it from the tsconfig.json file
@@ -352,7 +229,7 @@ const buildContentFields = (customConfiguration, baseDir) => {
352
229
  */
353
230
  moduleAugmentationDir: join(
354
231
  notDerivedContentConfig.baseDir,
355
- notDerivedContentConfig.moduleAugmentationDirName
232
+ customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR
356
233
  ),
357
234
  /**
358
235
  * Output format of the dictionary
@@ -365,15 +242,27 @@ const buildContentFields = (customConfiguration, baseDir) => {
365
242
  */
366
243
  dictionaryOutput: customConfiguration?.dictionaryOutput ?? DICTIONARY_OUTPUT
367
244
  };
368
- const resultDirDerivedConfiguration = {
245
+ const dictionariesDirDerivedConfiguration = {
369
246
  /**
370
- * Directory where the dictionaries will be stored
247
+ * Directory where the unmerged dictionaries will be stored
248
+ *
249
+ * Relative to the result directory
250
+ *
251
+ * Default: '.intlayer/unmerged_dictionary'
252
+ *
253
+ */
254
+ unmergedDictionariesDir: join(
255
+ notDerivedContentConfig.baseDir,
256
+ customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR
257
+ ),
258
+ /**
259
+ * Directory where the final dictionaries will be stored
371
260
  *
372
261
  * Relative to the result directory
373
262
  *
374
- * Default: {{resultDir}} / {{dictionariesDirName}}
263
+ * Default: .intlayer/dictionary
375
264
  *
376
- * Example: '/path/to/project/.intlayer/dictionary'
265
+ * Example: '.intlayer/dictionary'
377
266
  *
378
267
  * Note:
379
268
  * - If the types are not at the result directory level, update the dictionariesDirName field instead
@@ -382,90 +271,90 @@ const buildContentFields = (customConfiguration, baseDir) => {
382
271
  * - The dictionaries are built from the content files
383
272
  */
384
273
  dictionariesDir: join(
385
- baseDirDerivedConfiguration.resultDir,
386
- notDerivedContentConfig.dictionariesDirName
274
+ notDerivedContentConfig.baseDir,
275
+ customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR
387
276
  ),
388
277
  /**
389
278
  * Directory where the 18n dictionaries will be stored
390
279
  *
391
280
  * Relative to the result directory
392
281
  *
393
- * Default: {{resultDir}} / {{i18nextResourcesDirName}}
282
+ * Default: i18next_resources
394
283
  *
395
- * Example: '/path/to/project/.intlayer/dictionary/i18n'
284
+ * Example: '.intlayer/dictionary/i18n'
396
285
  *
397
286
  * Note:
398
287
  * - If the types are not at the result directory level, update the i18nextResourcesDirName field instead
399
288
  */
400
289
  i18nextResourcesDir: join(
401
- baseDirDerivedConfiguration.resultDir,
402
- notDerivedContentConfig.i18nextResourcesDirName
290
+ notDerivedContentConfig.baseDir,
291
+ customConfiguration?.i18nextResourcesDir ?? I18NEXT_DICTIONARIES_DIR
403
292
  ),
404
293
  /**
405
294
  * Directory where the dictionaries will be stored
406
295
  *
407
296
  * Relative to the result directory
408
297
  *
409
- * Default: {{resultDir}} / {{reactIntlMessagesDirName}}
298
+ * Default: intl_messages
410
299
  *
411
- * Example: '/path/to/project/.intlayer/react-intl_dictionary'
300
+ * Example: '.intlayer/react-intl_dictionary'
412
301
  *
413
302
  * Note:
414
303
  * - If the types are not at the result directory level, update the dictionariesDirName field instead
415
304
  */
416
305
  reactIntlMessagesDir: join(
417
- baseDirDerivedConfiguration.resultDir,
418
- notDerivedContentConfig.reactIntlMessagesDirName
306
+ notDerivedContentConfig.baseDir,
307
+ customConfiguration?.reactIntlMessagesDir ?? REACT_INTL_MESSAGES_DIR
419
308
  ),
420
309
  /**
421
310
  * Directory where the dictionaries types will be stored
422
311
  *
423
312
  * Relative to the result directory
424
313
  *
425
- * Default: {{resultDir}} / {{typeDirName}}
314
+ * Default: .intlayer/types
426
315
  *
427
- * Example: '/path/to/project/types'
316
+ * Example: 'types'
428
317
  *
429
318
  * Note:
430
319
  * - If the types are not at the result directory level, update the typesDirName field instead
431
320
  */
432
321
  typesDir: join(
433
- baseDirDerivedConfiguration.resultDir,
434
- notDerivedContentConfig.typeDirName
322
+ notDerivedContentConfig.baseDir,
323
+ customConfiguration?.typesDir ?? TYPES_DIR
435
324
  ),
436
325
  /**
437
326
  * Directory where the main files will be stored
438
327
  *
439
328
  * Relative to the result directory
440
329
  *
441
- * Default: {{resultDir}} / {{mainDirName}}
330
+ * Default: .intlayer/main
442
331
  *
443
- * Example: '/path/to/project/.intlayer/main'
332
+ * Example: '.intlayer/main'
444
333
  *
445
334
  * Note:
446
335
  *
447
336
  * - If the main files are not at the result directory level, update the mainDirName field instead
448
337
  */
449
338
  mainDir: join(
450
- baseDirDerivedConfiguration.resultDir,
451
- notDerivedContentConfig.mainDirName
339
+ notDerivedContentConfig.baseDir,
340
+ customConfiguration?.mainDir ?? MAIN_DIR
452
341
  ),
453
342
  /**
454
343
  * Directory where the configuration files are stored
455
344
  *
456
345
  * Relative to the result directory
457
346
  *
458
- * Default: {{resultDir}} / {{configDirName}}
347
+ * Default: .intlayer/config
459
348
  *
460
- * Example: '/path/to/project/.intlayer/config'
349
+ * Example: '.intlayer/config'
461
350
  *
462
351
  * Note:
463
352
  *
464
353
  * - If the configuration files are not at the result directory level, update the configDirName field instead
465
354
  */
466
355
  configDir: join(
467
- baseDirDerivedConfiguration.resultDir,
468
- notDerivedContentConfig.configDirName
356
+ notDerivedContentConfig.baseDir,
357
+ customConfiguration?.configDir ?? CONFIG_DIR
469
358
  )
470
359
  };
471
360
  const patternsConfiguration = {
@@ -480,22 +369,24 @@ const buildContentFields = (customConfiguration, baseDir) => {
480
369
  /**
481
370
  * Pattern of files to watch including the relative path
482
371
  *
483
- * Default: ['{{contentDir}}/**\/*.content.ts', '{{contentDir}}/**\/*.content.js', '{{contentDir}}/**\/*.content.json', '{{contentDir}}/**\/*.content.cjs', '{{contentDir}}/**\/*.content.mjs', '{{contentDir}}/**\/*.content.tsx', '{{contentDir}}/**\/*.content.jsx']
372
+ * Default: ['src/**\/*.content.ts', 'src/**\/*.content.js', 'src/**\/*.content.json', 'src/**\/*.content.cjs', 'src/**\/*.content.mjs', 'src/**\/*.content.tsx', 'src/**\/*.content.jsx']
484
373
  */
485
- watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.map(
486
- (ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`
374
+ watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(
375
+ (ext) => baseDirDerivedConfiguration.contentDir.map(
376
+ (contentDir) => `${contentDir}/**/*${ext}`
377
+ )
487
378
  ),
488
379
  /**
489
380
  * Pattern of dictionary to interpret
490
381
  *
491
- * Default: '{{dictionariesDir}}/**\/*.json'
382
+ * Default: '.intlayer/dictionary/**\/*.json'
492
383
  */
493
- outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`
384
+ outputFilesPatternWithPath: `${dictionariesDirDerivedConfiguration.dictionariesDir}/**/*.json`
494
385
  };
495
386
  return {
496
387
  ...notDerivedContentConfig,
497
388
  ...baseDirDerivedConfiguration,
498
- ...resultDirDerivedConfiguration,
389
+ ...dictionariesDirDerivedConfiguration,
499
390
  ...patternsConfiguration
500
391
  };
501
392
  };
@@ -591,36 +482,7 @@ const buildEditorFields = (customConfiguration) => ({
591
482
  *
592
483
  * Default: false
593
484
  */
594
- hotReload: customConfiguration?.hotReload ?? HOT_RELOAD,
595
- /**
596
- * OpenAI API key
597
- *
598
- * Use your own OpenAI API key to use the AI features of Intlayer.
599
- * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.
600
- *
601
- * Default: ''
602
- */
603
- openAiApiKey: customConfiguration?.openAiApiKey ?? OPEN_AI_API_KEY,
604
- /**
605
- * OpenAI API model
606
- *
607
- * The model to use for the AI features of Intlayer.
608
- *
609
- * Default: 'gpt-4o-2024-11-20'
610
- *
611
- * > Necessitate to define openAiApiKey to use this model
612
- */
613
- openAiApiModel: customConfiguration?.openAiApiModel ?? OPEN_AI_API_MODEL,
614
- /**
615
- * OpenAI API temperature
616
- *
617
- * The temperature to use for the AI features of Intlayer.
618
- * The temperature controls the randomness of the AI's responses.
619
- * A higher temperature will make the AI more creative and less predictable.
620
- *
621
- * Default: 0.1
622
- */
623
- openAiApiTemperature: customConfiguration?.openAiApiTemperature ?? OPEN_AI_API_TEMPERATURE
485
+ hotReload: customConfiguration?.hotReload ?? HOT_RELOAD
624
486
  });
625
487
  const buildLogFields = (customConfiguration) => ({
626
488
  /**
@@ -642,6 +504,28 @@ const buildLogFields = (customConfiguration) => ({
642
504
  */
643
505
  prefix: customConfiguration?.prefix ?? PREFIX
644
506
  });
507
+ const buildAiFields = (customConfiguration) => ({
508
+ /**
509
+ * AI configuration
510
+ */
511
+ provider: customConfiguration?.provider,
512
+ /**
513
+ * API key
514
+ */
515
+ apiKey: customConfiguration?.apiKey,
516
+ /**
517
+ * API model
518
+ */
519
+ model: customConfiguration?.model,
520
+ /**
521
+ * Temperature
522
+ */
523
+ temperature: customConfiguration?.temperature,
524
+ /**
525
+ * Application context
526
+ */
527
+ applicationContext: customConfiguration?.applicationContext
528
+ });
645
529
  const buildConfigurationFields = (customConfiguration, baseDir) => {
646
530
  const internationalizationConfig = buildInternationalizationFields(
647
531
  customConfiguration?.internationalization
@@ -655,12 +539,14 @@ const buildConfigurationFields = (customConfiguration, baseDir) => {
655
539
  );
656
540
  const editorConfig = buildEditorFields(customConfiguration?.editor);
657
541
  const logConfig = buildLogFields(customConfiguration?.log);
542
+ const aiConfig = buildAiFields(customConfiguration?.ai);
658
543
  storedConfiguration = {
659
544
  internationalization: internationalizationConfig,
660
545
  middleware: middlewareConfig,
661
546
  content: contentConfig,
662
547
  editor: editorConfig,
663
- log: logConfig
548
+ log: logConfig,
549
+ ai: aiConfig
664
550
  };
665
551
  return storedConfiguration;
666
552
  };
@@ -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,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,cAAc;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;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;AAA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A,EAUf,MAAM,qBAAqB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnC,QAAQ,qBAAqB,UAAU;AACzC;AAKO,MAAM,2BAA2B,CACtC,qBACA,YACmB;AACnB,QAAM,6BAA6B;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,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,cAAc;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;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;A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