@crowdin/app-project-module 0.45.1 → 0.46.0

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 (27) hide show
  1. package/out/app-test/crowdin-responses/mock-get-project.json +202 -0
  2. package/out/app-test/crowdin-responses/mock-list-supported-languages.json +7368 -0
  3. package/out/app-test/index.d.ts +6 -0
  4. package/out/app-test/index.js +13 -0
  5. package/out/app-test/integration/get-integration-files.d.ts +6 -0
  6. package/out/app-test/integration/get-integration-files.js +70 -0
  7. package/out/app-test/integration/index.d.ts +15 -0
  8. package/out/app-test/integration/index.js +73 -0
  9. package/out/app-test/integration/mocks/crowdin-storage.d.ts +35 -0
  10. package/out/app-test/integration/mocks/crowdin-storage.js +47 -0
  11. package/out/app-test/integration/mocks/mock-axios.d.ts +1 -0
  12. package/out/app-test/integration/mocks/mock-axios.js +18 -0
  13. package/out/app-test/integration/mocks/mock-crowdin-api-client.d.ts +1 -0
  14. package/out/app-test/integration/mocks/mock-crowdin-api-client.js +132 -0
  15. package/out/app-test/integration/types.d.ts +41 -0
  16. package/out/app-test/integration/types.js +2 -0
  17. package/out/app-test/integration/update-crowdin.d.ts +6 -0
  18. package/out/app-test/integration/update-crowdin.js +137 -0
  19. package/out/app-test/integration/update-integration.d.ts +8 -0
  20. package/out/app-test/integration/update-integration.js +78 -0
  21. package/out/app-test/types.d.ts +4 -0
  22. package/out/app-test/types.js +2 -0
  23. package/out/app-test/util/index.d.ts +1 -0
  24. package/out/app-test/util/index.js +24 -0
  25. package/out/modules/integration/util/job.js +1 -0
  26. package/out/views/main.handlebars +2 -2
  27. package/package.json +1 -1
@@ -0,0 +1,78 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.updateIntegrationTest = exports.getUpdateIntegrationRequest = void 0;
16
+ const globals_1 = require("@jest/globals");
17
+ const crowdin_api_client_1 = __importDefault(require("@crowdin/crowdin-api-client"));
18
+ const types_1 = require("../../modules/integration/util/types");
19
+ const index_1 = require("./index");
20
+ const crowdin_storage_1 = require("./mocks/crowdin-storage");
21
+ const util_1 = require("../util");
22
+ const getUpdateIntegrationRequest = () => {
23
+ const request = {};
24
+ index_1.mockFiles.forEach((file) => {
25
+ request[file.id] = ['es'];
26
+ });
27
+ return request;
28
+ };
29
+ exports.getUpdateIntegrationRequest = getUpdateIntegrationRequest;
30
+ const updateIntegrationTest = ({ appConfig, integrationTestConfig, }) => __awaiter(void 0, void 0, void 0, function* () {
31
+ if (!appConfig.projectIntegration) {
32
+ throw new Error('The app configuration is missing the projectIntegration module.');
33
+ }
34
+ const { updateIntegration, appSettings, integrationCredentials } = integrationTestConfig;
35
+ const client = new crowdin_api_client_1.default({ token: 'fakeToken' });
36
+ const updateProgressMock = jest.fn(() => __awaiter(void 0, void 0, void 0, function* () {
37
+ return { isCanceled: false };
38
+ }));
39
+ const request = (0, exports.getUpdateIntegrationRequest)();
40
+ const result = yield (0, util_1.assert)(() => {
41
+ var _a;
42
+ return (_a = appConfig.projectIntegration) === null || _a === void 0 ? void 0 : _a.updateIntegration({
43
+ projectId: index_1.mockProjectId,
44
+ client,
45
+ credentials: integrationCredentials,
46
+ request,
47
+ rootFolder: (0, crowdin_storage_1.getRootFolder)(appConfig),
48
+ appSettings,
49
+ job: {
50
+ get: function getJob() {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ return {
53
+ id: 'jobId1',
54
+ integrationId: 'string',
55
+ crowdinId: 'string',
56
+ type: types_1.JobType.UPDATE_TO_INTEGRATION,
57
+ title: 'Sync files to ' + appConfig.name,
58
+ progress: 0,
59
+ status: types_1.JobStatus.CREATED,
60
+ createdAt: 0,
61
+ };
62
+ });
63
+ },
64
+ update: updateProgressMock,
65
+ },
66
+ });
67
+ }, 'Fail to run method updateIntegration()');
68
+ if (!(updateIntegration === null || updateIntegration === void 0 ? void 0 : updateIntegration.updateProgressDisabled)) {
69
+ yield (0, util_1.assert)(() => (0, globals_1.expect)(updateProgressMock.mock.calls.length).toBeGreaterThanOrEqual(Object.keys(request).length), 'The sync progress should be updated at least once for each file in request');
70
+ }
71
+ if (updateIntegration === null || updateIntegration === void 0 ? void 0 : updateIntegration.extraChecks) {
72
+ yield (0, util_1.assert)(
73
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
74
+ // @ts-ignore
75
+ () => updateIntegration.extraChecks({ request, result }), 'ExtraChecks for updateIntegration() fails');
76
+ }
77
+ });
78
+ exports.updateIntegrationTest = updateIntegrationTest;
@@ -0,0 +1,4 @@
1
+ import { IntegrationTestConfig } from './integration/types';
2
+ export interface TestSuiteConfig {
3
+ projectIntegration?: IntegrationTestConfig;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare function assert(matcher: Function, error: string): Promise<unknown>;
@@ -0,0 +1,24 @@
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
+ exports.assert = void 0;
13
+ function assert(matcher, error) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ try {
16
+ return yield matcher();
17
+ }
18
+ catch (e) {
19
+ e.message = error + '\n\n' + e.message;
20
+ throw e;
21
+ }
22
+ });
23
+ }
24
+ exports.assert = assert;
@@ -29,6 +29,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, jobCall
29
29
  if (res) {
30
30
  res.status(202).send({ jobId: existingJob.id, message: 'Another sync is running' });
31
31
  }
32
+ (0, logger_1.log)(`Unable to run new job '${type}', with title '${title}', already running jobId ${existingJob.id}.`);
32
33
  return;
33
34
  }
34
35
  }
@@ -446,9 +446,9 @@
446
446
  return;
447
447
  }
448
448
 
449
- const selectedIds = selection.map(({id}) => id);
449
+ const selectedIds = selection.map(({id}) => id.toString());
450
450
  tree.forEach((node) => {
451
- selectedIds.includes(node.parent_id) && selectedIds.push(node.id);
451
+ selectedIds.includes(node.parent_id.toString()) && selectedIds.push(node.id.toString());
452
452
  });
453
453
  appIntegrationFiles.setSelected(selectedIds);
454
454
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.45.1",
3
+ "version": "0.46.0",
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",