smartling-api-sdk-nodejs 1.4.1 → 1.5.1

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.
@@ -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=AYaeDUlIgRVcM-XZbdjJ
6
- ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AYaeDUlIgRVcM-XZbdjJ
5
+ ceTaskId=AYb_wiRQgRVcM-XZbdmD
6
+ ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AYb_wiRQgRVcM-XZbdmD
@@ -13,4 +13,16 @@ export class DownloadFileParameters extends BaseParameters {
13
13
 
14
14
  return this;
15
15
  }
16
+
17
+ includeOriginalStrings(): DownloadFileParameters {
18
+ this.set("includeOriginalStrings", true);
19
+
20
+ return this;
21
+ }
22
+
23
+ excludeOriginalStrings(): DownloadFileParameters {
24
+ this.set("includeOriginalStrings", false);
25
+
26
+ return this;
27
+ }
16
28
  }
@@ -1,7 +1,7 @@
1
1
  import { SourceFileDto } from "./source-file-dto";
2
2
 
3
3
  interface FullSourceFileDto extends SourceFileDto {
4
- name: string;
4
+ localeIds: Array<string>;
5
5
  }
6
6
 
7
7
  export { FullSourceFileDto };
@@ -1,9 +1,9 @@
1
1
  import { JobDto } from "./job-dto";
2
- import { FullSourceFileDto } from "./full-source-file-dto";
2
+ import { SourceFileDto } from "./source-file-dto";
3
3
 
4
4
  interface JobDetailsDto extends JobDto {
5
5
  priority: string;
6
- sourceFiles: Array<FullSourceFileDto>;
6
+ sourceFiles: Array<SourceFileDto>;
7
7
  }
8
8
 
9
9
  export { JobDetailsDto };
@@ -1,5 +1,7 @@
1
1
  interface SourceFileDto {
2
2
  uri: string;
3
+ name: string;
4
+ fileUid: string;
3
5
  }
4
6
 
5
7
  export { SourceFileDto };
package/api/jobs/index.ts CHANGED
@@ -11,12 +11,12 @@ 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 { SourceFileDto } from "./dto/source-file-dto";
15
14
  import { RemovedFileDto } from "./dto/removed-file-dto";
16
15
  import { JobProgressDto } from "./dto/job-progress-dto";
17
16
  import { JobProgressParameters } from "./params/job-progress-parameters";
18
17
  import { CancelJobParameters } from "./params/cancel-job-parameters";
19
18
  import { SearchJobsParameters } from "./params/search-jobs-parameters";
19
+ import { FullSourceFileDto } from "./dto/full-source-file-dto";
20
20
 
21
21
  export class SmartlingJobsApi extends SmartlingBaseApi {
22
22
  constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger) {
@@ -42,7 +42,7 @@ export class SmartlingJobsApi extends SmartlingBaseApi {
42
42
 
43
43
  async getJobFiles(
44
44
  projectId: string, translationJobUid: string, params: ListJobFilesParameters
45
- ): Promise<SmartlingListResponse<SourceFileDto>> {
45
+ ): Promise<SmartlingListResponse<FullSourceFileDto>> {
46
46
  return await this.makeRequest(
47
47
  "get",
48
48
  `${this.entrypoint}/${projectId}/jobs/${translationJobUid}/files`,
@@ -3,4 +3,6 @@ import { RetrievalType } from "./retrieval-type";
3
3
  export declare class DownloadFileParameters extends BaseParameters {
4
4
  enableDebugMode(): DownloadFileParameters;
5
5
  setRetrievalType(retrievalType: RetrievalType): DownloadFileParameters;
6
+ includeOriginalStrings(): DownloadFileParameters;
7
+ excludeOriginalStrings(): DownloadFileParameters;
6
8
  }
@@ -11,6 +11,14 @@ class DownloadFileParameters extends index_1.BaseParameters {
11
11
  this.set("retrievalType", retrievalType);
12
12
  return this;
13
13
  }
14
+ includeOriginalStrings() {
15
+ this.set("includeOriginalStrings", true);
16
+ return this;
17
+ }
18
+ excludeOriginalStrings() {
19
+ this.set("includeOriginalStrings", false);
20
+ return this;
21
+ }
14
22
  }
15
23
  exports.DownloadFileParameters = DownloadFileParameters;
16
24
  //# sourceMappingURL=download-file-parameters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"download-file-parameters.js","sourceRoot":"","sources":["../../../../api/files/params/download-file-parameters.ts"],"names":[],"mappings":";;;AAAA,kDAAwD;AAGxD,MAAa,sBAAuB,SAAQ,sBAAc;IACtD,eAAe;QACX,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAEzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB,CAAC,aAA4B;QACzC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAZD,wDAYC"}
1
+ {"version":3,"file":"download-file-parameters.js","sourceRoot":"","sources":["../../../../api/files/params/download-file-parameters.ts"],"names":[],"mappings":";;;AAAA,kDAAwD;AAGxD,MAAa,sBAAuB,SAAQ,sBAAc;IACtD,eAAe;QACX,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAEzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB,CAAC,aAA4B;QACzC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,sBAAsB;QAClB,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,sBAAsB;QAClB,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAE1C,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAxBD,wDAwBC"}
@@ -1,5 +1,5 @@
1
1
  import { SourceFileDto } from "./source-file-dto";
2
2
  interface FullSourceFileDto extends SourceFileDto {
3
- name: string;
3
+ localeIds: Array<string>;
4
4
  }
5
5
  export { FullSourceFileDto };
@@ -1,7 +1,7 @@
1
1
  import { JobDto } from "./job-dto";
2
- import { FullSourceFileDto } from "./full-source-file-dto";
2
+ import { SourceFileDto } from "./source-file-dto";
3
3
  interface JobDetailsDto extends JobDto {
4
4
  priority: string;
5
- sourceFiles: Array<FullSourceFileDto>;
5
+ sourceFiles: Array<SourceFileDto>;
6
6
  }
7
7
  export { JobDetailsDto };
@@ -1,4 +1,6 @@
1
1
  interface SourceFileDto {
2
2
  uri: string;
3
+ name: string;
4
+ fileUid: string;
3
5
  }
4
6
  export { SourceFileDto };
@@ -11,17 +11,17 @@ 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 { SourceFileDto } from "./dto/source-file-dto";
15
14
  import { RemovedFileDto } from "./dto/removed-file-dto";
16
15
  import { JobProgressDto } from "./dto/job-progress-dto";
17
16
  import { JobProgressParameters } from "./params/job-progress-parameters";
18
17
  import { CancelJobParameters } from "./params/cancel-job-parameters";
19
18
  import { SearchJobsParameters } from "./params/search-jobs-parameters";
19
+ import { FullSourceFileDto } from "./dto/full-source-file-dto";
20
20
  export declare class SmartlingJobsApi extends SmartlingBaseApi {
21
21
  constructor(smartlingApiBaseUrl: string, authApi: SmartlingAuthApi, logger: Logger);
22
22
  createJob(projectId: string, params: CreateJobParameters): Promise<JobDto>;
23
23
  getJob(projectId: string, translationJobUid: string): Promise<JobDetailsDto>;
24
- getJobFiles(projectId: string, translationJobUid: string, params: ListJobFilesParameters): Promise<SmartlingListResponse<SourceFileDto>>;
24
+ getJobFiles(projectId: string, translationJobUid: string, params: ListJobFilesParameters): Promise<SmartlingListResponse<FullSourceFileDto>>;
25
25
  listJobs(projectId: string, params: ListJobsParameters): Promise<SmartlingListResponse<BaseJobDto>>;
26
26
  searchJobs(projectId: string, params: SearchJobsParameters): Promise<SmartlingListResponse<BaseJobDto>>;
27
27
  removeFileFromJob(projectId: string, translationJobUid: string, params: RemoveFileParameters): Promise<RemovedFileDto>;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartling-api-sdk-nodejs",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "description": "Package for Smartling API",
5
5
  "main": "built/index.js",
6
6
  "scripts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartling-api-sdk-nodejs",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "description": "Package for Smartling API",
5
5
  "main": "built/index.js",
6
6
  "scripts": {
@@ -74,29 +74,95 @@ describe("SmartlingFilesApi class tests.", () => {
74
74
  );
75
75
  });
76
76
 
77
- it("Download file", async () => {
77
+ describe("Download file", () => {
78
78
  const localeId = "fr-FR";
79
- const params = new DownloadFileParameters();
80
-
81
- params
82
- .setRetrievalType(RetrievalType.PUBLISHED)
83
- .enableDebugMode();
84
-
85
- await filesApi.downloadFile(projectId, fileUri, localeId, params);
86
-
87
- sinon.assert.calledOnce(filesApiFetchStub);
88
- sinon.assert.calledWithExactly(
89
- filesApiFetchStub,
90
- `https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&debugMode=1&fileUri=testFileUri`,
91
- {
92
- headers: {
93
- Authorization: "test_token_type test_access_token",
94
- "Content-Type": "application/json",
95
- "User-Agent": "test_user_agent"
96
- },
97
- method: "get"
98
- }
99
- );
79
+ let params: DownloadFileParameters;
80
+
81
+ beforeEach(() => {
82
+ params = new DownloadFileParameters();
83
+ });
84
+
85
+ it("Download file with debugMode enabled and retrievalType published", async () => {
86
+ params
87
+ .setRetrievalType(RetrievalType.PUBLISHED)
88
+ .enableDebugMode();
89
+
90
+ await filesApi.downloadFile(projectId, fileUri, localeId, params);
91
+
92
+ sinon.assert.calledOnce(filesApiFetchStub);
93
+ sinon.assert.calledWithExactly(
94
+ filesApiFetchStub,
95
+ `https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&debugMode=1&fileUri=testFileUri`,
96
+ {
97
+ headers: {
98
+ Authorization: "test_token_type test_access_token",
99
+ "Content-Type": "application/json",
100
+ "User-Agent": "test_user_agent"
101
+ },
102
+ method: "get"
103
+ }
104
+ );
105
+ });
106
+
107
+ it("Download file with debugMode disabled and retrievalType published", async () => {
108
+ params.setRetrievalType(RetrievalType.PUBLISHED);
109
+
110
+ await filesApi.downloadFile(projectId, fileUri, localeId, params);
111
+
112
+ sinon.assert.calledOnce(filesApiFetchStub);
113
+ sinon.assert.calledWithExactly(
114
+ filesApiFetchStub,
115
+ `https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&fileUri=testFileUri`,
116
+ {
117
+ headers: {
118
+ Authorization: "test_token_type test_access_token",
119
+ "Content-Type": "application/json",
120
+ "User-Agent": "test_user_agent"
121
+ },
122
+ method: "get"
123
+ }
124
+ );
125
+ });
126
+
127
+ it("Download file with includeOriginalStrings enabled", async() => {
128
+ params.setRetrievalType(RetrievalType.PUBLISHED).includeOriginalStrings();
129
+
130
+ await filesApi.downloadFile(projectId, fileUri, localeId, params);
131
+
132
+ sinon.assert.calledOnce(filesApiFetchStub);
133
+ sinon.assert.calledWithExactly(
134
+ filesApiFetchStub,
135
+ `https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&includeOriginalStrings=true&fileUri=testFileUri`,
136
+ {
137
+ headers: {
138
+ Authorization: "test_token_type test_access_token",
139
+ "Content-Type": "application/json",
140
+ "User-Agent": "test_user_agent"
141
+ },
142
+ method: "get"
143
+ }
144
+ );
145
+ });
146
+
147
+ it("Download file with includeOriginalStrings disabled", async() => {
148
+ params.setRetrievalType(RetrievalType.PUBLISHED).excludeOriginalStrings();
149
+
150
+ await filesApi.downloadFile(projectId, fileUri, localeId, params);
151
+
152
+ sinon.assert.calledOnce(filesApiFetchStub);
153
+ sinon.assert.calledWithExactly(
154
+ filesApiFetchStub,
155
+ `https://test.com/files-api/v2/projects/${projectId}/locales/${localeId}/file?retrievalType=published&includeOriginalStrings=false&fileUri=testFileUri`,
156
+ {
157
+ headers: {
158
+ Authorization: "test_token_type test_access_token",
159
+ "Content-Type": "application/json",
160
+ "User-Agent": "test_user_agent"
161
+ },
162
+ method: "get"
163
+ }
164
+ );
165
+ });
100
166
  });
101
167
 
102
168
  it("Delete file", async () => {