@crowdin/app-project-module 0.26.6 → 0.27.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.
package/README.md
CHANGED
|
@@ -129,6 +129,28 @@ const configuration = {
|
|
|
129
129
|
stopPagination: true, //send if no next files page
|
|
130
130
|
};
|
|
131
131
|
},
|
|
132
|
+
getFileProgress: async (projectId, client, fileId) => { //Use this function if you require a customized translation progress.
|
|
133
|
+
return {
|
|
134
|
+
[fileId]: [
|
|
135
|
+
{
|
|
136
|
+
languageId: 'uk',
|
|
137
|
+
eTag: '49a76a1632973b00175dac942976f7c6',
|
|
138
|
+
words: {
|
|
139
|
+
total: 180,
|
|
140
|
+
translated: 0,
|
|
141
|
+
approved: 0
|
|
142
|
+
},
|
|
143
|
+
phrases: {
|
|
144
|
+
total: 6,
|
|
145
|
+
translated: 0,
|
|
146
|
+
approved: 0
|
|
147
|
+
},
|
|
148
|
+
translationProgress: 100,
|
|
149
|
+
approvalProgress: 0
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
132
154
|
updateCrowdin: async (projectId, client, credentials, request, rootFolder, appSettings) => {
|
|
133
155
|
//here you need to get data from integration and upload it to Crowdin
|
|
134
156
|
console.log(`Request for updating data in Crowdin ${JSON.stringify(request)}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config } from '../models';
|
|
4
|
-
export default function handle(config: Config): (req: 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;
|
|
3
|
+
import { Config, IntegrationLogic } from '../models';
|
|
4
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: 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;
|
|
@@ -10,13 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const util_1 = require("../util");
|
|
13
|
-
function handle(config) {
|
|
13
|
+
function handle(config, integration) {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
const fileId = Number(req.params.fileId);
|
|
16
16
|
(0, util_1.log)(`Loading translation progress for file ${fileId}`, config.logger);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (integration.getFileProgress) {
|
|
18
|
+
const progress = yield integration.getFileProgress(req.crowdinContext.jwtPayload.context.project_id, req.crowdinApiClient, fileId);
|
|
19
|
+
(0, util_1.log)(`Translation progress for file ${fileId} ${JSON.stringify(progress, null, 2)}`, config.logger);
|
|
20
|
+
res.send(progress);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
res.send({});
|
|
24
|
+
}
|
|
20
25
|
}), config.onError);
|
|
21
26
|
}
|
|
22
27
|
exports.default = handle;
|
package/out/index.js
CHANGED
|
@@ -115,7 +115,7 @@ function addCrowdinEndpoints(app, plainConfig) {
|
|
|
115
115
|
app.post('/api/logout', (0, crowdin_client_1.default)(config, false, false), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_logout_1.default)(config, integrationLogic));
|
|
116
116
|
app.get('/api/crowdin/files', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_files_1.default)(config, integrationLogic));
|
|
117
117
|
app.get('/api/crowdin/project', json_response_1.default, (0, crowdin_client_1.default)(config), (0, crowdin_project_1.default)(config));
|
|
118
|
-
app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(config));
|
|
118
|
+
app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(config, integrationLogic));
|
|
119
119
|
app.get('/api/integration/data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_data_1.default)(config, integrationLogic));
|
|
120
120
|
app.post('/api/crowdin/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_update_1.default)(config, integrationLogic));
|
|
121
121
|
app.post('/api/integration/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_update_1.default)(config, integrationLogic));
|
package/out/models/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Crowdin, { LanguagesModel, SourceFilesModel, SourceStringsModel } from '@crowdin/crowdin-api-client';
|
|
1
|
+
import Crowdin, { LanguagesModel, SourceFilesModel, SourceStringsModel, TranslationStatusModel } from '@crowdin/crowdin-api-client';
|
|
2
2
|
import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
|
|
3
3
|
import { Request } from 'express';
|
|
4
4
|
import { MySQLStorageConfig } from '../storage/mysql';
|
|
@@ -235,6 +235,12 @@ export interface IntegrationLogic {
|
|
|
235
235
|
* Enable integration next page event
|
|
236
236
|
*/
|
|
237
237
|
integrationPagination?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* function to get crowdin file translation progress
|
|
240
|
+
*/
|
|
241
|
+
getFileProgress?: (projectId: number, client: Crowdin, fileId: number) => Promise<{
|
|
242
|
+
[key: number]: TranslationStatusModel.LanguageProgress[];
|
|
243
|
+
}>;
|
|
238
244
|
}
|
|
239
245
|
export declare type FormEntity = FormField | FormDelimeter;
|
|
240
246
|
export interface FormDelimeter {
|
package/out/util/defaults.js
CHANGED
|
@@ -118,6 +118,12 @@ function applyDefaults(config, integration) {
|
|
|
118
118
|
return res;
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
+
if (!integration.getFileProgress) {
|
|
122
|
+
integration.getFileProgress = (projectId, client, fileId) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
const progress = yield client.translationStatusApi.getFileProgress(projectId, fileId);
|
|
124
|
+
return { [fileId]: progress.data.map((e) => e.data) };
|
|
125
|
+
});
|
|
126
|
+
}
|
|
121
127
|
if (!integration.loginForm) {
|
|
122
128
|
integration.loginForm = {
|
|
123
129
|
fields: [
|
package/package.json
CHANGED