smartling-api-sdk-nodejs 1.1.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.scannerwork/report-task.txt +2 -2
- package/api/base/index.ts +1 -1
- package/api/builder/index.ts +8 -8
- package/api/files/index.ts +1 -8
- package/api/files/params/upload-file-parameters.ts +24 -2
- package/api/job-batches/index.ts +1 -6
- package/api/job-batches/params/upload-batch-file-parameters.ts +24 -1
- package/built/api/base/index.js +2 -21
- package/built/api/base/index.js.map +1 -1
- package/built/api/builder/index.d.ts +8 -8
- package/built/api/builder/index.js.map +1 -1
- package/built/api/files/index.js +1 -26
- package/built/api/files/index.js.map +1 -1
- package/built/api/files/params/upload-file-parameters.d.ts +3 -1
- package/built/api/files/params/upload-file-parameters.js +34 -2
- package/built/api/files/params/upload-file-parameters.js.map +1 -1
- package/built/api/job-batches/index.js +1 -24
- package/built/api/job-batches/index.js.map +1 -1
- package/built/api/job-batches/params/upload-batch-file-parameters.d.ts +2 -0
- package/built/api/job-batches/params/upload-batch-file-parameters.js +33 -1
- package/built/api/job-batches/params/upload-batch-file-parameters.js.map +1 -1
- package/built/package.json +6 -5
- package/package.json +6 -5
- package/test/files.spec.ts +59 -2
- package/test/job-batches.spec.ts +62 -2
- package/test/stream-to-string.ts +16 -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=AX5U6aJEEoKIQwCSYHJh
|
|
6
|
+
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AX5U6aJEEoKIQwCSYHJh
|
package/api/base/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import merge from "merge-deep";
|
|
2
2
|
import ua from "default-user-agent";
|
|
3
3
|
import FormData from "form-data";
|
|
4
|
-
import
|
|
4
|
+
import fetch from "cross-fetch";
|
|
5
5
|
import { ParsedUrlQueryInput, stringify } from "querystring";
|
|
6
6
|
import { Logger } from "../logger";
|
|
7
7
|
import { SmartlingException } from "../exception/index";
|
package/api/builder/index.ts
CHANGED
|
@@ -6,14 +6,14 @@ import { Logger } from "../logger";
|
|
|
6
6
|
const packageJson = require("../../package.json");
|
|
7
7
|
|
|
8
8
|
export class SmartlingApiClientBuilder {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
protected authApiClient: SmartlingAuthApi = null;
|
|
10
|
+
protected userId: string = null;
|
|
11
|
+
protected userSecret: string = null;
|
|
12
|
+
protected baseSmartlingApiUrl: string;
|
|
13
|
+
protected httpClientOptions: Record<string, unknown> = {};
|
|
14
|
+
protected clientLibId: string = packageJson.name;
|
|
15
|
+
protected clientLibVersion: string = packageJson.version;
|
|
16
|
+
protected logger: Logger = {
|
|
17
17
|
/* eslint-disable-next-line @typescript-eslint/no-empty-function */
|
|
18
18
|
debug: () => {},
|
|
19
19
|
/* eslint-disable-next-line @typescript-eslint/no-empty-function */
|
package/api/files/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import FormData from "form-data";
|
|
2
|
-
import * as fs from "fs";
|
|
3
2
|
import { SmartlingBaseApi } from "../base/index";
|
|
4
3
|
import { SmartlingAuthApi } from "../auth/index";
|
|
5
4
|
import { Logger } from "../logger";
|
|
@@ -68,13 +67,7 @@ export class SmartlingFilesApi extends SmartlingBaseApi {
|
|
|
68
67
|
const formData = new FormData();
|
|
69
68
|
const exported = parameters.export();
|
|
70
69
|
Object.keys(exported).forEach((key) => {
|
|
71
|
-
|
|
72
|
-
formData.append(key, fs.createReadStream(
|
|
73
|
-
fs.realpathSync(exported[key])
|
|
74
|
-
));
|
|
75
|
-
} else {
|
|
76
|
-
formData.append(key, exported[key]);
|
|
77
|
-
}
|
|
70
|
+
formData.append(key, exported[key]);
|
|
78
71
|
});
|
|
79
72
|
|
|
80
73
|
return await this.makeRequest(
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import string2fileStream from "string-to-file-stream";
|
|
1
3
|
import { BaseParameters } from "../../parameters/index";
|
|
2
4
|
import { FileType } from "./file-type";
|
|
3
5
|
|
|
@@ -8,8 +10,28 @@ export class UploadFileParameters extends BaseParameters {
|
|
|
8
10
|
return this;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated This method will be deleted in 2.0.0
|
|
15
|
+
* @param filePath
|
|
16
|
+
* @returns UploadFileParameters
|
|
17
|
+
*/
|
|
18
|
+
setFile(filePath: string): UploadFileParameters {
|
|
19
|
+
this.set("file", fs.createReadStream(
|
|
20
|
+
fs.realpathSync(filePath)
|
|
21
|
+
));
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setFileFromLocalFilePath(filePath: string): UploadFileParameters {
|
|
26
|
+
this.set("file", fs.createReadStream(
|
|
27
|
+
fs.realpathSync(filePath)
|
|
28
|
+
));
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setFileContent(fileContent: string): UploadFileParameters {
|
|
33
|
+
this.set("file", string2fileStream(fileContent));
|
|
34
|
+
|
|
13
35
|
return this;
|
|
14
36
|
}
|
|
15
37
|
|
package/api/job-batches/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
1
|
import FormData from "form-data";
|
|
3
2
|
import { SmartlingBaseApi } from "../base/index";
|
|
4
3
|
import { SmartlingAuthApi } from "../auth/index";
|
|
@@ -23,11 +22,7 @@ export class SmartlingJobBatchesApi extends SmartlingBaseApi {
|
|
|
23
22
|
const formData = new FormData();
|
|
24
23
|
|
|
25
24
|
Object.keys(opts.body).forEach((key) => {
|
|
26
|
-
if (key
|
|
27
|
-
formData.append(key, fs.createReadStream(
|
|
28
|
-
fs.realpathSync(opts.body[key])
|
|
29
|
-
));
|
|
30
|
-
} else if (Array.isArray(opts.body[key])) {
|
|
25
|
+
if (Array.isArray(opts.body[key])) {
|
|
31
26
|
opts.body[key].forEach((value) => {
|
|
32
27
|
formData.append(`${key}[]`, value);
|
|
33
28
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import string2fileStream from "string-to-file-stream";
|
|
1
3
|
import { BaseParameters } from "../../parameters/index";
|
|
2
4
|
import { FileType } from "../../files/params/file-type";
|
|
3
5
|
|
|
@@ -23,8 +25,29 @@ export class UploadBatchFileParameters extends BaseParameters {
|
|
|
23
25
|
return this;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated This method will be deleted in 2.0.0
|
|
30
|
+
* @param filePath
|
|
31
|
+
* @returns UploadBatchFileParameters
|
|
32
|
+
*/
|
|
26
33
|
setFile(filePath: string): UploadBatchFileParameters {
|
|
27
|
-
this.set("file",
|
|
34
|
+
this.set("file", fs.createReadStream(
|
|
35
|
+
fs.realpathSync(filePath)
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setFileFromLocalFilePath(filePath: string): UploadBatchFileParameters {
|
|
42
|
+
this.set("file", fs.createReadStream(
|
|
43
|
+
fs.realpathSync(filePath)
|
|
44
|
+
));
|
|
45
|
+
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setFileContent(fileContent: string): UploadBatchFileParameters {
|
|
50
|
+
this.set("file", string2fileStream(fileContent));
|
|
28
51
|
|
|
29
52
|
return this;
|
|
30
53
|
}
|
package/built/api/base/index.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
15
|
exports.SmartlingBaseApi = void 0;
|
|
35
16
|
const merge_deep_1 = __importDefault(require("merge-deep"));
|
|
36
17
|
const default_user_agent_1 = __importDefault(require("default-user-agent"));
|
|
37
|
-
const
|
|
18
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
38
19
|
const querystring_1 = require("querystring");
|
|
39
20
|
const index_1 = require("../exception/index");
|
|
40
21
|
const packageJson = require("../../package.json");
|
|
@@ -65,7 +46,7 @@ class SmartlingBaseApi {
|
|
|
65
46
|
}
|
|
66
47
|
fetch(uri, options) {
|
|
67
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return yield
|
|
49
|
+
return yield (0, cross_fetch_1.default)(uri, options);
|
|
69
50
|
});
|
|
70
51
|
}
|
|
71
52
|
ua(clientId, clientVersion) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/base/index.ts"],"names":[],"mappings":"
|
|
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;AAIxD,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,cAAc;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAEM,cAAc,CAAC,WAAmB;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAEM,mBAAmB;QACtB,OAAO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AQ,CAAC,IAAI,EAAE;oBACpC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;iBACpD,CAAC,CAAC;aACN;;KACJ;CACJ;AAlKD,4CAkKC"}
|
|
@@ -2,14 +2,14 @@ import { SmartlingAuthApi } from "../auth/index";
|
|
|
2
2
|
import { SmartlingBaseApi } from "../base/index";
|
|
3
3
|
import { Logger } from "../logger";
|
|
4
4
|
export declare class SmartlingApiClientBuilder {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
protected authApiClient: SmartlingAuthApi;
|
|
6
|
+
protected userId: string;
|
|
7
|
+
protected userSecret: string;
|
|
8
|
+
protected baseSmartlingApiUrl: string;
|
|
9
|
+
protected httpClientOptions: Record<string, unknown>;
|
|
10
|
+
protected clientLibId: string;
|
|
11
|
+
protected clientLibVersion: string;
|
|
12
|
+
protected logger: Logger;
|
|
13
13
|
setLogger(logger: Logger): SmartlingApiClientBuilder;
|
|
14
14
|
setBaseSmartlingApiUrl(baseSmartlingApiUrl: string): SmartlingApiClientBuilder;
|
|
15
15
|
setHttpClientConfiguration(httpClientOptions: Record<string, unknown>): SmartlingApiClientBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/builder/index.ts"],"names":[],"mappings":";;;AAAA,yCAAiD;AAKjD,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,MAAa,yBAAyB;IAAtC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/builder/index.ts"],"names":[],"mappings":";;;AAAA,yCAAiD;AAKjD,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,MAAa,yBAAyB;IAAtC;QACc,kBAAa,GAAqB,IAAI,CAAC;QACvC,WAAM,GAAW,I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AAU,KAAK,IAAI,EAAE;YACjF,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAgB,CACrC,IAAI,CAAC,mBAAmB,EACxB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,CACd,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACpD,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACjE;QAED,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAE5F,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACpD,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAE5C,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AApFD,8DAoFC"}
|
package/built/api/files/index.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -33,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
15
|
exports.SmartlingFilesApi = void 0;
|
|
35
16
|
const form_data_1 = __importDefault(require("form-data"));
|
|
36
|
-
const fs = __importStar(require("fs"));
|
|
37
17
|
const index_1 = require("../base/index");
|
|
38
18
|
class SmartlingFilesApi extends index_1.SmartlingBaseApi {
|
|
39
19
|
constructor(smartlingApiBaseUrl, authApi, logger) {
|
|
@@ -68,12 +48,7 @@ class SmartlingFilesApi extends index_1.SmartlingBaseApi {
|
|
|
68
48
|
const formData = new form_data_1.default();
|
|
69
49
|
const exported = parameters.export();
|
|
70
50
|
Object.keys(exported).forEach((key) => {
|
|
71
|
-
|
|
72
|
-
formData.append(key, fs.createReadStream(fs.realpathSync(exported[key])));
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
formData.append(key, exported[key]);
|
|
76
|
-
}
|
|
51
|
+
formData.append(key, exported[key]);
|
|
77
52
|
});
|
|
78
53
|
return yield this.makeRequest("post", `${this.entrypoint}/${projectId}/file`, formData, false, SmartlingFilesApi.fixContentTypeHeaderCase(formData));
|
|
79
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/files/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{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,UAAU,IAAI,SAAS,cAAc,EAC7C,IAAI,EACJ,KAAK,EACL,iBAAiB,CAAC,wBAAwB,CAAC,IAAI,CAAC,CACnD,CAAC;QACN,CAAC;KAAA;IAEK,UAAU,CACZ,SAAiB,EAAE,UAAgC;;YAEnD,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAClC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;YAEH,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,MAAM,EACN,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,OAAO,EACtC,QAAQ,EACR,KAAK,EACL,iBAAiB,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CACvD,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;CACJ;AA9ED,8CA8EC"}
|
|
@@ -2,7 +2,9 @@ import { BaseParameters } from "../../parameters/index";
|
|
|
2
2
|
import { FileType } from "./file-type";
|
|
3
3
|
export declare class UploadFileParameters extends BaseParameters {
|
|
4
4
|
setDirective(key: string, value: string): UploadFileParameters;
|
|
5
|
-
setFile(
|
|
5
|
+
setFile(filePath: string): UploadFileParameters;
|
|
6
|
+
setFileFromLocalFilePath(filePath: string): UploadFileParameters;
|
|
7
|
+
setFileContent(fileContent: string): UploadFileParameters;
|
|
6
8
|
setFileType(fileType: FileType): UploadFileParameters;
|
|
7
9
|
setFileUri(fileUri: string): UploadFileParameters;
|
|
8
10
|
}
|
|
@@ -1,14 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
2
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
25
|
exports.UploadFileParameters = void 0;
|
|
26
|
+
const fs = __importStar(require("fs"));
|
|
27
|
+
const string_to_file_stream_1 = __importDefault(require("string-to-file-stream"));
|
|
4
28
|
const index_1 = require("../../parameters/index");
|
|
5
29
|
class UploadFileParameters extends index_1.BaseParameters {
|
|
6
30
|
setDirective(key, value) {
|
|
7
31
|
this.set(`smartling.${key}`, value);
|
|
8
32
|
return this;
|
|
9
33
|
}
|
|
10
|
-
setFile(
|
|
11
|
-
this.set("file",
|
|
34
|
+
setFile(filePath) {
|
|
35
|
+
this.set("file", fs.createReadStream(fs.realpathSync(filePath)));
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
setFileFromLocalFilePath(filePath) {
|
|
39
|
+
this.set("file", fs.createReadStream(fs.realpathSync(filePath)));
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
setFileContent(fileContent) {
|
|
43
|
+
this.set("file", (0, string_to_file_stream_1.default)(fileContent));
|
|
12
44
|
return this;
|
|
13
45
|
}
|
|
14
46
|
setFileType(fileType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-file-parameters.js","sourceRoot":"","sources":["../../../../api/files/params/upload-file-parameters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload-file-parameters.js","sourceRoot":"","sources":["../../../../api/files/params/upload-file-parameters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,kFAAsD;AACtD,kDAAwD;AAGxD,MAAa,oBAAqB,SAAQ,sBAAc;IACpD,YAAY,CAAC,GAAW,EAAE,KAAa;QACnC,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC;IAChB,CAAC;IAOD,OAAO,CAAC,QAAgB;QACpB,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,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;QAEjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,QAAkB;QAC1B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,OAAe;QACtB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAzCD,oDAyCC"}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -32,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
15
|
exports.SmartlingJobBatchesApi = void 0;
|
|
35
|
-
const fs = __importStar(require("fs"));
|
|
36
16
|
const form_data_1 = __importDefault(require("form-data"));
|
|
37
17
|
const index_1 = require("../base/index");
|
|
38
18
|
class SmartlingJobBatchesApi extends index_1.SmartlingBaseApi {
|
|
@@ -45,10 +25,7 @@ class SmartlingJobBatchesApi extends index_1.SmartlingBaseApi {
|
|
|
45
25
|
if (uri.match(/job-batches-api\/.*\/projects\/.*\/batches\/.*\/file$/g)) {
|
|
46
26
|
const formData = new form_data_1.default();
|
|
47
27
|
Object.keys(opts.body).forEach((key) => {
|
|
48
|
-
if (key
|
|
49
|
-
formData.append(key, fs.createReadStream(fs.realpathSync(opts.body[key])));
|
|
50
|
-
}
|
|
51
|
-
else if (Array.isArray(opts.body[key])) {
|
|
28
|
+
if (Array.isArray(opts.body[key])) {
|
|
52
29
|
opts.body[key].forEach((value) => {
|
|
53
30
|
formData.append(`${key}[]`, value);
|
|
54
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/job-batches/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/job-batches/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAiC;AACjC,yCAAiD;AAUjD,MAAa,sBAAuB,SAAQ,wBAAgB;IACxD,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,8BAA8B,CAAC;IAC3E,CAAC;IAGD,gBAAgB,CAAC,GAAW,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,CAAC,MAAM,EAAE,CAAC,CAClC,CAAC;QACN,CAAC;KAAA;IAEK,eAAe,CACjB,SAAiB,EAAE,QAAgB,EAAE,MAAiC;;YAEtE,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,YAAY,QAAQ,EAAE,EACrD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAClC,CAAC;QACN,CAAC;KAAA;IAEK,eAAe,CACjB,SAAiB,EAAE,QAAgB,EAAE,MAAiC;;YAEtE,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,MAAM,EACN,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,YAAY,QAAQ,OAAO,EAC1D,MAAM,CAAC,MAAM,EAAE,CAClB,CAAC;QACN,CAAC;KAAA;IAEK,cAAc,CAAC,SAAiB,EAAE,QAAgB;;YACpD,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,YAAY,QAAQ,EAAE,CACxD,CAAC;QACN,CAAC;KAAA;CACJ;AAzED,wDAyEC"}
|
|
@@ -5,6 +5,8 @@ export declare class UploadBatchFileParameters extends BaseParameters {
|
|
|
5
5
|
setCallbackUrl(callbackUrl: string): UploadBatchFileParameters;
|
|
6
6
|
setLocalesToApprove(localesToApprove: Array<string>): UploadBatchFileParameters;
|
|
7
7
|
setFile(filePath: string): UploadBatchFileParameters;
|
|
8
|
+
setFileFromLocalFilePath(filePath: string): UploadBatchFileParameters;
|
|
9
|
+
setFileContent(fileContent: string): UploadBatchFileParameters;
|
|
8
10
|
setFileUri(fileUri: string): UploadBatchFileParameters;
|
|
9
11
|
setFileType(fileType: FileType): UploadBatchFileParameters;
|
|
10
12
|
setDirective(key: string, value: string): UploadBatchFileParameters;
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
2
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
25
|
exports.UploadBatchFileParameters = void 0;
|
|
26
|
+
const fs = __importStar(require("fs"));
|
|
27
|
+
const string_to_file_stream_1 = __importDefault(require("string-to-file-stream"));
|
|
4
28
|
const index_1 = require("../../parameters/index");
|
|
5
29
|
class UploadBatchFileParameters extends index_1.BaseParameters {
|
|
6
30
|
setClientLibId(clientLibId, version) {
|
|
@@ -19,7 +43,15 @@ class UploadBatchFileParameters extends index_1.BaseParameters {
|
|
|
19
43
|
return this;
|
|
20
44
|
}
|
|
21
45
|
setFile(filePath) {
|
|
22
|
-
this.set("file", filePath);
|
|
46
|
+
this.set("file", fs.createReadStream(fs.realpathSync(filePath)));
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
setFileFromLocalFilePath(filePath) {
|
|
50
|
+
this.set("file", fs.createReadStream(fs.realpathSync(filePath)));
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
setFileContent(fileContent) {
|
|
54
|
+
this.set("file", (0, string_to_file_stream_1.default)(fileContent));
|
|
23
55
|
return this;
|
|
24
56
|
}
|
|
25
57
|
setFileUri(fileUri) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-batch-file-parameters.js","sourceRoot":"","sources":["../../../../api/job-batches/params/upload-batch-file-parameters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload-batch-file-parameters.js","sourceRoot":"","sources":["../../../../api/job-batches/params/upload-batch-file-parameters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,kFAAsD;AACtD,kDAAwD;AAGxD,MAAa,yBAA0B,SAAQ,sBAAc;IACzD,cAAc,CAAC,WAAmB,EAAE,OAAe;QAC/C,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,SAAS,CAAC;YAC/C,MAAM,EAAE,WAAW;YACnB,OAAO;SACV,CAAC,CAAC,CAAC;QAEJ,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,mBAAmB,CAAC,gBAA+B;QAC/C,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IAChB,CAAC;IAOD,OAAO,CAAC,QAAgB;QACpB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAChC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAC5B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,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;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAA,+BAAiB,EAAC,WAAW,CAAC,CAAC,CAAC;QAEjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,OAAe;QACtB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,QAAkB;QAC1B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,YAAY,CAAC,GAAW,EAAE,KAAa;QACnC,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAlED,8DAkEC"}
|
package/built/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartling-api-sdk-nodejs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Package for Smartling API",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@types/mocha": "^9.0.0",
|
|
29
29
|
"@types/node": "^16.4.7",
|
|
30
|
+
"cross-fetch": "^3.1.4",
|
|
30
31
|
"default-user-agent": "^1.0.0",
|
|
31
32
|
"form-data": "^4.0.0",
|
|
32
33
|
"merge-deep": "^3.0.3",
|
|
33
|
-
"node-fetch": "^2.6.1",
|
|
34
34
|
"querystring": "^0.2.1",
|
|
35
35
|
"string-to-file-stream": "^1.3.0",
|
|
36
36
|
"typescript": "^4.3.5"
|
|
@@ -40,10 +40,11 @@
|
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^4.29.0",
|
|
41
41
|
"@typescript-eslint/parser": "^4.29.0",
|
|
42
42
|
"eslint": "^7.31.0",
|
|
43
|
-
"mocha": "^9.
|
|
44
|
-
"mocha-junit-reporter": "^2.0.
|
|
43
|
+
"mocha": "^9.1.3",
|
|
44
|
+
"mocha-junit-reporter": "^2.0.2",
|
|
45
45
|
"nyc": "^15.1.0",
|
|
46
|
-
"sinon": "^11.1.2"
|
|
46
|
+
"sinon": "^11.1.2",
|
|
47
|
+
"ansi-regex": "^5.0.1"
|
|
47
48
|
},
|
|
48
49
|
"nyc": {
|
|
49
50
|
"reporter": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartling-api-sdk-nodejs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Package for Smartling API",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@types/mocha": "^9.0.0",
|
|
29
29
|
"@types/node": "^16.4.7",
|
|
30
|
+
"cross-fetch": "^3.1.4",
|
|
30
31
|
"default-user-agent": "^1.0.0",
|
|
31
32
|
"form-data": "^4.0.0",
|
|
32
33
|
"merge-deep": "^3.0.3",
|
|
33
|
-
"node-fetch": "^2.6.1",
|
|
34
34
|
"querystring": "^0.2.1",
|
|
35
35
|
"string-to-file-stream": "^1.3.0",
|
|
36
36
|
"typescript": "^4.3.5"
|
|
@@ -40,10 +40,11 @@
|
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^4.29.0",
|
|
41
41
|
"@typescript-eslint/parser": "^4.29.0",
|
|
42
42
|
"eslint": "^7.31.0",
|
|
43
|
-
"mocha": "^9.
|
|
44
|
-
"mocha-junit-reporter": "^2.0.
|
|
43
|
+
"mocha": "^9.1.3",
|
|
44
|
+
"mocha-junit-reporter": "^2.0.2",
|
|
45
45
|
"nyc": "^15.1.0",
|
|
46
|
-
"sinon": "^11.1.2"
|
|
46
|
+
"sinon": "^11.1.2",
|
|
47
|
+
"ansi-regex": "^5.0.1"
|
|
47
48
|
},
|
|
48
49
|
"nyc": {
|
|
49
50
|
"reporter": [
|
package/test/files.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
1
2
|
import sinon from "sinon";
|
|
2
3
|
import assert from "assert";
|
|
3
4
|
import { SmartlingFilesApi } from "../api/files/index";
|
|
@@ -7,6 +8,7 @@ import { DownloadFileParameters } from "../api/files/params/download-file-parame
|
|
|
7
8
|
import { UploadFileParameters } from "../api/files/params/upload-file-parameters";
|
|
8
9
|
import { SmartlingAuthApi } from "../api/auth/index";
|
|
9
10
|
import { FileType } from "../api/files/params/file-type";
|
|
11
|
+
import { streamToString } from "./stream-to-string";
|
|
10
12
|
|
|
11
13
|
describe("SmartlingFilesApi class tests.", () => {
|
|
12
14
|
const projectId = "testProjectId";
|
|
@@ -133,11 +135,11 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
133
135
|
);
|
|
134
136
|
});
|
|
135
137
|
|
|
136
|
-
it("Upload file", async () => {
|
|
138
|
+
it("Upload file: from disk", async () => {
|
|
137
139
|
const params = new UploadFileParameters();
|
|
138
140
|
|
|
139
141
|
params
|
|
140
|
-
.
|
|
142
|
+
.setFileFromLocalFilePath("./test/data/file.xml")
|
|
141
143
|
.setFileUri("test-file-uri")
|
|
142
144
|
.setFileType(FileType.XML)
|
|
143
145
|
.setDirective("foo", "bar");
|
|
@@ -165,6 +167,61 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
165
167
|
filesApiFetchStub.getCall(0).args[1].headers["User-Agent"],
|
|
166
168
|
"test_user_agent"
|
|
167
169
|
);
|
|
170
|
+
|
|
171
|
+
assert.equal(
|
|
172
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
173
|
+
await streamToString(filesApiFetchStub.getCall(0).args[1].body._streams[1]),
|
|
174
|
+
fs.readFileSync(
|
|
175
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
176
|
+
"utf8"
|
|
177
|
+
)
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("Upload file: as string", async () => {
|
|
182
|
+
const params = new UploadFileParameters();
|
|
183
|
+
|
|
184
|
+
params
|
|
185
|
+
.setFileContent(fs.readFileSync(
|
|
186
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
187
|
+
"utf8"
|
|
188
|
+
))
|
|
189
|
+
.setFileUri("test-file-uri")
|
|
190
|
+
.setFileType(FileType.XML)
|
|
191
|
+
.setDirective("foo", "bar");
|
|
192
|
+
|
|
193
|
+
await filesApi.uploadFile(projectId, params);
|
|
194
|
+
|
|
195
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
196
|
+
|
|
197
|
+
assert.equal(
|
|
198
|
+
filesApiFetchStub.getCall(0).args[0],
|
|
199
|
+
`https://test.com/files-api/v2/projects/${projectId}/file`
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
assert.equal(
|
|
203
|
+
filesApiFetchStub.getCall(0).args[1].method,
|
|
204
|
+
"post"
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
assert.equal(
|
|
208
|
+
filesApiFetchStub.getCall(0).args[1].headers.Authorization,
|
|
209
|
+
"test_token_type test_access_token"
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
assert.equal(
|
|
213
|
+
filesApiFetchStub.getCall(0).args[1].headers["User-Agent"],
|
|
214
|
+
"test_user_agent"
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
assert.equal(
|
|
218
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
219
|
+
await streamToString(filesApiFetchStub.getCall(0).args[1].body._streams[1]),
|
|
220
|
+
fs.readFileSync(
|
|
221
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
222
|
+
"utf8"
|
|
223
|
+
)
|
|
224
|
+
);
|
|
168
225
|
});
|
|
169
226
|
});
|
|
170
227
|
});
|
package/test/job-batches.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
1
2
|
import sinon from "sinon";
|
|
2
3
|
import assert from "assert";
|
|
3
4
|
import { loggerMock, authMock, responseMock } from "./mock";
|
|
@@ -8,6 +9,7 @@ import { UploadBatchFileParameters } from "../api/job-batches/params/upload-batc
|
|
|
8
9
|
import { FileType } from "../api/files/params/file-type";
|
|
9
10
|
import { CancelBatchFileParameters } from "../api/job-batches/params/cancel-batch-file-parameters";
|
|
10
11
|
import { RegisterBatchFileParameters } from "../api/job-batches/params/register-batch-file-parameters";
|
|
12
|
+
import { streamToString } from "./stream-to-string";
|
|
11
13
|
|
|
12
14
|
describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
13
15
|
const projectId = "testProjectId";
|
|
@@ -115,11 +117,11 @@ describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
|
115
117
|
);
|
|
116
118
|
});
|
|
117
119
|
|
|
118
|
-
it("Upload batch file", async () => {
|
|
120
|
+
it("Upload batch file: from disk", async () => {
|
|
119
121
|
const params = new UploadBatchFileParameters();
|
|
120
122
|
|
|
121
123
|
params
|
|
122
|
-
.
|
|
124
|
+
.setFileFromLocalFilePath("./test/data/file.xml")
|
|
123
125
|
.setFileUri("test-file-uri")
|
|
124
126
|
.setFileType(FileType.XML)
|
|
125
127
|
.setDirective("foo", "bar")
|
|
@@ -150,6 +152,64 @@ describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
|
150
152
|
jobBatchesApiFetchStub.getCall(0).args[1].headers["User-Agent"],
|
|
151
153
|
"test_user_agent"
|
|
152
154
|
);
|
|
155
|
+
|
|
156
|
+
assert.equal(
|
|
157
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
158
|
+
await streamToString(jobBatchesApiFetchStub.getCall(0).args[1].body._streams[1]),
|
|
159
|
+
fs.readFileSync(
|
|
160
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
161
|
+
"utf8"
|
|
162
|
+
)
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("Upload batch file: as string", async () => {
|
|
167
|
+
const params = new UploadBatchFileParameters();
|
|
168
|
+
|
|
169
|
+
params
|
|
170
|
+
.setFileContent(fs.readFileSync(
|
|
171
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
172
|
+
"utf8"
|
|
173
|
+
))
|
|
174
|
+
.setFileUri("test-file-uri")
|
|
175
|
+
.setFileType(FileType.XML)
|
|
176
|
+
.setDirective("foo", "bar")
|
|
177
|
+
.setLocalesToApprove(["fr-FR", "de-DE"])
|
|
178
|
+
.setCallbackUrl("testCallbackUrl")
|
|
179
|
+
.setClientLibId("clientLibId", "clientLibVersion");
|
|
180
|
+
|
|
181
|
+
await jobBatchesApi.uploadBatchFile(projectId, batchUid, params);
|
|
182
|
+
|
|
183
|
+
sinon.assert.calledOnce(jobBatchesApiFetchStub);
|
|
184
|
+
|
|
185
|
+
assert.equal(
|
|
186
|
+
jobBatchesApiFetchStub.getCall(0).args[0],
|
|
187
|
+
`https://test.com/job-batches-api/v2/projects/${projectId}/batches/${batchUid}/file`
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
assert.equal(
|
|
191
|
+
jobBatchesApiFetchStub.getCall(0).args[1].method,
|
|
192
|
+
"post"
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
assert.equal(
|
|
196
|
+
jobBatchesApiFetchStub.getCall(0).args[1].headers.Authorization,
|
|
197
|
+
"test_token_type test_access_token"
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
assert.equal(
|
|
201
|
+
jobBatchesApiFetchStub.getCall(0).args[1].headers["User-Agent"],
|
|
202
|
+
"test_user_agent"
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
assert.equal(
|
|
206
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
207
|
+
await streamToString(jobBatchesApiFetchStub.getCall(0).args[1].body._streams[1]),
|
|
208
|
+
fs.readFileSync(
|
|
209
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
210
|
+
"utf8"
|
|
211
|
+
)
|
|
212
|
+
);
|
|
153
213
|
});
|
|
154
214
|
|
|
155
215
|
it("Get batch status", async () => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Readable } from "stream";
|
|
2
|
+
|
|
3
|
+
function streamToString(stream: Readable): Promise<string> {
|
|
4
|
+
const chunks = [];
|
|
5
|
+
|
|
6
|
+
stream.resume();
|
|
7
|
+
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
// eslint-disable-next-line fp/no-mutating-methods
|
|
10
|
+
stream.on("data", chunk => chunks.push(Buffer.from(chunk)));
|
|
11
|
+
stream.on("error", err => reject(err));
|
|
12
|
+
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { streamToString };
|