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.
Files changed (86) hide show
  1. package/dist/api.mjs +53 -42
  2. package/dist/attributes.mjs +4 -6
  3. package/dist/cache.mjs +141 -140
  4. package/dist/card.mjs +149 -148
  5. package/dist/cart.mjs +3 -5
  6. package/dist/categories.mjs +4 -6
  7. package/dist/content.mjs +1 -9
  8. package/dist/cookie.mjs +3 -4
  9. package/dist/currency.mjs +2 -3
  10. package/dist/{find.18f1ac6d.mjs → find.ba551a2e.mjs} +125 -5
  11. package/dist/{index.a8d5c125.mjs → index.3949a230.mjs} +4 -21
  12. package/dist/index.mjs +3 -4
  13. package/dist/locale.mjs +1 -2
  14. package/dist/payment.mjs +11 -14
  15. package/dist/products.mjs +10 -15
  16. package/dist/{round.577a8441.mjs → round.c68b8be5.mjs} +1 -1
  17. package/dist/settings.mjs +3 -4
  18. package/dist/subscriptions.mjs +4 -6
  19. package/dist/swell.cjs +439 -323
  20. package/dist/swell.cjs.map +1 -1
  21. package/dist/swell.umd.min.js +13676 -18860
  22. package/dist/swell.umd.min.js.map +1 -1
  23. package/dist/utils/index.mjs +3 -4
  24. package/package.json +15 -8
  25. package/types/account/camel.ts +10 -7
  26. package/types/account/index.ts +3 -3
  27. package/types/account/snake.ts +5 -5
  28. package/types/attribute/camel.ts +7 -4
  29. package/types/attribute/index.ts +3 -3
  30. package/types/attribute/snake.ts +2 -2
  31. package/types/billing/camel.ts +4 -4
  32. package/types/billing/index.ts +2 -2
  33. package/types/billing/snake.ts +1 -1
  34. package/types/card/camel.ts +5 -5
  35. package/types/card/index.ts +3 -3
  36. package/types/card/snake.ts +3 -3
  37. package/types/cart/camel.ts +17 -14
  38. package/types/cart/index.ts +3 -3
  39. package/types/cart/snake.ts +12 -12
  40. package/types/category/camel.ts +4 -4
  41. package/types/category/index.ts +3 -3
  42. package/types/category/snake.ts +2 -2
  43. package/types/content/camel.ts +5 -5
  44. package/types/content/index.ts +3 -3
  45. package/types/content/snake.ts +3 -3
  46. package/types/coupon/camel.ts +4 -4
  47. package/types/coupon/index.ts +2 -2
  48. package/types/coupon/snake.ts +2 -2
  49. package/types/currency/camel.ts +2 -2
  50. package/types/currency/index.ts +3 -3
  51. package/types/discount/camel.ts +3 -3
  52. package/types/discount/index.ts +2 -2
  53. package/types/giftcard/camel.ts +10 -7
  54. package/types/giftcard/index.ts +2 -2
  55. package/types/giftcard/snake.ts +5 -5
  56. package/types/index.d.cts +207 -0
  57. package/types/index.d.ts +83 -56
  58. package/types/invoice/camel.ts +10 -10
  59. package/types/invoice/index.ts +3 -3
  60. package/types/invoice/snake.ts +8 -8
  61. package/types/order/camel.ts +18 -15
  62. package/types/order/index.ts +3 -3
  63. package/types/order/snake.ts +18 -13
  64. package/types/payment/camel.ts +13 -10
  65. package/types/payment/index.ts +3 -3
  66. package/types/payment/snake.ts +8 -8
  67. package/types/product/camel.ts +5 -5
  68. package/types/product/index.ts +4 -4
  69. package/types/product/snake.ts +3 -3
  70. package/types/promotion/camel.ts +6 -6
  71. package/types/promotion/index.ts +2 -2
  72. package/types/promotion/snake.ts +4 -4
  73. package/types/purchase_link/camel.ts +10 -7
  74. package/types/purchase_link/index.ts +2 -2
  75. package/types/purchase_link/snake.ts +5 -5
  76. package/types/refund/camel.ts +6 -6
  77. package/types/refund/index.ts +2 -2
  78. package/types/refund/snake.ts +4 -4
  79. package/types/shipment_rating/camel.ts +3 -3
  80. package/types/shipment_rating/index.ts +2 -2
  81. package/types/subscription/camel.ts +16 -13
  82. package/types/subscription/index.ts +3 -3
  83. package/types/subscription/snake.ts +16 -11
  84. package/types/user/camel.ts +2 -2
  85. package/types/user/index.ts +3 -3
  86. 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 { b as isObject, k as isFunction, l as loadScript, c as cloneDeep, v as vaultRequest, t as toSnake, p as pick, n as isEmpty, o as isLiveMode, q as base64Encode, w as getLocationParams, x as removeUrlParams, a as toCamel } from './index.a8d5c125.mjs';
4
- import { g as get } from './find.18f1ac6d.mjs';
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 cardApi.createToken({
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 cardApi.createToken({
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 = cardApi.expiry(
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 = cardApi.type(cardNumber).toLowerCase();
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, 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.3949a230.mjs';
3
2
  import methods$1 from './attributes.mjs';
4
- import { g as get, f as find } from './find.18f1ac6d.mjs';
5
- import 'qs';
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 cacheApi.getFetch('products', id, () => get(id, ...args));
12
+ return api.cache.getFetch('products', id, () => get(id, ...args));
18
13
  },
19
14
 
20
15
  list,
21
16
 
22
- variation: calculateVariation,
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 = OPTIONS.useCamelCase ? toSnake(input) : input;
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 OPTIONS.useCamelCase ? toCamel(variation) : variation;
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.18f1ac6d.mjs';
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, a as toCamel, m as merge, c as cloneDeep, b as isObject, e as camelCase } from './index.a8d5c125.mjs';
2
- import { g as get, f as find } from './find.18f1ac6d.mjs';
3
- import 'qs';
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
 
@@ -1,10 +1,8 @@
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.3949a230.mjs';
4
3
  import './attributes.mjs';
5
- import './find.18f1ac6d.mjs';
6
- import 'qs';
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 cacheApi.getFetch('subscriptions', id, () => get(id, ...args));
13
+ return api.cache.getFetch('subscriptions', id, () => get(id, ...args));
16
14
  },
17
15
 
18
16
  list,