@crowdin/app-project-module 0.94.0 → 0.94.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.
@@ -149,7 +149,7 @@ function filesCron({ config, integration, period, }) {
149
149
  }
150
150
  exports.filesCron = filesCron;
151
151
  function processSyncSettings({ config, integration, period, syncSettings, }) {
152
- var _a;
152
+ var _a, _b, _c;
153
153
  return __awaiter(this, void 0, void 0, function* () {
154
154
  let projectData;
155
155
  let crowdinClient;
@@ -330,12 +330,32 @@ function processSyncSettings({ config, integration, period, syncSettings, }) {
330
330
  parent_id: file.parent_id || file.parentId,
331
331
  // eslint-disable-next-line @typescript-eslint/camelcase
332
332
  node_type: file.nodeType || file.node_type }, (file.type ? { type: file.type } : {}))));
333
- const intFiles = allIntFiles.filter((file) => 'type' in file);
333
+ let intFiles = allIntFiles.filter((file) => 'type' in file);
334
334
  if (intFiles.length <= 0) {
335
335
  return;
336
336
  }
337
337
  (0, logger_1.log)(`Executing updateCrowdin task for files cron job with period [${period}] for project ${projectId}. Files ${intFiles.length}`);
338
338
  const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
339
+ if (integration.filterByPathIntegrationFiles) {
340
+ const includePatterns = (_b = intConfig === null || intConfig === void 0 ? void 0 : intConfig.includeByFilePath) === null || _b === void 0 ? void 0 : _b.split('\n').filter(Boolean);
341
+ const excludePatterns = (_c = intConfig === null || intConfig === void 0 ? void 0 : intConfig.excludeByFilePath) === null || _c === void 0 ? void 0 : _c.split('\n').filter(Boolean);
342
+ try {
343
+ const fullTreeResult = yield integration.getIntegrationFiles(apiCredentials, intConfig);
344
+ const fullTree = (0, files_1.isExtendedResultType)(fullTreeResult) ? fullTreeResult.data || [] : fullTreeResult;
345
+ const filteredFiles = (0, files_1.filterFilesByPath)(fullTree, includePatterns, excludePatterns);
346
+ const filteredFileIds = new Set(filteredFiles.map((f) => f.id));
347
+ const filteredIntFiles = intFiles.filter((file) => filteredFileIds.has(file.id));
348
+ (0, logger_1.log)(`Path filtering applied: ${intFiles.length} -> ${filteredIntFiles.length} files`);
349
+ if (filteredIntFiles.length === 0) {
350
+ (0, logger_1.log)('No files passed path filtering, skipping sync');
351
+ return;
352
+ }
353
+ intFiles = filteredIntFiles;
354
+ }
355
+ catch (e) {
356
+ (0, logger_1.logError)(e, context);
357
+ }
358
+ }
339
359
  try {
340
360
  yield runUpdateProviderJob({
341
361
  integrationId: syncSettings.integrationId,
@@ -228,24 +228,26 @@ function applyIntegrationModuleDefaults(config, integration) {
228
228
  if (integration.uploadTranslations) {
229
229
  defaultSettings.push({
230
230
  labelHtml: `<b>Translation sync settings (${config.name} → Crowdin)</b>`,
231
+ category: types_1.DefaultCategory.SYNC,
232
+ position: 3,
231
233
  }, {
232
234
  key: 'importEqSuggestions',
233
235
  label: 'Add translations that are the same as the source text',
234
236
  type: 'checkbox',
235
237
  category: types_1.DefaultCategory.SYNC,
236
- position: 3,
238
+ position: 4,
237
239
  }, {
238
240
  key: 'autoApproveImported',
239
241
  label: 'Mark added translations as Approved in Crowdin',
240
242
  type: 'checkbox',
241
243
  category: types_1.DefaultCategory.SYNC,
242
- position: 4,
244
+ position: 5,
243
245
  }, {
244
246
  key: 'translateHidden',
245
247
  label: 'Add translations for hidden source strings in Crowdin',
246
248
  type: 'checkbox',
247
249
  category: types_1.DefaultCategory.SYNC,
248
- position: 5,
250
+ position: 6,
249
251
  });
250
252
  }
251
253
  defaultSettings.push({
@@ -255,7 +257,7 @@ function applyIntegrationModuleDefaults(config, integration) {
255
257
  defaultValue: '0',
256
258
  dependencySettings: JSON.stringify([{ '#schedule-settings': { type: '!equal', value: ['0'] } }]),
257
259
  category: types_1.DefaultCategory.SYNC,
258
- position: 6,
260
+ position: 7,
259
261
  options: [
260
262
  {
261
263
  value: '0',
@@ -295,7 +297,6 @@ function applyIntegrationModuleDefaults(config, integration) {
295
297
  helpText: integration.skipIntegrationNodesToggle.description,
296
298
  defaultValue: integration.skipIntegrationNodesToggle.value,
297
299
  category: types_1.DefaultCategory.GENERAL,
298
- position: 7,
299
300
  });
300
301
  }
301
302
  return [...defaultSettings, ...fields];
@@ -14,6 +14,7 @@ export declare const TABLES: {
14
14
  job: string;
15
15
  translation_file_cache: string;
16
16
  unsynced_files: string;
17
+ synced_data: string;
17
18
  };
18
19
  export interface Storage {
19
20
  tables: typeof TABLES;
@@ -58,6 +58,7 @@ exports.TABLES = {
58
58
  job: 'job',
59
59
  translation_file_cache: 'translation_file_cache',
60
60
  unsynced_files: 'unsynced_files',
61
+ synced_data: 'synced_data',
61
62
  };
62
63
  let storage;
63
64
  function initialize(config) {
@@ -44,6 +44,7 @@ export declare class PostgreStorage implements Storage {
44
44
  tableIndexes: TableIndexes;
45
45
  constructor(config: PostgreStorageConfig, directoryPath: string | null);
46
46
  executeQuery<T>(command: (client: Client) => Promise<T>): Promise<T>;
47
+ private hasDumpFiles;
47
48
  migrate(): Promise<void>;
48
49
  alterTables(client: Client): Promise<void>;
49
50
  addColumns(client: Client, newColumns: string[], tableName: string): Promise<void>;
@@ -194,10 +194,18 @@ class PostgreStorage {
194
194
  }));
195
195
  });
196
196
  }
197
+ hasDumpFiles(directoryPath) {
198
+ if (!fs_1.default.existsSync(directoryPath)) {
199
+ return false;
200
+ }
201
+ const [name, extension] = types_1.storageFiles.DUMP.split('%s');
202
+ const files = fs_1.default.readdirSync(directoryPath).filter((file) => file.startsWith(name) && file.endsWith(extension));
203
+ return files.length > 0;
204
+ }
197
205
  migrate() {
198
206
  return __awaiter(this, void 0, void 0, function* () {
199
207
  try {
200
- if (this.directoryPath && fs_1.default.existsSync(this.directoryPath + '/' + types_1.storageFiles.SQLITE)) {
208
+ if (this.directoryPath && this.hasDumpFiles(this.directoryPath)) {
201
209
  yield this.migrateFromSqlite(this.directoryPath);
202
210
  }
203
211
  yield this.executeQuery((client) => this.addTables(client));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.94.0",
3
+ "version": "0.94.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",