mailgun.js 12.0.3 → 12.1.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.
- package/AMD/definitions.amd.js +1 -1
- package/AMD/mailgun.amd.js +2 -2
- package/CHANGELOG.md +26 -0
- package/CJS/definitions.cjs +1 -1
- package/CJS/mailgun.node.cjs +2 -2
- package/ESM/definitions.browser.js +1 -1
- package/ESM/definitions.node.js +1 -1
- package/ESM/mailgun.browser.js +2 -2
- package/ESM/mailgun.node.js +2 -2
- package/README.md +77 -51
- package/Types/Classes/common/Error.d.ts +1 -0
- package/Types/Classes/common/FormDataBuilder.d.ts +4 -4
- package/Types/Classes/common/Request.d.ts +13 -18
- package/Types/Classes/common/RequestProviders/AxiosProvider.d.ts +20 -0
- package/Types/Interfaces/Common/RequestProviders/RequestProvider.d.ts +6 -0
- package/Types/Interfaces/Common/index.d.ts +1 -0
- package/Types/Interfaces/Domains/DomainTemplates.d.ts +1 -1
- package/Types/Types/Common/FormData.d.ts +7 -0
- package/Types/Types/Common/RequestOptions.d.ts +49 -5
- package/Types/Types/Common/RequestProvider.d.ts +30 -0
- package/Types/Types/Common/index.d.ts +1 -0
- package/Types/Types/Domains/Domains.d.ts +4 -0
- package/Types/Types/MailgunClient/MailgunClientOptions.d.ts +3 -2
- package/Types/index.js +1100 -850
- package/package.json +2 -2
- package/version.md +1 -1
package/Types/index.js
CHANGED
|
@@ -99,178 +99,6 @@ function getDefaultExportFromCjs (x) {
|
|
|
99
99
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
var base64$1 = {exports: {}};
|
|
103
|
-
|
|
104
|
-
/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */
|
|
105
|
-
var base64 = base64$1.exports;
|
|
106
|
-
|
|
107
|
-
var hasRequiredBase64;
|
|
108
|
-
|
|
109
|
-
function requireBase64 () {
|
|
110
|
-
if (hasRequiredBase64) return base64$1.exports;
|
|
111
|
-
hasRequiredBase64 = 1;
|
|
112
|
-
(function (module, exports) {
|
|
113
|
-
(function(root) {
|
|
114
|
-
|
|
115
|
-
// Detect free variables `exports`.
|
|
116
|
-
var freeExports = exports;
|
|
117
|
-
|
|
118
|
-
// Detect free variable `module`.
|
|
119
|
-
var freeModule = module &&
|
|
120
|
-
module.exports == freeExports && module;
|
|
121
|
-
|
|
122
|
-
// Detect free variable `global`, from Node.js or Browserified code, and use
|
|
123
|
-
// it as `root`.
|
|
124
|
-
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
|
|
125
|
-
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
|
126
|
-
root = freeGlobal;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/*--------------------------------------------------------------------------*/
|
|
130
|
-
|
|
131
|
-
var InvalidCharacterError = function(message) {
|
|
132
|
-
this.message = message;
|
|
133
|
-
};
|
|
134
|
-
InvalidCharacterError.prototype = new Error;
|
|
135
|
-
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
|
136
|
-
|
|
137
|
-
var error = function(message) {
|
|
138
|
-
// Note: the error messages used throughout this file match those used by
|
|
139
|
-
// the native `atob`/`btoa` implementation in Chromium.
|
|
140
|
-
throw new InvalidCharacterError(message);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
144
|
-
// http://whatwg.org/html/common-microsyntaxes.html#space-character
|
|
145
|
-
var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
|
|
146
|
-
|
|
147
|
-
// `decode` is designed to be fully compatible with `atob` as described in the
|
|
148
|
-
// HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
|
|
149
|
-
// The optimized base64-decoding algorithm used is based on @atk’s excellent
|
|
150
|
-
// implementation. https://gist.github.com/atk/1020396
|
|
151
|
-
var decode = function(input) {
|
|
152
|
-
input = String(input)
|
|
153
|
-
.replace(REGEX_SPACE_CHARACTERS, '');
|
|
154
|
-
var length = input.length;
|
|
155
|
-
if (length % 4 == 0) {
|
|
156
|
-
input = input.replace(/==?$/, '');
|
|
157
|
-
length = input.length;
|
|
158
|
-
}
|
|
159
|
-
if (
|
|
160
|
-
length % 4 == 1 ||
|
|
161
|
-
// http://whatwg.org/C#alphanumeric-ascii-characters
|
|
162
|
-
/[^+a-zA-Z0-9/]/.test(input)
|
|
163
|
-
) {
|
|
164
|
-
error(
|
|
165
|
-
'Invalid character: the string to be decoded is not correctly encoded.'
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
var bitCounter = 0;
|
|
169
|
-
var bitStorage;
|
|
170
|
-
var buffer;
|
|
171
|
-
var output = '';
|
|
172
|
-
var position = -1;
|
|
173
|
-
while (++position < length) {
|
|
174
|
-
buffer = TABLE.indexOf(input.charAt(position));
|
|
175
|
-
bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
|
|
176
|
-
// Unless this is the first of a group of 4 characters…
|
|
177
|
-
if (bitCounter++ % 4) {
|
|
178
|
-
// …convert the first 8 bits to a single ASCII character.
|
|
179
|
-
output += String.fromCharCode(
|
|
180
|
-
0xFF & bitStorage >> (-2 * bitCounter & 6)
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return output;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// `encode` is designed to be fully compatible with `btoa` as described in the
|
|
188
|
-
// HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
|
|
189
|
-
var encode = function(input) {
|
|
190
|
-
input = String(input);
|
|
191
|
-
if (/[^\0-\xFF]/.test(input)) {
|
|
192
|
-
// Note: no need to special-case astral symbols here, as surrogates are
|
|
193
|
-
// matched, and the input is supposed to only contain ASCII anyway.
|
|
194
|
-
error(
|
|
195
|
-
'The string to be encoded contains characters outside of the ' +
|
|
196
|
-
'Latin1 range.'
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
var padding = input.length % 3;
|
|
200
|
-
var output = '';
|
|
201
|
-
var position = -1;
|
|
202
|
-
var a;
|
|
203
|
-
var b;
|
|
204
|
-
var c;
|
|
205
|
-
var buffer;
|
|
206
|
-
// Make sure any padding is handled outside of the loop.
|
|
207
|
-
var length = input.length - padding;
|
|
208
|
-
|
|
209
|
-
while (++position < length) {
|
|
210
|
-
// Read three bytes, i.e. 24 bits.
|
|
211
|
-
a = input.charCodeAt(position) << 16;
|
|
212
|
-
b = input.charCodeAt(++position) << 8;
|
|
213
|
-
c = input.charCodeAt(++position);
|
|
214
|
-
buffer = a + b + c;
|
|
215
|
-
// Turn the 24 bits into four chunks of 6 bits each, and append the
|
|
216
|
-
// matching character for each of them to the output.
|
|
217
|
-
output += (
|
|
218
|
-
TABLE.charAt(buffer >> 18 & 0x3F) +
|
|
219
|
-
TABLE.charAt(buffer >> 12 & 0x3F) +
|
|
220
|
-
TABLE.charAt(buffer >> 6 & 0x3F) +
|
|
221
|
-
TABLE.charAt(buffer & 0x3F)
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (padding == 2) {
|
|
226
|
-
a = input.charCodeAt(position) << 8;
|
|
227
|
-
b = input.charCodeAt(++position);
|
|
228
|
-
buffer = a + b;
|
|
229
|
-
output += (
|
|
230
|
-
TABLE.charAt(buffer >> 10) +
|
|
231
|
-
TABLE.charAt((buffer >> 4) & 0x3F) +
|
|
232
|
-
TABLE.charAt((buffer << 2) & 0x3F) +
|
|
233
|
-
'='
|
|
234
|
-
);
|
|
235
|
-
} else if (padding == 1) {
|
|
236
|
-
buffer = input.charCodeAt(position);
|
|
237
|
-
output += (
|
|
238
|
-
TABLE.charAt(buffer >> 2) +
|
|
239
|
-
TABLE.charAt((buffer << 4) & 0x3F) +
|
|
240
|
-
'=='
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return output;
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
var base64 = {
|
|
248
|
-
'encode': encode,
|
|
249
|
-
'decode': decode,
|
|
250
|
-
'version': '1.0.0'
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
|
254
|
-
// like the following:
|
|
255
|
-
if (freeExports && !freeExports.nodeType) {
|
|
256
|
-
if (freeModule) { // in Node.js or RingoJS v0.8.0+
|
|
257
|
-
freeModule.exports = base64;
|
|
258
|
-
} else { // in Narwhal or RingoJS v0.7.0-
|
|
259
|
-
for (var key in base64) {
|
|
260
|
-
base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
} else { // in Rhino or a web browser
|
|
264
|
-
root.base64 = base64;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
}(base64));
|
|
268
|
-
} (base64$1, base64$1.exports));
|
|
269
|
-
return base64$1.exports;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
var base64Exports = requireBase64();
|
|
273
|
-
|
|
274
102
|
var urlJoin$1 = {exports: {}};
|
|
275
103
|
|
|
276
104
|
var urlJoin = urlJoin$1.exports;
|
|
@@ -365,58 +193,376 @@ function requireUrlJoin () {
|
|
|
365
193
|
var urlJoinExports = requireUrlJoin();
|
|
366
194
|
var urljoin = /*@__PURE__*/getDefaultExportFromCjs(urlJoinExports);
|
|
367
195
|
|
|
368
|
-
function
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
* @param {*} val The value to test
|
|
405
|
-
*
|
|
406
|
-
* @returns {boolean} True if the value is undefined, otherwise false
|
|
407
|
-
*/
|
|
408
|
-
const isUndefined = typeOfTest('undefined');
|
|
196
|
+
var APIError = /** @class */ (function (_super) {
|
|
197
|
+
__extends(APIError, _super);
|
|
198
|
+
function APIError(_a) {
|
|
199
|
+
var status = _a.status, statusText = _a.statusText, message = _a.message, _b = _a.body, body = _b === void 0 ? {} : _b;
|
|
200
|
+
var _this = this;
|
|
201
|
+
var bodyMessage = '';
|
|
202
|
+
var error = '';
|
|
203
|
+
if (typeof body === 'string') {
|
|
204
|
+
bodyMessage = body;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
bodyMessage = (body === null || body === void 0 ? void 0 : body.message) || '';
|
|
208
|
+
error = (body === null || body === void 0 ? void 0 : body.error) || '';
|
|
209
|
+
}
|
|
210
|
+
_this = _super.call(this) || this;
|
|
211
|
+
_this.stack = '';
|
|
212
|
+
_this.status = status;
|
|
213
|
+
_this.message = message || error || statusText || '';
|
|
214
|
+
_this.details = bodyMessage;
|
|
215
|
+
_this.type = 'MailgunAPIError';
|
|
216
|
+
return _this;
|
|
217
|
+
}
|
|
218
|
+
APIError.isApiError = function (err) {
|
|
219
|
+
return typeof err === 'object' && (err === null || err === void 0 ? void 0 : err.type) === 'MailgunAPIError';
|
|
220
|
+
};
|
|
221
|
+
APIError.getUserDataError = function (statusText, message) {
|
|
222
|
+
return new this({
|
|
223
|
+
status: 400,
|
|
224
|
+
statusText: statusText,
|
|
225
|
+
body: {
|
|
226
|
+
message: message
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
return APIError;
|
|
231
|
+
}(Error));
|
|
409
232
|
|
|
410
|
-
/**
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
233
|
+
var BlobFromStream = /** @class */ (function () {
|
|
234
|
+
function BlobFromStream(stream, size) {
|
|
235
|
+
this._stream = stream;
|
|
236
|
+
this.size = size;
|
|
237
|
+
}
|
|
238
|
+
BlobFromStream.prototype.stream = function () {
|
|
239
|
+
return this._stream;
|
|
240
|
+
};
|
|
241
|
+
Object.defineProperty(BlobFromStream.prototype, Symbol.toStringTag, {
|
|
242
|
+
get: function () {
|
|
243
|
+
return 'Blob';
|
|
244
|
+
},
|
|
245
|
+
enumerable: false,
|
|
246
|
+
configurable: true
|
|
247
|
+
});
|
|
248
|
+
return BlobFromStream;
|
|
249
|
+
}());
|
|
250
|
+
var AttachmentsHandler = /** @class */ (function () {
|
|
251
|
+
function AttachmentsHandler() {
|
|
252
|
+
}
|
|
253
|
+
AttachmentsHandler.prototype.getAttachmentOptions = function (item) {
|
|
254
|
+
var filename = item.filename, contentType = item.contentType, knownLength = item.knownLength;
|
|
255
|
+
return __assign(__assign(__assign({}, (filename ? { filename: filename } : { filename: 'file' })), (contentType && { contentType: contentType })), (knownLength && { knownLength: knownLength }));
|
|
256
|
+
};
|
|
257
|
+
AttachmentsHandler.prototype.getFileInfo = function (file) {
|
|
258
|
+
var filename = file.name, contentType = file.type, knownLength = file.size;
|
|
259
|
+
return this.getAttachmentOptions({ filename: filename, contentType: contentType, knownLength: knownLength });
|
|
260
|
+
};
|
|
261
|
+
AttachmentsHandler.prototype.getCustomFileInfo = function (file) {
|
|
262
|
+
var filename = file.filename, contentType = file.contentType, knownLength = file.knownLength;
|
|
263
|
+
return this.getAttachmentOptions({ filename: filename, contentType: contentType, knownLength: knownLength });
|
|
264
|
+
};
|
|
265
|
+
AttachmentsHandler.prototype.getBufferInfo = function (buffer) {
|
|
266
|
+
var knownLength = buffer.byteLength;
|
|
267
|
+
return this.getAttachmentOptions({ filename: 'file', contentType: '', knownLength: knownLength });
|
|
268
|
+
};
|
|
269
|
+
AttachmentsHandler.prototype.isStream = function (data) {
|
|
270
|
+
return typeof data === 'object' && typeof data.pipe === 'function';
|
|
271
|
+
};
|
|
272
|
+
AttachmentsHandler.prototype.isCustomFile = function (obj) {
|
|
273
|
+
return typeof obj === 'object'
|
|
274
|
+
&& !!obj.data;
|
|
275
|
+
};
|
|
276
|
+
AttachmentsHandler.prototype.isBrowserFile = function (obj) {
|
|
277
|
+
return typeof obj === 'object' && (!!obj.name || (typeof Blob !== 'undefined' && obj instanceof Blob));
|
|
278
|
+
};
|
|
279
|
+
AttachmentsHandler.prototype.isBuffer = function (data) {
|
|
280
|
+
return typeof Buffer !== 'undefined' && Buffer.isBuffer(data);
|
|
281
|
+
};
|
|
282
|
+
AttachmentsHandler.prototype.getAttachmentInfo = function (attachment) {
|
|
283
|
+
var isBrowserFile = this.isBrowserFile(attachment);
|
|
284
|
+
var isCustomFile = this.isCustomFile(attachment);
|
|
285
|
+
var isString = typeof attachment === 'string';
|
|
286
|
+
if (!isString) {
|
|
287
|
+
if (isBrowserFile) {
|
|
288
|
+
return this.getFileInfo(attachment);
|
|
289
|
+
}
|
|
290
|
+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(attachment)) {
|
|
291
|
+
return this.getBufferInfo(attachment);
|
|
292
|
+
}
|
|
293
|
+
if (isCustomFile) {
|
|
294
|
+
return this.getCustomFileInfo(attachment);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
var options = {
|
|
298
|
+
filename: 'file',
|
|
299
|
+
contentType: undefined,
|
|
300
|
+
knownLength: undefined
|
|
301
|
+
};
|
|
302
|
+
return options;
|
|
303
|
+
};
|
|
304
|
+
AttachmentsHandler.prototype.convertToFDexpectedShape = function (userProvidedValue) {
|
|
305
|
+
var isStream = this.isStream(userProvidedValue);
|
|
306
|
+
var isBrowserFile = this.isBrowserFile(userProvidedValue);
|
|
307
|
+
var isCustomFile = this.isCustomFile(userProvidedValue);
|
|
308
|
+
var isString = typeof userProvidedValue === 'string';
|
|
309
|
+
var result;
|
|
310
|
+
if (isStream || isString || isBrowserFile || this.isBuffer(userProvidedValue)) {
|
|
311
|
+
result = userProvidedValue;
|
|
312
|
+
}
|
|
313
|
+
else if (isCustomFile) {
|
|
314
|
+
result = userProvidedValue.data;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
throw APIError.getUserDataError("Unknown attachment type ".concat(typeof userProvidedValue), "The \"attachment\" property expects either Buffer, Blob, or String.\n Also, It is possible to provide an object that has the property \"data\" with a value that is equal to one of the types counted before.\n Additionally, you may use an array to send more than one attachment.");
|
|
318
|
+
}
|
|
319
|
+
return result;
|
|
320
|
+
};
|
|
321
|
+
AttachmentsHandler.prototype.getBlobFromStream = function (stream, size) {
|
|
322
|
+
return new BlobFromStream(stream, size);
|
|
323
|
+
};
|
|
324
|
+
return AttachmentsHandler;
|
|
325
|
+
}());
|
|
326
|
+
|
|
327
|
+
var FormDataBuilder = /** @class */ (function () {
|
|
328
|
+
function FormDataBuilder(FormDataConstructor, config) {
|
|
329
|
+
this.FormDataConstructor = FormDataConstructor;
|
|
330
|
+
this.fileKeys = ['attachment', 'inline', 'multipleValidationFile'];
|
|
331
|
+
this.attachmentsHandler = new AttachmentsHandler();
|
|
332
|
+
this.useFetch = config === null || config === void 0 ? void 0 : config.useFetch;
|
|
333
|
+
}
|
|
334
|
+
FormDataBuilder.prototype.createFormData = function (data) {
|
|
335
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
+
var formDataInstance, isFormDataP, formData, result, resObj, blob;
|
|
337
|
+
var _this = this;
|
|
338
|
+
return __generator(this, function (_a) {
|
|
339
|
+
switch (_a.label) {
|
|
340
|
+
case 0:
|
|
341
|
+
if (!data) {
|
|
342
|
+
throw new Error('Please provide data object');
|
|
343
|
+
}
|
|
344
|
+
formDataInstance = new this.FormDataConstructor();
|
|
345
|
+
isFormDataP = this.isFormDataPackage(formDataInstance);
|
|
346
|
+
if (isFormDataP && this.useFetch) {
|
|
347
|
+
// in case form-data package is used fetch client thinks form-data is of the string type
|
|
348
|
+
// also Content-Type is recognized incorrectly
|
|
349
|
+
throw APIError.getUserDataError('"form-data" npm package detected, and it can not be used together with "fetch" client', 'fetch client does not recognize object created by form-data package as valid FormData instance');
|
|
350
|
+
}
|
|
351
|
+
formData = Object.keys(data)
|
|
352
|
+
.filter(function (key) { return data[key]; })
|
|
353
|
+
.reduce(function (formDataAcc, key) {
|
|
354
|
+
if (_this.fileKeys.includes(key)) {
|
|
355
|
+
var attachmentValue = data[key];
|
|
356
|
+
if (_this.isMessageAttachment(attachmentValue)) {
|
|
357
|
+
_this.addFilesToFD(key, attachmentValue, formDataAcc);
|
|
358
|
+
return formDataAcc;
|
|
359
|
+
}
|
|
360
|
+
throw APIError.getUserDataError("Unknown value ".concat(data[key], " with type ").concat(typeof data[key], " for property \"").concat(key, "\""), "The key \"".concat(key, "\" should have type of Buffer, Stream, File, or String "));
|
|
361
|
+
}
|
|
362
|
+
if (key === 'message') { // mime message
|
|
363
|
+
var messageValue = data[key];
|
|
364
|
+
if (!messageValue || !_this.isMIME(messageValue)) {
|
|
365
|
+
throw APIError.getUserDataError("Unknown data type for \"".concat(key, "\" property"), 'The mime data should have type of Buffer, String or Blob');
|
|
366
|
+
}
|
|
367
|
+
_this.addMimeDataToFD(key, messageValue, formDataAcc);
|
|
368
|
+
return formDataAcc;
|
|
369
|
+
}
|
|
370
|
+
_this.addCommonPropertyToFD(key, data[key], formDataAcc);
|
|
371
|
+
return formDataAcc;
|
|
372
|
+
}, formDataInstance);
|
|
373
|
+
result = {
|
|
374
|
+
formData: formData,
|
|
375
|
+
dataSize: 0
|
|
376
|
+
};
|
|
377
|
+
if (!(this.useFetch && !isFormDataP)) return [3 /*break*/, 2];
|
|
378
|
+
// axios trick to get correct Content-Type with boundary
|
|
379
|
+
// otherwise boundary is missing and request fails
|
|
380
|
+
Object.defineProperty(formData, 'getHeaders', {
|
|
381
|
+
value: function () { return ({ 'Content-Type': undefined }); },
|
|
382
|
+
});
|
|
383
|
+
if (!(Response !== undefined)) return [3 /*break*/, 2];
|
|
384
|
+
resObj = new Response(formData);
|
|
385
|
+
return [4 /*yield*/, resObj.blob()];
|
|
386
|
+
case 1:
|
|
387
|
+
blob = _a.sent();
|
|
388
|
+
result.dataSize = blob.size;
|
|
389
|
+
_a.label = 2;
|
|
390
|
+
case 2: return [2 /*return*/, result];
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
FormDataBuilder.prototype.addMimeDataToFD = function (key, data, formDataInstance) {
|
|
396
|
+
if (typeof data === 'string') { // if string only two parameters should be used.
|
|
397
|
+
formDataInstance.append(key, data);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (this.isFormDataPackage(formDataInstance)) { // form-data package is used
|
|
401
|
+
var nodeFormData = formDataInstance;
|
|
402
|
+
nodeFormData.append(key, data, { filename: 'MimeMessage' });
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (typeof Blob !== undefined) { // either node > 18 or browser
|
|
406
|
+
var browserFormData = formDataInstance; // Browser compliant FormData
|
|
407
|
+
if (data instanceof Blob) {
|
|
408
|
+
browserFormData.append(key, data, 'MimeMessage');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (this.attachmentsHandler.isBuffer(data)) { // node environment
|
|
412
|
+
var blobInstance = new Blob([data]);
|
|
413
|
+
browserFormData.append(key, blobInstance, 'MimeMessage');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
FormDataBuilder.prototype.isMIME = function (data) {
|
|
418
|
+
return typeof data === 'string'
|
|
419
|
+
|| (typeof Blob !== 'undefined' && data instanceof Blob)
|
|
420
|
+
|| this.attachmentsHandler.isBuffer(data)
|
|
421
|
+
|| (typeof ReadableStream !== 'undefined' && data instanceof ReadableStream);
|
|
422
|
+
};
|
|
423
|
+
FormDataBuilder.prototype.isFormDataPackage = function (obj) {
|
|
424
|
+
return typeof obj === 'object'
|
|
425
|
+
&& obj !== null
|
|
426
|
+
&& typeof obj.getHeaders === 'function';
|
|
427
|
+
};
|
|
428
|
+
FormDataBuilder.prototype.isMessageAttachment = function (value) {
|
|
429
|
+
var _this = this;
|
|
430
|
+
return (this.attachmentsHandler.isCustomFile(value)
|
|
431
|
+
|| typeof value === 'string'
|
|
432
|
+
|| (typeof File !== 'undefined' && value instanceof File)
|
|
433
|
+
|| (typeof Blob !== 'undefined' && value instanceof Blob)
|
|
434
|
+
|| this.attachmentsHandler.isBuffer(value)
|
|
435
|
+
|| this.attachmentsHandler.isStream(value)
|
|
436
|
+
|| (Array.isArray(value) && value.every(function (item) { return _this.attachmentsHandler.isCustomFile(item)
|
|
437
|
+
|| (typeof File !== 'undefined' && item instanceof File)
|
|
438
|
+
|| (typeof Blob !== 'undefined' && value instanceof Blob)
|
|
439
|
+
|| _this.attachmentsHandler.isBuffer(item)
|
|
440
|
+
|| _this.attachmentsHandler.isStream(item); })));
|
|
441
|
+
};
|
|
442
|
+
FormDataBuilder.prototype.addFilesToFD = function (propertyName, value, formDataInstance) {
|
|
443
|
+
var _this = this;
|
|
444
|
+
var appendFileToFD = function (originalKey, attachment, formData) {
|
|
445
|
+
var key = originalKey === 'multipleValidationFile' ? 'file' : originalKey;
|
|
446
|
+
var objData = _this.attachmentsHandler.convertToFDexpectedShape(attachment);
|
|
447
|
+
var options = _this.attachmentsHandler.getAttachmentInfo(attachment);
|
|
448
|
+
if (_this.isFormDataPackage(formData)) {
|
|
449
|
+
var fd = formData;
|
|
450
|
+
var data = typeof objData === 'string' ? Buffer.from(objData) : objData;
|
|
451
|
+
fd.append(key, data, options);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (typeof Blob !== undefined) { // either node > 18 or browser
|
|
455
|
+
var browserFormData = formDataInstance; // Browser compliant FormData
|
|
456
|
+
if (typeof objData === 'string' || _this.attachmentsHandler.isBuffer(objData)) {
|
|
457
|
+
var blobInstance = new Blob([objData]);
|
|
458
|
+
browserFormData.append(key, blobInstance, options.filename);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (objData instanceof Blob) {
|
|
462
|
+
browserFormData.append(key, objData, options.filename);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (_this.attachmentsHandler.isStream(objData)) {
|
|
466
|
+
var blob = _this.attachmentsHandler.getBlobFromStream(objData, options.knownLength);
|
|
467
|
+
browserFormData.set(key, blob, options.filename);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
if (Array.isArray(value)) {
|
|
472
|
+
value.forEach(function (item) {
|
|
473
|
+
appendFileToFD(propertyName, item, formDataInstance);
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
appendFileToFD(propertyName, value, formDataInstance);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
FormDataBuilder.prototype.addCommonPropertyToFD = function (key, value, formDataAcc) {
|
|
481
|
+
var _this = this;
|
|
482
|
+
var addValueBasedOnFD = function (fdKey, fdValue) {
|
|
483
|
+
if (_this.isFormDataPackage(formDataAcc)) {
|
|
484
|
+
if (typeof fdValue === 'object') {
|
|
485
|
+
// eslint-disable-next-line no-console
|
|
486
|
+
console.warn('The received value is an object. \n'
|
|
487
|
+
+ '"JSON.Stringify" will be used to avoid TypeError \n'
|
|
488
|
+
+ 'To remove this warning: \n'
|
|
489
|
+
+ 'Consider switching to built-in FormData or converting the value on your own.\n');
|
|
490
|
+
return formDataAcc.append(fdKey, JSON.stringify(fdValue));
|
|
491
|
+
}
|
|
492
|
+
return formDataAcc.append(fdKey, fdValue);
|
|
493
|
+
}
|
|
494
|
+
if (typeof fdValue === 'string') {
|
|
495
|
+
return formDataAcc.append(fdKey, fdValue);
|
|
496
|
+
}
|
|
497
|
+
if (typeof Blob !== undefined && fdValue instanceof Blob) {
|
|
498
|
+
return formDataAcc.append(fdKey, fdValue);
|
|
499
|
+
}
|
|
500
|
+
throw APIError.getUserDataError('Unknown value type for Form Data. String or Blob expected', 'Browser compliant FormData allows only string or Blob values for properties that are not attachments.');
|
|
501
|
+
};
|
|
502
|
+
if (Array.isArray(value)) {
|
|
503
|
+
value.forEach(function (item) {
|
|
504
|
+
addValueBasedOnFD(key, item);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
else if (value != null) {
|
|
508
|
+
addValueBasedOnFD(key, value);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
return FormDataBuilder;
|
|
512
|
+
}());
|
|
513
|
+
|
|
514
|
+
function bind(fn, thisArg) {
|
|
515
|
+
return function wrap() {
|
|
516
|
+
return fn.apply(thisArg, arguments);
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// utils is a library of generic helper functions non-specific to axios
|
|
521
|
+
|
|
522
|
+
const {toString} = Object.prototype;
|
|
523
|
+
const {getPrototypeOf} = Object;
|
|
524
|
+
const {iterator, toStringTag} = Symbol;
|
|
525
|
+
|
|
526
|
+
const kindOf = (cache => thing => {
|
|
527
|
+
const str = toString.call(thing);
|
|
528
|
+
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
529
|
+
})(Object.create(null));
|
|
530
|
+
|
|
531
|
+
const kindOfTest = (type) => {
|
|
532
|
+
type = type.toLowerCase();
|
|
533
|
+
return (thing) => kindOf(thing) === type
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
const typeOfTest = type => thing => typeof thing === type;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Determine if a value is an Array
|
|
540
|
+
*
|
|
541
|
+
* @param {Object} val The value to test
|
|
542
|
+
*
|
|
543
|
+
* @returns {boolean} True if value is an Array, otherwise false
|
|
544
|
+
*/
|
|
545
|
+
const {isArray} = Array;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Determine if a value is undefined
|
|
549
|
+
*
|
|
550
|
+
* @param {*} val The value to test
|
|
551
|
+
*
|
|
552
|
+
* @returns {boolean} True if the value is undefined, otherwise false
|
|
553
|
+
*/
|
|
554
|
+
const isUndefined = typeOfTest('undefined');
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Determine if a value is a Buffer
|
|
558
|
+
*
|
|
559
|
+
* @param {*} val The value to test
|
|
560
|
+
*
|
|
561
|
+
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
562
|
+
*/
|
|
563
|
+
function isBuffer(val) {
|
|
564
|
+
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
565
|
+
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
420
566
|
}
|
|
421
567
|
|
|
422
568
|
/**
|
|
@@ -461,7 +607,7 @@ const isString = typeOfTest('string');
|
|
|
461
607
|
* @param {*} val The value to test
|
|
462
608
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
463
609
|
*/
|
|
464
|
-
const isFunction = typeOfTest('function');
|
|
610
|
+
const isFunction$1 = typeOfTest('function');
|
|
465
611
|
|
|
466
612
|
/**
|
|
467
613
|
* Determine if a value is a Number
|
|
@@ -505,6 +651,27 @@ const isPlainObject = (val) => {
|
|
|
505
651
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
506
652
|
};
|
|
507
653
|
|
|
654
|
+
/**
|
|
655
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
656
|
+
*
|
|
657
|
+
* @param {*} val The value to test
|
|
658
|
+
*
|
|
659
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
660
|
+
*/
|
|
661
|
+
const isEmptyObject = (val) => {
|
|
662
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
663
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
try {
|
|
668
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
669
|
+
} catch (e) {
|
|
670
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
|
|
508
675
|
/**
|
|
509
676
|
* Determine if a value is a Date
|
|
510
677
|
*
|
|
@@ -548,7 +715,7 @@ const isFileList = kindOfTest('FileList');
|
|
|
548
715
|
*
|
|
549
716
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
550
717
|
*/
|
|
551
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
718
|
+
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
552
719
|
|
|
553
720
|
/**
|
|
554
721
|
* Determine if a value is a FormData
|
|
@@ -561,10 +728,10 @@ const isFormData = (thing) => {
|
|
|
561
728
|
let kind;
|
|
562
729
|
return thing && (
|
|
563
730
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
564
|
-
isFunction(thing.append) && (
|
|
731
|
+
isFunction$1(thing.append) && (
|
|
565
732
|
(kind = kindOf(thing)) === 'formdata' ||
|
|
566
733
|
// detect form-data instance
|
|
567
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
734
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
568
735
|
)
|
|
569
736
|
)
|
|
570
737
|
)
|
|
@@ -627,6 +794,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
627
794
|
fn.call(null, obj[i], i, obj);
|
|
628
795
|
}
|
|
629
796
|
} else {
|
|
797
|
+
// Buffer check
|
|
798
|
+
if (isBuffer(obj)) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
|
|
630
802
|
// Iterate over object keys
|
|
631
803
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
632
804
|
const len = keys.length;
|
|
@@ -640,6 +812,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
640
812
|
}
|
|
641
813
|
|
|
642
814
|
function findKey(obj, key) {
|
|
815
|
+
if (isBuffer(obj)){
|
|
816
|
+
return null;
|
|
817
|
+
}
|
|
818
|
+
|
|
643
819
|
key = key.toLowerCase();
|
|
644
820
|
const keys = Object.keys(obj);
|
|
645
821
|
let i = keys.length;
|
|
@@ -680,7 +856,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
680
856
|
* @returns {Object} Result of all merge properties
|
|
681
857
|
*/
|
|
682
858
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
683
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
859
|
+
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
684
860
|
const result = {};
|
|
685
861
|
const assignValue = (val, key) => {
|
|
686
862
|
const targetKey = caseless && findKey(result, key) || key;
|
|
@@ -691,7 +867,9 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
691
867
|
} else if (isArray(val)) {
|
|
692
868
|
result[targetKey] = val.slice();
|
|
693
869
|
} else {
|
|
694
|
-
|
|
870
|
+
if (!skipUndefined || !isUndefined(val)) {
|
|
871
|
+
result[targetKey] = val;
|
|
872
|
+
}
|
|
695
873
|
}
|
|
696
874
|
};
|
|
697
875
|
|
|
@@ -713,7 +891,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
713
891
|
*/
|
|
714
892
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
715
893
|
forEach(b, (val, key) => {
|
|
716
|
-
if (thisArg && isFunction(val)) {
|
|
894
|
+
if (thisArg && isFunction$1(val)) {
|
|
717
895
|
a[key] = bind(val, thisArg);
|
|
718
896
|
} else {
|
|
719
897
|
a[key] = val;
|
|
@@ -929,13 +1107,13 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
929
1107
|
const freezeMethods = (obj) => {
|
|
930
1108
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
931
1109
|
// skip restricted props in strict mode
|
|
932
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
1110
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
933
1111
|
return false;
|
|
934
1112
|
}
|
|
935
1113
|
|
|
936
1114
|
const value = obj[name];
|
|
937
1115
|
|
|
938
|
-
if (!isFunction(value)) return;
|
|
1116
|
+
if (!isFunction$1(value)) return;
|
|
939
1117
|
|
|
940
1118
|
descriptor.enumerable = false;
|
|
941
1119
|
|
|
@@ -972,6 +1150,8 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
972
1150
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
973
1151
|
};
|
|
974
1152
|
|
|
1153
|
+
|
|
1154
|
+
|
|
975
1155
|
/**
|
|
976
1156
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
977
1157
|
*
|
|
@@ -980,7 +1160,7 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
980
1160
|
* @returns {boolean}
|
|
981
1161
|
*/
|
|
982
1162
|
function isSpecCompliantForm(thing) {
|
|
983
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
1163
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
984
1164
|
}
|
|
985
1165
|
|
|
986
1166
|
const toJSONObject = (obj) => {
|
|
@@ -993,6 +1173,11 @@ const toJSONObject = (obj) => {
|
|
|
993
1173
|
return;
|
|
994
1174
|
}
|
|
995
1175
|
|
|
1176
|
+
//Buffer check
|
|
1177
|
+
if (isBuffer(source)) {
|
|
1178
|
+
return source;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
996
1181
|
if(!('toJSON' in source)) {
|
|
997
1182
|
stack[i] = source;
|
|
998
1183
|
const target = isArray(source) ? [] : {};
|
|
@@ -1017,7 +1202,7 @@ const toJSONObject = (obj) => {
|
|
|
1017
1202
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
1018
1203
|
|
|
1019
1204
|
const isThenable = (thing) =>
|
|
1020
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
1205
|
+
thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
1021
1206
|
|
|
1022
1207
|
// original code
|
|
1023
1208
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -1041,7 +1226,7 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
1041
1226
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
1042
1227
|
})(
|
|
1043
1228
|
typeof setImmediate === 'function',
|
|
1044
|
-
isFunction(_global.postMessage)
|
|
1229
|
+
isFunction$1(_global.postMessage)
|
|
1045
1230
|
);
|
|
1046
1231
|
|
|
1047
1232
|
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
@@ -1050,7 +1235,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
1050
1235
|
// *********************
|
|
1051
1236
|
|
|
1052
1237
|
|
|
1053
|
-
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
|
|
1238
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
1054
1239
|
|
|
1055
1240
|
|
|
1056
1241
|
var utils$1 = {
|
|
@@ -1064,6 +1249,7 @@ var utils$1 = {
|
|
|
1064
1249
|
isBoolean,
|
|
1065
1250
|
isObject,
|
|
1066
1251
|
isPlainObject,
|
|
1252
|
+
isEmptyObject,
|
|
1067
1253
|
isReadableStream,
|
|
1068
1254
|
isRequest,
|
|
1069
1255
|
isResponse,
|
|
@@ -1073,7 +1259,7 @@ var utils$1 = {
|
|
|
1073
1259
|
isFile,
|
|
1074
1260
|
isBlob,
|
|
1075
1261
|
isRegExp,
|
|
1076
|
-
isFunction,
|
|
1262
|
+
isFunction: isFunction$1,
|
|
1077
1263
|
isStream,
|
|
1078
1264
|
isURLSearchParams,
|
|
1079
1265
|
isTypedArray,
|
|
@@ -1199,11 +1385,18 @@ AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
|
1199
1385
|
return prop !== 'isAxiosError';
|
|
1200
1386
|
});
|
|
1201
1387
|
|
|
1202
|
-
|
|
1388
|
+
const msg = error && error.message ? error.message : 'Error';
|
|
1203
1389
|
|
|
1204
|
-
|
|
1390
|
+
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
1391
|
+
const errCode = code == null && error ? error.code : code;
|
|
1392
|
+
AxiosError$1.call(axiosError, msg, errCode, config, request, response);
|
|
1393
|
+
|
|
1394
|
+
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
1395
|
+
if (error && axiosError.cause == null) {
|
|
1396
|
+
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
1397
|
+
}
|
|
1205
1398
|
|
|
1206
|
-
axiosError.name = error.name;
|
|
1399
|
+
axiosError.name = (error && error.name) || 'Error';
|
|
1207
1400
|
|
|
1208
1401
|
customProps && Object.assign(axiosError, customProps);
|
|
1209
1402
|
|
|
@@ -1494,9 +1687,7 @@ function encode(val) {
|
|
|
1494
1687
|
replace(/%3A/gi, ':').
|
|
1495
1688
|
replace(/%24/g, '$').
|
|
1496
1689
|
replace(/%2C/gi, ',').
|
|
1497
|
-
replace(/%20/g, '+')
|
|
1498
|
-
replace(/%5B/gi, '[').
|
|
1499
|
-
replace(/%5D/gi, ']');
|
|
1690
|
+
replace(/%20/g, '+');
|
|
1500
1691
|
}
|
|
1501
1692
|
|
|
1502
1693
|
/**
|
|
@@ -1693,7 +1884,7 @@ var platform = {
|
|
|
1693
1884
|
};
|
|
1694
1885
|
|
|
1695
1886
|
function toURLEncodedForm(data, options) {
|
|
1696
|
-
return toFormData$1(data, new platform.classes.URLSearchParams(),
|
|
1887
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
1697
1888
|
visitor: function(value, key, path, helpers) {
|
|
1698
1889
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1699
1890
|
this.append(key, value.toString('base64'));
|
|
@@ -1701,8 +1892,9 @@ function toURLEncodedForm(data, options) {
|
|
|
1701
1892
|
}
|
|
1702
1893
|
|
|
1703
1894
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1895
|
+
},
|
|
1896
|
+
...options
|
|
1897
|
+
});
|
|
1706
1898
|
}
|
|
1707
1899
|
|
|
1708
1900
|
/**
|
|
@@ -1898,7 +2090,7 @@ const defaults = {
|
|
|
1898
2090
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1899
2091
|
|
|
1900
2092
|
try {
|
|
1901
|
-
return JSON.parse(data);
|
|
2093
|
+
return JSON.parse(data, this.parseReviver);
|
|
1902
2094
|
} catch (e) {
|
|
1903
2095
|
if (strictJSONParsing) {
|
|
1904
2096
|
if (e.name === 'SyntaxError') {
|
|
@@ -2451,7 +2643,7 @@ function throttle(fn, freq) {
|
|
|
2451
2643
|
clearTimeout(timer);
|
|
2452
2644
|
timer = null;
|
|
2453
2645
|
}
|
|
2454
|
-
fn
|
|
2646
|
+
fn(...args);
|
|
2455
2647
|
};
|
|
2456
2648
|
|
|
2457
2649
|
const throttled = (...args) => {
|
|
@@ -2707,7 +2899,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
2707
2899
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
2708
2900
|
};
|
|
2709
2901
|
|
|
2710
|
-
utils$1.forEach(Object.keys(
|
|
2902
|
+
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
2711
2903
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2712
2904
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2713
2905
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -2719,7 +2911,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
2719
2911
|
var resolveConfig = (config) => {
|
|
2720
2912
|
const newConfig = mergeConfig$1({}, config);
|
|
2721
2913
|
|
|
2722
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
2914
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
2723
2915
|
|
|
2724
2916
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2725
2917
|
|
|
@@ -2732,17 +2924,21 @@ var resolveConfig = (config) => {
|
|
|
2732
2924
|
);
|
|
2733
2925
|
}
|
|
2734
2926
|
|
|
2735
|
-
let contentType;
|
|
2736
|
-
|
|
2737
2927
|
if (utils$1.isFormData(data)) {
|
|
2738
2928
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
2739
|
-
headers.setContentType(undefined); //
|
|
2740
|
-
} else if ((
|
|
2741
|
-
//
|
|
2742
|
-
const
|
|
2743
|
-
headers
|
|
2929
|
+
headers.setContentType(undefined); // browser handles it
|
|
2930
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
2931
|
+
// Node.js FormData (like form-data package)
|
|
2932
|
+
const formHeaders = data.getHeaders();
|
|
2933
|
+
// Only set safe headers to avoid overwriting security headers
|
|
2934
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
2935
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
2936
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
2937
|
+
headers.set(key, val);
|
|
2938
|
+
}
|
|
2939
|
+
});
|
|
2744
2940
|
}
|
|
2745
|
-
}
|
|
2941
|
+
}
|
|
2746
2942
|
|
|
2747
2943
|
// Add xsrf header
|
|
2748
2944
|
// This is only done if running in a standard browser environment.
|
|
@@ -2859,15 +3055,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2859
3055
|
};
|
|
2860
3056
|
|
|
2861
3057
|
// Handle low level network errors
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
3058
|
+
request.onerror = function handleError(event) {
|
|
3059
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
3060
|
+
// (message may be empty; when present, surface it)
|
|
3061
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
3062
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
3063
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
3064
|
+
// attach the underlying event for consumers who want details
|
|
3065
|
+
err.event = event || null;
|
|
3066
|
+
reject(err);
|
|
3067
|
+
request = null;
|
|
3068
|
+
};
|
|
3069
|
+
|
|
2871
3070
|
// Handle timeout
|
|
2872
3071
|
request.ontimeout = function handleTimeout() {
|
|
2873
3072
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
@@ -3081,14 +3280,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3081
3280
|
})
|
|
3082
3281
|
};
|
|
3083
3282
|
|
|
3084
|
-
const
|
|
3085
|
-
|
|
3283
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3284
|
+
|
|
3285
|
+
const {isFunction} = utils$1;
|
|
3286
|
+
|
|
3287
|
+
const globalFetchAPI = (({fetch, Request, Response}) => ({
|
|
3288
|
+
fetch, Request, Response
|
|
3289
|
+
}))(utils$1.global);
|
|
3290
|
+
|
|
3291
|
+
const {
|
|
3292
|
+
ReadableStream: ReadableStream$1, TextEncoder
|
|
3293
|
+
} = utils$1.global;
|
|
3086
3294
|
|
|
3087
|
-
// used only inside the fetch adapter
|
|
3088
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
3089
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
3090
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
3091
|
-
);
|
|
3092
3295
|
|
|
3093
3296
|
const test = (fn, ...args) => {
|
|
3094
3297
|
try {
|
|
@@ -3098,211 +3301,266 @@ const test = (fn, ...args) => {
|
|
|
3098
3301
|
}
|
|
3099
3302
|
};
|
|
3100
3303
|
|
|
3101
|
-
const
|
|
3102
|
-
|
|
3304
|
+
const factory = (env) => {
|
|
3305
|
+
const {fetch, Request, Response} = Object.assign({}, globalFetchAPI, env);
|
|
3306
|
+
const isFetchSupported = isFunction(fetch);
|
|
3307
|
+
const isRequestSupported = isFunction(Request);
|
|
3308
|
+
const isResponseSupported = isFunction(Response);
|
|
3103
3309
|
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
get duplex() {
|
|
3108
|
-
duplexAccessed = true;
|
|
3109
|
-
return 'half';
|
|
3110
|
-
},
|
|
3111
|
-
}).headers.has('Content-Type');
|
|
3310
|
+
if (!isFetchSupported) {
|
|
3311
|
+
return false;
|
|
3312
|
+
}
|
|
3112
3313
|
|
|
3113
|
-
|
|
3114
|
-
});
|
|
3314
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3115
3315
|
|
|
3116
|
-
const
|
|
3316
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
3317
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
3318
|
+
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
|
3319
|
+
);
|
|
3117
3320
|
|
|
3118
|
-
const
|
|
3119
|
-
|
|
3321
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
3322
|
+
let duplexAccessed = false;
|
|
3120
3323
|
|
|
3324
|
+
const hasContentType = new Request(platform.origin, {
|
|
3325
|
+
body: new ReadableStream$1(),
|
|
3326
|
+
method: 'POST',
|
|
3327
|
+
get duplex() {
|
|
3328
|
+
duplexAccessed = true;
|
|
3329
|
+
return 'half';
|
|
3330
|
+
},
|
|
3331
|
+
}).headers.has('Content-Type');
|
|
3121
3332
|
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3333
|
+
return duplexAccessed && !hasContentType;
|
|
3334
|
+
});
|
|
3335
|
+
|
|
3336
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
|
3337
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3338
|
+
|
|
3339
|
+
const resolvers = {
|
|
3340
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
3341
|
+
};
|
|
3342
|
+
|
|
3343
|
+
isFetchSupported && ((() => {
|
|
3344
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
3345
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
3346
|
+
let method = res && res[type];
|
|
3347
|
+
|
|
3348
|
+
if (method) {
|
|
3349
|
+
return method.call(res);
|
|
3350
|
+
}
|
|
3125
3351
|
|
|
3126
|
-
isFetchSupported && (((res) => {
|
|
3127
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
3128
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
3129
|
-
(_, config) => {
|
|
3130
3352
|
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
3131
3353
|
});
|
|
3132
|
-
|
|
3133
|
-
})(
|
|
3354
|
+
});
|
|
3355
|
+
})());
|
|
3134
3356
|
|
|
3135
|
-
const getBodyLength = async (body) => {
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3357
|
+
const getBodyLength = async (body) => {
|
|
3358
|
+
if (body == null) {
|
|
3359
|
+
return 0;
|
|
3360
|
+
}
|
|
3139
3361
|
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3362
|
+
if (utils$1.isBlob(body)) {
|
|
3363
|
+
return body.size;
|
|
3364
|
+
}
|
|
3143
3365
|
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3366
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
3367
|
+
const _request = new Request(platform.origin, {
|
|
3368
|
+
method: 'POST',
|
|
3369
|
+
body,
|
|
3370
|
+
});
|
|
3371
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
3372
|
+
}
|
|
3151
3373
|
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3374
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
3375
|
+
return body.byteLength;
|
|
3376
|
+
}
|
|
3155
3377
|
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3378
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
3379
|
+
body = body + '';
|
|
3380
|
+
}
|
|
3159
3381
|
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
};
|
|
3382
|
+
if (utils$1.isString(body)) {
|
|
3383
|
+
return (await encodeText(body)).byteLength;
|
|
3384
|
+
}
|
|
3385
|
+
};
|
|
3164
3386
|
|
|
3165
|
-
const resolveBodyLength = async (headers, body) => {
|
|
3166
|
-
|
|
3387
|
+
const resolveBodyLength = async (headers, body) => {
|
|
3388
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
3167
3389
|
|
|
3168
|
-
|
|
3169
|
-
};
|
|
3390
|
+
return length == null ? getBodyLength(body) : length;
|
|
3391
|
+
};
|
|
3170
3392
|
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3393
|
+
return async (config) => {
|
|
3394
|
+
let {
|
|
3395
|
+
url,
|
|
3396
|
+
method,
|
|
3397
|
+
data,
|
|
3398
|
+
signal,
|
|
3399
|
+
cancelToken,
|
|
3400
|
+
timeout,
|
|
3401
|
+
onDownloadProgress,
|
|
3402
|
+
onUploadProgress,
|
|
3403
|
+
responseType,
|
|
3404
|
+
headers,
|
|
3405
|
+
withCredentials = 'same-origin',
|
|
3406
|
+
fetchOptions
|
|
3407
|
+
} = resolveConfig(config);
|
|
3408
|
+
|
|
3409
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3410
|
+
|
|
3411
|
+
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
3412
|
+
|
|
3413
|
+
let request = null;
|
|
3414
|
+
|
|
3415
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
3194
3416
|
composedSignal.unsubscribe();
|
|
3195
|
-
|
|
3417
|
+
});
|
|
3196
3418
|
|
|
3197
|
-
|
|
3419
|
+
let requestContentLength;
|
|
3198
3420
|
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3421
|
+
try {
|
|
3422
|
+
if (
|
|
3423
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
3424
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
3425
|
+
) {
|
|
3426
|
+
let _request = new Request(url, {
|
|
3427
|
+
method: 'POST',
|
|
3428
|
+
body: data,
|
|
3429
|
+
duplex: "half"
|
|
3430
|
+
});
|
|
3209
3431
|
|
|
3210
|
-
|
|
3432
|
+
let contentTypeHeader;
|
|
3211
3433
|
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3434
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
3435
|
+
headers.setContentType(contentTypeHeader);
|
|
3436
|
+
}
|
|
3215
3437
|
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3438
|
+
if (_request.body) {
|
|
3439
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
3440
|
+
requestContentLength,
|
|
3441
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
3442
|
+
);
|
|
3221
3443
|
|
|
3222
|
-
|
|
3444
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
3445
|
+
}
|
|
3223
3446
|
}
|
|
3224
|
-
}
|
|
3225
3447
|
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3448
|
+
if (!utils$1.isString(withCredentials)) {
|
|
3449
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3450
|
+
}
|
|
3229
3451
|
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
request = new Request(url, {
|
|
3234
|
-
...fetchOptions,
|
|
3235
|
-
signal: composedSignal,
|
|
3236
|
-
method: method.toUpperCase(),
|
|
3237
|
-
headers: headers.normalize().toJSON(),
|
|
3238
|
-
body: data,
|
|
3239
|
-
duplex: "half",
|
|
3240
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3241
|
-
});
|
|
3452
|
+
// Cloudflare Workers throws when credentials are defined
|
|
3453
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
3454
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
3242
3455
|
|
|
3243
|
-
|
|
3456
|
+
const resolvedOptions = {
|
|
3457
|
+
...fetchOptions,
|
|
3458
|
+
signal: composedSignal,
|
|
3459
|
+
method: method.toUpperCase(),
|
|
3460
|
+
headers: headers.normalize().toJSON(),
|
|
3461
|
+
body: data,
|
|
3462
|
+
duplex: "half",
|
|
3463
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3464
|
+
};
|
|
3244
3465
|
|
|
3245
|
-
|
|
3466
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3246
3467
|
|
|
3247
|
-
|
|
3248
|
-
const options = {};
|
|
3468
|
+
let response = await (isRequestSupported ? fetch(request, fetchOptions) : fetch(url, resolvedOptions));
|
|
3249
3469
|
|
|
3250
|
-
|
|
3251
|
-
options[prop] = response[prop];
|
|
3252
|
-
});
|
|
3470
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3253
3471
|
|
|
3254
|
-
|
|
3472
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3473
|
+
const options = {};
|
|
3255
3474
|
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
) || [];
|
|
3475
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3476
|
+
options[prop] = response[prop];
|
|
3477
|
+
});
|
|
3260
3478
|
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
);
|
|
3268
|
-
}
|
|
3479
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3480
|
+
|
|
3481
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
3482
|
+
responseContentLength,
|
|
3483
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3484
|
+
) || [];
|
|
3269
3485
|
|
|
3270
|
-
|
|
3486
|
+
response = new Response(
|
|
3487
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
3488
|
+
flush && flush();
|
|
3489
|
+
unsubscribe && unsubscribe();
|
|
3490
|
+
}),
|
|
3491
|
+
options
|
|
3492
|
+
);
|
|
3493
|
+
}
|
|
3271
3494
|
|
|
3272
|
-
|
|
3495
|
+
responseType = responseType || 'text';
|
|
3273
3496
|
|
|
3274
|
-
|
|
3497
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3275
3498
|
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3499
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3500
|
+
|
|
3501
|
+
return await new Promise((resolve, reject) => {
|
|
3502
|
+
settle(resolve, reject, {
|
|
3503
|
+
data: responseData,
|
|
3504
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
3505
|
+
status: response.status,
|
|
3506
|
+
statusText: response.statusText,
|
|
3507
|
+
config,
|
|
3508
|
+
request
|
|
3509
|
+
});
|
|
3510
|
+
})
|
|
3511
|
+
} catch (err) {
|
|
3512
|
+
unsubscribe && unsubscribe();
|
|
3513
|
+
|
|
3514
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3515
|
+
throw Object.assign(
|
|
3516
|
+
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
|
3517
|
+
{
|
|
3518
|
+
cause: err.cause || err
|
|
3519
|
+
}
|
|
3520
|
+
)
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
throw AxiosError$1.from(err, err && err.code, config, request);
|
|
3296
3524
|
}
|
|
3525
|
+
}
|
|
3526
|
+
};
|
|
3527
|
+
|
|
3528
|
+
const seedCache = new Map();
|
|
3529
|
+
|
|
3530
|
+
const getFetch = (config) => {
|
|
3531
|
+
let env = utils$1.merge.call({
|
|
3532
|
+
skipUndefined: true
|
|
3533
|
+
}, globalFetchAPI, config ? config.env : null);
|
|
3534
|
+
|
|
3535
|
+
const {fetch, Request, Response} = env;
|
|
3536
|
+
|
|
3537
|
+
const seeds = [
|
|
3538
|
+
Request, Response, fetch
|
|
3539
|
+
];
|
|
3540
|
+
|
|
3541
|
+
let len = seeds.length, i = len,
|
|
3542
|
+
seed, target, map = seedCache;
|
|
3297
3543
|
|
|
3298
|
-
|
|
3544
|
+
while (i--) {
|
|
3545
|
+
seed = seeds[i];
|
|
3546
|
+
target = map.get(seed);
|
|
3547
|
+
|
|
3548
|
+
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
|
|
3549
|
+
|
|
3550
|
+
map = target;
|
|
3299
3551
|
}
|
|
3300
|
-
|
|
3552
|
+
|
|
3553
|
+
return target;
|
|
3554
|
+
};
|
|
3555
|
+
|
|
3556
|
+
getFetch();
|
|
3301
3557
|
|
|
3302
3558
|
const knownAdapters = {
|
|
3303
3559
|
http: httpAdapter,
|
|
3304
3560
|
xhr: xhrAdapter,
|
|
3305
|
-
fetch:
|
|
3561
|
+
fetch: {
|
|
3562
|
+
get: getFetch,
|
|
3563
|
+
}
|
|
3306
3564
|
};
|
|
3307
3565
|
|
|
3308
3566
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
@@ -3321,7 +3579,7 @@ const renderReason = (reason) => `- ${reason}`;
|
|
|
3321
3579
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3322
3580
|
|
|
3323
3581
|
var adapters = {
|
|
3324
|
-
getAdapter: (adapters) => {
|
|
3582
|
+
getAdapter: (adapters, config) => {
|
|
3325
3583
|
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
3326
3584
|
|
|
3327
3585
|
const {length} = adapters;
|
|
@@ -3344,7 +3602,7 @@ var adapters = {
|
|
|
3344
3602
|
}
|
|
3345
3603
|
}
|
|
3346
3604
|
|
|
3347
|
-
if (adapter) {
|
|
3605
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
3348
3606
|
break;
|
|
3349
3607
|
}
|
|
3350
3608
|
|
|
@@ -3412,7 +3670,7 @@ function dispatchRequest(config) {
|
|
|
3412
3670
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
3413
3671
|
}
|
|
3414
3672
|
|
|
3415
|
-
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
|
3673
|
+
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
3416
3674
|
|
|
3417
3675
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
3418
3676
|
throwIfCancellationRequested(config);
|
|
@@ -3446,7 +3704,7 @@ function dispatchRequest(config) {
|
|
|
3446
3704
|
});
|
|
3447
3705
|
}
|
|
3448
3706
|
|
|
3449
|
-
const VERSION$1 = "1.
|
|
3707
|
+
const VERSION$1 = "1.12.1";
|
|
3450
3708
|
|
|
3451
3709
|
const validators$1 = {};
|
|
3452
3710
|
|
|
@@ -3685,8 +3943,8 @@ let Axios$1 = class Axios {
|
|
|
3685
3943
|
|
|
3686
3944
|
if (!synchronousRequestInterceptors) {
|
|
3687
3945
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
3688
|
-
chain.unshift
|
|
3689
|
-
chain.push
|
|
3946
|
+
chain.unshift(...requestInterceptorChain);
|
|
3947
|
+
chain.push(...responseInterceptorChain);
|
|
3690
3948
|
len = chain.length;
|
|
3691
3949
|
|
|
3692
3950
|
promise = Promise.resolve(config);
|
|
@@ -4070,315 +4328,205 @@ axios.AxiosHeaders = AxiosHeaders$1;
|
|
|
4070
4328
|
|
|
4071
4329
|
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4072
4330
|
|
|
4073
|
-
axios.getAdapter = adapters.getAdapter;
|
|
4331
|
+
axios.getAdapter = adapters.getAdapter;
|
|
4332
|
+
|
|
4333
|
+
axios.HttpStatusCode = HttpStatusCode$1;
|
|
4334
|
+
|
|
4335
|
+
axios.default = axios;
|
|
4336
|
+
|
|
4337
|
+
// This module is intended to unwrap Axios default export as named.
|
|
4338
|
+
// Keep top-level export same with static properties
|
|
4339
|
+
// so that it can keep same with es module or cjs
|
|
4340
|
+
const {
|
|
4341
|
+
Axios,
|
|
4342
|
+
AxiosError,
|
|
4343
|
+
CanceledError,
|
|
4344
|
+
isCancel,
|
|
4345
|
+
CancelToken,
|
|
4346
|
+
VERSION,
|
|
4347
|
+
all,
|
|
4348
|
+
Cancel,
|
|
4349
|
+
isAxiosError,
|
|
4350
|
+
spread,
|
|
4351
|
+
toFormData,
|
|
4352
|
+
AxiosHeaders,
|
|
4353
|
+
HttpStatusCode,
|
|
4354
|
+
formToJSON,
|
|
4355
|
+
getAdapter,
|
|
4356
|
+
mergeConfig
|
|
4357
|
+
} = axios;
|
|
4358
|
+
|
|
4359
|
+
var base64$1 = {exports: {}};
|
|
4360
|
+
|
|
4361
|
+
/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */
|
|
4362
|
+
var base64 = base64$1.exports;
|
|
4363
|
+
|
|
4364
|
+
var hasRequiredBase64;
|
|
4365
|
+
|
|
4366
|
+
function requireBase64 () {
|
|
4367
|
+
if (hasRequiredBase64) return base64$1.exports;
|
|
4368
|
+
hasRequiredBase64 = 1;
|
|
4369
|
+
(function (module, exports) {
|
|
4370
|
+
(function(root) {
|
|
4371
|
+
|
|
4372
|
+
// Detect free variables `exports`.
|
|
4373
|
+
var freeExports = exports;
|
|
4374
|
+
|
|
4375
|
+
// Detect free variable `module`.
|
|
4376
|
+
var freeModule = module &&
|
|
4377
|
+
module.exports == freeExports && module;
|
|
4378
|
+
|
|
4379
|
+
// Detect free variable `global`, from Node.js or Browserified code, and use
|
|
4380
|
+
// it as `root`.
|
|
4381
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
|
|
4382
|
+
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
|
4383
|
+
root = freeGlobal;
|
|
4384
|
+
}
|
|
4385
|
+
|
|
4386
|
+
/*--------------------------------------------------------------------------*/
|
|
4387
|
+
|
|
4388
|
+
var InvalidCharacterError = function(message) {
|
|
4389
|
+
this.message = message;
|
|
4390
|
+
};
|
|
4391
|
+
InvalidCharacterError.prototype = new Error;
|
|
4392
|
+
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
|
4393
|
+
|
|
4394
|
+
var error = function(message) {
|
|
4395
|
+
// Note: the error messages used throughout this file match those used by
|
|
4396
|
+
// the native `atob`/`btoa` implementation in Chromium.
|
|
4397
|
+
throw new InvalidCharacterError(message);
|
|
4398
|
+
};
|
|
4399
|
+
|
|
4400
|
+
var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
4401
|
+
// http://whatwg.org/html/common-microsyntaxes.html#space-character
|
|
4402
|
+
var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
|
|
4403
|
+
|
|
4404
|
+
// `decode` is designed to be fully compatible with `atob` as described in the
|
|
4405
|
+
// HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
|
|
4406
|
+
// The optimized base64-decoding algorithm used is based on @atk’s excellent
|
|
4407
|
+
// implementation. https://gist.github.com/atk/1020396
|
|
4408
|
+
var decode = function(input) {
|
|
4409
|
+
input = String(input)
|
|
4410
|
+
.replace(REGEX_SPACE_CHARACTERS, '');
|
|
4411
|
+
var length = input.length;
|
|
4412
|
+
if (length % 4 == 0) {
|
|
4413
|
+
input = input.replace(/==?$/, '');
|
|
4414
|
+
length = input.length;
|
|
4415
|
+
}
|
|
4416
|
+
if (
|
|
4417
|
+
length % 4 == 1 ||
|
|
4418
|
+
// http://whatwg.org/C#alphanumeric-ascii-characters
|
|
4419
|
+
/[^+a-zA-Z0-9/]/.test(input)
|
|
4420
|
+
) {
|
|
4421
|
+
error(
|
|
4422
|
+
'Invalid character: the string to be decoded is not correctly encoded.'
|
|
4423
|
+
);
|
|
4424
|
+
}
|
|
4425
|
+
var bitCounter = 0;
|
|
4426
|
+
var bitStorage;
|
|
4427
|
+
var buffer;
|
|
4428
|
+
var output = '';
|
|
4429
|
+
var position = -1;
|
|
4430
|
+
while (++position < length) {
|
|
4431
|
+
buffer = TABLE.indexOf(input.charAt(position));
|
|
4432
|
+
bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
|
|
4433
|
+
// Unless this is the first of a group of 4 characters…
|
|
4434
|
+
if (bitCounter++ % 4) {
|
|
4435
|
+
// …convert the first 8 bits to a single ASCII character.
|
|
4436
|
+
output += String.fromCharCode(
|
|
4437
|
+
0xFF & bitStorage >> (-2 * bitCounter & 6)
|
|
4438
|
+
);
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
return output;
|
|
4442
|
+
};
|
|
4443
|
+
|
|
4444
|
+
// `encode` is designed to be fully compatible with `btoa` as described in the
|
|
4445
|
+
// HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
|
|
4446
|
+
var encode = function(input) {
|
|
4447
|
+
input = String(input);
|
|
4448
|
+
if (/[^\0-\xFF]/.test(input)) {
|
|
4449
|
+
// Note: no need to special-case astral symbols here, as surrogates are
|
|
4450
|
+
// matched, and the input is supposed to only contain ASCII anyway.
|
|
4451
|
+
error(
|
|
4452
|
+
'The string to be encoded contains characters outside of the ' +
|
|
4453
|
+
'Latin1 range.'
|
|
4454
|
+
);
|
|
4455
|
+
}
|
|
4456
|
+
var padding = input.length % 3;
|
|
4457
|
+
var output = '';
|
|
4458
|
+
var position = -1;
|
|
4459
|
+
var a;
|
|
4460
|
+
var b;
|
|
4461
|
+
var c;
|
|
4462
|
+
var buffer;
|
|
4463
|
+
// Make sure any padding is handled outside of the loop.
|
|
4464
|
+
var length = input.length - padding;
|
|
4074
4465
|
|
|
4075
|
-
|
|
4466
|
+
while (++position < length) {
|
|
4467
|
+
// Read three bytes, i.e. 24 bits.
|
|
4468
|
+
a = input.charCodeAt(position) << 16;
|
|
4469
|
+
b = input.charCodeAt(++position) << 8;
|
|
4470
|
+
c = input.charCodeAt(++position);
|
|
4471
|
+
buffer = a + b + c;
|
|
4472
|
+
// Turn the 24 bits into four chunks of 6 bits each, and append the
|
|
4473
|
+
// matching character for each of them to the output.
|
|
4474
|
+
output += (
|
|
4475
|
+
TABLE.charAt(buffer >> 18 & 0x3F) +
|
|
4476
|
+
TABLE.charAt(buffer >> 12 & 0x3F) +
|
|
4477
|
+
TABLE.charAt(buffer >> 6 & 0x3F) +
|
|
4478
|
+
TABLE.charAt(buffer & 0x3F)
|
|
4479
|
+
);
|
|
4480
|
+
}
|
|
4076
4481
|
|
|
4077
|
-
|
|
4482
|
+
if (padding == 2) {
|
|
4483
|
+
a = input.charCodeAt(position) << 8;
|
|
4484
|
+
b = input.charCodeAt(++position);
|
|
4485
|
+
buffer = a + b;
|
|
4486
|
+
output += (
|
|
4487
|
+
TABLE.charAt(buffer >> 10) +
|
|
4488
|
+
TABLE.charAt((buffer >> 4) & 0x3F) +
|
|
4489
|
+
TABLE.charAt((buffer << 2) & 0x3F) +
|
|
4490
|
+
'='
|
|
4491
|
+
);
|
|
4492
|
+
} else if (padding == 1) {
|
|
4493
|
+
buffer = input.charCodeAt(position);
|
|
4494
|
+
output += (
|
|
4495
|
+
TABLE.charAt(buffer >> 2) +
|
|
4496
|
+
TABLE.charAt((buffer << 4) & 0x3F) +
|
|
4497
|
+
'=='
|
|
4498
|
+
);
|
|
4499
|
+
}
|
|
4078
4500
|
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
// so that it can keep same with es module or cjs
|
|
4082
|
-
const {
|
|
4083
|
-
Axios,
|
|
4084
|
-
AxiosError,
|
|
4085
|
-
CanceledError,
|
|
4086
|
-
isCancel,
|
|
4087
|
-
CancelToken,
|
|
4088
|
-
VERSION,
|
|
4089
|
-
all,
|
|
4090
|
-
Cancel,
|
|
4091
|
-
isAxiosError,
|
|
4092
|
-
spread,
|
|
4093
|
-
toFormData,
|
|
4094
|
-
AxiosHeaders,
|
|
4095
|
-
HttpStatusCode,
|
|
4096
|
-
formToJSON,
|
|
4097
|
-
getAdapter,
|
|
4098
|
-
mergeConfig
|
|
4099
|
-
} = axios;
|
|
4501
|
+
return output;
|
|
4502
|
+
};
|
|
4100
4503
|
|
|
4101
|
-
var
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
var bodyMessage = '';
|
|
4107
|
-
var error = '';
|
|
4108
|
-
if (typeof body === 'string') {
|
|
4109
|
-
bodyMessage = body;
|
|
4110
|
-
}
|
|
4111
|
-
else {
|
|
4112
|
-
bodyMessage = (body === null || body === void 0 ? void 0 : body.message) || '';
|
|
4113
|
-
error = (body === null || body === void 0 ? void 0 : body.error) || '';
|
|
4114
|
-
}
|
|
4115
|
-
_this = _super.call(this) || this;
|
|
4116
|
-
_this.stack = '';
|
|
4117
|
-
_this.status = status;
|
|
4118
|
-
_this.message = message || error || statusText || '';
|
|
4119
|
-
_this.details = bodyMessage;
|
|
4120
|
-
_this.type = 'MailgunAPIError';
|
|
4121
|
-
return _this;
|
|
4122
|
-
}
|
|
4123
|
-
APIError.getUserDataError = function (statusText, message) {
|
|
4124
|
-
return new this({
|
|
4125
|
-
status: 400,
|
|
4126
|
-
statusText: statusText,
|
|
4127
|
-
body: {
|
|
4128
|
-
message: message
|
|
4129
|
-
}
|
|
4130
|
-
});
|
|
4131
|
-
};
|
|
4132
|
-
return APIError;
|
|
4133
|
-
}(Error));
|
|
4504
|
+
var base64 = {
|
|
4505
|
+
'encode': encode,
|
|
4506
|
+
'decode': decode,
|
|
4507
|
+
'version': '1.0.0'
|
|
4508
|
+
};
|
|
4134
4509
|
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
configurable: true
|
|
4149
|
-
});
|
|
4150
|
-
return BlobFromStream;
|
|
4151
|
-
}());
|
|
4152
|
-
var AttachmentsHandler = /** @class */ (function () {
|
|
4153
|
-
function AttachmentsHandler() {
|
|
4154
|
-
}
|
|
4155
|
-
AttachmentsHandler.prototype.getAttachmentOptions = function (item) {
|
|
4156
|
-
var filename = item.filename, contentType = item.contentType, knownLength = item.knownLength;
|
|
4157
|
-
return __assign(__assign(__assign({}, (filename ? { filename: filename } : { filename: 'file' })), (contentType && { contentType: contentType })), (knownLength && { knownLength: knownLength }));
|
|
4158
|
-
};
|
|
4159
|
-
AttachmentsHandler.prototype.getFileInfo = function (file) {
|
|
4160
|
-
var filename = file.name, contentType = file.type, knownLength = file.size;
|
|
4161
|
-
return this.getAttachmentOptions({ filename: filename, contentType: contentType, knownLength: knownLength });
|
|
4162
|
-
};
|
|
4163
|
-
AttachmentsHandler.prototype.getCustomFileInfo = function (file) {
|
|
4164
|
-
var filename = file.filename, contentType = file.contentType, knownLength = file.knownLength;
|
|
4165
|
-
return this.getAttachmentOptions({ filename: filename, contentType: contentType, knownLength: knownLength });
|
|
4166
|
-
};
|
|
4167
|
-
AttachmentsHandler.prototype.getBufferInfo = function (buffer) {
|
|
4168
|
-
var knownLength = buffer.byteLength;
|
|
4169
|
-
return this.getAttachmentOptions({ filename: 'file', contentType: '', knownLength: knownLength });
|
|
4170
|
-
};
|
|
4171
|
-
AttachmentsHandler.prototype.isStream = function (data) {
|
|
4172
|
-
return typeof data === 'object' && typeof data.pipe === 'function';
|
|
4173
|
-
};
|
|
4174
|
-
AttachmentsHandler.prototype.isCustomFile = function (obj) {
|
|
4175
|
-
return typeof obj === 'object'
|
|
4176
|
-
&& !!obj.data;
|
|
4177
|
-
};
|
|
4178
|
-
AttachmentsHandler.prototype.isBrowserFile = function (obj) {
|
|
4179
|
-
return typeof obj === 'object' && (!!obj.name || (typeof Blob !== 'undefined' && obj instanceof Blob));
|
|
4180
|
-
};
|
|
4181
|
-
AttachmentsHandler.prototype.isBuffer = function (data) {
|
|
4182
|
-
return typeof Buffer !== 'undefined' && Buffer.isBuffer(data);
|
|
4183
|
-
};
|
|
4184
|
-
AttachmentsHandler.prototype.getAttachmentInfo = function (attachment) {
|
|
4185
|
-
var isBrowserFile = this.isBrowserFile(attachment);
|
|
4186
|
-
var isCustomFile = this.isCustomFile(attachment);
|
|
4187
|
-
var isString = typeof attachment === 'string';
|
|
4188
|
-
if (!isString) {
|
|
4189
|
-
if (isBrowserFile) {
|
|
4190
|
-
return this.getFileInfo(attachment);
|
|
4191
|
-
}
|
|
4192
|
-
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(attachment)) {
|
|
4193
|
-
return this.getBufferInfo(attachment);
|
|
4194
|
-
}
|
|
4195
|
-
if (isCustomFile) {
|
|
4196
|
-
return this.getCustomFileInfo(attachment);
|
|
4197
|
-
}
|
|
4198
|
-
}
|
|
4199
|
-
var options = {
|
|
4200
|
-
filename: 'file',
|
|
4201
|
-
contentType: undefined,
|
|
4202
|
-
knownLength: undefined
|
|
4203
|
-
};
|
|
4204
|
-
return options;
|
|
4205
|
-
};
|
|
4206
|
-
AttachmentsHandler.prototype.convertToFDexpectedShape = function (userProvidedValue) {
|
|
4207
|
-
var isStream = this.isStream(userProvidedValue);
|
|
4208
|
-
var isBrowserFile = this.isBrowserFile(userProvidedValue);
|
|
4209
|
-
var isCustomFile = this.isCustomFile(userProvidedValue);
|
|
4210
|
-
var isString = typeof userProvidedValue === 'string';
|
|
4211
|
-
var result;
|
|
4212
|
-
if (isStream || isString || isBrowserFile || this.isBuffer(userProvidedValue)) {
|
|
4213
|
-
result = userProvidedValue;
|
|
4214
|
-
}
|
|
4215
|
-
else if (isCustomFile) {
|
|
4216
|
-
result = userProvidedValue.data;
|
|
4217
|
-
}
|
|
4218
|
-
else {
|
|
4219
|
-
throw APIError.getUserDataError("Unknown attachment type ".concat(typeof userProvidedValue), "The \"attachment\" property expects either Buffer, Blob, or String.\n Also, It is possible to provide an object that has the property \"data\" with a value that is equal to one of the types counted before.\n Additionally, you may use an array to send more than one attachment.");
|
|
4220
|
-
}
|
|
4221
|
-
return result;
|
|
4222
|
-
};
|
|
4223
|
-
AttachmentsHandler.prototype.getBlobFromStream = function (stream, size) {
|
|
4224
|
-
return new BlobFromStream(stream, size);
|
|
4225
|
-
};
|
|
4226
|
-
return AttachmentsHandler;
|
|
4227
|
-
}());
|
|
4510
|
+
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
|
4511
|
+
// like the following:
|
|
4512
|
+
if (freeExports && !freeExports.nodeType) {
|
|
4513
|
+
if (freeModule) { // in Node.js or RingoJS v0.8.0+
|
|
4514
|
+
freeModule.exports = base64;
|
|
4515
|
+
} else { // in Narwhal or RingoJS v0.7.0-
|
|
4516
|
+
for (var key in base64) {
|
|
4517
|
+
base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
} else { // in Rhino or a web browser
|
|
4521
|
+
root.base64 = base64;
|
|
4522
|
+
}
|
|
4228
4523
|
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
FormDataBuilder.prototype.createFormData = function (data) {
|
|
4236
|
-
var _this = this;
|
|
4237
|
-
if (!data) {
|
|
4238
|
-
throw new Error('Please provide data object');
|
|
4239
|
-
}
|
|
4240
|
-
var formData = Object.keys(data)
|
|
4241
|
-
.filter(function (key) { return data[key]; })
|
|
4242
|
-
.reduce(function (formDataAcc, key) {
|
|
4243
|
-
if (_this.fileKeys.includes(key)) {
|
|
4244
|
-
var attachmentValue = data[key];
|
|
4245
|
-
if (_this.isMessageAttachment(attachmentValue)) {
|
|
4246
|
-
_this.addFilesToFD(key, attachmentValue, formDataAcc);
|
|
4247
|
-
return formDataAcc;
|
|
4248
|
-
}
|
|
4249
|
-
throw APIError.getUserDataError("Unknown value ".concat(data[key], " with type ").concat(typeof data[key], " for property \"").concat(key, "\""), "The key \"".concat(key, "\" should have type of Buffer, Stream, File, or String "));
|
|
4250
|
-
}
|
|
4251
|
-
if (key === 'message') { // mime message
|
|
4252
|
-
var messageValue = data[key];
|
|
4253
|
-
if (!messageValue || !_this.isMIME(messageValue)) {
|
|
4254
|
-
throw APIError.getUserDataError("Unknown data type for \"".concat(key, "\" property"), 'The mime data should have type of Buffer, String or Blob');
|
|
4255
|
-
}
|
|
4256
|
-
_this.addMimeDataToFD(key, messageValue, formDataAcc);
|
|
4257
|
-
return formDataAcc;
|
|
4258
|
-
}
|
|
4259
|
-
_this.addCommonPropertyToFD(key, data[key], formDataAcc);
|
|
4260
|
-
return formDataAcc;
|
|
4261
|
-
}, new this.FormDataConstructor());
|
|
4262
|
-
return formData;
|
|
4263
|
-
};
|
|
4264
|
-
FormDataBuilder.prototype.addMimeDataToFD = function (key, data, formDataInstance) {
|
|
4265
|
-
if (typeof data === 'string') { // if string only two parameters should be used.
|
|
4266
|
-
formDataInstance.append(key, data);
|
|
4267
|
-
return;
|
|
4268
|
-
}
|
|
4269
|
-
if (this.isFormDataPackage(formDataInstance)) { // form-data package is used
|
|
4270
|
-
var nodeFormData = formDataInstance;
|
|
4271
|
-
nodeFormData.append(key, data, { filename: 'MimeMessage' });
|
|
4272
|
-
return;
|
|
4273
|
-
}
|
|
4274
|
-
if (typeof Blob !== undefined) { // either node > 18 or browser
|
|
4275
|
-
var browserFormData = formDataInstance; // Browser compliant FormData
|
|
4276
|
-
if (data instanceof Blob) {
|
|
4277
|
-
browserFormData.append(key, data, 'MimeMessage');
|
|
4278
|
-
return;
|
|
4279
|
-
}
|
|
4280
|
-
if (this.attachmentsHandler.isBuffer(data)) { // node environment
|
|
4281
|
-
var blobInstance = new Blob([data]);
|
|
4282
|
-
browserFormData.append(key, blobInstance, 'MimeMessage');
|
|
4283
|
-
}
|
|
4284
|
-
}
|
|
4285
|
-
};
|
|
4286
|
-
FormDataBuilder.prototype.isMIME = function (data) {
|
|
4287
|
-
return typeof data === 'string'
|
|
4288
|
-
|| (typeof Blob !== 'undefined' && data instanceof Blob)
|
|
4289
|
-
|| this.attachmentsHandler.isBuffer(data)
|
|
4290
|
-
|| (typeof ReadableStream !== 'undefined' && data instanceof ReadableStream);
|
|
4291
|
-
};
|
|
4292
|
-
FormDataBuilder.prototype.isFormDataPackage = function (obj) {
|
|
4293
|
-
return typeof obj === 'object'
|
|
4294
|
-
&& obj !== null
|
|
4295
|
-
&& typeof obj.getHeaders === 'function';
|
|
4296
|
-
};
|
|
4297
|
-
FormDataBuilder.prototype.isMessageAttachment = function (value) {
|
|
4298
|
-
var _this = this;
|
|
4299
|
-
return (this.attachmentsHandler.isCustomFile(value)
|
|
4300
|
-
|| typeof value === 'string'
|
|
4301
|
-
|| (typeof File !== 'undefined' && value instanceof File)
|
|
4302
|
-
|| (typeof Blob !== 'undefined' && value instanceof Blob)
|
|
4303
|
-
|| this.attachmentsHandler.isBuffer(value)
|
|
4304
|
-
|| this.attachmentsHandler.isStream(value)
|
|
4305
|
-
|| (Array.isArray(value) && value.every(function (item) { return _this.attachmentsHandler.isCustomFile(item)
|
|
4306
|
-
|| (typeof File !== 'undefined' && item instanceof File)
|
|
4307
|
-
|| (typeof Blob !== 'undefined' && value instanceof Blob)
|
|
4308
|
-
|| _this.attachmentsHandler.isBuffer(item)
|
|
4309
|
-
|| _this.attachmentsHandler.isStream(item); })));
|
|
4310
|
-
};
|
|
4311
|
-
FormDataBuilder.prototype.addFilesToFD = function (propertyName, value, formDataInstance) {
|
|
4312
|
-
var _this = this;
|
|
4313
|
-
var appendFileToFD = function (originalKey, attachment, formData) {
|
|
4314
|
-
var key = originalKey === 'multipleValidationFile' ? 'file' : originalKey;
|
|
4315
|
-
var objData = _this.attachmentsHandler.convertToFDexpectedShape(attachment);
|
|
4316
|
-
var options = _this.attachmentsHandler.getAttachmentInfo(attachment);
|
|
4317
|
-
if (_this.isFormDataPackage(formData)) {
|
|
4318
|
-
var fd = formData;
|
|
4319
|
-
var data = typeof objData === 'string' ? Buffer.from(objData) : objData;
|
|
4320
|
-
fd.append(key, data, options);
|
|
4321
|
-
return;
|
|
4322
|
-
}
|
|
4323
|
-
if (typeof Blob !== undefined) { // either node > 18 or browser
|
|
4324
|
-
var browserFormData = formDataInstance; // Browser compliant FormData
|
|
4325
|
-
if (typeof objData === 'string' || _this.attachmentsHandler.isBuffer(objData)) {
|
|
4326
|
-
var blobInstance = new Blob([objData]);
|
|
4327
|
-
browserFormData.append(key, blobInstance, options.filename);
|
|
4328
|
-
return;
|
|
4329
|
-
}
|
|
4330
|
-
if (objData instanceof Blob) {
|
|
4331
|
-
browserFormData.append(key, objData, options.filename);
|
|
4332
|
-
return;
|
|
4333
|
-
}
|
|
4334
|
-
if (_this.attachmentsHandler.isStream(objData)) {
|
|
4335
|
-
var blob = _this.attachmentsHandler.getBlobFromStream(objData, options.knownLength);
|
|
4336
|
-
browserFormData.set(key, blob, options.filename);
|
|
4337
|
-
}
|
|
4338
|
-
}
|
|
4339
|
-
};
|
|
4340
|
-
if (Array.isArray(value)) {
|
|
4341
|
-
value.forEach(function (item) {
|
|
4342
|
-
appendFileToFD(propertyName, item, formDataInstance);
|
|
4343
|
-
});
|
|
4344
|
-
}
|
|
4345
|
-
else {
|
|
4346
|
-
appendFileToFD(propertyName, value, formDataInstance);
|
|
4347
|
-
}
|
|
4348
|
-
};
|
|
4349
|
-
FormDataBuilder.prototype.addCommonPropertyToFD = function (key, value, formDataAcc) {
|
|
4350
|
-
var _this = this;
|
|
4351
|
-
var addValueBasedOnFD = function (fdKey, fdValue) {
|
|
4352
|
-
if (_this.isFormDataPackage(formDataAcc)) {
|
|
4353
|
-
if (typeof fdValue === 'object') {
|
|
4354
|
-
// eslint-disable-next-line no-console
|
|
4355
|
-
console.warn('The received value is an object. \n'
|
|
4356
|
-
+ '"JSON.Stringify" will be used to avoid TypeError \n'
|
|
4357
|
-
+ 'To remove this warning: \n'
|
|
4358
|
-
+ 'Consider switching to built-in FormData or converting the value on your own.\n');
|
|
4359
|
-
return formDataAcc.append(fdKey, JSON.stringify(fdValue));
|
|
4360
|
-
}
|
|
4361
|
-
return formDataAcc.append(fdKey, fdValue);
|
|
4362
|
-
}
|
|
4363
|
-
if (typeof fdValue === 'string') {
|
|
4364
|
-
return formDataAcc.append(fdKey, fdValue);
|
|
4365
|
-
}
|
|
4366
|
-
if (typeof Blob !== undefined && fdValue instanceof Blob) {
|
|
4367
|
-
return formDataAcc.append(fdKey, fdValue);
|
|
4368
|
-
}
|
|
4369
|
-
throw APIError.getUserDataError('Unknown value type for Form Data. String or Blob expected', 'Browser compliant FormData allows only string or Blob values for properties that are not attachments.');
|
|
4370
|
-
};
|
|
4371
|
-
if (Array.isArray(value)) {
|
|
4372
|
-
value.forEach(function (item) {
|
|
4373
|
-
addValueBasedOnFD(key, item);
|
|
4374
|
-
});
|
|
4375
|
-
}
|
|
4376
|
-
else if (value != null) {
|
|
4377
|
-
addValueBasedOnFD(key, value);
|
|
4378
|
-
}
|
|
4379
|
-
};
|
|
4380
|
-
return FormDataBuilder;
|
|
4381
|
-
}());
|
|
4524
|
+
}(base64));
|
|
4525
|
+
} (base64$1, base64$1.exports));
|
|
4526
|
+
return base64$1.exports;
|
|
4527
|
+
}
|
|
4528
|
+
|
|
4529
|
+
var base64Exports = requireBase64();
|
|
4382
4530
|
|
|
4383
4531
|
var SubaccountsClient = /** @class */ (function () {
|
|
4384
4532
|
function SubaccountsClient(request) {
|
|
@@ -4408,62 +4556,18 @@ var SubaccountsClient = /** @class */ (function () {
|
|
|
4408
4556
|
return SubaccountsClient;
|
|
4409
4557
|
}());
|
|
4410
4558
|
|
|
4411
|
-
var
|
|
4412
|
-
function
|
|
4413
|
-
|
|
4414
|
-
this.
|
|
4415
|
-
this.
|
|
4416
|
-
this.
|
|
4417
|
-
this.
|
|
4418
|
-
this.
|
|
4419
|
-
this.
|
|
4420
|
-
this.
|
|
4421
|
-
}
|
|
4422
|
-
|
|
4423
|
-
var _a, _b, _c;
|
|
4424
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4425
|
-
var options, requestHeaders, params, body, response, urlValue, err_1, errorResponse, res;
|
|
4426
|
-
return __generator(this, function (_d) {
|
|
4427
|
-
switch (_d.label) {
|
|
4428
|
-
case 0:
|
|
4429
|
-
options = __assign({}, onCallOptions);
|
|
4430
|
-
options === null || options === void 0 ? true : delete options.headers;
|
|
4431
|
-
requestHeaders = this.joinAndTransformHeaders(onCallOptions);
|
|
4432
|
-
params = __assign({}, options);
|
|
4433
|
-
if ((options === null || options === void 0 ? void 0 : options.query) && Object.getOwnPropertyNames(options === null || options === void 0 ? void 0 : options.query).length > 0) {
|
|
4434
|
-
params.params = new URLSearchParams(options.query);
|
|
4435
|
-
delete params.query;
|
|
4436
|
-
}
|
|
4437
|
-
if (options === null || options === void 0 ? void 0 : options.body) {
|
|
4438
|
-
body = options === null || options === void 0 ? void 0 : options.body;
|
|
4439
|
-
params.data = body;
|
|
4440
|
-
delete params.body;
|
|
4441
|
-
}
|
|
4442
|
-
urlValue = urljoin(this.url, url);
|
|
4443
|
-
_d.label = 1;
|
|
4444
|
-
case 1:
|
|
4445
|
-
_d.trys.push([1, 3, , 4]);
|
|
4446
|
-
return [4 /*yield*/, axios.request(__assign(__assign({ method: method.toLocaleUpperCase(), timeout: this.timeout, url: urlValue, headers: requestHeaders }, params), { maxBodyLength: this.maxBodyLength, proxy: this.proxy }))];
|
|
4447
|
-
case 2:
|
|
4448
|
-
response = _d.sent();
|
|
4449
|
-
return [3 /*break*/, 4];
|
|
4450
|
-
case 3:
|
|
4451
|
-
err_1 = _d.sent();
|
|
4452
|
-
errorResponse = err_1;
|
|
4453
|
-
throw new APIError({
|
|
4454
|
-
status: ((_a = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.response) === null || _a === void 0 ? void 0 : _a.status) || 400,
|
|
4455
|
-
statusText: ((_b = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.response) === null || _b === void 0 ? void 0 : _b.statusText) || errorResponse.code,
|
|
4456
|
-
body: ((_c = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.response) === null || _c === void 0 ? void 0 : _c.data) || errorResponse.message
|
|
4457
|
-
});
|
|
4458
|
-
case 4: return [4 /*yield*/, this.getResponseBody(response)];
|
|
4459
|
-
case 5:
|
|
4460
|
-
res = _d.sent();
|
|
4461
|
-
return [2 /*return*/, res];
|
|
4462
|
-
}
|
|
4463
|
-
});
|
|
4464
|
-
});
|
|
4465
|
-
};
|
|
4466
|
-
Request.prototype.getResponseBody = function (response) {
|
|
4559
|
+
var AxiosProvider = /** @class */ (function () {
|
|
4560
|
+
function AxiosProvider(_a) {
|
|
4561
|
+
var username = _a.username, key = _a.key, timeout = _a.timeout, maxBodyLength = _a.maxBodyLength, proxy = _a.proxy, configHeaders = _a.configHeaders, useFetch = _a.useFetch;
|
|
4562
|
+
this.timeout = timeout;
|
|
4563
|
+
this.maxBodyLength = maxBodyLength;
|
|
4564
|
+
this.proxy = proxy;
|
|
4565
|
+
this.username = username;
|
|
4566
|
+
this.key = key;
|
|
4567
|
+
this.headers = this.makeHeadersFromObject(configHeaders);
|
|
4568
|
+
this.useFetch = useFetch;
|
|
4569
|
+
}
|
|
4570
|
+
AxiosProvider.prototype.getResponseBody = function (response) {
|
|
4467
4571
|
return __awaiter(this, void 0, void 0, function () {
|
|
4468
4572
|
var res;
|
|
4469
4573
|
return __generator(this, function (_a) {
|
|
@@ -4490,17 +4594,34 @@ var Request$1 = /** @class */ (function () {
|
|
|
4490
4594
|
});
|
|
4491
4595
|
});
|
|
4492
4596
|
};
|
|
4493
|
-
|
|
4597
|
+
AxiosProvider.prototype.getDataRelatedHeaders = function (config) {
|
|
4598
|
+
var _a;
|
|
4599
|
+
var isFormURLEncoded = (_a = config === null || config === void 0 ? void 0 : config.isFormURLEncoded) !== null && _a !== void 0 ? _a : true;
|
|
4600
|
+
var isMultipartFormData = config === null || config === void 0 ? void 0 : config.isMultipartFormData;
|
|
4601
|
+
var isApplicationJSON = config === null || config === void 0 ? void 0 : config.isApplicationJSON;
|
|
4602
|
+
var headers = {};
|
|
4603
|
+
if (isFormURLEncoded) {
|
|
4604
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
4605
|
+
}
|
|
4606
|
+
if (isMultipartFormData) {
|
|
4607
|
+
headers['Content-Type'] = 'multipart/form-data';
|
|
4608
|
+
}
|
|
4609
|
+
if (isApplicationJSON) {
|
|
4610
|
+
headers['Content-Type'] = 'application/json';
|
|
4611
|
+
}
|
|
4612
|
+
return headers;
|
|
4613
|
+
};
|
|
4614
|
+
AxiosProvider.prototype.addRequestLevelHeaders = function (config) {
|
|
4494
4615
|
var requestHeaders = new AxiosHeaders();
|
|
4495
4616
|
var basic = base64Exports.encode("".concat(this.username, ":").concat(this.key));
|
|
4496
4617
|
requestHeaders.setAuthorization("Basic ".concat(basic));
|
|
4497
4618
|
requestHeaders.set(this.headers);
|
|
4498
|
-
var
|
|
4499
|
-
var onCallHeaders = this.makeHeadersFromObject(
|
|
4619
|
+
var dataRelatedHeaders = this.getDataRelatedHeaders(config);
|
|
4620
|
+
var onCallHeaders = this.makeHeadersFromObject(dataRelatedHeaders);
|
|
4500
4621
|
requestHeaders.set(onCallHeaders);
|
|
4501
4622
|
return requestHeaders;
|
|
4502
4623
|
};
|
|
4503
|
-
|
|
4624
|
+
AxiosProvider.prototype.makeHeadersFromObject = function (headersObject) {
|
|
4504
4625
|
if (headersObject === void 0) { headersObject = {}; }
|
|
4505
4626
|
var requestHeaders = new AxiosHeaders();
|
|
4506
4627
|
requestHeaders = Object.entries(headersObject).reduce(function (headersAccumulator, currentPair) {
|
|
@@ -4510,52 +4631,175 @@ var Request$1 = /** @class */ (function () {
|
|
|
4510
4631
|
}, requestHeaders);
|
|
4511
4632
|
return requestHeaders;
|
|
4512
4633
|
};
|
|
4513
|
-
|
|
4634
|
+
AxiosProvider.prototype.setSubAccountHeader = function (subAccountId) {
|
|
4635
|
+
this.headers.set(SubaccountsClient.SUBACCOUNT_HEADER, subAccountId);
|
|
4636
|
+
};
|
|
4637
|
+
AxiosProvider.prototype.resetSubAccountHeader = function () {
|
|
4638
|
+
this.headers.delete(SubaccountsClient.SUBACCOUNT_HEADER);
|
|
4639
|
+
};
|
|
4640
|
+
AxiosProvider.prototype.makeRequest = function (url, method, data, config) {
|
|
4641
|
+
var _a, _b, _c;
|
|
4642
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4643
|
+
var response, requestHeaders, reqObject, err_1, errorResponse, res;
|
|
4644
|
+
return __generator(this, function (_d) {
|
|
4645
|
+
switch (_d.label) {
|
|
4646
|
+
case 0:
|
|
4647
|
+
requestHeaders = this.addRequestLevelHeaders(config);
|
|
4648
|
+
_d.label = 1;
|
|
4649
|
+
case 1:
|
|
4650
|
+
_d.trys.push([1, 3, , 4]);
|
|
4651
|
+
reqObject = __assign(__assign({ method: method.toLocaleUpperCase(), timeout: this.timeout, url: url, headers: requestHeaders }, data), { maxBodyLength: this.maxBodyLength, proxy: this.proxy });
|
|
4652
|
+
if (this.useFetch) {
|
|
4653
|
+
reqObject.adapter = 'fetch';
|
|
4654
|
+
if (config === null || config === void 0 ? void 0 : config.dataSize) {
|
|
4655
|
+
if (config.dataSize > 0 && config.dataSize > this.maxBodyLength) {
|
|
4656
|
+
throw new APIError({
|
|
4657
|
+
status: 400,
|
|
4658
|
+
statusText: '(Fetch) Request body larger than maxBodyLength limit',
|
|
4659
|
+
body: "(Fetch) Request body size of ".concat(config.dataSize, " bytes exceeds the maximum allowed size of ").concat(this.maxBodyLength, " bytes")
|
|
4660
|
+
});
|
|
4661
|
+
}
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
return [4 /*yield*/, axios.request(reqObject)];
|
|
4665
|
+
case 2:
|
|
4666
|
+
response = _d.sent();
|
|
4667
|
+
return [3 /*break*/, 4];
|
|
4668
|
+
case 3:
|
|
4669
|
+
err_1 = _d.sent();
|
|
4670
|
+
errorResponse = err_1;
|
|
4671
|
+
throw new APIError({
|
|
4672
|
+
status: ((_a = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.response) === null || _a === void 0 ? void 0 : _a.status) || 400,
|
|
4673
|
+
statusText: ((_b = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.response) === null || _b === void 0 ? void 0 : _b.statusText) || errorResponse.code,
|
|
4674
|
+
body: ((_c = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.response) === null || _c === void 0 ? void 0 : _c.data) || errorResponse.message
|
|
4675
|
+
});
|
|
4676
|
+
case 4: return [4 /*yield*/, this.getResponseBody(response)];
|
|
4677
|
+
case 5:
|
|
4678
|
+
res = _d.sent();
|
|
4679
|
+
return [2 /*return*/, res];
|
|
4680
|
+
}
|
|
4681
|
+
});
|
|
4682
|
+
});
|
|
4683
|
+
};
|
|
4684
|
+
return AxiosProvider;
|
|
4685
|
+
}());
|
|
4686
|
+
|
|
4687
|
+
var Request = /** @class */ (function () {
|
|
4688
|
+
function Request(options, formData) {
|
|
4689
|
+
this.url = options.url;
|
|
4690
|
+
this.formDataBuilder = new FormDataBuilder(formData, { useFetch: options.useFetch });
|
|
4691
|
+
var providersConfig = {
|
|
4692
|
+
timeout: options.timeout,
|
|
4693
|
+
maxBodyLength: 52428800,
|
|
4694
|
+
proxy: options.proxy,
|
|
4695
|
+
username: options.username,
|
|
4696
|
+
key: options.key,
|
|
4697
|
+
configHeaders: options.headers,
|
|
4698
|
+
useFetch: options.useFetch
|
|
4699
|
+
};
|
|
4700
|
+
this.requestProvider = new AxiosProvider(providersConfig);
|
|
4701
|
+
}
|
|
4702
|
+
Request.prototype.request = function (method, url, onCallOptions, config) {
|
|
4514
4703
|
var _a;
|
|
4515
|
-
|
|
4516
|
-
|
|
4704
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4705
|
+
var options, params, urlValue;
|
|
4706
|
+
return __generator(this, function (_b) {
|
|
4707
|
+
options = __assign({}, onCallOptions);
|
|
4708
|
+
params = {};
|
|
4709
|
+
urlValue = urljoin(this.url, url);
|
|
4710
|
+
if ((options === null || options === void 0 ? void 0 : options.query) && Object.getOwnPropertyNames(options === null || options === void 0 ? void 0 : options.query).length > 0) {
|
|
4711
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.query) === null || _a === void 0 ? void 0 : _a.searchParams) {
|
|
4712
|
+
params.params = new URLSearchParams(options.query.searchParams);
|
|
4713
|
+
}
|
|
4714
|
+
else {
|
|
4715
|
+
params.params = new URLSearchParams(options.query);
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
if (options === null || options === void 0 ? void 0 : options.body) {
|
|
4719
|
+
params.data = options === null || options === void 0 ? void 0 : options.body;
|
|
4720
|
+
}
|
|
4721
|
+
return [2 /*return*/, this.requestProvider.makeRequest(urlValue, method.toUpperCase(), params, config)];
|
|
4722
|
+
});
|
|
4723
|
+
});
|
|
4724
|
+
};
|
|
4725
|
+
Request.prototype.setSubaccountHeader = function (subAccountId) {
|
|
4726
|
+
this.requestProvider.setSubAccountHeader(subAccountId);
|
|
4517
4727
|
};
|
|
4518
4728
|
Request.prototype.resetSubaccountHeader = function () {
|
|
4519
|
-
this.
|
|
4729
|
+
this.requestProvider.resetSubAccountHeader();
|
|
4520
4730
|
};
|
|
4521
|
-
Request.prototype.query = function (method, url, query
|
|
4522
|
-
return this.request(method, url,
|
|
4731
|
+
Request.prototype.query = function (method, url, query) {
|
|
4732
|
+
return this.request(method, url, { query: query });
|
|
4523
4733
|
};
|
|
4524
|
-
Request.prototype.command = function (method, url, data,
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
var requestOptions = __assign(__assign(__assign({}, headers), { body: data }), options);
|
|
4531
|
-
return this.request(method, url, requestOptions);
|
|
4734
|
+
Request.prototype.command = function (method, url, data, config, queryObject) {
|
|
4735
|
+
var requestOptions = {
|
|
4736
|
+
body: data,
|
|
4737
|
+
query: queryObject === null || queryObject === void 0 ? void 0 : queryObject.query,
|
|
4738
|
+
};
|
|
4739
|
+
return this.request(method, url, requestOptions, config);
|
|
4532
4740
|
};
|
|
4533
|
-
Request.prototype.get = function (url, query
|
|
4534
|
-
return this.query('get', url, query
|
|
4741
|
+
Request.prototype.get = function (url, query) {
|
|
4742
|
+
return this.query('get', url, query);
|
|
4535
4743
|
};
|
|
4536
|
-
Request.prototype.post = function (url, data,
|
|
4537
|
-
return this.command('post', url, data,
|
|
4744
|
+
Request.prototype.post = function (url, data, config) {
|
|
4745
|
+
return this.command('post', url, data, {
|
|
4746
|
+
isFormURLEncoded: false,
|
|
4747
|
+
isApplicationJSON: config === null || config === void 0 ? void 0 : config.isApplicationJSON
|
|
4748
|
+
});
|
|
4538
4749
|
};
|
|
4539
4750
|
Request.prototype.postWithFD = function (url, data) {
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4751
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4752
|
+
var _a, formData, dataSize;
|
|
4753
|
+
return __generator(this, function (_b) {
|
|
4754
|
+
switch (_b.label) {
|
|
4755
|
+
case 0: return [4 /*yield*/, this.formDataBuilder.createFormData(data)];
|
|
4756
|
+
case 1:
|
|
4757
|
+
_a = _b.sent(), formData = _a.formData, dataSize = _a.dataSize;
|
|
4758
|
+
return [2 /*return*/, this.command('post', url, formData, {
|
|
4759
|
+
isFormURLEncoded: false,
|
|
4760
|
+
isMultipartFormData: true,
|
|
4761
|
+
dataSize: dataSize
|
|
4762
|
+
})];
|
|
4763
|
+
}
|
|
4764
|
+
});
|
|
4765
|
+
});
|
|
4544
4766
|
};
|
|
4545
4767
|
Request.prototype.putWithFD = function (url, data) {
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4768
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4769
|
+
var _a, formData, dataSize;
|
|
4770
|
+
return __generator(this, function (_b) {
|
|
4771
|
+
switch (_b.label) {
|
|
4772
|
+
case 0: return [4 /*yield*/, this.formDataBuilder.createFormData(data)];
|
|
4773
|
+
case 1:
|
|
4774
|
+
_a = _b.sent(), formData = _a.formData, dataSize = _a.dataSize;
|
|
4775
|
+
return [2 /*return*/, this.command('put', url, formData, {
|
|
4776
|
+
isFormURLEncoded: false,
|
|
4777
|
+
isMultipartFormData: true,
|
|
4778
|
+
dataSize: dataSize
|
|
4779
|
+
})];
|
|
4780
|
+
}
|
|
4781
|
+
});
|
|
4782
|
+
});
|
|
4550
4783
|
};
|
|
4551
4784
|
Request.prototype.patchWithFD = function (url, data) {
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4785
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4786
|
+
var _a, formData, dataSize;
|
|
4787
|
+
return __generator(this, function (_b) {
|
|
4788
|
+
switch (_b.label) {
|
|
4789
|
+
case 0: return [4 /*yield*/, this.formDataBuilder.createFormData(data)];
|
|
4790
|
+
case 1:
|
|
4791
|
+
_a = _b.sent(), formData = _a.formData, dataSize = _a.dataSize;
|
|
4792
|
+
return [2 /*return*/, this.command('patch', url, formData, {
|
|
4793
|
+
isFormURLEncoded: false,
|
|
4794
|
+
isMultipartFormData: true,
|
|
4795
|
+
dataSize: dataSize
|
|
4796
|
+
})];
|
|
4797
|
+
}
|
|
4798
|
+
});
|
|
4799
|
+
});
|
|
4556
4800
|
};
|
|
4557
|
-
Request.prototype.put = function (url, data,
|
|
4558
|
-
return this.command('put', url, data,
|
|
4801
|
+
Request.prototype.put = function (url, data, queryObject) {
|
|
4802
|
+
return this.command('put', url, data, {}, queryObject);
|
|
4559
4803
|
};
|
|
4560
4804
|
Request.prototype.delete = function (url, data) {
|
|
4561
4805
|
return this.command('delete', url, data);
|
|
@@ -4749,17 +4993,20 @@ var DomainsClient = /** @class */ (function () {
|
|
|
4749
4993
|
return this.request.delete(urljoin('/v3/domains', domain, 'ips', 'ip_pool', searchParams));
|
|
4750
4994
|
};
|
|
4751
4995
|
DomainsClient.prototype.updateDKIMAuthority = function (domain, data) {
|
|
4752
|
-
|
|
4996
|
+
var options = { query: "self=".concat(data.self) };
|
|
4997
|
+
return this.request.put("/v3/domains/".concat(domain, "/dkim_authority"), {}, options)
|
|
4753
4998
|
.then(function (res) { return res; })
|
|
4754
4999
|
.then(function (res) { return res.body; });
|
|
4755
5000
|
};
|
|
4756
5001
|
DomainsClient.prototype.updateDKIMSelector = function (domain, data) {
|
|
4757
5002
|
var _a;
|
|
4758
5003
|
return __awaiter(this, void 0, void 0, function () {
|
|
4759
|
-
var res;
|
|
5004
|
+
var options, res;
|
|
4760
5005
|
return __generator(this, function (_b) {
|
|
4761
5006
|
switch (_b.label) {
|
|
4762
|
-
case 0:
|
|
5007
|
+
case 0:
|
|
5008
|
+
options = { query: "dkim_selector=".concat(data.dkimSelector) };
|
|
5009
|
+
return [4 /*yield*/, this.request.put("/v3/domains/".concat(domain, "/dkim_selector"), {}, options)];
|
|
4763
5010
|
case 1:
|
|
4764
5011
|
res = _b.sent();
|
|
4765
5012
|
return [2 /*return*/, {
|
|
@@ -4777,7 +5024,8 @@ var DomainsClient = /** @class */ (function () {
|
|
|
4777
5024
|
*/
|
|
4778
5025
|
DomainsClient.prototype.updateWebPrefix = function (domain, data) {
|
|
4779
5026
|
this.logger.warn('"domains.updateWebPrefix" method is deprecated, please use domains.update to set new "web_prefix". Current method will be removed in the future releases.');
|
|
4780
|
-
|
|
5027
|
+
var options = { query: "web_prefix=".concat(data.webPrefix) };
|
|
5028
|
+
return this.request.put("/v3/domains/".concat(domain, "/web_prefix"), {}, options)
|
|
4781
5029
|
.then(function (res) { return res; });
|
|
4782
5030
|
};
|
|
4783
5031
|
return DomainsClient;
|
|
@@ -4934,12 +5182,12 @@ var StatsClient = /** @class */ (function () {
|
|
|
4934
5182
|
};
|
|
4935
5183
|
StatsClient.prototype.getDomain = function (domain, query) {
|
|
4936
5184
|
var searchParams = this.prepareSearchParams(query);
|
|
4937
|
-
return this.request.get(urljoin('/v3', domain, 'stats/total'), searchParams)
|
|
5185
|
+
return this.request.get(urljoin('/v3', domain, 'stats/total'), { searchParams: searchParams })
|
|
4938
5186
|
.then(this.parseStats);
|
|
4939
5187
|
};
|
|
4940
5188
|
StatsClient.prototype.getAccount = function (query) {
|
|
4941
5189
|
var searchParams = this.prepareSearchParams(query);
|
|
4942
|
-
return this.request.get('/v3/stats/total', searchParams)
|
|
5190
|
+
return this.request.get('/v3/stats/total', { searchParams: searchParams })
|
|
4943
5191
|
.then(this.parseStats);
|
|
4944
5192
|
};
|
|
4945
5193
|
return StatsClient;
|
|
@@ -5029,9 +5277,6 @@ var WhiteList = /** @class */ (function (_super) {
|
|
|
5029
5277
|
return WhiteList;
|
|
5030
5278
|
}(Suppression));
|
|
5031
5279
|
|
|
5032
|
-
var createOptions = {
|
|
5033
|
-
headers: { 'Content-Type': 'application/json' }
|
|
5034
|
-
};
|
|
5035
5280
|
var SuppressionClient = /** @class */ (function (_super) {
|
|
5036
5281
|
__extends(SuppressionClient, _super);
|
|
5037
5282
|
function SuppressionClient(request) {
|
|
@@ -5071,7 +5316,7 @@ var SuppressionClient = /** @class */ (function (_super) {
|
|
|
5071
5316
|
throw APIError.getUserDataError('Tag property should not be used for creating multiple unsubscribes.', 'Tag property can be used only if one unsubscribe provided as second argument of create method. Please use tags instead.');
|
|
5072
5317
|
}
|
|
5073
5318
|
return this.request
|
|
5074
|
-
.post(urljoin('v3', domain, 'unsubscribes'), JSON.stringify(data),
|
|
5319
|
+
.post(urljoin('v3', domain, 'unsubscribes'), JSON.stringify(data), { isApplicationJSON: true })
|
|
5075
5320
|
.then(this.prepareResponse);
|
|
5076
5321
|
}
|
|
5077
5322
|
if (data === null || data === void 0 ? void 0 : data.tags) {
|
|
@@ -5133,7 +5378,7 @@ var SuppressionClient = /** @class */ (function (_super) {
|
|
|
5133
5378
|
postData = __spreadArray([], data, true);
|
|
5134
5379
|
}
|
|
5135
5380
|
return this.request
|
|
5136
|
-
.post(urljoin('v3', domain, type), JSON.stringify(postData),
|
|
5381
|
+
.post(urljoin('v3', domain, type), JSON.stringify(postData), { isApplicationJSON: true })
|
|
5137
5382
|
.then(this.prepareResponse);
|
|
5138
5383
|
};
|
|
5139
5384
|
SuppressionClient.prototype.destroy = function (domain, type, address) {
|
|
@@ -5892,7 +6137,7 @@ var DomainTagsClient = /** @class */ (function (_super) {
|
|
|
5892
6137
|
.then(function (res) { return new DomainTag(res.body); });
|
|
5893
6138
|
};
|
|
5894
6139
|
DomainTagsClient.prototype.update = function (domain, tag, description) {
|
|
5895
|
-
return this.request.put(urljoin(this.baseRoute, domain, '/tags', tag), description)
|
|
6140
|
+
return this.request.put(urljoin(this.baseRoute, domain, '/tags', tag), { description: description })
|
|
5896
6141
|
.then(function (res) { return res.body; });
|
|
5897
6142
|
};
|
|
5898
6143
|
DomainTagsClient.prototype.destroy = function (domain, tag) {
|
|
@@ -6159,7 +6404,7 @@ var InboxPlacementsResultsClient = /** @class */ (function (_super) {
|
|
|
6159
6404
|
switch (_a.label) {
|
|
6160
6405
|
case 0:
|
|
6161
6406
|
queryData = this.prepareQueryData(query);
|
|
6162
|
-
return [4 /*yield*/, this.request.get('/v4/inbox/results', queryData)];
|
|
6407
|
+
return [4 /*yield*/, this.request.get('/v4/inbox/results', __assign({}, queryData))];
|
|
6163
6408
|
case 1:
|
|
6164
6409
|
response = _a.sent();
|
|
6165
6410
|
return [2 /*return*/, this.parseList(response)];
|
|
@@ -6305,10 +6550,12 @@ var IPRSharingClient = /** @class */ (function () {
|
|
|
6305
6550
|
};
|
|
6306
6551
|
IPRSharingClient.prototype.update = function (id, data) {
|
|
6307
6552
|
return __awaiter(this, void 0, void 0, function () {
|
|
6308
|
-
var response, result;
|
|
6553
|
+
var options, response, result;
|
|
6309
6554
|
return __generator(this, function (_a) {
|
|
6310
6555
|
switch (_a.label) {
|
|
6311
|
-
case 0:
|
|
6556
|
+
case 0:
|
|
6557
|
+
options = { query: "enabled=".concat(data.enabled) };
|
|
6558
|
+
return [4 /*yield*/, this.request.put("/v4/inbox/sharing/".concat(id), {}, options)];
|
|
6312
6559
|
case 1:
|
|
6313
6560
|
response = _a.sent();
|
|
6314
6561
|
result = this.prepareInboxPlacementsResultSharing(response.body.sharing);
|
|
@@ -6526,8 +6773,11 @@ var MailgunClient = /** @class */ (function () {
|
|
|
6526
6773
|
if (!config.key) {
|
|
6527
6774
|
throw new Error('Parameter "key" is required');
|
|
6528
6775
|
}
|
|
6776
|
+
if (config.useFetch && config.proxy) {
|
|
6777
|
+
throw new Error('Proxy can not be used with fetch provider');
|
|
6778
|
+
}
|
|
6529
6779
|
/** @internal */
|
|
6530
|
-
this.request = new Request
|
|
6780
|
+
this.request = new Request(config, formData);
|
|
6531
6781
|
var mailListsMembers = new MailListsMembers(this.request);
|
|
6532
6782
|
var domainCredentialsClient = new DomainCredentialsClient(this.request);
|
|
6533
6783
|
var domainTemplatesClient = new DomainTemplatesClient(this.request);
|