@beamimpact/web-sdk 1.37.0 → 1.37.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.
- package/README.md +21 -1
- package/dist/chunks/{_share-dialog-dependencies-Ex1exJdU.esm.js → _share-dialog-dependencies-FheD3_vQ.esm.js} +2 -2
- package/dist/chunks/_share-dialog-dependencies-FheD3_vQ.esm.js.map +1 -0
- package/dist/chunks/{_share-dialog-dependencies-GOqKRBIc.esm.js → _share-dialog-dependencies-l35ECwOP.esm.js} +2 -2
- package/dist/chunks/_share-dialog-dependencies-l35ECwOP.esm.js.map +1 -0
- package/dist/chunks/{cart-contents-Cdq4ob0J.esm.d.ts → cart-contents-IOhdr24g.esm.d.ts} +1 -1
- package/dist/chunks/events-Y8fYvSqM.esm.js +2 -0
- package/dist/chunks/{events-5IECSF-x.esm.js.map → events-Y8fYvSqM.esm.js.map} +1 -1
- package/dist/chunks/{events-3-Mzl-dS.esm.d.ts → events-j-SJ9Cot.esm.d.ts} +17 -3
- package/dist/chunks/{index-SZxnIRAX.esm.d.ts → index-3F_Wjm5v.esm.d.ts} +1 -1
- package/dist/chunks/{index-9gijHGwh.esm.js → index-8yrr7ZZv.esm.js} +2 -2
- package/dist/chunks/index-8yrr7ZZv.esm.js.map +1 -0
- package/dist/chunks/index-B2oj1JKu.esm.js +2 -0
- package/dist/chunks/index-B2oj1JKu.esm.js.map +1 -0
- package/dist/chunks/index-E_HMWZ2A.esm.js +2 -0
- package/dist/chunks/index-E_HMWZ2A.esm.js.map +1 -0
- package/dist/chunks/{index-jYAdXbGg.esm.js → index-Gz7Q9nUW.esm.js} +2 -2
- package/dist/chunks/{index-jYAdXbGg.esm.js.map → index-Gz7Q9nUW.esm.js.map} +1 -1
- package/dist/chunks/index-JsXH5Lnc.esm.js +2 -0
- package/dist/chunks/index-JsXH5Lnc.esm.js.map +1 -0
- package/dist/chunks/{index-OnjTwvAw.esm.js → index-Lw32NXij.esm.js} +2 -2
- package/dist/chunks/index-Lw32NXij.esm.js.map +1 -0
- package/dist/chunks/index-RDKeoKqc.esm.js +2 -0
- package/dist/chunks/index-RDKeoKqc.esm.js.map +1 -0
- package/dist/chunks/index-VGoZaoVm.esm.js +2 -0
- package/dist/chunks/index-VGoZaoVm.esm.js.map +1 -0
- package/dist/chunks/{index-9Cs92uGK.esm.d.ts → index-WX8Yyx2u.esm.d.ts} +1 -1
- package/dist/chunks/{index-7-XLaXA4.esm.d.ts → index-mWnpDGl1.esm.d.ts} +1 -1
- package/dist/chunks/{index-U8Oy2aur.esm.js → index-phDmC-TS.esm.js} +2 -2
- package/dist/chunks/index-phDmC-TS.esm.js.map +1 -0
- package/dist/chunks/{index-xRjeUrl2.esm.d.ts → index-s8uQH63W.esm.d.ts} +4 -4
- package/dist/chunks/{index-b3DeBLwb.esm.d.ts → index-slrOT8Gd.esm.d.ts} +1 -1
- package/dist/chunks/{index-wsdeaTHd.esm.js → index-uF-Qtewb.esm.js} +2 -2
- package/dist/chunks/index-uF-Qtewb.esm.js.map +1 -0
- package/dist/chunks/{index-KErjmUlF.esm.js → index-vpkWmZo_.esm.js} +2 -2
- package/dist/chunks/{index-KErjmUlF.esm.js.map → index-vpkWmZo_.esm.js.map} +1 -1
- package/dist/chunks/index-xYLcuL6Z.esm.js +2 -0
- package/dist/chunks/index-xYLcuL6Z.esm.js.map +1 -0
- package/dist/chunks/{index-AhT9jBIr.esm.d.ts → index-yXqJ9Znv.esm.d.ts} +1 -1
- package/dist/chunks/{openapi-spec-WpREPNjl.esm.d.ts → openapi-spec-b529HHW3.esm.d.ts} +7 -7
- package/dist/chunks/order-page-9B0nZVh1.esm.js +2 -0
- package/dist/chunks/order-page-9B0nZVh1.esm.js.map +1 -0
- package/dist/chunks/{order-page-eOCpZ8vN.esm.d.ts → order-page-jkuLE25f.esm.d.ts} +3 -4
- package/dist/chunks/order-page-yM2h67MI.esm.js +2 -0
- package/dist/chunks/order-page-yM2h67MI.esm.js.map +1 -0
- package/dist/chunks/routes-LFjgVNGB.esm.js +2 -0
- package/dist/chunks/routes-LFjgVNGB.esm.js.map +1 -0
- package/dist/chunks/routes-ad0I3Ayc.esm.js +2 -0
- package/dist/chunks/routes-ad0I3Ayc.esm.js.map +1 -0
- package/dist/chunks/{update-cart-8nDxTnnQ.esm.js → update-cart-A2hs4tF8.esm.js} +2 -2
- package/dist/chunks/{update-cart-8nDxTnnQ.esm.js.map → update-cart-A2hs4tF8.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-D4jDrYC0.esm.d.ts → update-cart-EKZbvT8c.esm.d.ts} +1 -1
- package/dist/chunks/{update-cart-_cCsAqH9.esm.js → update-cart-vcujKNky.esm.js} +2 -2
- package/dist/chunks/{update-cart-_cCsAqH9.esm.js.map → update-cart-vcujKNky.esm.js.map} +1 -1
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.esm.js +1 -1
- package/dist/components/cumulative-impact.js +1 -1
- package/dist/components/impact-overview.esm.js +1 -1
- package/dist/components/impact-overview.js +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +3 -3
- package/dist/components/post-purchase.esm.js +1 -1
- package/dist/components/post-purchase.js +1 -1
- package/dist/components/redeem-transaction.d.ts +3 -3
- package/dist/components/redeem-transaction.esm.js +1 -1
- package/dist/components/redeem-transaction.js +1 -1
- package/dist/components/select-nonprofit.d.ts +3 -3
- package/dist/components/select-nonprofit.esm.js +19 -19
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +19 -19
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/shopify.d.ts +5 -5
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/subscription-management.d.ts +3 -3
- package/dist/components/subscription-management.esm.js +1 -1
- package/dist/components/subscription-management.js +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.d.ts +3 -3
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/index.d.ts +9 -9
- package/dist/integrations/index.esm.js +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/logs.d.ts +2 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/shopify.d.ts +4 -4
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.esm.js +1 -1
- package/dist/integrations/statsig.js +1 -1
- package/dist/integrations/utils.d.ts +3 -3
- package/dist/integrations/utils.esm.js +1 -1
- package/dist/integrations/utils.js +1 -1
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +2 -2
- package/dist/react/post-purchase.esm.js +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/redeem-transaction.d.ts +3 -3
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/select-nonprofit.d.ts +3 -3
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/subscription-management.d.ts +2 -2
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/utils/events.d.ts +3 -3
- package/dist/utils/events.esm.js +1 -1
- package/dist/utils/events.js +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/network-listeners.esm.js +1 -1
- package/dist/utils/network-listeners.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/_share-dialog-dependencies-Ex1exJdU.esm.js.map +0 -1
- package/dist/chunks/_share-dialog-dependencies-GOqKRBIc.esm.js.map +0 -1
- package/dist/chunks/events-5IECSF-x.esm.js +0 -2
- package/dist/chunks/index-5AkzIYu3.esm.js +0 -2
- package/dist/chunks/index-5AkzIYu3.esm.js.map +0 -1
- package/dist/chunks/index-8VxiCO_y.esm.js +0 -2
- package/dist/chunks/index-8VxiCO_y.esm.js.map +0 -1
- package/dist/chunks/index-9gijHGwh.esm.js.map +0 -1
- package/dist/chunks/index-OnjTwvAw.esm.js.map +0 -1
- package/dist/chunks/index-U8Oy2aur.esm.js.map +0 -1
- package/dist/chunks/index-a9SRo_pt.esm.js +0 -2
- package/dist/chunks/index-a9SRo_pt.esm.js.map +0 -1
- package/dist/chunks/index-fdm0Zxu6.esm.js +0 -2
- package/dist/chunks/index-fdm0Zxu6.esm.js.map +0 -1
- package/dist/chunks/index-gfShfkGQ.esm.js +0 -2
- package/dist/chunks/index-gfShfkGQ.esm.js.map +0 -1
- package/dist/chunks/index-wsdeaTHd.esm.js.map +0 -1
- package/dist/chunks/index-yEHTVDWu.esm.js +0 -2
- package/dist/chunks/index-yEHTVDWu.esm.js.map +0 -1
- package/dist/chunks/order-page-ZyVxKalS.esm.js +0 -2
- package/dist/chunks/order-page-ZyVxKalS.esm.js.map +0 -1
- package/dist/chunks/order-page-nKOujF0G.esm.js +0 -2
- package/dist/chunks/order-page-nKOujF0G.esm.js.map +0 -1
- package/dist/chunks/routes-S3ZS-od_.esm.js +0 -2
- package/dist/chunks/routes-S3ZS-od_.esm.js.map +0 -1
- package/dist/chunks/routes-jQjZhNH9.esm.js +0 -2
- package/dist/chunks/routes-jQjZhNH9.esm.js.map +0 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ Beam takes care of all the nonprofit management and compliance, impact tracking,
|
|
|
42
42
|
|
|
43
43
|
<br />
|
|
44
44
|
|
|
45
|
-
<img src="https://production-beam-widgets.beamimpact.com/assets/img/screenshots/beam-select-nonprofit.png"
|
|
45
|
+
<img src="https://production-beam-widgets.beamimpact.com/assets/img/screenshots/beam-select-nonprofit.png"
|
|
46
46
|
alt="Screenshot of Beam widget" />
|
|
47
47
|
|
|
48
48
|
The Beam Web SDK provides a set of web components and framework-specific wrappers for
|
|
@@ -218,6 +218,26 @@ document.addEventListener("beamnonprofitselect", (evt) => {
|
|
|
218
218
|
});
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
+
#### **Event Types**
|
|
222
|
+
|
|
223
|
+
**Select Nonprofit Widget & Post Purchase Widget**
|
|
224
|
+
|
|
225
|
+
- **Event:** `beamnonprofitselect`
|
|
226
|
+
- **Description:** Emitted when the end user selects a nonprofit in the Beam widget, and when the previous selection was restored automatically
|
|
227
|
+
|
|
228
|
+
**Select Nonprofit Widget**
|
|
229
|
+
|
|
230
|
+
- **Event:** `beamcartchange`
|
|
231
|
+
- **Description:** Emitted when Beam detects that cart contents have changed, and when items are added to the cart for the first time
|
|
232
|
+
|
|
233
|
+
- **Event:** `beamnonprofitselectionremoved`
|
|
234
|
+
- **Description:** Emitted when the nonprofit selection is removed from deselection or due to nonprofit cohort change
|
|
235
|
+
|
|
236
|
+
**Post Purchase Widget**
|
|
237
|
+
|
|
238
|
+
- **Event:** `beamordercreated`
|
|
239
|
+
- **Description:** Emitted when an order is registered with Beam for the first time, but NOT on repeat visits, page refreshes, etc.
|
|
240
|
+
|
|
221
241
|
### beam-post-purchase
|
|
222
242
|
|
|
223
243
|
A wrapper component that registers transactions and renders either the `beam-impact-overview` or
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./vendor-eeJfrOkP.esm.js";import"../components/impact-overview.esm.js";import"./lit-yVXn5Cbs.esm.js";import"./lodash-P8OIs-at.esm.js";import"./routes-
|
|
2
|
-
//# sourceMappingURL=_share-dialog-dependencies-
|
|
1
|
+
import"./vendor-eeJfrOkP.esm.js";import"../components/impact-overview.esm.js";import"./lit-yVXn5Cbs.esm.js";import"./lodash-P8OIs-at.esm.js";import"./routes-LFjgVNGB.esm.js";import"./beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";import"./progress-bar-7gWYaGlq.esm.js";import"./enforce-config-qna7hEL6.esm.js";import"./localize-GCkVUD8S.esm.js";import"./is-all-html-elements-SdSkxirh.esm.js";import"../components/beam-partner-logos.esm.js";import"./responsive-LYEag6TI.esm.js";
|
|
2
|
+
//# sourceMappingURL=_share-dialog-dependencies-FheD3_vQ.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_share-dialog-dependencies-FheD3_vQ.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./vendor-eeJfrOkP.esm.js";import"../components/impact-overview.js";import"./lit-yVXn5Cbs.esm.js";import"./lodash-P8OIs-at.esm.js";import"./routes-
|
|
2
|
-
//# sourceMappingURL=_share-dialog-dependencies-
|
|
1
|
+
import"./vendor-eeJfrOkP.esm.js";import"../components/impact-overview.js";import"./lit-yVXn5Cbs.esm.js";import"./lodash-P8OIs-at.esm.js";import"./routes-ad0I3Ayc.esm.js";import"./beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.js";import"./progress-bar-7gWYaGlq.esm.js";import"./enforce-config-fo8kIfoY.esm.js";import"./localize-pzAAkBvG.esm.js";import"./is-all-html-elements-SdSkxirh.esm.js";import"../components/beam-partner-logos.js";import"./responsive-LYEag6TI.esm.js";
|
|
2
|
+
//# sourceMappingURL=_share-dialog-dependencies-l35ECwOP.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_share-dialog-dependencies-l35ECwOP.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as paths } from './openapi-spec-
|
|
1
|
+
import { p as paths } from './openapi-spec-b529HHW3.esm.js';
|
|
2
2
|
|
|
3
3
|
type TCartApi = paths["/chain/findEligibleNonprofitsForCart"]["post"]["requestBody"]["content"]["application/json"]["cart"];
|
|
4
4
|
type TCart = TCartApi & {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const t=class C extends CustomEvent{constructor(e){super(C.eventName,{detail:e,bubbles:!0,composed:!0})}};t.eventName="beamnetworkcall";let a=t;const s=class E extends CustomEvent{constructor(e){super(E.eventName,{detail:e,bubbles:!0,composed:!0})}};s.eventName="beamnonprofitselect";let n=s;const o=class N extends CustomEvent{constructor(e){super(N.eventName,{detail:e,bubbles:!0,composed:!0})}};o.eventName="beamcartchange";let r=o;const m=class i extends CustomEvent{constructor(e){super(i.eventName,{detail:e,bubbles:!0,composed:!0})}};m.eventName="beamcartcreated";let c=m;const l=class B extends CustomEvent{constructor(e){super(B.eventName,{detail:e,bubbles:!0,composed:!0})}};l.eventName="beamordercreated";let v=l;const d=class f extends CustomEvent{constructor(e){super(f.eventName,{detail:e,bubbles:!0,composed:!0})}};d.eventName="beamstatuschange";let u=d;const b=class x extends CustomEvent{constructor(e){super(x.eventName,{detail:e,bubbles:!0,composed:!0})}};b.eventName="beamnonprofitselectionremoved";let p=b;var g=Object.freeze({__proto__:null,BeamCartChangeEvent:r,BeamCartCreatedEvent:c,BeamNetworkCallEvent:a,BeamNonprofitSelectEvent:n,BeamNonprofitSelectionRemovedEvent:p,BeamOrderCreatedEvent:v,BeamStatusChangeEvent:u});export{u as B,c as a,v as b,n as c,a as d,g as e,r as f,p as g};
|
|
2
|
+
//# sourceMappingURL=events-Y8fYvSqM.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events-
|
|
1
|
+
{"version":3,"file":"events-Y8fYvSqM.esm.js","sources":["../../src/utils/events.ts"],"sourcesContent":["import { TCartApi } from \"../shared/cart-contents\";\nimport { TId } from \"../shared/types\";\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype NetworkEventDetail =\n | { url: string; method: string; type: \"fetch\"; response: Response }\n | { url: string; method: string; type: \"xhr\"; xhr: XMLHttpRequest };\n\n/**\n * beamnetworkcall\n * Emitted by the Beam network listener whenever any API calls are made on the page\n */\nexport class BeamNetworkCallEvent extends CustomEvent<NetworkEventDetail> {\n static eventName = \"beamnetworkcall\" as const;\n constructor(detail: NetworkEventDetail) {\n super(BeamNetworkCallEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype NonprofitSelectDetail = {\n selectionId?: string;\n selectedNonprofitId?: number | null;\n nonprofitName?: string | null;\n};\n\n/**\n * beamnonprofitselect\n * Emitted when the end user selects a nonprofit in the Beam widget, and when the previous selection was restored\n * automatically\n */\nexport class BeamNonprofitSelectEvent extends CustomEvent<NonprofitSelectDetail> {\n static eventName = \"beamnonprofitselect\" as const;\n constructor(detail: NonprofitSelectDetail) {\n super(BeamNonprofitSelectEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype CartChangeDetail = TCartApi & {\n cartId?: string;\n subtotal?: number;\n itemCount?: number;\n currencyCode?: string;\n};\n\n/**\n * beamcartchange\n * Emitted when Beam detects that cart contents have changed, and when items are added to the cart for the first time\n */\nexport class BeamCartChangeEvent extends CustomEvent<CartChangeDetail> {\n static eventName = \"beamcartchange\" as const;\n constructor(detail: CartChangeDetail) {\n super(BeamCartChangeEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype CartCreatedDetail = CartChangeDetail;\n\n/**\n * beamcartcreated\n * Emitted when a cart is created in Beam for the first time, but NOT when the cart is updated\n * Beam's cart expiration rules are used to determine when a returning visit counts as the same cart\n */\nexport class BeamCartCreatedEvent extends CustomEvent<CartCreatedDetail> {\n static eventName = \"beamcartcreated\" as const;\n constructor(detail: CartCreatedDetail) {\n super(BeamCartCreatedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype OrderCreatedDetail = {\n orderId: TId;\n transactionId: TId;\n cartTotal: number;\n currencyCode: string;\n};\n\n/**\n * beamordercreated\n * Emitted when an order is registered with Beam for the first time, but NOT on repeat visits, page refreshes, etc.\n */\nexport class BeamOrderCreatedEvent extends CustomEvent<OrderCreatedDetail> {\n static eventName = \"beamordercreated\" as const;\n\n constructor(detail: OrderCreatedDetail) {\n super(BeamOrderCreatedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\n/**\n * beamstatuschange\n * Emitted when the Beam config object has finished initializing along with all plugins\n */\ntype BeamStatusChangeEventDetail = { status: \"pending\" } | { status: \"error\"; error: Error } | { status: \"ready\" };\nexport class BeamStatusChangeEvent extends CustomEvent<BeamStatusChangeEventDetail> {\n static eventName = \"beamstatuschange\" as const;\n\n constructor(detail: BeamStatusChangeEventDetail) {\n super(BeamStatusChangeEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\ntype NonprofitSelectionRemovedDetail = {\n previousNonprofitId?: number | null;\n newNonprofitId?: number | null;\n};\n\n/**\n * beamnonprofitselectionremoved\n * Emitted when the nonprofit selection is removed from deselection or due to nonprofit cohort change\n */\nexport class BeamNonprofitSelectionRemovedEvent extends CustomEvent<NonprofitSelectionRemovedDetail> {\n static eventName = \"beamnonprofitselectionremoved\" as const;\n constructor(detail: NonprofitSelectionRemovedDetail) {\n super(BeamNonprofitSelectionRemovedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n"],"names":["_BeamNetworkCallEvent","detail","BeamNetworkCallEvent","_BeamNonprofitSelectEvent","BeamNonprofitSelectEvent","_BeamCartChangeEvent","BeamCartChangeEvent","_BeamCartCreatedEvent","BeamCartCreatedEvent","_BeamOrderCreatedEvent","BeamOrderCreatedEvent","_BeamStatusChangeEvent","BeamStatusChangeEvent","_BeamNonprofitSelectionRemovedEvent","BeamNonprofitSelectionRemovedEvent"],"mappings":"AAaO,MAAMA,EAAN,MAAMA,UAA6B,WAAgC,CAExE,YAAYC,EAA4B,CACtC,MAAMD,EAAqB,UAAW,CAAE,OAAAC,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACjF,CACF,EALaD,EACJ,UAAY,kBADd,IAAME,EAANF,EAoBA,MAAMG,EAAN,MAAMA,UAAiC,WAAmC,CAE/E,YAAYF,EAA+B,CACzC,MAAME,EAAyB,UAAW,CAAE,OAAAF,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACrF,CACF,EALaE,EACJ,UAAY,sBADd,IAAMC,EAAND,EAoBA,MAAME,EAAN,MAAMA,UAA4B,WAA8B,CAErE,YAAYJ,EAA0B,CACpC,MAAMI,EAAoB,UAAW,CAAE,OAAAJ,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAChF,CACF,EALaI,EACJ,UAAY,iBADR,IAAAC,EAAND,EAgBA,MAAME,EAAN,MAAMA,UAA6B,WAA+B,CAEvE,YAAYN,EAA2B,CACrC,MAAMM,EAAqB,UAAW,CAAE,OAAAN,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACjF,CACF,EALaM,EACJ,UAAY,sBADRC,EAAND,EAoBA,MAAME,EAAN,MAAMA,UAA8B,WAAgC,CAGzE,YAAYR,EAA4B,CACtC,MAAMQ,EAAsB,UAAW,CAAE,OAAAR,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAClF,CACF,EANaQ,EACJ,UAAY,uBADRC,EAAND,EAeA,MAAME,EAAN,MAAMA,UAA8B,WAAyC,CAGlF,YAAYV,EAAqC,CAC/C,MAAMU,EAAsB,UAAW,CAAE,OAAAV,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAClF,CACF,EANaU,EACJ,UAAY,mBADR,IAAAC,EAAND,EAkBA,MAAME,EAAN,MAAMA,UAA2C,WAA6C,CAEnG,YAAYZ,EAAyC,CACnD,MAAMY,EAAmC,UAAW,CAAE,OAAAZ,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAC/F,CACF,EALaY,EACJ,UAAY,gCADd,IAAMC,EAAND"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as TCartApi } from './cart-contents-
|
|
1
|
+
import { a as TCartApi } from './cart-contents-IOhdr24g.esm.js';
|
|
2
2
|
import { c as TId } from './types-7kSi85Gv.esm.js';
|
|
3
3
|
|
|
4
4
|
type NetworkEventDetail = {
|
|
@@ -88,6 +88,18 @@ declare class BeamStatusChangeEvent extends CustomEvent<BeamStatusChangeEventDet
|
|
|
88
88
|
static eventName: "beamstatuschange";
|
|
89
89
|
constructor(detail: BeamStatusChangeEventDetail);
|
|
90
90
|
}
|
|
91
|
+
type NonprofitSelectionRemovedDetail = {
|
|
92
|
+
previousNonprofitId?: number | null;
|
|
93
|
+
newNonprofitId?: number | null;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* beamnonprofitselectionremoved
|
|
97
|
+
* Emitted when the nonprofit selection is removed from deselection or due to nonprofit cohort change
|
|
98
|
+
*/
|
|
99
|
+
declare class BeamNonprofitSelectionRemovedEvent extends CustomEvent<NonprofitSelectionRemovedDetail> {
|
|
100
|
+
static eventName: "beamnonprofitselectionremoved";
|
|
101
|
+
constructor(detail: NonprofitSelectionRemovedDetail);
|
|
102
|
+
}
|
|
91
103
|
|
|
92
104
|
type events_BeamCartChangeEvent = BeamCartChangeEvent;
|
|
93
105
|
declare const events_BeamCartChangeEvent: typeof BeamCartChangeEvent;
|
|
@@ -97,12 +109,14 @@ type events_BeamNetworkCallEvent = BeamNetworkCallEvent;
|
|
|
97
109
|
declare const events_BeamNetworkCallEvent: typeof BeamNetworkCallEvent;
|
|
98
110
|
type events_BeamNonprofitSelectEvent = BeamNonprofitSelectEvent;
|
|
99
111
|
declare const events_BeamNonprofitSelectEvent: typeof BeamNonprofitSelectEvent;
|
|
112
|
+
type events_BeamNonprofitSelectionRemovedEvent = BeamNonprofitSelectionRemovedEvent;
|
|
113
|
+
declare const events_BeamNonprofitSelectionRemovedEvent: typeof BeamNonprofitSelectionRemovedEvent;
|
|
100
114
|
type events_BeamOrderCreatedEvent = BeamOrderCreatedEvent;
|
|
101
115
|
declare const events_BeamOrderCreatedEvent: typeof BeamOrderCreatedEvent;
|
|
102
116
|
type events_BeamStatusChangeEvent = BeamStatusChangeEvent;
|
|
103
117
|
declare const events_BeamStatusChangeEvent: typeof BeamStatusChangeEvent;
|
|
104
118
|
declare namespace events {
|
|
105
|
-
export { events_BeamCartChangeEvent as BeamCartChangeEvent, events_BeamCartCreatedEvent as BeamCartCreatedEvent, events_BeamNetworkCallEvent as BeamNetworkCallEvent, events_BeamNonprofitSelectEvent as BeamNonprofitSelectEvent, events_BeamOrderCreatedEvent as BeamOrderCreatedEvent, events_BeamStatusChangeEvent as BeamStatusChangeEvent };
|
|
119
|
+
export { events_BeamCartChangeEvent as BeamCartChangeEvent, events_BeamCartCreatedEvent as BeamCartCreatedEvent, events_BeamNetworkCallEvent as BeamNetworkCallEvent, events_BeamNonprofitSelectEvent as BeamNonprofitSelectEvent, events_BeamNonprofitSelectionRemovedEvent as BeamNonprofitSelectionRemovedEvent, events_BeamOrderCreatedEvent as BeamOrderCreatedEvent, events_BeamStatusChangeEvent as BeamStatusChangeEvent };
|
|
106
120
|
}
|
|
107
121
|
|
|
108
|
-
export { BeamNonprofitSelectEvent as B, BeamNetworkCallEvent as a, BeamCartChangeEvent as b, BeamCartCreatedEvent as c, BeamOrderCreatedEvent as d, events as e, BeamStatusChangeEvent as f };
|
|
122
|
+
export { BeamNonprofitSelectEvent as B, BeamNetworkCallEvent as a, BeamCartChangeEvent as b, BeamCartCreatedEvent as c, BeamOrderCreatedEvent as d, events as e, BeamStatusChangeEvent as f, BeamNonprofitSelectionRemovedEvent as g };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TBeamOrderPageParams, a as addBeamAttributesToCart, g as getCurrentCart, r as registerCartIntegration, s as showBeamOrderPageWidgets, t as trackCart } from './order-page-
|
|
1
|
+
import { T as TBeamOrderPageParams, a as addBeamAttributesToCart, g as getCurrentCart, r as registerCartIntegration, s as showBeamOrderPageWidgets, t as trackCart } from './order-page-jkuLE25f.esm.js';
|
|
2
2
|
|
|
3
3
|
declare const index_TBeamOrderPageParams: typeof TBeamOrderPageParams;
|
|
4
4
|
declare const index_addBeamAttributesToCart: typeof addBeamAttributesToCart;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-Y8fYvSqM.esm.js";import{logger as r}from"../utils/logger.esm.js";import{fetchProxy as t,initNetworkListeners as i,xhrProxy as m}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as a}from"../utils/local-storage.esm.js";import{waitForElement as s}from"../utils/wait-for-element.esm.js";import{deleteCookieValue as l,getCookieMap as n,getCookieValue as p,setCookieValue as f}from"../utils/cookies.esm.js";import{getRemoteSession as g,saveRemoteSession as c}from"../utils/remote-session.esm.js";import{memoizeLast as u}from"../utils/memoize-last.esm.js";import{d as k,i as d}from"./lodash-P8OIs-at.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:a,debounce:k,deleteCookieValue:l,errors:e,events:o,fetchProxy:t,getCookieMap:n,getCookieValue:p,getRemoteSession:g,initNetworkListeners:i,isEqual:d,logger:r,memoizeLast:u,saveRemoteSession:c,setCookieValue:f,waitForElement:s,xhrProxy:m});export{x as i};
|
|
2
|
+
//# sourceMappingURL=index-8yrr7ZZv.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-8yrr7ZZv.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B2oj1JKu.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-E_HMWZ2A.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,d as n}from"./routes-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{a as i,d as n}from"./routes-ad0I3Ayc.esm.js";import{logger as d}from"../utils/logger.js";async function e(o,r){const{apiKey:a,baseUrl:s}=o;try{await n({baseUrl:s||i,headers:{authorization:`Api-Key ${a}`},requestBody:{...r}})}catch(t){d.error("Failed to send log",t)}}var l=Object.freeze({__proto__:null,sendLog:e});export{l as i,e as s};
|
|
2
|
+
//# sourceMappingURL=index-Gz7Q9nUW.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-Gz7Q9nUW.esm.js","sources":["../../src/integrations/logs/index.ts"],"sourcesContent":["import { postLogs } from \"../../api-sdk/v3/routes\";\nimport { paths } from \"../../api-sdk/v3/openapi-spec\";\nimport { logger } from \"../../utils/logger\";\nimport { DEFAULT_LOG_URL } from \"../../api-sdk/constants\";\n\ntype PostLogsReq = paths[\"/logs\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\n\ninterface SendLogConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport async function sendLog(config: SendLogConfig, payload: PostLogsReq): Promise<void> {\n const { apiKey, baseUrl } = config;\n try {\n await postLogs({\n baseUrl: baseUrl || DEFAULT_LOG_URL,\n headers: {\n authorization: `Api-Key ${apiKey}`,\n },\n requestBody: {\n ...payload,\n },\n });\n } catch (err) {\n logger.error(\"Failed to send log\", err);\n }\n}\n"],"names":["sendLog","config","payload","apiKey","baseUrl","postLogs","DEFAULT_LOG_URL","err","logger"],"mappings":"gGAYA,eAAsBA,EAAQC,EAAuBC,EAAqC,CACxF,KAAM,CAAE,OAAAC,EAAQ,QAAAC,CAAQ,EAAIH,EAC5B,GAAI,CACF,MAAMI,EAAS,CACb,QAASD,GAAWE,EACpB,QAAS,CACP,cAAe,WAAWH,CAAM,EAClC,EACA,YAAa,CACX,GAAGD,CACL,CACF,CAAC,CACH,OAASK,EAAK,CACZC,EAAO,MAAM,qBAAsBD,CAAG,CACxC,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as e,p as r,P as t,s as a,R as o}from"./order-page-yM2h67MI.esm.js";var s=Object.freeze({__proto__:null,addBeamAttributesToCart:e,getCurrentCart:r,registerCartIntegration:t,showBeamOrderPageWidgets:a,trackCart:o});export{s as i};
|
|
2
|
+
//# sourceMappingURL=index-JsXH5Lnc.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-JsXH5Lnc.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-Y8fYvSqM.esm.js";import{logger as r}from"../utils/logger.esm.js";import{fetchProxy as t,initNetworkListeners as i,xhrProxy as m}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as a}from"../utils/local-storage.esm.js";import{waitForElement as s}from"../utils/wait-for-element.esm.js";import{deleteCookieValue as l,getCookieMap as n,getCookieValue as p,setCookieValue as f}from"../utils/cookies.esm.js";import{getRemoteSession as g,saveRemoteSession as c}from"../utils/remote-session.esm.js";import{memoizeLast as u}from"../utils/memoize-last.esm.js";import{d as k,i as d}from"./lodash-P8OIs-at.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:a,debounce:k,deleteCookieValue:l,errors:e,events:o,fetchProxy:t,getCookieMap:n,getCookieValue:p,getRemoteSession:g,initNetworkListeners:i,isEqual:d,logger:r,memoizeLast:u,saveRemoteSession:c,setCookieValue:f,waitForElement:s,xhrProxy:m});export{x as i};
|
|
2
|
+
//# sourceMappingURL=index-Lw32NXij.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Lw32NXij.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i}from"./index-uF-Qtewb.esm.js";import{i as o}from"./index-VGoZaoVm.esm.js";import{i as r}from"./index-Z1UUeVXR.esm.js";import{i as e}from"./index-E_HMWZ2A.esm.js";import{i as m}from"./index-Gz7Q9nUW.esm.js";var s=Object.freeze({__proto__:null,Cart:e,Logs:m,Session:r,Shopify:o,Utils:i});export{s as i};
|
|
2
|
+
//# sourceMappingURL=index-RDKeoKqc.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-RDKeoKqc.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as e,p as r,P as t,s as a,R as o}from"./order-page-9B0nZVh1.esm.js";var s=Object.freeze({__proto__:null,addBeamAttributesToCart:e,getCurrentCart:r,registerCartIntegration:t,showBeamOrderPageWidgets:a,trackCart:o});export{s as i};
|
|
2
|
+
//# sourceMappingURL=index-VGoZaoVm.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-VGoZaoVm.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BeamCartAPIConfig, a as BeamCartValues, u as updateCart } from './update-cart-
|
|
1
|
+
import { B as BeamCartAPIConfig, a as BeamCartValues, u as updateCart } from './update-cart-EKZbvT8c.esm.js';
|
|
2
2
|
|
|
3
3
|
declare const index_BeamCartAPIConfig: typeof BeamCartAPIConfig;
|
|
4
4
|
declare const index_BeamCartValues: typeof BeamCartValues;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as beamErrors } from './beam-errors-fXDkG1zo.esm.js';
|
|
2
|
-
import { e as events } from './events-
|
|
2
|
+
import { e as events } from './events-j-SJ9Cot.esm.js';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import { fetchProxy, initNetworkListeners, xhrProxy } from '../utils/network-listeners.js';
|
|
5
5
|
import { createScopedLocalStorage } from '../utils/local-storage.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-Y8fYvSqM.esm.js";import{logger as r}from"../utils/logger.js";import{fetchProxy as t,initNetworkListeners as i,xhrProxy as m}from"../utils/network-listeners.js";import{createScopedLocalStorage as a}from"../utils/local-storage.js";import{waitForElement as s}from"../utils/wait-for-element.js";import{deleteCookieValue as l,getCookieMap as n,getCookieValue as p,setCookieValue as f}from"../utils/cookies.js";import{getRemoteSession as g,saveRemoteSession as c}from"../utils/remote-session.js";import{memoizeLast as u}from"../utils/memoize-last.js";import{d as k,i as d}from"./lodash-P8OIs-at.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:a,debounce:k,deleteCookieValue:l,errors:e,events:o,fetchProxy:t,getCookieMap:n,getCookieValue:p,getRemoteSession:g,initNetworkListeners:i,isEqual:d,logger:r,memoizeLast:u,saveRemoteSession:c,setCookieValue:f,waitForElement:s,xhrProxy:m});export{x as i};
|
|
2
|
+
//# sourceMappingURL=index-phDmC-TS.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-phDmC-TS.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as index$5 } from './index-
|
|
2
|
-
import { i as index$4 } from './index-
|
|
1
|
+
import { i as index$5 } from './index-mWnpDGl1.esm.js';
|
|
2
|
+
import { i as index$4 } from './index-3F_Wjm5v.esm.js';
|
|
3
3
|
import { i as index$3 } from './index-EGiUuWe-.esm.js';
|
|
4
|
-
import { i as index$1 } from './index-
|
|
5
|
-
import { i as index$2 } from './index-
|
|
4
|
+
import { i as index$1 } from './index-WX8Yyx2u.esm.js';
|
|
5
|
+
import { i as index$2 } from './index-yXqJ9Znv.esm.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* This file is used to provide type definitions
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as beamErrors } from './beam-errors-fXDkG1zo.esm.js';
|
|
2
|
-
import { e as events } from './events-
|
|
2
|
+
import { e as events } from './events-j-SJ9Cot.esm.js';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import { fetchProxy, initNetworkListeners, xhrProxy } from '../utils/network-listeners.js';
|
|
5
5
|
import { createScopedLocalStorage } from '../utils/local-storage.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-Y8fYvSqM.esm.js";import{logger as r}from"../utils/logger.js";import{fetchProxy as t,initNetworkListeners as i,xhrProxy as m}from"../utils/network-listeners.js";import{createScopedLocalStorage as a}from"../utils/local-storage.js";import{waitForElement as s}from"../utils/wait-for-element.js";import{deleteCookieValue as l,getCookieMap as n,getCookieValue as p,setCookieValue as f}from"../utils/cookies.js";import{getRemoteSession as g,saveRemoteSession as c}from"../utils/remote-session.js";import{memoizeLast as u}from"../utils/memoize-last.js";import{d as k,i as d}from"./lodash-P8OIs-at.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:a,debounce:k,deleteCookieValue:l,errors:e,events:o,fetchProxy:t,getCookieMap:n,getCookieValue:p,getRemoteSession:g,initNetworkListeners:i,isEqual:d,logger:r,memoizeLast:u,saveRemoteSession:c,setCookieValue:f,waitForElement:s,xhrProxy:m});export{x as i};
|
|
2
|
+
//# sourceMappingURL=index-uF-Qtewb.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-uF-Qtewb.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,d as n}from"./routes-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{a as i,d as n}from"./routes-LFjgVNGB.esm.js";import{logger as d}from"../utils/logger.esm.js";async function e(o,r){const{apiKey:a,baseUrl:s}=o;try{await n({baseUrl:s||i,headers:{authorization:`Api-Key ${a}`},requestBody:{...r}})}catch(t){d.error("Failed to send log",t)}}var l=Object.freeze({__proto__:null,sendLog:e});export{l as i,e as s};
|
|
2
|
+
//# sourceMappingURL=index-vpkWmZo_.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-vpkWmZo_.esm.js","sources":["../../src/integrations/logs/index.ts"],"sourcesContent":["import { postLogs } from \"../../api-sdk/v3/routes\";\nimport { paths } from \"../../api-sdk/v3/openapi-spec\";\nimport { logger } from \"../../utils/logger\";\nimport { DEFAULT_LOG_URL } from \"../../api-sdk/constants\";\n\ntype PostLogsReq = paths[\"/logs\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\n\ninterface SendLogConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport async function sendLog(config: SendLogConfig, payload: PostLogsReq): Promise<void> {\n const { apiKey, baseUrl } = config;\n try {\n await postLogs({\n baseUrl: baseUrl || DEFAULT_LOG_URL,\n headers: {\n authorization: `Api-Key ${apiKey}`,\n },\n requestBody: {\n ...payload,\n },\n });\n } catch (err) {\n logger.error(\"Failed to send log\", err);\n }\n}\n"],"names":["sendLog","config","payload","apiKey","baseUrl","postLogs","DEFAULT_LOG_URL","err","logger"],"mappings":"oGAYA,eAAsBA,EAAQC,EAAuBC,EAAqC,CACxF,KAAM,CAAE,OAAAC,EAAQ,QAAAC,CAAQ,EAAIH,EAC5B,GAAI,CACF,MAAMI,EAAS,CACb,QAASD,GAAWE,EACpB,QAAS,CACP,cAAe,WAAWH,CAAM,EAClC,EACA,YAAa,CACX,GAAGD,CACL,CACF,CAAC,CACH,OAASK,EAAK,CACZC,EAAO,MAAM,qBAAsBD,CAAG,CACxC,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i}from"./index-Lw32NXij.esm.js";import{i as o}from"./index-JsXH5Lnc.esm.js";import{i as r}from"./index-9YcaEQju.esm.js";import{i as e}from"./index-B2oj1JKu.esm.js";import{i as m}from"./index-vpkWmZo_.esm.js";var s=Object.freeze({__proto__:null,Cart:e,Logs:m,Session:r,Shopify:o,Utils:i});export{s as i};
|
|
2
|
+
//# sourceMappingURL=index-xYLcuL6Z.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-xYLcuL6Z.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -729,7 +729,7 @@ interface paths {
|
|
|
729
729
|
content: {
|
|
730
730
|
localAmount?: number;
|
|
731
731
|
items: {
|
|
732
|
-
remoteProductIdentifier
|
|
732
|
+
remoteProductIdentifier?: string | null;
|
|
733
733
|
localAmount: number;
|
|
734
734
|
remoteSubscriptionId?: string;
|
|
735
735
|
}[];
|
|
@@ -1678,8 +1678,6 @@ interface paths {
|
|
|
1678
1678
|
* @example 1001
|
|
1679
1679
|
*/
|
|
1680
1680
|
storeId?: number;
|
|
1681
|
-
/** @description Unique identifier associated with a specific geographical region for a store */
|
|
1682
|
-
regionId?: string | null;
|
|
1683
1681
|
/**
|
|
1684
1682
|
* @description The ID of the selection
|
|
1685
1683
|
* @example bqkdk-0393b-jbkdd-02difj
|
|
@@ -1784,7 +1782,7 @@ interface paths {
|
|
|
1784
1782
|
content: {
|
|
1785
1783
|
localAmount?: number;
|
|
1786
1784
|
items: {
|
|
1787
|
-
remoteProductIdentifier
|
|
1785
|
+
remoteProductIdentifier?: string | null;
|
|
1788
1786
|
localAmount: number;
|
|
1789
1787
|
remoteSubscriptionId?: string;
|
|
1790
1788
|
}[];
|
|
@@ -2218,8 +2216,6 @@ interface paths {
|
|
|
2218
2216
|
* @example 1001
|
|
2219
2217
|
*/
|
|
2220
2218
|
storeId: number;
|
|
2221
|
-
/** @description Unique identifier associated with a specific geographical region for a store */
|
|
2222
|
-
regionId?: string | null;
|
|
2223
2219
|
/**
|
|
2224
2220
|
* @description The ID of the selection
|
|
2225
2221
|
* @example bqkdk-0393b-jbkdd-02difj
|
|
@@ -2328,7 +2324,7 @@ interface paths {
|
|
|
2328
2324
|
content: {
|
|
2329
2325
|
localAmount?: number;
|
|
2330
2326
|
items: {
|
|
2331
|
-
remoteProductIdentifier
|
|
2327
|
+
remoteProductIdentifier?: string | null;
|
|
2332
2328
|
localAmount: number;
|
|
2333
2329
|
remoteSubscriptionId?: string;
|
|
2334
2330
|
}[];
|
|
@@ -2528,6 +2524,10 @@ interface paths {
|
|
|
2528
2524
|
storeId?: number;
|
|
2529
2525
|
/** @description UUID of existing beam user. Used to update user's `lastNonprofitId` */
|
|
2530
2526
|
beamUserId?: string | null;
|
|
2527
|
+
/** @example 10292 */
|
|
2528
|
+
postalCode?: string;
|
|
2529
|
+
/** @example US */
|
|
2530
|
+
countryCode?: string;
|
|
2531
2531
|
/** @description is this a test selection? */
|
|
2532
2532
|
isTest?: boolean;
|
|
2533
2533
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as T}from"./lodash-P8OIs-at.esm.js";import{d as U,f as A,c as O,g as R}from"./events-Y8fYvSqM.esm.js";import{logger as j}from"../utils/logger.js";import{initNetworkListeners as k}from"../utils/network-listeners.js";import{createScopedLocalStorage as E}from"../utils/local-storage.js";import{getCookieValue as u}from"../utils/cookies.js";import{memoizeLast as J}from"../utils/memoize-last.js";import{B as b}from"./cart-contents-h60geKWa.esm.js";import{x as I}from"./update-cart-vcujKNky.esm.js";import"../components/post-purchase.js";import{D as x}from"./routes-ad0I3Ayc.esm.js";import{waitForElement as K}from"../utils/wait-for-element.js";import{B as P}from"./beam-errors-P-Lu07Ce.esm.js";const N=window.Shopify?.routes?.root||"/";let S=!1;const v="cart";async function D(e){if(S)return!1;const d=await h(e);await I(e,d.cart),k(),window.addEventListener(U.eventName,async i=>{const r=i,o=/cart\/(add|change|update|clear)/,a=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,c=new URL(a);if(!o.test(c.pathname))return;const n=await h(e);if(!n.changed)return;const s={schema:n.cart.schema,content:{items:n.cart.content.items}};window.dispatchEvent(new A(s)),await I(e,n.cart)});let m,p;return window.addEventListener(O.eventName,async i=>{const r=i,{selectedNonprofitId:o,selectionId:a}=r.detail,c=await u(v),n=await u(b),{chainId:s,storeId:l}=e;m===o&&p===a||(await y({selectedNonprofitId:o,selectionId:a,beamCartId:n,cartId:c,chainId:s,storeId:l}),p=a,m=o)}),window.addEventListener(R.eventName,async i=>{const r=i,{newNonprofitId:o}=r.detail,a=await u(v),c=await u(b),{chainId:n,storeId:s}=e;await y({selectedNonprofitId:o,beamCartId:c,cartId:a,chainId:n,storeId:s})}),S=!0,!0}async function h(e){const{token:d,total_price:m,item_count:p,currency:i,items:r}=await window.fetch(N+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()),o={cartId:d,subtotal:m/100,itemCount:p,currencyCode:i,schema:{source:"generic"},content:{items:r.map(({sku:n,final_line_price:s,product_id:l})=>{const f=n||String(l),w=s/100;return{remoteProductIdentifier:f,localAmount:w}})}};let a=!1;const c=E(e).getItemJson("cart");return T(o,c)||(a=!0),{changed:a,cart:o}}const q=I,y=J(async function({selectedNonprofitId:e,selectionId:d,beamCartId:m,cartId:p,chainId:i,storeId:r}){const o={beam:JSON.stringify({nonprofit_id:e,selection_id:d,beam_cart_id:m,shopify_cart_id:p,chain_id:i,store_id:r})};try{await window.fetch(N+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:o})})}catch(a){j.error(a)}});async function F({parentSelector:e=".step__sections",apiKey:d,baseUrl:m=x,storeId:p,postalCode:i,countryCode:r,orderId:o,email:a,cartTotal:c,cart:n,discountCodes:s,currencyCode:l="USD",domain:f,lang:w="en",debug:B=!1}){const g=document.querySelector(e)||await K(e);if(!g)throw new P(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const C=await u("cart");if(C){const _=E({apiKey:d}),L=_.getItemJson("cart")||{};_.setItemJson("cart",{...L,cartId:C})}const t=document.createElement("beam-post-purchase");t.apiKey=d,t.baseUrl=m,t.storeId=p,t.postalCode=i,t.countryCode=r,t.orderId=String(o),t.email=a,t.cartTotal=c,t.cart=n,t.discountCodes=s,t.currencyCode=l,t.domain=f,t.lang=w,t.debug=B,g.appendChild(t)}export{D as P,q as R,y as f,h as p,F as s};
|
|
2
|
+
//# sourceMappingURL=order-page-9B0nZVh1.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-page-9B0nZVh1.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { logger, memoizeLast } from \"../../utils\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { initNetworkListeners } from \"../../utils/network-listeners\";\nimport {\n BeamCartChangeEvent,\n BeamNetworkCallEvent,\n BeamNonprofitSelectEvent,\n BeamNonprofitSelectionRemovedEvent,\n} from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TCart, TCartApi, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\n\ntype BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n const currentCart = await getCurrentCart(config);\n await updateCart(config, currentCart.cart);\n\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n return;\n }\n const eventDetail: TCartApi = {\n schema: currentCart.cart.schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: currentCart.cart.content.items as any,\n },\n };\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n await updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n const { selectedNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME); // Shopify cart ID cookie\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME); // Beam cart ID cookie\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n });\n\n /**\n * Upon removal of the selected nonprofit from the widget and local storage,\n * an event is emitted and that event is then used to update the cart attributes accordingly\n * This event listener updates the cart attributes based on the emitted event\n */\n window.addEventListener(BeamNonprofitSelectionRemovedEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectionRemovedEvent;\n const { newNonprofitId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME);\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME);\n const { chainId, storeId } = config;\n\n await addBeamAttributesToCart({\n selectedNonprofitId: newNonprofitId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n });\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n } = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n\n const cart = {\n cartId: token,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price, product_id }) => {\n const remoteProductIdentifier = sku || String(product_id);\n const localAmount = final_line_price / 100;\n return { remoteProductIdentifier, localAmount };\n }),\n },\n };\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n const cachedCart = localStorage.getItemJson(\"cart\");\n\n if (!isEqual(cart, cachedCart)) {\n changed = true;\n }\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n */\nconst addBeamAttributesToCart = memoizeLast(async function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\nexport { trackCart, getCurrentCart, addBeamAttributesToCart, registerCartIntegration };\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../utils/wait-for-element\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n domain?: string; // Base domain for setting cookies\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n domain,\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.domain = domain;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","currentCart","getCurrentCart","updateCart","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","eventDetail","BeamCartChangeEvent","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","selectedNonprofitId","selectionId","cartId","getCookieValue","beamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","addBeamAttributesToCart","BeamNonprofitSelectionRemovedEvent","newNonprofitId","token","total_price","item_count","currency","items","res","cart","sku","final_line_price","product_id","remoteProductIdentifier","localAmount","changed","cachedCart","createScopedLocalStorage","isEqual","trackCart","memoizeLast","beamCartAttrs","err","logger","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","domain","lang","debug","parentElement","waitForElement","BeamError","beamLocalStorage","existingValue","widget"],"mappings":"2rBAoBA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKT,MAAMI,EAAc,MAAMC,EAAeF,CAAM,EAC/C,MAAMG,EAAWH,EAAQC,EAAY,IAAI,EAGzCG,EAEA,EAAA,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,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AAC,CACH,OAASC,EAAK,CACZC,EAAO,MAAMD,CAAG,CAClB,CACF,CAAC,iBCnMqBE,EAAyB,CAC7C,eAAAC,EAAiB,kBACjB,OAAAC,EACA,QAAAC,EAAUC,EACV,QAAA7B,EACA,WAAA8B,EACA,YAAAC,EACA,QAAAC,EACA,MAAAC,EACA,UAAAC,EACA,KAAAxB,EACA,cAAAyB,EACA,aAAAC,EAAe,MACf,OAAAC,EACA,KAAAC,EAAO,KACP,MAAAC,EAAQ,EACV,EAAyB,CACvB,MAAMC,EAAgB,SAAS,cAAcd,CAAc,GAAM,MAAMe,EAAef,CAAc,EACpG,GAAI,CAACc,EACH,MAAM,IAAIE,EACR,mCAAmChB,CAAc,gDACnD,EAKF,MAAM/B,EAAS,MAAMC,EAAe,MAAM,EAC1C,GAAID,EAAQ,CACV,MAAMgD,EAAmBzB,EAAyB,CAAE,OAAAS,CAAO,CAAC,EACtDiB,EAAgBD,EAAiB,YAAY,MAAM,GAAK,CAAC,EAC/DA,EAAiB,YAAY,OAAQ,CAAE,GAAGC,EAAe,OAAAjD,CAAO,CAAC,CACnE,CAGA,MAAMkD,EAAS,SAAS,cAAc,oBAAoB,EAC1DA,EAAO,OAASlB,EAChBkB,EAAO,QAAUjB,EACjBiB,EAAO,QAAU7C,EACjB6C,EAAO,WAAaf,EACpBe,EAAO,YAAcd,EACrBc,EAAO,QAAU,OAAOb,CAAO,EAC/Ba,EAAO,MAAQZ,EACfY,EAAO,UAAYX,EACnBW,EAAO,KAAOnC,EACdmC,EAAO,cAAgBV,EACvBU,EAAO,aAAeT,EACtBS,EAAO,OAASR,EAChBQ,EAAO,KAAOP,EACdO,EAAO,MAAQN,EAGfC,EAAc,YAAYK,CAAM,CAClC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as lodash from 'lodash';
|
|
2
|
-
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-
|
|
3
|
-
import { T as TCart } from './cart-contents-
|
|
2
|
+
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-EKZbvT8c.esm.js';
|
|
3
|
+
import { T as TCart } from './cart-contents-IOhdr24g.esm.js';
|
|
4
4
|
import '../components/post-purchase.js';
|
|
5
5
|
import { T as TUrl, L as LANGUAGES } from './types-aju0qrRe.esm.js';
|
|
6
6
|
|
|
@@ -54,7 +54,6 @@ declare const postTransaction: ({ headers, baseUrl, apiRoot, pathParams, queryPa
|
|
|
54
54
|
requestBody?: {
|
|
55
55
|
orderId: string | number;
|
|
56
56
|
storeId?: number | undefined;
|
|
57
|
-
regionId?: string | null | undefined;
|
|
58
57
|
selectionId?: string | undefined;
|
|
59
58
|
beamCartId?: string | undefined;
|
|
60
59
|
cartId?: string | undefined;
|
|
@@ -123,7 +122,7 @@ declare const postTransaction: ({ headers, baseUrl, apiRoot, pathParams, queryPa
|
|
|
123
122
|
content: {
|
|
124
123
|
localAmount?: number | undefined;
|
|
125
124
|
items: {
|
|
126
|
-
remoteProductIdentifier
|
|
125
|
+
remoteProductIdentifier?: string | null | undefined;
|
|
127
126
|
localAmount: number;
|
|
128
127
|
remoteSubscriptionId?: string | undefined;
|
|
129
128
|
}[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as T}from"./lodash-P8OIs-at.esm.js";import{d as U,f as A,c as O,g as R}from"./events-Y8fYvSqM.esm.js";import{logger as j}from"../utils/logger.esm.js";import{initNetworkListeners as k}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as E}from"../utils/local-storage.esm.js";import{getCookieValue as u}from"../utils/cookies.esm.js";import{memoizeLast as J}from"../utils/memoize-last.esm.js";import{B as b}from"./cart-contents-h60geKWa.esm.js";import{x as I}from"./update-cart-A2hs4tF8.esm.js";import"../components/post-purchase.esm.js";import{D as x}from"./routes-LFjgVNGB.esm.js";import{waitForElement as K}from"../utils/wait-for-element.esm.js";import{B as P}from"./beam-errors-P-Lu07Ce.esm.js";const N=window.Shopify?.routes?.root||"/";let S=!1;const v="cart";async function D(e){if(S)return!1;const d=await h(e);await I(e,d.cart),k(),window.addEventListener(U.eventName,async i=>{const r=i,o=/cart\/(add|change|update|clear)/,a=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,c=new URL(a);if(!o.test(c.pathname))return;const n=await h(e);if(!n.changed)return;const s={schema:n.cart.schema,content:{items:n.cart.content.items}};window.dispatchEvent(new A(s)),await I(e,n.cart)});let m,p;return window.addEventListener(O.eventName,async i=>{const r=i,{selectedNonprofitId:o,selectionId:a}=r.detail,c=await u(v),n=await u(b),{chainId:s,storeId:l}=e;m===o&&p===a||(await y({selectedNonprofitId:o,selectionId:a,beamCartId:n,cartId:c,chainId:s,storeId:l}),p=a,m=o)}),window.addEventListener(R.eventName,async i=>{const r=i,{newNonprofitId:o}=r.detail,a=await u(v),c=await u(b),{chainId:n,storeId:s}=e;await y({selectedNonprofitId:o,beamCartId:c,cartId:a,chainId:n,storeId:s})}),S=!0,!0}async function h(e){const{token:d,total_price:m,item_count:p,currency:i,items:r}=await window.fetch(N+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()),o={cartId:d,subtotal:m/100,itemCount:p,currencyCode:i,schema:{source:"generic"},content:{items:r.map(({sku:n,final_line_price:s,product_id:l})=>{const f=n||String(l),w=s/100;return{remoteProductIdentifier:f,localAmount:w}})}};let a=!1;const c=E(e).getItemJson("cart");return T(o,c)||(a=!0),{changed:a,cart:o}}const q=I,y=J(async function({selectedNonprofitId:e,selectionId:d,beamCartId:m,cartId:p,chainId:i,storeId:r}){const o={beam:JSON.stringify({nonprofit_id:e,selection_id:d,beam_cart_id:m,shopify_cart_id:p,chain_id:i,store_id:r})};try{await window.fetch(N+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:o})})}catch(a){j.error(a)}});async function F({parentSelector:e=".step__sections",apiKey:d,baseUrl:m=x,storeId:p,postalCode:i,countryCode:r,orderId:o,email:a,cartTotal:c,cart:n,discountCodes:s,currencyCode:l="USD",domain:f,lang:w="en",debug:B=!1}){const g=document.querySelector(e)||await K(e);if(!g)throw new P(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const C=await u("cart");if(C){const _=E({apiKey:d}),L=_.getItemJson("cart")||{};_.setItemJson("cart",{...L,cartId:C})}const t=document.createElement("beam-post-purchase");t.apiKey=d,t.baseUrl=m,t.storeId=p,t.postalCode=i,t.countryCode=r,t.orderId=String(o),t.email=a,t.cartTotal=c,t.cart=n,t.discountCodes=s,t.currencyCode=l,t.domain=f,t.lang=w,t.debug=B,g.appendChild(t)}export{D as P,q as R,y as f,h as p,F as s};
|
|
2
|
+
//# sourceMappingURL=order-page-yM2h67MI.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-page-yM2h67MI.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { logger, memoizeLast } from \"../../utils\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { initNetworkListeners } from \"../../utils/network-listeners\";\nimport {\n BeamCartChangeEvent,\n BeamNetworkCallEvent,\n BeamNonprofitSelectEvent,\n BeamNonprofitSelectionRemovedEvent,\n} from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TCart, TCartApi, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\n\ntype BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n const currentCart = await getCurrentCart(config);\n await updateCart(config, currentCart.cart);\n\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n return;\n }\n const eventDetail: TCartApi = {\n schema: currentCart.cart.schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: currentCart.cart.content.items as any,\n },\n };\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n await updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n const { selectedNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME); // Shopify cart ID cookie\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME); // Beam cart ID cookie\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n });\n\n /**\n * Upon removal of the selected nonprofit from the widget and local storage,\n * an event is emitted and that event is then used to update the cart attributes accordingly\n * This event listener updates the cart attributes based on the emitted event\n */\n window.addEventListener(BeamNonprofitSelectionRemovedEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectionRemovedEvent;\n const { newNonprofitId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME);\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME);\n const { chainId, storeId } = config;\n\n await addBeamAttributesToCart({\n selectedNonprofitId: newNonprofitId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n });\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n } = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n\n const cart = {\n cartId: token,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price, product_id }) => {\n const remoteProductIdentifier = sku || String(product_id);\n const localAmount = final_line_price / 100;\n return { remoteProductIdentifier, localAmount };\n }),\n },\n };\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n const cachedCart = localStorage.getItemJson(\"cart\");\n\n if (!isEqual(cart, cachedCart)) {\n changed = true;\n }\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n */\nconst addBeamAttributesToCart = memoizeLast(async function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\nexport { trackCart, getCurrentCart, addBeamAttributesToCart, registerCartIntegration };\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../utils/wait-for-element\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n domain?: string; // Base domain for setting cookies\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n domain,\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.domain = domain;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","currentCart","getCurrentCart","updateCart","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","eventDetail","BeamCartChangeEvent","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","selectedNonprofitId","selectionId","cartId","getCookieValue","beamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","addBeamAttributesToCart","BeamNonprofitSelectionRemovedEvent","newNonprofitId","token","total_price","item_count","currency","items","res","cart","sku","final_line_price","product_id","remoteProductIdentifier","localAmount","changed","cachedCart","createScopedLocalStorage","isEqual","trackCart","memoizeLast","beamCartAttrs","err","logger","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","domain","lang","debug","parentElement","waitForElement","BeamError","beamLocalStorage","existingValue","widget"],"mappings":"utBAoBA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKT,MAAMI,EAAc,MAAMC,EAAeF,CAAM,EAC/C,MAAMG,EAAWH,EAAQC,EAAY,IAAI,EAGzCG,EAEA,EAAA,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,MAAMC,EAAQD,EACRE,EAAkB,kCAElBC,EAAgBF,EAAM,OAAO,OAAS,MAAQA,EAAM,OAAO,IAAI,YAAcA,EAAM,OAAO,SAAS,IACnGG,EAAM,IAAI,IAAID,CAAa,EACjC,GAAI,CAACD,EAAgB,KAAKE,EAAI,QAAQ,EACpC,OAEF,MAAMT,EAAc,MAAMC,EAAeF,CAAM,EAC/C,GAAI,CAACC,EAAY,QACf,OAEF,MAAMU,EAAwB,CAC5B,OAAQV,EAAY,KAAK,OACzB,QAAS,CACP,MAAOA,EAAY,KAAK,QAAQ,KAClC,CACF,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Me,EAAef,CAAc,EACpG,GAAI,CAACc,EACH,MAAM,IAAIE,EACR,mCAAmChB,CAAc,gDACnD,EAKF,MAAM/B,EAAS,MAAMC,EAAe,MAAM,EAC1C,GAAID,EAAQ,CACV,MAAMgD,EAAmBzB,EAAyB,CAAE,OAAAS,CAAO,CAAC,EACtDiB,EAAgBD,EAAiB,YAAY,MAAM,GAAK,CAAC,EAC/DA,EAAiB,YAAY,OAAQ,CAAE,GAAGC,EAAe,OAAAjD,CAAO,CAAC,CACnE,CAGA,MAAMkD,EAAS,SAAS,cAAc,oBAAoB,EAC1DA,EAAO,OAASlB,EAChBkB,EAAO,QAAUjB,EACjBiB,EAAO,QAAU7C,EACjB6C,EAAO,WAAaf,EACpBe,EAAO,YAAcd,EACrBc,EAAO,QAAU,OAAOb,CAAO,EAC/Ba,EAAO,MAAQZ,EACfY,EAAO,UAAYX,EACnBW,EAAO,KAAOnC,EACdmC,EAAO,cAAgBV,EACvBU,EAAO,aAAeT,EACtBS,EAAO,OAASR,EAChBQ,EAAO,KAAOP,EACdO,EAAO,MAAQN,EAGfC,EAAc,YAAYK,CAAM,CAClC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as E,N as l}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as c}from"../utils/logger.esm.js";var w="1.37.1",C={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.11.2",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function O(o,a){const p={method:"GET",...a,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":w,...a?.headers},preflightContinue:!0,mode:a?.mode||"cors",body:a?.body!=null?a.body:void 0};let r;try{r=await fetch(o,p)}catch(e){const s=new E(`Network call failed (${p?.method.toUpperCase()} ${o})`);throw s.cause=e,c.error(s,o),s}let i,n;try{n=await r.text(),n&&(i=JSON.parse(n))}catch(e){let s=e;throw e instanceof SyntaxError&&(s=new l(r,i,`Response invalid. Expected JSON. Received: "${n}"`),s.cause=e),c.error(s),s}if(!r.ok){const e=new l(r,i,"Response was not OK");throw c.error(e),e}return i}const u="https://api.beamimpact.com",v="https://production.beamimpactlogs.com",U={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},t=(o,a,p)=>({[o]:async function({headers:r={},baseUrl:i=u,apiRoot:n="/api/v3",pathParams:e={},queryParams:s={},requestBody:m}){const h=Object.entries(e).reduce((g,[y,N])=>g.replace(`{${y}}`,N),o),f=JSON.parse(JSON.stringify(s)),d=new URLSearchParams(f).toString(),S=i+n+h+(d&&`?${d}`),b={headers:r,method:a,body:JSON.stringify(m)};return O(S,b)}})[o],L=t("/impact","get"),R=t("/chain/{chainId}/cumulativeImpact","get"),T=t("/selectNonprofit","post"),A=t("/transaction","post"),k=t("/transaction/{transactionId}","put"),x=t("/cart","post"),B=t("/chain/findEligibleNonprofitsForCart","post"),J=t("/logs","post"),D=t("/experimentSession","post"),F=t("/subscriptions/updateSubscriptionNonprofit","post"),I=t("/subscriptions/findOrCreateSubscription","post");export{u as D,U as S,v as a,A as b,x as c,J as d,B as e,T as f,L as g,I as h,k as i,R as j,C as k,D as p,F as u};
|
|
2
|
+
//# sourceMappingURL=routes-LFjgVNGB.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-LFjgVNGB.esm.js","sources":["../../src/api-sdk/fetch-json.ts","../../src/api-sdk/constants.ts","../../src/api-sdk/v3/make-openapi-method.ts","../../src/api-sdk/v3/routes.ts"],"sourcesContent":["/**\n * Wrapper over window.fetch that expects/returns JSON\n */\nimport { BeamError, NetworkError } from \"../utils/beam-errors\";\nimport { logger } from \"../utils/logger\";\nimport { version as pkgVersion } from \"../../package.json\";\n\nexport async function fetchJson<T = unknown>(url: RequestInfo, options?: RequestInit): Promise<T> {\n const fetchOptions = {\n method: \"GET\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n \"X-Beam-Client\": \"WebSDK\",\n \"X-Beam-Client-Version\": pkgVersion,\n ...options?.headers,\n },\n preflightContinue: true,\n mode: options?.mode || \"cors\",\n body: options?.body != null ? options.body : undefined,\n };\n\n let response;\n try {\n response = await fetch(url, fetchOptions);\n // fetch can throw a TypeError if the server can't be reached, catch and log below\n } catch (err) {\n const error = new BeamError(`Network call failed (${fetchOptions?.method.toUpperCase()} ${url})`);\n error.cause = err;\n logger.error(error, url);\n throw error;\n }\n let body;\n let text;\n // This can throw a SyntaxError if response payload is malformed JSON\n try {\n text = await response.text();\n if (text) {\n // (response can be empty)\n body = JSON.parse(text);\n }\n } catch (err) {\n let error = err as Error;\n if (err instanceof SyntaxError) {\n error = new NetworkError(response, body, `Response invalid. Expected JSON. Received: \"${text}\"`);\n error.cause = err;\n }\n logger.error(error);\n throw error;\n }\n // Translate 4xx, 5xx status to runtime error\n if (!response.ok) {\n const error = new NetworkError(response, body, \"Response was not OK\");\n logger.error(error);\n throw error;\n }\n\n return body;\n}\n","import { LANGUAGES, TUrl } from \"./types\";\n\nexport const DEFAULT_BASE_URL: TUrl = \"https://api.beamimpact.com\";\n\nexport const DEFAULT_LOG_URL = \"https://production.beamimpactlogs.com\";\n\nexport const SUPPORTED_LANGUAGES: Record<string, LANGUAGES> = {\n en: \"en\",\n fr: \"fr\",\n de: \"de\",\n es: \"es\",\n it: \"it\",\n pl: \"pl\",\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { fetchJson } from \"../fetch-json\";\nimport { DEFAULT_BASE_URL } from \"../constants\";\nimport { THttpMethod } from \"../types\";\nimport { paths } from \"./openapi-spec\";\n\nexport const makeOpenApiMethod = <\n TPathName extends keyof paths,\n TMethod extends keyof paths[TPathName],\n TStatusCode extends paths[TPathName][TMethod] extends { responses: any }\n ? keyof paths[TPathName][TMethod][\"responses\"]\n : never\n>(\n pathName: TPathName,\n method: TMethod,\n okHttpStatus: TStatusCode\n) => {\n type TRouteSpec = paths[typeof pathName];\n type TRouteMethod = TRouteSpec[typeof method];\n type TParams = \"parameters\" extends keyof TRouteMethod ? TRouteMethod[\"parameters\"] : never;\n type TPathParams = TParams extends { path: any } ? TParams[\"path\"] : Record<string, never>;\n type TQueryParams = TParams extends { query: any } ? TParams[\"query\"] : Record<string, never>;\n type TRequestBody = TRouteMethod extends { requestBody: { content: { \"application/json\": any } } }\n ? TRouteMethod[\"requestBody\"][\"content\"][\"application/json\"]\n : never;\n type TAllResponses = TRouteMethod extends { responses: any } ? TRouteMethod[\"responses\"] : never;\n type TOkResponse = TAllResponses[typeof okHttpStatus] extends { content: { \"application/json\": any } }\n ? TAllResponses[typeof okHttpStatus][\"content\"][\"application/json\"]\n : never;\n const openApi = {\n [pathName]: async function ({\n headers = {},\n baseUrl = DEFAULT_BASE_URL,\n apiRoot = \"/api/v3\",\n pathParams = {},\n queryParams = {},\n requestBody,\n }: {\n baseUrl?: string;\n apiRoot?: string;\n pathParams?: TPathParams;\n queryParams?: TQueryParams;\n requestBody?: TRequestBody;\n headers?: Record<string, string>;\n }) {\n const pathWithParams: string = Object.entries(pathParams).reduce((newPath: string, [k, v]) => {\n return newPath.replace(`{${k}}`, v as string);\n }, pathName as string);\n const cleanQueryParams = JSON.parse(JSON.stringify(queryParams));\n const search = new URLSearchParams(cleanQueryParams as unknown as Record<string, string>).toString();\n const url = baseUrl + apiRoot + pathWithParams + (search && `?${search}`);\n const options = { headers, method: method as THttpMethod, body: JSON.stringify(requestBody) };\n\n return fetchJson<TOkResponse>(url, options);\n },\n };\n\n // Use object to create function with dynamic name, for better stacktraces\n return openApi[pathName];\n};\n","import { makeOpenApiMethod } from \"./make-openapi-method\";\n\nexport const getChainNonprofits = makeOpenApiMethod(\"/chain/{chainId}/nonprofits\", \"get\", 200);\n\nexport const getImpact = makeOpenApiMethod(\"/impact\", \"get\", 200);\n\nexport const getCumulativeImpact = makeOpenApiMethod(\"/chain/{chainId}/cumulativeImpact\", \"get\", 200);\n\nexport const postSelectNonprofit = makeOpenApiMethod(\"/selectNonprofit\", \"post\", 201);\n\nexport const postTransaction = makeOpenApiMethod(\"/transaction\", \"post\", 201);\n\nexport const putTransaction = makeOpenApiMethod(\"/transaction/{transactionId}\", \"put\", 204);\n\nexport const postCart = makeOpenApiMethod(\"/cart\", \"post\", 200);\n\nexport const postChainEligibleNonprofitsForCart = makeOpenApiMethod(\n \"/chain/findEligibleNonprofitsForCart\",\n \"post\",\n 200\n);\n\nexport const postLogs = makeOpenApiMethod(\"/logs\", \"post\", 200);\n\nexport const postExperimentSession = makeOpenApiMethod(\"/experimentSession\", \"post\", 200);\n\nexport const updateSubscription = makeOpenApiMethod(\"/subscriptions/updateSubscriptionNonprofit\", \"post\", 200);\n\nexport const postFindOrCreateSubscription = makeOpenApiMethod(\"/subscriptions/findOrCreateSubscription\", \"post\", 200);\n"],"names":["fetchJson","url","options","fetchOptions","pkgVersion","response","err","error","BeamError","logger","body","text","NetworkError","DEFAULT_BASE_URL","DEFAULT_LOG_URL","SUPPORTED_LANGUAGES","makeOpenApiMethod","pathName","method","okHttpStatus","headers","baseUrl","apiRoot","pathParams","queryParams","requestBody","pathWithParams","newPath","k","v","cleanQueryParams","search","getImpact","getCumulativeImpact","postSelectNonprofit","postTransaction","putTransaction","postCart","postChainEligibleNonprofitsForCart","postLogs","postExperimentSession","updateSubscription","postFindOrCreateSubscription"],"mappings":"wQAOA,eAAsBA,EAAuBC,EAAkBC,EAAmC,CAChG,MAAMC,EAAe,CACnB,OAAQ,MACR,GAAGD,EACH,QAAS,CACP,eAAgB,mBAChB,OAAQ,mBACR,gBAAiB,SACjB,wBAAyBE,EACzB,GAAGF,GAAS,OACd,EACA,kBAAmB,GACnB,KAAMA,GAAS,MAAQ,OACvB,KAAMA,GAAS,MAAQ,KAAOA,EAAQ,KAAO,MAC/C,EAEA,IAAIG,EACJ,GAAI,CACFA,EAAW,MAAM,MAAMJ,EAAKE,CAAY,CAE1C,OAASG,EAAK,CACZ,MAAMC,EAAQ,IAAIC,EAAU,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,OAAQF,EAAuB,KAAM,KAAK,UAAUO,CAAW,CAAE,EAE5F,OAAOzB,EAAuBC,EAAKC,CAAO,CAC5C,CACF,GAGee,CAAQ,ECvDZe,EAAYhB,EAAkB,UAAW,KAAU,EAEnDiB,EAAsBjB,EAAkB,oCAAqC,KAAU,EAEvFkB,EAAsBlB,EAAkB,mBAAoB,MAAW,EAEvEmB,EAAkBnB,EAAkB,eAAgB,MAAW,EAE/DoB,EAAiBpB,EAAkB,+BAAgC,KAAU,EAE7EqB,EAAWrB,EAAkB,QAAS,MAAW,EAEjDsB,EAAqCtB,EAChD,uCACA,MAEF,EAEauB,EAAWvB,EAAkB,QAAS,MAAW,EAEjDwB,EAAwBxB,EAAkB,qBAAsB,MAAW,EAE3EyB,EAAqBzB,EAAkB,6CAA8C,MAAW,EAEhG0B,EAA+B1B,EAAkB,0CAA2C,MAAW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as E,N as l}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as c}from"../utils/logger.js";var w="1.37.1",C={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.11.2",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function O(o,a){const p={method:"GET",...a,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":w,...a?.headers},preflightContinue:!0,mode:a?.mode||"cors",body:a?.body!=null?a.body:void 0};let r;try{r=await fetch(o,p)}catch(e){const s=new E(`Network call failed (${p?.method.toUpperCase()} ${o})`);throw s.cause=e,c.error(s,o),s}let i,n;try{n=await r.text(),n&&(i=JSON.parse(n))}catch(e){let s=e;throw e instanceof SyntaxError&&(s=new l(r,i,`Response invalid. Expected JSON. Received: "${n}"`),s.cause=e),c.error(s),s}if(!r.ok){const e=new l(r,i,"Response was not OK");throw c.error(e),e}return i}const u="https://api.beamimpact.com",v="https://production.beamimpactlogs.com",U={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},t=(o,a,p)=>({[o]:async function({headers:r={},baseUrl:i=u,apiRoot:n="/api/v3",pathParams:e={},queryParams:s={},requestBody:m}){const h=Object.entries(e).reduce((g,[y,N])=>g.replace(`{${y}}`,N),o),f=JSON.parse(JSON.stringify(s)),d=new URLSearchParams(f).toString(),S=i+n+h+(d&&`?${d}`),b={headers:r,method:a,body:JSON.stringify(m)};return O(S,b)}})[o],L=t("/impact","get"),R=t("/chain/{chainId}/cumulativeImpact","get"),T=t("/selectNonprofit","post"),A=t("/transaction","post"),k=t("/transaction/{transactionId}","put"),x=t("/cart","post"),B=t("/chain/findEligibleNonprofitsForCart","post"),J=t("/logs","post"),D=t("/experimentSession","post"),F=t("/subscriptions/updateSubscriptionNonprofit","post"),I=t("/subscriptions/findOrCreateSubscription","post");export{u as D,U as S,v as a,A as b,x as c,J as d,B as e,T as f,L as g,I as h,k as i,R as j,C as k,D as p,F as u};
|
|
2
|
+
//# sourceMappingURL=routes-ad0I3Ayc.esm.js.map
|