swell-js 5.8.1 → 5.9.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/dist/api.mjs +51 -39
- package/dist/attributes.mjs +2 -3
- package/dist/cache.mjs +139 -137
- package/dist/card.mjs +147 -145
- package/dist/cart.mjs +1 -2
- package/dist/categories.mjs +2 -3
- package/dist/content.mjs +1 -9
- package/dist/cookie.mjs +1 -1
- package/dist/{index.a8d5c125.mjs → index.777df7a8.mjs} +2 -14
- package/dist/index.mjs +1 -1
- package/dist/payment.mjs +296 -118
- package/dist/products.mjs +8 -12
- package/dist/settings.mjs +1 -1
- package/dist/subscriptions.mjs +2 -3
- package/dist/swell.cjs +605 -424
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +604 -423
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +14 -6
- 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 +9 -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/products.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
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.777df7a8.mjs';
|
|
3
2
|
import methods$1 from './attributes.mjs';
|
|
4
3
|
import { g as get, f as find } from './find.18f1ac6d.mjs';
|
|
5
4
|
import 'qs';
|
|
@@ -7,19 +6,17 @@ import './round.577a8441.mjs';
|
|
|
7
6
|
import 'deepmerge';
|
|
8
7
|
import 'fast-case';
|
|
9
8
|
|
|
10
|
-
let OPTIONS;
|
|
11
|
-
|
|
12
9
|
function methods(api, opt) {
|
|
13
|
-
OPTIONS = opt;
|
|
14
10
|
const { get, list } = defaultMethods(api, '/products', ['list', 'get']);
|
|
15
11
|
return {
|
|
16
12
|
get: (id, ...args) => {
|
|
17
|
-
return
|
|
13
|
+
return api.cache.getFetch('products', id, () => get(id, ...args));
|
|
18
14
|
},
|
|
19
15
|
|
|
20
16
|
list,
|
|
21
17
|
|
|
22
|
-
variation:
|
|
18
|
+
variation: (input, options, purchaseOption) =>
|
|
19
|
+
calculateVariation(input, options, purchaseOption, opt),
|
|
23
20
|
|
|
24
21
|
categories: getCategories,
|
|
25
22
|
|
|
@@ -116,8 +113,8 @@ function findVariantWithOptions(product, options) {
|
|
|
116
113
|
return findVariantWithOptionValueIds(product, optionValueIds);
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
function calculateVariation(input, options, purchaseOption) {
|
|
120
|
-
const product =
|
|
116
|
+
function calculateVariation(input, options, purchaseOption, opt) {
|
|
117
|
+
const product = opt.useCamelCase ? toSnake(input) : input;
|
|
121
118
|
const purchaseOp = findPurchaseOption(product, purchaseOption);
|
|
122
119
|
const variation = {
|
|
123
120
|
...product,
|
|
@@ -180,7 +177,7 @@ function calculateVariation(input, options, purchaseOption) {
|
|
|
180
177
|
if (variation.orig_price === undefined) {
|
|
181
178
|
delete variation.orig_price;
|
|
182
179
|
}
|
|
183
|
-
return
|
|
180
|
+
return opt.useCamelCase ? toCamel(variation) : variation;
|
|
184
181
|
}
|
|
185
182
|
|
|
186
183
|
function findPurchaseOption(product, purchaseOption) {
|
|
@@ -235,8 +232,7 @@ function findPurchaseOption(product, purchaseOption) {
|
|
|
235
232
|
}
|
|
236
233
|
|
|
237
234
|
async function getFilterableAttributeFilters(api, products, options) {
|
|
238
|
-
const { results: filterableAttributes } = await methods$1(
|
|
239
|
-
api).list({
|
|
235
|
+
const { results: filterableAttributes } = await methods$1(api).list({
|
|
240
236
|
filterable: true,
|
|
241
237
|
});
|
|
242
238
|
|
package/dist/settings.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as set,
|
|
1
|
+
import { s as set, t as toCamel, m as merge, c as cloneDeep, e as isObject, f as camelCase } from './index.777df7a8.mjs';
|
|
2
2
|
import { g as get, f as find } from './find.18f1ac6d.mjs';
|
|
3
3
|
import 'qs';
|
|
4
4
|
import './round.577a8441.mjs';
|
package/dist/subscriptions.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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.777df7a8.mjs';
|
|
4
3
|
import './attributes.mjs';
|
|
5
4
|
import './find.18f1ac6d.mjs';
|
|
6
5
|
import 'qs';
|
|
@@ -12,7 +11,7 @@ function methods(api) {
|
|
|
12
11
|
const { get, list } = defaultMethods(api, '/subscriptions', ['list', 'get']);
|
|
13
12
|
return {
|
|
14
13
|
get: (id, ...args) => {
|
|
15
|
-
return
|
|
14
|
+
return api.cache.getFetch('subscriptions', id, () => get(id, ...args));
|
|
16
15
|
},
|
|
17
16
|
|
|
18
17
|
list,
|