@kiva/kv-shop 3.4.12 → 3.5.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 (2) hide show
  1. package/dist/shopError.js +22 -19
  2. package/package.json +2 -2
package/dist/shopError.js CHANGED
@@ -1,43 +1,46 @@
1
- class t extends Error {
2
- constructor({ code: n, original: a }, ...i) {
3
- super(...i), Error.captureStackTrace && Error.captureStackTrace(this, t), this.name = "ShopError", this.code = n, this.original = a;
1
+ class a extends Error {
2
+ constructor({ code: n, original: i }, ...t) {
3
+ super(...t), Error.captureStackTrace && Error.captureStackTrace(this, a), this.name = "ShopError", this.code = n, this.original = i;
4
4
  }
5
5
  aggregateErrors(n) {
6
6
  this.errors = n;
7
7
  }
8
8
  }
9
- function l(e) {
10
- var i;
11
- if (e instanceof t)
9
+ function u(e) {
10
+ var t;
11
+ if (e instanceof a)
12
12
  return e;
13
- const n = (e == null ? void 0 : e.code) ?? ((i = e == null ? void 0 : e.extensions) == null ? void 0 : i.code) ?? (e == null ? void 0 : e.name) ?? "", a = typeof e == "string" ? e : (e == null ? void 0 : e.message) ?? "";
14
- if (n === "invalidMethodParameter" && a.includes("paymentMethod.create"))
15
- return new t({
13
+ const n = (e == null ? void 0 : e.code) ?? ((t = e == null ? void 0 : e.extensions) == null ? void 0 : t.code) ?? (e == null ? void 0 : e.name) ?? "", i = typeof e == "string" ? e : (e == null ? void 0 : e.message) ?? "";
14
+ if (n === "invalidMethodParameter" && i.includes("paymentMethod.create"))
15
+ return new a({
16
16
  code: "paymentMethod.create.invalidMethodParameter",
17
17
  original: e
18
18
  }, "There was a problem validating your payment information. Please double-check the details and try again.");
19
- if (a.includes("Invalid request: ")) {
20
- const s = a.split("Invalid request: ")[1].split("., ").map((d) => d.matchAll(/[A-Z_]+: (.*)/g))[0], o = s[1], c = s[2];
21
- return new t({
19
+ if (i.includes("Invalid request: ")) {
20
+ const s = i.split("Invalid request: ")[1].split("., ").map((c) => c.matchAll(/[A-Z_]+: (.*)/g))[0], o = s[1], d = s[2];
21
+ return new a({
22
22
  code: `paymentMethod.${o}`,
23
23
  original: e
24
- }, c);
24
+ }, d);
25
25
  }
26
- return n === "insufficientFunds" || a.includes("There is not enough credit") ? new t({
26
+ return n === "insufficientFunds" || i.includes("There is not enough credit") ? new a({
27
27
  code: "shop.insufficientFunds",
28
28
  original: e
29
- }, "There is not enough money to complete the checkout. Please double-check the details and try again.") : n === "shop.invalidBasketId" || n === "shop.basketRequired" || n === "shop.alreadyCheckedOut" ? new t({
29
+ }, "There is not enough money to complete the checkout. Please double-check the details and try again.") : i.includes("already has a Giving Fund with category") ? new a({
30
+ code: "shop.givingfunds.duplicateFundCreation",
31
+ original: e
32
+ }, "You already have a giving fund supporting this group of people.") : n === "shop.invalidBasketId" || n === "shop.basketRequired" || n === "shop.alreadyCheckedOut" ? new a({
30
33
  code: n,
31
34
  original: e
32
- }, "There was a problem with your basket. Please, refresh the page and try again.") : n === "donationAmountTooLarge" ? new t({
35
+ }, "There was a problem with your basket. Please, refresh the page and try again.") : n === "donationAmountTooLarge" ? new a({
33
36
  code: n,
34
37
  original: e
35
- }, a) : new t({
38
+ }, i) : new a({
36
39
  code: "shop.unknown",
37
40
  original: e
38
41
  }, "An unknown error occurred.");
39
42
  }
40
43
  export {
41
- t as ShopError,
42
- l as parseShopError
44
+ a as ShopError,
45
+ u as parseShopError
43
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-shop",
3
- "version": "3.4.12",
3
+ "version": "3.5.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -55,5 +55,5 @@
55
55
  "numeral": "2.x",
56
56
  "vue": "3.x"
57
57
  },
58
- "gitHead": "59526ed2d6727f6ee60c0da4d5f40b9b264b29b9"
58
+ "gitHead": "b6059432f7edffe51c08713b0476f993fd8c356d"
59
59
  }