@crowdin/app-project-module 0.29.3 → 0.29.5

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.
@@ -21,6 +21,7 @@ export declare class PostgreStorage implements Storage {
21
21
  constructor(config: PostgreStorageConfig);
22
22
  executeQuery<T>(command: (client: Client) => Promise<T>): Promise<T>;
23
23
  migrate(): Promise<void>;
24
+ addColumns(client: Client): Promise<void>;
24
25
  addTables(client: Client): Promise<void>;
25
26
  saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
26
27
  updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
@@ -48,6 +48,8 @@ class PostgreStorage {
48
48
  try {
49
49
  yield this.executeQuery(this.addTables);
50
50
  this._res && this._res();
51
+ // TODO: temporary code
52
+ yield this.executeQuery(this.addColumns);
51
53
  }
52
54
  catch (e) {
53
55
  console.error(e);
@@ -55,6 +57,22 @@ class PostgreStorage {
55
57
  }
56
58
  });
57
59
  }
60
+ addColumns(client) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const tableName = 'app_metadata';
63
+ const newColumns = ['crowdin_id'];
64
+ const tableInfo = yield client.query('SELECT column_name FROM information_schema.columns WHERE table_name = $1', [tableName]);
65
+ tableInfo.rows.map((columnInfo) => __awaiter(this, void 0, void 0, function* () {
66
+ const index = newColumns.indexOf(columnInfo.column_name);
67
+ if (~index) {
68
+ newColumns.splice(index, 1);
69
+ }
70
+ }));
71
+ for (const column of newColumns) {
72
+ yield client.query(`ALTER TABLE ${tableName} ADD COLUMN ${column} varchar NULL;`);
73
+ }
74
+ });
75
+ }
58
76
  addTables(client) {
59
77
  return __awaiter(this, void 0, void 0, function* () {
60
78
  yield client.query(`
@@ -97,7 +115,7 @@ class PostgreStorage {
97
115
  (
98
116
  id varchar primary key,
99
117
  data varchar,
100
- crowdin_id varchar,
118
+ crowdin_id varchar
101
119
  )
102
120
  `);
103
121
  yield client.query(`
package/out/util/cron.js CHANGED
@@ -83,8 +83,8 @@ function filesCron(config, integration, period) {
83
83
  }
84
84
  const intConfig = integrationCredentials.config
85
85
  ? JSON.parse(integrationCredentials.config)
86
- : { schedule: '0', condition: '0' };
87
- if (period !== intConfig.schedule) {
86
+ : { syncType: '0', schedule: '0', condition: '0' };
87
+ if (period !== intConfig.schedule || intConfig.syncType !== '1') {
88
88
  return;
89
89
  }
90
90
  const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
@@ -231,11 +231,12 @@ function skipFoldersFromIntegrationRequest(config, integration, projectId, crowd
231
231
  if (rootFolder) {
232
232
  folders = (yield crowdinClient.sourceFilesApi.withFetchAll().listProjectDirectories(projectId, {
233
233
  directoryId: rootFolder.id,
234
+ recursion: 'true',
234
235
  })).data;
235
236
  }
236
237
  }
237
238
  else {
238
- folders = (yield crowdinClient.sourceFilesApi.withFetchAll().listProjectDirectories(projectId)).data;
239
+ folders = (yield crowdinClient.sourceFilesApi.withFetchAll().listProjectDirectories(projectId, { recursion: 'true' })).data;
239
240
  }
240
241
  if (folders) {
241
242
  for (const fileId of Object.keys(crowdinFiles)) {
@@ -214,7 +214,7 @@ function applyIntegrationModuleDefaults(config, integration) {
214
214
  if ((_b = integration.syncNewElements) === null || _b === void 0 ? void 0 : _b.crowdin) {
215
215
  defaultSettings.push({
216
216
  key: 'new-crowdin-files',
217
- label: 'Sync new items from Crowdin',
217
+ label: 'Sync all new items from Crowdin',
218
218
  type: 'checkbox',
219
219
  dependencySettings: JSON.stringify([
220
220
  { '#syncType-settings': { type: 'equal', value: ['1', '2'] } },
@@ -224,7 +224,7 @@ function applyIntegrationModuleDefaults(config, integration) {
224
224
  if ((_c = integration.syncNewElements) === null || _c === void 0 ? void 0 : _c.integration) {
225
225
  defaultSettings.push({
226
226
  key: 'new-integration-files',
227
- label: `Sync new items from ${config.name}`,
227
+ label: `Sync all new items from ${config.name}`,
228
228
  type: 'checkbox',
229
229
  dependencySettings: JSON.stringify([
230
230
  { '#syncType-settings': { type: 'equal', value: ['1', '2'] } },
@@ -117,6 +117,12 @@ function getIntegrationSnapshot(integration, integrationCredentials, integration
117
117
  if (integration.integrationOneLevelFetching) {
118
118
  files = yield getOneLevelFetchingFiles(integration, integrationCredentials, integrationSettings, files);
119
119
  }
120
+ // trick for compatibility in requests and set files
121
+ files = files.map((file) => (Object.assign(Object.assign({}, file), { parentId: file.parent_id || file.parentId,
122
+ // eslint-disable-next-line @typescript-eslint/camelcase
123
+ parent_id: file.parent_id || file.parentId,
124
+ // eslint-disable-next-line @typescript-eslint/camelcase
125
+ node_type: file.nodeType || file.node_type })));
120
126
  return files;
121
127
  });
122
128
  }
@@ -0,0 +1,7 @@
1
+ import express from 'express';
2
+ declare module 'express-serve-static-core' {
3
+ interface Application {
4
+ baseListen: any;
5
+ }
6
+ }
7
+ export default express;
@@ -0,0 +1,21 @@
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
+ const express_1 = __importDefault(require("express"));
7
+ const terminus_1 = require("@godaddy/terminus");
8
+ express_1.default.application.baseListen = express_1.default.application.listen;
9
+ express_1.default.application.listen = function (...args) {
10
+ const [port, callback] = args;
11
+ const server = this.baseListen.call(this, port);
12
+ if (callback) {
13
+ callback();
14
+ }
15
+ (0, terminus_1.createTerminus)(server, {
16
+ timeout: Infinity,
17
+ useExit0: true,
18
+ });
19
+ return server;
20
+ };
21
+ exports.default = express_1.default;
@@ -653,8 +653,10 @@
653
653
  }
654
654
 
655
655
  appComponent.setIntegrationScheduleSync(e.detail);
656
+ const syncedFiles = await appComponent.getIntegrationScheduleSync(true);
657
+ {{else}}
658
+ const syncedFiles = await appComponent.getIntegrationScheduleSync();
656
659
  {{/if}}
657
- const syncedFiles = await appComponent.getIntegrationScheduleSync();
658
660
  appComponent.setAttribute('is-integration-loading', true);
659
661
  updateSyncSettings(syncedFiles, 'schedule', 'integration');
660
662
  }
@@ -674,8 +676,10 @@
674
676
  }
675
677
 
676
678
  appComponent.setCrowdinScheduleSync(e.detail);
679
+ const syncedFiles = await appComponent.getCrowdinScheduleSync(true);
680
+ {{else}}
681
+ const syncedFiles = await appComponent.getCrowdinScheduleSync();
677
682
  {{/if}}
678
- const syncedFiles = await appComponent.getCrowdinScheduleSync();
679
683
  appComponent.setAttribute('is-crowdin-loading', true);
680
684
  updateSyncSettings(syncedFiles, 'schedule', 'crowdin');
681
685
  }
@@ -686,7 +690,11 @@
686
690
  return;
687
691
  }
688
692
  appComponent.setAttribute('is-integration-loading', true);
689
- const syncedFiles = await appComponent.getIntegrationScheduleSync();
693
+ {{#if syncNewElements.integration}}
694
+ const syncedFiles = await appComponent.getIntegrationScheduleSync(true);
695
+ {{else}}
696
+ const syncedFiles = await appComponent.getIntegrationScheduleSync();
697
+ {{/if}}
690
698
 
691
699
  updateSyncSettings(syncedFiles, 'schedule', 'integration');
692
700
  }
@@ -697,7 +705,11 @@
697
705
  return;
698
706
  }
699
707
  appComponent.setAttribute('is-crowdin-loading', true);
700
- const syncedFiles = await appComponent.getCrowdinScheduleSync();
708
+ {{#if syncNewElements.crowdin}}
709
+ const syncedFiles = await appComponent.getCrowdinScheduleSync(true);
710
+ {{else}}
711
+ const syncedFiles = await appComponent.getCrowdinScheduleSync();
712
+ {{/if}}
701
713
 
702
714
  updateSyncSettings(syncedFiles, 'schedule', 'crowdin');
703
715
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.29.3",
3
+ "version": "0.29.5",
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",
@@ -15,11 +15,12 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@crowdin/crowdin-apps-functions": "0.5.1",
18
+ "@godaddy/terminus": "^4.12.1",
18
19
  "@types/pg": "^8.6.6",
19
20
  "amqplib": "^0.10.3",
20
21
  "crypto-js": "^4.0.0",
21
22
  "express": "4.18.2",
22
- "express-handlebars": "^5.3.4",
23
+ "express-handlebars": "^5.3.5",
23
24
  "mysql2": "^2.3.3",
24
25
  "node-cron": "^3.0.2",
25
26
  "pg": "^8.10.0",
@@ -30,7 +31,7 @@
30
31
  },
31
32
  "devDependencies": {
32
33
  "@babel/preset-react": "^7.22.3",
33
- "@emotion/react": "^11.10.6",
34
+ "@emotion/react": "^11.11.1",
34
35
  "@emotion/styled": "^11.10.6",
35
36
  "@mui/icons-material": "^5.11.16",
36
37
  "@mui/material": "^5.11.12",
@@ -45,7 +46,7 @@
45
46
  "@rollup/plugin-replace": "^5.0.2",
46
47
  "@rollup/plugin-terser": "^0.4.0",
47
48
  "@types/amqplib": "^0.10.1",
48
- "@types/crypto-js": "^4.0.0",
49
+ "@types/crypto-js": "^4.1.1",
49
50
  "@types/express": "4.17.17",
50
51
  "@types/express-handlebars": "^5.3.1",
51
52
  "@types/jest": "^29.5.2",
@@ -63,7 +64,7 @@
63
64
  "react": "^18.2.0",
64
65
  "react-dom": "^18.2.0",
65
66
  "rollup": "^3.20.2",
66
- "ts-jest": "^29.1.0",
67
+ "ts-jest": "^29.1.1",
67
68
  "typescript": "^4.9.5"
68
69
  },
69
70
  "repository": {