swell-js 4.1.0 → 4.1.2
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/dist/account.mjs +14 -2
- package/dist/api.mjs +4 -4
- package/dist/attributes.mjs +3 -3
- package/dist/cache.mjs +4 -4
- package/dist/card.mjs +4 -4
- package/dist/cart.mjs +12 -9
- package/dist/categories.mjs +3 -3
- package/dist/content.mjs +3 -3
- package/dist/cookie.mjs +3 -3
- package/dist/currency.mjs +7 -7
- package/dist/{find.fd7de00e.mjs → find.18f1ac6d.mjs} +1 -5
- package/dist/{index.78b6af02.mjs → index.f58acfb6.mjs} +81 -70
- package/dist/index.mjs +3 -3
- package/dist/locale.mjs +1 -1
- package/dist/payment.mjs +140 -47
- package/dist/products.mjs +5 -5
- package/dist/{round.a606b844.mjs → round.577a8441.mjs} +1 -1
- package/dist/settings.mjs +5 -5
- package/dist/subscriptions.mjs +3 -3
- package/dist/swell.cjs +333 -218
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +5928 -2102
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.mjs +3 -3
- package/package.json +17 -17
- package/types/account/camel.d.ts +6 -10
- package/types/account/index.d.ts +4 -3
- package/types/account/snake.d.ts +12 -9
- package/types/attribute/camel.d.ts +2 -4
- package/types/attribute/snake.d.ts +4 -3
- package/types/billing/camel.d.ts +14 -25
- package/types/billing/index.d.ts +5 -0
- package/types/billing/snake.d.ts +30 -21
- package/types/card/camel.d.ts +7 -10
- package/types/card/index.d.ts +4 -3
- package/types/card/snake.d.ts +6 -4
- package/types/cart/camel.d.ts +24 -16
- package/types/cart/index.d.ts +23 -1
- package/types/cart/snake.d.ts +57 -22
- package/types/category/camel.d.ts +2 -4
- package/types/category/snake.d.ts +10 -7
- package/types/content/camel.d.ts +3 -7
- package/types/content/index.d.ts +1 -0
- package/types/content/snake.d.ts +6 -3
- package/types/coupon/camel.d.ts +2 -4
- package/types/coupon/snake.d.ts +9 -11
- package/types/currency/camel.d.ts +9 -10
- package/types/currency/index.d.ts +3 -0
- package/types/discount/camel.d.ts +14 -5
- package/types/discount/index.d.ts +16 -2
- package/types/discount/snake.d.ts +34 -8
- package/types/giftcard/camel.d.ts +6 -0
- package/types/giftcard/index.d.ts +5 -0
- package/types/giftcard/snake.d.ts +39 -0
- package/types/index.d.ts +324 -154
- package/types/invoice/camel.d.ts +2 -4
- package/types/invoice/snake.d.ts +16 -10
- package/types/order/camel.d.ts +7 -16
- package/types/order/index.d.ts +1 -0
- package/types/order/snake.d.ts +35 -21
- package/types/payment/camel.d.ts +17 -25
- package/types/payment/index.d.ts +8 -0
- package/types/payment/snake.d.ts +57 -34
- package/types/product/camel.d.ts +13 -36
- package/types/product/index.d.ts +8 -8
- package/types/product/snake.d.ts +37 -30
- package/types/promotion/camel.d.ts +6 -5
- package/types/promotion/index.d.ts +6 -2
- package/types/promotion/snake.d.ts +20 -8
- package/types/purchase_link/camel.d.ts +3 -9
- package/types/purchase_link/index.d.ts +3 -7
- package/types/purchase_link/snake.d.ts +9 -12
- package/types/refund/camel.d.ts +2 -4
- package/types/shipment_rating/camel.d.ts +4 -7
- package/types/shipment_rating/index.d.ts +1 -0
- package/types/shipment_rating/snake.d.ts +3 -1
- package/types/subscription/camel.d.ts +13 -8
- package/types/subscription/index.d.ts +17 -3
- package/types/subscription/snake.d.ts +38 -28
package/dist/account.mjs
CHANGED
|
@@ -77,7 +77,7 @@ function methods(request) {
|
|
|
77
77
|
},
|
|
78
78
|
|
|
79
79
|
listOrders(query) {
|
|
80
|
-
return request('get',
|
|
80
|
+
return request('get', '/account/orders', query);
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
getOrder(id) {
|
|
@@ -85,14 +85,26 @@ function methods(request) {
|
|
|
85
85
|
},
|
|
86
86
|
|
|
87
87
|
// Deprecated methods
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated use `listAddresses` instead
|
|
91
|
+
*/
|
|
88
92
|
getAddresses(query) {
|
|
89
93
|
return request('get', '/account/addresses', query);
|
|
90
94
|
},
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated use `listCards` instead
|
|
98
|
+
*/
|
|
91
99
|
getCards(query) {
|
|
92
100
|
return request('get', '/account/cards', query);
|
|
93
101
|
},
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated use `listOrders` instead
|
|
105
|
+
*/
|
|
94
106
|
getOrders(query) {
|
|
95
|
-
return request('get',
|
|
107
|
+
return request('get', '/account/orders', query);
|
|
96
108
|
},
|
|
97
109
|
};
|
|
98
110
|
}
|
package/dist/api.mjs
CHANGED
|
@@ -7,15 +7,15 @@ import methods$5 from './products.mjs';
|
|
|
7
7
|
import methods$6 from './categories.mjs';
|
|
8
8
|
import methods$7 from './attributes.mjs';
|
|
9
9
|
import methods$8 from './subscriptions.mjs';
|
|
10
|
-
import { d as defaultMethods, z as trimEnd, A as utils, B as trimStart, C as trimBoth, t as toSnake, D as stringifyQuery, E as base64Encode, a as toCamel, F as setOptions } from './index.
|
|
10
|
+
import { d as defaultMethods, z as trimEnd, A as utils, B as trimStart, C as trimBoth, t as toSnake, D as stringifyQuery, E as base64Encode, a as toCamel, F as setOptions } from './index.f58acfb6.mjs';
|
|
11
11
|
import methods$9 from './content.mjs';
|
|
12
12
|
import methods$a from './settings.mjs';
|
|
13
13
|
import PaymentController from './payment.mjs';
|
|
14
14
|
import methods$b from './locale.mjs';
|
|
15
15
|
import methods$c from './currency.mjs';
|
|
16
16
|
import 'qs';
|
|
17
|
-
import './find.
|
|
18
|
-
import './round.
|
|
17
|
+
import './find.18f1ac6d.mjs';
|
|
18
|
+
import './round.577a8441.mjs';
|
|
19
19
|
import 'deepmerge';
|
|
20
20
|
import 'fast-case';
|
|
21
21
|
|
|
@@ -135,7 +135,7 @@ const options = {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
const api = {
|
|
138
|
-
version: '4.1.
|
|
138
|
+
version: '4.1.2',
|
|
139
139
|
options,
|
|
140
140
|
request,
|
|
141
141
|
|
package/dist/attributes.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as defaultMethods } from './index.
|
|
1
|
+
import { d as defaultMethods } from './index.f58acfb6.mjs';
|
|
2
2
|
import cacheApi from './cache.mjs';
|
|
3
3
|
import 'qs';
|
|
4
|
-
import './find.
|
|
5
|
-
import './round.
|
|
4
|
+
import './find.18f1ac6d.mjs';
|
|
5
|
+
import './round.577a8441.mjs';
|
|
6
6
|
import 'deepmerge';
|
|
7
7
|
import 'fast-case';
|
|
8
8
|
|
package/dist/cache.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.
|
|
2
|
-
import { g as get } from './find.
|
|
1
|
+
import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.f58acfb6.mjs';
|
|
2
|
+
import { g as get } from './find.18f1ac6d.mjs';
|
|
3
3
|
import 'qs';
|
|
4
|
-
import './round.
|
|
4
|
+
import './round.577a8441.mjs';
|
|
5
5
|
import 'deepmerge';
|
|
6
6
|
import 'fast-case';
|
|
7
7
|
|
|
@@ -53,7 +53,7 @@ const cacheApi = {
|
|
|
53
53
|
set(details) {
|
|
54
54
|
this.debug('cache.set', ...arguments);
|
|
55
55
|
let { model, id, path, value } = details;
|
|
56
|
-
let { data = {}, record
|
|
56
|
+
let { data = {}, record } = this.values(details);
|
|
57
57
|
|
|
58
58
|
if (id === null) {
|
|
59
59
|
return;
|
package/dist/card.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as toSnake, v as vaultRequest } from './index.
|
|
1
|
+
import { t as toSnake, v as vaultRequest } from './index.f58acfb6.mjs';
|
|
2
2
|
import 'qs';
|
|
3
|
-
import './find.
|
|
4
|
-
import './round.
|
|
3
|
+
import './find.18f1ac6d.mjs';
|
|
4
|
+
import './round.577a8441.mjs';
|
|
5
5
|
import 'deepmerge';
|
|
6
6
|
import 'fast-case';
|
|
7
7
|
|
|
@@ -64,7 +64,7 @@ const cardApi = {
|
|
|
64
64
|
return value;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const parts = new String(value).split(/[\s
|
|
67
|
+
const parts = new String(value).split(/[\s/-]+/, 2);
|
|
68
68
|
const month = parts[0];
|
|
69
69
|
let year = parts[1];
|
|
70
70
|
|
package/dist/cart.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import 'qs';
|
|
2
|
-
import { c as cloneDeep } from './index.
|
|
2
|
+
import { c as cloneDeep } from './index.f58acfb6.mjs';
|
|
3
3
|
import 'deepmerge';
|
|
4
4
|
import 'fast-case';
|
|
5
5
|
import { cleanProductOptions } from './products.mjs';
|
|
6
|
-
import './find.
|
|
7
|
-
import './round.
|
|
6
|
+
import './find.18f1ac6d.mjs';
|
|
7
|
+
import './round.577a8441.mjs';
|
|
8
8
|
import './cache.mjs';
|
|
9
9
|
import './attributes.mjs';
|
|
10
10
|
|
|
@@ -38,9 +38,12 @@ function methods(request, options) {
|
|
|
38
38
|
|
|
39
39
|
const { handler, resolve, reject } = this.pendingRequests.shift();
|
|
40
40
|
|
|
41
|
-
return Promise.resolve()
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
return Promise.resolve()
|
|
42
|
+
.then(handler)
|
|
43
|
+
.then(resolve, reject)
|
|
44
|
+
.finally(() => {
|
|
45
|
+
this.nextRequest();
|
|
46
|
+
});
|
|
44
47
|
},
|
|
45
48
|
|
|
46
49
|
async requestStateSync(handler) {
|
|
@@ -134,7 +137,7 @@ function methods(request, options) {
|
|
|
134
137
|
if (options.updateCart) {
|
|
135
138
|
return options.updateCart(input);
|
|
136
139
|
}
|
|
137
|
-
return this.requestStateChange('put',
|
|
140
|
+
return this.requestStateChange('put', '/cart', data);
|
|
138
141
|
},
|
|
139
142
|
|
|
140
143
|
applyCoupon(code) {
|
|
@@ -173,11 +176,11 @@ function methods(request, options) {
|
|
|
173
176
|
async getOrder(checkoutId = undefined) {
|
|
174
177
|
let result;
|
|
175
178
|
if (checkoutId) {
|
|
176
|
-
result = await request('get',
|
|
179
|
+
result = await request('get', '/cart/order', {
|
|
177
180
|
checkout_id: checkoutId,
|
|
178
181
|
});
|
|
179
182
|
} else {
|
|
180
|
-
result = await request('get',
|
|
183
|
+
result = await request('get', '/cart/order');
|
|
181
184
|
}
|
|
182
185
|
this.order = result;
|
|
183
186
|
return result;
|
package/dist/categories.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as defaultMethods } from './index.
|
|
1
|
+
import { d as defaultMethods } from './index.f58acfb6.mjs';
|
|
2
2
|
import cacheApi from './cache.mjs';
|
|
3
3
|
import 'qs';
|
|
4
|
-
import './find.
|
|
5
|
-
import './round.
|
|
4
|
+
import './find.18f1ac6d.mjs';
|
|
5
|
+
import './round.577a8441.mjs';
|
|
6
6
|
import 'deepmerge';
|
|
7
7
|
import 'fast-case';
|
|
8
8
|
|
package/dist/content.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import cacheApi from './cache.mjs';
|
|
2
|
-
import './index.
|
|
2
|
+
import './index.f58acfb6.mjs';
|
|
3
3
|
import 'qs';
|
|
4
|
-
import './find.
|
|
5
|
-
import './round.
|
|
4
|
+
import './find.18f1ac6d.mjs';
|
|
5
|
+
import './round.577a8441.mjs';
|
|
6
6
|
import 'deepmerge';
|
|
7
7
|
import 'fast-case';
|
|
8
8
|
|
package/dist/cookie.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as isServer } from './index.
|
|
1
|
+
import { i as isServer } from './index.f58acfb6.mjs';
|
|
2
2
|
import 'qs';
|
|
3
|
-
import './find.
|
|
4
|
-
import './round.
|
|
3
|
+
import './find.18f1ac6d.mjs';
|
|
4
|
+
import './round.577a8441.mjs';
|
|
5
5
|
import 'deepmerge';
|
|
6
6
|
import 'fast-case';
|
|
7
7
|
|
package/dist/currency.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'qs';
|
|
2
|
-
import { f as find, g as get } from './find.
|
|
3
|
-
import { r as round } from './round.
|
|
2
|
+
import { f as find, g as get } from './find.18f1ac6d.mjs';
|
|
3
|
+
import { r as round } from './round.577a8441.mjs';
|
|
4
4
|
import 'deepmerge';
|
|
5
5
|
import 'fast-case';
|
|
6
6
|
|
|
@@ -25,7 +25,8 @@ function methods(request, opt) {
|
|
|
25
25
|
selected() {
|
|
26
26
|
if (!this.code) {
|
|
27
27
|
this.set(
|
|
28
|
-
opt.getCookie('swell-currency') ||
|
|
28
|
+
opt.getCookie('swell-currency') ||
|
|
29
|
+
opt.api.settings.get('store.currency'),
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -69,8 +70,7 @@ function methods(request, opt) {
|
|
|
69
70
|
const formatCode = params.code || code;
|
|
70
71
|
const formatRate = params.rate || rate;
|
|
71
72
|
const formatLocale = params.locale || this.locale;
|
|
72
|
-
const formatDecimals =
|
|
73
|
-
'decimals' in params ? params.decimals : decimals;
|
|
73
|
+
const formatDecimals = 'decimals' in params ? params.decimals : decimals;
|
|
74
74
|
const { convert = true } = params;
|
|
75
75
|
|
|
76
76
|
let formatAmount = amount;
|
|
@@ -171,8 +171,8 @@ function methods(request, opt) {
|
|
|
171
171
|
? 'up'
|
|
172
172
|
: 'down'
|
|
173
173
|
: diff <= -0.5
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
? 'down'
|
|
175
|
+
: 'up'
|
|
176
176
|
: config.round;
|
|
177
177
|
|
|
178
178
|
switch (direction) {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
const global$1 = (typeof global !== "undefined" ? global :
|
|
2
|
-
typeof self !== "undefined" ? self :
|
|
3
|
-
typeof window !== "undefined" ? window : {});
|
|
4
|
-
|
|
5
1
|
/** Detect free variable `global` from Node.js. */
|
|
6
|
-
var freeGlobal = typeof global
|
|
2
|
+
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
7
3
|
|
|
8
4
|
const freeGlobal$1 = freeGlobal;
|
|
9
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { stringify } from 'qs';
|
|
2
|
-
import { c as getNative, e as eq, i as isObject$1, d as castPath, h as toKey, j as isIndex, k as baseFindIndex, S as Set, s as setToArray, l as SetCache, m as cacheHas, n as baseGet, o as hasIn, p as Symbol$1, q as isArray, u as isArguments, v as arrayPush, w as identity, x as keys, y as isPrototype, z as isArrayLike, A as arrayLikeKeys, r as root, B as getSymbols, C as overArg, D as stubArray, E as baseGetAllKeys, U as Uint8Array, F as isObjectLike, G as getTag, H as nodeUtil, I as baseUnary, J as isBuffer, K as Stack, L as getAllKeys, b as toString, M as baseIsEqual, N as isTypedArray, O as baseKeys, f as find, P as findIndex, g as get, t as toNumber } from './find.
|
|
3
|
-
import { r as round } from './round.
|
|
2
|
+
import { c as getNative, e as eq, i as isObject$1, d as castPath, h as toKey, j as isIndex, k as baseFindIndex, S as Set, s as setToArray, l as SetCache, m as cacheHas, n as baseGet, o as hasIn, p as Symbol$1, q as isArray, u as isArguments, v as arrayPush, w as identity, x as keys, y as isPrototype, z as isArrayLike, A as arrayLikeKeys, r as root, B as getSymbols, C as overArg, D as stubArray, E as baseGetAllKeys, U as Uint8Array, F as isObjectLike, G as getTag, H as nodeUtil, I as baseUnary, J as isBuffer, K as Stack, L as getAllKeys, b as toString, M as baseIsEqual, N as isTypedArray, O as baseKeys, f as find, P as findIndex, g as get, t as toNumber } from './find.18f1ac6d.mjs';
|
|
3
|
+
import { r as round } from './round.577a8441.mjs';
|
|
4
4
|
import deepmerge from 'deepmerge';
|
|
5
5
|
import { camelize, decamelize, camelizeKeys, decamelizeKeys } from 'fast-case';
|
|
6
6
|
|
|
@@ -1469,36 +1469,47 @@ function isEmpty(value) {
|
|
|
1469
1469
|
return true;
|
|
1470
1470
|
}
|
|
1471
1471
|
|
|
1472
|
+
/* global Buffer */
|
|
1473
|
+
|
|
1472
1474
|
const LOADING_SCRIPTS = {};
|
|
1473
1475
|
|
|
1474
1476
|
let options = {};
|
|
1475
1477
|
|
|
1476
|
-
function
|
|
1478
|
+
function arrayMerge(target, source, options) {
|
|
1479
|
+
const destination = target.slice();
|
|
1480
|
+
source.forEach((item, index) => {
|
|
1481
|
+
if (typeof destination[index] === 'undefined') {
|
|
1482
|
+
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
|
|
1483
|
+
} else if (options.isMergeableObject(item)) {
|
|
1484
|
+
destination[index] = merge(target[index], item, options);
|
|
1485
|
+
} else if (target.indexOf(item) === -1) {
|
|
1486
|
+
destination.push(item);
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
return destination;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* @template T
|
|
1494
|
+
* @param {Partial<T>} x
|
|
1495
|
+
* @param {Partial<T>} y
|
|
1496
|
+
* @param {deepmerge.Options} [opt]
|
|
1497
|
+
* @returns {T}
|
|
1498
|
+
*/
|
|
1499
|
+
function merge(x, y, opt) {
|
|
1477
1500
|
if (!y || typeof y !== 'object') {
|
|
1478
1501
|
return x;
|
|
1479
1502
|
}
|
|
1503
|
+
|
|
1480
1504
|
if (!x || typeof x !== 'object') {
|
|
1481
1505
|
return x;
|
|
1482
1506
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
if (typeof destination[index] === 'undefined') {
|
|
1487
|
-
destination[index] = options.cloneUnlessOtherwiseSpecified(
|
|
1488
|
-
item,
|
|
1489
|
-
options,
|
|
1490
|
-
);
|
|
1491
|
-
} else if (options.isMergeableObject(item)) {
|
|
1492
|
-
destination[index] = merge(target[index], item, options);
|
|
1493
|
-
} else if (target.indexOf(item) === -1) {
|
|
1494
|
-
destination.push(item);
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
return destination;
|
|
1507
|
+
|
|
1508
|
+
if (!opt) {
|
|
1509
|
+
opt = { arrayMerge };
|
|
1498
1510
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
});
|
|
1511
|
+
|
|
1512
|
+
return deepmerge(x, y, opt);
|
|
1502
1513
|
}
|
|
1503
1514
|
|
|
1504
1515
|
function setOptions(optns) {
|
|
@@ -1590,64 +1601,62 @@ function defaultMethods(request, uri, methods) {
|
|
|
1590
1601
|
};
|
|
1591
1602
|
}
|
|
1592
1603
|
|
|
1593
|
-
async function vaultRequest(method, url, data
|
|
1594
|
-
const vaultUrl = options
|
|
1595
|
-
const
|
|
1596
|
-
const requestId = vaultRequestId();
|
|
1597
|
-
const callback = `swell_vault_response_${requestId}`;
|
|
1598
|
-
|
|
1599
|
-
data = {
|
|
1604
|
+
async function vaultRequest(method, url, data) {
|
|
1605
|
+
const { vaultUrl, timeout, key } = options;
|
|
1606
|
+
const requestData = {
|
|
1600
1607
|
$jsonp: {
|
|
1601
1608
|
method,
|
|
1602
|
-
callback,
|
|
1609
|
+
callback: 'none',
|
|
1603
1610
|
},
|
|
1604
1611
|
$data: data,
|
|
1605
|
-
$key:
|
|
1612
|
+
$key: key,
|
|
1606
1613
|
};
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
window[callback] = (result) => {
|
|
1623
|
-
clearTimeout(errorTimeout);
|
|
1624
|
-
if (result && result.$error) {
|
|
1625
|
-
const err = new Error(result.$error);
|
|
1626
|
-
err.code = 'request_error';
|
|
1627
|
-
err.status = result.$status;
|
|
1628
|
-
reject(err);
|
|
1629
|
-
} else if (!result || result.$status >= 300) {
|
|
1630
|
-
const err = new Error(
|
|
1631
|
-
'A connection error occurred while making the request',
|
|
1614
|
+
const requestUrl = `${trimEnd(vaultUrl)}/${trimStart(url)}?${serializeData(
|
|
1615
|
+
requestData,
|
|
1616
|
+
)}`;
|
|
1617
|
+
|
|
1618
|
+
const abortController = new AbortController();
|
|
1619
|
+
const id = setTimeout(() => abortController.abort(), timeout);
|
|
1620
|
+
|
|
1621
|
+
const result = await fetch(requestUrl, {
|
|
1622
|
+
signal: abortController.signal,
|
|
1623
|
+
})
|
|
1624
|
+
.then((response) => response.json())
|
|
1625
|
+
.catch((error) => {
|
|
1626
|
+
if (error.name === 'AbortError') {
|
|
1627
|
+
const timeoutError = new Error(
|
|
1628
|
+
`Request timed out after ${timeout / 1000} seconds`,
|
|
1632
1629
|
);
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
resolve(result.$data);
|
|
1630
|
+
|
|
1631
|
+
timeoutError.status = 500;
|
|
1632
|
+
|
|
1633
|
+
throw timeoutError;
|
|
1638
1634
|
}
|
|
1639
|
-
delete window[callback];
|
|
1640
|
-
script.parentNode.removeChild(script);
|
|
1641
|
-
};
|
|
1642
1635
|
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1636
|
+
throw new Error(error.message);
|
|
1637
|
+
});
|
|
1638
|
+
|
|
1639
|
+
clearTimeout(id);
|
|
1640
|
+
|
|
1641
|
+
if (result?.$error) {
|
|
1642
|
+
const requestError = new Error(result.$error);
|
|
1646
1643
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1644
|
+
requestError.code = 'request_error';
|
|
1645
|
+
requestError.status = result.$status;
|
|
1646
|
+
|
|
1647
|
+
throw requestError;
|
|
1648
|
+
} else if (!result || result.$status >= 300) {
|
|
1649
|
+
const connectionError = new Error(
|
|
1650
|
+
'A connection error occurred while making the request',
|
|
1651
|
+
);
|
|
1652
|
+
|
|
1653
|
+
connectionError.code = 'connection_error';
|
|
1654
|
+
connectionError.status = result?.$status;
|
|
1655
|
+
|
|
1656
|
+
throw connectionError;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
return result.$data;
|
|
1651
1660
|
}
|
|
1652
1661
|
|
|
1653
1662
|
function serializeData(data) {
|
|
@@ -1666,7 +1675,9 @@ function serializeData(data) {
|
|
|
1666
1675
|
}
|
|
1667
1676
|
return s.join('&').replace(' ', '+');
|
|
1668
1677
|
}
|
|
1678
|
+
|
|
1669
1679
|
const rbracket = /\[\]$/;
|
|
1680
|
+
|
|
1670
1681
|
function buildParams(key, obj, add) {
|
|
1671
1682
|
let name;
|
|
1672
1683
|
if (obj instanceof Array) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { default } from './api.mjs';
|
|
2
2
|
import './card.mjs';
|
|
3
|
-
import './index.
|
|
3
|
+
import './index.f58acfb6.mjs';
|
|
4
4
|
import 'qs';
|
|
5
|
-
import './find.
|
|
6
|
-
import './round.
|
|
5
|
+
import './find.18f1ac6d.mjs';
|
|
6
|
+
import './round.577a8441.mjs';
|
|
7
7
|
import 'deepmerge';
|
|
8
8
|
import 'fast-case';
|
|
9
9
|
import './cookie.mjs';
|
package/dist/locale.mjs
CHANGED