asposeslidescloud 23.2.0 → 23.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.
@@ -1,13 +1,12 @@
1
- import request = require("request");
2
1
  import { Configuration } from "./configuration";
3
- export declare function checkMultipartContent(options: request.Options, files: any): void;
2
+ export declare function checkMultipartContent(options: any, files: any): void;
4
3
  /**
5
4
  * Invoke api method
6
5
  * @param requestOptions request parameters
7
6
  * @param confguration api configuration
8
7
  * @param notApplyAuthToRequest if setted to true, auth is not applied to request
9
8
  */
10
- export declare function invokeApiMethod(requestOptions: request.Options, confguration: Configuration, notApplyAuthToRequest?: boolean): Promise<request.RequestResponse>;
9
+ export declare function invokeApiMethod(requestOptions: any, confguration: Configuration, notApplyAuthToRequest?: boolean): Promise<any>;
11
10
  /**
12
11
  * Add parameter to query
13
12
  * @param url url
@@ -33,8 +33,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.addHeaderParameter = exports.addPathParameterToUrl = exports.addQueryParameterToUrl = exports.invokeApiMethod = exports.checkMultipartContent = void 0;
36
- const request = require("request");
37
- const requestDebug = require("request-debug");
36
+ const axios_1 = require("axios");
37
+ axios_1.default.interceptors.request.use(request => {
38
+ if (request.debug) {
39
+ console.log('>> Request');
40
+ console.log(request);
41
+ }
42
+ return request;
43
+ });
44
+ axios_1.default.interceptors.response.use(response => {
45
+ if (response.config.debug) {
46
+ console.log('<< Response');
47
+ console.log(response);
48
+ }
49
+ return response;
50
+ });
38
51
  const objectSerializer_1 = require("./objectSerializer");
39
52
  function checkMultipartContent(options, files) {
40
53
  if (files && files.length) {
@@ -42,8 +55,8 @@ function checkMultipartContent(options, files) {
42
55
  pipeline: null,
43
56
  attachments: []
44
57
  };
45
- if (options.json !== true && options.json) {
46
- data.pipeline = JSON.stringify(options.json);
58
+ if (options.data) {
59
+ data.pipeline = JSON.stringify(options.data);
47
60
  }
48
61
  else {
49
62
  delete data.pipeline;
@@ -51,8 +64,11 @@ function checkMultipartContent(options, files) {
51
64
  for (var i = 0; i < files.length; i++) {
52
65
  data.attachments.push(files[i]);
53
66
  }
54
- options.formData = data;
55
- options.json = null;
67
+ options.data = data;
68
+ if (!options.headers) {
69
+ options.headers = {};
70
+ }
71
+ options.headers["Content-type"] = "multipart/form-data";
56
72
  }
57
73
  }
58
74
  exports.checkMultipartContent = checkMultipartContent;
@@ -135,21 +151,13 @@ exports.addHeaderParameter = addHeaderParameter;
135
151
  */
136
152
  function invokeApiMethodInternal(requestOptions, configuration, notApplyAuthToRequest) {
137
153
  return __awaiter(this, void 0, void 0, function* () {
138
- requestDebug(request, (type, data, r) => {
139
- if (r.writeDebugToConsole) {
140
- const toLog = {};
141
- toLog[type] = data;
142
- // tslint:disable-next-line:no-console
143
- console.log(JSON.stringify(toLog, undefined, 2));
144
- }
145
- });
146
154
  if (configuration.allowInsecureRequests) {
147
155
  requestOptions.rejectUnauthorized = false;
148
156
  }
149
157
  if (!requestOptions.headers) {
150
158
  requestOptions.headers = {};
151
159
  }
152
- requestOptions.headers["x-aspose-client"] = "nodejs sdk v23.2.0";
160
+ requestOptions.headers["x-aspose-client"] = "nodejs sdk v23.3.0";
153
161
  if (configuration.timeout) {
154
162
  requestOptions.headers["x-aspose-timeout"] = configuration.timeout;
155
163
  }
@@ -159,49 +167,30 @@ function invokeApiMethodInternal(requestOptions, configuration, notApplyAuthToRe
159
167
  if (!notApplyAuthToRequest) {
160
168
  yield addAuthHeader(requestOptions, configuration);
161
169
  }
170
+ else {
171
+ requestOptions.headers["Content-type"] = "application/x-www-form-urlencoded";
172
+ }
173
+ requestOptions.debug = configuration.debugMode;
162
174
  return new Promise((resolve, reject) => {
163
- const r = request(requestOptions, (error, response) => __awaiter(this, void 0, void 0, function* () {
164
- if (error) {
165
- reject(error);
175
+ const r = (0, axios_1.default)(requestOptions)
176
+ .then((response) => __awaiter(this, void 0, void 0, function* () {
177
+ //compatibility with request library responses
178
+ response.body = response.data;
179
+ response.statusCode = response.status;
180
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
181
+ resolve(response);
166
182
  }
167
183
  else {
168
- if (response.statusCode >= 200 && response.statusCode <= 299) {
169
- resolve(response);
170
- }
171
- else if (!notApplyAuthToRequest && response.statusCode === 401) {
172
- yield requestToken(configuration);
173
- reject(new NeedRepeatException());
174
- }
175
- else {
176
- try {
177
- if (response.statusCode == 400 && response.body && response.body.error && typeof response.body.error == "string") {
178
- reject({ message: response.body.error, code: 401 });
179
- }
180
- else if (response.body && (response.body.length === undefined || response.body.length)) {
181
- let bodyContent = response.body;
182
- let bodyString = bodyContent;
183
- if (bodyContent instanceof Buffer) {
184
- bodyString = bodyContent.toString("utf8");
185
- bodyContent = JSON.parse(bodyString);
186
- }
187
- let result = objectSerializer_1.ObjectSerializer.deserialize(bodyContent, "SlidesApiErrorResponse");
188
- try {
189
- result = JSON.parse(result);
190
- }
191
- catch (_a) {
192
- //Error means the object is already deserialized
193
- reject({ message: result.error ? result.error.message : bodyString, code: response.statusCode });
194
- }
195
- }
196
- else {
197
- reject({ message: response.statusMessage, code: response.statusCode });
198
- }
199
- }
200
- catch (error) {
201
- reject({ message: "Error while parse server error: " + error });
202
- }
203
- }
184
+ yield rejectResponse(reject, response, configuration, notApplyAuthToRequest);
185
+ }
186
+ }))
187
+ .catch((error) => __awaiter(this, void 0, void 0, function* () {
188
+ if (error.response) {
189
+ error.response.body = error.response.data;
190
+ error.response.statusCode = error.response.status;
191
+ yield rejectResponse(reject, error.response, configuration, notApplyAuthToRequest);
204
192
  }
193
+ reject(error);
205
194
  }));
206
195
  r.writeDebugToConsole = configuration.debugMode;
207
196
  });
@@ -230,19 +219,55 @@ function requestToken(configuration) {
230
219
  return __awaiter(this, void 0, void 0, function* () {
231
220
  const requestOptions = {
232
221
  method: "POST",
233
- json: true,
234
- uri: configuration.authBaseUrl + "/connect/token",
235
- form: {
222
+ url: configuration.authBaseUrl + "/connect/token",
223
+ data: {
236
224
  grant_type: "client_credentials",
237
225
  client_id: configuration.appSid,
238
226
  client_secret: configuration.appKey,
239
- },
227
+ }
240
228
  };
241
229
  const response = yield invokeApiMethod(requestOptions, configuration, true);
242
230
  configuration.accessToken = response.body.access_token;
243
231
  return Promise.resolve();
244
232
  });
245
233
  }
234
+ function rejectResponse(reject, response, configuration, notApplyAuthToRequest) {
235
+ return __awaiter(this, void 0, void 0, function* () {
236
+ if (!notApplyAuthToRequest && response.statusCode === 401) {
237
+ yield requestToken(configuration);
238
+ reject(new NeedRepeatException());
239
+ }
240
+ else {
241
+ try {
242
+ if (response.statusCode == 400 && response.body && response.body.error && typeof response.body.error == "string") {
243
+ reject({ message: response.body.error, code: 401 });
244
+ }
245
+ else if (response.body && (response.body.length === undefined || response.body.length)) {
246
+ let bodyContent = response.body;
247
+ let bodyString = bodyContent;
248
+ if (bodyContent instanceof Buffer) {
249
+ bodyString = bodyContent.toString("utf8");
250
+ bodyContent = JSON.parse(bodyString);
251
+ }
252
+ let result = objectSerializer_1.ObjectSerializer.deserialize(bodyContent, "SlidesApiErrorResponse");
253
+ try {
254
+ result = JSON.parse(result);
255
+ }
256
+ catch (_a) {
257
+ //Error means the object is already deserialized
258
+ reject({ message: result.error ? result.error.message : bodyString, code: response.statusCode });
259
+ }
260
+ }
261
+ else {
262
+ reject({ message: response.statusMessage, code: response.statusCode });
263
+ }
264
+ }
265
+ catch (error) {
266
+ reject({ message: "Error while parse server error: " + error });
267
+ }
268
+ }
269
+ });
270
+ }
246
271
  var requestingToken = null;
247
272
  var isRequestTokenPending = false;
248
273
  /**
package/model.d.ts CHANGED
@@ -3462,6 +3462,10 @@ export declare class ImageExportOptions extends ImageExportOptionsBase {
3462
3462
  * Gets or sets the color of comments area (Applies only if comments are displayed on the right).
3463
3463
  */
3464
3464
  commentsAreaColor?: string;
3465
+ /**
3466
+ * Show hidden slides. If true, hidden are exported.
3467
+ */
3468
+ showHiddenSlides?: boolean;
3465
3469
  }
3466
3470
  export declare namespace ImageExportOptions {
3467
3471
  enum NotesPositionEnum {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asposeslidescloud",
3
- "version": "23.2.0",
3
+ "version": "23.3.0",
4
4
  "description": "Aspose.Slides Cloud SDK for Node.js",
5
5
  "homepage": "https://products.aspose.cloud/slides/cloud",
6
6
  "author": {