swell-js 5.8.2 → 5.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.mjs +53 -42
- package/dist/attributes.mjs +4 -6
- package/dist/cache.mjs +141 -140
- package/dist/card.mjs +149 -148
- package/dist/cart.mjs +3 -5
- package/dist/categories.mjs +4 -6
- package/dist/content.mjs +1 -9
- package/dist/cookie.mjs +3 -4
- package/dist/currency.mjs +2 -3
- package/dist/{find.18f1ac6d.mjs → find.ba551a2e.mjs} +125 -5
- package/dist/{index.a8d5c125.mjs → index.3949a230.mjs} +4 -21
- package/dist/index.mjs +3 -4
- package/dist/locale.mjs +1 -2
- package/dist/payment.mjs +11 -14
- package/dist/products.mjs +10 -15
- package/dist/{round.577a8441.mjs → round.c68b8be5.mjs} +1 -1
- package/dist/settings.mjs +3 -4
- package/dist/subscriptions.mjs +4 -6
- package/dist/swell.cjs +439 -323
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +13676 -18860
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.mjs +3 -4
- package/package.json +15 -8
- package/types/account/camel.ts +10 -7
- package/types/account/index.ts +3 -3
- package/types/account/snake.ts +5 -5
- package/types/attribute/camel.ts +7 -4
- package/types/attribute/index.ts +3 -3
- package/types/attribute/snake.ts +2 -2
- package/types/billing/camel.ts +4 -4
- package/types/billing/index.ts +2 -2
- package/types/billing/snake.ts +1 -1
- package/types/card/camel.ts +5 -5
- package/types/card/index.ts +3 -3
- package/types/card/snake.ts +3 -3
- package/types/cart/camel.ts +17 -14
- package/types/cart/index.ts +3 -3
- package/types/cart/snake.ts +12 -12
- package/types/category/camel.ts +4 -4
- package/types/category/index.ts +3 -3
- package/types/category/snake.ts +2 -2
- package/types/content/camel.ts +5 -5
- package/types/content/index.ts +3 -3
- package/types/content/snake.ts +3 -3
- package/types/coupon/camel.ts +4 -4
- package/types/coupon/index.ts +2 -2
- package/types/coupon/snake.ts +2 -2
- package/types/currency/camel.ts +2 -2
- package/types/currency/index.ts +3 -3
- package/types/discount/camel.ts +3 -3
- package/types/discount/index.ts +2 -2
- package/types/giftcard/camel.ts +10 -7
- package/types/giftcard/index.ts +2 -2
- package/types/giftcard/snake.ts +5 -5
- package/types/index.d.cts +207 -0
- package/types/index.d.ts +83 -56
- package/types/invoice/camel.ts +10 -10
- package/types/invoice/index.ts +3 -3
- package/types/invoice/snake.ts +8 -8
- package/types/order/camel.ts +18 -15
- package/types/order/index.ts +3 -3
- package/types/order/snake.ts +18 -13
- package/types/payment/camel.ts +13 -10
- package/types/payment/index.ts +3 -3
- package/types/payment/snake.ts +8 -8
- package/types/product/camel.ts +5 -5
- package/types/product/index.ts +4 -4
- package/types/product/snake.ts +3 -3
- package/types/promotion/camel.ts +6 -6
- package/types/promotion/index.ts +2 -2
- package/types/promotion/snake.ts +4 -4
- package/types/purchase_link/camel.ts +10 -7
- package/types/purchase_link/index.ts +2 -2
- package/types/purchase_link/snake.ts +5 -5
- package/types/refund/camel.ts +6 -6
- package/types/refund/index.ts +2 -2
- package/types/refund/snake.ts +4 -4
- package/types/shipment_rating/camel.ts +3 -3
- package/types/shipment_rating/index.ts +2 -2
- package/types/subscription/camel.ts +16 -13
- package/types/subscription/index.ts +3 -3
- package/types/subscription/snake.ts +16 -11
- package/types/user/camel.ts +2 -2
- package/types/user/index.ts +3 -3
- package/types/user/snake.ts +1 -1
package/dist/card.mjs
CHANGED
|
@@ -1,174 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
3
|
-
import './
|
|
4
|
-
import './round.577a8441.mjs';
|
|
1
|
+
import { b as toSnake, v as vaultRequest } from './index.3949a230.mjs';
|
|
2
|
+
import './find.ba551a2e.mjs';
|
|
3
|
+
import './round.c68b8be5.mjs';
|
|
5
4
|
import 'deepmerge';
|
|
6
5
|
import 'fast-case';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const card = toSnake(data);
|
|
18
|
-
if (!card.nonce) {
|
|
19
|
-
if (!this.validateNumber(card.number)) {
|
|
20
|
-
error = 'Card number appears to be invalid';
|
|
21
|
-
code = 'invalid_card_number';
|
|
22
|
-
param = 'number';
|
|
7
|
+
function methods(options) {
|
|
8
|
+
return {
|
|
9
|
+
async createToken(data) {
|
|
10
|
+
let error = null;
|
|
11
|
+
let code = null;
|
|
12
|
+
let param = null;
|
|
13
|
+
if (!data) {
|
|
14
|
+
error = 'Card details are missing in `swell.card.createToken(card)`';
|
|
15
|
+
param = '';
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
card.
|
|
27
|
-
|
|
17
|
+
const card = toSnake(data);
|
|
18
|
+
if (!card.nonce) {
|
|
19
|
+
if (!this.validateNumber(card.number)) {
|
|
20
|
+
error = 'Card number appears to be invalid';
|
|
21
|
+
code = 'invalid_card_number';
|
|
22
|
+
param = 'number';
|
|
23
|
+
}
|
|
24
|
+
if (card.exp) {
|
|
25
|
+
const exp = this.expiry(card.exp);
|
|
26
|
+
card.exp_month = exp.month;
|
|
27
|
+
card.exp_year = exp.year;
|
|
28
|
+
}
|
|
29
|
+
if (!this.validateExpiry(card.exp_month, card.exp_year)) {
|
|
30
|
+
error = 'Card expiry appears to be invalid';
|
|
31
|
+
code = 'invalid_card_expiry';
|
|
32
|
+
param = 'exp_month';
|
|
33
|
+
}
|
|
34
|
+
if (!this.validateCVC(card.cvc)) {
|
|
35
|
+
error = 'Card CVC code appears to be invalid';
|
|
36
|
+
code = 'invalid_card_cvc';
|
|
37
|
+
param = 'exp_cvc';
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
|
|
41
|
+
if (error) {
|
|
42
|
+
const err = new Error(error);
|
|
43
|
+
err.code = code || 'invalid_card';
|
|
44
|
+
err.status = 402;
|
|
45
|
+
err.param = param;
|
|
46
|
+
throw err;
|
|
33
47
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
|
|
49
|
+
// Get a token from the vault
|
|
50
|
+
const result = await vaultRequest('post', '/tokens', card, options);
|
|
51
|
+
if (result.errors) {
|
|
52
|
+
const param = Object.keys(result.errors)[0];
|
|
53
|
+
const err = new Error(result.errors[param].message || 'Unknown error');
|
|
54
|
+
err.code = 'vault_error';
|
|
55
|
+
err.status = 402;
|
|
56
|
+
err.param = param;
|
|
57
|
+
throw err;
|
|
38
58
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
err.param = param;
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Get a token from the vault
|
|
50
|
-
const result = await vaultRequest('post', '/tokens', card);
|
|
51
|
-
if (result.errors) {
|
|
52
|
-
const param = Object.keys(result.errors)[0];
|
|
53
|
-
const err = new Error(result.errors[param].message || 'Unknown error');
|
|
54
|
-
err.code = 'vault_error';
|
|
55
|
-
err.status = 402;
|
|
56
|
-
err.param = param;
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
expiry(value) {
|
|
63
|
-
if (value && value.month && value.year) {
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const parts = new String(value).split(/[\s/-]+/, 2);
|
|
68
|
-
const month = parts[0];
|
|
69
|
-
|
|
70
|
-
const currentYear = new Date().getUTCFullYear().toString();
|
|
71
|
-
let strYear = parts[1];
|
|
72
|
-
|
|
73
|
-
if (strYear.length < currentYear.length) {
|
|
74
|
-
let fullYear =
|
|
75
|
-
currentYear.slice(0, currentYear.length - strYear.length) + strYear;
|
|
76
|
-
|
|
77
|
-
// If the expiration year is less than the current year,
|
|
78
|
-
// then the expiration year is in the next century.
|
|
79
|
-
if (fullYear < currentYear) {
|
|
80
|
-
let year = Number(fullYear);
|
|
81
|
-
year += 10 ** strYear.length;
|
|
82
|
-
fullYear = year.toString();
|
|
59
|
+
return result;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
expiry(value) {
|
|
63
|
+
if (value && value.month && value.year) {
|
|
64
|
+
return value;
|
|
83
65
|
}
|
|
84
66
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
t[30] = t[36] = t[38] = t[39] = 'Diners Club';
|
|
102
|
-
return t;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
type(num) {
|
|
106
|
-
return this.types()[num.slice(0, 2)] || 'Unknown';
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
luhnCheck(num) {
|
|
110
|
-
const numbers = String(num);
|
|
111
|
-
let odd = false;
|
|
112
|
-
let sum = 0;
|
|
113
|
-
|
|
114
|
-
for (let i = numbers.length - 1; i >= 0; --i) {
|
|
115
|
-
let digit = Number.parseInt(numbers[i], 10);
|
|
116
|
-
|
|
117
|
-
if (odd) {
|
|
118
|
-
digit *= 2;
|
|
119
|
-
|
|
120
|
-
if (digit > 9) {
|
|
121
|
-
digit -= 9;
|
|
67
|
+
const parts = new String(value).split(/[\s/-]+/, 2);
|
|
68
|
+
const month = parts[0];
|
|
69
|
+
|
|
70
|
+
const currentYear = new Date().getUTCFullYear().toString();
|
|
71
|
+
let strYear = parts[1];
|
|
72
|
+
|
|
73
|
+
if (strYear.length < currentYear.length) {
|
|
74
|
+
let fullYear =
|
|
75
|
+
currentYear.slice(0, currentYear.length - strYear.length) + strYear;
|
|
76
|
+
|
|
77
|
+
// If the expiration year is less than the current year,
|
|
78
|
+
// then the expiration year is in the next century.
|
|
79
|
+
if (fullYear < currentYear) {
|
|
80
|
+
let year = Number(fullYear);
|
|
81
|
+
year += 10 ** strYear.length;
|
|
82
|
+
fullYear = year.toString();
|
|
122
83
|
}
|
|
84
|
+
|
|
85
|
+
strYear = fullYear;
|
|
123
86
|
}
|
|
124
87
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
88
|
+
return {
|
|
89
|
+
month: Number.parseInt(month, 10),
|
|
90
|
+
year: Number.parseInt(strYear, 10),
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
types() {
|
|
95
|
+
let t = {};
|
|
96
|
+
for (let e = 40; e <= 49; ++e) t[e] = 'Visa';
|
|
97
|
+
for (let e = 50; e <= 59; ++e) t[e] = 'MasterCard';
|
|
98
|
+
t[34] = t[37] = 'American Express';
|
|
99
|
+
t[60] = t[62] = t[64] = t[65] = 'Discover';
|
|
100
|
+
t[35] = 'JCB';
|
|
101
|
+
t[30] = t[36] = t[38] = t[39] = 'Diners Club';
|
|
102
|
+
return t;
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
type(num) {
|
|
106
|
+
return this.types()[num.slice(0, 2)] || 'Unknown';
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
luhnCheck(num) {
|
|
110
|
+
const numbers = String(num);
|
|
111
|
+
let odd = false;
|
|
112
|
+
let sum = 0;
|
|
113
|
+
|
|
114
|
+
for (let i = numbers.length - 1; i >= 0; --i) {
|
|
115
|
+
let digit = Number.parseInt(numbers[i], 10);
|
|
116
|
+
|
|
117
|
+
if (odd) {
|
|
118
|
+
digit *= 2;
|
|
119
|
+
|
|
120
|
+
if (digit > 9) {
|
|
121
|
+
digit -= 9;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
sum += digit;
|
|
126
|
+
odd = !odd;
|
|
127
|
+
}
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
return sum % 10 === 0;
|
|
130
|
+
},
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
validateNumber(num) {
|
|
133
|
+
num = String(num).replace(/\s+|-/g, '');
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
return num.length >= 10 && num.length <= 16 && this.luhnCheck(num);
|
|
136
|
+
},
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
validateExpiry(month, year) {
|
|
139
|
+
month = String(month).trim();
|
|
140
|
+
year = String(year).trim();
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
if (!/^\d+$/.test(month) || !/^\d+$/.test(year)) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
const numMonth = Number.parseInt(month, 10);
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
if (numMonth <= 0 || numMonth > 12) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
const date = new Date(year, month);
|
|
153
|
+
date.setMonth(date.getMonth() - 1);
|
|
154
|
+
date.setMonth(date.getMonth() + 1, 1);
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
const diff = date.getTime() - Date.now();
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
// The card has expired
|
|
159
|
+
if (diff < 0) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
// The card's validity period must not exceed 50 years from the current time.
|
|
164
|
+
return Math.round(diff / 31_557_600_000) < 50;
|
|
165
|
+
},
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
validateCVC(val) {
|
|
168
|
+
val = String(val).trim();
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
170
|
+
return /^\d+$/.test(val) && val.length >= 3 && val.length <= 4;
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
173
174
|
|
|
174
|
-
export {
|
|
175
|
+
export { methods as default };
|
package/dist/cart.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import { c as cloneDeep } from './index.
|
|
1
|
+
import './find.ba551a2e.mjs';
|
|
2
|
+
import { c as cloneDeep } from './index.3949a230.mjs';
|
|
3
3
|
import 'deepmerge';
|
|
4
4
|
import 'fast-case';
|
|
5
5
|
import { cleanProductOptions } from './products.mjs';
|
|
6
|
-
import './
|
|
7
|
-
import './round.577a8441.mjs';
|
|
8
|
-
import './cache.mjs';
|
|
6
|
+
import './round.c68b8be5.mjs';
|
|
9
7
|
import './attributes.mjs';
|
|
10
8
|
|
|
11
9
|
function methods(api, options) {
|
package/dist/categories.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { d as defaultMethods } from './index.
|
|
2
|
-
import
|
|
3
|
-
import '
|
|
4
|
-
import './find.18f1ac6d.mjs';
|
|
5
|
-
import './round.577a8441.mjs';
|
|
1
|
+
import { d as defaultMethods } from './index.3949a230.mjs';
|
|
2
|
+
import './find.ba551a2e.mjs';
|
|
3
|
+
import './round.c68b8be5.mjs';
|
|
6
4
|
import 'deepmerge';
|
|
7
5
|
import 'fast-case';
|
|
8
6
|
|
|
@@ -11,7 +9,7 @@ function methods(api) {
|
|
|
11
9
|
|
|
12
10
|
return {
|
|
13
11
|
get: (id, ...args) => {
|
|
14
|
-
return
|
|
12
|
+
return api.cache.getFetch('categories', id, () => get(id, ...args));
|
|
15
13
|
},
|
|
16
14
|
|
|
17
15
|
list,
|
package/dist/content.mjs
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import cacheApi from './cache.mjs';
|
|
2
|
-
import './index.a8d5c125.mjs';
|
|
3
|
-
import 'qs';
|
|
4
|
-
import './find.18f1ac6d.mjs';
|
|
5
|
-
import './round.577a8441.mjs';
|
|
6
|
-
import 'deepmerge';
|
|
7
|
-
import 'fast-case';
|
|
8
|
-
|
|
9
1
|
function methods(api, opt) {
|
|
10
2
|
return {
|
|
11
3
|
get: (type, id, query) => {
|
|
12
|
-
return
|
|
4
|
+
return api.cache.getFetch(`content_${type}`, id, () =>
|
|
13
5
|
api.request('get', `/content/${type}`, id, {
|
|
14
6
|
$preview: opt.previewContent,
|
|
15
7
|
...(query || {}),
|
package/dist/cookie.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { i as isServer } from './index.
|
|
2
|
-
import '
|
|
3
|
-
import './
|
|
4
|
-
import './round.577a8441.mjs';
|
|
1
|
+
import { i as isServer } from './index.3949a230.mjs';
|
|
2
|
+
import './find.ba551a2e.mjs';
|
|
3
|
+
import './round.c68b8be5.mjs';
|
|
5
4
|
import 'deepmerge';
|
|
6
5
|
import 'fast-case';
|
|
7
6
|
|
package/dist/currency.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import {
|
|
3
|
-
import { r as round } from './round.577a8441.mjs';
|
|
1
|
+
import { f as find, g as get } from './find.ba551a2e.mjs';
|
|
2
|
+
import { r as round } from './round.c68b8be5.mjs';
|
|
4
3
|
import 'deepmerge';
|
|
5
4
|
import 'fast-case';
|
|
6
5
|
|
|
@@ -1,3 +1,123 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* The UTF-8/RFC 3986 encoder in this file is adapted from qs 6.16.0 (lib/utils.js).
|
|
3
|
+
* That code was originally written by Brian White (mscdex) for the io.js core
|
|
4
|
+
* querystring library and adapted by qs for stricter adherence to RFC 3986.
|
|
5
|
+
*
|
|
6
|
+
* @license BSD-3-Clause
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2014, Nathan LaFreniere and other contributors
|
|
9
|
+
* (https://github.com/ljharb/qs/graphs/contributors)
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
*
|
|
12
|
+
* Redistribution and use in source and binary forms, with or without
|
|
13
|
+
* modification, are permitted provided that the following conditions are met:
|
|
14
|
+
*
|
|
15
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
16
|
+
* list of conditions and the following disclaimer.
|
|
17
|
+
*
|
|
18
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
19
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
20
|
+
* and/or other materials provided with the distribution.
|
|
21
|
+
*
|
|
22
|
+
* 3. Neither the name of the copyright holder nor the names of its
|
|
23
|
+
* contributors may be used to endorse or promote products derived from
|
|
24
|
+
* this software without specific prior written permission.
|
|
25
|
+
*
|
|
26
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
27
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
28
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
29
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
30
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
31
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
32
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
33
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
34
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
35
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const hex = Array.from({ length: 256 }, (_, c) =>
|
|
39
|
+
`%${c.toString(16).padStart(2, '0')}`.toUpperCase(),
|
|
40
|
+
);
|
|
41
|
+
const toISO = Date.prototype.toISOString;
|
|
42
|
+
|
|
43
|
+
function encode(value) {
|
|
44
|
+
if (value.length === 0) return value;
|
|
45
|
+
const string =
|
|
46
|
+
typeof value === 'symbol'
|
|
47
|
+
? Symbol.prototype.toString.call(value)
|
|
48
|
+
: String(value);
|
|
49
|
+
let out = '';
|
|
50
|
+
for (let j = 0; j < string.length; j += 1024) {
|
|
51
|
+
let segment = string.slice(j, j + 1024);
|
|
52
|
+
if (j + 1024 < string.length) {
|
|
53
|
+
const last = segment.charCodeAt(segment.length - 1);
|
|
54
|
+
if (last >= 0xd800 && last <= 0xdbff) {
|
|
55
|
+
segment = segment.slice(0, -1);
|
|
56
|
+
j -= 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
60
|
+
let c = segment.charCodeAt(i);
|
|
61
|
+
if (
|
|
62
|
+
c === 0x2d ||
|
|
63
|
+
c === 0x2e ||
|
|
64
|
+
c === 0x5f ||
|
|
65
|
+
c === 0x7e ||
|
|
66
|
+
(c >= 0x30 && c <= 0x39) ||
|
|
67
|
+
(c >= 0x41 && c <= 0x5a) ||
|
|
68
|
+
(c >= 0x61 && c <= 0x7a)
|
|
69
|
+
) {
|
|
70
|
+
out += segment.charAt(i);
|
|
71
|
+
} else if (c < 0x80) {
|
|
72
|
+
out += hex[c];
|
|
73
|
+
} else if (c < 0x800) {
|
|
74
|
+
out += hex[0xc0 | (c >> 6)] + hex[0x80 | (c & 0x3f)];
|
|
75
|
+
} else if (c < 0xd800 || c >= 0xe000) {
|
|
76
|
+
out +=
|
|
77
|
+
hex[0xe0 | (c >> 12)] +
|
|
78
|
+
hex[0x80 | ((c >> 6) & 0x3f)] +
|
|
79
|
+
hex[0x80 | (c & 0x3f)];
|
|
80
|
+
} else {
|
|
81
|
+
i += 1;
|
|
82
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
83
|
+
out +=
|
|
84
|
+
hex[0xf0 | (c >> 18)] +
|
|
85
|
+
hex[0x80 | ((c >> 12) & 0x3f)] +
|
|
86
|
+
hex[0x80 | ((c >> 6) & 0x3f)] +
|
|
87
|
+
hex[0x80 | (c & 0x3f)];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function stringifyQuery(obj) {
|
|
95
|
+
if (typeof obj !== 'object' || obj === null) return '';
|
|
96
|
+
const parts = [];
|
|
97
|
+
const ancestors = new Set();
|
|
98
|
+
function walk(value, prefix) {
|
|
99
|
+
if (value === undefined) return;
|
|
100
|
+
if (value instanceof Date) value = toISO.call(value);
|
|
101
|
+
if (value === null) value = '';
|
|
102
|
+
const isObject = typeof value === 'object';
|
|
103
|
+
const isBuffer =
|
|
104
|
+
isObject &&
|
|
105
|
+
value.constructor &&
|
|
106
|
+
value.constructor.isBuffer &&
|
|
107
|
+
value.constructor.isBuffer(value);
|
|
108
|
+
if ((!isObject && typeof value !== 'function') || isBuffer) {
|
|
109
|
+
parts.push(`${encode(prefix)}=${encode(value)}`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (ancestors.has(value)) throw new RangeError('Cyclic object value');
|
|
113
|
+
ancestors.add(value);
|
|
114
|
+
for (const key of Object.keys(value)) walk(value[key], `${prefix}[${key}]`);
|
|
115
|
+
ancestors.delete(value);
|
|
116
|
+
}
|
|
117
|
+
for (const key of Object.keys(obj)) walk(obj[key], key);
|
|
118
|
+
return parts.join('&');
|
|
119
|
+
}
|
|
120
|
+
|
|
1
121
|
/** Detect free variable `global` from Node.js. */
|
|
2
122
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
3
123
|
|
|
@@ -1210,9 +1330,9 @@ function cacheHas(cache, key) {
|
|
|
1210
1330
|
}
|
|
1211
1331
|
|
|
1212
1332
|
/* Built-in method references that are verified to be native. */
|
|
1213
|
-
var Set = getNative(root$1, 'Set');
|
|
1333
|
+
var Set$1 = getNative(root$1, 'Set');
|
|
1214
1334
|
|
|
1215
|
-
const Set$
|
|
1335
|
+
const Set$2 = Set$1;
|
|
1216
1336
|
|
|
1217
1337
|
/**
|
|
1218
1338
|
* Converts `set` to an array of its values.
|
|
@@ -2235,7 +2355,7 @@ var dataViewTag = '[object DataView]';
|
|
|
2235
2355
|
var dataViewCtorString = toSource(DataView$1),
|
|
2236
2356
|
mapCtorString = toSource(Map$1),
|
|
2237
2357
|
promiseCtorString = toSource(Promise$2),
|
|
2238
|
-
setCtorString = toSource(Set$
|
|
2358
|
+
setCtorString = toSource(Set$2),
|
|
2239
2359
|
weakMapCtorString = toSource(WeakMap$1);
|
|
2240
2360
|
|
|
2241
2361
|
/**
|
|
@@ -2251,7 +2371,7 @@ var getTag = baseGetTag;
|
|
|
2251
2371
|
if ((DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag) ||
|
|
2252
2372
|
(Map$1 && getTag(new Map$1) != mapTag) ||
|
|
2253
2373
|
(Promise$2 && getTag(Promise$2.resolve()) != promiseTag) ||
|
|
2254
|
-
(Set$
|
|
2374
|
+
(Set$2 && getTag(new Set$2) != setTag) ||
|
|
2255
2375
|
(WeakMap$1 && getTag(new WeakMap$1) != weakMapTag)) {
|
|
2256
2376
|
getTag = function(value) {
|
|
2257
2377
|
var result = baseGetTag(value),
|
|
@@ -2964,4 +3084,4 @@ var find = createFind(findIndex);
|
|
|
2964
3084
|
|
|
2965
3085
|
const find$1 = find;
|
|
2966
3086
|
|
|
2967
|
-
export { arrayLikeKeys as A, getSymbols$1 as B, overArg as C, stubArray as D, baseGetAllKeys as E, isObjectLike as F, getTag$1 as G, nodeUtil$1 as H, baseUnary as I, isBuffer$1 as J, Stack as K, getAllKeys as L, baseIsEqual as M, isTypedArray$1 as N, baseKeys as O, findIndex as P, Set$
|
|
3087
|
+
export { arrayLikeKeys as A, getSymbols$1 as B, overArg as C, stubArray as D, baseGetAllKeys as E, isObjectLike as F, getTag$1 as G, nodeUtil$1 as H, baseUnary as I, isBuffer$1 as J, Stack as K, getAllKeys as L, baseIsEqual as M, isTypedArray$1 as N, baseKeys as O, findIndex as P, stringifyQuery as Q, Set$2 as S, Uint8Array$1 as U, toInteger as a, toString as b, getNative as c, castPath as d, eq as e, find$1 as f, get as g, toKey as h, isObject as i, isIndex as j, baseFindIndex as k, SetCache as l, cacheHas as m, baseGet as n, hasIn as o, Symbol$2 as p, isArray$1 as q, root$1 as r, setToArray as s, toNumber as t, isArguments$1 as u, arrayPush as v, identity as w, keys as x, isPrototype as y, isArrayLike as z };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { r as round } from './round.577a8441.mjs';
|
|
1
|
+
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, Q as stringifyQuery, t as toNumber } from './find.ba551a2e.mjs';
|
|
2
|
+
import { r as round } from './round.c68b8be5.mjs';
|
|
4
3
|
import deepmerge from 'deepmerge';
|
|
5
4
|
import { camelize, decamelize, camelizeKeys, decamelizeKeys } from 'fast-case';
|
|
6
5
|
|
|
@@ -1473,8 +1472,6 @@ function isEmpty(value) {
|
|
|
1473
1472
|
|
|
1474
1473
|
const LOADING_SCRIPTS = {};
|
|
1475
1474
|
|
|
1476
|
-
let options = {};
|
|
1477
|
-
|
|
1478
1475
|
function arrayMerge(target, source, options) {
|
|
1479
1476
|
const destination = target.slice();
|
|
1480
1477
|
source.forEach((item, index) => {
|
|
@@ -1512,14 +1509,6 @@ function merge(x, y, opt) {
|
|
|
1512
1509
|
return deepmerge(x, y, opt);
|
|
1513
1510
|
}
|
|
1514
1511
|
|
|
1515
|
-
function setOptions(optns) {
|
|
1516
|
-
options = optns;
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
function getOptions() {
|
|
1520
|
-
return options;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
1512
|
function isObject(val) {
|
|
1524
1513
|
return val && typeof val === 'object' && !(val instanceof Array);
|
|
1525
1514
|
}
|
|
@@ -1563,10 +1552,6 @@ function trimEnd(str) {
|
|
|
1563
1552
|
return typeof str === 'string' ? str.replace(/[/]+$/, '') : '';
|
|
1564
1553
|
}
|
|
1565
1554
|
|
|
1566
|
-
function stringifyQuery(str) {
|
|
1567
|
-
return stringify(str);
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
1555
|
function map(arr, cb) {
|
|
1571
1556
|
return arr instanceof Array ? arr.map(cb) : [];
|
|
1572
1557
|
}
|
|
@@ -1601,7 +1586,7 @@ function defaultMethods(api, uri, methods) {
|
|
|
1601
1586
|
};
|
|
1602
1587
|
}
|
|
1603
1588
|
|
|
1604
|
-
async function vaultRequest(method, url, data) {
|
|
1589
|
+
async function vaultRequest(method, url, data, options) {
|
|
1605
1590
|
const { vaultUrl, timeout, key } = options;
|
|
1606
1591
|
const requestData = {
|
|
1607
1592
|
$jsonp: {
|
|
@@ -1785,7 +1770,6 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1785
1770
|
findIndex,
|
|
1786
1771
|
get,
|
|
1787
1772
|
getLocationParams,
|
|
1788
|
-
getOptions,
|
|
1789
1773
|
isEmpty,
|
|
1790
1774
|
isEqual,
|
|
1791
1775
|
isFunction,
|
|
@@ -1800,7 +1784,6 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1800
1784
|
removeUrlParams,
|
|
1801
1785
|
round,
|
|
1802
1786
|
set,
|
|
1803
|
-
setOptions,
|
|
1804
1787
|
snakeCase,
|
|
1805
1788
|
stringifyQuery,
|
|
1806
1789
|
toCamel,
|
|
@@ -1815,4 +1798,4 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1815
1798
|
vaultRequest
|
|
1816
1799
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1817
1800
|
|
|
1818
|
-
export {
|
|
1801
|
+
export { trimBoth as A, toLower as B, map as C, toCamelPath as a, toSnake as b, cloneDeep as c, defaultMethods as d, isObject as e, camelCase as f, snakeCase as g, isEqual as h, isServer as i, isFunction as j, isEmpty as k, loadScript as l, merge as m, isLiveMode as n, base64Encode as o, pick$1 as p, getLocationParams as q, reduce as r, set as s, toCamel as t, uniq as u, vaultRequest as v, removeUrlParams as w, trimEnd as x, utils as y, trimStart as z };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { default } from './api.mjs';
|
|
2
2
|
import './card.mjs';
|
|
3
|
-
import './index.
|
|
4
|
-
import '
|
|
5
|
-
import './
|
|
6
|
-
import './round.577a8441.mjs';
|
|
3
|
+
import './index.3949a230.mjs';
|
|
4
|
+
import './find.ba551a2e.mjs';
|
|
5
|
+
import './round.c68b8be5.mjs';
|
|
7
6
|
import 'deepmerge';
|
|
8
7
|
import 'fast-case';
|
|
9
8
|
import './cookie.mjs';
|
package/dist/locale.mjs
CHANGED