asposeslidescloud 21.12.0 → 22.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.
@@ -1,247 +1,247 @@
1
- "use strict";
2
- /*
3
- * MIT License
4
-
5
- * Copyright (c) 2018 Aspose Pty Ltd
6
-
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
-
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
-
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- return new (P || (P = Promise))(function (resolve, reject) {
27
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
28
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
29
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
30
- step((generator = generator.apply(thisArg, _arguments || [])).next());
31
- });
32
- };
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- const request = require("request");
35
- const requestDebug = require("request-debug");
36
- const objectSerializer_1 = require("./objectSerializer");
37
- function checkMultipartContent(options, files) {
38
- if (files && files.length) {
39
- const data = {
40
- pipeline: null,
41
- attachments: []
42
- };
43
- if (options.json !== true && options.json) {
44
- data.pipeline = JSON.stringify(options.json);
45
- }
46
- else {
47
- delete data.pipeline;
48
- }
49
- for (var i = 0; i < files.length; i++) {
50
- data.attachments.push(files[i]);
51
- }
52
- options.formData = data;
53
- options.json = null;
54
- }
55
- }
56
- exports.checkMultipartContent = checkMultipartContent;
57
- /**
58
- * Invoke api method
59
- * @param requestOptions request parameters
60
- * @param confguration api configuration
61
- * @param notApplyAuthToRequest if setted to true, auth is not applied to request
62
- */
63
- function invokeApiMethod(requestOptions, confguration, notApplyAuthToRequest) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- try {
66
- return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
67
- }
68
- catch (e) {
69
- if (e instanceof NeedRepeatException) {
70
- return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
71
- }
72
- throw e;
73
- }
74
- });
75
- }
76
- exports.invokeApiMethod = invokeApiMethod;
77
- /**
78
- * Add parameter to query
79
- * @param url url
80
- * @param queryParameters queryParameters
81
- * @param parameterName parameterName
82
- * @param parameterValue parameterValue
83
- */
84
- function addQueryParameterToUrl(url, queryParameters, parameterName, parameterValue) {
85
- if (parameterValue !== undefined && parameterValue != null) {
86
- if (Array.isArray(parameterValue)) {
87
- parameterValue = parameterValue.join(",");
88
- }
89
- if (url.indexOf("{" + parameterName + "}") >= 0) {
90
- url = url.replace("{" + parameterName + "}", String(parameterValue));
91
- }
92
- else {
93
- queryParameters[parameterName] = String(parameterValue);
94
- }
95
- }
96
- else {
97
- url = url.replace("/{" + parameterName + "}", "");
98
- }
99
- return url;
100
- }
101
- exports.addQueryParameterToUrl = addQueryParameterToUrl;
102
- /**
103
- * Add parameter to query
104
- * @param url url
105
- * @param queryParameters queryParameters
106
- * @param parameterName parameterName
107
- * @param parameterValue parameterValue
108
- */
109
- function addPathParameterToUrl(url, parameterName, parameterValue) {
110
- if (!parameterValue) {
111
- return url.replace("/{" + parameterName + "}", "");
112
- }
113
- return url.replace("{" + parameterName + "}", parameterValue);
114
- }
115
- exports.addPathParameterToUrl = addPathParameterToUrl;
116
- /**
117
- * Add parameter to headers
118
- * @param headers headers
119
- * @param parameterName parameterName
120
- * @param parameterValue parameterValue
121
- */
122
- function addHeaderParameter(headers, parameterName, parameterValue) {
123
- if (parameterValue) {
124
- headers[parameterName] = String(parameterValue);
125
- }
126
- }
127
- exports.addHeaderParameter = addHeaderParameter;
128
- /**
129
- * Invoke api method
130
- * @param requestOptions request parameters
131
- * @param confguration api configuration
132
- * @param notApplyAuthToRequest if setted to true, auth is not applied to request
133
- */
134
- function invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- requestDebug(request, (type, data, r) => {
137
- if (r.writeDebugToConsole) {
138
- const toLog = {};
139
- toLog[type] = data;
140
- // tslint:disable-next-line:no-console
141
- console.log(JSON.stringify(toLog, undefined, 2));
142
- }
143
- });
144
- if (!requestOptions.headers) {
145
- requestOptions.headers = {};
146
- }
147
- requestOptions.headers["x-aspose-client"] = "nodejs sdk v21.12.0";
148
- if (confguration.timeout) {
149
- requestOptions.headers["x-aspose-timeout"] = confguration.timeout;
150
- }
151
- for (var key in confguration.customHeaders) {
152
- requestOptions.headers[key] = confguration.customHeaders[key];
153
- }
154
- if (!notApplyAuthToRequest) {
155
- yield addAuthHeader(requestOptions, confguration);
156
- }
157
- return new Promise((resolve, reject) => {
158
- const r = request(requestOptions, (error, response) => __awaiter(this, void 0, void 0, function* () {
159
- if (error) {
160
- reject(error);
161
- }
162
- else {
163
- if (response.statusCode >= 200 && response.statusCode <= 299) {
164
- resolve(response);
165
- }
166
- else if (!notApplyAuthToRequest && response.statusCode === 401) {
167
- yield requestToken(confguration);
168
- reject(new NeedRepeatException());
169
- }
170
- else {
171
- try {
172
- if (response.statusCode == 400 && response.body && response.body.error && typeof response.body.error == "string") {
173
- reject({ message: response.body.error, code: 401 });
174
- }
175
- else if (response.body && (response.body.length === undefined || response.body.length)) {
176
- let bodyContent = response.body;
177
- let bodyString = bodyContent;
178
- if (bodyContent instanceof Buffer) {
179
- bodyString = bodyContent.toString("utf8");
180
- bodyContent = JSON.parse(bodyString);
181
- }
182
- let result = objectSerializer_1.ObjectSerializer.deserialize(bodyContent, "SlidesApiErrorResponse");
183
- try {
184
- result = JSON.parse(result);
185
- }
186
- catch (_a) {
187
- //Error means the object is already deserialized
188
- reject({ message: result.error ? result.error.message : bodyString, code: response.statusCode });
189
- }
190
- }
191
- else {
192
- reject({ message: response.statusMessage, code: response.statusCode });
193
- }
194
- }
195
- catch (error) {
196
- reject({ message: "Error while parse server error: " + error });
197
- }
198
- }
199
- }
200
- }));
201
- r.writeDebugToConsole = confguration.debugMode;
202
- });
203
- });
204
- }
205
- function addAuthHeader(requestOptions, configuration) {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- if (configuration.appSid || configuration.appKey) {
208
- if (isRequestTokenPending) {
209
- yield requestingToken;
210
- }
211
- if (!configuration.accessToken) {
212
- isRequestTokenPending = true;
213
- requestingToken = requestToken(configuration).catch((err) => { isRequestTokenPending = false; throw (err); });
214
- yield requestingToken;
215
- }
216
- isRequestTokenPending = false;
217
- if (requestOptions && requestOptions.headers) {
218
- requestOptions.headers.Authorization = "Bearer " + configuration.accessToken;
219
- }
220
- }
221
- return Promise.resolve();
222
- });
223
- }
224
- function requestToken(configuration) {
225
- return __awaiter(this, void 0, void 0, function* () {
226
- const requestOptions = {
227
- method: "POST",
228
- json: true,
229
- uri: configuration.authBaseUrl + "/connect/token",
230
- form: {
231
- grant_type: "client_credentials",
232
- client_id: configuration.appSid,
233
- client_secret: configuration.appKey,
234
- },
235
- };
236
- const response = yield invokeApiMethod(requestOptions, configuration, true);
237
- configuration.accessToken = response.body.access_token;
238
- return Promise.resolve();
239
- });
240
- }
241
- var requestingToken = null;
242
- var isRequestTokenPending = false;
243
- /**
244
- * Exception, indicating necessity of request repeat
245
- */
246
- class NeedRepeatException extends Error {
247
- }
1
+ "use strict";
2
+ /*
3
+ * MIT License
4
+
5
+ * Copyright (c) 2018 Aspose Pty Ltd
6
+
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ return new (P || (P = Promise))(function (resolve, reject) {
27
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
28
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
29
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
30
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31
+ });
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ const request = require("request");
35
+ const requestDebug = require("request-debug");
36
+ const objectSerializer_1 = require("./objectSerializer");
37
+ function checkMultipartContent(options, files) {
38
+ if (files && files.length) {
39
+ const data = {
40
+ pipeline: null,
41
+ attachments: []
42
+ };
43
+ if (options.json !== true && options.json) {
44
+ data.pipeline = JSON.stringify(options.json);
45
+ }
46
+ else {
47
+ delete data.pipeline;
48
+ }
49
+ for (var i = 0; i < files.length; i++) {
50
+ data.attachments.push(files[i]);
51
+ }
52
+ options.formData = data;
53
+ options.json = null;
54
+ }
55
+ }
56
+ exports.checkMultipartContent = checkMultipartContent;
57
+ /**
58
+ * Invoke api method
59
+ * @param requestOptions request parameters
60
+ * @param confguration api configuration
61
+ * @param notApplyAuthToRequest if setted to true, auth is not applied to request
62
+ */
63
+ function invokeApiMethod(requestOptions, confguration, notApplyAuthToRequest) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ try {
66
+ return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
67
+ }
68
+ catch (e) {
69
+ if (e instanceof NeedRepeatException) {
70
+ return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
71
+ }
72
+ throw e;
73
+ }
74
+ });
75
+ }
76
+ exports.invokeApiMethod = invokeApiMethod;
77
+ /**
78
+ * Add parameter to query
79
+ * @param url url
80
+ * @param queryParameters queryParameters
81
+ * @param parameterName parameterName
82
+ * @param parameterValue parameterValue
83
+ */
84
+ function addQueryParameterToUrl(url, queryParameters, parameterName, parameterValue) {
85
+ if (parameterValue !== undefined && parameterValue != null) {
86
+ if (Array.isArray(parameterValue)) {
87
+ parameterValue = parameterValue.join(",");
88
+ }
89
+ if (url.indexOf("{" + parameterName + "}") >= 0) {
90
+ url = url.replace("{" + parameterName + "}", String(parameterValue));
91
+ }
92
+ else {
93
+ queryParameters[parameterName] = String(parameterValue);
94
+ }
95
+ }
96
+ else {
97
+ url = url.replace("/{" + parameterName + "}", "");
98
+ }
99
+ return url;
100
+ }
101
+ exports.addQueryParameterToUrl = addQueryParameterToUrl;
102
+ /**
103
+ * Add parameter to query
104
+ * @param url url
105
+ * @param queryParameters queryParameters
106
+ * @param parameterName parameterName
107
+ * @param parameterValue parameterValue
108
+ */
109
+ function addPathParameterToUrl(url, parameterName, parameterValue) {
110
+ if (!parameterValue) {
111
+ return url.replace("/{" + parameterName + "}", "");
112
+ }
113
+ return url.replace("{" + parameterName + "}", parameterValue);
114
+ }
115
+ exports.addPathParameterToUrl = addPathParameterToUrl;
116
+ /**
117
+ * Add parameter to headers
118
+ * @param headers headers
119
+ * @param parameterName parameterName
120
+ * @param parameterValue parameterValue
121
+ */
122
+ function addHeaderParameter(headers, parameterName, parameterValue) {
123
+ if (parameterValue) {
124
+ headers[parameterName] = String(parameterValue);
125
+ }
126
+ }
127
+ exports.addHeaderParameter = addHeaderParameter;
128
+ /**
129
+ * Invoke api method
130
+ * @param requestOptions request parameters
131
+ * @param confguration api configuration
132
+ * @param notApplyAuthToRequest if setted to true, auth is not applied to request
133
+ */
134
+ function invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ requestDebug(request, (type, data, r) => {
137
+ if (r.writeDebugToConsole) {
138
+ const toLog = {};
139
+ toLog[type] = data;
140
+ // tslint:disable-next-line:no-console
141
+ console.log(JSON.stringify(toLog, undefined, 2));
142
+ }
143
+ });
144
+ if (!requestOptions.headers) {
145
+ requestOptions.headers = {};
146
+ }
147
+ requestOptions.headers["x-aspose-client"] = "nodejs sdk v22.2.0";
148
+ if (confguration.timeout) {
149
+ requestOptions.headers["x-aspose-timeout"] = confguration.timeout;
150
+ }
151
+ for (var key in confguration.customHeaders) {
152
+ requestOptions.headers[key] = confguration.customHeaders[key];
153
+ }
154
+ if (!notApplyAuthToRequest) {
155
+ yield addAuthHeader(requestOptions, confguration);
156
+ }
157
+ return new Promise((resolve, reject) => {
158
+ const r = request(requestOptions, (error, response) => __awaiter(this, void 0, void 0, function* () {
159
+ if (error) {
160
+ reject(error);
161
+ }
162
+ else {
163
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
164
+ resolve(response);
165
+ }
166
+ else if (!notApplyAuthToRequest && response.statusCode === 401) {
167
+ yield requestToken(confguration);
168
+ reject(new NeedRepeatException());
169
+ }
170
+ else {
171
+ try {
172
+ if (response.statusCode == 400 && response.body && response.body.error && typeof response.body.error == "string") {
173
+ reject({ message: response.body.error, code: 401 });
174
+ }
175
+ else if (response.body && (response.body.length === undefined || response.body.length)) {
176
+ let bodyContent = response.body;
177
+ let bodyString = bodyContent;
178
+ if (bodyContent instanceof Buffer) {
179
+ bodyString = bodyContent.toString("utf8");
180
+ bodyContent = JSON.parse(bodyString);
181
+ }
182
+ let result = objectSerializer_1.ObjectSerializer.deserialize(bodyContent, "SlidesApiErrorResponse");
183
+ try {
184
+ result = JSON.parse(result);
185
+ }
186
+ catch (_a) {
187
+ //Error means the object is already deserialized
188
+ reject({ message: result.error ? result.error.message : bodyString, code: response.statusCode });
189
+ }
190
+ }
191
+ else {
192
+ reject({ message: response.statusMessage, code: response.statusCode });
193
+ }
194
+ }
195
+ catch (error) {
196
+ reject({ message: "Error while parse server error: " + error });
197
+ }
198
+ }
199
+ }
200
+ }));
201
+ r.writeDebugToConsole = confguration.debugMode;
202
+ });
203
+ });
204
+ }
205
+ function addAuthHeader(requestOptions, configuration) {
206
+ return __awaiter(this, void 0, void 0, function* () {
207
+ if (configuration.appSid || configuration.appKey) {
208
+ if (isRequestTokenPending) {
209
+ yield requestingToken;
210
+ }
211
+ if (!configuration.accessToken) {
212
+ isRequestTokenPending = true;
213
+ requestingToken = requestToken(configuration).catch((err) => { isRequestTokenPending = false; throw (err); });
214
+ yield requestingToken;
215
+ }
216
+ isRequestTokenPending = false;
217
+ if (requestOptions && requestOptions.headers) {
218
+ requestOptions.headers.Authorization = "Bearer " + configuration.accessToken;
219
+ }
220
+ }
221
+ return Promise.resolve();
222
+ });
223
+ }
224
+ function requestToken(configuration) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ const requestOptions = {
227
+ method: "POST",
228
+ json: true,
229
+ uri: configuration.authBaseUrl + "/connect/token",
230
+ form: {
231
+ grant_type: "client_credentials",
232
+ client_id: configuration.appSid,
233
+ client_secret: configuration.appKey,
234
+ },
235
+ };
236
+ const response = yield invokeApiMethod(requestOptions, configuration, true);
237
+ configuration.accessToken = response.body.access_token;
238
+ return Promise.resolve();
239
+ });
240
+ }
241
+ var requestingToken = null;
242
+ var isRequestTokenPending = false;
243
+ /**
244
+ * Exception, indicating necessity of request repeat
245
+ */
246
+ class NeedRepeatException extends Error {
247
+ }