@crowdin/app-project-module 0.32.2 → 0.34.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.
@@ -53,6 +53,7 @@ function catchRejection(e, message) {
53
53
  subscriptionModal.open();
54
54
  return;
55
55
  }
56
+ console.error(e.message || message);
56
57
  showToast(e.message || message);
57
58
  }
58
59
 
@@ -1,4 +1,4 @@
1
- import { Config, CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncedFiles, IntegrationSyncSettings, Provider } from '../models';
1
+ import { Config, CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, Provider } from '../models';
2
2
  export interface Storage {
3
3
  migrate(): Promise<void>;
4
4
  saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
@@ -25,9 +25,6 @@ export interface Storage {
25
25
  saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: Provider): Promise<void>;
26
26
  updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: Provider): Promise<void>;
27
27
  getFilesSnapshot(integrationId: string, crowdinId: string, provider: Provider): Promise<IntegrationFilesSnapshot | undefined>;
28
- saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
29
- updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
30
- getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
31
28
  }
32
29
  export declare function initialize(config: Config): Promise<void>;
33
30
  export declare function getStorage(): Storage;
@@ -1,5 +1,5 @@
1
1
  import { Storage } from '.';
2
- import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncedFiles, IntegrationSyncSettings } from '../models';
2
+ import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings } from '../models';
3
3
  export interface MySQLStorageConfig {
4
4
  uri?: string;
5
5
  host?: string;
@@ -42,7 +42,4 @@ export declare class MySQLStorage implements Storage {
42
42
  saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
43
43
  updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
44
44
  getFilesSnapshot(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationFilesSnapshot | undefined>;
45
- saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
46
- updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
47
- getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
48
45
  }
@@ -114,15 +114,6 @@ class MySQLStorage {
114
114
  provider varchar(255) not null
115
115
  )
116
116
  `);
117
- yield connection.execute(`
118
- create table if not exists synced_files
119
- (
120
- id int auto_increment primary key,
121
- integration_id varchar(255) not null,
122
- crowdin_id varchar(255) not null,
123
- file_ids text
124
- )
125
- `);
126
117
  });
127
118
  }
128
119
  saveCrowdinCredentials(credentials) {
@@ -345,34 +336,5 @@ class MySQLStorage {
345
336
  }));
346
337
  });
347
338
  }
348
- saveSyncedFiles(fileIds, integrationId, crowdinId) {
349
- return __awaiter(this, void 0, void 0, function* () {
350
- yield this.dbPromise;
351
- yield this.executeQuery((connection) => connection.execute('INSERT INTO synced_files(file_ids, integration_id, crowdin_id) VALUES (?, ?, ?)', [
352
- fileIds,
353
- integrationId,
354
- crowdinId,
355
- ]));
356
- });
357
- }
358
- updateSyncedFiles(fileIds, integrationId, crowdinId) {
359
- return __awaiter(this, void 0, void 0, function* () {
360
- yield this.dbPromise;
361
- yield this.executeQuery((connection) => connection.execute('UPDATE synced_files SET file_ids = ? WHERE integration_id = ? AND crowdin_id = ?', [
362
- fileIds,
363
- integrationId,
364
- crowdinId,
365
- ]));
366
- });
367
- }
368
- getSyncedFiles(integrationId, crowdinId) {
369
- return __awaiter(this, void 0, void 0, function* () {
370
- yield this.dbPromise;
371
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
372
- const [rows] = yield connection.execute('SELECT id, file_ids as "fileIds", integration_id as "integrationId", crowdin_id as "crowdinId" FROM synced_files WHERE integration_id = ? AND crowdin_id = ?', [integrationId, crowdinId]);
373
- return (rows || [])[0];
374
- }));
375
- });
376
- }
377
339
  }
378
340
  exports.MySQLStorage = MySQLStorage;
@@ -1,6 +1,6 @@
1
1
  import { Client } from 'pg';
2
2
  import { Storage } from '.';
3
- import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncedFiles, IntegrationSyncSettings } from '../models';
3
+ import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings } from '../models';
4
4
  export interface PostgreStorageConfig {
5
5
  host?: string;
6
6
  connectionString?: string;
@@ -47,7 +47,4 @@ export declare class PostgreStorage implements Storage {
47
47
  saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
48
48
  updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
49
49
  getFilesSnapshot(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationFilesSnapshot | undefined>;
50
- saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
51
- updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
52
- getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
53
50
  }
@@ -128,15 +128,6 @@ class PostgreStorage {
128
128
  provider varchar not null
129
129
  )
130
130
  `);
131
- yield client.query(`
132
- create table if not exists synced_files
133
- (
134
- id serial primary key,
135
- integration_id varchar not null,
136
- crowdin_id varchar not null,
137
- file_ids varchar
138
- )
139
- `);
140
131
  });
141
132
  }
142
133
  saveCrowdinCredentials(credentials) {
@@ -359,34 +350,5 @@ class PostgreStorage {
359
350
  }));
360
351
  });
361
352
  }
362
- saveSyncedFiles(fileIds, integrationId, crowdinId) {
363
- return __awaiter(this, void 0, void 0, function* () {
364
- yield this.dbPromise;
365
- yield this.executeQuery((client) => client.query('INSERT INTO synced_files(file_ids, integration_id, crowdin_id) VALUES ($1, $2, $3)', [
366
- fileIds,
367
- integrationId,
368
- crowdinId,
369
- ]));
370
- });
371
- }
372
- updateSyncedFiles(fileIds, integrationId, crowdinId) {
373
- return __awaiter(this, void 0, void 0, function* () {
374
- yield this.dbPromise;
375
- yield this.executeQuery((client) => client.query('UPDATE synced_files SET file_ids = $1 WHERE integration_id = $2 AND crowdin_id = $3', [
376
- fileIds,
377
- integrationId,
378
- crowdinId,
379
- ]));
380
- });
381
- }
382
- getSyncedFiles(integrationId, crowdinId) {
383
- return __awaiter(this, void 0, void 0, function* () {
384
- yield this.dbPromise;
385
- return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
386
- const res = yield client.query('SELECT id, file_ids as "fileIds", integration_id as "integrationId", crowdin_id as "crowdinId" FROM synced_files WHERE integration_id = $1 AND crowdin_id = $2', [integrationId, crowdinId]);
387
- return res === null || res === void 0 ? void 0 : res.rows[0];
388
- }));
389
- });
390
- }
391
353
  }
392
354
  exports.PostgreStorage = PostgreStorage;
@@ -1,5 +1,5 @@
1
1
  import { Storage } from '.';
2
- import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncedFiles, IntegrationSyncSettings } from '../models';
2
+ import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings } from '../models';
3
3
  export interface SQLiteStorageConfig {
4
4
  dbFolder: string;
5
5
  }
@@ -41,7 +41,4 @@ export declare class SQLiteStorage implements Storage {
41
41
  saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
42
42
  updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
43
43
  getFilesSnapshot(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationFilesSnapshot | undefined>;
44
- saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
45
- updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
46
- getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
47
44
  }
@@ -185,15 +185,6 @@ class SQLiteStorage {
185
185
  files varchar null,
186
186
  provider varchar not null
187
187
  );
188
- `, []);
189
- yield this._run(`
190
- create table if not exists synced_files
191
- (
192
- id integer not null primary key autoincrement,
193
- integration_id varchar not null,
194
- crowdin_id varchar not null,
195
- file_ids varchar null
196
- );
197
188
  `, []);
198
189
  this._res && this._res();
199
190
  // TODO: temporary code
@@ -360,27 +351,5 @@ class SQLiteStorage {
360
351
  }
361
352
  });
362
353
  }
363
- saveSyncedFiles(fileIds, integrationId, crowdinId) {
364
- return this.run('INSERT INTO synced_files(file_ids, integration_id, crowdin_id) VALUES (?, ?, ?)', [
365
- fileIds,
366
- integrationId,
367
- crowdinId,
368
- ]);
369
- }
370
- updateSyncedFiles(fileIds, integrationId, crowdinId) {
371
- return this.run('UPDATE synced_files SET file_ids = ? WHERE integration_id = ? AND crowdin_id = ?', [
372
- fileIds,
373
- integrationId,
374
- crowdinId,
375
- ]);
376
- }
377
- getSyncedFiles(integrationId, crowdinId) {
378
- return __awaiter(this, void 0, void 0, function* () {
379
- const row = yield this.get('SELECT id, file_ids as fileIds, integration_id as integrationId, crowdin_id as crowdinId FROM synced_files WHERE integration_id = ? AND crowdin_id = ?', [integrationId, crowdinId]);
380
- if (row) {
381
- return row;
382
- }
383
- });
384
- }
385
354
  }
386
355
  exports.SQLiteStorage = SQLiteStorage;
@@ -58,7 +58,7 @@ function getOauthRoute(integration) {
58
58
  }
59
59
  exports.getOauthRoute = getOauthRoute;
60
60
  function applyIntegrationModuleDefaults(config, integration) {
61
- var _a;
61
+ var _a, _b;
62
62
  if (!integration.getCrowdinFiles) {
63
63
  integration.getCrowdinFiles = (projectId, client, rootFolder) => __awaiter(this, void 0, void 0, function* () {
64
64
  const allBranches = (yield client.sourceFilesApi.withFetchAll().listProjectBranches(projectId)).data.map((d) => d.data);
@@ -142,7 +142,7 @@ function applyIntegrationModuleDefaults(config, integration) {
142
142
  if (integration.withCronSync || integration.webhooks) {
143
143
  const getUserSettings = integration.getConfiguration;
144
144
  integration.getConfiguration = (projectId, crowdinClient, integrationCredentials) => __awaiter(this, void 0, void 0, function* () {
145
- var _b, _c;
145
+ var _c, _d;
146
146
  let fields = [];
147
147
  if (getUserSettings) {
148
148
  fields = yield getUserSettings(projectId, crowdinClient, integrationCredentials);
@@ -211,7 +211,7 @@ function applyIntegrationModuleDefaults(config, integration) {
211
211
  label: 'Webhooks',
212
212
  });
213
213
  }
214
- if ((_b = integration.syncNewElements) === null || _b === void 0 ? void 0 : _b.crowdin) {
214
+ if ((_c = integration.syncNewElements) === null || _c === void 0 ? void 0 : _c.crowdin) {
215
215
  defaultSettings.push({
216
216
  key: 'new-crowdin-files',
217
217
  label: 'Sync all new items from Crowdin',
@@ -221,7 +221,7 @@ function applyIntegrationModuleDefaults(config, integration) {
221
221
  ]),
222
222
  });
223
223
  }
224
- if ((_c = integration.syncNewElements) === null || _c === void 0 ? void 0 : _c.integration) {
224
+ if ((_d = integration.syncNewElements) === null || _d === void 0 ? void 0 : _d.integration) {
225
225
  defaultSettings.push({
226
226
  key: 'new-integration-files',
227
227
  label: `Sync all new items from ${config.name}`,
@@ -268,6 +268,9 @@ function applyIntegrationModuleDefaults(config, integration) {
268
268
  if (integration.webhooks && !((_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.urlParam)) {
269
269
  integration.webhooks.urlParam = 'crowdinData';
270
270
  }
271
+ if (!((_b = integration.filtering) === null || _b === void 0 ? void 0 : _b.hasOwnProperty('crowdinLanguages'))) {
272
+ integration.filtering = Object.assign(Object.assign({}, (integration.filtering || {})), { crowdinLanguages: true });
273
+ }
271
274
  }
272
275
  exports.applyIntegrationModuleDefaults = applyIntegrationModuleDefaults;
273
276
  function constructOauthUrl(config, integration) {
@@ -1,4 +1,4 @@
1
- import { Config } from '../models';
1
+ import { Config, CrowdinContextInfo } from '../models';
2
2
  export type LogFunction = (message: string) => void;
3
3
  export type LogErrorFunction = (error: any) => void;
4
4
  export type LogContext = {
@@ -7,8 +7,9 @@ export type LogContext = {
7
7
  projectId: number;
8
8
  };
9
9
  export declare function initialize(config: Config): void;
10
- export declare function withContext(context: LogContext): LogFunction;
11
- export declare function withContextError(context: LogContext): LogFunction;
12
- export declare function log(message: string, context?: LogContext): void;
13
- export declare function logError(e: any, context?: LogContext): void;
10
+ export declare function preprareContext(context: CrowdinContextInfo): LogContext;
11
+ export declare function withContext(context: CrowdinContextInfo): LogFunction;
12
+ export declare function withContextError(context: CrowdinContextInfo): LogFunction;
13
+ export declare function log(message: string, context?: CrowdinContextInfo): void;
14
+ export declare function logError(e: any, context?: CrowdinContextInfo): void;
14
15
  export declare function getErrorMessage(err: any): any;
@@ -1,6 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getErrorMessage = exports.logError = exports.log = exports.withContextError = exports.withContext = exports.initialize = void 0;
26
+ exports.getErrorMessage = exports.logError = exports.log = exports.withContextError = exports.withContext = exports.preprareContext = exports.initialize = void 0;
27
+ const logsFormatter = __importStar(require("@crowdin/logs-formatter"));
4
28
  let logConfig;
5
29
  let onError;
6
30
  function initialize(config) {
@@ -8,6 +32,14 @@ function initialize(config) {
8
32
  onError = config.onError;
9
33
  }
10
34
  exports.initialize = initialize;
35
+ function preprareContext(context) {
36
+ return {
37
+ orgId: context.crowdinId,
38
+ userId: context.clientId,
39
+ projectId: context.jwtPayload.context.project_id,
40
+ };
41
+ }
42
+ exports.preprareContext = preprareContext;
11
43
  function withContext(context) {
12
44
  return (message) => log(message, context);
13
45
  }
@@ -24,7 +56,16 @@ function log(message, context) {
24
56
  else {
25
57
  let prefix = `[${new Date().toISOString()}]`;
26
58
  if (context) {
27
- prefix += ` Context [${JSON.stringify(context)}]`;
59
+ logsFormatter.setContext({
60
+ project: {
61
+ id: context.jwtPayload.context.project_id,
62
+ // eslint-disable-next-line @typescript-eslint/camelcase
63
+ organization_id: context.jwtPayload.context.organization_id,
64
+ // eslint-disable-next-line @typescript-eslint/camelcase
65
+ user_id: context.jwtPayload.context.user_id,
66
+ },
67
+ });
68
+ prefix += ` Context [${JSON.stringify(preprareContext(context))}]`;
28
69
  }
29
70
  // eslint-disable-next-line no-console
30
71
  console.log(`${prefix} ${message}`);
@@ -39,7 +80,16 @@ function logError(e, context) {
39
80
  else {
40
81
  let message = `[${new Date().toISOString()}] Error.`;
41
82
  if (context) {
42
- message += ` Context ${JSON.stringify(context)}`;
83
+ logsFormatter.setContext({
84
+ project: {
85
+ id: context.jwtPayload.context.project_id,
86
+ // eslint-disable-next-line @typescript-eslint/camelcase
87
+ organization_id: context.jwtPayload.context.organization_id,
88
+ // eslint-disable-next-line @typescript-eslint/camelcase
89
+ user_id: context.jwtPayload.context.user_id,
90
+ },
91
+ });
92
+ message += ` Context ${JSON.stringify(preprareContext(context))}`;
43
93
  }
44
94
  if (isAxiosError(e)) {
45
95
  const request = e.config ? { url: e.config.url, method: e.config.method, data: e.config.data } : {};
@@ -13,27 +13,14 @@
13
13
  </div>
14
14
  </crowdin-alert>
15
15
  {{/if}}
16
- <div {{#if filtering}}class="top-button"{{/if}}>
17
- {{#if filtering}}
18
- <div class="integration-filter">
19
- <crowdin-integration-filter
20
- {{#if filtering.syncStatus}}
21
- enable-sync-status-filter
22
- {{/if}}
23
- integration-logo="logo.png"
24
- ></crowdin-integration-filter>
25
- </div>
16
+ <div>
17
+ {{#if infoModal}}
18
+ <crowdin-button icon-before="info" onclick="infoModal.open();">{{infoModal.title}}</crowdin-button>
26
19
  {{/if}}
27
-
28
- <div>
29
- {{#if infoModal}}
30
- <crowdin-button icon-before="info" onclick="infoModal.open();">{{infoModal.title}}</crowdin-button>
31
- {{/if}}
32
- {{#if configurationFields}}
33
- <crowdin-button icon-before="settings" onclick="settingsModal.open();fillSettingsForm();">Settings</crowdin-button>
34
- {{/if}}
35
- <crowdin-button icon-before="account_circle" onclick="integrationLogout()">Log out</crowdin-button>
36
- </div>
20
+ {{#if configurationFields}}
21
+ <crowdin-button icon-before="settings" onclick="settingsModal.open();fillSettingsForm();">Settings</crowdin-button>
22
+ {{/if}}
23
+ <crowdin-button icon-before="account_circle" onclick="integrationLogout()">Log out</crowdin-button>
37
24
  </div>
38
25
  {{#if uploadTranslations}}
39
26
  <crowdin-alert id="translation-info" no-icon="true" style="display: none;">
@@ -75,6 +62,9 @@
75
62
  {{#if uploadTranslations}}
76
63
  integration-button-menu-items='[{"label":"Upload Translations", "action":"uploadTranslations"}]'
77
64
  {{/if}}
65
+ {{#if filtering.crowdinLanguages}}
66
+ crowdin-filter
67
+ {{/if}}
78
68
  >
79
69
  </crowdin-simple-integration>
80
70
  </div>
@@ -186,9 +176,21 @@
186
176
  {{/ifeq}}
187
177
  {{else}}
188
178
  {{#if labelHtml}}
189
- <crowdin-p>{{labelHtml}}</crowdin-p>
179
+ <crowdin-p
180
+ {{#if dependencySettings}}
181
+ data-dependency="{{dependencySettings}}"
182
+ {{/if}}
183
+ >
184
+ {{{labelHtml}}}
185
+ </crowdin-p>
190
186
  {{else}}
191
- <crowdin-p>{{label}}</crowdin-p>
187
+ <crowdin-p
188
+ {{#if dependencySettings}}
189
+ data-dependency="{{dependencySettings}}"
190
+ {{/if}}
191
+ >
192
+ {{label}}
193
+ </crowdin-p>
192
194
  {{/if}}
193
195
  {{/if}}
194
196
  <div
@@ -263,11 +265,6 @@
263
265
  const appComponent = document.querySelector('crowdin-simple-integration');
264
266
  const subscriptionModal = document.getElementById('subscription-modal');
265
267
 
266
- {{#if filtering}}
267
- let syncedFiles = [];
268
- const filterIntegration = document.querySelector('crowdin-integration-filter');
269
- {{/if}}
270
-
271
268
  const folderType = '0';
272
269
  const fileType = '1';
273
270
  const branchType = '2';
@@ -299,6 +296,7 @@
299
296
  name: e.name,
300
297
  id: e.id,
301
298
  customContent: e.customContent,
299
+ labels: e.labels,
302
300
  };
303
301
  if (e.type) {
304
302
  item.type = e.type;
@@ -317,16 +315,10 @@
317
315
  .then((res) => {
318
316
  project = res;
319
317
  appComponent.setCrowdinLanguagesData(project.targetLanguages)
320
- {{#if filtering}}
321
- filterIntegration.setLanguages(project.targetLanguages)
322
- {{/if}}
323
318
  })
324
319
  {{#or withCronSync webhooks}}
325
320
  .then(() => getSyncSettings('crowdin'))
326
321
  {{/or}}
327
- {{#if filtering}}
328
- .then(() => getSyncedFiles())
329
- {{/if}}
330
322
  .catch(e => catchRejection(e, 'Can\'t fetch Crowdin data'))
331
323
  .finally(() => (appComponent.setAttribute('is-crowdin-loading', false)));
332
324
  }
@@ -345,6 +337,7 @@
345
337
  name: e.name,
346
338
  id: e.id,
347
339
  customContent: e.customContent,
340
+ labels: e.labels,
348
341
  };
349
342
  if (e.type) {
350
343
  item.type = e.type;
@@ -489,23 +482,21 @@
489
482
 
490
483
  function fillSettingsForm() {
491
484
  Object.entries(config).forEach(([key, value]) => {
492
- if (value) {
493
- const el = document.getElementById(`${key}-settings`);
494
- if (el) {
495
- if (el.tagName.toLowerCase() === 'crowdin-select') {
496
- if (el.hasAttribute('is-multi')) {
497
- el.value = JSON.stringify(value);
498
- } else {
499
- el.value = JSON.stringify([value]);
500
- }
501
- } else if (el.tagName.toLowerCase() === 'crowdin-checkbox') {
502
- el.checked = !!value;
485
+ const el = document.getElementById(`${key}-settings`);
486
+ if (el && (value || el.tagName.toLowerCase() === 'crowdin-checkbox')) {
487
+ if (el.tagName.toLowerCase() === 'crowdin-select') {
488
+ if (el.hasAttribute('is-multi')) {
489
+ el.value = JSON.stringify(value);
503
490
  } else {
504
- el.value = value;
491
+ el.value = JSON.stringify([value]);
505
492
  }
506
-
507
- triggerEvent(el, 'change');
493
+ } else if (el.tagName.toLowerCase() === 'crowdin-checkbox') {
494
+ el.checked = !!value;
495
+ } else {
496
+ el.value = value;
508
497
  }
498
+
499
+ triggerEvent(el, 'change');
509
500
  }
510
501
  });
511
502
  }
@@ -787,34 +778,6 @@
787
778
  }
788
779
  checkAlert(translationInfo);
789
780
  {{/if}}
790
-
791
- {{#if filtering}}
792
- document.body.addEventListener("integrationFilterChange", filterFiles);
793
-
794
- function filterFiles(event) {
795
- const filter = event.detail;
796
-
797
- if (filter.languages) {
798
- const languageIds = filter.languages === 'all' ? [] : [filter.languages];
799
- appComponent.filterCrowdinFilesByLanguages(languageIds);
800
- }
801
- if (filter.sync) {
802
- const fileId = filter.sync === 'all' ? [] : syncedFiles;
803
- appComponent.filterIntegrationFilesByIds(fileId, filter.sync !== 'not_synced');
804
- }
805
- }
806
-
807
- function getSyncedFiles() {
808
- checkOrigin()
809
- .then(restParams => fetch('/api/synced-files' + restParams))
810
- .then(checkResponse)
811
- .then((res) => {
812
- syncedFiles = res;
813
- })
814
- .catch(e => catchRejection(e, 'Can\'t fetch file progress'));
815
- }
816
-
817
- {{/if}}
818
781
  </script>
819
782
 
820
783
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.32.2",
3
+ "version": "0.34.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",
@@ -15,26 +15,27 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@crowdin/crowdin-apps-functions": "0.5.1",
18
+ "@crowdin/logs-formatter": "^2.0.3",
18
19
  "@godaddy/terminus": "^4.12.1",
19
- "@types/pg": "^8.6.6",
20
+ "@types/pg": "^8.10.2",
20
21
  "amqplib": "^0.10.3",
21
22
  "crypto-js": "^4.0.0",
22
23
  "express": "4.18.2",
23
24
  "express-handlebars": "^5.3.5",
24
25
  "mysql2": "^2.3.3",
25
26
  "node-cron": "^3.0.2",
26
- "pg": "^8.10.0",
27
+ "pg": "^8.11.3",
27
28
  "redoc-express": "^2.1.0",
28
29
  "sqlite3": "^5.1.6",
29
30
  "swagger-jsdoc": "^6.2.8",
30
31
  "uuid": "^8.3.2"
31
32
  },
32
33
  "devDependencies": {
33
- "@babel/preset-react": "^7.22.3",
34
+ "@babel/preset-react": "^7.22.5",
34
35
  "@emotion/react": "^11.11.1",
35
36
  "@emotion/styled": "^11.11.0",
36
- "@mui/icons-material": "^5.11.16",
37
- "@mui/material": "^5.14.2",
37
+ "@mui/icons-material": "^5.14.7",
38
+ "@mui/material": "^5.14.7",
38
39
  "@rjsf/core": "^5.7.3",
39
40
  "@rjsf/mui": "^5.7.3",
40
41
  "@rjsf/utils": "^5.7.3",
@@ -1,3 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- export default function handle(): (req: import("../../models").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const storage_1 = require("../../storage");
13
- const util_1 = require("../../util");
14
- function handle() {
15
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
- let fileIds = [];
17
- req.logInfo('Loading synced files');
18
- const syncedFiles = yield (0, storage_1.getStorage)().getSyncedFiles(req.crowdinContext.clientId, req.crowdinContext.crowdinId);
19
- if (syncedFiles) {
20
- fileIds = JSON.parse(syncedFiles.fileIds) || [];
21
- }
22
- req.logInfo(`Returning synced files ${JSON.stringify(fileIds, null, 2)}`);
23
- res.send(fileIds);
24
- }));
25
- }
26
- exports.default = handle;
@@ -1,2 +0,0 @@
1
- import { CreateOrUpdateSyncedFilesArgs } from '../models';
2
- export declare function createOrUpdateSyncedFiles(args: CreateOrUpdateSyncedFilesArgs): Promise<void>;