smartling-api-sdk-nodejs 2.16.1 → 2.18.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.
Files changed (43) hide show
  1. package/.scannerwork/report-task.txt +2 -2
  2. package/api/base/enum/response-body-type.ts +1 -0
  3. package/api/base/index.ts +5 -0
  4. package/api/file-translations/dto/translated-file-dto.ts +7 -0
  5. package/api/file-translations/index.ts +52 -2
  6. package/api/file-translations/params/base-parameters-with-callback.ts +9 -0
  7. package/api/file-translations/params/fts-callback-method.ts +6 -0
  8. package/api/file-translations/params/fts-callback-parameter.ts +9 -0
  9. package/api/file-translations/params/language-detection-parameters.ts +4 -0
  10. package/api/file-translations/params/translate-file-parameters.ts +2 -2
  11. package/built/api/base/enum/response-body-type.d.ts +2 -1
  12. package/built/api/base/enum/response-body-type.js +1 -0
  13. package/built/api/base/enum/response-body-type.js.map +1 -1
  14. package/built/api/base/index.js +3 -0
  15. package/built/api/base/index.js.map +1 -1
  16. package/built/api/file-translations/dto/translated-file-dto.d.ts +6 -0
  17. package/built/api/file-translations/dto/translated-file-dto.js +3 -0
  18. package/built/api/file-translations/dto/translated-file-dto.js.map +1 -0
  19. package/built/api/file-translations/index.d.ts +6 -1
  20. package/built/api/file-translations/index.js +31 -2
  21. package/built/api/file-translations/index.js.map +1 -1
  22. package/built/api/file-translations/params/base-parameters-with-callback.d.ts +5 -0
  23. package/built/api/file-translations/params/base-parameters-with-callback.js +12 -0
  24. package/built/api/file-translations/params/base-parameters-with-callback.js.map +1 -0
  25. package/built/api/file-translations/params/fts-callback-method.d.ts +4 -0
  26. package/built/api/file-translations/params/fts-callback-method.js +9 -0
  27. package/built/api/file-translations/params/fts-callback-method.js.map +1 -0
  28. package/built/api/file-translations/params/fts-callback-parameter.d.ts +7 -0
  29. package/built/api/file-translations/params/fts-callback-parameter.js +3 -0
  30. package/built/api/file-translations/params/fts-callback-parameter.js.map +1 -0
  31. package/built/api/file-translations/params/language-detection-parameters.d.ts +3 -0
  32. package/built/api/file-translations/params/language-detection-parameters.js +8 -0
  33. package/built/api/file-translations/params/language-detection-parameters.js.map +1 -0
  34. package/built/api/file-translations/params/translate-file-parameters.d.ts +2 -2
  35. package/built/api/file-translations/params/translate-file-parameters.js +2 -2
  36. package/built/api/file-translations/params/translate-file-parameters.js.map +1 -1
  37. package/built/index.d.ts +3 -0
  38. package/built/index.js +3 -0
  39. package/built/index.js.map +1 -1
  40. package/built/package.json +1 -1
  41. package/index.ts +3 -0
  42. package/package.json +1 -1
  43. package/test/file-translations.spec.ts +291 -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=AZT0dv92Gh-y-CGibre5
6
- ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZT0dv92Gh-y-CGibre5
5
+ ceTaskId=AZVHKwudfYfLTOL0FF0N
6
+ ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZVHKwudfYfLTOL0FF0N
@@ -1,4 +1,5 @@
1
1
  export enum ResponseBodyType {
2
2
  TEXT = "TEXT",
3
3
  ARRAY_BUFFER = "ARRAY_BUFFER",
4
+ RAW_RESPONSE = "RAW_RESPONSE",
4
5
  }
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) => {
@@ -0,0 +1,7 @@
1
+ interface TranslatedFileDto {
2
+ fileContent: ArrayBuffer;
3
+ fileName?: string;
4
+ contentType?: string;
5
+ }
6
+
7
+ export { TranslatedFileDto };
@@ -9,7 +9,9 @@ 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";
14
+ import { LanguageDetectionParameters } from "./params/language-detection-parameters";
13
15
 
14
16
  export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
15
17
  constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger) {
@@ -76,6 +78,19 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
76
78
  );
77
79
  }
78
80
 
81
+ async downloadTranslatedFileWithMetadata(
82
+ accountUid: string, fileUid: string, mtUid: string, localeId: string
83
+ ): Promise<TranslatedFileDto> {
84
+ return await SmartlingFileTranslationsApi.downloadResponseToTranslatedFileDto(
85
+ await this.makeRequest(
86
+ "get",
87
+ `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
88
+ null,
89
+ ResponseBodyType.RAW_RESPONSE
90
+ )
91
+ );
92
+ }
93
+
79
94
  async downloadTranslatedFiles(
80
95
  accountUid: string, fileUid: string, mtUid: string
81
96
  ): Promise<ArrayBuffer> {
@@ -87,6 +102,19 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
87
102
  );
88
103
  }
89
104
 
105
+ async downloadTranslatedFilesWithMetadata(
106
+ accountUid: string, fileUid: string, mtUid: string
107
+ ): Promise<TranslatedFileDto> {
108
+ return await SmartlingFileTranslationsApi.downloadResponseToTranslatedFileDto(
109
+ await this.makeRequest(
110
+ "get",
111
+ `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
112
+ null,
113
+ ResponseBodyType.RAW_RESPONSE
114
+ )
115
+ );
116
+ }
117
+
90
118
  async cancelFileTranslation(
91
119
  accountUid: string, fileUid: string, mtUid: string
92
120
  ): Promise<void> {
@@ -96,10 +124,13 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
96
124
  );
97
125
  }
98
126
 
99
- async detectFileLanguage(accountUid: string, fileUid: string): Promise<LanguageDetectionDto> {
127
+ async detectFileLanguage(
128
+ accountUid: string, fileUid: string, params?: LanguageDetectionParameters
129
+ ): Promise<LanguageDetectionDto> {
100
130
  return await this.makeRequest(
101
131
  "post",
102
- `${this.entrypoint}/${accountUid}/files/${fileUid}/language-detection`
132
+ `${this.entrypoint}/${accountUid}/files/${fileUid}/language-detection`,
133
+ JSON.stringify(params?.export())
103
134
  );
104
135
  }
105
136
 
@@ -120,4 +151,23 @@ export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
120
151
  delete headers["content-type"];
121
152
  return headers;
122
153
  }
154
+
155
+ private static async downloadResponseToTranslatedFileDto(
156
+ response: Response
157
+ ): Promise<TranslatedFileDto> {
158
+ const contentType = response.headers.get("content-type") ?? undefined;
159
+ const contentDisposition = response.headers.get("content-disposition");
160
+ let fileName;
161
+ if (contentDisposition) {
162
+ const fileNameMatch = contentDisposition.match(/filename="((?:[^"\\]|\\.)*)"/);
163
+ if (fileNameMatch) {
164
+ fileName = fileNameMatch[1].replace(/\\"/g, "\"");
165
+ }
166
+ }
167
+ return {
168
+ fileContent: await response.arrayBuffer(),
169
+ fileName,
170
+ contentType
171
+ };
172
+ }
123
173
  }
@@ -0,0 +1,9 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { FtsCallback } from "./fts-callback-parameter";
3
+
4
+ export class BaseParametersWithCallback extends BaseParameters {
5
+ setCallback(callback: FtsCallback): this {
6
+ this.parameters.callback = callback;
7
+ return this;
8
+ }
9
+ }
@@ -0,0 +1,6 @@
1
+ enum FtsCallbackMethod {
2
+ // Other HTTP methods are not supported by API for now
3
+ POST = "POST"
4
+ }
5
+
6
+ export { FtsCallbackMethod };
@@ -0,0 +1,9 @@
1
+ import { FtsCallbackMethod } from "./fts-callback-method";
2
+
3
+ interface FtsCallback {
4
+ url: string;
5
+ httpMethod: FtsCallbackMethod;
6
+ userData?: string
7
+ }
8
+
9
+ export { FtsCallback };
@@ -0,0 +1,4 @@
1
+ import { BaseParametersWithCallback } from "./base-parameters-with-callback";
2
+
3
+ export class LanguageDetectionParameters extends BaseParametersWithCallback {
4
+ }
@@ -1,6 +1,6 @@
1
- import { BaseParameters } from "../../parameters";
1
+ import { BaseParametersWithCallback } from "./base-parameters-with-callback";
2
2
 
3
- export class TranslateFileParameters extends BaseParameters {
3
+ export class TranslateFileParameters extends BaseParametersWithCallback {
4
4
  setSourceLocaleId(sourceLocaleId: string): TranslateFileParameters {
5
5
  this.set("sourceLocaleId", sourceLocaleId);
6
6
  return this;
@@ -1,4 +1,5 @@
1
1
  export declare enum ResponseBodyType {
2
2
  TEXT = "TEXT",
3
- ARRAY_BUFFER = "ARRAY_BUFFER"
3
+ ARRAY_BUFFER = "ARRAY_BUFFER",
4
+ RAW_RESPONSE = "RAW_RESPONSE"
4
5
  }
@@ -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,gBAGX;AAHD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iDAA6B,CAAA;AACjC,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B"}
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"}
@@ -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,MAAc;QAThB,YAAO,GAAqB,SAAS,CAAC;QAU5C,IAAI,CAAC,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC;QAC3C,IAAI,CAAC,oBAAoB,GAAG,WAAW,CAAC,OAAO,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAC3C,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,UAAU,CAAC,OAAgC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,cA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,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,6 @@
1
+ interface TranslatedFileDto {
2
+ fileContent: ArrayBuffer;
3
+ fileName?: string;
4
+ contentType?: string;
5
+ }
6
+ export { TranslatedFileDto };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=translated-file-dto.js.map
@@ -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,20 @@ 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";
13
+ import { LanguageDetectionParameters } from "./params/language-detection-parameters";
12
14
  export declare class SmartlingFileTranslationsApi extends SmartlingBaseApi {
13
15
  constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger);
14
16
  uploadFile(accountUid: string, parameters: FtsUploadFileParameters): Promise<FtsUploadedFileDto>;
15
17
  translateFile(accountUid: string, fileUid: string, params: TranslateFileParameters): Promise<TranslationDto>;
16
18
  getTranslationProgress(accountUid: string, fileUid: string, mtUid: string): Promise<TranslationStatusDto>;
17
19
  downloadTranslatedFile(accountUid: string, fileUid: string, mtUid: string, localeId: string): Promise<string>;
20
+ downloadTranslatedFileWithMetadata(accountUid: string, fileUid: string, mtUid: string, localeId: string): Promise<TranslatedFileDto>;
18
21
  downloadTranslatedFiles(accountUid: string, fileUid: string, mtUid: string): Promise<ArrayBuffer>;
22
+ downloadTranslatedFilesWithMetadata(accountUid: string, fileUid: string, mtUid: string): Promise<TranslatedFileDto>;
19
23
  cancelFileTranslation(accountUid: string, fileUid: string, mtUid: string): Promise<void>;
20
- detectFileLanguage(accountUid: string, fileUid: string): Promise<LanguageDetectionDto>;
24
+ detectFileLanguage(accountUid: string, fileUid: string, params?: LanguageDetectionParameters): Promise<LanguageDetectionDto>;
21
25
  getLanguageDetectionProgress(accountUid: string, fileUid: string, languageDetectionUid: string): Promise<LanguageDetectionStatusDto>;
22
26
  static fixContentTypeHeaderCase(form: FormData): Record<string, unknown>;
27
+ private static downloadResponseToTranslatedFileDto;
23
28
  }
@@ -55,19 +55,29 @@ class SmartlingFileTranslationsApi extends base_1.SmartlingBaseApi {
55
55
  return yield this.makeRequest("get", `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`, null, true);
56
56
  });
57
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
+ }
58
63
  downloadTranslatedFiles(accountUid, fileUid, mtUid) {
59
64
  return __awaiter(this, void 0, void 0, function* () {
60
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);
61
66
  });
62
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
+ }
63
73
  cancelFileTranslation(accountUid, fileUid, mtUid) {
64
74
  return __awaiter(this, void 0, void 0, function* () {
65
75
  yield this.makeRequest("post", `${this.entrypoint}/${accountUid}/files/${fileUid}/mt/${mtUid}/cancel`);
66
76
  });
67
77
  }
68
- detectFileLanguage(accountUid, fileUid) {
78
+ detectFileLanguage(accountUid, fileUid, params) {
69
79
  return __awaiter(this, void 0, void 0, function* () {
70
- return yield this.makeRequest("post", `${this.entrypoint}/${accountUid}/files/${fileUid}/language-detection`);
80
+ return yield this.makeRequest("post", `${this.entrypoint}/${accountUid}/files/${fileUid}/language-detection`, JSON.stringify(params === null || params === void 0 ? void 0 : params.export()));
71
81
  });
72
82
  }
73
83
  getLanguageDetectionProgress(accountUid, fileUid, languageDetectionUid) {
@@ -81,6 +91,25 @@ class SmartlingFileTranslationsApi extends base_1.SmartlingBaseApi {
81
91
  delete headers["content-type"];
82
92
  return headers;
83
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
+ }
84
113
  }
85
114
  exports.SmartlingFileTranslationsApi = SmartlingFileTranslationsApi;
86
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;AAU3C,wEAAm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IAAI,UAAU,UAAU,OAAO,uBAAuB,oBAAoB,SAAS,CACxG,CAAC;QACN,CAAC;KAAA;IAED,MAAM,CAAC,wBAAwB,CAAC,IAAc;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAElC,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;QAElD,OAAO,OAAO,CAAC,cAAc,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,MAAM,CAAO,mCAAmC,CACpD,QAAkB;;;YAElB,MAAM,WAAW,GAAG,MAAA,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,mCAAI,SAAS,CAAC;YACtE,MAAM,kBAAkB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;YACvE,IAAI,QAAQ,CAAC;YACb,IAAI,kBAAkB,EAAE;gBACpB,MAAM,aAAa,GAAG,kBAAkB,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;gBAC/E,IAAI,aAAa,EAAE;oBACf,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;iBACrD;aACJ;YACD,OAAO;gBACH,WAAW,EAAE,MAAM,QAAQ,CAAC,WAAW,EAAE;gBACzC,QAAQ;gBACR,WAAW;aACd,CAAC;;KACL;CACJ;AA7JD,oEA6JC"}
@@ -0,0 +1,5 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { FtsCallback } from "./fts-callback-parameter";
3
+ export declare class BaseParametersWithCallback extends BaseParameters {
4
+ setCallback(callback: FtsCallback): this;
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseParametersWithCallback = void 0;
4
+ const parameters_1 = require("../../parameters");
5
+ class BaseParametersWithCallback extends parameters_1.BaseParameters {
6
+ setCallback(callback) {
7
+ this.parameters.callback = callback;
8
+ return this;
9
+ }
10
+ }
11
+ exports.BaseParametersWithCallback = BaseParametersWithCallback;
12
+ //# sourceMappingURL=base-parameters-with-callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-parameters-with-callback.js","sourceRoot":"","sources":["../../../../api/file-translations/params/base-parameters-with-callback.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAGlD,MAAa,0BAA2B,SAAQ,2BAAc;IAC1D,WAAW,CAAC,QAAqB;QAC7B,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AALD,gEAKC"}
@@ -0,0 +1,4 @@
1
+ declare enum FtsCallbackMethod {
2
+ POST = "POST"
3
+ }
4
+ export { FtsCallbackMethod };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FtsCallbackMethod = void 0;
4
+ var FtsCallbackMethod;
5
+ (function (FtsCallbackMethod) {
6
+ FtsCallbackMethod["POST"] = "POST";
7
+ })(FtsCallbackMethod || (FtsCallbackMethod = {}));
8
+ exports.FtsCallbackMethod = FtsCallbackMethod;
9
+ //# sourceMappingURL=fts-callback-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fts-callback-method.js","sourceRoot":"","sources":["../../../../api/file-translations/params/fts-callback-method.ts"],"names":[],"mappings":";;;AAAA,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IAElB,kCAAa,CAAA;AACjB,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAEQ,8CAAiB"}
@@ -0,0 +1,7 @@
1
+ import { FtsCallbackMethod } from "./fts-callback-method";
2
+ interface FtsCallback {
3
+ url: string;
4
+ httpMethod: FtsCallbackMethod;
5
+ userData?: string;
6
+ }
7
+ export { FtsCallback };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=fts-callback-parameter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fts-callback-parameter.js","sourceRoot":"","sources":["../../../../api/file-translations/params/fts-callback-parameter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { BaseParametersWithCallback } from "./base-parameters-with-callback";
2
+ export declare class LanguageDetectionParameters extends BaseParametersWithCallback {
3
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LanguageDetectionParameters = void 0;
4
+ const base_parameters_with_callback_1 = require("./base-parameters-with-callback");
5
+ class LanguageDetectionParameters extends base_parameters_with_callback_1.BaseParametersWithCallback {
6
+ }
7
+ exports.LanguageDetectionParameters = LanguageDetectionParameters;
8
+ //# sourceMappingURL=language-detection-parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language-detection-parameters.js","sourceRoot":"","sources":["../../../../api/file-translations/params/language-detection-parameters.ts"],"names":[],"mappings":";;;AAAA,mFAA6E;AAE7E,MAAa,2BAA4B,SAAQ,0DAA0B;CAC1E;AADD,kEACC"}
@@ -1,5 +1,5 @@
1
- import { BaseParameters } from "../../parameters";
2
- export declare class TranslateFileParameters extends BaseParameters {
1
+ import { BaseParametersWithCallback } from "./base-parameters-with-callback";
2
+ export declare class TranslateFileParameters extends BaseParametersWithCallback {
3
3
  setSourceLocaleId(sourceLocaleId: string): TranslateFileParameters;
4
4
  setTargetLocaleIds(targetLocaleIds: string[]): TranslateFileParameters;
5
5
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TranslateFileParameters = void 0;
4
- const parameters_1 = require("../../parameters");
5
- class TranslateFileParameters extends parameters_1.BaseParameters {
4
+ const base_parameters_with_callback_1 = require("./base-parameters-with-callback");
5
+ class TranslateFileParameters extends base_parameters_with_callback_1.BaseParametersWithCallback {
6
6
  setSourceLocaleId(sourceLocaleId) {
7
7
  this.set("sourceLocaleId", sourceLocaleId);
8
8
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"translate-file-parameters.js","sourceRoot":"","sources":["../../../../api/file-translations/params/translate-file-parameters.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAElD,MAAa,uBAAwB,SAAQ,2BAAc;IACvD,iBAAiB,CAAC,cAAsB;QACpC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kBAAkB,CAAC,eAAyB;QACxC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAVD,0DAUC"}
1
+ {"version":3,"file":"translate-file-parameters.js","sourceRoot":"","sources":["../../../../api/file-translations/params/translate-file-parameters.ts"],"names":[],"mappings":";;;AAAA,mFAA6E;AAE7E,MAAa,uBAAwB,SAAQ,0DAA0B;IACnE,iBAAiB,CAAC,cAAsB;QACpC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kBAAkB,CAAC,eAAyB;QACxC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAVD,0DAUC"}
package/built/index.d.ts CHANGED
@@ -16,7 +16,10 @@ export * from "./api/context/params/list-parameters";
16
16
  export * from "./api/context/context-http-response";
17
17
  export * from "./api/exception/index";
18
18
  export * from "./api/file-translations/index";
19
+ export * from "./api/file-translations/params/fts-callback-parameter";
20
+ export * from "./api/file-translations/params/fts-callback-method";
19
21
  export * from "./api/file-translations/params/fts-upload-file-parameters";
22
+ export * from "./api/file-translations/params/language-detection-parameters";
20
23
  export * from "./api/file-translations/params/translate-file-parameters";
21
24
  export * from "./api/file-translations/dto/error";
22
25
  export * from "./api/file-translations/dto/fts-uploaded-file-dto";
package/built/index.js CHANGED
@@ -32,7 +32,10 @@ __exportStar(require("./api/context/params/list-parameters"), exports);
32
32
  __exportStar(require("./api/context/context-http-response"), exports);
33
33
  __exportStar(require("./api/exception/index"), exports);
34
34
  __exportStar(require("./api/file-translations/index"), exports);
35
+ __exportStar(require("./api/file-translations/params/fts-callback-parameter"), exports);
36
+ __exportStar(require("./api/file-translations/params/fts-callback-method"), exports);
35
37
  __exportStar(require("./api/file-translations/params/fts-upload-file-parameters"), exports);
38
+ __exportStar(require("./api/file-translations/params/language-detection-parameters"), exports);
36
39
  __exportStar(require("./api/file-translations/params/translate-file-parameters"), exports);
37
40
  __exportStar(require("./api/file-translations/dto/error"), exports);
38
41
  __exportStar(require("./api/file-translations/dto/fts-uploaded-file-dto"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kEAAgD;AAChD,mDAAiC;AACjC,sDAAoC;AACpC,sDAAoC;AACpC,wEAAsD;AACtD,6EAA2D;AAC3D,gEAA8C;AAC9C,4EAA0D;AAC1D,uEAAqD;AACrD,0FAAwE;AACxE,oEAAkD;AAClD,iFAA+D;AAC/D,kFAAgE;AAChE,uEAAqD;AACrD,sEAAoD;AACpD,wDAAsC;AACtC,gEAA8C;AAC9C,4FAA0E;AAC1E,2FAAyE;AACzE,oEAAkD;AAClD,oFAAkE;AAClE,qFAAmE;AACnE,uFAAqE;AACrE,4FAA0E;AAC1E,2EAAyD;AACzD,uEAAqD;AACrD,8EAA4D;AAC5D,4FAA0E;AAC1E,qFAAmE;AACnE,oDAAkC;AAClC,8EAA4D;AAC5D,6EAA2D;AAC3D,oEAAkD;AAClD,+DAA6C;AAC7C,4EAA0D;AAC1D,kFAAgE;AAChE,kFAAgE;AAChE,+EAA6D;AAC7D,oEAAkD;AAClD,qEAAmD;AACnD,0DAAwC;AACxC,kEAAgD;AAChD,uEAAqD;AACrD,yEAAuD;AACvD,yEAAuD;AACvD,4EAA0D;AAC1D,oFAAkE;AAClE,oFAAkE;AAClE,mFAAiE;AACjE,kFAAgE;AAChE,wFAAsE;AACtE,2FAAyE;AACzE,wFAAsE;AACtE,0FAAwE;AACxE,wEAAsD;AACtD,wEAAsD;AACtD,mFAAiE;AACjE,6EAA2D;AAC3D,mDAAiC;AACjC,8DAA4C;AAC5C,kFAAgE;AAChE,kEAAgD;AAChD,mEAAiD;AACjD,sEAAoD;AACpD,iEAA+C;AAC/C,yDAAuC;AACvC,iEAA+C;AAC/C,mFAAiE;AACjE,uFAAqE;AACrE,kEAAgD;AAChD,mEAAiD;AACjD,yEAAuD;AACvD,kEAAgD;AAChD,oEAAkD;AAClD,0EAAwD;AACxD,6EAA2D;AAC3D,4EAA0D;AAC1D,+DAA6C;AAC7C,8EAA4D;AAC5D,yEAAuD;AACvD,2EAAyD;AACzD,0EAAwD;AACxD,yEAAuD;AACvD,2EAAyD;AACzD,0EAAwD;AACxD,yDAAuC;AACvC,yDAAuC;AACvC,uDAAqC;AACrC,iEAA+C;AAC/C,gEAA8C;AAC9C,8DAA4C;AAC5C,+EAA6D;AAC7D,mGAAiF;AACjF,sDAAoC;AACpC,sEAAoD;AACpD,0EAAwD;AACxD,uFAAqE;AACrE,+CAA6B;AAC7B,wEAAsD;AACtD,+FAA6E;AAC7E,6EAA2D;AAC3D,gEAA8C;AAC9C,2EAAyD;AACzD,yEAAuD;AACvD,8DAA4C;AAC5C,mEAAiD;AACjD,8EAA4D;AAC5D,sDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kEAAgD;AAChD,mDAAiC;AACjC,sDAAoC;AACpC,sDAAoC;AACpC,wEAAsD;AACtD,6EAA2D;AAC3D,gEAA8C;AAC9C,4EAA0D;AAC1D,uEAAqD;AACrD,0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AAC9C,8DAA4C;AAC5C,+EAA6D;AAC7D,mGAAiF;AACjF,sDAAoC;AACpC,sEAAoD;AACpD,0EAAwD;AACxD,uFAAqE;AACrE,+CAA6B;AAC7B,wEAAsD;AACtD,+FAA6E;AAC7E,6EAA2D;AAC3D,gEAA8C;AAC9C,2EAAyD;AACzD,yEAAuD;AACvD,8DAA4C;AAC5C,mEAAiD;AACjD,8EAA4D;AAC5D,sDAAoC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartling-api-sdk-nodejs",
3
- "version": "2.16.1",
3
+ "version": "2.18.0",
4
4
  "description": "Package for Smartling API",
5
5
  "main": "built/index.js",
6
6
  "engines": {
package/index.ts CHANGED
@@ -16,7 +16,10 @@ export * from "./api/context/params/list-parameters";
16
16
  export * from "./api/context/context-http-response";
17
17
  export * from "./api/exception/index";
18
18
  export * from "./api/file-translations/index";
19
+ export * from "./api/file-translations/params/fts-callback-parameter";
20
+ export * from "./api/file-translations/params/fts-callback-method";
19
21
  export * from "./api/file-translations/params/fts-upload-file-parameters";
22
+ export * from "./api/file-translations/params/language-detection-parameters";
20
23
  export * from "./api/file-translations/params/translate-file-parameters";
21
24
  export * from "./api/file-translations/dto/error";
22
25
  export * from "./api/file-translations/dto/fts-uploaded-file-dto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartling-api-sdk-nodejs",
3
- "version": "2.16.1",
3
+ "version": "2.18.0",
4
4
  "description": "Package for Smartling API",
5
5
  "main": "built/index.js",
6
6
  "engines": {
@@ -9,6 +9,8 @@ import { FtsUploadFileParameters } from "../api/file-translations/params/fts-upl
9
9
  import { FileType } from "../api/files/params/file-type";
10
10
  import { streamToString } from "./stream-to-string";
11
11
  import { TranslateFileParameters } from "../api/file-translations/params/translate-file-parameters";
12
+ import { FtsCallbackMethod } from "../api/file-translations/params/fts-callback-method";
13
+ import { LanguageDetectionParameters } from "../api/file-translations/params/language-detection-parameters";
12
14
 
13
15
  describe("SmartlingFileTranslationsApi class tests.", () => {
14
16
  const userAgent = "test_user_agent";
@@ -21,6 +23,7 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
21
23
  let fileTranslationsApiFetchStub;
22
24
  let fileTranslationsApiUaStub;
23
25
  let responseMockJsonStub;
26
+ let getHeaderStub;
24
27
 
25
28
  beforeEach(() => {
26
29
  fileTranslationsApi = new SmartlingFileTranslationsApi(
@@ -37,12 +40,15 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
37
40
  responseMockJsonStub.returns({
38
41
  response: {}
39
42
  });
43
+ getHeaderStub = sinon.stub(responseMock.headers, "get");
44
+ getHeaderStub.returns(null);
40
45
  });
41
46
 
42
47
  afterEach(() => {
43
48
  fileTranslationsApiFetchStub.restore();
44
49
  fileTranslationsApiUaStub.restore();
45
50
  responseMockJsonStub.restore();
51
+ getHeaderStub.restore();
46
52
  });
47
53
 
48
54
  describe("Methods", () => {
@@ -323,6 +329,78 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
323
329
  );
324
330
  });
325
331
 
332
+ it("Translate file with callback and without user data", async () => {
333
+ const params = new TranslateFileParameters();
334
+
335
+ params
336
+ .setSourceLocaleId("en-US")
337
+ .setTargetLocaleIds(["de-DE", "fr-FR"])
338
+ .setCallback({
339
+ url: "https://myhost.com",
340
+ httpMethod: FtsCallbackMethod.POST
341
+ });
342
+
343
+ await fileTranslationsApi.translateFile(accountUid, fileUid, params);
344
+
345
+ sinon.assert.calledOnceWithExactly(
346
+ fileTranslationsApiFetchStub,
347
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt`,
348
+ {
349
+ method: "post",
350
+ headers: {
351
+ Authorization: "test_token_type test_access_token",
352
+ "Content-Type": "application/json",
353
+ "User-Agent": userAgent
354
+ },
355
+ body: JSON.stringify({
356
+ sourceLocaleId: "en-US",
357
+ targetLocaleIds: ["de-DE", "fr-FR"],
358
+ callback: {
359
+ url: "https://myhost.com",
360
+ httpMethod: "POST"
361
+ }
362
+ })
363
+ }
364
+ );
365
+ });
366
+
367
+ it("Translate file with callback and user data", async () => {
368
+ const params = new TranslateFileParameters();
369
+
370
+ params
371
+ .setSourceLocaleId("en-US")
372
+ .setTargetLocaleIds(["de-DE", "fr-FR"])
373
+ .setCallback({
374
+ url: "https://myhost.com",
375
+ httpMethod: FtsCallbackMethod.POST,
376
+ userData: "test user data"
377
+ });
378
+
379
+ await fileTranslationsApi.translateFile(accountUid, fileUid, params);
380
+
381
+ sinon.assert.calledOnceWithExactly(
382
+ fileTranslationsApiFetchStub,
383
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt`,
384
+ {
385
+ method: "post",
386
+ headers: {
387
+ Authorization: "test_token_type test_access_token",
388
+ "Content-Type": "application/json",
389
+ "User-Agent": userAgent
390
+ },
391
+ body: JSON.stringify({
392
+ sourceLocaleId: "en-US",
393
+ targetLocaleIds: ["de-DE", "fr-FR"],
394
+ callback: {
395
+ url: "https://myhost.com",
396
+ httpMethod: "POST",
397
+ userData: "test user data"
398
+ }
399
+ })
400
+ }
401
+ );
402
+ });
403
+
326
404
  it("Get translation progress", async () => {
327
405
  await fileTranslationsApi.getTranslationProgress(accountUid, fileUid, mtUid);
328
406
 
@@ -359,6 +437,89 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
359
437
  );
360
438
  });
361
439
 
440
+ it("Download translated file with metadata when no headers", async () => {
441
+ const localeId = "de-DE";
442
+
443
+ const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFileWithMetadata(
444
+ accountUid, fileUid, mtUid, localeId
445
+ );
446
+
447
+ sinon.assert.calledOnceWithExactly(
448
+ fileTranslationsApiFetchStub,
449
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
450
+ {
451
+ method: "get",
452
+ headers: {
453
+ Authorization: "test_token_type test_access_token",
454
+ "Content-Type": "application/json",
455
+ "User-Agent": userAgent
456
+ }
457
+ }
458
+ );
459
+
460
+ assert.ok(fileWithMetadata.contentType === undefined);
461
+ assert.ok(fileWithMetadata.fileName === undefined);
462
+ assert.ok(fileWithMetadata.fileContent.byteLength === 1);
463
+ });
464
+
465
+ it("Download translated file with metadata", async () => {
466
+ const localeId = "de-DE";
467
+
468
+ getHeaderStub.onCall(0).returns("application/xml");
469
+ getHeaderStub.onCall(1).returns("attachment; filename=\"test.xml\"");
470
+ getHeaderStub.returns(null);
471
+
472
+ const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFileWithMetadata(
473
+ accountUid, fileUid, mtUid, localeId
474
+ );
475
+
476
+ sinon.assert.calledOnceWithExactly(
477
+ fileTranslationsApiFetchStub,
478
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
479
+ {
480
+ method: "get",
481
+ headers: {
482
+ Authorization: "test_token_type test_access_token",
483
+ "Content-Type": "application/json",
484
+ "User-Agent": userAgent
485
+ }
486
+ }
487
+ );
488
+
489
+ assert.ok(fileWithMetadata.contentType === "application/xml");
490
+ assert.ok(fileWithMetadata.fileName === "test.xml");
491
+ assert.ok(fileWithMetadata.fileContent.byteLength === 1);
492
+ });
493
+
494
+ it("Download translated file with escaped quotes in the file name", async () => {
495
+ const localeId = "de-DE";
496
+
497
+ getHeaderStub.onCall(0).returns("application/xml");
498
+ getHeaderStub.onCall(1).returns("attachment; filename=\"test - \\\"phase 1\\\".xml\"");
499
+ getHeaderStub.returns(null);
500
+
501
+ const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFileWithMetadata(
502
+ accountUid, fileUid, mtUid, localeId
503
+ );
504
+
505
+ sinon.assert.calledOnceWithExactly(
506
+ fileTranslationsApiFetchStub,
507
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
508
+ {
509
+ method: "get",
510
+ headers: {
511
+ Authorization: "test_token_type test_access_token",
512
+ "Content-Type": "application/json",
513
+ "User-Agent": userAgent
514
+ }
515
+ }
516
+ );
517
+
518
+ assert.ok(fileWithMetadata.contentType === "application/xml");
519
+ assert.ok(fileWithMetadata.fileName === "test - \"phase 1\".xml");
520
+ assert.ok(fileWithMetadata.fileContent.byteLength === 1);
521
+ });
522
+
362
523
  it("Download translated files", async () => {
363
524
  await fileTranslationsApi.downloadTranslatedFiles(accountUid, fileUid, mtUid);
364
525
 
@@ -376,6 +537,56 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
376
537
  );
377
538
  });
378
539
 
540
+ it("Download translated files with metadata when no headers", async () => {
541
+ const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFilesWithMetadata(
542
+ accountUid, fileUid, mtUid
543
+ );
544
+
545
+ sinon.assert.calledOnceWithExactly(
546
+ fileTranslationsApiFetchStub,
547
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
548
+ {
549
+ method: "get",
550
+ headers: {
551
+ Authorization: "test_token_type test_access_token",
552
+ "Content-Type": "application/json",
553
+ "User-Agent": userAgent
554
+ }
555
+ }
556
+ );
557
+
558
+ assert.ok(fileWithMetadata.contentType === undefined);
559
+ assert.ok(fileWithMetadata.fileName === undefined);
560
+ assert.ok(fileWithMetadata.fileContent.byteLength === 1);
561
+ });
562
+
563
+ it("Download translated files with metadata", async () => {
564
+ getHeaderStub.onCall(0).returns("application/zip");
565
+ getHeaderStub.onCall(1).returns("attachment; filename=\"test.zip\"");
566
+ getHeaderStub.returns(null);
567
+
568
+ const fileWithMetadata = await fileTranslationsApi.downloadTranslatedFilesWithMetadata(
569
+ accountUid, fileUid, mtUid
570
+ );
571
+
572
+ sinon.assert.calledOnceWithExactly(
573
+ fileTranslationsApiFetchStub,
574
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
575
+ {
576
+ method: "get",
577
+ headers: {
578
+ Authorization: "test_token_type test_access_token",
579
+ "Content-Type": "application/json",
580
+ "User-Agent": userAgent
581
+ }
582
+ }
583
+ );
584
+
585
+ assert.ok(fileWithMetadata.contentType === "application/zip");
586
+ assert.ok(fileWithMetadata.fileName === "test.zip");
587
+ assert.ok(fileWithMetadata.fileContent.byteLength === 1);
588
+ });
589
+
379
590
  it("Cancel file translation", async () => {
380
591
  await fileTranslationsApi.cancelFileTranslation(accountUid, fileUid, mtUid);
381
592
 
@@ -410,6 +621,86 @@ describe("SmartlingFileTranslationsApi class tests.", () => {
410
621
  );
411
622
  });
412
623
 
624
+ it("Detect file language with empty parameters", async () => {
625
+ await fileTranslationsApi.detectFileLanguage(
626
+ accountUid, fileUid, new LanguageDetectionParameters()
627
+ );
628
+
629
+ sinon.assert.calledOnceWithExactly(
630
+ fileTranslationsApiFetchStub,
631
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/language-detection`,
632
+ {
633
+ method: "post",
634
+ headers: {
635
+ Authorization: "test_token_type test_access_token",
636
+ "Content-Type": "application/json",
637
+ "User-Agent": userAgent
638
+ },
639
+ body: JSON.stringify({})
640
+ }
641
+ );
642
+ });
643
+
644
+ it("Detect file language with callback and without user data", async () => {
645
+ const params = new LanguageDetectionParameters()
646
+ .setCallback({
647
+ url: "https://myhost.com",
648
+ httpMethod: FtsCallbackMethod.POST
649
+ });
650
+
651
+ await fileTranslationsApi.detectFileLanguage(accountUid, fileUid, params);
652
+
653
+ sinon.assert.calledOnceWithExactly(
654
+ fileTranslationsApiFetchStub,
655
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/language-detection`,
656
+ {
657
+ method: "post",
658
+ headers: {
659
+ Authorization: "test_token_type test_access_token",
660
+ "Content-Type": "application/json",
661
+ "User-Agent": userAgent
662
+ },
663
+ body: JSON.stringify({
664
+ callback: {
665
+ url: "https://myhost.com",
666
+ httpMethod: "POST"
667
+ }
668
+ })
669
+ }
670
+ );
671
+ });
672
+
673
+ it("Detect file language with callback and with user data", async () => {
674
+ const params = new LanguageDetectionParameters()
675
+ .setCallback({
676
+ url: "https://myhost.com",
677
+ httpMethod: FtsCallbackMethod.POST,
678
+ userData: "test user data"
679
+ });
680
+
681
+ await fileTranslationsApi.detectFileLanguage(accountUid, fileUid, params);
682
+
683
+ sinon.assert.calledOnceWithExactly(
684
+ fileTranslationsApiFetchStub,
685
+ `https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/language-detection`,
686
+ {
687
+ method: "post",
688
+ headers: {
689
+ Authorization: "test_token_type test_access_token",
690
+ "Content-Type": "application/json",
691
+ "User-Agent": userAgent
692
+ },
693
+ body: JSON.stringify({
694
+ callback: {
695
+ url: "https://myhost.com",
696
+ httpMethod: "POST",
697
+ userData: "test user data"
698
+ }
699
+ })
700
+ }
701
+ );
702
+ });
703
+
413
704
  it("Get language detection progress", async () => {
414
705
  await fileTranslationsApi.getLanguageDetectionProgress(
415
706
  accountUid,