smartling-api-sdk-nodejs 2.0.0 → 2.2.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/jobs/dto/added-file-dto.ts +6 -0
- package/api/jobs/index.ts +21 -0
- package/api/jobs/params/add-file-parameters.ts +9 -0
- package/built/api/jobs/dto/added-file-dto.d.ts +5 -0
- package/built/api/jobs/dto/added-file-dto.js +3 -0
- package/built/api/jobs/dto/added-file-dto.js.map +1 -0
- package/built/api/jobs/index.d.ts +4 -0
- package/built/api/jobs/index.js +10 -0
- package/built/api/jobs/index.js.map +1 -1
- package/built/api/jobs/params/add-file-parameters.d.ts +4 -0
- package/built/api/jobs/params/add-file-parameters.js +12 -0
- package/built/api/jobs/params/add-file-parameters.js.map +1 -0
- package/built/package.json +1 -1
- package/package.json +1 -1
- package/test/jobs.spec.ts +42 -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=AYuUxbyYRe7rJHsZ61mH
|
|
6
|
+
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AYuUxbyYRe7rJHsZ61mH
|
package/api/jobs/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { JobDetailsDto } from "./dto/job-details-dto";
|
|
|
11
11
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
12
12
|
import { BaseJobDto } from "./dto/base-job-dto";
|
|
13
13
|
import { FileProgressDto } from "./dto/file-progress-dto";
|
|
14
|
+
import { AddFileParameters } from "./params/add-file-parameters";
|
|
14
15
|
import { RemovedFileDto } from "./dto/removed-file-dto";
|
|
15
16
|
import { JobProgressDto } from "./dto/job-progress-dto";
|
|
16
17
|
import { JobProgressParameters } from "./params/job-progress-parameters";
|
|
@@ -18,6 +19,7 @@ import { CancelJobParameters } from "./params/cancel-job-parameters";
|
|
|
18
19
|
import { CloseJobParameters } from "./params/close-job-parameters";
|
|
19
20
|
import { SearchJobsParameters } from "./params/search-jobs-parameters";
|
|
20
21
|
import { FullSourceFileDto } from "./dto/full-source-file-dto";
|
|
22
|
+
import { AddedFileDto } from "./dto/added-file-dto";
|
|
21
23
|
|
|
22
24
|
export class SmartlingJobsApi extends SmartlingBaseApi {
|
|
23
25
|
constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger) {
|
|
@@ -72,6 +74,16 @@ export class SmartlingJobsApi extends SmartlingBaseApi {
|
|
|
72
74
|
);
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
async addFileToJob(
|
|
78
|
+
projectId: string, translationJobUid: string, params: AddFileParameters
|
|
79
|
+
): Promise<AddedFileDto> {
|
|
80
|
+
return await this.makeRequest(
|
|
81
|
+
"post",
|
|
82
|
+
`${this.entrypoint}/${projectId}/jobs/${translationJobUid}/file/add`,
|
|
83
|
+
JSON.stringify(params.export())
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
75
87
|
async removeFileFromJob(
|
|
76
88
|
projectId: string, translationJobUid: string, params: RemoveFileParameters
|
|
77
89
|
): Promise<RemovedFileDto> {
|
|
@@ -121,4 +133,13 @@ export class SmartlingJobsApi extends SmartlingBaseApi {
|
|
|
121
133
|
JSON.stringify(params.export())
|
|
122
134
|
);
|
|
123
135
|
}
|
|
136
|
+
|
|
137
|
+
async deleteJob(
|
|
138
|
+
projectId: string, translationJobUid: string
|
|
139
|
+
): Promise<void> {
|
|
140
|
+
await this.makeRequest(
|
|
141
|
+
"delete",
|
|
142
|
+
`${this.entrypoint}/${projectId}/jobs/${translationJobUid}`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
124
145
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"added-file-dto.js","sourceRoot":"","sources":["../../../../api/jobs/dto/added-file-dto.ts"],"names":[],"mappings":""}
|
|
@@ -11,6 +11,7 @@ import { JobDetailsDto } from "./dto/job-details-dto";
|
|
|
11
11
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
12
12
|
import { BaseJobDto } from "./dto/base-job-dto";
|
|
13
13
|
import { FileProgressDto } from "./dto/file-progress-dto";
|
|
14
|
+
import { AddFileParameters } from "./params/add-file-parameters";
|
|
14
15
|
import { RemovedFileDto } from "./dto/removed-file-dto";
|
|
15
16
|
import { JobProgressDto } from "./dto/job-progress-dto";
|
|
16
17
|
import { JobProgressParameters } from "./params/job-progress-parameters";
|
|
@@ -18,6 +19,7 @@ import { CancelJobParameters } from "./params/cancel-job-parameters";
|
|
|
18
19
|
import { CloseJobParameters } from "./params/close-job-parameters";
|
|
19
20
|
import { SearchJobsParameters } from "./params/search-jobs-parameters";
|
|
20
21
|
import { FullSourceFileDto } from "./dto/full-source-file-dto";
|
|
22
|
+
import { AddedFileDto } from "./dto/added-file-dto";
|
|
21
23
|
export declare class SmartlingJobsApi extends SmartlingBaseApi {
|
|
22
24
|
constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger);
|
|
23
25
|
createJob(projectId: string, params: CreateJobParameters): Promise<JobDto>;
|
|
@@ -25,9 +27,11 @@ export declare class SmartlingJobsApi extends SmartlingBaseApi {
|
|
|
25
27
|
getJobFiles(projectId: string, translationJobUid: string, params: ListJobFilesParameters): Promise<SmartlingListResponse<FullSourceFileDto>>;
|
|
26
28
|
listJobs(projectId: string, params: ListJobsParameters): Promise<SmartlingListResponse<BaseJobDto>>;
|
|
27
29
|
searchJobs(projectId: string, params: SearchJobsParameters): Promise<SmartlingListResponse<BaseJobDto>>;
|
|
30
|
+
addFileToJob(projectId: string, translationJobUid: string, params: AddFileParameters): Promise<AddedFileDto>;
|
|
28
31
|
removeFileFromJob(projectId: string, translationJobUid: string, params: RemoveFileParameters): Promise<RemovedFileDto>;
|
|
29
32
|
getJobProgress(projectId: string, translationJobUid: string, params: JobProgressParameters): Promise<JobProgressDto>;
|
|
30
33
|
getJobFileProgress(projectId: string, translationJobUid: string, params: FileProgressParameters): Promise<FileProgressDto>;
|
|
31
34
|
cancelJob(projectId: string, translationJobUid: string, params: CancelJobParameters): Promise<void>;
|
|
32
35
|
closeJob(projectId: string, translationJobUid: string, params: CloseJobParameters): Promise<void>;
|
|
36
|
+
deleteJob(projectId: string, translationJobUid: string): Promise<void>;
|
|
33
37
|
}
|
package/built/api/jobs/index.js
CHANGED
|
@@ -42,6 +42,11 @@ class SmartlingJobsApi extends index_1.SmartlingBaseApi {
|
|
|
42
42
|
return yield this.makeRequest("post", `${this.entrypoint}/${projectId}/jobs/search`, JSON.stringify(params.export()));
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
+
addFileToJob(projectId, translationJobUid, params) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return yield this.makeRequest("post", `${this.entrypoint}/${projectId}/jobs/${translationJobUid}/file/add`, JSON.stringify(params.export()));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
45
50
|
removeFileFromJob(projectId, translationJobUid, params) {
|
|
46
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
52
|
return yield this.makeRequest("post", `${this.entrypoint}/${projectId}/jobs/${translationJobUid}/file/remove`, JSON.stringify(params.export()));
|
|
@@ -67,6 +72,11 @@ class SmartlingJobsApi extends index_1.SmartlingBaseApi {
|
|
|
67
72
|
yield this.makeRequest("post", `${this.entrypoint}/${projectId}/jobs/${translationJobUid}/close`, JSON.stringify(params.export()));
|
|
68
73
|
});
|
|
69
74
|
}
|
|
75
|
+
deleteJob(projectId, translationJobUid) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
yield this.makeRequest("delete", `${this.entrypoint}/${projectId}/jobs/${translationJobUid}`);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
70
80
|
}
|
|
71
81
|
exports.SmartlingJobsApi = SmartlingJobsApi;
|
|
72
82
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/jobs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/jobs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiD;AAuBjD,MAAa,gBAAiB,SAAQ,wBAAgB;IAClD,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,uBAAuB,CAAC;IACpE,CAAC;IAEK,SAAS,CAAC,SAAiB,EAAE,MAA2B;;YAC1D,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,MAAM,EACN,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,OAAO,EACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAClC,CAAC;QACN,CAAC;KAAA;IAEK,MAAM,CAAC,SAAiB,EAAE,iBAAyB;;YACrD,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,SAAS,iBAAiB,EAAE,CAC9D,CAAC;QACN,CAAC;KAAA;IAEK,WAAW,CACb,SAAiB,EAAE,iBAAyB,EAAE,MAA8B;;YAE5E,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,SAAS,iBAAiB,QAAQ,EACjE,MAAM,CAAC,MAAM,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AAE,MAA8B;;YAE5E,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,SAAS,iBAAiB,gBAAgB,EACzE,MAAM,CAAC,MAAM,EAAE,CAClB,CAAC;QACN,CAAC;KAAA;IAEK,SAAS,CACX,SAAiB,EAAE,iBAAyB,EAAE,MAA2B;;YAEzE,MAAM,IAAI,CAAC,WAAW,CAClB,MAAM,EACN,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,SAAS,iBAAiB,SAAS,EAClE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAClC,CAAC;QACN,CAAC;KAAA;IAEK,QAAQ,CACV,SAAiB,EAAE,iBAAyB,EAAE,MAA0B;;YAExE,MAAM,IAAI,CAAC,WAAW,CAClB,MAAM,EACN,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,SAAS,iBAAiB,QAAQ,EACjE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAClC,CAAC;QACN,CAAC;KAAA;IAEK,SAAS,CACX,SAAiB,EAAE,iBAAyB;;YAE5C,MAAM,IAAI,CAAC,WAAW,CAClB,QAAQ,EACR,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,SAAS,iBAAiB,EAAE,CAC9D,CAAC;QACN,CAAC;KAAA;CACJ;AAzHD,4CAyHC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddFileParameters = void 0;
|
|
4
|
+
const index_1 = require("../../parameters/index");
|
|
5
|
+
class AddFileParameters extends index_1.BaseParameters {
|
|
6
|
+
setFileUri(fileUri) {
|
|
7
|
+
this.set("fileUri", fileUri);
|
|
8
|
+
return this;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.AddFileParameters = AddFileParameters;
|
|
12
|
+
//# sourceMappingURL=add-file-parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-file-parameters.js","sourceRoot":"","sources":["../../../../api/jobs/params/add-file-parameters.ts"],"names":[],"mappings":";;;AAAA,kDAAwD;AAExD,MAAa,iBAAkB,SAAQ,sBAAc;IACjD,UAAU,CAAC,OAAe;QACtB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE7B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAND,8CAMC"}
|
package/built/package.json
CHANGED
package/package.json
CHANGED
package/test/jobs.spec.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { RemoveFileParameters } from "../api/jobs/params/remove-file-parameters"
|
|
|
12
12
|
import { JobProgressParameters } from "../api/jobs/params/job-progress-parameters";
|
|
13
13
|
import { CancelJobParameters } from "../api/jobs/params/cancel-job-parameters";
|
|
14
14
|
import { CloseJobParameters } from "../api/jobs/params/close-job-parameters";
|
|
15
|
+
import { AddFileParameters } from "../api/jobs/params/add-file-parameters";
|
|
15
16
|
|
|
16
17
|
describe("SmartlingJobsAPI class tests.", () => {
|
|
17
18
|
const projectId = "testProjectId";
|
|
@@ -181,6 +182,29 @@ describe("SmartlingJobsAPI class tests.", () => {
|
|
|
181
182
|
);
|
|
182
183
|
});
|
|
183
184
|
|
|
185
|
+
it("Adds file to job", async () => {
|
|
186
|
+
const params = new AddFileParameters();
|
|
187
|
+
|
|
188
|
+
params.setFileUri(fileUri);
|
|
189
|
+
|
|
190
|
+
await jobApi.addFileToJob(projectId, jobUid, params);
|
|
191
|
+
|
|
192
|
+
sinon.assert.calledOnce(jobServiceApiFetchStub);
|
|
193
|
+
sinon.assert.calledWithExactly(
|
|
194
|
+
jobServiceApiFetchStub,
|
|
195
|
+
`https://test.com/jobs-api/v3/projects/${projectId}/jobs/${jobUid}/file/add`,
|
|
196
|
+
{
|
|
197
|
+
body: "{\"fileUri\":\"testFileUri.json\"}",
|
|
198
|
+
headers: {
|
|
199
|
+
Authorization: "test_token_type test_access_token",
|
|
200
|
+
"Content-Type": "application/json",
|
|
201
|
+
"User-Agent": "test_user_agent"
|
|
202
|
+
},
|
|
203
|
+
method: "post"
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
|
|
184
208
|
it("Remove file from job", async () => {
|
|
185
209
|
const params = new RemoveFileParameters();
|
|
186
210
|
|
|
@@ -247,5 +271,23 @@ describe("SmartlingJobsAPI class tests.", () => {
|
|
|
247
271
|
}
|
|
248
272
|
);
|
|
249
273
|
});
|
|
274
|
+
|
|
275
|
+
it("Delete job", async () => {
|
|
276
|
+
await jobApi.deleteJob(projectId, jobUid);
|
|
277
|
+
|
|
278
|
+
sinon.assert.calledOnce(jobServiceApiFetchStub);
|
|
279
|
+
sinon.assert.calledWithExactly(
|
|
280
|
+
jobServiceApiFetchStub,
|
|
281
|
+
`https://test.com/jobs-api/v3/projects/${projectId}/jobs/${jobUid}`,
|
|
282
|
+
{
|
|
283
|
+
headers: {
|
|
284
|
+
Authorization: "test_token_type test_access_token",
|
|
285
|
+
"Content-Type": "application/json",
|
|
286
|
+
"User-Agent": "test_user_agent"
|
|
287
|
+
},
|
|
288
|
+
method: "delete"
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
});
|
|
250
292
|
});
|
|
251
293
|
});
|