@crowdin/app-project-module 0.18.1 → 0.18.2
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
|
@@ -573,6 +573,15 @@ const configuration = {
|
|
|
573
573
|
crowdinModule.createApp(configuration);
|
|
574
574
|
```
|
|
575
575
|
|
|
576
|
+
By default custom file format will use `filesFolder` as a temporary folder to store huge responses. But it can be overridden:
|
|
577
|
+
|
|
578
|
+
```javascript
|
|
579
|
+
configuration.customFileFormat.storeFile = (content) => {
|
|
580
|
+
//logic to store file, e.g. put it to AWS S3
|
|
581
|
+
return '<url-to-download>';
|
|
582
|
+
};
|
|
583
|
+
```
|
|
584
|
+
|
|
576
585
|
### Custom MT
|
|
577
586
|
|
|
578
587
|
Example of [custom mt module](https://support.crowdin.com/crowdin-apps-modules/#custom-mt-machine-translation-module).
|
|
@@ -57,8 +57,15 @@ function handleBuildFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
57
57
|
response.content = contentFileEncoded;
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
let url;
|
|
61
|
+
if (config.storeFile) {
|
|
62
|
+
url = yield config.storeFile(res.contentFile);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const storedFile = yield storeFile(res.contentFile, dataFolder);
|
|
66
|
+
url = `${baseUrl}?file=${storedFile}`;
|
|
67
|
+
}
|
|
68
|
+
response.contentUrl = url;
|
|
62
69
|
}
|
|
63
70
|
return { response, error: res.error };
|
|
64
71
|
});
|
|
@@ -80,8 +87,15 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
80
87
|
response.preview = previewFileEncoded;
|
|
81
88
|
}
|
|
82
89
|
else {
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
let url;
|
|
91
|
+
if (config.storeFile) {
|
|
92
|
+
url = yield config.storeFile(res.previewFile);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const storedFile = yield storeFile(res.previewFile, dataFolder);
|
|
96
|
+
url = `${baseUrl}?file=${storedFile}`;
|
|
97
|
+
}
|
|
98
|
+
response.previewUrl = url;
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
101
|
if (res.strings) {
|
|
@@ -100,8 +114,15 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
100
114
|
response.strings = strings;
|
|
101
115
|
}
|
|
102
116
|
else {
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
let url;
|
|
118
|
+
if (config.storeFile) {
|
|
119
|
+
url = yield config.storeFile(stringsJson);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const storedFile = yield storeFile(stringsJson, dataFolder);
|
|
123
|
+
url = `${baseUrl}?file=${storedFile}`;
|
|
124
|
+
}
|
|
125
|
+
response.stringsUrl = url;
|
|
105
126
|
}
|
|
106
127
|
}
|
|
107
128
|
return { response, error: res.error };
|
package/out/models/index.d.ts
CHANGED
|
@@ -433,6 +433,10 @@ export interface CustomFileFormatLogic {
|
|
|
433
433
|
* Used for strings export
|
|
434
434
|
*/
|
|
435
435
|
exportStrings?: (req: Omit<ProcessFileRequest, 'jobType'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
436
|
+
/**
|
|
437
|
+
* Override to store huge responses (by default they will be stored in fs)
|
|
438
|
+
*/
|
|
439
|
+
storeFile?: (content: string) => Promise<string>;
|
|
436
440
|
}
|
|
437
441
|
export interface SignaturePatterns {
|
|
438
442
|
fileName?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdin/app-project-module",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
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",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@types/express-handlebars": "^5.3.1",
|
|
29
29
|
"@types/node": "^12.0.10",
|
|
30
30
|
"@types/node-cron": "^3.0.0",
|
|
31
|
-
"@types/sqlite3": "^3.1.7",
|
|
32
31
|
"@typescript-eslint/eslint-plugin": "^2.3.1",
|
|
33
32
|
"@typescript-eslint/parser": "^2.3.1",
|
|
34
33
|
"eslint": "^6.4.0",
|