@crowdin/app-project-module 1.5.0 → 1.5.1

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.
@@ -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 SNAPSHOT_FETCH_CONCURRENCY = 5;
19
20
  function getCrowdinSnapshot(config, integration, crowdinApiClient, projectId, integrationSettings) {
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
22
  let files = [];
@@ -47,22 +48,27 @@ function getOneLevelFetchingFiles(integration, integrationCredentials, integrati
47
48
  if (folders.length === 0) {
48
49
  return parentFiles;
49
50
  }
50
- const childResults = yield Promise.all(folders.map((folder) => __awaiter(this, void 0, void 0, function* () {
51
- const childs = getTreeItems(yield integration.getIntegrationFiles({
52
- credentials: integrationCredentials,
53
- client,
54
- projectId,
55
- settings: integrationSettings,
56
- parentId: folder.id,
57
- search: '',
58
- page: 0,
59
- }));
60
- if (childs.length === 0) {
61
- return [];
62
- }
63
- return getOneLevelFetchingFiles(integration, integrationCredentials, integrationSettings, childs, client, projectId);
64
- })));
65
- return [...parentFiles, ...childResults.flat()];
51
+ const results = [];
52
+ for (let i = 0; i < folders.length; i += SNAPSHOT_FETCH_CONCURRENCY) {
53
+ const batch = folders.slice(i, i + SNAPSHOT_FETCH_CONCURRENCY);
54
+ const batchResults = yield Promise.all(batch.map((folder) => __awaiter(this, void 0, void 0, function* () {
55
+ const childs = getTreeItems(yield integration.getIntegrationFiles({
56
+ credentials: integrationCredentials,
57
+ client,
58
+ projectId,
59
+ settings: integrationSettings,
60
+ parentId: folder.id,
61
+ search: '',
62
+ page: 0,
63
+ }));
64
+ if (childs.length === 0) {
65
+ return [];
66
+ }
67
+ return getOneLevelFetchingFiles(integration, integrationCredentials, integrationSettings, childs, client, projectId);
68
+ })));
69
+ results.push(...batchResults.flat());
70
+ }
71
+ return [...parentFiles, ...results];
66
72
  });
67
73
  }
68
74
  function getIntegrationSnapshot(_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",