@kiva/kv-shop 2.1.2 → 3.0.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 (76) hide show
  1. package/dist/_virtual/_commonjs-dynamic-modules.js +6 -0
  2. package/dist/_virtual/_commonjsHelpers.js +8 -0
  3. package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
  4. package/dist/_virtual/dropin.js +11 -0
  5. package/dist/_virtual/dropin2.js +4 -0
  6. package/dist/basket.js +35 -12
  7. package/dist/basketCredits.js +78 -14
  8. package/dist/basketItems.js +27 -8
  9. package/dist/basketTotals.js +38 -10
  10. package/dist/basketVerification.js +6 -6
  11. package/dist/checkoutStatus.js +52 -8
  12. package/dist/components/KvPaymentSelect.css +1 -0
  13. package/dist/components/KvPaymentSelect.js +23 -0
  14. package/dist/components/KvPaymentSelect2.js +110 -0
  15. package/dist/index.d.ts +321 -20
  16. package/dist/index.js +49 -96
  17. package/dist/managedAccount.js +62 -8
  18. package/dist/oneTimeCheckout.js +156 -12
  19. package/dist/receipt.js +143 -12
  20. package/dist/shopError.js +41 -6
  21. package/dist/shopQueries.js +82 -11
  22. package/dist/subscriptionCheckout.js +88 -7
  23. package/dist/useBraintreeDropIn.js +145 -9
  24. package/dist/util/cookie.js +11 -0
  25. package/dist/util/poll.js +17 -0
  26. package/dist/util/redirect.js +8 -0
  27. package/dist/util/visitorId.js +7 -0
  28. package/dist/validatePreCheckout.js +44 -11
  29. package/dist/vendor/braintree-web-drop-in/dist/browser/dropin.js +12223 -0
  30. package/package.json +28 -26
  31. package/dist/basket.cjs +0 -141
  32. package/dist/basket.d.ts +0 -8
  33. package/dist/basketCredits.cjs +0 -250
  34. package/dist/basketCredits.d.ts +0 -32
  35. package/dist/basketItems.cjs +0 -205
  36. package/dist/basketItems.d.ts +0 -26
  37. package/dist/basketTotals.cjs +0 -228
  38. package/dist/basketTotals.d.ts +0 -37
  39. package/dist/basketVerification.cjs +0 -41
  40. package/dist/basketVerification.d.ts +0 -10
  41. package/dist/checkoutStatus.cjs +0 -111
  42. package/dist/checkoutStatus.d.ts +0 -20
  43. package/dist/chunk-4ODZGLWK.js +0 -64
  44. package/dist/chunk-ASZJVUQ7.js +0 -72
  45. package/dist/chunk-FBF4WMN6.js +0 -49
  46. package/dist/chunk-FC4QW6QA.js +0 -106
  47. package/dist/chunk-FCAOCO7O.js +0 -17
  48. package/dist/chunk-GVVI7X2R.js +0 -196
  49. package/dist/chunk-IIN37LC7.js +0 -45
  50. package/dist/chunk-IOZ5ERDX.js +0 -121
  51. package/dist/chunk-KCUOMCSN.js +0 -58
  52. package/dist/chunk-LZ4UMRCV.js +0 -16
  53. package/dist/chunk-RQNRQ2E5.js +0 -155
  54. package/dist/chunk-SRGYGDAX.js +0 -80
  55. package/dist/chunk-TPJPGUO7.js +0 -12
  56. package/dist/chunk-UJXHTR43.js +0 -86
  57. package/dist/chunk-VZ3VDRRP.js +0 -167
  58. package/dist/chunk-Z7JRY3QE.js +0 -34
  59. package/dist/components/KvPaymentSelect.vue +0 -380
  60. package/dist/index.cjs +0 -1227
  61. package/dist/managedAccount.cjs +0 -231
  62. package/dist/managedAccount.d.ts +0 -59
  63. package/dist/oneTimeCheckout.cjs +0 -636
  64. package/dist/oneTimeCheckout.d.ts +0 -21
  65. package/dist/receipt.cjs +0 -191
  66. package/dist/receipt.d.ts +0 -16
  67. package/dist/shopError.cjs +0 -88
  68. package/dist/shopError.d.ts +0 -14
  69. package/dist/shopQueries.cjs +0 -248
  70. package/dist/shopQueries.d.ts +0 -8
  71. package/dist/subscriptionCheckout.cjs +0 -187
  72. package/dist/subscriptionCheckout.d.ts +0 -13
  73. package/dist/useBraintreeDropIn.cjs +0 -258
  74. package/dist/useBraintreeDropIn.d.ts +0 -25
  75. package/dist/validatePreCheckout.cjs +0 -218
  76. package/dist/validatePreCheckout.d.ts +0 -28
package/dist/receipt.cjs DELETED
@@ -1,191 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/receipt.ts
20
- var receipt_exports = {};
21
- __export(receipt_exports, {
22
- getCheckoutTrackingData: () => getCheckoutTrackingData,
23
- getFTDStatus: () => getFTDStatus,
24
- getReceiptItems: () => getReceiptItems,
25
- getReceiptTotals: () => getReceiptTotals
26
- });
27
- module.exports = __toCommonJS(receipt_exports);
28
- var import_core = require("@apollo/client/core/core.cjs");
29
-
30
- // src/util/cookie.ts
31
- var getCookieValue = (name) => {
32
- if (typeof document !== void 0) {
33
- return decodeURIComponent(document.cookie.match(`(^|;)\\s*${name}\\s*=\\s*([^;]+)`)?.pop() || "");
34
- }
35
- };
36
-
37
- // src/util/visitorId.ts
38
- function getVisitorID() {
39
- return getCookieValue("uiv");
40
- }
41
-
42
- // src/receipt.ts
43
- async function getFTDStatus(apollo) {
44
- const result = await apollo.query({
45
- query: import_core.gql`
46
- query ftdStatus {
47
- my {
48
- id
49
- userAccount {
50
- id
51
- isFirstTimeDepositor
52
- }
53
- }
54
- }
55
- `
56
- });
57
- return result.data?.my?.userAccount?.isFirstTimeDepositor ?? false;
58
- }
59
- async function getReceiptItems(apollo, checkoutId) {
60
- return new Promise((resolve, reject) => {
61
- const limit = 100;
62
- let offset = 0;
63
- const observer = apollo.watchQuery({
64
- query: import_core.gql`
65
- query receiptItems($checkoutId: Int, $visitorId: String, $limit: Int, $offset: Int) {
66
- shop {
67
- id
68
- receipt(checkoutId: $checkoutId, visitorId: $visitorId) {
69
- id
70
- items(limit: $limit, offset: $offset) {
71
- totalCount
72
- values {
73
- id
74
- price
75
- __typename
76
-
77
- ... on Donation {
78
- id
79
- isTip
80
- isUserEdited
81
- }
82
- }
83
- }
84
- }
85
- }
86
- }
87
- `,
88
- variables: {
89
- checkoutId,
90
- visitorId: getVisitorID(),
91
- limit,
92
- offset
93
- }
94
- });
95
- let items = [];
96
- const handleResult = async (result) => {
97
- const total = result.data?.shop?.receipt?.items?.totalCount;
98
- items = items.concat(result.data?.shop?.receipt?.items?.values);
99
- if (total > offset + limit) {
100
- offset += limit;
101
- const nextResult = await observer.fetchMore({
102
- variables: {
103
- offset
104
- }
105
- });
106
- try {
107
- handleResult(nextResult);
108
- } catch (e) {
109
- reject(e);
110
- }
111
- } else {
112
- resolve(items);
113
- }
114
- };
115
- observer.subscribe({
116
- next: handleResult,
117
- error: (error) => {
118
- reject(error);
119
- }
120
- });
121
- });
122
- }
123
- async function getReceiptTotals(apollo, checkoutId) {
124
- const result = await apollo.query({
125
- query: import_core.gql`
126
- query receiptTotals($checkoutId: Int, $visitorId: String) {
127
- shop {
128
- id
129
- receipt(checkoutId: $checkoutId, visitorId: $visitorId) {
130
- id
131
- totals {
132
- loanReservationTotal
133
- donationTotal
134
- kivaCardTotal
135
- itemTotal
136
- kivaCreditAppliedTotal
137
- depositTotals {
138
- depositTotal
139
- }
140
- }
141
- }
142
- }
143
- }
144
- `,
145
- variables: {
146
- checkoutId,
147
- visitorId: getVisitorID()
148
- }
149
- });
150
- return result.data?.shop?.receipt?.totals;
151
- }
152
- async function getCheckoutTrackingData(apollo, checkoutId, paymentType) {
153
- const checkoutIdInt = parseInt(checkoutId, 10);
154
- const [isFTD, items, totals] = await Promise.all([
155
- getFTDStatus(apollo),
156
- getReceiptItems(apollo, checkoutIdInt),
157
- getReceiptTotals(apollo, checkoutIdInt)
158
- ]);
159
- const loans = items.filter((item) => item.__typename === "LoanReservation");
160
- const donations = items.filter((item) => item.__typename === "Donation");
161
- const kivaCards = items.filter((item) => item.__typename === "KivaCard");
162
- return {
163
- transactionId: checkoutId,
164
- itemTotal: totals.itemTotal,
165
- // Loan reservations
166
- loans,
167
- loanCount: loans.length,
168
- loanTotal: totals.loanReservationTotal,
169
- // Donations
170
- donations: donations.map(({ id, price, __typename }) => ({ id, price, __typename })),
171
- donationTotal: totals.donationTotal,
172
- isTip: donations.every((donation) => donation.isTip),
173
- isUserEdited: donations.some((donation) => donation.isUserEdited),
174
- // Kiva Cards
175
- kivaCards,
176
- kivaCardCount: kivaCards.length,
177
- kivaCardTotal: totals.kivaCardTotal,
178
- // Credit & deposit
179
- kivaCreditAppliedTotal: totals.kivaCreditAppliedTotal,
180
- depositTotal: totals.depositTotals?.depositTotal ?? "0.00",
181
- paymentType,
182
- isFTD
183
- };
184
- }
185
- // Annotate the CommonJS export names for ESM import in node:
186
- 0 && (module.exports = {
187
- getCheckoutTrackingData,
188
- getFTDStatus,
189
- getReceiptItems,
190
- getReceiptTotals
191
- });
package/dist/receipt.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { ApolloClient } from '@apollo/client/core/core.cjs';
2
- import { TransactionData } from '@kiva/kv-analytics';
3
-
4
- declare function getFTDStatus(apollo: ApolloClient<any>): Promise<any>;
5
- interface ReceiptItem {
6
- id: string;
7
- price: string;
8
- __typename: string;
9
- isTip?: boolean;
10
- isUserEdited?: boolean;
11
- }
12
- declare function getReceiptItems(apollo: ApolloClient<any>, checkoutId: number): Promise<ReceiptItem[]>;
13
- declare function getReceiptTotals(apollo: ApolloClient<any>, checkoutId: number): Promise<any>;
14
- declare function getCheckoutTrackingData(apollo: ApolloClient<any>, checkoutId: string, paymentType: string): Promise<TransactionData>;
15
-
16
- export { getCheckoutTrackingData, getFTDStatus, getReceiptItems, getReceiptTotals };
@@ -1,88 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/shopError.ts
20
- var shopError_exports = {};
21
- __export(shopError_exports, {
22
- ShopError: () => ShopError,
23
- parseShopError: () => parseShopError
24
- });
25
- module.exports = __toCommonJS(shopError_exports);
26
- var ShopError = class extends Error {
27
- constructor({ code, original }, ...params) {
28
- super(...params);
29
- if (Error.captureStackTrace) {
30
- Error.captureStackTrace(this, ShopError);
31
- }
32
- this.name = "ShopError";
33
- this.code = code;
34
- this.original = original;
35
- }
36
- aggregateErrors(errors) {
37
- this.errors = errors;
38
- }
39
- };
40
- function parseShopError(error) {
41
- if (error instanceof ShopError) {
42
- return error;
43
- }
44
- const errorCode = error?.code ?? error?.extensions?.code ?? error?.name ?? "";
45
- const errorMessage = typeof error === "string" ? error : error?.message ?? "";
46
- if (errorCode === "invalidMethodParameter" && errorMessage.includes("paymentMethod.create")) {
47
- return new ShopError({
48
- code: "paymentMethod.create.invalidMethodParameter",
49
- original: error
50
- }, "There was a problem validating your payment information. Please double-check the details and try again.");
51
- }
52
- if (errorMessage.includes("Invalid request: ")) {
53
- const finalError = errorMessage.split("Invalid request: ")[1].split("., ").map((e) => e.matchAll(/[A-Z_]+: (.*)/g))[0];
54
- const finalCode = finalError[1];
55
- const finalMessage = finalError[2];
56
- return new ShopError({
57
- code: `paymentMethod.${finalCode}`,
58
- original: error
59
- }, finalMessage);
60
- }
61
- if (errorCode === "insufficientFunds" || errorMessage.includes("There is not enough credit")) {
62
- return new ShopError({
63
- code: "shop.insufficientFunds",
64
- original: error
65
- }, "There is not enough money to complete the checkout. Please double-check the details and try again.");
66
- }
67
- if (errorCode === "shop.invalidBasketId" || errorCode === "shop.basketRequired" || errorCode === "shop.alreadyCheckedOut") {
68
- return new ShopError({
69
- code: errorCode,
70
- original: error
71
- }, "There was a problem with your basket. Please, refresh the page and try again.");
72
- }
73
- if (errorCode === "donationAmountTooLarge") {
74
- return new ShopError({
75
- code: errorCode,
76
- original: error
77
- }, errorMessage);
78
- }
79
- return new ShopError({
80
- code: "shop.unknown",
81
- original: error
82
- }, "An unknown error occurred.");
83
- }
84
- // Annotate the CommonJS export names for ESM import in node:
85
- 0 && (module.exports = {
86
- ShopError,
87
- parseShopError
88
- });
@@ -1,14 +0,0 @@
1
- interface ShopErrorOptions {
2
- code: string;
3
- original?: object;
4
- }
5
- declare class ShopError extends Error {
6
- code: string;
7
- original?: object;
8
- errors?: Array<ShopError>;
9
- constructor({ code, original }: ShopErrorOptions, ...params: any[]);
10
- aggregateErrors(errors: Array<ShopError>): void;
11
- }
12
- declare function parseShopError(error: any): ShopError;
13
-
14
- export { ShopError, ShopErrorOptions, parseShopError };
@@ -1,248 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/shopQueries.ts
20
- var shopQueries_exports = {};
21
- __export(shopQueries_exports, {
22
- callShopMutation: () => callShopMutation,
23
- callShopQuery: () => callShopQuery,
24
- watchShopQuery: () => watchShopQuery
25
- });
26
- module.exports = __toCommonJS(shopQueries_exports);
27
-
28
- // src/basket.ts
29
- var import_core = require("@apollo/client/core/core.cjs");
30
-
31
- // src/util/cookie.ts
32
- var getCookieValue = (name) => {
33
- if (typeof document !== void 0) {
34
- return decodeURIComponent(document.cookie.match(`(^|;)\\s*${name}\\s*=\\s*([^;]+)`)?.pop() || "");
35
- }
36
- };
37
- var setCookieValue = (name, value, options = "") => {
38
- if (typeof document !== void 0) {
39
- document.cookie = `${name}=${encodeURIComponent(value)};${options}`;
40
- }
41
- };
42
-
43
- // src/shopError.ts
44
- var ShopError = class extends Error {
45
- constructor({ code, original }, ...params) {
46
- super(...params);
47
- if (Error.captureStackTrace) {
48
- Error.captureStackTrace(this, ShopError);
49
- }
50
- this.name = "ShopError";
51
- this.code = code;
52
- this.original = original;
53
- }
54
- aggregateErrors(errors) {
55
- this.errors = errors;
56
- }
57
- };
58
- function parseShopError(error) {
59
- if (error instanceof ShopError) {
60
- return error;
61
- }
62
- const errorCode = error?.code ?? error?.extensions?.code ?? error?.name ?? "";
63
- const errorMessage = typeof error === "string" ? error : error?.message ?? "";
64
- if (errorCode === "invalidMethodParameter" && errorMessage.includes("paymentMethod.create")) {
65
- return new ShopError({
66
- code: "paymentMethod.create.invalidMethodParameter",
67
- original: error
68
- }, "There was a problem validating your payment information. Please double-check the details and try again.");
69
- }
70
- if (errorMessage.includes("Invalid request: ")) {
71
- const finalError = errorMessage.split("Invalid request: ")[1].split("., ").map((e) => e.matchAll(/[A-Z_]+: (.*)/g))[0];
72
- const finalCode = finalError[1];
73
- const finalMessage = finalError[2];
74
- return new ShopError({
75
- code: `paymentMethod.${finalCode}`,
76
- original: error
77
- }, finalMessage);
78
- }
79
- if (errorCode === "insufficientFunds" || errorMessage.includes("There is not enough credit")) {
80
- return new ShopError({
81
- code: "shop.insufficientFunds",
82
- original: error
83
- }, "There is not enough money to complete the checkout. Please double-check the details and try again.");
84
- }
85
- if (errorCode === "shop.invalidBasketId" || errorCode === "shop.basketRequired" || errorCode === "shop.alreadyCheckedOut") {
86
- return new ShopError({
87
- code: errorCode,
88
- original: error
89
- }, "There was a problem with your basket. Please, refresh the page and try again.");
90
- }
91
- if (errorCode === "donationAmountTooLarge") {
92
- return new ShopError({
93
- code: errorCode,
94
- original: error
95
- }, errorMessage);
96
- }
97
- return new ShopError({
98
- code: "shop.unknown",
99
- original: error
100
- }, "An unknown error occurred.");
101
- }
102
-
103
- // src/basket.ts
104
- function getBasketID() {
105
- return getCookieValue("kvbskt");
106
- }
107
- function setBasketID(basketId) {
108
- setCookieValue("kvbskt", basketId, "path=/;secure;");
109
- }
110
- async function createBasketHelper(apollo) {
111
- try {
112
- return apollo.mutate({
113
- mutation: import_core.gql`mutation createNewBasketForUser { shop { id createBasket } }`
114
- }).then(({ data }) => {
115
- const newBasketId = data.shop?.createBasket ?? null;
116
- if (newBasketId) {
117
- setBasketID(newBasketId);
118
- }
119
- });
120
- } catch (error) {
121
- throw parseShopError(error);
122
- }
123
- }
124
- var activeBasketCreationQuery = null;
125
- async function createBasket(apollo) {
126
- if (activeBasketCreationQuery) {
127
- return activeBasketCreationQuery;
128
- }
129
- activeBasketCreationQuery = createBasketHelper(apollo);
130
- return activeBasketCreationQuery;
131
- }
132
- function hasBasketExpired(error) {
133
- const errorCode = error?.code ?? error?.extensions?.code ?? error?.name ?? "";
134
- return ["shop.invalidBasketId", "shop.basketRequired", "shop.alreadyCheckedOut"].includes(errorCode);
135
- }
136
-
137
- // src/shopQueries.ts
138
- var watchQueries = /* @__PURE__ */ new Set();
139
- async function callShopMutation(apollo, options, maxretries = 2) {
140
- try {
141
- const result = await apollo.mutate({
142
- ...options,
143
- variables: {
144
- ...options.variables,
145
- basketId: getBasketID()
146
- },
147
- refetchQueries: options.awaitRefetchQueries ? Array.from(watchQueries) : []
148
- });
149
- if (result?.errors?.length) {
150
- const basketErrors = result?.errors.filter((err) => hasBasketExpired(err));
151
- if (basketErrors.length) {
152
- if (maxretries > 0) {
153
- await createBasket(apollo);
154
- return callShopMutation(apollo, options, maxretries - 1);
155
- }
156
- throw basketErrors[0];
157
- }
158
- if (result?.errors?.length) {
159
- throw result.errors[0];
160
- }
161
- }
162
- return result?.data;
163
- } catch (e) {
164
- throw parseShopError(e);
165
- }
166
- }
167
- async function callShopQuery(apollo, options, maxretries = 2) {
168
- try {
169
- const result = await apollo.query({
170
- ...options,
171
- variables: {
172
- ...options.variables,
173
- basketId: getBasketID()
174
- }
175
- });
176
- if (result?.errors?.length) {
177
- const basketErrors = result?.errors.filter((err) => hasBasketExpired(err));
178
- if (basketErrors.length) {
179
- if (maxretries > 0) {
180
- await createBasket(apollo);
181
- return callShopQuery(apollo, options, maxretries - 1);
182
- }
183
- throw basketErrors[0];
184
- }
185
- if (result?.errors?.length) {
186
- throw result.errors[0];
187
- }
188
- }
189
- return result?.data;
190
- } catch (e) {
191
- throw parseShopError(e);
192
- }
193
- }
194
- function watchShopQuery(apollo, options, maxretries = 2) {
195
- let retries = 0;
196
- watchQueries.add(options.query);
197
- const observable = apollo.watchQuery({
198
- ...options,
199
- variables: {
200
- ...options.variables,
201
- basketId: getBasketID()
202
- }
203
- });
204
- const oldSubscribe = observable.subscribe.bind(observable);
205
- observable.subscribe = (...args) => {
206
- let nextFn;
207
- let errorFn;
208
- let completeFn;
209
- if (typeof args[0] === "function") {
210
- [nextFn, errorFn, completeFn] = args;
211
- } else {
212
- nextFn = args[0]?.next;
213
- errorFn = args[0]?.error;
214
- completeFn = args[0]?.complete;
215
- }
216
- const newErrorFn = (err) => {
217
- const basketErrors = err?.graphQLErrors?.filter((e) => hasBasketExpired(e));
218
- if (basketErrors.length) {
219
- if (retries < maxretries) {
220
- createBasket(apollo).then(() => {
221
- retries += 1;
222
- observable.refetch({
223
- ...observable.variables,
224
- basketId: getBasketID()
225
- });
226
- });
227
- } else {
228
- errorFn(parseShopError(basketErrors[0]));
229
- }
230
- } else {
231
- if (err?.graphQLErrors?.length) {
232
- errorFn(parseShopError(err.graphQLErrors[0]));
233
- }
234
- if (err?.networkError) {
235
- errorFn(parseShopError(err.networkError));
236
- }
237
- }
238
- };
239
- return oldSubscribe(nextFn, newErrorFn, completeFn);
240
- };
241
- return observable;
242
- }
243
- // Annotate the CommonJS export names for ESM import in node:
244
- 0 && (module.exports = {
245
- callShopMutation,
246
- callShopQuery,
247
- watchShopQuery
248
- });
@@ -1,8 +0,0 @@
1
- import * as _apollo_client_core_ObservableQuery from '@apollo/client/core/ObservableQuery';
2
- import { ApolloClient, MutationOptions, QueryOptions, WatchQueryOptions } from '@apollo/client/core/core.cjs';
3
-
4
- declare function callShopMutation<TData>(apollo: ApolloClient<any>, options: MutationOptions<TData, any>, maxretries?: number): Promise<TData>;
5
- declare function callShopQuery<TData>(apollo: ApolloClient<any>, options: QueryOptions<any, TData>, maxretries?: number): Promise<TData>;
6
- declare function watchShopQuery<TData>(apollo: ApolloClient<any>, options: WatchQueryOptions<any, TData>, maxretries?: number): _apollo_client_core_ObservableQuery.ObservableQuery<TData, any>;
7
-
8
- export { callShopMutation, callShopQuery, watchShopQuery };