@intlayer/chokidar 6.0.0-canary.3 → 6.0.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/chokidar/watcher.cjs +4 -4
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +3 -25
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +19 -21
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +13 -4
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +47 -12
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +52 -9
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +5 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +3 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/buildIntlayerDictionary.cjs +3 -3
- package/dist/cjs/transpiler/intlayer_dictionary/buildIntlayerDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/index.cjs +3 -3
- package/dist/cjs/transpiler/intlayer_dictionary/index.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/processContentDeclaration.cjs +1 -1
- package/dist/cjs/transpiler/intlayer_dictionary/processContentDeclaration.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeDynamicDictionary.cjs +19 -10
- package/dist/cjs/transpiler/intlayer_dictionary/writeDynamicDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeFetchDictionary.cjs +9 -3
- package/dist/cjs/transpiler/intlayer_dictionary/writeFetchDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeMergedDictionary.cjs +12 -8
- package/dist/cjs/transpiler/intlayer_dictionary/writeMergedDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeRemoteDictionary.cjs +9 -7
- package/dist/cjs/transpiler/intlayer_dictionary/writeRemoteDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeUnmergedDictionary.cjs +12 -8
- package/dist/cjs/transpiler/intlayer_dictionary/writeUnmergedDictionary.cjs.map +1 -0
- package/dist/cjs/writeConfiguration/index.cjs +5 -6
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -5
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +46 -0
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -0
- package/dist/cjs/{transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.cjs → writeJsonIfChanged.cjs} +11 -14
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -0
- package/dist/esm/chokidar/watcher.mjs +1 -1
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +5 -32
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +19 -21
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +14 -5
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +50 -13
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +53 -8
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +6 -2
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +4 -2
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/buildIntlayerDictionary.mjs +2 -2
- package/dist/esm/transpiler/intlayer_dictionary/buildIntlayerDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/index.mjs +1 -1
- package/dist/esm/transpiler/intlayer_dictionary/index.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/processContentDeclaration.mjs +1 -1
- package/dist/esm/transpiler/intlayer_dictionary/processContentDeclaration.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeDynamicDictionary.mjs +25 -12
- package/dist/esm/transpiler/intlayer_dictionary/writeDynamicDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeFetchDictionary.mjs +15 -5
- package/dist/esm/transpiler/intlayer_dictionary/writeFetchDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeMergedDictionary.mjs +14 -10
- package/dist/esm/transpiler/intlayer_dictionary/writeMergedDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeRemoteDictionary.mjs +11 -9
- package/dist/esm/transpiler/intlayer_dictionary/writeRemoteDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeUnmergedDictionary.mjs +14 -10
- package/dist/esm/transpiler/intlayer_dictionary/writeUnmergedDictionary.mjs.map +1 -0
- package/dist/esm/writeConfiguration/index.mjs +5 -6
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -5
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +22 -0
- package/dist/esm/writeFileIfChanged.mjs.map +1 -0
- package/dist/esm/writeJsonIfChanged.mjs +10 -0
- package/dist/esm/writeJsonIfChanged.mjs.map +1 -0
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +4 -0
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +5 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/log.d.ts +7 -0
- package/dist/types/loadDictionaries/log.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +1 -1
- package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/buildIntlayerDictionary.d.ts +1 -1
- package/dist/types/transpiler/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/index.d.ts +1 -1
- package/dist/types/transpiler/intlayer_dictionary/index.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/processContentDeclaration.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeDynamicDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeFetchDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeMergedDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeRemoteDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +1 -0
- package/dist/types/writeConfiguration/index.d.ts +1 -1
- package/dist/types/writeConfiguration/index.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeFileIfChanged.d.ts +4 -0
- package/dist/types/writeFileIfChanged.d.ts.map +1 -0
- package/dist/types/writeJsonIfChanged.d.ts +4 -0
- package/dist/types/writeJsonIfChanged.d.ts.map +1 -0
- package/package.json +15 -15
- package/dist/cjs/fetchDistantDictionaryKeysAndUpdateTimestamp.cjs +0 -45
- package/dist/cjs/fetchDistantDictionaryKeysAndUpdateTimestamp.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs +0 -46
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.cjs +0 -103
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.cjs +0 -23
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs +0 -51
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs +0 -40
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs +0 -30
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs +0 -52
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs.map +0 -1
- package/dist/esm/fetchDistantDictionaryKeysAndUpdateTimestamp.mjs +0 -21
- package/dist/esm/fetchDistantDictionaryKeysAndUpdateTimestamp.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs +0 -24
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.mjs +0 -81
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.mjs +0 -13
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.mjs +0 -2
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs +0 -27
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs +0 -16
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs +0 -6
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs +0 -28
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs.map +0 -1
- package/dist/types/fetchDistantDictionaryKeysAndUpdateTimestamp.d.ts +0 -3
- package/dist/types/fetchDistantDictionaryKeysAndUpdateTimestamp.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts +0 -6
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.d.ts +0 -7
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts +0 -7
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts +0 -8
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts +0 -7
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts.map +0 -1
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/processContentDeclaration.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeDynamicDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeFetchDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeMergedDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeRemoteDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeUnmergedDictionary.d.ts +0 -0
|
@@ -35,7 +35,6 @@ var import_built = __toESM(require("@intlayer/config/built"));
|
|
|
35
35
|
var import_client = require("@intlayer/config/client");
|
|
36
36
|
var import_unmerged_dictionaries_entry = __toESM(require("@intlayer/unmerged-dictionaries-entry"));
|
|
37
37
|
var import_deep_equal = __toESM(require("deep-equal"));
|
|
38
|
-
var import_fs = require("fs");
|
|
39
38
|
var import_promises = require("fs/promises");
|
|
40
39
|
var import_path = require("path");
|
|
41
40
|
var import_prepareContentDeclaration = require('../prepareContentDeclaration.cjs');
|
|
@@ -95,10 +94,7 @@ const writeContentDeclaration = async (dictionary, config = import_built.default
|
|
|
95
94
|
const writeFileWithDirectories = async (filePath, data) => {
|
|
96
95
|
try {
|
|
97
96
|
const dir = (0, import_path.dirname)(filePath);
|
|
98
|
-
|
|
99
|
-
if (!directoryExists) {
|
|
100
|
-
await (0, import_promises.mkdir)(dir, { recursive: true });
|
|
101
|
-
}
|
|
97
|
+
await (0, import_promises.mkdir)(dir, { recursive: true });
|
|
102
98
|
const extention = (0, import_path.extname)(filePath);
|
|
103
99
|
const acceptedExtensions = import_built.default.content.fileExtensions.map(
|
|
104
100
|
(extention2) => (0, import_path.extname)(extention2)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizePath, x, type IntlayerConfig } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/unmerged-dictionaries-entry';\nimport deepEqual from 'deep-equal';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizePath, x, type IntlayerConfig } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/unmerged-dictionaries-entry';\nimport deepEqual from 'deep-equal';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { dirname, extname } from 'path';\nimport { prepareContentDeclaration } from '../prepareContentDeclaration';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { writeJSFile } from './writeJSFile';\n\nconst DEFAULT_NEW_DICTIONARY_PATH = 'intlayer-dictionaries';\n\nconst formatContentDeclaration = async (dictionary: Dictionary) => {\n // Clean Markdown, Insertion, File, etc. node metadata\n const preparedContentDeclaration =\n await prepareContentDeclaration(dictionary);\n\n // Remove the filePath from the dictionary and set $schema\n const { filePath, $schema, ...dictionaryWithoutPath } =\n preparedContentDeclaration;\n\n const formattedContentDeclaration = {\n $schema: 'https://intlayer.org/schema.json',\n ...dictionaryWithoutPath,\n };\n\n return formattedContentDeclaration;\n};\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n config: IntlayerConfig = configuration,\n newDictionariesPath?: string\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = config;\n const { baseDir } = content;\n\n const newDictionaryRelativeLocationPath =\n newDictionariesPath ?? DEFAULT_NEW_DICTIONARY_PATH;\n const newDictionaryLocationPath = `${baseDir}/${newDictionaryRelativeLocationPath}`;\n\n const existingDictionary = (\n dictionariesRecord[dictionary.key] as Dictionary[]\n ).filter((el) => el.filePath === dictionary.filePath);\n\n const filePath = dictionary.filePath;\n const formattedContentDeclaration =\n await formatContentDeclaration(dictionary);\n\n if (existingDictionary) {\n // Compare existing dictionary with distant dictionary\n if (deepEqual(existingDictionary, dictionary)) {\n // Up to date, nothing to do\n return {\n status: 'up-to-date',\n path: filePath!,\n };\n } else {\n if (filePath) {\n await writeFileWithDirectories(filePath, formattedContentDeclaration);\n\n return { status: 'updated', path: filePath };\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const contentDeclarationPath = `${newDictionaryLocationPath}/${dictionary.key}.content.json`;\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration\n );\n\n return {\n status: 'new content file',\n path: contentDeclarationPath,\n };\n }\n }\n } else {\n // No existing dictionary, write to new location\n const contentDeclarationPath = `${newDictionaryLocationPath}/${dictionary.key}.content.json`;\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n }\n};\n\nconst writeFileWithDirectories = async (\n filePath: string,\n data: string | Buffer\n): Promise<void> => {\n try {\n // Extract the directory from the file path\n const dir = dirname(filePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extention = extname(filePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extention) => extname(extention)\n );\n\n if (!acceptedExtensions.includes(extention)) {\n throw new Error(\n `Invalid file extension: ${extention}, file: ${filePath}`\n );\n }\n\n if (extention === '.json') {\n const jsonDictionary = JSON.stringify(data, null, 2);\n\n // Write the file\n await writeFile(filePath, jsonDictionary);\n } else {\n await writeJSFile(filePath, data as unknown as Dictionary);\n }\n } catch (error) {\n console.error(data);\n\n throw new Error(\n `${x} Error writing file to ${colorizePath(filePath)}: ${error}`\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,oBAAqD;AAErD,yCAA+B;AAC/B,wBAAsB;AACtB,sBAAiC;AACjC,kBAAiC;AACjC,uCAA0C;AAE1C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;AAEA,MAAM,2BAA2B,OAC/B,UACA,SACkB;AAClB,MAAI;AAEF,UAAM,UAAM,qBAAQ,QAAQ;AAG5B,cAAM,uBAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAEpC,UAAM,gBAAY,qBAAQ,QAAQ;AAClC,UAAM,qBAAqB,aAAAF,QAAc,QAAQ,eAAe;AAAA,MAC9D,CAACG,mBAAc,qBAAQA,UAAS;AAAA,IAClC;AAEA,QAAI,CAAC,mBAAmB,SAAS,SAAS,GAAG;AAC3C,YAAM,IAAI;AAAA,QACR,2BAA2B,SAAS,WAAW,QAAQ;AAAA,MACzD;AAAA,IACF;AAEA,QAAI,cAAc,SAAS;AACzB,YAAM,iBAAiB,KAAK,UAAU,MAAM,MAAM,CAAC;AAGnD,gBAAM,2BAAU,UAAU,cAAc;AAAA,IAC1C,OAAO;AACL,gBAAM,gCAAY,UAAU,IAA6B;AAAA,IAC3D;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,IAAI;AAElB,UAAM,IAAI;AAAA,MACR,GAAG,eAAC,8BAA0B,4BAAa,QAAQ,CAAC,KAAK,KAAK;AAAA,IAChE;AAAA,EACF;AACF;","names":["configuration","dictionariesRecord","deepEqual","extention"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var writeFileIfChanged_exports = {};
|
|
20
|
+
__export(writeFileIfChanged_exports, {
|
|
21
|
+
writeFileIfChanged: () => writeFileIfChanged
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(writeFileIfChanged_exports);
|
|
24
|
+
var import_node_crypto = require("node:crypto");
|
|
25
|
+
var import_node_fs = require("node:fs");
|
|
26
|
+
var import_promises = require("node:fs/promises");
|
|
27
|
+
const hashFile = async (path) => {
|
|
28
|
+
const h = (0, import_node_crypto.createHash)("sha256");
|
|
29
|
+
const rs = (0, import_node_fs.createReadStream)(path);
|
|
30
|
+
rs.on("data", (chunk) => h.update(chunk));
|
|
31
|
+
await new Promise((res, rej) => {
|
|
32
|
+
rs.on("end", () => res());
|
|
33
|
+
rs.on("error", rej);
|
|
34
|
+
});
|
|
35
|
+
return h.digest("hex");
|
|
36
|
+
};
|
|
37
|
+
const isReadableStream = (value) => !!value && typeof value === "object" && typeof value.pipe === "function";
|
|
38
|
+
const writeFileIfChanged = async (path, dataOrStream, { encoding = "utf8" } = {}) => {
|
|
39
|
+
await (0, import_promises.writeFile)(path, dataOrStream, { encoding });
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
writeFileIfChanged
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=writeFileIfChanged.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/writeFileIfChanged.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { createReadStream } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport { Readable } from 'node:stream';\n\nconst hashFile = async (path: string) => {\n const h = createHash('sha256');\n const rs = createReadStream(path);\n rs.on('data', (chunk) => h.update(chunk));\n await new Promise<void>((res, rej) => {\n rs.on('end', () => res());\n rs.on('error', rej);\n });\n return h.digest('hex');\n};\n\nconst isReadableStream = (value: unknown): value is Readable =>\n !!value &&\n typeof value === 'object' &&\n typeof (value as any).pipe === 'function';\n\nexport const writeFileIfChanged = async (\n path: string,\n dataOrStream: string,\n { encoding = 'utf8' }: { encoding?: BufferEncoding } = {}\n): Promise<boolean> => {\n // Disabled because it's too slow. Build time increases from 3s to 7s.\n await writeFile(path, dataOrStream, { encoding });\n\n // 1) write new content to temporary file (stream-safe)\n // const tmp = `${path}.tmp`;\n\n // if (isReadableStream(dataOrStream)) {\n // await pipeline(dataOrStream, createWriteStream(tmp));\n // } else {\n // // dataOrStream = string | Buffer\n // const buf = Buffer.isBuffer(dataOrStream)\n // ? dataOrStream\n // : Buffer.from(dataOrStream, encoding);\n // await writeFile(tmp, buf);\n // }\n\n // 2) if old file exists, compare hashes (streaming)\n // let same = false;\n // try {\n // const [oldHash, newHash] = await Promise.all([\n // hashFile(path),\n // hashFile(tmp),\n // ]);\n // same = oldHash === newHash;\n // } catch {\n // // old file missing -> will replace\n // }\n\n // if (same) {\n // await rm(tmp);\n // return false; // no change\n // }\n\n // 3) atomic replacement\n // On Unix, rename is atomic. On Windows, if file exists, we can delete it first.\n // try {\n // await rename(tmp, path);\n // } catch {\n // try {\n // await rm(path);\n // } catch {}\n // await rename(tmp, path);\n // }\n\n return true; // changed\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,qBAAiC;AACjC,sBAA0B;AAG1B,MAAM,WAAW,OAAO,SAAiB;AACvC,QAAM,QAAI,+BAAW,QAAQ;AAC7B,QAAM,SAAK,iCAAiB,IAAI;AAChC,KAAG,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,KAAK,CAAC;AACxC,QAAM,IAAI,QAAc,CAAC,KAAK,QAAQ;AACpC,OAAG,GAAG,OAAO,MAAM,IAAI,CAAC;AACxB,OAAG,GAAG,SAAS,GAAG;AAAA,EACpB,CAAC;AACD,SAAO,EAAE,OAAO,KAAK;AACvB;AAEA,MAAM,mBAAmB,CAAC,UACxB,CAAC,CAAC,SACF,OAAO,UAAU,YACjB,OAAQ,MAAc,SAAS;AAE1B,MAAM,qBAAqB,OAChC,MACA,cACA,EAAE,WAAW,OAAO,IAAmC,CAAC,MACnC;AAErB,YAAM,2BAAU,MAAM,cAAc,EAAE,SAAS,CAAC;AA2ChD,SAAO;AACT;","names":[]}
|
|
@@ -16,22 +16,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var writeJsonIfChanged_exports = {};
|
|
20
|
+
__export(writeJsonIfChanged_exports, {
|
|
21
|
+
writeJsonIfChanged: () => writeJsonIfChanged
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
else if (numberValue <= 7) return "few";
|
|
30
|
-
else if (numberValue <= 99) return "many";
|
|
31
|
-
else return "other";
|
|
23
|
+
module.exports = __toCommonJS(writeJsonIfChanged_exports);
|
|
24
|
+
var import_writeFileIfChanged = require('./writeFileIfChanged.cjs');
|
|
25
|
+
const writeJsonIfChanged = async (path, data, { pretty = process.env.NODE_ENV === "development" } = {}) => {
|
|
26
|
+
const space = pretty ? 2 : void 0;
|
|
27
|
+
const json = JSON.stringify(data, null, space);
|
|
28
|
+
return await (0, import_writeFileIfChanged.writeFileIfChanged)(path, json);
|
|
32
29
|
};
|
|
33
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
31
|
0 && (module.exports = {
|
|
35
|
-
|
|
32
|
+
writeJsonIfChanged
|
|
36
33
|
});
|
|
37
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=writeJsonIfChanged.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/writeJsonIfChanged.ts"],"sourcesContent":["import { writeFileIfChanged } from './writeFileIfChanged';\n\nexport const writeJsonIfChanged = async <T>(\n path: string,\n data: T,\n { pretty = process.env.NODE_ENV === 'development' } = {}\n): Promise<boolean> => {\n const space = pretty ? 2 : undefined;\n const json = JSON.stringify(data, null, space);\n\n return await writeFileIfChanged(path, json);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAmC;AAE5B,MAAM,qBAAqB,OAChC,MACA,MACA,EAAE,SAAS,QAAQ,IAAI,aAAa,cAAc,IAAI,CAAC,MAClC;AACrB,QAAM,QAAQ,SAAS,IAAI;AAC3B,QAAM,OAAO,KAAK,UAAU,MAAM,MAAM,KAAK;AAE7C,SAAO,UAAM,8CAAmB,MAAM,IAAI;AAC5C;","names":[]}
|
|
@@ -8,12 +8,12 @@ import { getBuiltDictionariesPath } from "../getBuiltDictionariesPath.mjs";
|
|
|
8
8
|
import { listDictionaries } from "../listDictionariesPath.mjs";
|
|
9
9
|
import { loadLocalDictionaries } from "../loadDictionaries/loadLocalDictionaries.mjs";
|
|
10
10
|
import { prepareIntlayer } from "../prepareIntlayer.mjs";
|
|
11
|
-
import { buildDictionary } from "../transpiler/declaration_file_to_dictionary/index.mjs";
|
|
12
11
|
import { createDictionaryEntryPoint } from "../transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs";
|
|
13
12
|
import {
|
|
14
13
|
createModuleAugmentation,
|
|
15
14
|
createTypes
|
|
16
15
|
} from "../transpiler/dictionary_to_type/index.mjs";
|
|
16
|
+
import { buildDictionary } from "../transpiler/intlayer_dictionary/buildIntlayerDictionary.mjs";
|
|
17
17
|
import { formatPath } from "../utils/formatter.mjs";
|
|
18
18
|
const recentlyAddedFiles = /* @__PURE__ */ new Set();
|
|
19
19
|
const handleAdditionalContentDeclarationFile = async (filePath, configuration) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import {\n GetConfigurationOptions,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { basename } from 'path';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getBuiltDictionariesPath } from '../getBuiltDictionariesPath';\nimport { listDictionaries } from '../listDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { prepareIntlayer } from '../prepareIntlayer';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import {\n GetConfigurationOptions,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { basename } from 'path';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getBuiltDictionariesPath } from '../getBuiltDictionariesPath';\nimport { listDictionaries } from '../listDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { prepareIntlayer } from '../prepareIntlayer';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from '../transpiler/dictionary_to_type/index';\nimport { buildDictionary } from '../transpiler/intlayer_dictionary/buildIntlayerDictionary';\nimport { formatPath } from '../utils/formatter';\n\nconst recentlyAddedFiles = new Set<string>();\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleUnlikedContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = listDictionaries(configuration);\n\n const localeDictionaries = await loadLocalDictionaries(files);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint();\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n await createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n const allDictionariesPaths: string[] = getBuiltDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n await createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n const appLogger = getAppLogger(configuration);\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n recentlyAddedFiles.add(fileName);\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n\n setTimeout(() => recentlyAddedFiles.delete(fileName), 1000); // Allow time for unlink to trigger if it's a move\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n setTimeout(async () => {\n const fileName = basename(filePath);\n\n if (recentlyAddedFiles.has(fileName)) {\n // The file was moved, so ignore unlink\n return;\n }\n\n await handleUnlikedContentDeclarationFile(filePath, configuration);\n }, 300); // Allow time for unlink to trigger if it's a move\n })\n .on('error', async (error) => {\n appLogger('Watcher error: ' + error, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch || options.persistent) {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;AAAA,EACL,CAAC,EACE,GAAG,OAAO,OAAO,aAAa;AAC7B,UAAM,WAAW,SAAS,QAAQ;AAClC,uBAAmB,IAAI,QAAQ;AAE/B,UAAM,uCAAuC,UAAU,aAAa;AAEpE,eAAW,MAAM,mBAAmB,OAAO,QAAQ,GAAG,GAAI;AAAA,EAC5D,CAAC,EACA;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,mCAAmC,UAAU,aAAa;AAAA,EACpE,EACC,GAAG,UAAU,OAAO,aAAa;AAChC,eAAW,YAAY;AACrB,YAAM,WAAW,SAAS,QAAQ;AAElC,UAAI,mBAAmB,IAAI,QAAQ,GAAG;AAEpC;AAAA,MACF;AAEA,YAAM,oCAAoC,UAAU,aAAa;AAAA,IACnE,GAAG,GAAG;AAAA,EACR,CAAC,EACA,GAAG,SAAS,OAAO,UAAU;AAC5B,cAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAED,cAAU,oBAAoB;AAE9B,UAAM,gBAAgB,aAAa;AAAA,EACrC,CAAC;AACL;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,aAAa;AAEnE,QAAM,gBAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,SAAS,QAAQ,YAAY;AAErD,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
ANSIColors,
|
|
4
|
-
colorize,
|
|
5
|
-
getAppLogger,
|
|
6
|
-
getConfiguration
|
|
7
|
-
} from "@intlayer/config";
|
|
1
|
+
import { getIntlayerAPIProxy } from "@intlayer/api";
|
|
2
|
+
import { getAppLogger, getConfiguration, x } from "@intlayer/config";
|
|
8
3
|
import { parallelize } from "./utils/parallelize.mjs";
|
|
9
4
|
const fetchDistantDictionaries = async (options, onStatusUpdate) => {
|
|
10
5
|
const config = getConfiguration();
|
|
11
6
|
const appLogger = getAppLogger(config);
|
|
12
7
|
try {
|
|
13
|
-
const
|
|
14
|
-
const authAPI = getOAuthAPI(config);
|
|
15
|
-
const dictionaryAPI = getDictionaryAPI(void 0, config);
|
|
16
|
-
if (!clientId || !clientSecret) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
"Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();
|
|
22
|
-
const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
|
|
8
|
+
const intlayerAPI = getIntlayerAPIProxy(void 0, config);
|
|
23
9
|
const distantDictionariesKeys = options.dictionaryKeys;
|
|
24
10
|
const processDictionary = async (dictionaryKey) => {
|
|
25
11
|
onStatusUpdate?.([
|
|
@@ -30,17 +16,7 @@ const fetchDistantDictionaries = async (options, onStatusUpdate) => {
|
|
|
30
16
|
}
|
|
31
17
|
]);
|
|
32
18
|
try {
|
|
33
|
-
const getDictionaryResult = await
|
|
34
|
-
dictionaryKey,
|
|
35
|
-
void 0,
|
|
36
|
-
{
|
|
37
|
-
...oAuth2AccessToken && {
|
|
38
|
-
headers: {
|
|
39
|
-
Authorization: `Bearer ${oAuth2AccessToken}`
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
);
|
|
19
|
+
const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(dictionaryKey);
|
|
44
20
|
const distantDictionary = getDictionaryResult.data;
|
|
45
21
|
if (!distantDictionary) {
|
|
46
22
|
throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
|
|
@@ -70,10 +46,7 @@ const fetchDistantDictionaries = async (options, onStatusUpdate) => {
|
|
|
70
46
|
);
|
|
71
47
|
return filteredResult;
|
|
72
48
|
} catch (error) {
|
|
73
|
-
appLogger(
|
|
74
|
-
`${colorize("\u2717", ANSIColors.RED)} Failed to fetch distant dictionaries`,
|
|
75
|
-
{ level: "error" }
|
|
76
|
-
);
|
|
49
|
+
appLogger(`${x} Failed to fetch distant dictionaries`, { level: "error" });
|
|
77
50
|
return [];
|
|
78
51
|
}
|
|
79
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration, x } from '@intlayer/config';\nimport { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":"AAAA,SAAS,2BAA2B;AAGpC,SAAS,cAAc,kBAAkB,SAAS;AAElD,SAAS,mBAAmB;AAWrB,MAAM,2BAA2B,OACtC,SACA,mBAC6B;AAC7B,QAAM,SAAS,iBAAiB;AAChC,QAAM,YAAY,aAAa,MAAM;AACrC,MAAI;AACF,UAAM,cAAc,oBAAoB,QAAW,MAAM;AAEzD,UAAM,0BAA0B,QAAQ;AAExC,UAAM,oBAAoB,OACxB,kBACuC;AACvC,uBAAiB;AAAA,QACf;AAAA,UACE;AAAA,UACA,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,UAAI;AAEF,cAAM,sBACJ,MAAM,YAAY,WAAW,cAAc,aAAa;AAE1D,cAAM,oBAAoB,oBAAoB;AAE9C,YAAI,CAAC,mBAAmB;AACtB,gBAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,QACnE;AAEA,yBAAiB;AAAA,UACf,EAAE,eAAe,MAAM,UAAU,QAAQ,UAAU;AAAA,QACrD,CAAC;AAED,eAAO;AAAA,MACT,SAAS,OAAO;AACd,yBAAiB;AAAA,UACf;AAAA,YACE;AAAA,YACA,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,OAAO,6BAA6B,aAAa,KAAK,KAAK;AAAA,UAC7D;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAEA,UAAM,SAAS,MAAM;AAAA,MACnB;AAAA,MACA,OAAO,kBAAkB,MAAM,kBAAkB,aAAa;AAAA,IAChE;AAGA,UAAM,iBAAiB,OAAO;AAAA,MAC5B,CAAC,SACC,SAAS;AAAA,IACb;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,cAAU,GAAG,CAAC,yCAAyC,EAAE,OAAO,QAAQ,CAAC;AACzE,WAAO,CAAC;AAAA,EACV;AACF;","names":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
} from "./chokidar/watcher.mjs";
|
|
7
7
|
import { cleanOutputDir } from "./cleanOutputDir.mjs";
|
|
8
8
|
import { fetchDistantDictionaries } from "./fetchDistantDictionaries.mjs";
|
|
9
|
-
import { fetchDistantDictionaryKeysAndUpdateTimestamp } from "./fetchDistantDictionaryKeysAndUpdateTimestamp.mjs";
|
|
10
9
|
import { getBuiltDictionariesPath } from "./getBuiltDictionariesPath.mjs";
|
|
11
10
|
import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
|
|
12
11
|
import { listDictionaries } from "./listDictionariesPath.mjs";
|
|
@@ -24,12 +23,12 @@ import { prepareContentDeclaration } from "./prepareContentDeclaration.mjs";
|
|
|
24
23
|
import { prepareIntlayer } from "./prepareIntlayer.mjs";
|
|
25
24
|
import { processPerLocaleDictionary } from "./processPerLocaleDictionary.mjs";
|
|
26
25
|
import { reduceDictionaryContent } from "./reduceDictionaryContent/reduceDictionaryContent.mjs";
|
|
27
|
-
import { buildDictionary } from "./transpiler/declaration_file_to_dictionary/index.mjs";
|
|
28
26
|
import {
|
|
29
27
|
createDictionaryEntryPoint,
|
|
30
28
|
generateDictionaryListContent
|
|
31
29
|
} from "./transpiler/dictionary_to_main/index.mjs";
|
|
32
30
|
import { createModuleAugmentation } from "./transpiler/dictionary_to_type/createModuleAugmentation.mjs";
|
|
31
|
+
import { buildDictionary } from "./transpiler/intlayer_dictionary/buildIntlayerDictionary.mjs";
|
|
33
32
|
import { formatLocale, formatPath } from "./utils/formatter.mjs";
|
|
34
33
|
import { getFileHash } from "./utils/getFileHash.mjs";
|
|
35
34
|
import { kebabCaseToCamelCase } from "./utils/kebabCaseToCamelCase.mjs";
|
|
@@ -47,7 +46,6 @@ export {
|
|
|
47
46
|
createDictionaryEntryPoint,
|
|
48
47
|
createModuleAugmentation,
|
|
49
48
|
fetchDistantDictionaries,
|
|
50
|
-
fetchDistantDictionaryKeysAndUpdateTimestamp,
|
|
51
49
|
formatLocale,
|
|
52
50
|
formatPath,
|
|
53
51
|
generateDictionaryListContent,
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { buildDictionary } from './transpiler/intlayer_dictionary/buildIntlayerDictionary';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getFileHash } from './utils/getFileHash';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;AAChC,SAAS,cAAc,kBAAkB;AACzC,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,eAAe;AACxB,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,OAEK;","names":[]}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "@intlayer/config";
|
|
6
6
|
import { relative } from "path";
|
|
7
7
|
import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
|
|
8
|
-
import { processContentDeclaration } from "../transpiler/
|
|
8
|
+
import { processContentDeclaration } from "../transpiler/intlayer_dictionary/processContentDeclaration.mjs";
|
|
9
9
|
import { parallelize } from "../utils/parallelize.mjs";
|
|
10
10
|
const formatLocalDictionaries = (dictionariesRecord) => Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({
|
|
11
11
|
...dict,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n getConfiguration,\n IntlayerConfig,\n loadExternalFile,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { processContentDeclaration } from '../transpiler/
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n getConfiguration,\n IntlayerConfig,\n loadExternalFile,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { processContentDeclaration } from '../transpiler/intlayer_dictionary/processContentDeclaration';\nimport { parallelize } from '../utils/parallelize';\nimport { DictionariesStatus } from './loadDictionaries';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n localId: `${dict.key}::local::${relativePath}`,\n location: 'locale' as const,\n filePath: relativePath,\n }));\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const dictionariesRecord = contentDeclarationFilePath.reduce(\n (acc, path) => {\n const relativePath = relative(configuration.content.baseDir, path);\n return {\n ...acc,\n [relativePath]: loadExternalFile(path, undefined, projectRequire),\n };\n },\n {} as Record<string, Dictionary>\n );\n const contentDeclarations: Dictionary[] =\n formatLocalDictionaries(dictionariesRecord);\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries);\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,mBAAmB;AAGrB,MAAM,0BAA0B,CACrC,uBAEA,OAAO,QAAQ,kBAAkB,EAAE,IAAI,CAAC,CAAC,cAAc,IAAI,OAAO;AAAA,EAChE,GAAG;AAAA,EACH,SAAS,GAAG,KAAK,GAAG,YAAY,YAAY;AAAA,EAC5C,UAAU;AAAA,EACV,UAAU;AACZ,EAAE;AAEG,MAAM,0BAA0B,OACrC,4BACA,gBAAgC,iBAAiB,GACjD,iBAAiB,gBACjB,mBAC0B;AAC1B,QAAM,qBAAqB,2BAA2B;AAAA,IACpD,CAAC,KAAK,SAAS;AACb,YAAM,eAAe,SAAS,cAAc,QAAQ,SAAS,IAAI;AACjE,aAAO;AAAA,QACL,GAAG;AAAA,QACH,CAAC,YAAY,GAAG,iBAAiB,MAAM,QAAW,cAAc;AAAA,MAClE;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACA,QAAM,sBACJ,wBAAwB,kBAAkB;AAE5C,QAAM,wBAAwB,oBAAoB,IAAI,CAAC,iBAAiB;AAAA,IACtE,eAAe,YAAY;AAAA,IAC3B,MAAM;AAAA,IACN,QAAQ;AAAA,EACV,EAAE;AAEF,mBAAiB,qBAAqB;AAEtC,QAAM,wBAAwB,MAAM;AAAA,IAClC;AAAA,IACA,OAAO,uBAAwD;AAC7D,UAAI,CAAC,oBAAoB;AACvB,eAAO;AAAA,MACT;AAEA,uBAAiB;AAAA,QACf;AAAA,UACE,eAAe,mBAAmB;AAAA,UAClC,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,YAAM,8BAA8B,MAAM;AAAA,QACxC;AAAA,MACF;AAEA,UAAI,CAAC,6BAA6B;AAChC,eAAO;AAAA,MACT;AAEA,uBAAiB;AAAA,QACf;AAAA,UACE,eAAe,4BAA4B;AAAA,UAC3C,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,0BAA0B,qBAAqB;AACxD;","names":[]}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getAppLogger,
|
|
8
8
|
getConfiguration
|
|
9
9
|
} from "@intlayer/config";
|
|
10
|
-
import {
|
|
10
|
+
import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
|
|
11
11
|
import { loadContentDeclarations } from "./loadContentDeclaration.mjs";
|
|
12
12
|
import { loadRemoteDictionaries } from "./loadRemoteDictionaries.mjs";
|
|
13
13
|
import { DictionariesLogger } from "./log.mjs";
|
|
@@ -104,6 +104,7 @@ const printSummary = (configuration = getConfiguration()) => {
|
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
const loadDictionaries = async (contentDeclarationsPaths, configuration = getConfiguration(), projectRequire = ESMxCJSRequire) => {
|
|
107
|
+
const loadDictionariesStartTime = Date.now();
|
|
107
108
|
const appLogger = getAppLogger(configuration);
|
|
108
109
|
appLogger("Dictionaries:", { isVerbose: true });
|
|
109
110
|
const files = Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths];
|
|
@@ -113,24 +114,8 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = getCon
|
|
|
113
114
|
projectRequire,
|
|
114
115
|
setLoadDictionariesStatus
|
|
115
116
|
);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const hasContent = Boolean(dict.content);
|
|
119
|
-
if (!hasContent) {
|
|
120
|
-
appLogger(
|
|
121
|
-
[
|
|
122
|
-
"Content declaration has no exported content",
|
|
123
|
-
dict.filePath ? relative(configuration.content.baseDir, dict.filePath) : ""
|
|
124
|
-
],
|
|
125
|
-
{ level: "error" }
|
|
126
|
-
);
|
|
127
|
-
} else if (!hasKey) {
|
|
128
|
-
appLogger(["Content declaration has no key", dict.filePath], {
|
|
129
|
-
level: "error"
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return hasKey && hasContent;
|
|
133
|
-
});
|
|
117
|
+
const localDictionariesTime = Date.now();
|
|
118
|
+
const filteredLocalDictionaries = filterInvalidDictionaries(localDictionaries);
|
|
134
119
|
const localDictionariesStatus = filteredLocalDictionaries.map(
|
|
135
120
|
(dict) => ({
|
|
136
121
|
dictionaryKey: dict.key,
|
|
@@ -142,18 +127,31 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = getCon
|
|
|
142
127
|
const hasRemoteDictionaries = Boolean(
|
|
143
128
|
configuration.editor.clientId && configuration.editor.clientSecret
|
|
144
129
|
);
|
|
130
|
+
if (hasRemoteDictionaries) {
|
|
131
|
+
logger.setExpectRemote(true);
|
|
132
|
+
}
|
|
145
133
|
let remoteDictionaries = [];
|
|
146
134
|
if (hasRemoteDictionaries) {
|
|
147
135
|
remoteDictionaries = await loadRemoteDictionaries(
|
|
148
136
|
configuration,
|
|
149
|
-
setLoadDictionariesStatus
|
|
137
|
+
setLoadDictionariesStatus,
|
|
138
|
+
{
|
|
139
|
+
onStartRemoteCheck: () => logger.startRemoteCheck(),
|
|
140
|
+
onStopRemoteCheck: () => logger.stopRemoteCheck(),
|
|
141
|
+
onError: () => logger.setRemoteError()
|
|
142
|
+
}
|
|
150
143
|
);
|
|
151
144
|
}
|
|
145
|
+
const remoteDictionariesTime = Date.now();
|
|
152
146
|
logger.finish();
|
|
153
147
|
printSummary(configuration);
|
|
154
148
|
return {
|
|
155
149
|
localDictionaries: filteredLocalDictionaries,
|
|
156
|
-
remoteDictionaries
|
|
150
|
+
remoteDictionaries,
|
|
151
|
+
time: {
|
|
152
|
+
localDictionaries: localDictionariesTime - loadDictionariesStartTime,
|
|
153
|
+
remoteDictionaries: remoteDictionariesTime - localDictionariesTime
|
|
154
|
+
}
|
|
157
155
|
};
|
|
158
156
|
};
|
|
159
157
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'node:path';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n}> => {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const filteredLocalDictionaries = localDictionaries.filter((dict) => {\n const hasKey = Boolean(dict.key);\n const hasContent = Boolean(dict.content);\n\n if (!hasContent) {\n appLogger(\n [\n 'Content declaration has no exported content',\n dict.filePath\n ? relative(configuration.content.baseDir, dict.filePath)\n : '',\n ],\n { level: 'error' }\n );\n } else if (!hasKey) {\n appLogger(['Content declaration has no key', dict.filePath], {\n level: 'error',\n });\n }\n\n return hasKey && hasContent;\n });\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus\n );\n }\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n };\n};\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,gBAAgB;AACzB,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,mBAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;AAEA,2BAAyB;AACzB,SAAO,OAAO,QAAQ;AAEtB,SAAO;AACT;AAOA,MAAM,UAAU,CAAC,WAAyC;AACxD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,MAAM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,SAAS,KAAK,QAAQ,IACrD;AAAA,QACN;AAAA,QACA,EAAE,OAAO,QAAQ;AAAA,MACnB;AAAA,IACF,WAAW,CAAC,QAAQ;AAClB,gBAAU,CAAC,kCAAkC,KAAK,QAAQ,GAAG;AAAA,QAC3D,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAEA,WAAO,UAAU;AAAA,EACnB,CAAC;AAED,QAAM,0BAA0B,0BAA0B;AAAA,IACxD,CAAC,UACE;AAAA,MACC,eAAe,KAAK;AAAA,MACpB,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACJ;AAEA,4BAA0B,uBAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,MAAM;AAAA,MACzB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries =\n filterInvalidDictionaries(localDictionaries);\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: () => logger.setRemoteError(),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,iCAAiC;AAC1C,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,mBAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;A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kC,MAAM;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,wBAAwB,KAAK,IAAI;AAEvC,QAAM,4BACJ,0BAA0B,iBAAiB;AAE7C,QAAM,0BAA0B,0BAA0B;AAAA,IACxD,CAAC,UACE;AAAA,MACC,eAAe,KAAK;AAAA,MACpB,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACJ;AAEA,4BAA0B,uBAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,uBAAuB;AAEzB,WAAO,gBAAgB,IAAI;AAAA,EAC7B;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,MAAM;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,QACE,oBAAoB,MAAM,OAAO,iBAAiB;AAAA,QAClD,mBAAmB,MAAM,OAAO,gBAAgB;AAAA,QAChD,SAAS,MAAM,OAAO,eAAe;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACA,QAAM,yBAAyB,KAAK,IAAI;AAGxC,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,IACA,MAAM;AAAA,MACJ,mBAAmB,wBAAwB;AAAA,MAC3C,oBAAoB,yBAAyB;AAAA,IAC/C;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getIntlayerAPIProxy } from "@intlayer/api";
|
|
2
|
+
import { getAppLogger, getConfiguration } from "@intlayer/config";
|
|
2
3
|
import remoteDictionariesRecord from "@intlayer/remote-dictionaries-entry";
|
|
3
4
|
import { fetchDistantDictionaries } from "../fetchDistantDictionaries.mjs";
|
|
4
|
-
import { fetchDistantDictionaryKeysAndUpdateTimestamp } from "../fetchDistantDictionaryKeysAndUpdateTimestamp.mjs";
|
|
5
5
|
import { sortAlphabetically } from "../utils/sortAlphabetically.mjs";
|
|
6
6
|
const formatDistantDictionaries = (dictionaries) => dictionaries.map((dict) => ({
|
|
7
7
|
...dict,
|
|
8
8
|
localId: `${dict.key}::remote::${dict.id}`,
|
|
9
9
|
location: "distant"
|
|
10
10
|
}));
|
|
11
|
-
const loadRemoteDictionaries = async (configuration = getConfiguration(), onStatusUpdate) => {
|
|
11
|
+
const loadRemoteDictionaries = async (configuration = getConfiguration(), onStatusUpdate, options) => {
|
|
12
12
|
const appLogger = getAppLogger(configuration);
|
|
13
13
|
const { editor } = configuration;
|
|
14
14
|
const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);
|
|
15
15
|
if (!hasRemoteDictionaries) return [];
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
options?.onStartRemoteCheck?.();
|
|
18
|
+
const intlayerAPI = getIntlayerAPIProxy(void 0, configuration);
|
|
19
|
+
const getDictionariesKeysResult = await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();
|
|
20
|
+
const distantDictionaryUpdateTimeStamp = getDictionariesKeysResult.data;
|
|
21
|
+
if (!distantDictionaryUpdateTimeStamp) {
|
|
22
|
+
throw new Error("No distant dictionaries found");
|
|
23
|
+
}
|
|
18
24
|
const dictionariesKeysToFetch = Object.entries(
|
|
19
25
|
distantDictionaryUpdateTimeStamp
|
|
20
26
|
).filter(([dictionaryKey, remoteUpdatedAt]) => {
|
|
@@ -62,8 +68,11 @@ const loadRemoteDictionaries = async (configuration = getConfiguration(), onStat
|
|
|
62
68
|
);
|
|
63
69
|
return [...cachedDictionaries, ...distantDictionaries];
|
|
64
70
|
} catch (error) {
|
|
65
|
-
|
|
71
|
+
console.error(error);
|
|
72
|
+
options?.onError?.(error);
|
|
66
73
|
return [];
|
|
74
|
+
} finally {
|
|
75
|
+
options?.onStopRemoteCheck?.();
|
|
67
76
|
}
|
|
68
77
|
};
|
|
69
78
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport remoteDictionariesRecord from '@intlayer/remote-dictionaries-entry';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport { DictionariesStatus } from '../loadDictionaries/loadDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\n\nexport const formatDistantDictionaries = (\n dictionaries: DictionaryAPI[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'distant' as const,\n }));\n\nexport const loadRemoteDictionaries = async (\n configuration = getConfiguration(),\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: {\n onStartRemoteCheck?: () => void;\n onStopRemoteCheck?: () => void;\n onError?: (error: Error) => void;\n }\n): Promise<DictionaryAPI[]> => {\n const appLogger = getAppLogger(configuration);\n\n const { editor } = configuration;\n\n const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);\n\n if (!hasRemoteDictionaries) return [];\n\n try {\n options?.onStartRemoteCheck?.();\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();\n\n const distantDictionaryUpdateTimeStamp = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesKeysToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n )\n .filter(([dictionaryKey, remoteUpdatedAt]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!remoteUpdatedAt) return true;\n\n // If no local cache exists, fetch\n const local = (remoteDictionariesRecord as any)[dictionaryKey];\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // If local timestamp missing or older than remote, fetch\n if (typeof localUpdatedAt !== 'number') return true;\n return remoteUpdatedAt > localUpdatedAt;\n })\n .map(([dictionaryKey]) => dictionaryKey);\n\n const cachedDictionaries = Object.entries(remoteDictionariesRecord)\n .filter(([key, dictionary]) => {\n const remoteUpdatedAt = distantDictionaryUpdateTimeStamp[key];\n const localUpdatedAtRaw = (dictionary as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n // Consider as cached/imported when local exists and is up-to-date or newer\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n })\n .map(([, dictionary]) => dictionary as any);\n\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((d) => ({\n dictionaryKey: d.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n const orderedDistantDictionaryKeys =\n dictionariesKeysToFetch.sort(sortAlphabetically);\n\n // Report pending for keys to be fetched so totals are visible immediately\n if (orderedDistantDictionaryKeys.length > 0) {\n onStatusUpdate?.(\n orderedDistantDictionaryKeys.map((key) => ({\n dictionaryKey: key,\n type: 'remote',\n status: 'pending',\n }))\n );\n }\n\n const distantDictionariesData = await fetchDistantDictionaries(\n {\n dictionaryKeys: orderedDistantDictionaryKeys,\n },\n onStatusUpdate\n );\n\n const distantDictionaries: DictionaryAPI[] = formatDistantDictionaries(\n distantDictionariesData\n );\n\n return [...cachedDictionaries, ...distantDictionaries];\n } catch (error) {\n console.error(error);\n options?.onError?.(error as Error);\n return [];\n } finally {\n options?.onStopRemoteCheck?.();\n }\n};\n"],"mappings":"AAAA,SAAS,2BAA2B;AAGpC,SAAS,cAAc,wBAAwB;AAE/C,OAAO,8BAA8B;AACrC,SAAS,gCAAgC;AAEzC,SAAS,0BAA0B;AAE5B,MAAM,4BAA4B,CACvC,iBAEA,aAAa,IAAI,CAAC,UAAU;AAAA,EAC1B,GAAG;AAAA,EACH,SAAS,GAAG,KAAK,GAAG,aAAa,KAAK,EAAE;AAAA,EACxC,UAAU;AACZ,EAAE;AAEG,MAAM,yBAAyB,OACpC,gBAAgB,iBAAiB,GACjC,gBACA,YAK6B;AAC7B,QAAM,YAAY,aAAa,aAAa;AAE5C,QAAM,EAAE,OAAO,IAAI;AAEnB,QAAM,wBAAwB,QAAQ,OAAO,YAAY,OAAO,YAAY;AAE5E,MAAI,CAAC,sBAAuB,QAAO,CAAC;AAEpC,MAAI;AACF,aAAS,qBAAqB;AAE9B,UAAM,cAAc,oBAAoB,QAAW,aAAa;AAGhE,UAAM,4BACJ,MAAM,YAAY,WAAW,+BAA+B;AAE9D,UAAM,mCAAmC,0BAA0B;AAEnE,QAAI,CAAC,kCAAkC;AACrC,YAAM,IAAI,MAAM,+BAA+B;AAAA,IACjD;AAEA,UAAM,0BAA0B,OAAO;AAAA,MACrC;AAAA,IACF,EACG,OAAO,CAAC,CAAC,eAAe,eAAe,MAAM;AAE5C,UAAI,CAAC,gBAAiB,QAAO;AAG7B,YAAM,QAAS,yBAAiC,aAAa;AAC7D,UAAI,CAAC,MAAO,QAAO;AAEnB,YAAM,oBAAqB,OAAe;AAI1C,YAAM,iBACJ,OAAO,sBAAsB,WACzB,oBACA,oBACE,IAAI,KAAK,iBAAi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