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.
Files changed (82) hide show
  1. package/dist/api.mjs +51 -39
  2. package/dist/attributes.mjs +2 -3
  3. package/dist/cache.mjs +139 -137
  4. package/dist/card.mjs +147 -145
  5. package/dist/cart.mjs +1 -2
  6. package/dist/categories.mjs +2 -3
  7. package/dist/content.mjs +1 -9
  8. package/dist/cookie.mjs +1 -1
  9. package/dist/{index.a8d5c125.mjs → index.777df7a8.mjs} +2 -14
  10. package/dist/index.mjs +1 -1
  11. package/dist/payment.mjs +296 -118
  12. package/dist/products.mjs +8 -12
  13. package/dist/settings.mjs +1 -1
  14. package/dist/subscriptions.mjs +2 -3
  15. package/dist/swell.cjs +605 -424
  16. package/dist/swell.cjs.map +1 -1
  17. package/dist/swell.umd.min.js +604 -423
  18. package/dist/swell.umd.min.js.map +1 -1
  19. package/dist/utils/index.mjs +1 -1
  20. package/package.json +14 -6
  21. package/types/account/camel.ts +10 -7
  22. package/types/account/index.ts +3 -3
  23. package/types/account/snake.ts +5 -5
  24. package/types/attribute/camel.ts +7 -4
  25. package/types/attribute/index.ts +3 -3
  26. package/types/attribute/snake.ts +2 -2
  27. package/types/billing/camel.ts +4 -4
  28. package/types/billing/index.ts +2 -2
  29. package/types/billing/snake.ts +1 -1
  30. package/types/card/camel.ts +5 -5
  31. package/types/card/index.ts +3 -3
  32. package/types/card/snake.ts +3 -3
  33. package/types/cart/camel.ts +17 -14
  34. package/types/cart/index.ts +3 -3
  35. package/types/cart/snake.ts +12 -12
  36. package/types/category/camel.ts +4 -4
  37. package/types/category/index.ts +3 -3
  38. package/types/category/snake.ts +2 -2
  39. package/types/content/camel.ts +5 -5
  40. package/types/content/index.ts +3 -3
  41. package/types/content/snake.ts +3 -3
  42. package/types/coupon/camel.ts +4 -4
  43. package/types/coupon/index.ts +2 -2
  44. package/types/coupon/snake.ts +2 -2
  45. package/types/currency/camel.ts +2 -2
  46. package/types/currency/index.ts +3 -3
  47. package/types/discount/camel.ts +3 -3
  48. package/types/discount/index.ts +2 -2
  49. package/types/giftcard/camel.ts +10 -7
  50. package/types/giftcard/index.ts +2 -2
  51. package/types/giftcard/snake.ts +5 -5
  52. package/types/index.d.cts +207 -0
  53. package/types/index.d.ts +83 -56
  54. package/types/invoice/camel.ts +10 -10
  55. package/types/invoice/index.ts +3 -3
  56. package/types/invoice/snake.ts +8 -8
  57. package/types/order/camel.ts +18 -15
  58. package/types/order/index.ts +3 -3
  59. package/types/order/snake.ts +18 -13
  60. package/types/payment/camel.ts +13 -10
  61. package/types/payment/index.ts +9 -3
  62. package/types/payment/snake.ts +8 -8
  63. package/types/product/camel.ts +5 -5
  64. package/types/product/index.ts +4 -4
  65. package/types/product/snake.ts +3 -3
  66. package/types/promotion/camel.ts +6 -6
  67. package/types/promotion/index.ts +2 -2
  68. package/types/promotion/snake.ts +4 -4
  69. package/types/purchase_link/camel.ts +10 -7
  70. package/types/purchase_link/index.ts +2 -2
  71. package/types/purchase_link/snake.ts +5 -5
  72. package/types/refund/camel.ts +6 -6
  73. package/types/refund/index.ts +2 -2
  74. package/types/refund/snake.ts +4 -4
  75. package/types/shipment_rating/camel.ts +3 -3
  76. package/types/shipment_rating/index.ts +2 -2
  77. package/types/subscription/camel.ts +16 -13
  78. package/types/subscription/index.ts +3 -3
  79. package/types/subscription/snake.ts +16 -11
  80. package/types/user/camel.ts +2 -2
  81. package/types/user/index.ts +3 -3
  82. package/types/user/snake.ts +1 -1
package/dist/products.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { d as defaultMethods, r as reduce, t as toSnake, a as toCamel, f as snakeCase, u as uniq, g as isEqual } from './index.a8d5c125.mjs';
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 cacheApi.getFetch('products', id, () => get(id, ...args));
13
+ return api.cache.getFetch('products', id, () => get(id, ...args));
18
14
  },
19
15
 
20
16
  list,
21
17
 
22
- variation: calculateVariation,
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 = OPTIONS.useCamelCase ? toSnake(input) : input;
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 OPTIONS.useCamelCase ? toCamel(variation) : variation;
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, a as toCamel, m as merge, c as cloneDeep, b as isObject, e as camelCase } from './index.a8d5c125.mjs';
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';
@@ -1,6 +1,5 @@
1
1
  import { cleanProductOptions } from './products.mjs';
2
- import { d as defaultMethods } from './index.a8d5c125.mjs';
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 cacheApi.getFetch('subscriptions', id, () => get(id, ...args));
14
+ return api.cache.getFetch('subscriptions', id, () => get(id, ...args));
16
15
  },
17
16
 
18
17
  list,