smartling-api-sdk-nodejs 2.16.0 → 2.17.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/.scannerwork/report-task.txt +2 -2
- package/api/base/enum/response-body-type.ts +1 -0
- package/api/base/index.ts +5 -0
- package/api/file-translations/dto/translated-file-dto.ts +7 -0
- package/api/file-translations/index.ts +56 -2
- package/api/file-translations/params/fts-upload-file-parameters.ts +15 -0
- package/built/api/base/enum/response-body-type.d.ts +2 -1
- package/built/api/base/enum/response-body-type.js +1 -0
- package/built/api/base/enum/response-body-type.js.map +1 -1
- package/built/api/base/index.js +3 -0
- package/built/api/base/index.js.map +1 -1
- package/built/api/file-translations/dto/translated-file-dto.d.ts +6 -0
- package/built/api/file-translations/dto/translated-file-dto.js +3 -0
- package/built/api/file-translations/dto/translated-file-dto.js.map +1 -0
- package/built/api/file-translations/index.d.ts +5 -1
- package/built/api/file-translations/index.js +37 -1
- package/built/api/file-translations/index.js.map +1 -1
- package/built/api/file-translations/params/fts-upload-file-parameters.d.ts +5 -0
- package/built/api/file-translations/params/fts-upload-file-parameters.js +12 -0
- package/built/api/file-translations/params/fts-upload-file-parameters.js.map +1 -1
- package/built/package.json +1 -1
- package/package.json +1 -1
- package/test/file-translations.spec.ts +289 -0
|
@@ -2,5 +2,5 @@ projectKey=smartling-api-sdk-nodejs
|
|
|
2
2
|
serverUrl=https://sonar-next.connectors.stg.smartling.net
|
|
3
3
|
serverVersion=8.6.1.40680
|
|
4
4
|
dashboardUrl=https://sonar-next.connectors.stg.smartling.net/dashboard?id=smartling-api-sdk-nodejs
|
|
5
|
-
ceTaskId=
|
|
6
|
-
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=
|
|
5
|
+
ceTaskId=AZT-MpEN_0lymG1kFSkV
|
|
6
|
+
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZT-MpEN_0lymG1kFSkV
|
package/api/base/index.ts
CHANGED
|
@@ -144,6 +144,11 @@ export class SmartlingBaseApi {
|
|
|
144
144
|
return response.arrayBuffer();
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
// Special case for download file with metadata - return raw response.
|
|
148
|
+
if (returnRawResponseBody === ResponseBodyType.RAW_RESPONSE) {
|
|
149
|
+
return response;
|
|
150
|
+
}
|
|
151
|
+
|
|
147
152
|
try {
|
|
148
153
|
const textResponse = await response.text();
|
|
149
154
|
const jsonResponse = JSON.parse(textResponse, (key, value) => {
|
|
@@ -9,6 +9,7 @@ import { TranslateFileParameters } from "./params/translate-file-parameters";
|
|
|
9
9
|
import { TranslationStatusDto } from "./dto/translation-status-dto";
|
|
10
10
|
import { LanguageDetectionDto } from "./dto/language-detection-dto";
|
|
11
11
|
import { LanguageDetectionStatusDto } from "./dto/language-detection-status-dto";
|
|
12
|
+
import { TranslatedFileDto } from "./dto/translated-file-dto";
|
|
12
13
|
import { ResponseBodyType } from "../base/enum/response-body-type";
|
|
13
14
|
|
|
14
15
|
export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
|
|
@@ -24,7 +25,15 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
|
|
|
24
25
|
const formData = new FormData();
|
|
25
26
|
const exported = parameters.export();
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
const fileOptions: Record<string, unknown> = {};
|
|
29
|
+
if (exported.fileName) {
|
|
30
|
+
fileOptions.filename = exported.fileName;
|
|
31
|
+
}
|
|
32
|
+
if (exported.contentType) {
|
|
33
|
+
fileOptions.contentType = exported.contentType;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
formData.append("file", exported.file, fileOptions);
|
|
28
37
|
formData.append("request", JSON.stringify(exported.request), {
|
|
29
38
|
contentType: "application/json"
|
|
30
39
|
});
|
|
@@ -68,9 +77,22 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
|
|
|
68
77
|
);
|
|
69
78
|
}
|
|
70
79
|
|
|
80
|
+
async downloadTranslatedFileWithMetadata(
|
|
81
|
+
accountUid: string, fileUid: string, mtUid: string, localeId: string
|
|
82
|
+
): Promise<TranslatedFileDto> {
|
|
83
|
+
return await SmartlingFileTranslationsApi.downloadResponseToTranslatedFileDto(
|
|
84
|
+
await this.makeRequest(
|
|
85
|
+
"get",
|
|
86
|
+
`${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
|
|
87
|
+
null,
|
|
88
|
+
ResponseBodyType.RAW_RESPONSE
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
71
93
|
async downloadTranslatedFiles(
|
|
72
94
|
accountUid: string, fileUid: string, mtUid: string
|
|
73
|
-
): Promise<
|
|
95
|
+
): Promise<ArrayBuffer> {
|
|
74
96
|
return await this.makeRequest(
|
|
75
97
|
"get",
|
|
76
98
|
`${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
|
|
@@ -79,6 +101,19 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
|
|
|
79
101
|
);
|
|
80
102
|
}
|
|
81
103
|
|
|
104
|
+
async downloadTranslatedFilesWithMetadata(
|
|
105
|
+
accountUid: string, fileUid: string, mtUid: string
|
|
106
|
+
): Promise<TranslatedFileDto> {
|
|
107
|
+
return await SmartlingFileTranslationsApi.downloadResponseToTranslatedFileDto(
|
|
108
|
+
await this.makeRequest(
|
|
109
|
+
"get",
|
|
110
|
+
`${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
|
|
111
|
+
null,
|
|
112
|
+
ResponseBodyType.RAW_RESPONSE
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
82
117
|
async cancelFileTranslation(
|
|
83
118
|
accountUid: string, fileUid: string, mtUid: string
|
|
84
119
|
): Promise<void> {
|
|
@@ -112,4 +147,23 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
|
|
|
112
147
|
delete headers["content-type"];
|
|
113
148
|
return headers;
|
|
114
149
|
}
|
|
150
|
+
|
|
151
|
+
private static async downloadResponseToTranslatedFileDto(
|
|
152
|
+
response: Response
|
|
153
|
+
): Promise<TranslatedFileDto> {
|
|
154
|
+
const contentType = response.headers.get("content-type") ?? undefined;
|
|
155
|
+
const contentDisposition = response.headers.get("content-disposition");
|
|
156
|
+
let fileName;
|
|
157
|
+
if (contentDisposition) {
|
|
158
|
+
const fileNameMatch = contentDisposition.match(/filename="((?:[^"\\]|\\.)*)"/);
|
|
159
|
+
if (fileNameMatch) {
|
|
160
|
+
fileName = fileNameMatch[1].replace(/\\"/g, "\"");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
fileContent: await response.arrayBuffer(),
|
|
165
|
+
fileName,
|
|
166
|
+
contentType
|
|
167
|
+
};
|
|
168
|
+
}
|
|
115
169
|
}
|
|
@@ -22,6 +22,21 @@ export class FtsUploadFileParameters extends BaseParameters {
|
|
|
22
22
|
return this;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
setFileContentFromBuffer(fileContent: Buffer): FtsUploadFileParameters {
|
|
26
|
+
this.set("file", fileContent);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setFileName(fileName: string): FtsUploadFileParameters {
|
|
31
|
+
this.set("fileName", fileName);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setFileContentType(contentType: string): FtsUploadFileParameters {
|
|
36
|
+
this.set("contentType", contentType);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
25
40
|
setFileType(fileType: FileType): FtsUploadFileParameters {
|
|
26
41
|
this.parameters.request.fileType = fileType.toUpperCase();
|
|
27
42
|
return this;
|
|
@@ -5,5 +5,6 @@ var ResponseBodyType;
|
|
|
5
5
|
(function (ResponseBodyType) {
|
|
6
6
|
ResponseBodyType["TEXT"] = "TEXT";
|
|
7
7
|
ResponseBodyType["ARRAY_BUFFER"] = "ARRAY_BUFFER";
|
|
8
|
+
ResponseBodyType["RAW_RESPONSE"] = "RAW_RESPONSE";
|
|
8
9
|
})(ResponseBodyType = exports.ResponseBodyType || (exports.ResponseBodyType = {}));
|
|
9
10
|
//# sourceMappingURL=response-body-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-body-type.js","sourceRoot":"","sources":["../../../../api/base/enum/response-body-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"response-body-type.js","sourceRoot":"","sources":["../../../../api/base/enum/response-body-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iDAA6B,CAAA;IAC7B,iDAA6B,CAAA;AACjC,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B"}
|
package/built/api/base/index.js
CHANGED
|
@@ -108,6 +108,9 @@ class SmartlingBaseApi {
|
|
|
108
108
|
if (returnRawResponseBody === response_body_type_1.ResponseBodyType.ARRAY_BUFFER) {
|
|
109
109
|
return response.arrayBuffer();
|
|
110
110
|
}
|
|
111
|
+
if (returnRawResponseBody === response_body_type_1.ResponseBodyType.RAW_RESPONSE) {
|
|
112
|
+
return response;
|
|
113
|
+
}
|
|
111
114
|
try {
|
|
112
115
|
const textResponse = yield response.text();
|
|
113
116
|
const jsonResponse = JSON.parse(textResponse, (key, value) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA+B;AAC/B,4EAAoC;AAEpC,8DAAgC;AAChC,6CAA6D;AAE7D,8CAAwD;AAExD,kEAA6D;AAG7D,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,MAAa,gBAAgB;IAUzB,YAAY,M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AkB,CAAC,8BAA8B,EAAE;oBACzD,UAAU,EAAE,QAAQ,CAAC,MAAM;oBAC3B,aAAa,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE;oBACpC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;iBACpD,CAAC,CAAC;aACN;;KACJ;IAEM,MAAM,CAAC,iBAAiB,CAAC,GAAW,EAAE,KAAU;QACnD,MAAM,mBAAmB,GAAG;YACxB,gBAAgB;YAChB,YAAY;YACZ,aAAa;YACb,cAAc;SACjB,CAAC;QAEF,IAAI,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACzE,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC;SAC3C;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA7LD,4CA6LC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translated-file-dto.js","sourceRoot":"","sources":["../../../../api/file-translations/dto/translated-file-dto.ts"],"names":[],"mappings":""}
|
|
@@ -9,15 +9,19 @@ import { TranslateFileParameters } from "./params/translate-file-parameters";
|
|
|
9
9
|
import { TranslationStatusDto } from "./dto/translation-status-dto";
|
|
10
10
|
import { LanguageDetectionDto } from "./dto/language-detection-dto";
|
|
11
11
|
import { LanguageDetectionStatusDto } from "./dto/language-detection-status-dto";
|
|
12
|
+
import { TranslatedFileDto } from "./dto/translated-file-dto";
|
|
12
13
|
export declare class SmartlingFileTranslationsApi extends SmartlingBaseApi {
|
|
13
14
|
constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger);
|
|
14
15
|
uploadFile(accountUid: string, parameters: FtsUploadFileParameters): Promise<FtsUploadedFileDto>;
|
|
15
16
|
translateFile(accountUid: string, fileUid: string, params: TranslateFileParameters): Promise<TranslationDto>;
|
|
16
17
|
getTranslationProgress(accountUid: string, fileUid: string, mtUid: string): Promise<TranslationStatusDto>;
|
|
17
18
|
downloadTranslatedFile(accountUid: string, fileUid: string, mtUid: string, localeId: string): Promise<string>;
|
|
18
|
-
|
|
19
|
+
downloadTranslatedFileWithMetadata(accountUid: string, fileUid: string, mtUid: string, localeId: string): Promise<TranslatedFileDto>;
|
|
20
|
+
downloadTranslatedFiles(accountUid: string, fileUid: string, mtUid: string): Promise<ArrayBuffer>;
|
|
21
|
+
downloadTranslatedFilesWithMetadata(accountUid: string, fileUid: string, mtUid: string): Promise<TranslatedFileDto>;
|
|
19
22
|
cancelFileTranslation(accountUid: string, fileUid: string, mtUid: string): Promise<void>;
|
|
20
23
|
detectFileLanguage(accountUid: string, fileUid: string): Promise<LanguageDetectionDto>;
|
|
21
24
|
getLanguageDetectionProgress(accountUid: string, fileUid: string, languageDetectionUid: string): Promise<LanguageDetectionStatusDto>;
|
|
22
25
|
static fixContentTypeHeaderCase(form: FormData): Record<string, unknown>;
|
|
26
|
+
private static downloadResponseToTranslatedFileDto;
|
|
23
27
|
}
|
|
@@ -26,7 +26,14 @@ class SmartlingFileTranslationsApi extends base_1.SmartlingBaseApi {
|
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const formData = new form_data_1.default();
|
|
28
28
|
const exported = parameters.export();
|
|
29
|
-
|
|
29
|
+
const fileOptions = {};
|
|
30
|
+
if (exported.fileName) {
|
|
31
|
+
fileOptions.filename = exported.fileName;
|
|
32
|
+
}
|
|
33
|
+
if (exported.contentType) {
|
|
34
|
+
fileOptions.contentType = exported.contentType;
|
|
35
|
+
}
|
|
36
|
+
formData.append("file", exported.file, fileOptions);
|
|
30
37
|
formData.append("request", JSON.stringify(exported.request), {
|
|
31
38
|
contentType: "application/json"
|
|
32
39
|
});
|
|
@@ -48,11 +55,21 @@ class SmartlingFileTranslationsApi extends base_1.SmartlingBaseApi {
|
|
|
48
55
|
return yield this.makeRequest("get", `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`, null, true);
|
|
49
56
|
});
|
|
50
57
|
}
|
|
58
|
+
downloadTranslatedFileWithMetadata(accountUid, fileUid, mtUid, localeId) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return yield SmartlingFileTranslationsApi.downloadResponseToTranslatedFileDto(yield this.makeRequest("get", `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`, null, response_body_type_1.ResponseBodyType.RAW_RESPONSE));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
51
63
|
downloadTranslatedFiles(accountUid, fileUid, mtUid) {
|
|
52
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
65
|
return yield this.makeRequest("get", `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`, null, response_body_type_1.ResponseBodyType.ARRAY_BUFFER);
|
|
54
66
|
});
|
|
55
67
|
}
|
|
68
|
+
downloadTranslatedFilesWithMetadata(accountUid, fileUid, mtUid) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
return yield SmartlingFileTranslationsApi.downloadResponseToTranslatedFileDto(yield this.makeRequest("get", `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`, null, response_body_type_1.ResponseBodyType.RAW_RESPONSE));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
56
73
|
cancelFileTranslation(accountUid, fileUid, mtUid) {
|
|
57
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
75
|
yield this.makeRequest("post", `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/cancel`);
|
|
@@ -74,6 +91,25 @@ class SmartlingFileTranslationsApi extends base_1.SmartlingBaseApi {
|
|
|
74
91
|
delete headers["content-type"];
|
|
75
92
|
return headers;
|
|
76
93
|
}
|
|
94
|
+
static downloadResponseToTranslatedFileDto(response) {
|
|
95
|
+
var _a;
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const contentType = (_a = response.headers.get("content-type")) !== null && _a !== void 0 ? _a : undefined;
|
|
98
|
+
const contentDisposition = response.headers.get("content-disposition");
|
|
99
|
+
let fileName;
|
|
100
|
+
if (contentDisposition) {
|
|
101
|
+
const fileNameMatch = contentDisposition.match(/filename="((?:[^"\\]|\\.)*)"/);
|
|
102
|
+
if (fileNameMatch) {
|
|
103
|
+
fileName = fileNameMatch[1].replace(/\\"/g, "\"");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
fileContent: yield response.arrayBuffer(),
|
|
108
|
+
fileName,
|
|
109
|
+
contentType
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
77
113
|
}
|
|
78
114
|
exports.SmartlingFileTranslationsApi = SmartlingFileTranslationsApi;
|
|
79
115
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/file-translations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAiC;AACjC,kCAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/file-translations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAiC;AACjC,kCAA2C;AAW3C,wEAAmE;AAEnE,MAAa,4BAA6B,SAAQ,uBAAgB;IAC9D,YAAY,mBAA2B,EAAE,OAAyB,EAAE,MAAc;QAC9E,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,GAAG,mBAAmB,oCAAoC,CAAC;IACjF,CAAC;IAEK,UAAU,CACZ,UAAkB,EAAE,UAAmC;;YAEvD,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,EAA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|
+
/// <reference types="node" />
|
|
1
3
|
import { BaseParameters } from "../../parameters";
|
|
2
4
|
import { FileType } from "../../files/params/file-type";
|
|
3
5
|
export declare class FtsUploadFileParameters extends BaseParameters {
|
|
4
6
|
constructor(parameters?: Record<string, unknown>);
|
|
5
7
|
setFileFromLocalFilePath(filePath: string): FtsUploadFileParameters;
|
|
6
8
|
setFileContent(fileContent: string): FtsUploadFileParameters;
|
|
9
|
+
setFileContentFromBuffer(fileContent: Buffer): FtsUploadFileParameters;
|
|
10
|
+
setFileName(fileName: string): FtsUploadFileParameters;
|
|
11
|
+
setFileContentType(contentType: string): FtsUploadFileParameters;
|
|
7
12
|
setFileType(fileType: FileType): FtsUploadFileParameters;
|
|
8
13
|
}
|
|
@@ -43,6 +43,18 @@ class FtsUploadFileParameters extends parameters_1.BaseParameters {
|
|
|
43
43
|
this.set("file", (0, string_to_file_stream_1.default)(fileContent));
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
|
+
setFileContentFromBuffer(fileContent) {
|
|
47
|
+
this.set("file", fileContent);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
setFileName(fileName) {
|
|
51
|
+
this.set("fileName", fileName);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
setFileContentType(contentType) {
|
|
55
|
+
this.set("contentType", contentType);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
46
58
|
setFileType(fileType) {
|
|
47
59
|
this.parameters.request.fileType = fileType.toUpperCase();
|
|
48
60
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fts-upload-file-parameters.js","sourceRoot":"","sources":["../../../../api/file-translations/params/fts-upload-file-parameters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,kFAAsD;AACtD,iDAAkD;AAGlD,MAAa,uBAAwB,SAAQ,2BAAc;IACvD,YAAY,aAAsC,EAAE;QAChD,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,wBAAwB,CAAC,QAAgB;QACrC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAChC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAC5B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAA,+BAAiB,EAAC,WAAW,CAAC,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,QAAkB;QAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;
|
|
1
|
+
{"version":3,"file":"fts-upload-file-parameters.js","sourceRoot":"","sources":["../../../../api/file-translations/params/fts-upload-file-parameters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,kFAAsD;AACtD,iDAAkD;AAGlD,MAAa,uBAAwB,SAAQ,2BAAc;IACvD,YAAY,aAAsC,EAAE;QAChD,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,wBAAwB,CAAC,QAAgB;QACrC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAChC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAC5B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAA,+BAAiB,EAAC,WAAW,CAAC,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,wBAAwB,CAAC,WAAmB;QACxC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,QAAgB;QACxB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kBAAkB,CAAC,WAAmB;QAClC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,QAAkB;QAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAtCD,0DAsCC"}
|
package/built/package.json
CHANGED
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
|
|
|
21
21
|
let fileTranslationsApiFetchStub;
|
|
22
22
|
let fileTranslationsApiUaStub;
|
|
23
23
|
let responseMockJsonStub;
|
|
24
|
+
let getHeaderStub;
|
|
24
25
|
|
|
25
26
|
beforeEach(() => {
|
|
26
27
|
fileTranslationsApi = new SmartlingFileTranslationsApi(
|
|
@@ -37,12 +38,15 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
|
|
|
37
38
|
responseMockJsonStub.returns({
|
|
38
39
|
response: {}
|
|
39
40
|
});
|
|
41
|
+
getHeaderStub = sinon.stub(responseMock.headers, "get");
|
|
42
|
+
getHeaderStub.returns(null);
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
afterEach(() => {
|
|
43
46
|
fileTranslationsApiFetchStub.restore();
|
|
44
47
|
fileTranslationsApiUaStub.restore();
|
|
45
48
|
responseMockJsonStub.restore();
|
|
49
|
+
getHeaderStub.restore();
|
|
46
50
|
});
|
|
47
51
|
|
|
48
52
|
describe("Methods", () => {
|
|
@@ -144,6 +148,158 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
|
|
|
144
148
|
assert.equal(fileTranslationsApiFetchCall.args[1].body._streams[4], "{\"fileType\":\"XML\"}");
|
|
145
149
|
});
|
|
146
150
|
|
|
151
|
+
it("Upload file: as binary buffer", async () => {
|
|
152
|
+
const params = new FtsUploadFileParameters();
|
|
153
|
+
|
|
154
|
+
const testFileContent = fs.readFileSync(
|
|
155
|
+
fs.realpathSync("./test/data/file.xml")
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
params
|
|
159
|
+
.setFileType(FileType.XML)
|
|
160
|
+
.setFileContentFromBuffer(testFileContent);
|
|
161
|
+
|
|
162
|
+
await fileTranslationsApi.uploadFile(accountUid, params);
|
|
163
|
+
|
|
164
|
+
sinon.assert.calledOnce(fileTranslationsApiFetchStub);
|
|
165
|
+
|
|
166
|
+
const fileTranslationsApiFetchCall = fileTranslationsApiFetchStub.getCall(0);
|
|
167
|
+
|
|
168
|
+
assert.equal(
|
|
169
|
+
fileTranslationsApiFetchCall.args[0],
|
|
170
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files`
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
assert.equal(
|
|
174
|
+
fileTranslationsApiFetchCall.args[1].method,
|
|
175
|
+
"post"
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
assert.equal(
|
|
179
|
+
fileTranslationsApiFetchCall.args[1].headers.Authorization,
|
|
180
|
+
"test_token_type test_access_token"
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const formData = fileTranslationsApiFetchCall.args[1].body as FormData;
|
|
184
|
+
const boundary = formData.getBoundary();
|
|
185
|
+
|
|
186
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["User-Agent"], userAgent);
|
|
187
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["Content-Type"], `multipart/form-data; boundary=${boundary}`);
|
|
188
|
+
|
|
189
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
190
|
+
const content = fileTranslationsApiFetchCall.args[1].body._streams[1].toString("utf-8");
|
|
191
|
+
assert.equal(content, testFileContent);
|
|
192
|
+
|
|
193
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
194
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].body._streams[4], "{\"fileType\":\"XML\"}");
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("Upload file: with file name", async () => {
|
|
198
|
+
const params = new FtsUploadFileParameters();
|
|
199
|
+
|
|
200
|
+
const testFileContent = fs.readFileSync(
|
|
201
|
+
fs.realpathSync("./test/data/file.xml")
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
params
|
|
205
|
+
.setFileType(FileType.XML)
|
|
206
|
+
.setFileContentFromBuffer(testFileContent)
|
|
207
|
+
.setFileName("my-file");
|
|
208
|
+
|
|
209
|
+
await fileTranslationsApi.uploadFile(accountUid, params);
|
|
210
|
+
|
|
211
|
+
sinon.assert.calledOnce(fileTranslationsApiFetchStub);
|
|
212
|
+
|
|
213
|
+
const fileTranslationsApiFetchCall = fileTranslationsApiFetchStub.getCall(0);
|
|
214
|
+
|
|
215
|
+
assert.equal(
|
|
216
|
+
fileTranslationsApiFetchCall.args[0],
|
|
217
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files`
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
assert.equal(
|
|
221
|
+
fileTranslationsApiFetchCall.args[1].method,
|
|
222
|
+
"post"
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
assert.equal(
|
|
226
|
+
fileTranslationsApiFetchCall.args[1].headers.Authorization,
|
|
227
|
+
"test_token_type test_access_token"
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const formData = fileTranslationsApiFetchCall.args[1].body as FormData;
|
|
231
|
+
const boundary = formData.getBoundary();
|
|
232
|
+
|
|
233
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["User-Agent"], userAgent);
|
|
234
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["Content-Type"], `multipart/form-data; boundary=${boundary}`);
|
|
235
|
+
|
|
236
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
237
|
+
const content = fileTranslationsApiFetchCall.args[1].body._streams[1].toString("utf-8");
|
|
238
|
+
assert.equal(content, testFileContent);
|
|
239
|
+
|
|
240
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
241
|
+
const contentDisposition = fileTranslationsApiFetchCall.args[1].body._streams[0].toString("utf-8");
|
|
242
|
+
|
|
243
|
+
assert.ok(contentDisposition.includes("filename=\"my-file\""));
|
|
244
|
+
assert.ok(contentDisposition.includes("Content-Type: application/octet-stream"));
|
|
245
|
+
|
|
246
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
247
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].body._streams[4], "{\"fileType\":\"XML\"}");
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("Upload file: with file content type", async () => {
|
|
251
|
+
const params = new FtsUploadFileParameters();
|
|
252
|
+
|
|
253
|
+
const testFileContent = fs.readFileSync(
|
|
254
|
+
fs.realpathSync("./test/data/file.xml")
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
params
|
|
258
|
+
.setFileType(FileType.XML)
|
|
259
|
+
.setFileContentFromBuffer(testFileContent)
|
|
260
|
+
.setFileContentType("application/xml");
|
|
261
|
+
|
|
262
|
+
await fileTranslationsApi.uploadFile(accountUid, params);
|
|
263
|
+
|
|
264
|
+
sinon.assert.calledOnce(fileTranslationsApiFetchStub);
|
|
265
|
+
|
|
266
|
+
const fileTranslationsApiFetchCall = fileTranslationsApiFetchStub.getCall(0);
|
|
267
|
+
|
|
268
|
+
assert.equal(
|
|
269
|
+
fileTranslationsApiFetchCall.args[0],
|
|
270
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files`
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
assert.equal(
|
|
274
|
+
fileTranslationsApiFetchCall.args[1].method,
|
|
275
|
+
"post"
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
assert.equal(
|
|
279
|
+
fileTranslationsApiFetchCall.args[1].headers.Authorization,
|
|
280
|
+
"test_token_type test_access_token"
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
const formData = fileTranslationsApiFetchCall.args[1].body as FormData;
|
|
284
|
+
const boundary = formData.getBoundary();
|
|
285
|
+
|
|
286
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["User-Agent"], userAgent);
|
|
287
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["Content-Type"], `multipart/form-data; boundary=${boundary}`);
|
|
288
|
+
|
|
289
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
290
|
+
const content = fileTranslationsApiFetchCall.args[1].body._streams[1].toString("utf-8");
|
|
291
|
+
assert.equal(content, testFileContent);
|
|
292
|
+
|
|
293
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
294
|
+
const contentDisposition = fileTranslationsApiFetchCall.args[1].body._streams[0].toString("utf-8");
|
|
295
|
+
|
|
296
|
+
assert.ok(!contentDisposition.includes("filename="));
|
|
297
|
+
assert.ok(contentDisposition.includes("Content-Type: application/xml"));
|
|
298
|
+
|
|
299
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
300
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].body._streams[4], "{\"fileType\":\"XML\"}");
|
|
301
|
+
});
|
|
302
|
+
|
|
147
303
|
it("Translate file", async () => {
|
|
148
304
|
const params = new TranslateFileParameters();
|
|
149
305
|
|
|
@@ -207,6 +363,89 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
|
|
|
207
363
|
);
|
|
208
364
|
});
|
|
209
365
|
|
|
366
|
+
it("Download translated file with metadata when no headers", async () => {
|
|
367
|
+
const localeId = "de-DE";
|
|
368
|
+
|
|
369
|
+
const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFileWithMetadata(
|
|
370
|
+
accountUid, fileUid, mtUid, localeId
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
sinon.assert.calledOnceWithExactly(
|
|
374
|
+
fileTranslationsApiFetchStub,
|
|
375
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
|
|
376
|
+
{
|
|
377
|
+
method: "get",
|
|
378
|
+
headers: {
|
|
379
|
+
Authorization: "test_token_type test_access_token",
|
|
380
|
+
"Content-Type": "application/json",
|
|
381
|
+
"User-Agent": userAgent
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
assert.ok(fileWithMetadata.contentType === undefined);
|
|
387
|
+
assert.ok(fileWithMetadata.fileName === undefined);
|
|
388
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it("Download translated file with metadata", async () => {
|
|
392
|
+
const localeId = "de-DE";
|
|
393
|
+
|
|
394
|
+
getHeaderStub.onCall(0).returns("application/xml");
|
|
395
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.xml\"");
|
|
396
|
+
getHeaderStub.returns(null);
|
|
397
|
+
|
|
398
|
+
const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFileWithMetadata(
|
|
399
|
+
accountUid, fileUid, mtUid, localeId
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
sinon.assert.calledOnceWithExactly(
|
|
403
|
+
fileTranslationsApiFetchStub,
|
|
404
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
|
|
405
|
+
{
|
|
406
|
+
method: "get",
|
|
407
|
+
headers: {
|
|
408
|
+
Authorization: "test_token_type test_access_token",
|
|
409
|
+
"Content-Type": "application/json",
|
|
410
|
+
"User-Agent": userAgent
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
assert.ok(fileWithMetadata.contentType === "application/xml");
|
|
416
|
+
assert.ok(fileWithMetadata.fileName === "test.xml");
|
|
417
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it("Download translated file with escaped quotes in the file name", async () => {
|
|
421
|
+
const localeId = "de-DE";
|
|
422
|
+
|
|
423
|
+
getHeaderStub.onCall(0).returns("application/xml");
|
|
424
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test - \\\"phase 1\\\".xml\"");
|
|
425
|
+
getHeaderStub.returns(null);
|
|
426
|
+
|
|
427
|
+
const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFileWithMetadata(
|
|
428
|
+
accountUid, fileUid, mtUid, localeId
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
sinon.assert.calledOnceWithExactly(
|
|
432
|
+
fileTranslationsApiFetchStub,
|
|
433
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
|
|
434
|
+
{
|
|
435
|
+
method: "get",
|
|
436
|
+
headers: {
|
|
437
|
+
Authorization: "test_token_type test_access_token",
|
|
438
|
+
"Content-Type": "application/json",
|
|
439
|
+
"User-Agent": userAgent
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
assert.ok(fileWithMetadata.contentType === "application/xml");
|
|
445
|
+
assert.ok(fileWithMetadata.fileName === "test - \"phase 1\".xml");
|
|
446
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
447
|
+
});
|
|
448
|
+
|
|
210
449
|
it("Download translated files", async () => {
|
|
211
450
|
await fileTranslationsApi.downloadTranslatedFiles(accountUid, fileUid, mtUid);
|
|
212
451
|
|
|
@@ -224,6 +463,56 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
|
|
|
224
463
|
);
|
|
225
464
|
});
|
|
226
465
|
|
|
466
|
+
it("Download translated files with metadata when no headers", async () => {
|
|
467
|
+
const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFilesWithMetadata(
|
|
468
|
+
accountUid, fileUid, mtUid
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
sinon.assert.calledOnceWithExactly(
|
|
472
|
+
fileTranslationsApiFetchStub,
|
|
473
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
|
|
474
|
+
{
|
|
475
|
+
method: "get",
|
|
476
|
+
headers: {
|
|
477
|
+
Authorization: "test_token_type test_access_token",
|
|
478
|
+
"Content-Type": "application/json",
|
|
479
|
+
"User-Agent": userAgent
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
assert.ok(fileWithMetadata.contentType === undefined);
|
|
485
|
+
assert.ok(fileWithMetadata.fileName === undefined);
|
|
486
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it("Download translated files with metadata", async () => {
|
|
490
|
+
getHeaderStub.onCall(0).returns("application/zip");
|
|
491
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.zip\"");
|
|
492
|
+
getHeaderStub.returns(null);
|
|
493
|
+
|
|
494
|
+
const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFilesWithMetadata(
|
|
495
|
+
accountUid, fileUid, mtUid
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
sinon.assert.calledOnceWithExactly(
|
|
499
|
+
fileTranslationsApiFetchStub,
|
|
500
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
|
|
501
|
+
{
|
|
502
|
+
method: "get",
|
|
503
|
+
headers: {
|
|
504
|
+
Authorization: "test_token_type test_access_token",
|
|
505
|
+
"Content-Type": "application/json",
|
|
506
|
+
"User-Agent": userAgent
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
assert.ok(fileWithMetadata.contentType === "application/zip");
|
|
512
|
+
assert.ok(fileWithMetadata.fileName === "test.zip");
|
|
513
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
514
|
+
});
|
|
515
|
+
|
|
227
516
|
it("Cancel file translation", async () => {
|
|
228
517
|
await fileTranslationsApi.cancelFileTranslation(accountUid, fileUid, mtUid);
|
|
229
518
|
|