smartling-api-sdk-nodejs 2.26.0 → 2.28.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/base-api.ts +205 -0
- package/api/base/base-file-api.ts +23 -0
- package/api/base/index.ts +2 -205
- package/api/file-translations/index.ts +5 -24
- package/api/files/index.ts +20 -2
- package/api/files/params/download-file-with-metadata-parameters.ts +12 -0
- package/api/files/params/filename-mode.ts +4 -0
- package/built/api/base/base-api.d.ts +26 -0
- package/built/api/base/base-api.js +163 -0
- package/built/api/base/base-api.js.map +1 -0
- package/built/api/base/base-file-api.d.ts +5 -0
- package/built/api/base/base-file-api.js +36 -0
- package/built/api/base/base-file-api.js.map +1 -0
- package/built/api/base/index.d.ts +2 -26
- package/built/api/base/index.js +5 -160
- package/built/api/base/index.js.map +1 -1
- package/built/api/dto/translated-file-dto.js.map +1 -0
- package/built/api/file-translations/index.d.ts +3 -4
- package/built/api/file-translations/index.js +3 -22
- package/built/api/file-translations/index.js.map +1 -1
- package/built/api/files/index.d.ts +5 -2
- package/built/api/files/index.js +7 -2
- package/built/api/files/index.js.map +1 -1
- package/built/api/files/params/download-file-with-metadata-parameters.d.ts +5 -0
- package/built/api/files/params/download-file-with-metadata-parameters.js +15 -0
- package/built/api/files/params/download-file-with-metadata-parameters.js.map +1 -0
- package/built/api/files/params/filename-mode.d.ts +4 -0
- package/built/api/files/params/filename-mode.js +9 -0
- package/built/api/files/params/filename-mode.js.map +1 -0
- package/built/index.d.ts +5 -1
- package/built/index.js +5 -1
- package/built/index.js.map +1 -1
- package/built/package.json +1 -1
- package/index.ts +5 -1
- package/package.json +1 -1
- package/test/base-file.spec.ts +57 -0
- package/test/files.spec.ts +272 -0
- package/built/api/file-translations/dto/translated-file-dto.js.map +0 -1
- /package/api/{file-translations/dto → dto}/translated-file-dto.ts +0 -0
- /package/built/api/{file-translations/dto → dto}/translated-file-dto.d.ts +0 -0
- /package/built/api/{file-translations/dto → dto}/translated-file-dto.js +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileNameMode = void 0;
|
|
4
|
+
var FileNameMode;
|
|
5
|
+
(function (FileNameMode) {
|
|
6
|
+
FileNameMode["ORIGINAL"] = "original";
|
|
7
|
+
FileNameMode["TRANSFORMED"] = "transformed";
|
|
8
|
+
})(FileNameMode = exports.FileNameMode || (exports.FileNameMode = {}));
|
|
9
|
+
//# sourceMappingURL=filename-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filename-mode.js","sourceRoot":"","sources":["../../../../api/files/params/filename-mode.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,qCAAqB,CAAA;IACrB,2CAA2B,CAAA;AAC/B,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB"}
|
package/built/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./api/auth/index";
|
|
|
2
2
|
export * from "./api/auth/dto/access-token-dto";
|
|
3
3
|
export * from "./api/auth/static-access-token-provider";
|
|
4
4
|
export * from "./api/auth/access-token-provider";
|
|
5
|
-
export * from "./api/base
|
|
5
|
+
export * from "./api/base";
|
|
6
6
|
export * from "./api/base/enum/response-body-type";
|
|
7
7
|
export * from "./api/builder/index";
|
|
8
8
|
export * from "./api/context/index";
|
|
@@ -17,6 +17,7 @@ export * from "./api/context/params/context-upload-parameters";
|
|
|
17
17
|
export * from "./api/context/params/create-bindings-parameters";
|
|
18
18
|
export * from "./api/context/params/list-parameters";
|
|
19
19
|
export * from "./api/context/context-http-response";
|
|
20
|
+
export * from "./api/dto/translated-file-dto";
|
|
20
21
|
export * from "./api/exception/index";
|
|
21
22
|
export * from "./api/file-translations/index";
|
|
22
23
|
export * from "./api/file-translations/params/fts-callback-parameter";
|
|
@@ -36,9 +37,11 @@ export * from "./api/file-translations/dto/translation-locale-status-dto";
|
|
|
36
37
|
export * from "./api/file-translations/dto/translation-status-dto";
|
|
37
38
|
export * from "./api/files/index";
|
|
38
39
|
export * from "./api/files/params/download-file-parameters";
|
|
40
|
+
export * from "./api/files/params/download-file-with-metadata-parameters";
|
|
39
41
|
export * from "./api/files/params/recently-uploaded-files";
|
|
40
42
|
export * from "./api/files/params/retrieval-type";
|
|
41
43
|
export * from "./api/files/params/file-type";
|
|
44
|
+
export * from "./api/files/params/filename-mode";
|
|
42
45
|
export * from "./api/files/params/upload-file-parameters";
|
|
43
46
|
export * from "./api/files/dto/file-status-for-all-locales-dto";
|
|
44
47
|
export * from "./api/files/dto/file-status-for-locale-item-dto";
|
|
@@ -163,6 +166,7 @@ export * from "./api/mt/params/source-text-item";
|
|
|
163
166
|
export * from "./api/mt/dto/translation-text-item-dto";
|
|
164
167
|
export * from "./api/reports/index";
|
|
165
168
|
export * from "./api/reports/dto/report-response";
|
|
169
|
+
export * from "./api/reports/dto/step-types";
|
|
166
170
|
export * from "./api/reports/dto/word-count-dto";
|
|
167
171
|
export * from "./api/reports/params/word-count-parameters";
|
|
168
172
|
export * from "./api/reports/params/date-formatter";
|
package/built/index.js
CHANGED
|
@@ -18,7 +18,7 @@ __exportStar(require("./api/auth/index"), exports);
|
|
|
18
18
|
__exportStar(require("./api/auth/dto/access-token-dto"), exports);
|
|
19
19
|
__exportStar(require("./api/auth/static-access-token-provider"), exports);
|
|
20
20
|
__exportStar(require("./api/auth/access-token-provider"), exports);
|
|
21
|
-
__exportStar(require("./api/base
|
|
21
|
+
__exportStar(require("./api/base"), exports);
|
|
22
22
|
__exportStar(require("./api/base/enum/response-body-type"), exports);
|
|
23
23
|
__exportStar(require("./api/builder/index"), exports);
|
|
24
24
|
__exportStar(require("./api/context/index"), exports);
|
|
@@ -33,6 +33,7 @@ __exportStar(require("./api/context/params/context-upload-parameters"), exports)
|
|
|
33
33
|
__exportStar(require("./api/context/params/create-bindings-parameters"), exports);
|
|
34
34
|
__exportStar(require("./api/context/params/list-parameters"), exports);
|
|
35
35
|
__exportStar(require("./api/context/context-http-response"), exports);
|
|
36
|
+
__exportStar(require("./api/dto/translated-file-dto"), exports);
|
|
36
37
|
__exportStar(require("./api/exception/index"), exports);
|
|
37
38
|
__exportStar(require("./api/file-translations/index"), exports);
|
|
38
39
|
__exportStar(require("./api/file-translations/params/fts-callback-parameter"), exports);
|
|
@@ -52,9 +53,11 @@ __exportStar(require("./api/file-translations/dto/translation-locale-status-dto"
|
|
|
52
53
|
__exportStar(require("./api/file-translations/dto/translation-status-dto"), exports);
|
|
53
54
|
__exportStar(require("./api/files/index"), exports);
|
|
54
55
|
__exportStar(require("./api/files/params/download-file-parameters"), exports);
|
|
56
|
+
__exportStar(require("./api/files/params/download-file-with-metadata-parameters"), exports);
|
|
55
57
|
__exportStar(require("./api/files/params/recently-uploaded-files"), exports);
|
|
56
58
|
__exportStar(require("./api/files/params/retrieval-type"), exports);
|
|
57
59
|
__exportStar(require("./api/files/params/file-type"), exports);
|
|
60
|
+
__exportStar(require("./api/files/params/filename-mode"), exports);
|
|
58
61
|
__exportStar(require("./api/files/params/upload-file-parameters"), exports);
|
|
59
62
|
__exportStar(require("./api/files/dto/file-status-for-all-locales-dto"), exports);
|
|
60
63
|
__exportStar(require("./api/files/dto/file-status-for-locale-item-dto"), exports);
|
|
@@ -179,6 +182,7 @@ __exportStar(require("./api/mt/params/source-text-item"), exports);
|
|
|
179
182
|
__exportStar(require("./api/mt/dto/translation-text-item-dto"), exports);
|
|
180
183
|
__exportStar(require("./api/reports/index"), exports);
|
|
181
184
|
__exportStar(require("./api/reports/dto/report-response"), exports);
|
|
185
|
+
__exportStar(require("./api/reports/dto/step-types"), exports);
|
|
182
186
|
__exportStar(require("./api/reports/dto/word-count-dto"), exports);
|
|
183
187
|
__exportStar(require("./api/reports/params/word-count-parameters"), exports);
|
|
184
188
|
__exportStar(require("./api/reports/params/date-formatter"), exports);
|
package/built/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kEAAgD;AAChD,0EAAwD;AACxD,mEAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"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"}
|
package/built/package.json
CHANGED
package/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./api/auth/index";
|
|
|
2
2
|
export * from "./api/auth/dto/access-token-dto";
|
|
3
3
|
export * from "./api/auth/static-access-token-provider";
|
|
4
4
|
export * from "./api/auth/access-token-provider";
|
|
5
|
-
export * from "./api/base
|
|
5
|
+
export * from "./api/base";
|
|
6
6
|
export * from "./api/base/enum/response-body-type";
|
|
7
7
|
export * from "./api/builder/index";
|
|
8
8
|
export * from "./api/context/index";
|
|
@@ -17,6 +17,7 @@ export * from "./api/context/params/context-upload-parameters";
|
|
|
17
17
|
export * from "./api/context/params/create-bindings-parameters";
|
|
18
18
|
export * from "./api/context/params/list-parameters";
|
|
19
19
|
export * from "./api/context/context-http-response";
|
|
20
|
+
export * from "./api/dto/translated-file-dto";
|
|
20
21
|
export * from "./api/exception/index";
|
|
21
22
|
export * from "./api/file-translations/index";
|
|
22
23
|
export * from "./api/file-translations/params/fts-callback-parameter";
|
|
@@ -36,9 +37,11 @@ export * from "./api/file-translations/dto/translation-locale-status-dto";
|
|
|
36
37
|
export * from "./api/file-translations/dto/translation-status-dto";
|
|
37
38
|
export * from "./api/files/index";
|
|
38
39
|
export * from "./api/files/params/download-file-parameters";
|
|
40
|
+
export * from "./api/files/params/download-file-with-metadata-parameters";
|
|
39
41
|
export * from "./api/files/params/recently-uploaded-files";
|
|
40
42
|
export * from "./api/files/params/retrieval-type";
|
|
41
43
|
export * from "./api/files/params/file-type";
|
|
44
|
+
export * from "./api/files/params/filename-mode";
|
|
42
45
|
export * from "./api/files/params/upload-file-parameters";
|
|
43
46
|
export * from "./api/files/dto/file-status-for-all-locales-dto";
|
|
44
47
|
export * from "./api/files/dto/file-status-for-locale-item-dto";
|
|
@@ -163,6 +166,7 @@ export * from "./api/mt/params/source-text-item";
|
|
|
163
166
|
export * from "./api/mt/dto/translation-text-item-dto";
|
|
164
167
|
export * from "./api/reports/index";
|
|
165
168
|
export * from "./api/reports/dto/report-response";
|
|
169
|
+
export * from "./api/reports/dto/step-types";
|
|
166
170
|
export * from "./api/reports/dto/word-count-dto";
|
|
167
171
|
export * from "./api/reports/params/word-count-parameters";
|
|
168
172
|
export * from "./api/reports/params/date-formatter";
|
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import sinon from "sinon";
|
|
3
|
+
import { responseMock } from "./mock";
|
|
4
|
+
import { SmartlingBaseFileApi } from "../api/base";
|
|
5
|
+
|
|
6
|
+
describe("SmartlingBaseFileApi class tests.", () => {
|
|
7
|
+
let mockResponse;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
mockResponse = {
|
|
11
|
+
...responseMock,
|
|
12
|
+
headers: {
|
|
13
|
+
get: sinon.stub().returns(null)
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("Methods", () => {
|
|
19
|
+
it("Convert response to dto when response doesn't have headers", async () => {
|
|
20
|
+
const fileWithMetadata = await SmartlingBaseFileApi.downloadResponseToTranslatedFileDto(
|
|
21
|
+
mockResponse as Response
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
assert.ok(fileWithMetadata.contentType === undefined);
|
|
25
|
+
assert.ok(fileWithMetadata.fileName === undefined);
|
|
26
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("Convert response to dto when response has headers", async () => {
|
|
30
|
+
mockResponse.headers.get.onCall(0).returns("application/xml");
|
|
31
|
+
mockResponse.headers.get.onCall(1).returns("attachment; filename=\"test.xml\"");
|
|
32
|
+
mockResponse.headers.get.returns(null);
|
|
33
|
+
|
|
34
|
+
const fileWithMetadata = await SmartlingBaseFileApi.downloadResponseToTranslatedFileDto(
|
|
35
|
+
mockResponse as Response
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
assert.ok(fileWithMetadata.contentType === "application/xml");
|
|
39
|
+
assert.ok(fileWithMetadata.fileName === "test.xml");
|
|
40
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("Convert response to dto when file name has quotes", async () => {
|
|
44
|
+
mockResponse.headers.get.onCall(0).returns("application/xml");
|
|
45
|
+
mockResponse.headers.get.onCall(1).returns("attachment; filename=\"test - \\\"phase 1\\\".xml\"");
|
|
46
|
+
mockResponse.headers.get.returns(null);
|
|
47
|
+
|
|
48
|
+
const fileWithMetadata = await SmartlingBaseFileApi.downloadResponseToTranslatedFileDto(
|
|
49
|
+
mockResponse as Response
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
assert.ok(fileWithMetadata.contentType === "application/xml");
|
|
53
|
+
assert.ok(fileWithMetadata.fileName === "test - \"phase 1\".xml");
|
|
54
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
package/test/files.spec.ts
CHANGED
|
@@ -5,12 +5,14 @@ import { SmartlingFilesApi } from "../api/files/index";
|
|
|
5
5
|
import { authMock, loggerMock, responseMock } from "./mock";
|
|
6
6
|
import { RetrievalType } from "../api/files/params/retrieval-type";
|
|
7
7
|
import { DownloadFileParameters } from "../api/files/params/download-file-parameters";
|
|
8
|
+
import { DownloadFileWithMetadataParameters } from "../api/files/params/download-file-with-metadata-parameters";
|
|
8
9
|
import { UploadFileParameters } from "../api/files/params/upload-file-parameters";
|
|
9
10
|
import { SmartlingAuthApi } from "../api/auth/index";
|
|
10
11
|
import { FileType } from "../api/files/params/file-type";
|
|
11
12
|
import { streamToString } from "./stream-to-string";
|
|
12
13
|
import { DownloadFileAllTranslationsParameters } from "../api/files/params/download-file-all-translations-parameters";
|
|
13
14
|
import { RecentlyUploadedFilesParameters } from "../api/files/params/recently-uploaded-files";
|
|
15
|
+
import { FileNameMode } from "../api/files/params/filename-mode";
|
|
14
16
|
|
|
15
17
|
describe("SmartlingFilesApi class tests.", () => {
|
|
16
18
|
const projectId = "testProjectId";
|
|
@@ -210,6 +212,276 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
210
212
|
});
|
|
211
213
|
});
|
|
212
214
|
|
|
215
|
+
describe("Download file with metadata", () => {
|
|
216
|
+
let getHeaderStub;
|
|
217
|
+
const localeId = "fr-FR";
|
|
218
|
+
let params: DownloadFileWithMetadataParameters;
|
|
219
|
+
|
|
220
|
+
beforeEach(() => {
|
|
221
|
+
params = new DownloadFileWithMetadataParameters();
|
|
222
|
+
getHeaderStub = sinon.stub(responseMock.headers, "get");
|
|
223
|
+
getHeaderStub.returns(null);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
afterEach(() => {
|
|
227
|
+
getHeaderStub.restore();
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("Download file when no headers in response", async () => {
|
|
231
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
232
|
+
projectId,
|
|
233
|
+
fileUri,
|
|
234
|
+
localeId,
|
|
235
|
+
params
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
239
|
+
sinon.assert.calledWithExactly(
|
|
240
|
+
filesApiFetchStub,
|
|
241
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?fileUri=testFileUri`,
|
|
242
|
+
{
|
|
243
|
+
headers: {
|
|
244
|
+
Authorization: "test_token_type test_access_token",
|
|
245
|
+
"Content-Type": "application/json",
|
|
246
|
+
"User-Agent": "test_user_agent"
|
|
247
|
+
},
|
|
248
|
+
method: "get"
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
assert.ok(fileWithMetadata.contentType === undefined);
|
|
253
|
+
assert.ok(fileWithMetadata.fileName === undefined);
|
|
254
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("Download file with metadata", async () => {
|
|
258
|
+
getHeaderStub.onCall(0).returns("application/xml");
|
|
259
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.xml\"");
|
|
260
|
+
getHeaderStub.returns(null);
|
|
261
|
+
|
|
262
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
263
|
+
projectId,
|
|
264
|
+
fileUri,
|
|
265
|
+
localeId,
|
|
266
|
+
params
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
270
|
+
sinon.assert.calledWithExactly(
|
|
271
|
+
filesApiFetchStub,
|
|
272
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?fileUri=testFileUri`,
|
|
273
|
+
{
|
|
274
|
+
headers: {
|
|
275
|
+
Authorization: "test_token_type test_access_token",
|
|
276
|
+
"Content-Type": "application/json",
|
|
277
|
+
"User-Agent": "test_user_agent"
|
|
278
|
+
},
|
|
279
|
+
method: "get"
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
assert.ok(fileWithMetadata.contentType === "application/xml");
|
|
284
|
+
assert.ok(fileWithMetadata.fileName === "test.xml");
|
|
285
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("Download file with fileNameMode original", async () => {
|
|
289
|
+
params.setFileNameMode(FileNameMode.ORIGINAL);
|
|
290
|
+
|
|
291
|
+
getHeaderStub.onCall(0).returns("application/xml");
|
|
292
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.xml\"");
|
|
293
|
+
getHeaderStub.returns(null);
|
|
294
|
+
|
|
295
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
296
|
+
projectId,
|
|
297
|
+
fileUri,
|
|
298
|
+
localeId,
|
|
299
|
+
params
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
303
|
+
sinon.assert.calledWithExactly(
|
|
304
|
+
filesApiFetchStub,
|
|
305
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?fileUri=testFileUri`,
|
|
306
|
+
{
|
|
307
|
+
headers: {
|
|
308
|
+
Authorization: "test_token_type test_access_token",
|
|
309
|
+
"Content-Type": "application/json",
|
|
310
|
+
"User-Agent": "test_user_agent"
|
|
311
|
+
},
|
|
312
|
+
method: "get"
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
assert.ok(fileWithMetadata.contentType === "application/xml");
|
|
317
|
+
assert.ok(fileWithMetadata.fileName === "test.xml");
|
|
318
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("Download file with fileNameMode transformed", async () => {
|
|
322
|
+
params.setFileNameMode(FileNameMode.TRANSFORMED);
|
|
323
|
+
|
|
324
|
+
getHeaderStub.onCall(0).returns("application/xml");
|
|
325
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.xml\"");
|
|
326
|
+
getHeaderStub.returns(null);
|
|
327
|
+
|
|
328
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
329
|
+
projectId,
|
|
330
|
+
fileUri,
|
|
331
|
+
localeId,
|
|
332
|
+
params
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
336
|
+
sinon.assert.calledWithExactly(
|
|
337
|
+
filesApiFetchStub,
|
|
338
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?changeFileName=true&fileUri=testFileUri`,
|
|
339
|
+
{
|
|
340
|
+
headers: {
|
|
341
|
+
Authorization: "test_token_type test_access_token",
|
|
342
|
+
"Content-Type": "application/json",
|
|
343
|
+
"User-Agent": "test_user_agent"
|
|
344
|
+
},
|
|
345
|
+
method: "get"
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
assert.ok(fileWithMetadata.contentType === "application/xml");
|
|
350
|
+
assert.ok(fileWithMetadata.fileName === "test.xml");
|
|
351
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it("Download file with debugMode enabled and retrievalType published", async () => {
|
|
355
|
+
params
|
|
356
|
+
.setRetrievalType(RetrievalType.PUBLISHED)
|
|
357
|
+
.enableDebugMode();
|
|
358
|
+
|
|
359
|
+
getHeaderStub.onCall(0).returns("application/json");
|
|
360
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.json\"");
|
|
361
|
+
getHeaderStub.returns(null);
|
|
362
|
+
|
|
363
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
364
|
+
projectId,
|
|
365
|
+
fileUri,
|
|
366
|
+
localeId,
|
|
367
|
+
params
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
371
|
+
sinon.assert.calledWithExactly(
|
|
372
|
+
filesApiFetchStub,
|
|
373
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&debugMode=1&fileUri=testFileUri`,
|
|
374
|
+
{
|
|
375
|
+
headers: {
|
|
376
|
+
Authorization: "test_token_type test_access_token",
|
|
377
|
+
"Content-Type": "application/json",
|
|
378
|
+
"User-Agent": "test_user_agent"
|
|
379
|
+
},
|
|
380
|
+
method: "get"
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
assert.ok(fileWithMetadata.contentType === "application/json");
|
|
384
|
+
assert.ok(fileWithMetadata.fileName === "test.json");
|
|
385
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it("Download file with debugMode disabled and retrievalType published", async () => {
|
|
389
|
+
params.setRetrievalType(RetrievalType.PUBLISHED);
|
|
390
|
+
|
|
391
|
+
getHeaderStub.onCall(0).returns("application/json");
|
|
392
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.json\"");
|
|
393
|
+
getHeaderStub.returns(null);
|
|
394
|
+
|
|
395
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
396
|
+
projectId,
|
|
397
|
+
fileUri,
|
|
398
|
+
localeId,
|
|
399
|
+
params
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
403
|
+
sinon.assert.calledWithExactly(
|
|
404
|
+
filesApiFetchStub,
|
|
405
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&fileUri=testFileUri`,
|
|
406
|
+
{
|
|
407
|
+
headers: {
|
|
408
|
+
Authorization: "test_token_type test_access_token",
|
|
409
|
+
"Content-Type": "application/json",
|
|
410
|
+
"User-Agent": "test_user_agent"
|
|
411
|
+
},
|
|
412
|
+
method: "get"
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
assert.ok(fileWithMetadata.contentType === "application/json");
|
|
416
|
+
assert.ok(fileWithMetadata.fileName === "test.json");
|
|
417
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it("Download file with includeOriginalStrings enabled", async() => {
|
|
421
|
+
params.setRetrievalType(RetrievalType.PUBLISHED).includeOriginalStrings();
|
|
422
|
+
|
|
423
|
+
getHeaderStub.onCall(0).returns("application/json");
|
|
424
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.json\"");
|
|
425
|
+
getHeaderStub.returns(null);
|
|
426
|
+
|
|
427
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
428
|
+
projectId,
|
|
429
|
+
fileUri,
|
|
430
|
+
localeId,
|
|
431
|
+
params
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
435
|
+
sinon.assert.calledWithExactly(
|
|
436
|
+
filesApiFetchStub,
|
|
437
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&includeOriginalStrings=true&fileUri=testFileUri`,
|
|
438
|
+
{
|
|
439
|
+
headers: {
|
|
440
|
+
Authorization: "test_token_type test_access_token",
|
|
441
|
+
"Content-Type": "application/json",
|
|
442
|
+
"User-Agent": "test_user_agent"
|
|
443
|
+
},
|
|
444
|
+
method: "get"
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
assert.ok(fileWithMetadata.contentType === "application/json");
|
|
448
|
+
assert.ok(fileWithMetadata.fileName === "test.json");
|
|
449
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
it("Download file with includeOriginalStrings disabled", async() => {
|
|
453
|
+
params.setRetrievalType(RetrievalType.PUBLISHED).excludeOriginalStrings();
|
|
454
|
+
|
|
455
|
+
getHeaderStub.onCall(0).returns("application/json");
|
|
456
|
+
getHeaderStub.onCall(1).returns("attachment; filename=\"test.json\"");
|
|
457
|
+
getHeaderStub.returns(null);
|
|
458
|
+
|
|
459
|
+
const fileWithMetadata = await filesApi.downloadFileWithMetadata(
|
|
460
|
+
projectId,
|
|
461
|
+
fileUri,
|
|
462
|
+
localeId,
|
|
463
|
+
params
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
467
|
+
sinon.assert.calledWithExactly(
|
|
468
|
+
filesApiFetchStub,
|
|
469
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&includeOriginalStrings=false&fileUri=testFileUri`,
|
|
470
|
+
{
|
|
471
|
+
headers: {
|
|
472
|
+
Authorization: "test_token_type test_access_token",
|
|
473
|
+
"Content-Type": "application/json",
|
|
474
|
+
"User-Agent": "test_user_agent"
|
|
475
|
+
},
|
|
476
|
+
method: "get"
|
|
477
|
+
}
|
|
478
|
+
);
|
|
479
|
+
assert.ok(fileWithMetadata.contentType === "application/json");
|
|
480
|
+
assert.ok(fileWithMetadata.fileName === "test.json");
|
|
481
|
+
assert.ok(fileWithMetadata.fileContent.byteLength === 1);
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
|
|
213
485
|
describe("Download file - all translations", () => {
|
|
214
486
|
let params: DownloadFileAllTranslationsParameters;
|
|
215
487
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translated-file-dto.js","sourceRoot":"","sources":["../../../../api/file-translations/dto/translated-file-dto.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|