@crowdin/app-project-module 0.16.3 → 0.16.4
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 +3 -10
- package/out/handlers/custom-file-format/process.js +19 -7
- package/out/handlers/manifest.js +11 -22
- package/out/models/index.d.ts +8 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -173,9 +173,6 @@ const configuration = {
|
|
|
173
173
|
crowdinModule.createApp(configuration);
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
176
|
## Payment
|
|
180
177
|
|
|
181
178
|
By default App does not have any subscription and it's free to use. But you can override this.
|
|
@@ -540,14 +537,10 @@ const configuration = {
|
|
|
540
537
|
extensions: [
|
|
541
538
|
'.resx'
|
|
542
539
|
],
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
return { strings: [] };
|
|
546
|
-
},
|
|
547
|
-
buildFile: async (file, req, strings, client, context, projectId) => {
|
|
548
|
-
const isStringsExport = !!req.file.path;
|
|
540
|
+
exportStrings: async (req, strings, client, context, projectId) => {
|
|
541
|
+
const file = req.file;
|
|
549
542
|
//export logic
|
|
550
|
-
return { contentFile:
|
|
543
|
+
return { contentFile: '' }
|
|
551
544
|
}
|
|
552
545
|
}
|
|
553
546
|
};
|
|
@@ -29,7 +29,7 @@ function storeFile(fileContent, folder) {
|
|
|
29
29
|
}
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
32
|
-
function handleBuildFile(baseUrl, dataFolder, config,
|
|
32
|
+
function handleBuildFile(baseUrl, dataFolder, config, req, client, context, projectId, file) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const response = {};
|
|
35
35
|
if (!req.strings && !req.stringsUrl) {
|
|
@@ -42,7 +42,16 @@ function handleBuildFile(baseUrl, dataFolder, config, file, req, client, context
|
|
|
42
42
|
else {
|
|
43
43
|
strings = (yield axios_1.default.get(req.stringsUrl)).data;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
let res;
|
|
46
|
+
if ((req.file.id || !file) && config.exportStrings) {
|
|
47
|
+
res = yield config.exportStrings(req, strings, client, context, projectId);
|
|
48
|
+
}
|
|
49
|
+
else if (file && config.buildFile) {
|
|
50
|
+
res = yield config.buildFile(file, req, strings, client, context, projectId);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
46
55
|
const contentFileEncoded = Buffer.from(res.contentFile).toString('base64');
|
|
47
56
|
if (Buffer.byteLength(contentFileEncoded, 'utf8') < MAX_BODY_SIZE) {
|
|
48
57
|
response.content = contentFileEncoded;
|
|
@@ -54,9 +63,12 @@ function handleBuildFile(baseUrl, dataFolder, config, file, req, client, context
|
|
|
54
63
|
return response;
|
|
55
64
|
});
|
|
56
65
|
}
|
|
57
|
-
function handleParseFile(baseUrl, dataFolder, config,
|
|
66
|
+
function handleParseFile(baseUrl, dataFolder, config, req, client, context, projectId, file) {
|
|
58
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
68
|
const response = {};
|
|
69
|
+
if (!config.parseFile || !file) {
|
|
70
|
+
return response;
|
|
71
|
+
}
|
|
60
72
|
const res = yield config.parseFile(file, req, client, context, projectId);
|
|
61
73
|
if (res.previewFile) {
|
|
62
74
|
const previewFileEncoded = Buffer.from(res.previewFile).toString('base64');
|
|
@@ -103,16 +115,16 @@ function handle(baseConfig, baseUrl, folder, config) {
|
|
|
103
115
|
if (body.file.content) {
|
|
104
116
|
file = Buffer.from(body.file.content, 'base64').toString();
|
|
105
117
|
}
|
|
106
|
-
else {
|
|
107
|
-
file = (yield axios_1.default.get(body.file.contentUrl
|
|
118
|
+
else if (body.file.contentUrl) {
|
|
119
|
+
file = (yield axios_1.default.get(body.file.contentUrl)).data;
|
|
108
120
|
}
|
|
109
121
|
let response = {};
|
|
110
122
|
switch (body.jobType) {
|
|
111
123
|
case models_1.ProcessFileJobType.BUILD_FILE:
|
|
112
|
-
response = yield handleBuildFile(baseFilesUrl, folder, config,
|
|
124
|
+
response = yield handleBuildFile(baseFilesUrl, folder, config, body, req.crowdinApiClient, req.crowdinContext, req.crowdinContext.jwtPayload.context.project_id, file);
|
|
113
125
|
break;
|
|
114
126
|
case models_1.ProcessFileJobType.PARSE_FILE:
|
|
115
|
-
response = yield handleParseFile(baseFilesUrl, folder, config,
|
|
127
|
+
response = yield handleParseFile(baseFilesUrl, folder, config, body, req.crowdinApiClient, req.crowdinContext, req.crowdinContext.jwtPayload.context.project_id, file);
|
|
116
128
|
break;
|
|
117
129
|
}
|
|
118
130
|
(0, util_1.log)(`Returning response from process file action ${JSON.stringify(response, null, 2)}`, baseConfig.logger);
|
package/out/handlers/manifest.js
CHANGED
|
@@ -15,28 +15,17 @@ function handle(config) {
|
|
|
15
15
|
];
|
|
16
16
|
}
|
|
17
17
|
if (config.customFileFormat) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
else {
|
|
30
|
-
modules['custom-file-format'] = [
|
|
31
|
-
{
|
|
32
|
-
key: config.identifier + '-ff',
|
|
33
|
-
type: config.customFileFormat.type,
|
|
34
|
-
multilingual: !!config.customFileFormat.multilingual,
|
|
35
|
-
signaturePatterns: config.customFileFormat.signaturePatterns,
|
|
36
|
-
url: '/process',
|
|
37
|
-
},
|
|
38
|
-
];
|
|
39
|
-
}
|
|
18
|
+
modules['custom-file-format'] = [
|
|
19
|
+
{
|
|
20
|
+
key: config.identifier + '-ff',
|
|
21
|
+
type: config.customFileFormat.type,
|
|
22
|
+
stringsExport: !!config.customFileFormat.stringsExport,
|
|
23
|
+
multilingual: !!config.customFileFormat.multilingual,
|
|
24
|
+
extensions: config.customFileFormat.extensions,
|
|
25
|
+
signaturePatterns: config.customFileFormat.signaturePatterns,
|
|
26
|
+
url: '/process',
|
|
27
|
+
},
|
|
28
|
+
];
|
|
40
29
|
}
|
|
41
30
|
if (config.customMT) {
|
|
42
31
|
modules['custom-mt'] = [
|
package/out/models/index.d.ts
CHANGED
|
@@ -401,11 +401,15 @@ export interface CustomFileFormatLogic {
|
|
|
401
401
|
/**
|
|
402
402
|
* Used for initial source file upload, source file update, and translation upload
|
|
403
403
|
*/
|
|
404
|
-
parseFile
|
|
404
|
+
parseFile?: (fileContent: string | object, req: Omit<ProcessFileRequest, 'jobType' | 'file'>, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ParseFileResponse>;
|
|
405
405
|
/**
|
|
406
406
|
* Used for translation download
|
|
407
407
|
*/
|
|
408
|
-
buildFile
|
|
408
|
+
buildFile?: (fileContent: string | object, req: Omit<ProcessFileRequest, 'jobType' | 'file'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
409
|
+
/**
|
|
410
|
+
* Used for strings export
|
|
411
|
+
*/
|
|
412
|
+
exportStrings?: (req: Omit<ProcessFileRequest, 'jobType'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
409
413
|
}
|
|
410
414
|
export interface SignaturePatterns {
|
|
411
415
|
fileName?: string;
|
|
@@ -423,6 +427,8 @@ export interface ProcessFileRecord {
|
|
|
423
427
|
content?: string;
|
|
424
428
|
contentUrl?: string;
|
|
425
429
|
path?: string;
|
|
430
|
+
id?: number;
|
|
431
|
+
name?: string;
|
|
426
432
|
}
|
|
427
433
|
export declare enum ProcessFileJobType {
|
|
428
434
|
PARSE_FILE = "parse-file",
|
package/package.json
CHANGED