swell-js 4.2.5 → 5.0.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 (111) hide show
  1. package/dist/api.mjs +18 -5
  2. package/dist/settings.mjs +5 -1
  3. package/dist/swell.cjs +23 -6
  4. package/dist/swell.cjs.map +1 -1
  5. package/dist/swell.umd.min.js +23 -6
  6. package/dist/swell.umd.min.js.map +1 -1
  7. package/package.json +3 -2
  8. package/types/account/camel.ts +26 -0
  9. package/types/account/index.ts +26 -0
  10. package/types/account/{snake.d.ts → snake.ts} +8 -10
  11. package/types/attribute/camel.ts +15 -0
  12. package/types/attribute/index.ts +8 -0
  13. package/types/attribute/{snake.d.ts → snake.ts} +3 -4
  14. package/types/billing/camel.ts +39 -0
  15. package/types/billing/index.ts +21 -0
  16. package/types/billing/{snake.d.ts → snake.ts} +9 -18
  17. package/types/card/camel.ts +28 -0
  18. package/types/card/index.ts +26 -0
  19. package/types/card/{snake.d.ts → snake.ts} +6 -6
  20. package/types/cart/camel.ts +95 -0
  21. package/types/cart/index.ts +45 -0
  22. package/types/cart/{snake.d.ts → snake.ts} +20 -31
  23. package/types/category/camel.ts +21 -0
  24. package/types/category/index.ts +8 -0
  25. package/types/category/{snake.d.ts → snake.ts} +3 -5
  26. package/types/content/camel.ts +6 -0
  27. package/types/content/index.ts +8 -0
  28. package/types/content/{snake.d.ts → snake.ts} +3 -5
  29. package/types/coupon/camel.ts +15 -0
  30. package/types/coupon/index.ts +2 -0
  31. package/types/coupon/{snake.d.ts → snake.ts} +3 -3
  32. package/types/currency/camel.ts +14 -0
  33. package/types/currency/index.ts +34 -0
  34. package/types/currency/{snake.d.ts → snake.ts} +3 -3
  35. package/types/discount/camel.ts +32 -0
  36. package/types/discount/index.ts +7 -0
  37. package/types/discount/{snake.d.ts → snake.ts} +7 -9
  38. package/types/giftcard/camel.ts +30 -0
  39. package/types/giftcard/index.ts +2 -0
  40. package/types/giftcard/{snake.d.ts → snake.ts} +7 -9
  41. package/types/index.d.ts +407 -397
  42. package/types/invoice/camel.ts +37 -0
  43. package/types/invoice/index.ts +8 -0
  44. package/types/invoice/{snake.d.ts → snake.ts} +11 -11
  45. package/types/order/camel.ts +79 -0
  46. package/types/order/index.ts +32 -0
  47. package/types/order/{snake.d.ts → snake.ts} +18 -26
  48. package/types/payment/camel.ts +58 -0
  49. package/types/payment/index.ts +79 -0
  50. package/types/payment/{snake.d.ts → snake.ts} +16 -21
  51. package/types/product/camel.ts +86 -0
  52. package/types/product/index.ts +72 -0
  53. package/types/product/{snake.d.ts → snake.ts} +12 -23
  54. package/types/promotion/camel.ts +28 -0
  55. package/types/promotion/index.ts +2 -0
  56. package/types/promotion/{snake.d.ts → snake.ts} +6 -8
  57. package/types/purchase_link/camel.ts +21 -0
  58. package/types/purchase_link/index.ts +2 -0
  59. package/types/purchase_link/{snake.d.ts → snake.ts} +6 -6
  60. package/types/refund/camel.ts +19 -0
  61. package/types/refund/index.ts +2 -0
  62. package/types/refund/{snake.d.ts → snake.ts} +5 -5
  63. package/types/shipment_rating/camel.ts +15 -0
  64. package/types/shipment_rating/index.ts +2 -0
  65. package/types/shipment_rating/{snake.d.ts → snake.ts} +2 -4
  66. package/types/subscription/camel.ts +61 -0
  67. package/types/subscription/index.ts +28 -0
  68. package/types/subscription/{snake.d.ts → snake.ts} +14 -20
  69. package/types/utils.ts +10 -0
  70. package/types/account/camel.d.ts +0 -8
  71. package/types/account/index.d.ts +0 -9
  72. package/types/attribute/camel.d.ts +0 -4
  73. package/types/attribute/index.d.ts +0 -4
  74. package/types/billing/camel.d.ts +0 -25
  75. package/types/billing/index.d.ts +0 -38
  76. package/types/card/camel.d.ts +0 -9
  77. package/types/card/index.d.ts +0 -9
  78. package/types/cart/camel.d.ts +0 -32
  79. package/types/cart/index.d.ts +0 -46
  80. package/types/category/camel.d.ts +0 -4
  81. package/types/category/index.d.ts +0 -4
  82. package/types/content/camel.d.ts +0 -5
  83. package/types/content/index.d.ts +0 -8
  84. package/types/coupon/camel.d.ts +0 -4
  85. package/types/coupon/index.d.ts +0 -4
  86. package/types/currency/camel.d.ts +0 -15
  87. package/types/currency/index.d.ts +0 -21
  88. package/types/discount/camel.d.ts +0 -15
  89. package/types/discount/index.d.ts +0 -18
  90. package/types/giftcard/camel.d.ts +0 -6
  91. package/types/giftcard/index.d.ts +0 -5
  92. package/types/invoice/camel.d.ts +0 -4
  93. package/types/invoice/index.d.ts +0 -4
  94. package/types/order/camel.d.ts +0 -15
  95. package/types/order/index.d.ts +0 -20
  96. package/types/payment/camel.d.ts +0 -35
  97. package/types/payment/index.d.ts +0 -51
  98. package/types/product/camel.d.ts +0 -24
  99. package/types/product/index.d.ts +0 -49
  100. package/types/promotion/camel.d.ts +0 -7
  101. package/types/promotion/index.d.ts +0 -8
  102. package/types/purchase_link/camel.d.ts +0 -4
  103. package/types/purchase_link/index.d.ts +0 -4
  104. package/types/refund/camel.d.ts +0 -4
  105. package/types/refund/index.d.ts +0 -4
  106. package/types/shipment_rating/camel.d.ts +0 -7
  107. package/types/shipment_rating/index.d.ts +0 -10
  108. package/types/subscription/camel.d.ts +0 -15
  109. package/types/subscription/index.d.ts +0 -21
  110. /package/types/locale/{index.d.ts → index.ts} +0 -0
  111. /package/types/settings/{index.d.ts → index.ts} +0 -0
package/dist/api.mjs CHANGED
@@ -126,12 +126,21 @@ function methods(api, _opt) {
126
126
  };
127
127
  }
128
128
 
129
+ /** @typedef {import('../types').InitOptions} InitOptions */
130
+
131
+ /**
132
+ * @template {'snake' | 'camel'} C
133
+ * @typedef {import('../types').SwellClient<C>} SwellClient<C>
134
+ */
135
+
129
136
  /**
130
137
  * Swell API client
131
- * @param {string} initStore - Store name
132
- * @param {string} initKey - API key
133
- * @param {InitOptions} initOptions - Options
134
- * @returns {SwellClient} API client
138
+ *
139
+ * @template {'snake' | 'camel'} C
140
+ * @param {string} [initStore] - Store name
141
+ * @param {string} [initKey] - API key
142
+ * @param {InitOptions} [initOptions] - Options
143
+ * @returns {SwellClient<C>} API client
135
144
  */
136
145
  function swell(initStore = undefined, initKey, initOptions = {}) {
137
146
  const options = {
@@ -145,7 +154,7 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
145
154
  const api = {};
146
155
 
147
156
  Object.assign(api, {
148
- version: '4.2.5',
157
+ version: '5.0.0',
149
158
  options,
150
159
  request,
151
160
 
@@ -228,6 +237,10 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
228
237
  functions: methods(api),
229
238
 
230
239
  utils,
240
+
241
+ getCookie,
242
+
243
+ setCookie,
231
244
  });
232
245
 
233
246
  async function request(
package/dist/settings.mjs CHANGED
@@ -181,7 +181,11 @@ function methods(api, opt) {
181
181
  value: session,
182
182
  });
183
183
  } catch (err) {
184
- console.error(`Swell: unable to load settings (${err})`);
184
+ if (err instanceof Error) {
185
+ err.message = `Swell: unable to load settings (${err.message})`;
186
+ }
187
+
188
+ console.error(err);
185
189
  }
186
190
  },
187
191
  };
package/dist/swell.cjs CHANGED
@@ -6155,7 +6155,11 @@ function methods$4(api, opt) {
6155
6155
  value: session,
6156
6156
  });
6157
6157
  } catch (err) {
6158
- console.error(`Swell: unable to load settings (${err})`);
6158
+ if (err instanceof Error) {
6159
+ err.message = `Swell: unable to load settings (${err.message})`;
6160
+ }
6161
+
6162
+ console.error(err);
6159
6163
  }
6160
6164
  },
6161
6165
  };
@@ -10157,12 +10161,21 @@ function methods(api, _opt) {
10157
10161
  };
10158
10162
  }
10159
10163
 
10164
+ /** @typedef {import('../types').InitOptions} InitOptions */
10165
+
10166
+ /**
10167
+ * @template {'snake' | 'camel'} C
10168
+ * @typedef {import('../types').SwellClient<C>} SwellClient<C>
10169
+ */
10170
+
10160
10171
  /**
10161
10172
  * Swell API client
10162
- * @param {string} initStore - Store name
10163
- * @param {string} initKey - API key
10164
- * @param {InitOptions} initOptions - Options
10165
- * @returns {SwellClient} API client
10173
+ *
10174
+ * @template {'snake' | 'camel'} C
10175
+ * @param {string} [initStore] - Store name
10176
+ * @param {string} [initKey] - API key
10177
+ * @param {InitOptions} [initOptions] - Options
10178
+ * @returns {SwellClient<C>} API client
10166
10179
  */
10167
10180
  function swell(initStore = undefined, initKey, initOptions = {}) {
10168
10181
  const options = {
@@ -10176,7 +10189,7 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
10176
10189
  const api = {};
10177
10190
 
10178
10191
  Object.assign(api, {
10179
- version: '4.2.5',
10192
+ version: '5.0.0',
10180
10193
  options,
10181
10194
  request,
10182
10195
 
@@ -10259,6 +10272,10 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
10259
10272
  functions: methods(api),
10260
10273
 
10261
10274
  utils,
10275
+
10276
+ getCookie,
10277
+
10278
+ setCookie,
10262
10279
  });
10263
10280
 
10264
10281
  async function request(