@crowdin/app-project-module 2.5.0 → 2.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.
@@ -2,14 +2,14 @@ import { CrowdinContextInfo, ModuleKey } from '../../types';
2
2
  import Crowdin from '@crowdin/crowdin-api-client';
3
3
  export interface AiRequestProcessorModule extends ModuleKey {
4
4
  /**
5
- * updates request data
5
+ * updates request data; the returned value is sent back as the processed request
6
6
  */
7
7
  processRequest: (options: {
8
8
  requestData: any;
9
9
  requestContext: any;
10
10
  client: Crowdin;
11
11
  context: CrowdinContextInfo;
12
- }) => Promise<never>;
12
+ }) => Promise<any>;
13
13
  }
14
14
  export interface AiStreamProcessorModule extends AiRequestProcessorModule {
15
15
  /**
@@ -1,5 +1,11 @@
1
1
  import { CrowdinContextInfo, Environments, ModuleKey, UiModule } from '../../types';
2
2
  import Crowdin, { SourceFilesModel, ProjectsGroupsModel, LanguagesModel, SourceStringsModel, StringTranslationsModel } from '@crowdin/crowdin-api-client';
3
+ export interface QaCheckTranslation extends StringTranslationsModel.StringTranslation {
4
+ /**
5
+ * id of the source string this translation belongs to
6
+ */
7
+ stringId: number;
8
+ }
3
9
  export interface ExternalQaCheckModule extends Environments, ModuleKey {
4
10
  /**
5
11
  * module description
@@ -20,7 +26,7 @@ export interface ExternalQaCheckModule extends Environments, ModuleKey {
20
26
  sourceLanguage: LanguagesModel.Language;
21
27
  strings: SourceStringsModel.String[];
22
28
  targetLanguage: LanguagesModel.Language;
23
- translations: StringTranslationsModel.StringTranslation[];
29
+ translations: QaCheckTranslation[];
24
30
  context: CrowdinContextInfo;
25
31
  }) => Promise<ExternalQaCheckResponse>;
26
32
  /**
@@ -34,7 +40,7 @@ export interface ExternalQaCheckRequest {
34
40
  sourceLanguage: LanguagesModel.Language;
35
41
  strings: SourceStringsModel.String[];
36
42
  targetLanguage: LanguagesModel.Language;
37
- translations: StringTranslationsModel.StringTranslation[];
43
+ translations: QaCheckTranslation[];
38
44
  }
39
45
  interface SuggestedFix {
40
46
  indexStart: number;
@@ -16,6 +16,7 @@ exports.filterFilesFromIntegrationRequest = filterFilesFromIntegrationRequest;
16
16
  exports.createOrUpdateSyncSettings = createOrUpdateSyncSettings;
17
17
  exports.removeFinishedJobs = removeFinishedJobs;
18
18
  const storage_1 = require("../../../storage");
19
+ const util_1 = require("../../../util");
19
20
  const token_1 = require("../../../util/app-functions/token");
20
21
  const connection_1 = require("../../../util/connection");
21
22
  const logger_1 = require("../../../util/logger");
@@ -486,14 +487,25 @@ function getAllNewFiles(_a) {
486
487
  function getNewFoldersFile(folders, snapshotFiles) {
487
488
  let files = [];
488
489
  for (const folder of folders) {
489
- const folderFiles = snapshotFiles.filter((file) => Number(file.parentId) === Number(folder.id));
490
+ const folderFiles = snapshotFiles.filter((file) => isSameFolder(file.parentId, folder.id));
490
491
  if (folderFiles.length) {
491
492
  files = files.concat(folderFiles);
492
493
  }
493
494
  }
494
- files = files.filter((file) => 'type' in file);
495
+ files = (0, util_1.uniqBy)(files, 'id').filter((file) => Boolean(file.type));
495
496
  return files;
496
497
  }
498
+ function isSameFolder(parentId, folderId) {
499
+ if (parentId === null || parentId === undefined || folderId === null || folderId === undefined) {
500
+ return false;
501
+ }
502
+ const numParentId = Number(parentId);
503
+ const numFolderId = Number(folderId);
504
+ if (!Number.isNaN(numParentId) && !Number.isNaN(numFolderId)) {
505
+ return numParentId === numFolderId;
506
+ }
507
+ return String(parentId) === String(folderId) || String(parentId).startsWith(`${folderId}/`);
508
+ }
497
509
  function getOnlyTranslatedOrApprovedFiles(_a) {
498
510
  return __awaiter(this, arguments, void 0, function* ({ projectId, crowdinFiles, crowdinClient, onlyApproved, onlyTranslated, context, integration, }) {
499
511
  const deletedFiles = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "2.5.0",
3
+ "version": "2.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",