asposeslidescloud 23.4.0 → 23.4.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.
- package/api.d.ts +3512 -3512
- package/api.js +11633 -11633
- package/internal/configuration.d.ts +48 -48
- package/internal/configuration.js +62 -62
- package/internal/objectSerializer.d.ts +18 -18
- package/internal/objectSerializer.js +185 -185
- package/internal/requestHelper.d.ts +32 -32
- package/internal/requestHelper.js +280 -277
- package/model.d.ts +8232 -8232
- package/model.js +4931 -4931
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { Configuration } from "./configuration";
|
|
2
|
-
export declare function checkMultipartContent(options: any, files: any): void;
|
|
3
|
-
/**
|
|
4
|
-
* Invoke api method
|
|
5
|
-
* @param requestOptions request parameters
|
|
6
|
-
* @param confguration api configuration
|
|
7
|
-
* @param notApplyAuthToRequest if setted to true, auth is not applied to request
|
|
8
|
-
*/
|
|
9
|
-
export declare function invokeApiMethod(requestOptions: any, confguration: Configuration, notApplyAuthToRequest?: boolean): Promise<any>;
|
|
10
|
-
/**
|
|
11
|
-
* Add parameter to query
|
|
12
|
-
* @param url url
|
|
13
|
-
* @param queryParameters queryParameters
|
|
14
|
-
* @param parameterName parameterName
|
|
15
|
-
* @param parameterValue parameterValue
|
|
16
|
-
*/
|
|
17
|
-
export declare function addQueryParameterToUrl(url: string, queryParameters: Array<string>, parameterName: string, parameterValue: any): string;
|
|
18
|
-
/**
|
|
19
|
-
* Add parameter to query
|
|
20
|
-
* @param url url
|
|
21
|
-
* @param queryParameters queryParameters
|
|
22
|
-
* @param parameterName parameterName
|
|
23
|
-
* @param parameterValue parameterValue
|
|
24
|
-
*/
|
|
25
|
-
export declare function addPathParameterToUrl(url: string, parameterName: string, parameterValue: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Add parameter to headers
|
|
28
|
-
* @param headers headers
|
|
29
|
-
* @param parameterName parameterName
|
|
30
|
-
* @param parameterValue parameterValue
|
|
31
|
-
*/
|
|
32
|
-
export declare function addHeaderParameter(headers: any, parameterName: string, parameterValue: any): void;
|
|
1
|
+
import { Configuration } from "./configuration";
|
|
2
|
+
export declare function checkMultipartContent(options: any, files: any): void;
|
|
3
|
+
/**
|
|
4
|
+
* Invoke api method
|
|
5
|
+
* @param requestOptions request parameters
|
|
6
|
+
* @param confguration api configuration
|
|
7
|
+
* @param notApplyAuthToRequest if setted to true, auth is not applied to request
|
|
8
|
+
*/
|
|
9
|
+
export declare function invokeApiMethod(requestOptions: any, confguration: Configuration, notApplyAuthToRequest?: boolean): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Add parameter to query
|
|
12
|
+
* @param url url
|
|
13
|
+
* @param queryParameters queryParameters
|
|
14
|
+
* @param parameterName parameterName
|
|
15
|
+
* @param parameterValue parameterValue
|
|
16
|
+
*/
|
|
17
|
+
export declare function addQueryParameterToUrl(url: string, queryParameters: Array<string>, parameterName: string, parameterValue: any): string;
|
|
18
|
+
/**
|
|
19
|
+
* Add parameter to query
|
|
20
|
+
* @param url url
|
|
21
|
+
* @param queryParameters queryParameters
|
|
22
|
+
* @param parameterName parameterName
|
|
23
|
+
* @param parameterValue parameterValue
|
|
24
|
+
*/
|
|
25
|
+
export declare function addPathParameterToUrl(url: string, parameterName: string, parameterValue: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Add parameter to headers
|
|
28
|
+
* @param headers headers
|
|
29
|
+
* @param parameterName parameterName
|
|
30
|
+
* @param parameterValue parameterValue
|
|
31
|
+
*/
|
|
32
|
+
export declare function addHeaderParameter(headers: any, parameterName: string, parameterValue: any): void;
|
|
@@ -1,277 +1,280 @@
|
|
|
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
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.addHeaderParameter = exports.addPathParameterToUrl = exports.addQueryParameterToUrl = exports.invokeApiMethod = exports.checkMultipartContent = void 0;
|
|
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
|
-
});
|
|
51
|
-
const objectSerializer_1 = require("./objectSerializer");
|
|
52
|
-
function checkMultipartContent(options, files) {
|
|
53
|
-
if (files && files.length) {
|
|
54
|
-
const data = {
|
|
55
|
-
pipeline: null,
|
|
56
|
-
attachments: []
|
|
57
|
-
};
|
|
58
|
-
if (options.data) {
|
|
59
|
-
data.pipeline = JSON.stringify(options.data);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
delete data.pipeline;
|
|
63
|
-
}
|
|
64
|
-
for (var i = 0; i < files.length; i++) {
|
|
65
|
-
data.attachments.push(files[i]);
|
|
66
|
-
}
|
|
67
|
-
options.data = data;
|
|
68
|
-
if (!options.headers) {
|
|
69
|
-
options.headers = {};
|
|
70
|
-
}
|
|
71
|
-
options.headers["Content-type"] = "multipart/form-data";
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.checkMultipartContent = checkMultipartContent;
|
|
75
|
-
/**
|
|
76
|
-
* Invoke api method
|
|
77
|
-
* @param requestOptions request parameters
|
|
78
|
-
* @param confguration api configuration
|
|
79
|
-
* @param notApplyAuthToRequest if setted to true, auth is not applied to request
|
|
80
|
-
*/
|
|
81
|
-
function invokeApiMethod(requestOptions, confguration, notApplyAuthToRequest) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
try {
|
|
84
|
-
return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
if (e instanceof NeedRepeatException) {
|
|
88
|
-
return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
|
|
89
|
-
}
|
|
90
|
-
throw e;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
exports.invokeApiMethod = invokeApiMethod;
|
|
95
|
-
/**
|
|
96
|
-
* Add parameter to query
|
|
97
|
-
* @param url url
|
|
98
|
-
* @param queryParameters queryParameters
|
|
99
|
-
* @param parameterName parameterName
|
|
100
|
-
* @param parameterValue parameterValue
|
|
101
|
-
*/
|
|
102
|
-
function addQueryParameterToUrl(url, queryParameters, parameterName, parameterValue) {
|
|
103
|
-
if (parameterValue !== undefined && parameterValue != null) {
|
|
104
|
-
if (Array.isArray(parameterValue)) {
|
|
105
|
-
parameterValue = parameterValue.join(",");
|
|
106
|
-
}
|
|
107
|
-
if (url.indexOf("{" + parameterName + "}") >= 0) {
|
|
108
|
-
url = url.replace("{" + parameterName + "}", String(parameterValue));
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
queryParameters[parameterName] = String(parameterValue);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
url = url.replace("/{" + parameterName + "}", "");
|
|
116
|
-
}
|
|
117
|
-
return url;
|
|
118
|
-
}
|
|
119
|
-
exports.addQueryParameterToUrl = addQueryParameterToUrl;
|
|
120
|
-
/**
|
|
121
|
-
* Add parameter to query
|
|
122
|
-
* @param url url
|
|
123
|
-
* @param queryParameters queryParameters
|
|
124
|
-
* @param parameterName parameterName
|
|
125
|
-
* @param parameterValue parameterValue
|
|
126
|
-
*/
|
|
127
|
-
function addPathParameterToUrl(url, parameterName, parameterValue) {
|
|
128
|
-
if (!parameterValue) {
|
|
129
|
-
return url.replace("/{" + parameterName + "}", "");
|
|
130
|
-
}
|
|
131
|
-
return url.replace("{" + parameterName + "}", parameterValue);
|
|
132
|
-
}
|
|
133
|
-
exports.addPathParameterToUrl = addPathParameterToUrl;
|
|
134
|
-
/**
|
|
135
|
-
* Add parameter to headers
|
|
136
|
-
* @param headers headers
|
|
137
|
-
* @param parameterName parameterName
|
|
138
|
-
* @param parameterValue parameterValue
|
|
139
|
-
*/
|
|
140
|
-
function addHeaderParameter(headers, parameterName, parameterValue) {
|
|
141
|
-
if (parameterValue) {
|
|
142
|
-
headers[parameterName] = String(parameterValue);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.addHeaderParameter = addHeaderParameter;
|
|
146
|
-
/**
|
|
147
|
-
* Invoke api method
|
|
148
|
-
* @param requestOptions request parameters
|
|
149
|
-
* @param configuration api configuration
|
|
150
|
-
* @param notApplyAuthToRequest if setted to true, auth is not applied to request
|
|
151
|
-
*/
|
|
152
|
-
function invokeApiMethodInternal(requestOptions, configuration, notApplyAuthToRequest) {
|
|
153
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
if (configuration.allowInsecureRequests) {
|
|
155
|
-
requestOptions.rejectUnauthorized = false;
|
|
156
|
-
}
|
|
157
|
-
if (!requestOptions.headers) {
|
|
158
|
-
requestOptions.headers = {};
|
|
159
|
-
}
|
|
160
|
-
requestOptions.headers["x-aspose-client"] = "nodejs sdk v23.4.0";
|
|
161
|
-
if (configuration.timeout) {
|
|
162
|
-
requestOptions.headers["x-aspose-timeout"] = configuration.timeout;
|
|
163
|
-
}
|
|
164
|
-
for (var key in configuration.customHeaders) {
|
|
165
|
-
requestOptions.headers[key] = configuration.customHeaders[key];
|
|
166
|
-
}
|
|
167
|
-
if (!notApplyAuthToRequest) {
|
|
168
|
-
yield addAuthHeader(requestOptions, configuration);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
requestOptions.headers["Content-type"] = "application/x-www-form-urlencoded";
|
|
172
|
-
}
|
|
173
|
-
requestOptions.debug = configuration.debugMode;
|
|
174
|
-
return new Promise((resolve, reject) => {
|
|
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);
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
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);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.addHeaderParameter = exports.addPathParameterToUrl = exports.addQueryParameterToUrl = exports.invokeApiMethod = exports.checkMultipartContent = void 0;
|
|
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
|
+
});
|
|
51
|
+
const objectSerializer_1 = require("./objectSerializer");
|
|
52
|
+
function checkMultipartContent(options, files) {
|
|
53
|
+
if (files && files.length) {
|
|
54
|
+
const data = {
|
|
55
|
+
pipeline: null,
|
|
56
|
+
attachments: []
|
|
57
|
+
};
|
|
58
|
+
if (options.data) {
|
|
59
|
+
data.pipeline = JSON.stringify(options.data);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
delete data.pipeline;
|
|
63
|
+
}
|
|
64
|
+
for (var i = 0; i < files.length; i++) {
|
|
65
|
+
data.attachments.push(files[i]);
|
|
66
|
+
}
|
|
67
|
+
options.data = data;
|
|
68
|
+
if (!options.headers) {
|
|
69
|
+
options.headers = {};
|
|
70
|
+
}
|
|
71
|
+
options.headers["Content-type"] = "multipart/form-data";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.checkMultipartContent = checkMultipartContent;
|
|
75
|
+
/**
|
|
76
|
+
* Invoke api method
|
|
77
|
+
* @param requestOptions request parameters
|
|
78
|
+
* @param confguration api configuration
|
|
79
|
+
* @param notApplyAuthToRequest if setted to true, auth is not applied to request
|
|
80
|
+
*/
|
|
81
|
+
function invokeApiMethod(requestOptions, confguration, notApplyAuthToRequest) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
try {
|
|
84
|
+
return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
if (e instanceof NeedRepeatException) {
|
|
88
|
+
return yield invokeApiMethodInternal(requestOptions, confguration, notApplyAuthToRequest);
|
|
89
|
+
}
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.invokeApiMethod = invokeApiMethod;
|
|
95
|
+
/**
|
|
96
|
+
* Add parameter to query
|
|
97
|
+
* @param url url
|
|
98
|
+
* @param queryParameters queryParameters
|
|
99
|
+
* @param parameterName parameterName
|
|
100
|
+
* @param parameterValue parameterValue
|
|
101
|
+
*/
|
|
102
|
+
function addQueryParameterToUrl(url, queryParameters, parameterName, parameterValue) {
|
|
103
|
+
if (parameterValue !== undefined && parameterValue != null) {
|
|
104
|
+
if (Array.isArray(parameterValue)) {
|
|
105
|
+
parameterValue = parameterValue.join(",");
|
|
106
|
+
}
|
|
107
|
+
if (url.indexOf("{" + parameterName + "}") >= 0) {
|
|
108
|
+
url = url.replace("{" + parameterName + "}", String(parameterValue));
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
queryParameters[parameterName] = String(parameterValue);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
url = url.replace("/{" + parameterName + "}", "");
|
|
116
|
+
}
|
|
117
|
+
return url;
|
|
118
|
+
}
|
|
119
|
+
exports.addQueryParameterToUrl = addQueryParameterToUrl;
|
|
120
|
+
/**
|
|
121
|
+
* Add parameter to query
|
|
122
|
+
* @param url url
|
|
123
|
+
* @param queryParameters queryParameters
|
|
124
|
+
* @param parameterName parameterName
|
|
125
|
+
* @param parameterValue parameterValue
|
|
126
|
+
*/
|
|
127
|
+
function addPathParameterToUrl(url, parameterName, parameterValue) {
|
|
128
|
+
if (!parameterValue) {
|
|
129
|
+
return url.replace("/{" + parameterName + "}", "");
|
|
130
|
+
}
|
|
131
|
+
return url.replace("{" + parameterName + "}", parameterValue);
|
|
132
|
+
}
|
|
133
|
+
exports.addPathParameterToUrl = addPathParameterToUrl;
|
|
134
|
+
/**
|
|
135
|
+
* Add parameter to headers
|
|
136
|
+
* @param headers headers
|
|
137
|
+
* @param parameterName parameterName
|
|
138
|
+
* @param parameterValue parameterValue
|
|
139
|
+
*/
|
|
140
|
+
function addHeaderParameter(headers, parameterName, parameterValue) {
|
|
141
|
+
if (parameterValue) {
|
|
142
|
+
headers[parameterName] = String(parameterValue);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.addHeaderParameter = addHeaderParameter;
|
|
146
|
+
/**
|
|
147
|
+
* Invoke api method
|
|
148
|
+
* @param requestOptions request parameters
|
|
149
|
+
* @param configuration api configuration
|
|
150
|
+
* @param notApplyAuthToRequest if setted to true, auth is not applied to request
|
|
151
|
+
*/
|
|
152
|
+
function invokeApiMethodInternal(requestOptions, configuration, notApplyAuthToRequest) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
if (configuration.allowInsecureRequests) {
|
|
155
|
+
requestOptions.rejectUnauthorized = false;
|
|
156
|
+
}
|
|
157
|
+
if (!requestOptions.headers) {
|
|
158
|
+
requestOptions.headers = {};
|
|
159
|
+
}
|
|
160
|
+
requestOptions.headers["x-aspose-client"] = "nodejs sdk v23.4.0";
|
|
161
|
+
if (configuration.timeout) {
|
|
162
|
+
requestOptions.headers["x-aspose-timeout"] = configuration.timeout;
|
|
163
|
+
}
|
|
164
|
+
for (var key in configuration.customHeaders) {
|
|
165
|
+
requestOptions.headers[key] = configuration.customHeaders[key];
|
|
166
|
+
}
|
|
167
|
+
if (!notApplyAuthToRequest) {
|
|
168
|
+
yield addAuthHeader(requestOptions, configuration);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
requestOptions.headers["Content-type"] = "application/x-www-form-urlencoded";
|
|
172
|
+
}
|
|
173
|
+
requestOptions.debug = configuration.debugMode;
|
|
174
|
+
return new Promise((resolve, reject) => {
|
|
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);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
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);
|
|
192
|
+
}
|
|
193
|
+
else if (error.request && error.request.res) {
|
|
194
|
+
yield rejectResponse(reject, error.request.res, configuration, notApplyAuthToRequest);
|
|
195
|
+
}
|
|
196
|
+
reject(error);
|
|
197
|
+
}));
|
|
198
|
+
r.writeDebugToConsole = configuration.debugMode;
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function addAuthHeader(requestOptions, configuration) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
if (configuration.appSid || configuration.appKey) {
|
|
205
|
+
if (isRequestTokenPending) {
|
|
206
|
+
yield requestingToken;
|
|
207
|
+
}
|
|
208
|
+
if (!configuration.accessToken) {
|
|
209
|
+
isRequestTokenPending = true;
|
|
210
|
+
requestingToken = requestToken(configuration).catch((err) => { isRequestTokenPending = false; throw (err); });
|
|
211
|
+
yield requestingToken;
|
|
212
|
+
}
|
|
213
|
+
isRequestTokenPending = false;
|
|
214
|
+
if (requestOptions && requestOptions.headers) {
|
|
215
|
+
requestOptions.headers.Authorization = "Bearer " + configuration.accessToken;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return Promise.resolve();
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function requestToken(configuration) {
|
|
222
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
const requestOptions = {
|
|
224
|
+
method: "POST",
|
|
225
|
+
url: configuration.authBaseUrl + "/connect/token",
|
|
226
|
+
data: {
|
|
227
|
+
grant_type: "client_credentials",
|
|
228
|
+
client_id: configuration.appSid,
|
|
229
|
+
client_secret: configuration.appKey,
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const response = yield invokeApiMethod(requestOptions, configuration, true);
|
|
233
|
+
configuration.accessToken = response.body.access_token;
|
|
234
|
+
return Promise.resolve();
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function rejectResponse(reject, response, configuration, notApplyAuthToRequest) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
if (!notApplyAuthToRequest && response.statusCode === 401) {
|
|
240
|
+
yield requestToken(configuration);
|
|
241
|
+
reject(new NeedRepeatException());
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
try {
|
|
245
|
+
if (response.statusCode == 400 && response.body && response.body.error && typeof response.body.error == "string") {
|
|
246
|
+
reject({ message: response.body.error, code: 401 });
|
|
247
|
+
}
|
|
248
|
+
else if (response.body && (response.body.length === undefined || response.body.length)) {
|
|
249
|
+
let bodyContent = response.body;
|
|
250
|
+
let bodyString = bodyContent;
|
|
251
|
+
if (bodyContent instanceof Buffer) {
|
|
252
|
+
bodyString = bodyContent.toString("utf8");
|
|
253
|
+
bodyContent = JSON.parse(bodyString);
|
|
254
|
+
}
|
|
255
|
+
let result = objectSerializer_1.ObjectSerializer.deserialize(bodyContent, "SlidesApiErrorResponse");
|
|
256
|
+
try {
|
|
257
|
+
result = JSON.parse(result);
|
|
258
|
+
}
|
|
259
|
+
catch (_a) {
|
|
260
|
+
//Error means the object is already deserialized
|
|
261
|
+
reject({ message: result.error ? result.error.message : bodyString, code: response.statusCode });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
reject({ message: response.statusMessage, code: response.statusCode });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
reject({ message: "Error while parse server error: " + error });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
var requestingToken = null;
|
|
275
|
+
var isRequestTokenPending = false;
|
|
276
|
+
/**
|
|
277
|
+
* Exception, indicating necessity of request repeat
|
|
278
|
+
*/
|
|
279
|
+
class NeedRepeatException extends Error {
|
|
280
|
+
}
|