@kiva/kv-shop 1.10.32 → 1.11.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.
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var basketCredits_exports = {};
21
21
  __export(basketCredits_exports, {
22
22
  applyKivaCredit: () => applyKivaCredit,
23
- removeKivaCredit: () => removeKivaCredit
23
+ applyPromoCredit: () => applyPromoCredit,
24
+ removeKivaCredit: () => removeKivaCredit,
25
+ removePromoCredit: () => removePromoCredit
24
26
  });
25
27
  module.exports = __toCommonJS(basketCredits_exports);
26
28
  var import_core2 = require("@apollo/client/core");
@@ -190,8 +192,42 @@ async function removeKivaCredit(apollo) {
190
192
  });
191
193
  return !!data?.shop?.removeCreditByType;
192
194
  }
195
+ async function applyPromoCredit(apollo) {
196
+ const data = await callShopMutation(apollo, {
197
+ awaitRefetchQueries: true,
198
+ mutation: import_core2.gql`mutation applyPromoCredit(
199
+ $basketId: String,
200
+ $creditType: CreditTypeEnum!,
201
+ $redemptionCode: String
202
+ ) {
203
+ shop (basketId: $basketId) {
204
+ id
205
+ addCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
206
+ }
207
+ }`
208
+ });
209
+ return !!data?.shop?.addCreditByType;
210
+ }
211
+ async function removePromoCredit(apollo) {
212
+ const data = await callShopMutation(apollo, {
213
+ awaitRefetchQueries: true,
214
+ mutation: import_core2.gql`mutation removePromoCredit(
215
+ $basketId: String,
216
+ $creditType: CreditTypeEnum!,
217
+ $redemptionCode: String
218
+ ) {
219
+ shop (basketId: $basketId) {
220
+ id
221
+ removeCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
222
+ }
223
+ }`
224
+ });
225
+ return !!data?.shop?.removeCreditByType;
226
+ }
193
227
  // Annotate the CommonJS export names for ESM import in node:
194
228
  0 && (module.exports = {
195
229
  applyKivaCredit,
196
- removeKivaCredit
230
+ applyPromoCredit,
231
+ removeKivaCredit,
232
+ removePromoCredit
197
233
  });
@@ -14,5 +14,19 @@ interface RemoveKivaCreditData {
14
14
  } | null;
15
15
  }
16
16
  declare function removeKivaCredit(apollo: ApolloClient<any>): Promise<boolean>;
17
+ interface ApplyPromoCreditData {
18
+ shop: {
19
+ id: string;
20
+ addCreditByType: boolean;
21
+ } | null;
22
+ }
23
+ declare function applyPromoCredit(apollo: ApolloClient<any>): Promise<boolean>;
24
+ interface RemovePromoCreditData {
25
+ shop: {
26
+ id: string;
27
+ removeCreditByType: boolean;
28
+ } | null;
29
+ }
30
+ declare function removePromoCredit(apollo: ApolloClient<any>): Promise<boolean>;
17
31
 
18
- export { ApplyKivaCreditData, RemoveKivaCreditData, applyKivaCredit, removeKivaCredit };
32
+ export { ApplyKivaCreditData, ApplyPromoCreditData, RemoveKivaCreditData, RemovePromoCreditData, applyKivaCredit, applyPromoCredit, removeKivaCredit, removePromoCredit };
@@ -1,12 +1,16 @@
1
1
  import {
2
2
  applyKivaCredit,
3
- removeKivaCredit
4
- } from "./chunk-MRCBNXPS.js";
3
+ applyPromoCredit,
4
+ removeKivaCredit,
5
+ removePromoCredit
6
+ } from "./chunk-2KFUFQOY.js";
5
7
  import "./chunk-CBJJUUVR.js";
6
8
  import "./chunk-2NC7LGGO.js";
7
9
  import "./chunk-4ODZGLWK.js";
8
10
  import "./chunk-LZ4UMRCV.js";
9
11
  export {
10
12
  applyKivaCredit,
11
- removeKivaCredit
13
+ applyPromoCredit,
14
+ removeKivaCredit,
15
+ removePromoCredit
12
16
  };
@@ -0,0 +1,69 @@
1
+ import {
2
+ callShopMutation
3
+ } from "./chunk-CBJJUUVR.js";
4
+
5
+ // src/basketCredits.ts
6
+ import { gql } from "@apollo/client/core";
7
+ async function applyKivaCredit(apollo) {
8
+ const data = await callShopMutation(apollo, {
9
+ awaitRefetchQueries: true,
10
+ mutation: gql`mutation applyKivaCredit($basketId: String) {
11
+ shop (basketId: $basketId) {
12
+ id
13
+ addCreditByType(creditType: kiva_credit)
14
+ }
15
+ }`
16
+ });
17
+ return !!data?.shop?.addCreditByType;
18
+ }
19
+ async function removeKivaCredit(apollo) {
20
+ const data = await callShopMutation(apollo, {
21
+ awaitRefetchQueries: true,
22
+ mutation: gql`mutation removeKivaCredit($basketId: String) {
23
+ shop (basketId: $basketId) {
24
+ id
25
+ removeCreditByType(creditType: kiva_credit)
26
+ }
27
+ }`
28
+ });
29
+ return !!data?.shop?.removeCreditByType;
30
+ }
31
+ async function applyPromoCredit(apollo) {
32
+ const data = await callShopMutation(apollo, {
33
+ awaitRefetchQueries: true,
34
+ mutation: gql`mutation applyPromoCredit(
35
+ $basketId: String,
36
+ $creditType: CreditTypeEnum!,
37
+ $redemptionCode: String
38
+ ) {
39
+ shop (basketId: $basketId) {
40
+ id
41
+ addCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
42
+ }
43
+ }`
44
+ });
45
+ return !!data?.shop?.addCreditByType;
46
+ }
47
+ async function removePromoCredit(apollo) {
48
+ const data = await callShopMutation(apollo, {
49
+ awaitRefetchQueries: true,
50
+ mutation: gql`mutation removePromoCredit(
51
+ $basketId: String,
52
+ $creditType: CreditTypeEnum!,
53
+ $redemptionCode: String
54
+ ) {
55
+ shop (basketId: $basketId) {
56
+ id
57
+ removeCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
58
+ }
59
+ }`
60
+ });
61
+ return !!data?.shop?.removeCreditByType;
62
+ }
63
+
64
+ export {
65
+ applyKivaCredit,
66
+ removeKivaCredit,
67
+ applyPromoCredit,
68
+ removePromoCredit
69
+ };
@@ -3,7 +3,14 @@ import {
3
3
  } from "./chunk-2NBRXSIM.js";
4
4
  import {
5
5
  validatePreCheckout
6
- } from "./chunk-SYVMRWCO.js";
6
+ } from "./chunk-GFOL4PU6.js";
7
+ import {
8
+ pollForFinishedCheckout,
9
+ wait
10
+ } from "./chunk-P62MSJJ3.js";
11
+ import {
12
+ getVisitorID
13
+ } from "./chunk-TPJPGUO7.js";
7
14
  import {
8
15
  callShopMutation,
9
16
  callShopQuery
@@ -12,13 +19,6 @@ import {
12
19
  ShopError,
13
20
  parseShopError
14
21
  } from "./chunk-4ODZGLWK.js";
15
- import {
16
- pollForFinishedCheckout,
17
- wait
18
- } from "./chunk-P62MSJJ3.js";
19
- import {
20
- getVisitorID
21
- } from "./chunk-TPJPGUO7.js";
22
22
 
23
23
  // src/oneTimeCheckout.ts
24
24
  import { gql } from "@apollo/client/core";
package/dist/index.cjs CHANGED
@@ -32,6 +32,7 @@ __export(src_exports, {
32
32
  ShopError: () => ShopError,
33
33
  VerificationState: () => VerificationState,
34
34
  applyKivaCredit: () => applyKivaCredit,
35
+ applyPromoCredit: () => applyPromoCredit,
35
36
  basketTotalsQuery: () => basketTotalsQuery,
36
37
  callShopMutation: () => callShopMutation,
37
38
  callShopQuery: () => callShopQuery,
@@ -52,6 +53,7 @@ __export(src_exports, {
52
53
  parseShopError: () => parseShopError,
53
54
  pollForFinishedCheckout: () => pollForFinishedCheckout,
54
55
  removeKivaCredit: () => removeKivaCredit,
56
+ removePromoCredit: () => removePromoCredit,
55
57
  setBasketID: () => setBasketID,
56
58
  setTipDonation: () => setTipDonation,
57
59
  useBraintreeDropIn: () => useBraintreeDropIn,
@@ -306,6 +308,38 @@ async function removeKivaCredit(apollo) {
306
308
  });
307
309
  return !!data?.shop?.removeCreditByType;
308
310
  }
311
+ async function applyPromoCredit(apollo) {
312
+ const data = await callShopMutation(apollo, {
313
+ awaitRefetchQueries: true,
314
+ mutation: import_core2.gql`mutation applyPromoCredit(
315
+ $basketId: String,
316
+ $creditType: CreditTypeEnum!,
317
+ $redemptionCode: String
318
+ ) {
319
+ shop (basketId: $basketId) {
320
+ id
321
+ addCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
322
+ }
323
+ }`
324
+ });
325
+ return !!data?.shop?.addCreditByType;
326
+ }
327
+ async function removePromoCredit(apollo) {
328
+ const data = await callShopMutation(apollo, {
329
+ awaitRefetchQueries: true,
330
+ mutation: import_core2.gql`mutation removePromoCredit(
331
+ $basketId: String,
332
+ $creditType: CreditTypeEnum!,
333
+ $redemptionCode: String
334
+ ) {
335
+ shop (basketId: $basketId) {
336
+ id
337
+ removeCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
338
+ }
339
+ }`
340
+ });
341
+ return !!data?.shop?.removeCreditByType;
342
+ }
309
343
 
310
344
  // src/basketItems.ts
311
345
  var import_core3 = require("@apollo/client/core");
@@ -1072,6 +1106,7 @@ function useBraintreeDropIn(key = "default") {
1072
1106
  ShopError,
1073
1107
  VerificationState,
1074
1108
  applyKivaCredit,
1109
+ applyPromoCredit,
1075
1110
  basketTotalsQuery,
1076
1111
  callShopMutation,
1077
1112
  callShopQuery,
@@ -1092,6 +1127,7 @@ function useBraintreeDropIn(key = "default") {
1092
1127
  parseShopError,
1093
1128
  pollForFinishedCheckout,
1094
1129
  removeKivaCredit,
1130
+ removePromoCredit,
1095
1131
  setBasketID,
1096
1132
  setTipDonation,
1097
1133
  useBraintreeDropIn,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { createBasket, getBasketID, hasBasketExpired, setBasketID } from './basket.js';
2
- export { ApplyKivaCreditData, RemoveKivaCreditData, applyKivaCredit, removeKivaCredit } from './basketCredits.js';
2
+ export { ApplyKivaCreditData, ApplyPromoCreditData, RemoveKivaCreditData, RemovePromoCreditData, applyKivaCredit, applyPromoCredit, removeKivaCredit, removePromoCredit } from './basketCredits.js';
3
3
  export { SetTipDonationData, SetTipDonationOptions, setTipDonation } from './basketItems.js';
4
4
  export { BasketTotalsData, basketTotalsQuery, watchBasketTotals } from './basketTotals.js';
5
5
  export { VerificationState, isBasketVerified } from './basketVerification.js';
package/dist/index.js CHANGED
@@ -1,3 +1,12 @@
1
+ import {
2
+ executeOneTimeCheckout
3
+ } from "./chunk-NDLLZLN6.js";
4
+ import {
5
+ getCheckoutTrackingData,
6
+ getFTDStatus,
7
+ getReceiptItems,
8
+ getReceiptTotals
9
+ } from "./chunk-2NBRXSIM.js";
1
10
  import {
2
11
  checkSubscriptionStatus,
3
12
  executeNewSubscriptionCheckout
@@ -7,10 +16,16 @@ import {
7
16
  getClientToken,
8
17
  useBraintreeDropIn
9
18
  } from "./chunk-JXQPCEKG.js";
19
+ import {
20
+ validatePreCheckout,
21
+ validatePreCheckoutMutation
22
+ } from "./chunk-GFOL4PU6.js";
10
23
  import {
11
24
  applyKivaCredit,
12
- removeKivaCredit
13
- } from "./chunk-MRCBNXPS.js";
25
+ applyPromoCredit,
26
+ removeKivaCredit,
27
+ removePromoCredit
28
+ } from "./chunk-2KFUFQOY.js";
14
29
  import {
15
30
  setTipDonation
16
31
  } from "./chunk-AI6E33YE.js";
@@ -23,18 +38,10 @@ import {
23
38
  isBasketVerified
24
39
  } from "./chunk-FCAOCO7O.js";
25
40
  import {
26
- executeOneTimeCheckout
27
- } from "./chunk-25GYVNF4.js";
28
- import {
29
- getCheckoutTrackingData,
30
- getFTDStatus,
31
- getReceiptItems,
32
- getReceiptTotals
33
- } from "./chunk-2NBRXSIM.js";
34
- import {
35
- validatePreCheckout,
36
- validatePreCheckoutMutation
37
- } from "./chunk-SYVMRWCO.js";
41
+ getCheckoutStatus,
42
+ pollForFinishedCheckout
43
+ } from "./chunk-P62MSJJ3.js";
44
+ import "./chunk-TPJPGUO7.js";
38
45
  import {
39
46
  callShopMutation,
40
47
  callShopQuery,
@@ -50,16 +57,12 @@ import {
50
57
  ShopError,
51
58
  parseShopError
52
59
  } from "./chunk-4ODZGLWK.js";
53
- import {
54
- getCheckoutStatus,
55
- pollForFinishedCheckout
56
- } from "./chunk-P62MSJJ3.js";
57
- import "./chunk-TPJPGUO7.js";
58
60
  import "./chunk-LZ4UMRCV.js";
59
61
  export {
60
62
  ShopError,
61
63
  VerificationState,
62
64
  applyKivaCredit,
65
+ applyPromoCredit,
63
66
  basketTotalsQuery,
64
67
  callShopMutation,
65
68
  callShopQuery,
@@ -80,6 +83,7 @@ export {
80
83
  parseShopError,
81
84
  pollForFinishedCheckout,
82
85
  removeKivaCredit,
86
+ removePromoCredit,
83
87
  setBasketID,
84
88
  setTipDonation,
85
89
  useBraintreeDropIn,
@@ -0,0 +1,227 @@
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/managedAccount.ts
20
+ var managedAccount_exports = {};
21
+ __export(managedAccount_exports, {
22
+ getPromoFromBasket: () => getPromoFromBasket
23
+ });
24
+ module.exports = __toCommonJS(managedAccount_exports);
25
+ var import_core2 = require("@apollo/client/core");
26
+
27
+ // src/basket.ts
28
+ var import_core = require("@apollo/client/core");
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
+ var setCookieValue = (name, value, options = "") => {
37
+ if (typeof document !== void 0) {
38
+ document.cookie = `${name}=${encodeURIComponent(value)};${options}`;
39
+ }
40
+ };
41
+
42
+ // src/shopError.ts
43
+ var ShopError = class extends Error {
44
+ constructor({ code, original }, ...params) {
45
+ super(...params);
46
+ if (Error.captureStackTrace) {
47
+ Error.captureStackTrace(this, ShopError);
48
+ }
49
+ this.name = "ShopError";
50
+ this.code = code;
51
+ this.original = original;
52
+ }
53
+ aggregateErrors(errors) {
54
+ this.errors = errors;
55
+ }
56
+ };
57
+ function parseShopError(error) {
58
+ if (error instanceof ShopError) {
59
+ return error;
60
+ }
61
+ const errorCode = error?.code ?? error?.extensions?.code ?? error?.name ?? "";
62
+ const errorMessage = typeof error === "string" ? error : error?.message ?? "";
63
+ if (errorCode === "invalidMethodParameter" && errorMessage.includes("paymentMethod.create")) {
64
+ return new ShopError({
65
+ code: "paymentMethod.create.invalidMethodParameter",
66
+ original: error
67
+ }, "There was a problem validating your payment information. Please double-check the details and try again.");
68
+ }
69
+ if (errorMessage.includes("Invalid request: ")) {
70
+ const finalError = errorMessage.split("Invalid request: ")[1].split("., ").map((e) => e.matchAll(/[A-Z_]+: (.*)/g))[0];
71
+ const finalCode = finalError[1];
72
+ const finalMessage = finalError[2];
73
+ return new ShopError({
74
+ code: `paymentMethod.${finalCode}`,
75
+ original: error
76
+ }, finalMessage);
77
+ }
78
+ if (errorCode === "insufficientFunds" || errorMessage.includes("There is not enough credit")) {
79
+ return new ShopError({
80
+ code: "shop.insufficientFunds",
81
+ original: error
82
+ }, "There is not enough money to complete the checkout. Please double-check the details and try again.");
83
+ }
84
+ if (errorCode === "shop.invalidBasketId" || errorCode === "shop.basketRequired" || errorCode === "shop.alreadyCheckedOut") {
85
+ return new ShopError({
86
+ code: errorCode,
87
+ original: error
88
+ }, "There was a problem with your basket. Please, refresh the page and try again.");
89
+ }
90
+ if (errorCode === "donationAmountTooLarge") {
91
+ return new ShopError({
92
+ code: errorCode,
93
+ original: error
94
+ }, errorMessage);
95
+ }
96
+ return new ShopError({
97
+ code: "shop.unknown",
98
+ original: error
99
+ }, "An unknown error occurred.");
100
+ }
101
+
102
+ // src/basket.ts
103
+ function getBasketID() {
104
+ return getCookieValue("kvbskt");
105
+ }
106
+ function setBasketID(basketId) {
107
+ setCookieValue("kvbskt", basketId, "path=/;secure;");
108
+ }
109
+ async function createBasketHelper(apollo) {
110
+ try {
111
+ return apollo.mutate({
112
+ mutation: import_core.gql`mutation createNewBasketForUser { shop { id createBasket } }`
113
+ }).then(({ data }) => {
114
+ const newBasketId = data.shop?.createBasket ?? null;
115
+ if (newBasketId) {
116
+ setBasketID(newBasketId);
117
+ }
118
+ });
119
+ } catch (error) {
120
+ throw parseShopError(error);
121
+ }
122
+ }
123
+ var activeBasketCreationQuery = null;
124
+ async function createBasket(apollo) {
125
+ if (activeBasketCreationQuery) {
126
+ return activeBasketCreationQuery;
127
+ }
128
+ activeBasketCreationQuery = createBasketHelper(apollo);
129
+ return activeBasketCreationQuery;
130
+ }
131
+ function hasBasketExpired(error) {
132
+ const errorCode = error?.code ?? error?.extensions?.code ?? error?.name ?? "";
133
+ return ["shop.invalidBasketId", "shop.basketRequired", "shop.alreadyCheckedOut"].includes(errorCode);
134
+ }
135
+
136
+ // src/shopQueries.ts
137
+ async function callShopQuery(apollo, options, maxretries = 2) {
138
+ try {
139
+ const result = await apollo.query({
140
+ ...options,
141
+ variables: {
142
+ ...options.variables,
143
+ basketId: getBasketID()
144
+ }
145
+ });
146
+ if (result?.errors?.length) {
147
+ const basketErrors = result?.errors.filter((err) => hasBasketExpired(err));
148
+ if (basketErrors.length) {
149
+ if (maxretries > 0) {
150
+ await createBasket(apollo);
151
+ return callShopQuery(apollo, options, maxretries - 1);
152
+ }
153
+ throw basketErrors[0];
154
+ }
155
+ if (result?.errors?.length) {
156
+ throw result.errors[0];
157
+ }
158
+ }
159
+ return result?.data;
160
+ } catch (e) {
161
+ throw parseShopError(e);
162
+ }
163
+ }
164
+
165
+ // src/managedAccount.ts
166
+ async function getPromoFromBasket(apollo) {
167
+ const data = await callShopQuery(apollo, {
168
+ query: import_core2.gql`
169
+ query promoCampaign($basketId: String, $promoFundId: String) {
170
+ shop (basketId: $basketId) {
171
+ id
172
+ promoCampaign (promoFundId: $promoFundId) {
173
+ promoFund {
174
+ id
175
+ displayName
176
+ displayDescription
177
+ promoPrice
178
+ }
179
+ promoGroup {
180
+ id
181
+ type
182
+ teamId
183
+ }
184
+ managedAccount {
185
+ managementType
186
+ audience
187
+ allowDonations
188
+ sendKivaNewsletter
189
+ id
190
+ isEmployee
191
+ formId
192
+ pageId
193
+ loanSearchCriteria {
194
+ filters {
195
+ cityState
196
+ country
197
+ currencyLossPossible
198
+ dafEligible
199
+ distributionModel
200
+ status
201
+ excludeNonRated
202
+ expiringSoon
203
+ gender
204
+ hasResearchScore
205
+ isGroup
206
+ lenderFavorite
207
+ loanLimit
208
+ isMatched
209
+ sector
210
+ loanTags
211
+ theme
212
+ }
213
+ sortBy
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+ `,
220
+ fetchPolicy: "network-only"
221
+ }, 0);
222
+ return data;
223
+ }
224
+ // Annotate the CommonJS export names for ESM import in node:
225
+ 0 && (module.exports = {
226
+ getPromoFromBasket
227
+ });
@@ -0,0 +1,55 @@
1
+ import { ApolloClient } from '@apollo/client/core';
2
+
3
+ interface ShopPromoCampaignData {
4
+ shop: {
5
+ id: string;
6
+ promoCampaign: {
7
+ promoFund: {
8
+ id: number;
9
+ displayName: string;
10
+ displayDescription: string;
11
+ promoPrice: string;
12
+ };
13
+ promoGroup: {
14
+ id: number;
15
+ type: string;
16
+ teamId: number;
17
+ };
18
+ managedAccount: {
19
+ managementType: string;
20
+ audience: string;
21
+ allowDonations: string;
22
+ sendKivaNewsletter: string;
23
+ id: number;
24
+ isEmployee: boolean;
25
+ formId: string;
26
+ pageId: string;
27
+ loanSearchCriteria: {
28
+ filters: {
29
+ cityState: [string];
30
+ country: [string];
31
+ currencyLossPossible: boolean;
32
+ dafEligible: boolean;
33
+ distributionModel: any | string;
34
+ excludeNonRated: boolean;
35
+ expiringSoon: boolean;
36
+ gender: any | string;
37
+ hasResearchScore: boolean;
38
+ isGroup: boolean;
39
+ lenderFavorite: number;
40
+ loanLimit: number;
41
+ loanTags: [number];
42
+ isMatched: boolean;
43
+ sector: [number];
44
+ status: any | string;
45
+ theme: [string];
46
+ };
47
+ sortBy: any | string | null;
48
+ } | any | null;
49
+ } | any | null;
50
+ } | any | null;
51
+ } | null;
52
+ }
53
+ declare function getPromoFromBasket(apollo: ApolloClient<any>): Promise<ShopPromoCampaignData | null>;
54
+
55
+ export { getPromoFromBasket };
@@ -0,0 +1,70 @@
1
+ import {
2
+ callShopQuery
3
+ } from "./chunk-CBJJUUVR.js";
4
+ import "./chunk-2NC7LGGO.js";
5
+ import "./chunk-4ODZGLWK.js";
6
+ import "./chunk-LZ4UMRCV.js";
7
+
8
+ // src/managedAccount.ts
9
+ import { gql } from "@apollo/client/core";
10
+ async function getPromoFromBasket(apollo) {
11
+ const data = await callShopQuery(apollo, {
12
+ query: gql`
13
+ query promoCampaign($basketId: String, $promoFundId: String) {
14
+ shop (basketId: $basketId) {
15
+ id
16
+ promoCampaign (promoFundId: $promoFundId) {
17
+ promoFund {
18
+ id
19
+ displayName
20
+ displayDescription
21
+ promoPrice
22
+ }
23
+ promoGroup {
24
+ id
25
+ type
26
+ teamId
27
+ }
28
+ managedAccount {
29
+ managementType
30
+ audience
31
+ allowDonations
32
+ sendKivaNewsletter
33
+ id
34
+ isEmployee
35
+ formId
36
+ pageId
37
+ loanSearchCriteria {
38
+ filters {
39
+ cityState
40
+ country
41
+ currencyLossPossible
42
+ dafEligible
43
+ distributionModel
44
+ status
45
+ excludeNonRated
46
+ expiringSoon
47
+ gender
48
+ hasResearchScore
49
+ isGroup
50
+ lenderFavorite
51
+ loanLimit
52
+ isMatched
53
+ sector
54
+ loanTags
55
+ theme
56
+ }
57
+ sortBy
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ `,
64
+ fetchPolicy: "network-only"
65
+ }, 0);
66
+ return data;
67
+ }
68
+ export {
69
+ getPromoFromBasket
70
+ };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  executeOneTimeCheckout
3
- } from "./chunk-25GYVNF4.js";
3
+ } from "./chunk-NDLLZLN6.js";
4
4
  import "./chunk-2NBRXSIM.js";
5
- import "./chunk-SYVMRWCO.js";
5
+ import "./chunk-GFOL4PU6.js";
6
+ import "./chunk-P62MSJJ3.js";
7
+ import "./chunk-TPJPGUO7.js";
6
8
  import "./chunk-CBJJUUVR.js";
7
9
  import "./chunk-2NC7LGGO.js";
8
10
  import "./chunk-4ODZGLWK.js";
9
- import "./chunk-P62MSJJ3.js";
10
- import "./chunk-TPJPGUO7.js";
11
11
  import "./chunk-LZ4UMRCV.js";
12
12
  export {
13
13
  executeOneTimeCheckout
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  validatePreCheckout,
3
3
  validatePreCheckoutMutation
4
- } from "./chunk-SYVMRWCO.js";
4
+ } from "./chunk-GFOL4PU6.js";
5
+ import "./chunk-TPJPGUO7.js";
5
6
  import "./chunk-CBJJUUVR.js";
6
7
  import "./chunk-2NC7LGGO.js";
7
8
  import "./chunk-4ODZGLWK.js";
8
- import "./chunk-TPJPGUO7.js";
9
9
  import "./chunk-LZ4UMRCV.js";
10
10
  export {
11
11
  validatePreCheckout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-shop",
3
- "version": "1.10.32",
3
+ "version": "1.11.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@apollo/client": "^3.7.14",
41
41
  "@kiva/kv-analytics": "^1.3.0",
42
- "@kiva/kv-components": "^3.78.1",
42
+ "@kiva/kv-components": "^3.78.2",
43
43
  "@types/braintree-web-drop-in": "^1.34.2",
44
44
  "braintree-web-drop-in": "^1.37.0",
45
45
  "numeral": "^2.0.6",
@@ -54,5 +54,5 @@
54
54
  "optional": true
55
55
  }
56
56
  },
57
- "gitHead": "b5b74f8e63914076537541d4460777494c56ae58"
57
+ "gitHead": "c6f35180e5a27c234e8c7f4ea19d7b267b842677"
58
58
  }
@@ -1,35 +0,0 @@
1
- import {
2
- callShopMutation
3
- } from "./chunk-CBJJUUVR.js";
4
-
5
- // src/basketCredits.ts
6
- import { gql } from "@apollo/client/core";
7
- async function applyKivaCredit(apollo) {
8
- const data = await callShopMutation(apollo, {
9
- awaitRefetchQueries: true,
10
- mutation: gql`mutation applyKivaCredit($basketId: String) {
11
- shop (basketId: $basketId) {
12
- id
13
- addCreditByType(creditType: kiva_credit)
14
- }
15
- }`
16
- });
17
- return !!data?.shop?.addCreditByType;
18
- }
19
- async function removeKivaCredit(apollo) {
20
- const data = await callShopMutation(apollo, {
21
- awaitRefetchQueries: true,
22
- mutation: gql`mutation removeKivaCredit($basketId: String) {
23
- shop (basketId: $basketId) {
24
- id
25
- removeCreditByType(creditType: kiva_credit)
26
- }
27
- }`
28
- });
29
- return !!data?.shop?.removeCreditByType;
30
- }
31
-
32
- export {
33
- applyKivaCredit,
34
- removeKivaCredit
35
- };
@@ -1,3 +1,6 @@
1
+ import {
2
+ getVisitorID
3
+ } from "./chunk-TPJPGUO7.js";
1
4
  import {
2
5
  callShopMutation
3
6
  } from "./chunk-CBJJUUVR.js";
@@ -5,9 +8,6 @@ import {
5
8
  ShopError,
6
9
  parseShopError
7
10
  } from "./chunk-4ODZGLWK.js";
8
- import {
9
- getVisitorID
10
- } from "./chunk-TPJPGUO7.js";
11
11
 
12
12
  // src/validatePreCheckout.ts
13
13
  import { gql } from "@apollo/client/core";