@crowdin/app-project-module 0.45.1 → 0.46.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.
- package/out/app-test/crowdin-responses/mock-get-project.json +202 -0
- package/out/app-test/crowdin-responses/mock-list-supported-languages.json +7368 -0
- package/out/app-test/index.d.ts +6 -0
- package/out/app-test/index.js +13 -0
- package/out/app-test/integration/get-integration-files.d.ts +6 -0
- package/out/app-test/integration/get-integration-files.js +70 -0
- package/out/app-test/integration/index.d.ts +15 -0
- package/out/app-test/integration/index.js +73 -0
- package/out/app-test/integration/mocks/crowdin-storage.d.ts +35 -0
- package/out/app-test/integration/mocks/crowdin-storage.js +47 -0
- package/out/app-test/integration/mocks/mock-axios.d.ts +1 -0
- package/out/app-test/integration/mocks/mock-axios.js +18 -0
- package/out/app-test/integration/mocks/mock-crowdin-api-client.d.ts +1 -0
- package/out/app-test/integration/mocks/mock-crowdin-api-client.js +132 -0
- package/out/app-test/integration/types.d.ts +41 -0
- package/out/app-test/integration/types.js +2 -0
- package/out/app-test/integration/update-crowdin.d.ts +6 -0
- package/out/app-test/integration/update-crowdin.js +137 -0
- package/out/app-test/integration/update-integration.d.ts +8 -0
- package/out/app-test/integration/update-integration.js +78 -0
- package/out/app-test/types.d.ts +4 -0
- package/out/app-test/types.js +2 -0
- package/out/app-test/util/index.d.ts +1 -0
- package/out/app-test/util/index.js +24 -0
- package/out/index.js +1 -1
- package/out/modules/custom-spell-check/handlers/get-languages-list.js +3 -1
- package/out/modules/custom-spell-check/types.d.ts +2 -2
- package/out/modules/integration/util/job.js +1 -0
- package/out/views/main.handlebars +2 -2
- 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 @@
|
|
|
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;
|
package/out/index.js
CHANGED
|
@@ -141,7 +141,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
141
141
|
contextMenuApp.register({ config, app });
|
|
142
142
|
//other apps only work in authorized context
|
|
143
143
|
if (!(0, util_1.isAuthorizedConfig)(config)) {
|
|
144
|
-
return {};
|
|
144
|
+
return Object.assign({}, exports.metadataStore);
|
|
145
145
|
}
|
|
146
146
|
app.post('/installed', (0, install_1.default)(config));
|
|
147
147
|
app.post('/uninstall', (0, uninstall_1.default)(config));
|
|
@@ -41,8 +41,8 @@ export interface CustomSpellcheckerModule extends Environments {
|
|
|
41
41
|
* function to get list of supported languages that are supports by current spellchecker
|
|
42
42
|
*/
|
|
43
43
|
getSupportedLanguage: ({ client, context, }: {
|
|
44
|
-
client
|
|
45
|
-
context
|
|
44
|
+
client?: Crowdin;
|
|
45
|
+
context?: CrowdinContextInfo;
|
|
46
46
|
}) => Promise<SupportedLanguage[]>;
|
|
47
47
|
/**
|
|
48
48
|
* function to check spelling
|
|
@@ -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