@crowdin/app-project-module 0.30.1 → 0.30.3

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 (52) hide show
  1. package/.release-it.json +17 -0
  2. package/CONTRIBUTING.md +3 -0
  3. package/out/handlers/{crowdin-file-progress.d.ts → integration/crowdin-file-progress.d.ts} +1 -1
  4. package/out/handlers/{crowdin-file-progress.js → integration/crowdin-file-progress.js} +1 -1
  5. package/out/handlers/{crowdin-files.d.ts → integration/crowdin-files.d.ts} +1 -1
  6. package/out/handlers/{crowdin-files.js → integration/crowdin-files.js} +2 -2
  7. package/out/handlers/{crowdin-project.d.ts → integration/crowdin-project.d.ts} +1 -1
  8. package/out/handlers/{crowdin-project.js → integration/crowdin-project.js} +1 -1
  9. package/out/handlers/{crowdin-update.d.ts → integration/crowdin-update.d.ts} +1 -1
  10. package/out/handlers/{crowdin-update.js → integration/crowdin-update.js} +3 -3
  11. package/out/handlers/{crowdin-webhook.d.ts → integration/crowdin-webhook.d.ts} +1 -1
  12. package/out/handlers/{crowdin-webhook.js → integration/crowdin-webhook.js} +6 -6
  13. package/out/handlers/{integration-data.d.ts → integration/integration-data.d.ts} +1 -1
  14. package/out/handlers/{integration-data.js → integration/integration-data.js} +1 -1
  15. package/out/handlers/{integration-login.d.ts → integration/integration-login.d.ts} +1 -1
  16. package/out/handlers/{integration-login.js → integration/integration-login.js} +2 -2
  17. package/out/handlers/{integration-logout.d.ts → integration/integration-logout.d.ts} +1 -1
  18. package/out/handlers/{integration-logout.js → integration/integration-logout.js} +4 -4
  19. package/out/handlers/{integration-update.d.ts → integration/integration-update.d.ts} +1 -1
  20. package/out/handlers/{integration-update.js → integration/integration-update.js} +2 -2
  21. package/out/handlers/{integration-webhook.d.ts → integration/integration-webhook.d.ts} +1 -1
  22. package/out/handlers/{integration-webhook.js → integration/integration-webhook.js} +3 -3
  23. package/out/handlers/{main.d.ts → integration/main.d.ts} +1 -1
  24. package/out/handlers/{main.js → integration/main.js} +3 -3
  25. package/out/handlers/{oauth-login.d.ts → integration/oauth-login.d.ts} +1 -1
  26. package/out/handlers/{oauth-login.js → integration/oauth-login.js} +2 -2
  27. package/out/handlers/{oauth-url.d.ts → integration/oauth-url.d.ts} +1 -1
  28. package/out/handlers/{oauth-url.js → integration/oauth-url.js} +2 -2
  29. package/out/handlers/{settings-save.d.ts → integration/settings-save.d.ts} +1 -1
  30. package/out/handlers/{settings-save.js → integration/settings-save.js} +6 -6
  31. package/out/handlers/{settings.d.ts → integration/settings.d.ts} +1 -1
  32. package/out/handlers/{settings.js → integration/settings.js} +1 -1
  33. package/out/handlers/{subscription-info.d.ts → integration/subscription-info.d.ts} +1 -1
  34. package/out/handlers/{subscription-info.js → integration/subscription-info.js} +1 -1
  35. package/out/handlers/{sync-settings-save.d.ts → integration/sync-settings-save.d.ts} +1 -1
  36. package/out/handlers/{sync-settings-save.js → integration/sync-settings-save.js} +3 -3
  37. package/out/handlers/{sync-settings.d.ts → integration/sync-settings.d.ts} +1 -1
  38. package/out/handlers/{sync-settings.js → integration/sync-settings.js} +2 -2
  39. package/out/handlers/{synced-files.d.ts → integration/synced-files.d.ts} +1 -1
  40. package/out/handlers/{synced-files.js → integration/synced-files.js} +2 -2
  41. package/out/index.d.ts +1 -1
  42. package/out/index.js +21 -21
  43. package/out/static/js/form.js +14 -14
  44. package/out/util/api/api.d.ts +1 -1
  45. package/out/util/api/api.js +13 -13
  46. package/out/util/axios.d.ts +10 -0
  47. package/out/util/axios.js +42 -0
  48. package/out/util/connection.d.ts +1 -1
  49. package/out/util/connection.js +148 -6
  50. package/out/util/cron.d.ts +1 -1
  51. package/out/util/cron.js +6 -21
  52. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
- import { ApiEndpoints, ApiModule, Config, CrowdinClientRequest, CrowdinContextInfo } from '../../models';
2
1
  import { Express } from 'express';
2
+ import { ApiEndpoints, ApiModule, Config, CrowdinClientRequest, CrowdinContextInfo } from '../../models';
3
3
  export declare function getApiManifest(config: Config, apiModule: ApiModule): ApiEndpoints[];
4
4
  export declare function updateCrowdinContext(req: CrowdinClientRequest, context: CrowdinContextInfo): CrowdinContextInfo;
5
5
  export declare function addDefaultApiEndpoints(app: Express, config: Config): void;
@@ -4,23 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addSwagerApiDocumentation = exports.addDefaultApiEndpoints = exports.updateCrowdinContext = exports.getApiManifest = void 0;
7
- const models_1 = require("../../models");
7
+ const path_1 = __importDefault(require("path"));
8
8
  const redoc_express_1 = __importDefault(require("redoc-express"));
9
9
  const swagger_jsdoc_1 = __importDefault(require("swagger-jsdoc"));
10
- const json_response_1 = __importDefault(require("../../middlewares/json-response"));
10
+ const crowdin_file_progress_1 = __importDefault(require("../../handlers/integration/crowdin-file-progress"));
11
+ const crowdin_files_1 = __importDefault(require("../../handlers/integration/crowdin-files"));
12
+ const crowdin_update_1 = __importDefault(require("../../handlers/integration/crowdin-update"));
13
+ const integration_data_1 = __importDefault(require("../../handlers/integration/integration-data"));
14
+ const integration_login_1 = __importDefault(require("../../handlers/integration/integration-login"));
15
+ const integration_update_1 = __importDefault(require("../../handlers/integration/integration-update"));
16
+ const settings_1 = __importDefault(require("../../handlers/integration/settings"));
17
+ const settings_save_1 = __importDefault(require("../../handlers/integration/settings-save"));
18
+ const sync_settings_1 = __importDefault(require("../../handlers/integration/sync-settings"));
19
+ const sync_settings_save_1 = __importDefault(require("../../handlers/integration/sync-settings-save"));
11
20
  const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
12
21
  const integration_credentials_1 = __importDefault(require("../../middlewares/integration-credentials"));
13
- const crowdin_files_1 = __importDefault(require("../../handlers/crowdin-files"));
14
- const integration_data_1 = __importDefault(require("../../handlers/integration-data"));
15
- const crowdin_file_progress_1 = __importDefault(require("../../handlers/crowdin-file-progress"));
16
- const crowdin_update_1 = __importDefault(require("../../handlers/crowdin-update"));
17
- const sync_settings_1 = __importDefault(require("../../handlers/sync-settings"));
18
- const sync_settings_save_1 = __importDefault(require("../../handlers/sync-settings-save"));
19
- const settings_save_1 = __importDefault(require("../../handlers/settings-save"));
20
- const settings_1 = __importDefault(require("../../handlers/settings"));
21
- const integration_update_1 = __importDefault(require("../../handlers/integration-update"));
22
- const path_1 = __importDefault(require("path"));
23
- const integration_login_1 = __importDefault(require("../../handlers/integration-login"));
22
+ const json_response_1 = __importDefault(require("../../middlewares/json-response"));
23
+ const models_1 = require("../../models");
24
24
  function getApiManifest(config, apiModule) {
25
25
  const apiModuleManifest = [];
26
26
  if (apiModule.endpoints) {
@@ -0,0 +1,10 @@
1
+ import { AxiosInstance } from 'axios';
2
+ export declare class AxiosProvider {
3
+ private static readonly CROWDIN_API_MAX_CONCURRENT_REQUESTS;
4
+ private static readonly CROWDIN_API_REQUESTS_INTERVAL_MS;
5
+ private pendingRequests;
6
+ axios: AxiosInstance;
7
+ constructor();
8
+ private configureRequest;
9
+ private configureResponse;
10
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AxiosProvider = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ //copy from api client to control throughput
9
+ class AxiosProvider {
10
+ constructor() {
11
+ this.pendingRequests = 0;
12
+ this.axios = axios_1.default.create({});
13
+ this.configureRequest();
14
+ this.configureResponse();
15
+ }
16
+ configureRequest() {
17
+ this.axios.interceptors.request.use((config) => {
18
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
19
+ return new Promise((resolve) => {
20
+ const interval = setInterval(() => {
21
+ if (this.pendingRequests < AxiosProvider.CROWDIN_API_MAX_CONCURRENT_REQUESTS) {
22
+ this.pendingRequests++;
23
+ clearInterval(interval);
24
+ resolve(config);
25
+ }
26
+ }, AxiosProvider.CROWDIN_API_REQUESTS_INTERVAL_MS);
27
+ });
28
+ });
29
+ }
30
+ configureResponse() {
31
+ this.axios.interceptors.response.use((response) => {
32
+ this.pendingRequests = Math.max(0, this.pendingRequests - 1);
33
+ return Promise.resolve(response);
34
+ }, (error) => {
35
+ this.pendingRequests = Math.max(0, this.pendingRequests - 1);
36
+ return Promise.reject(error);
37
+ });
38
+ }
39
+ }
40
+ exports.AxiosProvider = AxiosProvider;
41
+ AxiosProvider.CROWDIN_API_MAX_CONCURRENT_REQUESTS = 15;
42
+ AxiosProvider.CROWDIN_API_REQUESTS_INTERVAL_MS = 10;
@@ -1,6 +1,6 @@
1
1
  import Crowdin from '@crowdin/crowdin-api-client';
2
2
  import { AccountType, Config, CrowdinCredentials, IntegrationCredentials, IntegrationLogic, SubscriptionInfo } from '../models';
3
- export declare function prepareCrowdinClient(config: Config, credentials: CrowdinCredentials): Promise<{
3
+ export declare function prepareCrowdinClient(config: Config, credentials: CrowdinCredentials, autoRenew?: boolean): Promise<{
4
4
  client: Crowdin;
5
5
  token: string;
6
6
  }>;
@@ -19,6 +19,8 @@ const axios_1 = __importDefault(require("axios"));
19
19
  const _1 = require(".");
20
20
  const models_1 = require("../models");
21
21
  const storage_1 = require("../storage");
22
+ const axios_2 = require("./axios");
23
+ const axiosCustom = new axios_2.AxiosProvider().axios;
22
24
  function refreshToken(config, credentials) {
23
25
  var _a, _b;
24
26
  return __awaiter(this, void 0, void 0, function* () {
@@ -51,23 +53,163 @@ function refreshToken(config, credentials) {
51
53
  };
52
54
  });
53
55
  }
54
- function prepareCrowdinClient(config, credentials) {
56
+ function prepareCrowdinClient(config, credentials, autoRenew = false) {
55
57
  var _a, _b;
56
58
  return __awaiter(this, void 0, void 0, function* () {
57
59
  //2 min as an extra buffer
58
60
  const isExpired = +credentials.expire - 120 < Date.now() / 1000;
59
61
  const organization = credentials.type === models_1.AccountType.ENTERPRISE ? credentials.id : undefined;
62
+ let token;
63
+ let crowdinCreds;
60
64
  if (!isExpired) {
61
- const token = (0, _1.decryptData)(config, credentials.accessToken);
65
+ token = (0, _1.decryptData)(config, credentials.accessToken);
66
+ crowdinCreds = credentials;
67
+ }
68
+ else {
69
+ const res = yield refreshCrowdinCreds({ config, credentials });
70
+ token = res.token;
71
+ crowdinCreds = res.credentials;
72
+ }
73
+ if (!autoRenew) {
62
74
  return {
63
75
  client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.apiUrl }),
64
76
  token,
65
77
  };
66
78
  }
79
+ const getHttpConfig = (config) => {
80
+ if (!config) {
81
+ return;
82
+ }
83
+ return { headers: Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${token}` }) };
84
+ };
85
+ const renewToken = () => __awaiter(this, void 0, void 0, function* () {
86
+ const res = yield refreshCrowdinCreds({ config, credentials: crowdinCreds });
87
+ token = res.token;
88
+ crowdinCreds = res.credentials;
89
+ });
90
+ const isExpiredCause = (error) => {
91
+ var _a, _b;
92
+ const errorObj = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error;
93
+ return (errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) === 401 && (errorObj === null || errorObj === void 0 ? void 0 : errorObj.message) === 'Unauthorized';
94
+ };
95
+ //providing custom http client to handle expirations and renew token on the fly
96
+ //needed for long running jobs with single Crowdin client instance
97
+ return {
98
+ client: new crowdin_api_client_1.default({
99
+ token,
100
+ organization,
101
+ baseUrl: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.apiUrl,
102
+ }, {
103
+ httpClient: {
104
+ get(url, httpConfig) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ try {
107
+ const res = yield axiosCustom.get(url, getHttpConfig(httpConfig));
108
+ return res.data;
109
+ }
110
+ catch (e) {
111
+ if (isExpiredCause(e)) {
112
+ yield renewToken();
113
+ const res = yield axiosCustom.get(url, getHttpConfig(httpConfig));
114
+ return res.data;
115
+ }
116
+ throw e;
117
+ }
118
+ });
119
+ },
120
+ delete(url, httpConfig) {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ try {
123
+ const res = yield axiosCustom.delete(url, getHttpConfig(httpConfig));
124
+ return res.data;
125
+ }
126
+ catch (e) {
127
+ if (isExpiredCause(e)) {
128
+ yield renewToken();
129
+ const res = yield axiosCustom.delete(url, getHttpConfig(httpConfig));
130
+ return res.data;
131
+ }
132
+ throw e;
133
+ }
134
+ });
135
+ },
136
+ head(url, httpConfig) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ try {
139
+ const res = yield axiosCustom.head(url, getHttpConfig(httpConfig));
140
+ return res.data;
141
+ }
142
+ catch (e) {
143
+ if (isExpiredCause(e)) {
144
+ yield renewToken();
145
+ const res = yield axiosCustom.head(url, getHttpConfig(httpConfig));
146
+ return res.data;
147
+ }
148
+ throw e;
149
+ }
150
+ });
151
+ },
152
+ patch(url, data, httpConfig) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ try {
155
+ const res = yield axiosCustom.patch(url, data, getHttpConfig(httpConfig));
156
+ return res.data;
157
+ }
158
+ catch (e) {
159
+ if (isExpiredCause(e)) {
160
+ yield renewToken();
161
+ const res = yield axiosCustom.patch(url, data, getHttpConfig(httpConfig));
162
+ return res.data;
163
+ }
164
+ throw e;
165
+ }
166
+ });
167
+ },
168
+ post(url, data, httpConfig) {
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ try {
171
+ const res = yield axiosCustom.post(url, data, getHttpConfig(httpConfig));
172
+ return res.data;
173
+ }
174
+ catch (e) {
175
+ if (isExpiredCause(e)) {
176
+ yield renewToken();
177
+ const res = yield axiosCustom.post(url, data, getHttpConfig(httpConfig));
178
+ return res.data;
179
+ }
180
+ throw e;
181
+ }
182
+ });
183
+ },
184
+ put(url, data, httpConfig) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ try {
187
+ const res = yield axiosCustom.put(url, data, getHttpConfig(httpConfig));
188
+ return res.data;
189
+ }
190
+ catch (e) {
191
+ if (isExpiredCause(e)) {
192
+ yield renewToken();
193
+ const res = yield axiosCustom.put(url, data, getHttpConfig(httpConfig));
194
+ return res.data;
195
+ }
196
+ throw e;
197
+ }
198
+ });
199
+ },
200
+ },
201
+ }),
202
+ token,
203
+ };
204
+ });
205
+ }
206
+ exports.prepareCrowdinClient = prepareCrowdinClient;
207
+ function refreshCrowdinCreds({ config, credentials }) {
208
+ return __awaiter(this, void 0, void 0, function* () {
67
209
  (0, _1.log)('Crowdin credentials have expired. Requesting a new credentials', config.logger);
68
210
  const newCredentials = yield refreshToken(config, credentials);
69
211
  (0, _1.log)('Saving updated crowdin credentials in the database', config.logger);
70
- yield (0, storage_1.getStorage)().updateCrowdinCredentials({
212
+ const newCrowdinCredentials = {
71
213
  id: credentials.id,
72
214
  appSecret: credentials.appSecret,
73
215
  domain: credentials.domain,
@@ -78,15 +220,15 @@ function prepareCrowdinClient(config, credentials) {
78
220
  accessToken: newCredentials.accessToken,
79
221
  expire: (new Date().getTime() / 1000 + newCredentials.expiresIn).toString(),
80
222
  type: credentials.type,
81
- });
223
+ };
224
+ yield (0, storage_1.getStorage)().updateCrowdinCredentials(newCrowdinCredentials);
82
225
  const token = (0, _1.decryptData)(config, newCredentials.accessToken);
83
226
  return {
84
- client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.apiUrl }),
227
+ credentials: newCrowdinCredentials,
85
228
  token,
86
229
  };
87
230
  });
88
231
  }
89
- exports.prepareCrowdinClient = prepareCrowdinClient;
90
232
  function prepareIntegrationCredentials(config, integration, integrationCredentials) {
91
233
  var _a, _b, _c, _d, _e, _f, _g, _h;
92
234
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,5 +1,5 @@
1
1
  import Crowdin from '@crowdin/crowdin-api-client';
2
- import { Config, CronJob, IntegrationLogic, UpdateIntegrationRequest, Provider, IntegrationRequest } from '../models';
2
+ import { Config, CronJob, IntegrationLogic, IntegrationRequest, Provider, UpdateIntegrationRequest } from '../models';
3
3
  export declare function runJob(config: Config, integration: IntegrationLogic, job: CronJob): Promise<void>;
4
4
  export declare function filesCron(config: Config, integration: IntegrationLogic, period: string): Promise<void>;
5
5
  export declare function skipFoldersFromIntegrationRequest(config: Config, integration: IntegrationLogic, projectId: number, crowdinFiles: UpdateIntegrationRequest, crowdinClient: Crowdin): Promise<UpdateIntegrationRequest>;
package/out/util/cron.js CHANGED
@@ -45,16 +45,14 @@ function runJob(config, integration, job) {
45
45
  (0, _1.log)(`Starting cron job with expression [${job.expression}]`, config.logger);
46
46
  const crowdinCredentialsList = yield (0, storage_1.getStorage)().getAllCrowdinCredentials();
47
47
  yield Promise.all(crowdinCredentialsList.map((crowdinCredentials) => __awaiter(this, void 0, void 0, function* () {
48
- const { token } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
48
+ const { token, client: crowdinClient } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials, true);
49
49
  const { expired } = yield (0, connection_1.checkSubscription)(config, token, crowdinCredentials.id, crowdinCredentials.type);
50
50
  if (expired) {
51
51
  (0, _1.log)(`Subscription expired. Skipping job [${job.expression}] for organization ${crowdinCredentials.id}`);
52
52
  return;
53
53
  }
54
54
  const integrationCredentialsList = yield (0, storage_1.getStorage)().getAllIntegrationCredentials(crowdinCredentials.id);
55
- //executing in non-parallel way to properly prepare crowdin client (avoid expriration issues)
56
55
  for (const integrationCredentials of integrationCredentialsList) {
57
- const { client: crowdinClient } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
58
56
  const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
59
57
  const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
60
58
  const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, crowdinClient, projectId);
@@ -88,7 +86,7 @@ function filesCron(config, integration, period) {
88
86
  return;
89
87
  }
90
88
  const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
91
- const { client: crowdinClient, token } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
89
+ const { client: crowdinClient, token } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials, true);
92
90
  const { expired } = yield (0, connection_1.checkSubscription)(config, token, crowdinCredentials.id, crowdinCredentials.type);
93
91
  if (expired) {
94
92
  (0, _1.log)(`Subscription expired. Skipping job [${period}] for organization ${crowdinCredentials.id}`);
@@ -96,8 +94,6 @@ function filesCron(config, integration, period) {
96
94
  }
97
95
  const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, crowdinClient, projectId);
98
96
  const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
99
- //split invocation into chunks to avoid expiration issues
100
- const chunkSize = 10;
101
97
  if ((_a = integration.syncNewElements) === null || _a === void 0 ? void 0 : _a[syncSettings.provider]) {
102
98
  newFiles = yield (0, file_snapshot_1.getAllNewFiles)({
103
99
  config,
@@ -126,15 +122,8 @@ function filesCron(config, integration, period) {
126
122
  return;
127
123
  }
128
124
  }
129
- const filesArr = Object.keys(filesToProcess);
130
- for (let i = 0; i < filesArr.length; i += chunkSize) {
131
- const chunk = filesArr.slice(i, i + chunkSize);
132
- const filesChunk = {};
133
- chunk.forEach((f) => (filesChunk[f] = filesToProcess[f]));
134
- const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
135
- const { client } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
136
- yield integration.updateIntegration(projectId, client, apiCredentials, filesChunk, rootFolder, intConfig);
137
- }
125
+ const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
126
+ yield integration.updateIntegration(projectId, crowdinClient, apiCredentials, filesToProcess, rootFolder, intConfig);
138
127
  if (newFiles) {
139
128
  yield (0, storage_1.getStorage)().updateSyncSettings(JSON.stringify(Object.assign(Object.assign({}, files), newFiles)), syncSettings.integrationId, syncSettings.crowdinId, 'schedule', syncSettings.provider);
140
129
  const currentFileSnapshot = yield (0, file_snapshot_1.getCrowdinSnapshot)(config, integration, crowdinClient, projectId, intConfig);
@@ -150,12 +139,8 @@ function filesCron(config, integration, period) {
150
139
  node_type: file.nodeType || file.node_type }, (file.type ? { type: file.type } : {}))));
151
140
  const intFiles = allIntFiles.filter((file) => 'type' in file);
152
141
  (0, _1.log)(`Executing updateCrowdin task for files cron job with period [${period}] for project ${projectId}. Files ${intFiles.length}`, config.logger);
153
- for (let i = 0; i < intFiles.length; i += chunkSize) {
154
- const chunk = intFiles.slice(i, i + chunkSize);
155
- const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
156
- const { client } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
157
- yield integration.updateCrowdin(projectId, client, apiCredentials, chunk, rootFolder, intConfig);
158
- }
142
+ const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
143
+ yield integration.updateCrowdin(projectId, crowdinClient, apiCredentials, intFiles, rootFolder, intConfig);
159
144
  const newSyncSettingsFiels = allIntFiles.map((file) => (Object.assign(Object.assign({}, file), { schedule: true, sync: false })));
160
145
  if (newFiles) {
161
146
  yield (0, storage_1.getStorage)().updateSyncSettings(JSON.stringify(newSyncSettingsFiels), syncSettings.integrationId, syncSettings.crowdinId, 'schedule', syncSettings.provider);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.30.1",
3
+ "version": "0.30.3",
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",
@@ -32,9 +32,9 @@
32
32
  "devDependencies": {
33
33
  "@babel/preset-react": "^7.22.3",
34
34
  "@emotion/react": "^11.11.1",
35
- "@emotion/styled": "^11.10.6",
35
+ "@emotion/styled": "^11.11.0",
36
36
  "@mui/icons-material": "^5.11.16",
37
- "@mui/material": "^5.11.12",
37
+ "@mui/material": "^5.14.2",
38
38
  "@rjsf/core": "^5.7.3",
39
39
  "@rjsf/mui": "^5.7.3",
40
40
  "@rjsf/utils": "^5.7.3",
@@ -44,14 +44,14 @@
44
44
  "@rollup/plugin-json": "^6.0.0",
45
45
  "@rollup/plugin-node-resolve": "^15.0.1",
46
46
  "@rollup/plugin-replace": "^5.0.2",
47
- "@rollup/plugin-terser": "^0.4.0",
47
+ "@rollup/plugin-terser": "^0.4.3",
48
48
  "@types/amqplib": "^0.10.1",
49
49
  "@types/crypto-js": "^4.1.1",
50
50
  "@types/express": "4.17.17",
51
51
  "@types/express-handlebars": "^5.3.1",
52
52
  "@types/jest": "^29.5.2",
53
53
  "@types/node": "^12.20.55",
54
- "@types/node-cron": "^3.0.7",
54
+ "@types/node-cron": "^3.0.8",
55
55
  "@types/swagger-jsdoc": "^6.0.1",
56
56
  "@typescript-eslint/eslint-plugin": "^2.3.1",
57
57
  "@typescript-eslint/parser": "^2.3.1",