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/payment.mjs
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import methods from './cart.mjs';
|
|
2
2
|
import methods$1 from './settings.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import { g as get } from './find.
|
|
5
|
-
import 'qs';
|
|
3
|
+
import { e as isObject, j as isFunction, l as loadScript, c as cloneDeep, v as vaultRequest, b as toSnake, p as pick, k as isEmpty, n as isLiveMode, o as base64Encode, q as getLocationParams, w as removeUrlParams, t as toCamel } from './index.3949a230.mjs';
|
|
4
|
+
import { g as get } from './find.ba551a2e.mjs';
|
|
6
5
|
import 'deepmerge';
|
|
7
6
|
import 'fast-case';
|
|
8
|
-
import cardApi from './card.mjs';
|
|
9
7
|
import './products.mjs';
|
|
10
|
-
import './cache.mjs';
|
|
11
|
-
import './round.577a8441.mjs';
|
|
12
8
|
import './attributes.mjs';
|
|
9
|
+
import './round.c68b8be5.mjs';
|
|
13
10
|
|
|
14
11
|
const SCRIPT_HANDLERS = {
|
|
15
12
|
'stripe-js': loadStripe,
|
|
@@ -423,7 +420,7 @@ class Payment {
|
|
|
423
420
|
* @returns {Promise<object>}
|
|
424
421
|
*/
|
|
425
422
|
async createIntent(data) {
|
|
426
|
-
return vaultRequest('post', '/intent', data);
|
|
423
|
+
return vaultRequest('post', '/intent', data, this.options);
|
|
427
424
|
}
|
|
428
425
|
|
|
429
426
|
/**
|
|
@@ -433,7 +430,7 @@ class Payment {
|
|
|
433
430
|
* @returns {Promise<object>}
|
|
434
431
|
*/
|
|
435
432
|
async updateIntent(data) {
|
|
436
|
-
return vaultRequest('put', '/intent', data);
|
|
433
|
+
return vaultRequest('put', '/intent', data, this.options);
|
|
437
434
|
}
|
|
438
435
|
|
|
439
436
|
/**
|
|
@@ -443,7 +440,7 @@ class Payment {
|
|
|
443
440
|
* @returns {Promise<object>}
|
|
444
441
|
*/
|
|
445
442
|
async authorizeGateway(data) {
|
|
446
|
-
return vaultRequest('post', '/authorization', data);
|
|
443
|
+
return vaultRequest('post', '/authorization', data, this.options);
|
|
447
444
|
}
|
|
448
445
|
|
|
449
446
|
/**
|
|
@@ -2727,7 +2724,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2727
2724
|
|
|
2728
2725
|
if (cart.subscription_delivery) {
|
|
2729
2726
|
try {
|
|
2730
|
-
const card = await
|
|
2727
|
+
const card = await this.api.card.createToken({
|
|
2731
2728
|
gateway: 'braintree',
|
|
2732
2729
|
account_id: cart.account_id,
|
|
2733
2730
|
nonce,
|
|
@@ -3404,7 +3401,7 @@ class BraintreeApplePayment extends Payment {
|
|
|
3404
3401
|
|
|
3405
3402
|
if (cart.subscription_delivery) {
|
|
3406
3403
|
try {
|
|
3407
|
-
const card = await
|
|
3404
|
+
const card = await this.api.card.createToken({
|
|
3408
3405
|
gateway: 'braintree',
|
|
3409
3406
|
account_id: cart.account_id,
|
|
3410
3407
|
nonce: payload.nonce,
|
|
@@ -4310,7 +4307,7 @@ class ConvesioCardPayment extends Payment {
|
|
|
4310
4307
|
''
|
|
4311
4308
|
).replace(/[^0-9]+/g, '');
|
|
4312
4309
|
|
|
4313
|
-
const cardExpiry =
|
|
4310
|
+
const cardExpiry = this.api.card.expiry(
|
|
4314
4311
|
this.params.exp ||
|
|
4315
4312
|
document.getElementById(
|
|
4316
4313
|
this.params.cardExpiry?.elementId || 'cardExpiry-element',
|
|
@@ -4334,7 +4331,7 @@ class ConvesioCardPayment extends Payment {
|
|
|
4334
4331
|
''
|
|
4335
4332
|
).trim();
|
|
4336
4333
|
|
|
4337
|
-
const cardBrand =
|
|
4334
|
+
const cardBrand = this.api.card.type(cardNumber).toLowerCase();
|
|
4338
4335
|
|
|
4339
4336
|
const payment = await createConvesioCardPaymentToken(this.method, {
|
|
4340
4337
|
paymentMethod: {
|
|
@@ -6039,7 +6036,7 @@ class PaymentController {
|
|
|
6039
6036
|
}
|
|
6040
6037
|
|
|
6041
6038
|
async _vaultRequest(method, url, data) {
|
|
6042
|
-
const response = await vaultRequest(method, url, data);
|
|
6039
|
+
const response = await vaultRequest(method, url, data, this.options);
|
|
6043
6040
|
|
|
6044
6041
|
if (this.options.useCamelCase) {
|
|
6045
6042
|
return toCamel(response);
|
package/dist/products.mjs
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { d as defaultMethods, r as reduce,
|
|
2
|
-
import cacheApi from './cache.mjs';
|
|
1
|
+
import { d as defaultMethods, r as reduce, b as toSnake, t as toCamel, g as snakeCase, u as uniq, h as isEqual } from './index.3949a230.mjs';
|
|
3
2
|
import methods$1 from './attributes.mjs';
|
|
4
|
-
import { g as get, f as find } from './find.
|
|
5
|
-
import '
|
|
6
|
-
import './round.577a8441.mjs';
|
|
3
|
+
import { g as get, f as find } from './find.ba551a2e.mjs';
|
|
4
|
+
import './round.c68b8be5.mjs';
|
|
7
5
|
import 'deepmerge';
|
|
8
6
|
import 'fast-case';
|
|
9
7
|
|
|
10
|
-
let OPTIONS;
|
|
11
|
-
|
|
12
8
|
function methods(api, opt) {
|
|
13
|
-
OPTIONS = opt;
|
|
14
9
|
const { get, list } = defaultMethods(api, '/products', ['list', 'get']);
|
|
15
10
|
return {
|
|
16
11
|
get: (id, ...args) => {
|
|
17
|
-
return
|
|
12
|
+
return api.cache.getFetch('products', id, () => get(id, ...args));
|
|
18
13
|
},
|
|
19
14
|
|
|
20
15
|
list,
|
|
21
16
|
|
|
22
|
-
variation:
|
|
17
|
+
variation: (input, options, purchaseOption) =>
|
|
18
|
+
calculateVariation(input, options, purchaseOption, opt),
|
|
23
19
|
|
|
24
20
|
categories: getCategories,
|
|
25
21
|
|
|
@@ -116,8 +112,8 @@ function findVariantWithOptions(product, options) {
|
|
|
116
112
|
return findVariantWithOptionValueIds(product, optionValueIds);
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
function calculateVariation(input, options, purchaseOption) {
|
|
120
|
-
const product =
|
|
115
|
+
function calculateVariation(input, options, purchaseOption, opt) {
|
|
116
|
+
const product = opt.useCamelCase ? toSnake(input) : input;
|
|
121
117
|
const purchaseOp = findPurchaseOption(product, purchaseOption);
|
|
122
118
|
const variation = {
|
|
123
119
|
...product,
|
|
@@ -180,7 +176,7 @@ function calculateVariation(input, options, purchaseOption) {
|
|
|
180
176
|
if (variation.orig_price === undefined) {
|
|
181
177
|
delete variation.orig_price;
|
|
182
178
|
}
|
|
183
|
-
return
|
|
179
|
+
return opt.useCamelCase ? toCamel(variation) : variation;
|
|
184
180
|
}
|
|
185
181
|
|
|
186
182
|
function findPurchaseOption(product, purchaseOption) {
|
|
@@ -235,8 +231,7 @@ function findPurchaseOption(product, purchaseOption) {
|
|
|
235
231
|
}
|
|
236
232
|
|
|
237
233
|
async function getFilterableAttributeFilters(api, products, options) {
|
|
238
|
-
const { results: filterableAttributes } = await methods$1(
|
|
239
|
-
api).list({
|
|
234
|
+
const { results: filterableAttributes } = await methods$1(api).list({
|
|
240
235
|
filterable: true,
|
|
241
236
|
});
|
|
242
237
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as root, t as toNumber, a as toInteger, b as toString } from './find.
|
|
1
|
+
import { r as root, t as toNumber, a as toInteger, b as toString } from './find.ba551a2e.mjs';
|
|
2
2
|
|
|
3
3
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
4
4
|
var nativeIsFinite = root.isFinite,
|
package/dist/settings.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { s as set,
|
|
2
|
-
import { g as get, f as find } from './find.
|
|
3
|
-
import '
|
|
4
|
-
import './round.577a8441.mjs';
|
|
1
|
+
import { s as set, t as toCamel, m as merge, c as cloneDeep, e as isObject, f as camelCase } from './index.3949a230.mjs';
|
|
2
|
+
import { g as get, f as find } from './find.ba551a2e.mjs';
|
|
3
|
+
import './round.c68b8be5.mjs';
|
|
5
4
|
import 'deepmerge';
|
|
6
5
|
import 'fast-case';
|
|
7
6
|
|
package/dist/subscriptions.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { cleanProductOptions } from './products.mjs';
|
|
2
|
-
import { d as defaultMethods } from './index.
|
|
3
|
-
import cacheApi from './cache.mjs';
|
|
2
|
+
import { d as defaultMethods } from './index.3949a230.mjs';
|
|
4
3
|
import './attributes.mjs';
|
|
5
|
-
import './find.
|
|
6
|
-
import '
|
|
7
|
-
import './round.577a8441.mjs';
|
|
4
|
+
import './find.ba551a2e.mjs';
|
|
5
|
+
import './round.c68b8be5.mjs';
|
|
8
6
|
import 'deepmerge';
|
|
9
7
|
import 'fast-case';
|
|
10
8
|
|
|
@@ -12,7 +10,7 @@ function methods(api) {
|
|
|
12
10
|
const { get, list } = defaultMethods(api, '/subscriptions', ['list', 'get']);
|
|
13
11
|
return {
|
|
14
12
|
get: (id, ...args) => {
|
|
15
|
-
return
|
|
13
|
+
return api.cache.getFetch('subscriptions', id, () => get(id, ...args));
|
|
16
14
|
},
|
|
17
15
|
|
|
18
16
|
list,
|