swell-js 4.0.8 → 4.0.9

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 (75) hide show
  1. package/dist/account.mjs +14 -2
  2. package/dist/api.mjs +2 -2
  3. package/dist/attributes.mjs +1 -1
  4. package/dist/cache.mjs +2 -2
  5. package/dist/card.mjs +2 -2
  6. package/dist/cart.mjs +4 -4
  7. package/dist/categories.mjs +1 -1
  8. package/dist/content.mjs +1 -1
  9. package/dist/cookie.mjs +1 -1
  10. package/dist/{index.6938673d.mjs → index.95daac5a.mjs} +3 -1
  11. package/dist/index.mjs +1 -1
  12. package/dist/payment.mjs +4 -4
  13. package/dist/products.mjs +1 -1
  14. package/dist/settings.mjs +3 -3
  15. package/dist/subscriptions.mjs +1 -1
  16. package/dist/swell.cjs +28 -14
  17. package/dist/swell.cjs.map +1 -1
  18. package/dist/swell.umd.min.js +117 -85
  19. package/dist/swell.umd.min.js.map +1 -1
  20. package/dist/utils/index.mjs +1 -1
  21. package/package.json +9 -2
  22. package/types/account/camel.d.ts +6 -10
  23. package/types/account/index.d.ts +4 -3
  24. package/types/account/snake.d.ts +12 -9
  25. package/types/attribute/camel.d.ts +2 -4
  26. package/types/attribute/snake.d.ts +3 -2
  27. package/types/billing/camel.d.ts +14 -25
  28. package/types/billing/index.d.ts +5 -0
  29. package/types/billing/snake.d.ts +30 -21
  30. package/types/card/camel.d.ts +7 -10
  31. package/types/card/index.d.ts +4 -3
  32. package/types/card/snake.d.ts +5 -4
  33. package/types/cart/camel.d.ts +24 -16
  34. package/types/cart/index.d.ts +23 -1
  35. package/types/cart/snake.d.ts +57 -22
  36. package/types/category/camel.d.ts +2 -4
  37. package/types/category/snake.d.ts +10 -7
  38. package/types/content/camel.d.ts +3 -7
  39. package/types/content/index.d.ts +1 -0
  40. package/types/content/snake.d.ts +6 -3
  41. package/types/coupon/camel.d.ts +2 -4
  42. package/types/coupon/snake.d.ts +9 -11
  43. package/types/currency/camel.d.ts +9 -10
  44. package/types/currency/index.d.ts +3 -0
  45. package/types/discount/camel.d.ts +14 -5
  46. package/types/discount/index.d.ts +16 -2
  47. package/types/discount/snake.d.ts +34 -8
  48. package/types/giftcard/camel.d.ts +6 -0
  49. package/types/giftcard/index.d.ts +5 -0
  50. package/types/giftcard/snake.d.ts +39 -0
  51. package/types/index.d.ts +210 -147
  52. package/types/invoice/camel.d.ts +2 -4
  53. package/types/invoice/snake.d.ts +16 -10
  54. package/types/order/camel.d.ts +7 -16
  55. package/types/order/index.d.ts +1 -0
  56. package/types/order/snake.d.ts +35 -21
  57. package/types/payment/camel.d.ts +17 -25
  58. package/types/payment/index.d.ts +8 -0
  59. package/types/payment/snake.d.ts +47 -30
  60. package/types/product/camel.d.ts +13 -36
  61. package/types/product/index.d.ts +8 -8
  62. package/types/product/snake.d.ts +37 -30
  63. package/types/promotion/camel.d.ts +6 -5
  64. package/types/promotion/index.d.ts +6 -2
  65. package/types/promotion/snake.d.ts +20 -8
  66. package/types/purchase_link/camel.d.ts +3 -9
  67. package/types/purchase_link/index.d.ts +3 -7
  68. package/types/purchase_link/snake.d.ts +9 -12
  69. package/types/refund/camel.d.ts +2 -4
  70. package/types/shipment_rating/camel.d.ts +4 -7
  71. package/types/shipment_rating/index.d.ts +1 -0
  72. package/types/shipment_rating/snake.d.ts +3 -1
  73. package/types/subscription/camel.d.ts +13 -8
  74. package/types/subscription/index.d.ts +17 -3
  75. package/types/subscription/snake.d.ts +35 -27
package/dist/account.mjs CHANGED
@@ -77,7 +77,7 @@ function methods(request) {
77
77
  },
78
78
 
79
79
  listOrders(query) {
80
- return request('get', `/account/orders`, query);
80
+ return request('get', '/account/orders', query);
81
81
  },
82
82
 
83
83
  getOrder(id) {
@@ -85,14 +85,26 @@ function methods(request) {
85
85
  },
86
86
 
87
87
  // Deprecated methods
88
+
89
+ /**
90
+ * @deprecated use `listAddresses` instead
91
+ */
88
92
  getAddresses(query) {
89
93
  return request('get', '/account/addresses', query);
90
94
  },
95
+
96
+ /**
97
+ * @deprecated use `listCards` instead
98
+ */
91
99
  getCards(query) {
92
100
  return request('get', '/account/cards', query);
93
101
  },
102
+
103
+ /**
104
+ * @deprecated use `listOrders` instead
105
+ */
94
106
  getOrders(query) {
95
- return request('get', `/account/orders`, query);
107
+ return request('get', '/account/orders', query);
96
108
  },
97
109
  };
98
110
  }
package/dist/api.mjs CHANGED
@@ -7,7 +7,7 @@ import methods$5 from './products.mjs';
7
7
  import methods$6 from './categories.mjs';
8
8
  import methods$7 from './attributes.mjs';
9
9
  import methods$8 from './subscriptions.mjs';
10
- import { d as defaultMethods, z as trimEnd, A as utils, B as trimStart, C as trimBoth, t as toSnake, D as stringifyQuery, E as base64Encode, a as toCamel, F as setOptions } from './index.6938673d.mjs';
10
+ import { d as defaultMethods, z as trimEnd, A as utils, B as trimStart, C as trimBoth, t as toSnake, D as stringifyQuery, E as base64Encode, a as toCamel, F as setOptions } from './index.95daac5a.mjs';
11
11
  import methods$9 from './content.mjs';
12
12
  import methods$a from './settings.mjs';
13
13
  import PaymentController from './payment.mjs';
@@ -135,7 +135,7 @@ const options = {
135
135
  };
136
136
 
137
137
  const api = {
138
- version: '4.0.8',
138
+ version: '4.0.9',
139
139
  options,
140
140
  request,
141
141
 
@@ -1,4 +1,4 @@
1
- import { d as defaultMethods } from './index.6938673d.mjs';
1
+ import { d as defaultMethods } from './index.95daac5a.mjs';
2
2
  import cacheApi from './cache.mjs';
3
3
  import 'qs';
4
4
  import './find.fd7de00e.mjs';
package/dist/cache.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.6938673d.mjs';
1
+ import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.95daac5a.mjs';
2
2
  import { g as get } from './find.fd7de00e.mjs';
3
3
  import 'qs';
4
4
  import './round.a606b844.mjs';
@@ -53,7 +53,7 @@ const cacheApi = {
53
53
  set(details) {
54
54
  this.debug('cache.set', ...arguments);
55
55
  let { model, id, path, value } = details;
56
- let { data = {}, record, presets } = this.values(details);
56
+ let { data = {}, record } = this.values(details);
57
57
 
58
58
  if (id === null) {
59
59
  return;
package/dist/card.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as toSnake, v as vaultRequest } from './index.6938673d.mjs';
1
+ import { t as toSnake, v as vaultRequest } from './index.95daac5a.mjs';
2
2
  import 'qs';
3
3
  import './find.fd7de00e.mjs';
4
4
  import './round.a606b844.mjs';
@@ -64,7 +64,7 @@ const cardApi = {
64
64
  return value;
65
65
  }
66
66
 
67
- const parts = new String(value).split(/[\s\/\-]+/, 2);
67
+ const parts = new String(value).split(/[\s/-]+/, 2);
68
68
  const month = parts[0];
69
69
  let year = parts[1];
70
70
 
package/dist/cart.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'qs';
2
- import { c as cloneDeep } from './index.6938673d.mjs';
2
+ import { c as cloneDeep } from './index.95daac5a.mjs';
3
3
  import 'deepmerge';
4
4
  import 'fast-case';
5
5
  import { cleanProductOptions } from './products.mjs';
@@ -137,7 +137,7 @@ function methods(request, options) {
137
137
  if (options.updateCart) {
138
138
  return options.updateCart(input);
139
139
  }
140
- return this.requestStateChange('put', `/cart`, data);
140
+ return this.requestStateChange('put', '/cart', data);
141
141
  },
142
142
 
143
143
  applyCoupon(code) {
@@ -176,11 +176,11 @@ function methods(request, options) {
176
176
  async getOrder(checkoutId = undefined) {
177
177
  let result;
178
178
  if (checkoutId) {
179
- result = await request('get', `/cart/order`, {
179
+ result = await request('get', '/cart/order', {
180
180
  checkout_id: checkoutId,
181
181
  });
182
182
  } else {
183
- result = await request('get', `/cart/order`);
183
+ result = await request('get', '/cart/order');
184
184
  }
185
185
  this.order = result;
186
186
  return result;
@@ -1,4 +1,4 @@
1
- import { d as defaultMethods } from './index.6938673d.mjs';
1
+ import { d as defaultMethods } from './index.95daac5a.mjs';
2
2
  import cacheApi from './cache.mjs';
3
3
  import 'qs';
4
4
  import './find.fd7de00e.mjs';
package/dist/content.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import cacheApi from './cache.mjs';
2
- import './index.6938673d.mjs';
2
+ import './index.95daac5a.mjs';
3
3
  import 'qs';
4
4
  import './find.fd7de00e.mjs';
5
5
  import './round.a606b844.mjs';
package/dist/cookie.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as isServer } from './index.6938673d.mjs';
1
+ import { i as isServer } from './index.95daac5a.mjs';
2
2
  import 'qs';
3
3
  import './find.fd7de00e.mjs';
4
4
  import './round.a606b844.mjs';
@@ -1469,11 +1469,13 @@ function isEmpty(value) {
1469
1469
  return true;
1470
1470
  }
1471
1471
 
1472
+ /* global Buffer */
1473
+
1472
1474
  const LOADING_SCRIPTS = {};
1473
1475
 
1474
1476
  let options = {};
1475
1477
 
1476
- function merge(x, y, opt = {}) {
1478
+ function merge(x, y, _opt = {}) {
1477
1479
  if (!y || typeof y !== 'object') {
1478
1480
  return x;
1479
1481
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default } from './api.mjs';
2
2
  import './card.mjs';
3
- import './index.6938673d.mjs';
3
+ import './index.95daac5a.mjs';
4
4
  import 'qs';
5
5
  import './find.fd7de00e.mjs';
6
6
  import './round.a606b844.mjs';
package/dist/payment.mjs CHANGED
@@ -1,6 +1,6 @@
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, t as toSnake, v as vaultRequest, p as pick, n as toLower, o as isEmpty, r as reduce, q as isLiveMode, w as map, x as getLocationParams, y as removeUrlParams, a as toCamel } from './index.6938673d.mjs';
3
+ import { b as isObject, k as isFunction, l as loadScript, c as cloneDeep, t as toSnake, v as vaultRequest, p as pick, n as toLower, o as isEmpty, r as reduce, q as isLiveMode, w as map, x as getLocationParams, y as removeUrlParams, a as toCamel } from './index.95daac5a.mjs';
4
4
  import { g as get, t as toNumber } from './find.fd7de00e.mjs';
5
5
  import 'qs';
6
6
  import 'deepmerge';
@@ -1923,7 +1923,7 @@ class BraintreePaypalPayment extends Payment {
1923
1923
  });
1924
1924
  }
1925
1925
 
1926
- async _onApprove(paypalCheckout, data, actions) {
1926
+ async _onApprove(paypalCheckout, data, _actions) {
1927
1927
  const { require: { shipping: requireShipping = true } = {} } = this.params;
1928
1928
  const { details, nonce } = await paypalCheckout.tokenizePayment(data);
1929
1929
  const { email, countryCode, firstName, lastName } = details;
@@ -2809,7 +2809,7 @@ class PaypalDirectPayment extends Payment {
2809
2809
  }
2810
2810
  }
2811
2811
 
2812
- async _onCreateOrder(cart, data, actions) {
2812
+ async _onCreateOrder(cart, _data, _actions) {
2813
2813
  const { require: { shipping: requireShipping = true } = {} } = this.params;
2814
2814
  const { capture_total, currency, subscription_delivery } = cart;
2815
2815
  const hasSubscriptionProduct = Boolean(subscription_delivery);
@@ -3038,7 +3038,7 @@ class AmazonDirectPayment extends Payment {
3038
3038
  this.element = {
3039
3039
  ledgerCurrency: cart.currency,
3040
3040
  checkoutLanguage: locale,
3041
- productType: Boolean(requireShipping) ? 'PayAndShip' : 'PayOnly',
3041
+ productType: requireShipping ? 'PayAndShip' : 'PayOnly',
3042
3042
  buttonColor: color,
3043
3043
  placement,
3044
3044
  merchantId: this.merchantId,
package/dist/products.mjs CHANGED
@@ -1,4 +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.6938673d.mjs';
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.95daac5a.mjs';
2
2
  import cacheApi from './cache.mjs';
3
3
  import methods$1 from './attributes.mjs';
4
4
  import { g as get, f as find } from './find.fd7de00e.mjs';
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.6938673d.mjs';
1
+ import { s as set, a as toCamel, m as merge, c as cloneDeep, b as isObject, e as camelCase } from './index.95daac5a.mjs';
2
2
  import { g as get, f as find } from './find.fd7de00e.mjs';
3
3
  import 'qs';
4
4
  import './round.a606b844.mjs';
@@ -216,7 +216,7 @@ function decodeLocaleValue(locale, values, key, configs, opt) {
216
216
  let returnLocaleConfig;
217
217
  const localeKeys = Object.keys(values[key]);
218
218
  for (let localeKey of localeKeys) {
219
- const shortKey = localeKey.replace(/\-.+$/, '');
219
+ const shortKey = localeKey.replace(/-.+$/, '');
220
220
  const transformedLocale = opt.useCamelCase ? camelCase(locale) : locale;
221
221
 
222
222
  if (
@@ -233,7 +233,7 @@ function decodeLocaleValue(locale, values, key, configs, opt) {
233
233
  if (!returnLocaleKey && isObject(configs)) {
234
234
  const localeKeys = Object.keys(configs);
235
235
  for (let localeKey of localeKeys) {
236
- const shortKey = localeKey.replace(/\-.+$/, '');
236
+ const shortKey = localeKey.replace(/-.+$/, '');
237
237
  if (localeKey === locale || shortKey === locale) {
238
238
  returnLocaleKey = localeKey;
239
239
  returnLocaleConfig = configs[localeKey];
@@ -1,5 +1,5 @@
1
1
  import { cleanProductOptions } from './products.mjs';
2
- import { d as defaultMethods } from './index.6938673d.mjs';
2
+ import { d as defaultMethods } from './index.95daac5a.mjs';
3
3
  import cacheApi from './cache.mjs';
4
4
  import './attributes.mjs';
5
5
  import './find.fd7de00e.mjs';
package/dist/swell.cjs CHANGED
@@ -4493,11 +4493,13 @@ function isEmpty(value) {
4493
4493
  return true;
4494
4494
  }
4495
4495
 
4496
+ /* global Buffer */
4497
+
4496
4498
  const LOADING_SCRIPTS = {};
4497
4499
 
4498
4500
  let options$1 = {};
4499
4501
 
4500
- function merge(x, y, opt = {}) {
4502
+ function merge(x, y, _opt = {}) {
4501
4503
  if (!y || typeof y !== 'object') {
4502
4504
  return x;
4503
4505
  }
@@ -4876,7 +4878,7 @@ const cardApi = {
4876
4878
  return value;
4877
4879
  }
4878
4880
 
4879
- const parts = new String(value).split(/[\s\/\-]+/, 2);
4881
+ const parts = new String(value).split(/[\s/-]+/, 2);
4880
4882
  const month = parts[0];
4881
4883
  let year = parts[1];
4882
4884
 
@@ -5050,7 +5052,7 @@ const cacheApi = {
5050
5052
  set(details) {
5051
5053
  this.debug('cache.set', ...arguments);
5052
5054
  let { model, id, path, value } = details;
5053
- let { data = {}, record, presets } = this.values(details);
5055
+ let { data = {}, record } = this.values(details);
5054
5056
 
5055
5057
  if (id === null) {
5056
5058
  return;
@@ -5701,7 +5703,7 @@ function methods$a(request, options) {
5701
5703
  if (options.updateCart) {
5702
5704
  return options.updateCart(input);
5703
5705
  }
5704
- return this.requestStateChange('put', `/cart`, data);
5706
+ return this.requestStateChange('put', '/cart', data);
5705
5707
  },
5706
5708
 
5707
5709
  applyCoupon(code) {
@@ -5740,11 +5742,11 @@ function methods$a(request, options) {
5740
5742
  async getOrder(checkoutId = undefined) {
5741
5743
  let result;
5742
5744
  if (checkoutId) {
5743
- result = await request('get', `/cart/order`, {
5745
+ result = await request('get', '/cart/order', {
5744
5746
  checkout_id: checkoutId,
5745
5747
  });
5746
5748
  } else {
5747
- result = await request('get', `/cart/order`);
5749
+ result = await request('get', '/cart/order');
5748
5750
  }
5749
5751
  this.order = result;
5750
5752
  return result;
@@ -5836,7 +5838,7 @@ function methods$9(request) {
5836
5838
  },
5837
5839
 
5838
5840
  listOrders(query) {
5839
- return request('get', `/account/orders`, query);
5841
+ return request('get', '/account/orders', query);
5840
5842
  },
5841
5843
 
5842
5844
  getOrder(id) {
@@ -5844,14 +5846,26 @@ function methods$9(request) {
5844
5846
  },
5845
5847
 
5846
5848
  // Deprecated methods
5849
+
5850
+ /**
5851
+ * @deprecated use `listAddresses` instead
5852
+ */
5847
5853
  getAddresses(query) {
5848
5854
  return request('get', '/account/addresses', query);
5849
5855
  },
5856
+
5857
+ /**
5858
+ * @deprecated use `listCards` instead
5859
+ */
5850
5860
  getCards(query) {
5851
5861
  return request('get', '/account/cards', query);
5852
5862
  },
5863
+
5864
+ /**
5865
+ * @deprecated use `listOrders` instead
5866
+ */
5853
5867
  getOrders(query) {
5854
- return request('get', `/account/orders`, query);
5868
+ return request('get', '/account/orders', query);
5855
5869
  },
5856
5870
  };
5857
5871
  }
@@ -6169,7 +6183,7 @@ function decodeLocaleValue(locale, values, key, configs, opt) {
6169
6183
  let returnLocaleConfig;
6170
6184
  const localeKeys = Object.keys(values[key]);
6171
6185
  for (let localeKey of localeKeys) {
6172
- const shortKey = localeKey.replace(/\-.+$/, '');
6186
+ const shortKey = localeKey.replace(/-.+$/, '');
6173
6187
  const transformedLocale = opt.useCamelCase ? camelCase(locale) : locale;
6174
6188
 
6175
6189
  if (
@@ -6186,7 +6200,7 @@ function decodeLocaleValue(locale, values, key, configs, opt) {
6186
6200
  if (!returnLocaleKey && isObject(configs)) {
6187
6201
  const localeKeys = Object.keys(configs);
6188
6202
  for (let localeKey of localeKeys) {
6189
- const shortKey = localeKey.replace(/\-.+$/, '');
6203
+ const shortKey = localeKey.replace(/-.+$/, '');
6190
6204
  if (localeKey === locale || shortKey === locale) {
6191
6205
  returnLocaleKey = localeKey;
6192
6206
  returnLocaleConfig = configs[localeKey];
@@ -8189,7 +8203,7 @@ class BraintreePaypalPayment extends Payment {
8189
8203
  });
8190
8204
  }
8191
8205
 
8192
- async _onApprove(paypalCheckout, data, actions) {
8206
+ async _onApprove(paypalCheckout, data, _actions) {
8193
8207
  const { require: { shipping: requireShipping = true } = {} } = this.params;
8194
8208
  const { details, nonce } = await paypalCheckout.tokenizePayment(data);
8195
8209
  const { email, countryCode, firstName, lastName } = details;
@@ -9075,7 +9089,7 @@ class PaypalDirectPayment extends Payment {
9075
9089
  }
9076
9090
  }
9077
9091
 
9078
- async _onCreateOrder(cart, data, actions) {
9092
+ async _onCreateOrder(cart, _data, _actions) {
9079
9093
  const { require: { shipping: requireShipping = true } = {} } = this.params;
9080
9094
  const { capture_total, currency, subscription_delivery } = cart;
9081
9095
  const hasSubscriptionProduct = Boolean(subscription_delivery);
@@ -9304,7 +9318,7 @@ class AmazonDirectPayment extends Payment {
9304
9318
  this.element = {
9305
9319
  ledgerCurrency: cart.currency,
9306
9320
  checkoutLanguage: locale,
9307
- productType: Boolean(requireShipping) ? 'PayAndShip' : 'PayOnly',
9321
+ productType: requireShipping ? 'PayAndShip' : 'PayOnly',
9308
9322
  buttonColor: color,
9309
9323
  placement,
9310
9324
  merchantId: this.merchantId,
@@ -10153,7 +10167,7 @@ const options = {
10153
10167
  };
10154
10168
 
10155
10169
  const api = {
10156
- version: '4.0.8',
10170
+ version: '4.0.9',
10157
10171
  options,
10158
10172
  request,
10159
10173