smartling-api-sdk-nodejs 2.2.0 → 2.3.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/files/dto/file-status-for-project-dto.ts +11 -0
- package/api/files/index.ts +24 -0
- package/api/files/params/download-file-all-translations-parameters.ts +9 -0
- package/api/jobs/index.ts +10 -0
- package/api/jobs/params/authorize-job-parameters.ts +21 -0
- package/api/jobs/params/create-job-parameters.ts +6 -0
- package/built/api/files/dto/file-status-for-project-dto.d.ts +9 -0
- package/built/api/files/dto/file-status-for-project-dto.js +3 -0
- package/built/api/files/dto/file-status-for-project-dto.js.map +1 -0
- package/built/api/files/index.d.ts +4 -0
- package/built/api/files/index.js +10 -0
- package/built/api/files/index.js.map +1 -1
- package/built/api/files/params/download-file-all-translations-parameters.d.ts +4 -0
- package/built/api/files/params/download-file-all-translations-parameters.js +12 -0
- package/built/api/files/params/download-file-all-translations-parameters.js.map +1 -0
- package/built/api/jobs/index.d.ts +2 -0
- package/built/api/jobs/index.js +5 -0
- package/built/api/jobs/index.js.map +1 -1
- package/built/api/jobs/params/authorize-job-parameters.d.ts +5 -0
- package/built/api/jobs/params/authorize-job-parameters.js +17 -0
- package/built/api/jobs/params/authorize-job-parameters.js.map +1 -0
- package/built/api/jobs/params/create-job-parameters.d.ts +1 -0
- package/built/api/jobs/params/create-job-parameters.js +4 -0
- package/built/api/jobs/params/create-job-parameters.js.map +1 -1
- package/built/index.d.ts +3 -0
- package/built/index.js +3 -0
- package/built/index.js.map +1 -1
- package/built/package.json +1 -1
- package/index.ts +3 -0
- package/package.json +1 -1
- package/test/files.spec.ts +72 -0
- package/test/jobs.spec.ts +41 -2
|
@@ -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=AYu51urzRe7rJHsZ61mc
|
|
6
|
+
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AYu51urzRe7rJHsZ61mc
|
package/api/files/index.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { FileStatusForAllLocalesDto } from "./dto/file-status-for-all-locales-dt
|
|
|
8
8
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
9
9
|
import { LastModifiedForLocale } from "./dto/last-modified-for-locale-dto";
|
|
10
10
|
import { UploadedFileDto } from "./dto/uploaded-file-dto";
|
|
11
|
+
import { FileStatusForProjectDto } from "./dto/file-status-for-project-dto";
|
|
12
|
+
import { DownloadFileAllTranslationsParameters } from "./params/download-file-all-translations-parameters";
|
|
11
13
|
|
|
12
14
|
export class SmartlingFilesApi extends SmartlingBaseApi {
|
|
13
15
|
constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger) {
|
|
@@ -47,6 +49,19 @@ export class SmartlingFilesApi extends SmartlingBaseApi {
|
|
|
47
49
|
);
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
async downloadFileAllTranslations(
|
|
53
|
+
projectId: string,
|
|
54
|
+
fileUri: string,
|
|
55
|
+
params: DownloadFileAllTranslationsParameters
|
|
56
|
+
): Promise<string> {
|
|
57
|
+
return await this.makeRequest(
|
|
58
|
+
"get",
|
|
59
|
+
`${this.entrypoint}/${projectId}/locales/all/file`,
|
|
60
|
+
Object.assign(params.export(), { fileUri }),
|
|
61
|
+
true
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
async deleteFile(projectId: string, fileUri: string): Promise<boolean> {
|
|
51
66
|
const form = new FormData();
|
|
52
67
|
|
|
@@ -79,6 +94,15 @@ export class SmartlingFilesApi extends SmartlingBaseApi {
|
|
|
79
94
|
);
|
|
80
95
|
}
|
|
81
96
|
|
|
97
|
+
async getRecentlyUploadedFiles(
|
|
98
|
+
projectId: string
|
|
99
|
+
): Promise<SmartlingListResponse<FileStatusForProjectDto>> {
|
|
100
|
+
return await this.makeRequest(
|
|
101
|
+
"get",
|
|
102
|
+
`${this.entrypoint}/${projectId}/files/list`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
82
106
|
static fixContentTypeHeaderCase(form: FormData): Record<string, unknown> {
|
|
83
107
|
const headers = form.getHeaders();
|
|
84
108
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DownloadFileParameters } from "./download-file-parameters";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class DownloadFileAllTranslationsParameters extends DownloadFileParameters {
|
|
5
|
+
setZipFileName(fileName: string): DownloadFileAllTranslationsParameters {
|
|
6
|
+
this.set("zipFileName", fileName);
|
|
7
|
+
return this;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/api/jobs/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { CloseJobParameters } from "./params/close-job-parameters";
|
|
|
20
20
|
import { SearchJobsParameters } from "./params/search-jobs-parameters";
|
|
21
21
|
import { FullSourceFileDto } from "./dto/full-source-file-dto";
|
|
22
22
|
import { AddedFileDto } from "./dto/added-file-dto";
|
|
23
|
+
import { AuthorizeJobParameters } from "./params/authorize-job-parameters";
|
|
23
24
|
|
|
24
25
|
export class SmartlingJobsApi extends SmartlingBaseApi {
|
|
25
26
|
constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger) {
|
|
@@ -43,6 +44,15 @@ export class SmartlingJobsApi extends SmartlingBaseApi {
|
|
|
43
44
|
);
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
async authorizeJob(projectId: string, translationJobUid: string, params: AuthorizeJobParameters
|
|
48
|
+
): Promise<Record<string, unknown>> {
|
|
49
|
+
return await this.makeRequest(
|
|
50
|
+
"post",
|
|
51
|
+
`${this.entrypoint}/${projectId}/jobs/${translationJobUid}/authorize`,
|
|
52
|
+
JSON.stringify(params.export())
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
async getJobFiles(
|
|
47
57
|
projectId: string, translationJobUid: string, params: ListJobFilesParameters
|
|
48
58
|
): Promise<SmartlingListResponse<FullSourceFileDto>> {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseParameters } from "../../parameters/index";
|
|
2
|
+
|
|
3
|
+
export class AuthorizeJobParameters extends BaseParameters {
|
|
4
|
+
constructor(parameters: Record<string, unknown> = {}) {
|
|
5
|
+
super(parameters);
|
|
6
|
+
|
|
7
|
+
// if no localeWorkflows are set, the request's body should be empty
|
|
8
|
+
// https://api-reference.smartling.com/#tag/Jobs/operation/authorizeJob
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
addLocaleWorkflows(targetLocaleId: string, workflowUid: string): AuthorizeJobParameters {
|
|
12
|
+
const { localeWorkflows } = this.parameters;
|
|
13
|
+
const newLocaleWorkflow = { targetLocaleId, workflowUid };
|
|
14
|
+
|
|
15
|
+
this.set("localeWorkflows",
|
|
16
|
+
localeWorkflows?.concat(newLocaleWorkflow) || [newLocaleWorkflow]
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-status-for-project-dto.js","sourceRoot":"","sources":["../../../../api/files/dto/file-status-for-project-dto.ts"],"names":[],"mappings":""}
|
|
@@ -8,12 +8,16 @@ import { FileStatusForAllLocalesDto } from "./dto/file-status-for-all-locales-dt
|
|
|
8
8
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
9
9
|
import { LastModifiedForLocale } from "./dto/last-modified-for-locale-dto";
|
|
10
10
|
import { UploadedFileDto } from "./dto/uploaded-file-dto";
|
|
11
|
+
import { FileStatusForProjectDto } from "./dto/file-status-for-project-dto";
|
|
12
|
+
import { DownloadFileAllTranslationsParameters } from "./params/download-file-all-translations-parameters";
|
|
11
13
|
export declare class SmartlingFilesApi extends SmartlingBaseApi {
|
|
12
14
|
constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger);
|
|
13
15
|
getStatusForAllLocales(projectId: string, fileUri: string): Promise<FileStatusForAllLocalesDto>;
|
|
14
16
|
getLastModified(projectId: string, fileUri: string): Promise<SmartlingListResponse<LastModifiedForLocale>>;
|
|
15
17
|
downloadFile(projectId: string, fileUri: string, locale: string, params: DownloadFileParameters): Promise<string>;
|
|
18
|
+
downloadFileAllTranslations(projectId: string, fileUri: string, params: DownloadFileAllTranslationsParameters): Promise<string>;
|
|
16
19
|
deleteFile(projectId: string, fileUri: string): Promise<boolean>;
|
|
17
20
|
uploadFile(projectId: string, parameters: UploadFileParameters): Promise<UploadedFileDto>;
|
|
21
|
+
getRecentlyUploadedFiles(projectId: string): Promise<SmartlingListResponse<FileStatusForProjectDto>>;
|
|
18
22
|
static fixContentTypeHeaderCase(form: FormData): Record<string, unknown>;
|
|
19
23
|
}
|
package/built/api/files/index.js
CHANGED
|
@@ -36,6 +36,11 @@ class SmartlingFilesApi extends index_1.SmartlingBaseApi {
|
|
|
36
36
|
return yield this.makeRequest("get", `${this.entrypoint}/${projectId}/locales/${locale}/file`, Object.assign(params.export(), { fileUri }), true);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
downloadFileAllTranslations(projectId, fileUri, params) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return yield this.makeRequest("get", `${this.entrypoint}/${projectId}/locales/all/file`, Object.assign(params.export(), { fileUri }), true);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
39
44
|
deleteFile(projectId, fileUri) {
|
|
40
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
46
|
const form = new form_data_1.default();
|
|
@@ -53,6 +58,11 @@ class SmartlingFilesApi extends index_1.SmartlingBaseApi {
|
|
|
53
58
|
return yield this.makeRequest("post", `${this.entrypoint}/${projectId}/file`, formData, false, SmartlingFilesApi.fixContentTypeHeaderCase(formData));
|
|
54
59
|
});
|
|
55
60
|
}
|
|
61
|
+
getRecentlyUploadedFiles(projectId) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return yield this.makeRequest("get", `${this.entrypoint}/${projectId}/files/list`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
56
66
|
static fixContentTypeHeaderCase(form) {
|
|
57
67
|
const headers = form.getHeaders();
|
|
58
68
|
headers["Content-Type"] = headers["content-type"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/files/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAiC;AACjC,yCAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/files/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAiC;AACjC,yCAAiD;AAYjD,MAAa,iBAAkB,SAAQ,wBAAgB;IACnD,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,wBAAwB,CAAC;IACrE,CAAC;IAEK,sBAAsB,CACxB,SAAiB,EAAE,OAAe;;YAElC,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,cAAc,EAC7C,EAAE,OAAO,EAAE,CACd,CAAC;QACN,CAAC;KAAA;IAEK,eAAe,CACjB,SAAiB,EAAE,OAAe;;YAElC,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,qBAAqB,EACpD,EAA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G,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;IAEK,wBAAwB,CAC1B,SAAiB;;YAEjB,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,aAAa,CAC/C,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;AApGD,8CAoGC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DownloadFileAllTranslationsParameters = void 0;
|
|
4
|
+
const download_file_parameters_1 = require("./download-file-parameters");
|
|
5
|
+
class DownloadFileAllTranslationsParameters extends download_file_parameters_1.DownloadFileParameters {
|
|
6
|
+
setZipFileName(fileName) {
|
|
7
|
+
this.set("zipFileName", fileName);
|
|
8
|
+
return this;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.DownloadFileAllTranslationsParameters = DownloadFileAllTranslationsParameters;
|
|
12
|
+
//# sourceMappingURL=download-file-all-translations-parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-file-all-translations-parameters.js","sourceRoot":"","sources":["../../../../api/files/params/download-file-all-translations-parameters.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AAGpE,MAAa,qCAAsC,SAAQ,iDAAsB;IAC7E,cAAc,CAAC,QAAgB;QAC3B,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AALD,sFAKC"}
|
|
@@ -20,10 +20,12 @@ import { CloseJobParameters } from "./params/close-job-parameters";
|
|
|
20
20
|
import { SearchJobsParameters } from "./params/search-jobs-parameters";
|
|
21
21
|
import { FullSourceFileDto } from "./dto/full-source-file-dto";
|
|
22
22
|
import { AddedFileDto } from "./dto/added-file-dto";
|
|
23
|
+
import { AuthorizeJobParameters } from "./params/authorize-job-parameters";
|
|
23
24
|
export declare class SmartlingJobsApi extends SmartlingBaseApi {
|
|
24
25
|
constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger);
|
|
25
26
|
createJob(projectId: string, params: CreateJobParameters): Promise<JobDto>;
|
|
26
27
|
getJob(projectId: string, translationJobUid: string): Promise<JobDetailsDto>;
|
|
28
|
+
authorizeJob(projectId: string, translationJobUid: string, params: AuthorizeJobParameters): Promise<Record<string, unknown>>;
|
|
27
29
|
getJobFiles(projectId: string, translationJobUid: string, params: ListJobFilesParameters): Promise<SmartlingListResponse<FullSourceFileDto>>;
|
|
28
30
|
listJobs(projectId: string, params: ListJobsParameters): Promise<SmartlingListResponse<BaseJobDto>>;
|
|
29
31
|
searchJobs(projectId: string, params: SearchJobsParameters): Promise<SmartlingListResponse<BaseJobDto>>;
|
package/built/api/jobs/index.js
CHANGED
|
@@ -27,6 +27,11 @@ class SmartlingJobsApi extends index_1.SmartlingBaseApi {
|
|
|
27
27
|
return yield this.makeRequest("get", `${this.entrypoint}/${projectId}/jobs/${translationJobUid}`);
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
authorizeJob(projectId, translationJobUid, params) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return yield this.makeRequest("post", `${this.entrypoint}/${projectId}/jobs/${translationJobUid}/authorize`, JSON.stringify(params.export()));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
30
35
|
getJobFiles(projectId, translationJobUid, params) {
|
|
31
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
37
|
return yield this.makeRequest("get", `${this.entrypoint}/${projectId}/jobs/${translationJobUid}/files`, params.export());
|
|
@@ -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;AAwBjD,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,YAAY,CAAC,SAAiB,EAAE,iBAAyB,EAAE,MAA8B;;YAE3F,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,MAAM,EACN,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 @@
|
|
|
1
|
+
import { BaseParameters } from "../../parameters/index";
|
|
2
|
+
export declare class AuthorizeJobParameters extends BaseParameters {
|
|
3
|
+
constructor(parameters?: Record<string, unknown>);
|
|
4
|
+
addLocaleWorkflows(targetLocaleId: string, workflowUid: string): AuthorizeJobParameters;
|
|
5
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthorizeJobParameters = void 0;
|
|
4
|
+
const index_1 = require("../../parameters/index");
|
|
5
|
+
class AuthorizeJobParameters extends index_1.BaseParameters {
|
|
6
|
+
constructor(parameters = {}) {
|
|
7
|
+
super(parameters);
|
|
8
|
+
}
|
|
9
|
+
addLocaleWorkflows(targetLocaleId, workflowUid) {
|
|
10
|
+
const { localeWorkflows } = this.parameters;
|
|
11
|
+
const newLocaleWorkflow = { targetLocaleId, workflowUid };
|
|
12
|
+
this.set("localeWorkflows", (localeWorkflows === null || localeWorkflows === void 0 ? void 0 : localeWorkflows.concat(newLocaleWorkflow)) || [newLocaleWorkflow]);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.AuthorizeJobParameters = AuthorizeJobParameters;
|
|
17
|
+
//# sourceMappingURL=authorize-job-parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize-job-parameters.js","sourceRoot":"","sources":["../../../../api/jobs/params/authorize-job-parameters.ts"],"names":[],"mappings":";;;AAAA,kDAAwD;AAExD,MAAa,sBAAuB,SAAQ,sBAAc;IACtD,YAAY,aAAsC,EAAE;QAChD,KAAK,CAAC,UAAU,CAAC,CAAC;IAItB,CAAC;IAED,kBAAkB,CAAC,cAAsB,EAAE,WAAmB;QAC1D,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;QAC5C,MAAM,iBAAiB,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;QAE1D,IAAI,CAAC,GAAG,CAAC,iBAAiB,EACtB,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,CAAC,iBAAiB,CAAC,KAAI,CAAC,iBAAiB,CAAC,CACpE,CAAC;QAEF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAlBD,wDAkBC"}
|
|
@@ -3,4 +3,5 @@ export declare class CreateJobParameters extends BaseParameters {
|
|
|
3
3
|
setName(jobName: string): CreateJobParameters;
|
|
4
4
|
setDescription(description: string): CreateJobParameters;
|
|
5
5
|
setDueDate(dueDate: Date): CreateJobParameters;
|
|
6
|
+
setTargetLocaleIds(targetLocaleIds: string[]): CreateJobParameters;
|
|
6
7
|
}
|
|
@@ -25,6 +25,10 @@ class CreateJobParameters extends index_1.BaseParameters {
|
|
|
25
25
|
this.set("dueDate", dueDate.toISOString());
|
|
26
26
|
return this;
|
|
27
27
|
}
|
|
28
|
+
setTargetLocaleIds(targetLocaleIds) {
|
|
29
|
+
this.set("targetLocaleIds", targetLocaleIds);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
exports.CreateJobParameters = CreateJobParameters;
|
|
30
34
|
//# sourceMappingURL=create-job-parameters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-job-parameters.js","sourceRoot":"","sources":["../../../../api/jobs/params/create-job-parameters.ts"],"names":[],"mappings":";;;AAAA,kDAAwD;AACxD,iDAA2D;AAE3D,MAAa,mBAAoB,SAAQ,sBAAc;IACnD,OAAO,CAAC,OAAe;QACnB,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG,EAAE;YACvB,MAAM,IAAI,0BAAkB,CAAC,8CAA8C,CAAC,CAAC;SAChF;QAED,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,WAAW,CAAC,MAAM,IAAI,IAAI,EAAE;YAC5B,MAAM,IAAI,0BAAkB,CAAC,sDAAsD,CAAC,CAAC;SACxF;QAED,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,OAAa;QACpB,IAAI,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5C,MAAM,IAAI,0BAAkB,CAAC,qCAAqC,CAAC,CAAC;SACvE;QAED,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAE3C,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;
|
|
1
|
+
{"version":3,"file":"create-job-parameters.js","sourceRoot":"","sources":["../../../../api/jobs/params/create-job-parameters.ts"],"names":[],"mappings":";;;AAAA,kDAAwD;AACxD,iDAA2D;AAE3D,MAAa,mBAAoB,SAAQ,sBAAc;IACnD,OAAO,CAAC,OAAe;QACnB,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG,EAAE;YACvB,MAAM,IAAI,0BAAkB,CAAC,8CAA8C,CAAC,CAAC;SAChF;QAED,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,WAAW,CAAC,MAAM,IAAI,IAAI,EAAE;YAC5B,MAAM,IAAI,0BAAkB,CAAC,sDAAsD,CAAC,CAAC;SACxF;QAED,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,OAAa;QACpB,IAAI,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5C,MAAM,IAAI,0BAAkB,CAAC,qCAAqC,CAAC,CAAC;SACvE;QAED,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAE3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kBAAkB,CAAC,eAAyB;QACxC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;QAE7C,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AApCD,kDAoCC"}
|
package/built/index.d.ts
CHANGED
|
@@ -73,3 +73,6 @@ export * from "./api/strings/dto/source-string-dto";
|
|
|
73
73
|
export * from "./api/strings/dto/source-string-key-dto";
|
|
74
74
|
export * from "./api/strings/params/fetch-source-strings-parameters";
|
|
75
75
|
export * from "./api/logger";
|
|
76
|
+
export * from "./api/jobs/params/add-file-parameters";
|
|
77
|
+
export * from "./api/files/params/download-file-all-translations-parameters";
|
|
78
|
+
export * from "./api/jobs/params/authorize-job-parameters";
|
package/built/index.js
CHANGED
|
@@ -89,4 +89,7 @@ __exportStar(require("./api/strings/dto/source-string-dto"), exports);
|
|
|
89
89
|
__exportStar(require("./api/strings/dto/source-string-key-dto"), exports);
|
|
90
90
|
__exportStar(require("./api/strings/params/fetch-source-strings-parameters"), exports);
|
|
91
91
|
__exportStar(require("./api/logger"), exports);
|
|
92
|
+
__exportStar(require("./api/jobs/params/add-file-parameters"), exports);
|
|
93
|
+
__exportStar(require("./api/files/params/download-file-all-translations-parameters"), exports);
|
|
94
|
+
__exportStar(require("./api/jobs/params/authorize-job-parameters"), exports);
|
|
92
95
|
//# sourceMappingURL=index.js.map
|
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,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,oDAAkC;AAClC,8EAA4D;AAC5D,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,mFAAiE;AACjE,wFAAsE;AACtE,2FAAyE;AACzE,wFAAsE;AACtE,0FAAwE;AACxE,wEAAsD;AACtD,wEAAsD;AACtD,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,0EAAwD;AACxD,6EAA2D;AAC3D,4EAA0D;AAC1D,+DAA6C;AAC7C,8EAA4D;AAC5D,yEAAuD;AACvD,2EAAyD;AACzD,0EAAwD;AACxD,yEAAuD;AACvD,2EAAyD;AACzD,yDAAuC;AACvC,yDAAuC;AACvC,uDAAqC;AACrC,iEAA+C;AAC/C,gEAA8C;AAC9C,sDAAoC;AACpC,sEAAoD;AACpD,0EAAwD;AACxD,uFAAqE;AACrE,+CAA6B"}
|
|
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,oDAAkC;AAClC,8EAA4D;AAC5D,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,mFAAiE;AACjE,wFAAsE;AACtE,2FAAyE;AACzE,wFAAsE;AACtE,0FAAwE;AACxE,wEAAsD;AACtD,wEAAsD;AACtD,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,0EAAwD;AACxD,6EAA2D;AAC3D,4EAA0D;AAC1D,+DAA6C;AAC7C,8EAA4D;AAC5D,yEAAuD;AACvD,2EAAyD;AACzD,0EAAwD;AACxD,yEAAuD;AACvD,2EAAyD;AACzD,yDAAuC;AACvC,yDAAuC;AACvC,uDAAqC;AACrC,iEAA+C;AAC/C,gEAA8C;AAC9C,sDAAoC;AACpC,sEAAoD;AACpD,0EAAwD;AACxD,uFAAqE;AACrE,+CAA6B;AAC7B,wEAAsD;AACtD,+FAA6E;AAC7E,6EAA2D"}
|
package/built/package.json
CHANGED
package/index.ts
CHANGED
|
@@ -73,3 +73,6 @@ export * from "./api/strings/dto/source-string-dto";
|
|
|
73
73
|
export * from "./api/strings/dto/source-string-key-dto";
|
|
74
74
|
export * from "./api/strings/params/fetch-source-strings-parameters";
|
|
75
75
|
export * from "./api/logger";
|
|
76
|
+
export * from "./api/jobs/params/add-file-parameters";
|
|
77
|
+
export * from "./api/files/params/download-file-all-translations-parameters";
|
|
78
|
+
export * from "./api/jobs/params/authorize-job-parameters";
|
package/package.json
CHANGED
package/test/files.spec.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { UploadFileParameters } from "../api/files/params/upload-file-parameters
|
|
|
9
9
|
import { SmartlingAuthApi } from "../api/auth/index";
|
|
10
10
|
import { FileType } from "../api/files/params/file-type";
|
|
11
11
|
import { streamToString } from "./stream-to-string";
|
|
12
|
+
import { DownloadFileAllTranslationsParameters } from "../api/files/params/download-file-all-translations-parameters";
|
|
12
13
|
|
|
13
14
|
describe("SmartlingFilesApi class tests.", () => {
|
|
14
15
|
const projectId = "testProjectId";
|
|
@@ -56,6 +57,24 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
56
57
|
);
|
|
57
58
|
});
|
|
58
59
|
|
|
60
|
+
it("Get recently uploaded files for project", async () => {
|
|
61
|
+
await filesApi.getRecentlyUploadedFiles(projectId);
|
|
62
|
+
|
|
63
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
64
|
+
sinon.assert.calledWithExactly(
|
|
65
|
+
filesApiFetchStub,
|
|
66
|
+
`https://test.com/files-api/v2/projects/${projectId}/files/list`,
|
|
67
|
+
{
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: "test_token_type test_access_token",
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
"User-Agent": "test_user_agent"
|
|
72
|
+
},
|
|
73
|
+
method: "get"
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
59
78
|
it("Get last modified", async () => {
|
|
60
79
|
await filesApi.getLastModified(projectId, fileUri);
|
|
61
80
|
|
|
@@ -165,6 +184,59 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
165
184
|
});
|
|
166
185
|
});
|
|
167
186
|
|
|
187
|
+
describe("Download file - all translations", () => {
|
|
188
|
+
let params: DownloadFileAllTranslationsParameters;
|
|
189
|
+
|
|
190
|
+
beforeEach(() => {
|
|
191
|
+
params = new DownloadFileAllTranslationsParameters();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
it("Supports all parameters of single file download", async () => {
|
|
196
|
+
params
|
|
197
|
+
.setRetrievalType(RetrievalType.PUBLISHED)
|
|
198
|
+
.enableDebugMode();
|
|
199
|
+
|
|
200
|
+
await filesApi.downloadFileAllTranslations(projectId, fileUri, params);
|
|
201
|
+
|
|
202
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
203
|
+
sinon.assert.calledWithExactly(
|
|
204
|
+
filesApiFetchStub,
|
|
205
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/all/file?retrievalType=published&debugMode=1&fileUri=testFileUri`,
|
|
206
|
+
{
|
|
207
|
+
headers: {
|
|
208
|
+
Authorization: "test_token_type test_access_token",
|
|
209
|
+
"Content-Type": "application/json",
|
|
210
|
+
"User-Agent": "test_user_agent"
|
|
211
|
+
},
|
|
212
|
+
method: "get"
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("Download file with zip's name set", async () => {
|
|
218
|
+
const zipFileName = "translations-2.zip";
|
|
219
|
+
params.setZipFileName(zipFileName);
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
await filesApi.downloadFileAllTranslations(projectId, fileUri, params);
|
|
223
|
+
|
|
224
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
225
|
+
sinon.assert.calledWithExactly(
|
|
226
|
+
filesApiFetchStub,
|
|
227
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/all/file?zipFileName=${zipFileName}&fileUri=testFileUri`,
|
|
228
|
+
{
|
|
229
|
+
headers: {
|
|
230
|
+
Authorization: "test_token_type test_access_token",
|
|
231
|
+
"Content-Type": "application/json",
|
|
232
|
+
"User-Agent": "test_user_agent"
|
|
233
|
+
},
|
|
234
|
+
method: "get"
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
168
240
|
it("Delete file", async () => {
|
|
169
241
|
await filesApi.deleteFile(projectId, fileUri);
|
|
170
242
|
|
package/test/jobs.spec.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { JobProgressParameters } from "../api/jobs/params/job-progress-parameter
|
|
|
13
13
|
import { CancelJobParameters } from "../api/jobs/params/cancel-job-parameters";
|
|
14
14
|
import { CloseJobParameters } from "../api/jobs/params/close-job-parameters";
|
|
15
15
|
import { AddFileParameters } from "../api/jobs/params/add-file-parameters";
|
|
16
|
+
import { AuthorizeJobParameters } from "../api/jobs/params/authorize-job-parameters";
|
|
16
17
|
|
|
17
18
|
describe("SmartlingJobsAPI class tests.", () => {
|
|
18
19
|
const projectId = "testProjectId";
|
|
@@ -50,7 +51,8 @@ describe("SmartlingJobsAPI class tests.", () => {
|
|
|
50
51
|
params
|
|
51
52
|
.setName("Test job")
|
|
52
53
|
.setDescription("Test job description")
|
|
53
|
-
.setDueDate(new Date("2100-12-31T22:00:00.000Z"))
|
|
54
|
+
.setDueDate(new Date("2100-12-31T22:00:00.000Z"))
|
|
55
|
+
.setTargetLocaleIds(["pt-PT"]);
|
|
54
56
|
|
|
55
57
|
|
|
56
58
|
await jobApi.createJob(projectId, params);
|
|
@@ -60,7 +62,7 @@ describe("SmartlingJobsAPI class tests.", () => {
|
|
|
60
62
|
jobServiceApiFetchStub,
|
|
61
63
|
`https://test.com/jobs-api/v3/projects/${projectId}/jobs`,
|
|
62
64
|
{
|
|
63
|
-
body: "{\"jobName\":\"Test job\",\"description\":\"Test job description\",\"dueDate\":\"2100-12-31T22:00:00.000Z\"}",
|
|
65
|
+
body: "{\"jobName\":\"Test job\",\"description\":\"Test job description\",\"dueDate\":\"2100-12-31T22:00:00.000Z\",\"targetLocaleIds\":[\"pt-PT\"]}",
|
|
64
66
|
headers: {
|
|
65
67
|
Authorization: "test_token_type test_access_token",
|
|
66
68
|
"Content-Type": "application/json",
|
|
@@ -205,6 +207,43 @@ describe("SmartlingJobsAPI class tests.", () => {
|
|
|
205
207
|
);
|
|
206
208
|
});
|
|
207
209
|
|
|
210
|
+
it("Authorizes a job", async () => {
|
|
211
|
+
const params = new AuthorizeJobParameters();
|
|
212
|
+
await jobApi.authorizeJob(projectId, jobUid, params);
|
|
213
|
+
sinon.assert.calledOnce(jobServiceApiFetchStub);
|
|
214
|
+
sinon.assert.calledWithExactly(
|
|
215
|
+
jobServiceApiFetchStub,
|
|
216
|
+
`https://test.com/jobs-api/v3/projects/${projectId}/jobs/${jobUid}/authorize`,
|
|
217
|
+
{
|
|
218
|
+
body: "{}",
|
|
219
|
+
headers: {
|
|
220
|
+
Authorization: "test_token_type test_access_token",
|
|
221
|
+
"Content-Type": "application/json",
|
|
222
|
+
"User-Agent": "test_user_agent"
|
|
223
|
+
},
|
|
224
|
+
method: "post"
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
params.addLocaleWorkflows("fr", "wf1");
|
|
229
|
+
params.addLocaleWorkflows("de", "wf2");
|
|
230
|
+
await jobApi.authorizeJob(projectId, jobUid, params);
|
|
231
|
+
sinon.assert.calledTwice(jobServiceApiFetchStub);
|
|
232
|
+
sinon.assert.calledWithExactly(
|
|
233
|
+
jobServiceApiFetchStub,
|
|
234
|
+
`https://test.com/jobs-api/v3/projects/${projectId}/jobs/${jobUid}/authorize`,
|
|
235
|
+
{
|
|
236
|
+
body: "{\"localeWorkflows\":[{\"targetLocaleId\":\"fr\",\"workflowUid\":\"wf1\"},{\"targetLocaleId\":\"de\",\"workflowUid\":\"wf2\"}]}",
|
|
237
|
+
headers: {
|
|
238
|
+
Authorization: "test_token_type test_access_token",
|
|
239
|
+
"Content-Type": "application/json",
|
|
240
|
+
"User-Agent": "test_user_agent"
|
|
241
|
+
},
|
|
242
|
+
method: "post"
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
|
|
208
247
|
it("Remove file from job", async () => {
|
|
209
248
|
const params = new RemoveFileParameters();
|
|
210
249
|
|