@crowdin/app-project-module 1.5.0 → 1.5.2
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.
|
@@ -196,6 +196,12 @@ export interface IntegrationLogic extends ModuleKey {
|
|
|
196
196
|
* Enable integration folder open event
|
|
197
197
|
*/
|
|
198
198
|
integrationOneLevelFetching?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Concurrency limit for snapshot fetching when integrationOneLevelFetching is enabled.
|
|
201
|
+
* Controls how many folders are fetched in parallel at each level of the tree.
|
|
202
|
+
* @default 1
|
|
203
|
+
*/
|
|
204
|
+
snapshotFetchConcurrency?: number;
|
|
199
205
|
/**
|
|
200
206
|
* Enable integration search event
|
|
201
207
|
*/
|
|
@@ -16,6 +16,7 @@ const types_1 = require("../types");
|
|
|
16
16
|
const storage_1 = require("../../../storage");
|
|
17
17
|
const defaults_1 = require("./defaults");
|
|
18
18
|
const files_1 = require("./files");
|
|
19
|
+
const DEFAULT_SNAPSHOT_FETCH_CONCURRENCY = 1;
|
|
19
20
|
function getCrowdinSnapshot(config, integration, crowdinApiClient, projectId, integrationSettings) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
let files = [];
|
|
@@ -43,26 +44,33 @@ function getTreeItems(integrationData) {
|
|
|
43
44
|
}
|
|
44
45
|
function getOneLevelFetchingFiles(integration, integrationCredentials, integrationSettings, parentFiles, client, projectId) {
|
|
45
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
var _a;
|
|
46
48
|
const folders = parentFiles.filter((file) => !file.type);
|
|
47
49
|
if (folders.length === 0) {
|
|
48
50
|
return parentFiles;
|
|
49
51
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
const concurrency = (_a = integration.snapshotFetchConcurrency) !== null && _a !== void 0 ? _a : DEFAULT_SNAPSHOT_FETCH_CONCURRENCY;
|
|
53
|
+
const results = [];
|
|
54
|
+
for (let i = 0; i < folders.length; i += concurrency) {
|
|
55
|
+
const batch = folders.slice(i, i + concurrency);
|
|
56
|
+
const batchResults = yield Promise.all(batch.map((folder) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const childs = getTreeItems(yield integration.getIntegrationFiles({
|
|
58
|
+
credentials: integrationCredentials,
|
|
59
|
+
client,
|
|
60
|
+
projectId,
|
|
61
|
+
settings: integrationSettings,
|
|
62
|
+
parentId: folder.id,
|
|
63
|
+
search: '',
|
|
64
|
+
page: 0,
|
|
65
|
+
}));
|
|
66
|
+
if (childs.length === 0) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
return getOneLevelFetchingFiles(integration, integrationCredentials, integrationSettings, childs, client, projectId);
|
|
70
|
+
})));
|
|
71
|
+
results.push(...batchResults.flat());
|
|
72
|
+
}
|
|
73
|
+
return [...parentFiles, ...results];
|
|
66
74
|
});
|
|
67
75
|
}
|
|
68
76
|
function getIntegrationSnapshot(_a) {
|
package/package.json
CHANGED