smartling-api-sdk-nodejs 1.4.0 → 1.5.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.
@@ -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=AYV9DhQDVHxvPN93RdDY
6
- ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AYV9DhQDVHxvPN93RdDY
5
+ ceTaskId=AYbms_u9gRVcM-XZbdl1
6
+ ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AYbms_u9gRVcM-XZbdl1
@@ -79,6 +79,7 @@ export class SmartlingApiClientBuilder {
79
79
 
80
80
  this.authApiClient.setClientLibId(this.clientLibId);
81
81
  this.authApiClient.setClientLibVersion(this.clientLibVersion);
82
+ this.authApiClient.setOptions(this.httpClientOptions);
82
83
  }
83
84
 
84
85
  const instance = new constructor(this.baseSmartlingApiUrl, this.authApiClient, this.logger);
@@ -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
  }
@@ -48,6 +48,7 @@ class SmartlingApiClientBuilder {
48
48
  this.authApiClient = new index_1.SmartlingAuthApi(this.baseSmartlingApiUrl, this.userId, this.userSecret, this.logger);
49
49
  this.authApiClient.setClientLibId(this.clientLibId);
50
50
  this.authApiClient.setClientLibVersion(this.clientLibVersion);
51
+ this.authApiClient.setOptions(this.httpClientOptions);
51
52
  }
52
53
  const instance = new constructor(this.baseSmartlingApiUrl, this.authApiClient, this.logger);
53
54
  instance.setClientLibId(this.clientLibId);
@@ -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;QACc,kBAAa,GAAqB,IAAI,CAAC;QACvC,WAAM,GAAW,IAAI,CAAC;QACtB,eAAU,GAAW,IAAI,CAAC;QAE1B,sBAAiB,GAA4B,EAAE,CAAC;QAChD,gBAAW,GAAW,WAAW,CAAC,IAAI,CAAC;QACvC,qBAAgB,GAAW,WAAW,CAAC,OAAO,CAAC;QAC/C,WAAM,GAAW;YAEvB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;YAEf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YAEd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;SAClB,CAAC;IAqEN,CAAC;IAnEU,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,sBAAsB,CAAC,mBAA2B;QACrD,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAE/C,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,0BAA0B,CAC7B,iBAA0C;QAE1C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAE3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,oBAAoB,CACvB,WAAmB,EAAE,gBAAwB;QAE7C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAEzC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,2BAA2B,CAC9B,MAAc,EAAE,UAAkB;QAElC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,C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,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;YAC9D,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;SACzD;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;AArFD,8DAqFC"}
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "smartling-api-sdk-nodejs",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
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.0",
3
+ "version": "1.5.0",
4
4
  "description": "Package for Smartling API",
5
5
  "main": "built/index.js",
6
6
  "scripts": {
@@ -229,6 +229,17 @@ describe("SmartlingApiClientBuilder class tests.", () => {
229
229
  );
230
230
  });
231
231
 
232
+ it("should provide http client options to auth client", () => {
233
+ const httpClientOptions = { test: "value" };
234
+ const apiClient = new SmartlingApiClientBuilder()
235
+ .authWithUserIdAndUserSecret("test_user_id", "test_user_secret")
236
+ .setBaseSmartlingApiUrl("test_base_url")
237
+ .setHttpClientConfiguration(httpClientOptions)
238
+ .build(SmartlingJobsApi);
239
+
240
+ assert.equal(apiClient["options"], httpClientOptions);
241
+ });
242
+
232
243
  it("Instantiates files api client", () => {
233
244
  assertApiClient(
234
245
  SmartlingFilesApi,
@@ -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 () => {