@lockerverse/sdk 0.2.56 → 0.2.59
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 +22 -8
- package/dist/checkout.d.ts.map +1 -1
- package/dist/checkout.js +1 -1
- package/dist/checkout.js.map +1 -1
- package/dist/signup.d.ts +2 -25
- package/dist/signup.d.ts.map +1 -1
- package/dist/signup.js +1 -1
- package/dist/signup.js.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,9 +58,22 @@ const recovered = await client.getPaymentStatus(checkout.paymentReference);
|
|
|
58
58
|
|
|
59
59
|
`createLockerverseCheckoutClient()` exposes only `load`, `calculateTotal`,
|
|
60
60
|
`submitPayment`, and `getPaymentStatus`. It has no selection store, lifecycle
|
|
61
|
-
state,
|
|
61
|
+
state, recurring billing lifecycle, or Stripe state. React applications can use
|
|
62
62
|
`@lockerverse/react` for the complete payment UI and orchestration.
|
|
63
63
|
|
|
64
|
+
Select one fixed recurring Product without a quantity. Lockerverse returns its
|
|
65
|
+
monthly or annual cadence in the prepared checkout:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const recurringCheckout = await client.calculateTotal({
|
|
69
|
+
email: "customer@example.com",
|
|
70
|
+
items: [{ productId: monthlyProduct.id }],
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
One-time fixed Products use `quantity`. One-time custom Products use
|
|
75
|
+
`amountCents`. A recurring checkout contains exactly one fixed Product.
|
|
76
|
+
|
|
64
77
|
Fixed prices in the catalog are display data. `calculateTotal()` sends Product
|
|
65
78
|
IDs and selections to Lockerverse, which resolves the payable amount. The host
|
|
66
79
|
returns them together as one immutable prepared checkout. Pass that prepared
|
|
@@ -97,26 +110,27 @@ positive `requestTimeoutMs` value.
|
|
|
97
110
|
## Signup
|
|
98
111
|
|
|
99
112
|
```ts
|
|
100
|
-
import {
|
|
113
|
+
import { createLockerverseSignupClient } from "@lockerverse/sdk/signup";
|
|
101
114
|
|
|
102
|
-
const signup =
|
|
115
|
+
const signup = createLockerverseSignupClient({
|
|
103
116
|
communitySlug: "auburn",
|
|
104
117
|
signupSlug: "tailgate-guests",
|
|
105
118
|
});
|
|
106
119
|
|
|
107
120
|
const definition = await signup.load();
|
|
121
|
+
const submissionReference = crypto.randomUUID();
|
|
108
122
|
const submission = await signup.submit({
|
|
109
123
|
answers: [{ fieldId: "guest-type", value: "student" }],
|
|
110
124
|
email: "customer@example.com",
|
|
111
125
|
name: "Ada Lovelace",
|
|
112
126
|
participantCount: 2,
|
|
113
|
-
});
|
|
127
|
+
}, { submissionReference });
|
|
114
128
|
```
|
|
115
129
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
130
|
+
The signup client is stateless. Calls to `load` and `submit` are independent.
|
|
131
|
+
Create a submission reference before a request. If an error has
|
|
132
|
+
`recoveryRecommended: true`, reuse that reference with the same values so
|
|
133
|
+
Lockerverse can return the original submission.
|
|
120
134
|
|
|
121
135
|
## Security and observability
|
|
122
136
|
|
package/dist/checkout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","names":[],"sources":["../src/checkout-client.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","names":[],"sources":["../src/checkout-client.ts"],"mappings":";;iBAoDgB,gCACd,SAAS,iCACR"}
|
package/dist/checkout.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,M as i,N as a,O as o,P as s,S as c,T as l,_ as u,b as d,c as f,d as p,g as m,h,i as g,j as _,k as v,l as y,m as b,n as ee,o as x,p as S,r as C,s as w,t as T,u as E,v as te,w as D,x as O,y as k}from"./transport.js";import{n as A,t as ne}from"./types.js";function j(e){let t=p(e.apiBaseUrl!==void 0&&e.environment===void 0?{...e,environment:`production`}:e,`widgetSlug`);return{...t,widgetSlug:t.resourceSlug,widgetSlugValue:t.resourceSlugValue}}const M=l(D(e({email:D(_()),includeServiceFee:D(b()),promoCode:D(_()),tipCents:D(E(0))}),{})),N=l(e({confirmationToken:D(f),customFieldAnswers:D(S(x)),email:_(),memberId:D(_()),merchSize:D(r([`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`])),metadata:D(o(_(),_())),phone:D(_()),shipping:D(e({address:e({city:_(),country:_(),line1:_(),line2:D(_()),postal_code:_(),state:_()}),name:_()}))})),re=a([e({amountCents:E(1),productId:f}),e({productId:f,quantity:E(1)})]),ie=a([e({amountCents:E(1),productSlug:f}),e({productSlug:f,quantity:E(1)})]),P=l(n(S(re),k(1))),ae=l(n(S(ie),k(1))),F=r([`one-time`,`monthly`,`annually`]),I=O(E(0)),L=n(_(),v(/^pk_(?:test|live)_\S+$/,`Invalid publishable key.`)),R={description:y,id:f,inventoryQuantity:I,maxQuantity:I,minimumAmountCents:I,minQuantity:I,name:f,paymentOption:F},z=n(s(`pricingMode`,[t({...R,amountCents:E(0),pricingMode:u(`fixed`)}),t({...R,amountCents:I,pricingMode:u(`custom`)})]),h(({maxQuantity:e,minQuantity:t})=>e===null||t===null||t<=e)),B=t({acceptsDiscounts:D(b(),!1),id:f,product:z,productId:f,slug:f}),V=D(t({memberId:D(b(),!1),merchSize:D(b(),!1),phone:D(b(),!1),promoCode:D(b(),!1),serviceFee:D(b(),!1),shipping:D(b(),!1),tipping:D(b(),!1)}),{}),H=n(t({community:D(t({color:_(),name:f,thumbnail:_()})),config:D(t({customFields:w,fields:V})),description:y,id:D(_(),``),name:D(_(),`Lockerverse widget`),payment:t({currency:u(`usd`),publishableKey:L}),pricingPolicy:D(t({currency:D(u(`usd`),`usd`),serviceFeeRateBasisPoints:D(E(0),0)})),products:D(S(B),[]),showCommunityBranding:D(b(),!0),title:y}),i(e=>({...e,config:{customFields:e.config?.customFields??[],fields:{memberId:e.config?.fields?.memberId??!1,merchSize:e.config?.fields?.merchSize??!1,phone:e.config?.fields?.phone??!1,promoCode:e.config?.fields?.promoCode??!1,serviceFee:e.config?.fields?.serviceFee??!1,shipping:e.config?.fields?.shipping??!1,tipping:e.config?.fields?.tipping??!1}},pricingPolicy:e.pricingPolicy??{currency:`usd`,serviceFeeRateBasisPoints:0}}))),U=O(t({percentageOff:n(c(),m(),d(0),te(100)),source:r([`email_list`,`promo_code`])})),W=t({acceptsDiscounts:b(),listingId:f,listingSlug:f,paymentOption:F,pricingMode:r([`fixed`,`custom`]),productId:f,productName:f,quantity:E(1),subtotalCents:E(0),unitAmountCents:E(0)}),G=t({amountCents:E(0),appliedDiscount:U,connectedAccountId:O(f),discountableSubtotalCents:E(0),discountCents:E(0),lineItems:S(W),paymentOption:F,serviceFeeCents:E(0),subtotalCents:E(0),tipCents:E(0),totalCents:E(0)}),K=n(g,h(e=>e.checkoutId.trim()&&e.paymentReference.trim()?e.checkoutStatus===`action_required`?e.requiresAction&&e.paymentRequired&&!!e.clientSecret?.trim():!e.requiresAction&&e.clientSecret===null:!1,`Invalid payment result state.`)),q=t({catalog:H,quote:G}),J=l(G),oe=l(q),Y=l(K),se=l(H);function ce(e){let{product:t}=e;return{acceptsDiscounts:e.acceptsDiscounts??!1,amountCents:t.amountCents,description:t.description??null,id:t.id,inventoryQuantity:t.inventoryQuantity,listingId:e.id,maximumQuantity:t.maxQuantity,minimumAmountCents:t.minimumAmountCents,minimumQuantity:t.minQuantity,name:t.name,paymentOption:t.paymentOption,pricingMode:t.pricingMode,slug:e.slug}}function X(e){let t=e.config?.fields??{};return{community:e.community?{accentColor:e.community.color,imageUrl:e.community.thumbnail,name:e.community.name}:null,payment:{currency:e.payment.currency,publishableKey:e.payment.publishableKey},pricingPolicy:{currency:`usd`,serviceFeeRateBasisPoints:e.pricingPolicy?.serviceFeeRateBasisPoints??0},products:(e.products??[]).map(ce),widget:{customFields:e.config?.customFields??[],description:e.description??null,fields:{memberId:t.memberId??!1,merchSize:t.merchSize??!1,phone:t.phone??!1,promoCode:t.promoCode??!1,serviceFee:t.serviceFee??!1,shipping:t.shipping??!1,tipping:t.tipping??!1},id:e.id??``,name:e.name??`Lockerverse widget`,showCommunityBranding:e.showCommunityBranding??!0,title:e.title??null}}}function Z(e){return $(e)}function le(e){return $(e)}function Q(e){return $(e)}function $(e){return C(structuredClone(e))}function ue(e){let{apiBaseUrl:t,communitySlug:n,communitySlugValue:r,environment:i,fetchImplementation:a,onError:o,requestTimeoutMs:s,sentryDsn:c,widgetSlug:l,widgetSlugValue:u}=j(e),d,f=ee({communitySlug:r,environment:i,getContext:()=>({widgetSlug:u}),onError:o,resourceContextName:`lockerverse_widget`,sentryDsn:c}),{requestJson:p}=T(a,f,s),m=`${t}/v2/community/${n}/payment-widgets/${l}/checkout`;function h(e,t,n=`invalid_selection`){throw f(new A({code:n,message:e,operation:t,reportable:!1}))}function g(e,t){return e instanceof A?e:new A({...t,reportable:!0})}function _(e,t,n=!1){let r=g(e,t),i=n&&(r.status===void 0||r.status>=500);throw f(i?new A({code:r.code,message:r.message,operation:r.operation,recoveryRecommended:!0,reportable:r.reportable,...r.status===void 0?{}:{status:r.status}}):r)}function v(e,t){let n;try{n=M(e)}catch{h(`Checkout pricing input is invalid.`,t)}let r=n.email?.trim().toLowerCase(),i=n.promoCode?.trim();return{...r?{email:r}:{},...n.includeServiceFee===void 0?{}:{includeServiceFee:n.includeServiceFee},...i?{promoCode:i}:{},...n.tipCents===void 0?{}:{tipCents:n.tipCents}}}function y(e){(!(e&&typeof e==`object`)||Array.isArray(e))&&h(`Checkout selection is invalid.`,`bootstrap_checkout`);let{items:t,...n}=e;try{return{pricing:v(n,`bootstrap_checkout`),selection:ae(t)}}catch(e){if(e instanceof A)throw e;h(`Checkout selection is invalid.`,`bootstrap_checkout`)}}function b(e,t){return t.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);return n||h(`Selected Product is unavailable.`,`bootstrap_checkout`),`amountCents`in t?((n.pricingMode!==`custom`||n.minimumAmountCents!==null&&t.amountCents<n.minimumAmountCents)&&h(`Selected Product amount is invalid.`,`bootstrap_checkout`),{amountCents:t.amountCents,productId:n.id}):((n.pricingMode!==`fixed`||n.minimumQuantity!==null&&t.quantity<n.minimumQuantity||n.maximumQuantity!==null&&t.quantity>n.maximumQuantity||n.inventoryQuantity!==null&&t.quantity>n.inventoryQuantity)&&h(`Selected Product quantity is invalid.`,`bootstrap_checkout`),{productId:n.id,quantity:t.quantity})})}function x(e,t,n,r){if(!d)throw new A({...r,message:`Load the Lockerverse widget before calculating a checkout.`,reportable:!1});if(e.paymentOption!==`one-time`)throw new A({...r,message:`Lockerverse returned an unsupported checkout cadence.`,reportable:!0});let{connectedAccountId:i,paymentOption:a,...o}=e;return le(C({...o,authoritative:!0,items:t,payment:{connectedAccountId:i,currency:`usd`,publishableKey:d},paymentOption:`one-time`,paymentReference:globalThis.crypto.randomUUID(),pricing:n}))}function S(e){(!(e&&typeof e==`object`)||Array.isArray(e))&&h(`Checkout selection is invalid.`,`calculate_total`);let{items:t,...n}=e;try{return{items:P(t),pricing:v(n,`calculate_total`)}}catch(e){if(e instanceof A)throw e;h(`Checkout selection is invalid.`,`calculate_total`)}}function w(e){try{if(!(e&&typeof e==`object`)||Array.isArray(e))throw TypeError(`Invalid quote.`);let t=e;if(t.authoritative!==!0||t.paymentOption!==`one-time`||typeof t.paymentReference!=`string`||t.paymentReference.length===0||t.payment.currency!==`usd`||t.payment.publishableKey!==d)throw TypeError(`Invalid quote.`);let n=J({...t,connectedAccountId:t.payment.connectedAccountId});if(n.paymentOption!==`one-time`)throw TypeError(`Unsupported checkout cadence.`);let{connectedAccountId:r,paymentOption:i,...a}=n;return C({...a,authoritative:!0,payment:{connectedAccountId:r,currency:`usd`,publishableKey:d},paymentOption:`one-time`,paymentReference:t.paymentReference})}catch{h(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}function E(e){try{if(!(e&&typeof e==`object`)||Array.isArray(e))throw TypeError(`Invalid payment input.`);let{checkout:t,submission:n}=e;if(!(t&&typeof t==`object`)||Array.isArray(t))throw TypeError(`Invalid prepared checkout.`);let r=t,i=P(r.items),a=v(r.pricing,`submit_payment`),o=w(r),s=N(n);o.totalCents>0&&!s.confirmationToken&&h(`Stripe confirmation is required for a paid checkout.`,`submit_payment`,`payment_submit_failed`);let c=s.email.trim().toLowerCase();return(!c||c!==a.email)&&h(`Payment email must match the current checkout quote.`,`submit_payment`),{items:i,pricing:a,quote:o,submission:{...s,email:c}}}catch(e){if(e instanceof A)throw e;h(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}return{async bootstrapCheckout(e){let{pricing:t,selection:n}=y(e),r={code:`checkout_bootstrap_failed`,message:`Lockerverse returned an invalid checkout bootstrap.`,operation:`bootstrap_checkout`};try{let e=await p(`${m}/bootstrap`,{body:JSON.stringify({...t,items:n}),headers:{"Content-Type":`application/json`},method:`POST`},oe,{...r,message:`Unable to bootstrap the Lockerverse checkout because the request failed.`,report:!1},{...r,report:!1});if(!e.ok)throw new A({...r,message:`Unable to bootstrap the Lockerverse checkout (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});let i=C(X(e.value.catalog));d=i.payment.publishableKey;let a=b(i,n),o={...t,includeServiceFee:t.includeServiceFee??i.widget.fields.serviceFee};return C({catalog:Z(i),checkout:x(e.value.quote,a,o,r)})}catch(e){_(e,r)}},async calculateTotal(e){let{items:t,pricing:n}=S(e),r={code:`total_calculation_failed`,message:`Lockerverse returned an invalid checkout total.`,operation:`calculate_total`};try{let e=await p(`${m}/quote`,{body:JSON.stringify({...n,items:t}),headers:{"Content-Type":`application/json`},method:`POST`},J,{...r,message:`Unable to calculate the Lockerverse checkout total because the request failed.`,report:!1},{...r,report:!1});if(!e.ok)throw new A({...r,message:`Unable to calculate the Lockerverse checkout total (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});return x(e.value,t,n,r)}catch(e){_(e,r)}},async getPaymentStatus(e){(typeof e!=`string`||!e.trim())&&h(`Provide a payment reference to recover its status.`,`get_payment_status`);let t=e.trim(),n={code:`payment_status_failed`,message:`Lockerverse returned an invalid payment status.`,operation:`get_payment_status`};try{let e=await p(`${m}/${encodeURIComponent(t)}/status`,void 0,Y,{...n,message:`Unable to recover the Lockerverse payment status because the request failed.`,report:!1},{...n,report:!1});if(!e.ok)throw new A({...n,message:`Unable to recover the Lockerverse payment status (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});if(e.value.paymentReference!==t)throw new A({...n,reportable:!0});return Q(e.value)}catch(e){_(e,n)}},async load(){let e={code:`widget_load_failed`,message:`Lockerverse returned an invalid widget catalog.`,operation:`load_widget`};try{let r=await p(`${t}/v2/community/${n}/payment-widgets/${l}`,void 0,se,{...e,message:`Unable to load Lockerverse widget because the request failed.`,report:!1},{...e,report:!1});if(!r.ok)throw new A({...e,message:`Unable to load Lockerverse widget (${r.response.status}).`,reportable:r.response.status>=500,status:r.response.status});let i=C(X(r.value));return d=i.payment.publishableKey,Z(i)}catch(t){_(t,e)}},async submitPayment(e){let{items:t,pricing:n,quote:r,submission:i}=E(e),a={code:`payment_submit_failed`,message:`Lockerverse returned an invalid payment confirmation.`,operation:`submit_payment`};try{let e=await p(`${m}/confirm`,{body:JSON.stringify({...i.confirmationToken?{confirmationToken:i.confirmationToken}:{},customFieldAnswers:i.customFieldAnswers,email:i.email,expectedAmountCents:r.amountCents,expectedAppliedDiscount:r.appliedDiscount,expectedConnectedAccountId:r.payment.connectedAccountId,expectedDiscountableSubtotalCents:r.discountableSubtotalCents,expectedDiscountCents:r.discountCents,expectedServiceFeeCents:r.serviceFeeCents,expectedSubtotalCents:r.subtotalCents,expectedTipCents:r.tipCents,expectedTotalCents:r.totalCents,...n,items:t,memberId:i.memberId,merchSize:i.merchSize,metadata:i.metadata,paymentReference:r.paymentReference,phone:i.phone,quoteContractVersion:1,shipping:i.shipping}),headers:{"Content-Type":`application/json`},method:`POST`},Y,{...a,message:`Unable to submit the Lockerverse payment because the request failed.`,report:!1},{...a,report:!1});if(!e.ok)throw new A({...a,message:`Unable to submit the Lockerverse payment (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});if(e.value.paymentReference!==r.paymentReference)throw new A({...a,reportable:!0});return Q(e.value)}catch(e){_(e,a,!0)}}}}export{ne as LOCKERVERSE_SDK_VERSION,A as LockerverseSdkError,ue as createLockerverseCheckoutClient};
|
|
1
|
+
import{A as e,C as t,D as n,E as r,M as i,N as a,O as o,P as s,S as c,T as l,_ as u,b as d,c as f,d as p,g as m,h,i as g,j as _,k as v,l as y,m as b,n as ee,o as x,p as S,r as C,s as w,t as T,u as E,v as D,w as O,x as k,y as A}from"./transport.js";import{n as j,t as te}from"./types.js";function ne(e){let t=p(e.apiBaseUrl!==void 0&&e.environment===void 0?{...e,environment:`production`}:e,`widgetSlug`);return{...t,widgetSlug:t.resourceSlug,widgetSlugValue:t.resourceSlugValue}}const re=l(O(e({email:O(_()),includeServiceFee:O(b()),promoCode:O(_()),tipCents:O(E(0))}),{})),M=l(e({confirmationToken:O(f),customFieldAnswers:O(S(x)),email:_(),memberId:O(_()),merchSize:O(r([`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`])),metadata:O(o(_(),_())),phone:O(_()),shipping:O(e({address:e({city:_(),country:_(),line1:_(),line2:O(_()),postal_code:_(),state:_()}),name:_()}))})),N=a([e({amountCents:E(1),productId:f}),e({productId:f,quantity:E(1)}),e({productId:f})]),P=a([e({amountCents:E(1),productSlug:f}),e({productSlug:f,quantity:E(1)}),e({productSlug:f})]),F=l(n(S(N),A(1))),ie=l(n(S(P),A(1))),I=r([`one-time`,`monthly`,`annually`]),L=k(E(0)),ae=n(_(),v(/^pk_(?:test|live)_\S+$/,`Invalid publishable key.`)),R={description:y,id:f,inventoryQuantity:L,maxQuantity:L,minimumAmountCents:L,minQuantity:L,name:f,paymentOption:I},z=n(s(`pricingMode`,[t({...R,amountCents:E(0),pricingMode:u(`fixed`)}),t({...R,amountCents:L,pricingMode:u(`custom`)})]),h(({maxQuantity:e,minQuantity:t})=>e===null||t===null||t<=e)),B=t({acceptsDiscounts:O(b(),!1),id:f,product:z,productId:f,slug:f}),V=O(t({memberId:O(b(),!1),merchSize:O(b(),!1),phone:O(b(),!1),promoCode:O(b(),!1),serviceFee:O(b(),!1),shipping:O(b(),!1),tipping:O(b(),!1)}),{}),H=n(t({community:O(t({color:_(),name:f,thumbnail:_()})),config:O(t({customFields:w,fields:V})),description:y,id:O(_(),``),name:O(_(),`Lockerverse widget`),payment:t({currency:u(`usd`),publishableKey:ae}),pricingPolicy:O(t({currency:O(u(`usd`),`usd`),serviceFeeRateBasisPoints:O(E(0),0)})),products:O(S(B),[]),showCommunityBranding:O(b(),!0),title:y}),i(e=>({...e,config:{customFields:e.config?.customFields??[],fields:{memberId:e.config?.fields?.memberId??!1,merchSize:e.config?.fields?.merchSize??!1,phone:e.config?.fields?.phone??!1,promoCode:e.config?.fields?.promoCode??!1,serviceFee:e.config?.fields?.serviceFee??!1,shipping:e.config?.fields?.shipping??!1,tipping:e.config?.fields?.tipping??!1}},pricingPolicy:e.pricingPolicy??{currency:`usd`,serviceFeeRateBasisPoints:0}}))),U=k(t({percentageOff:n(c(),m(),d(0),D(100)),source:r([`email_list`,`promo_code`])})),W=t({acceptsDiscounts:b(),listingId:f,listingSlug:f,paymentOption:I,pricingMode:r([`fixed`,`custom`]),productId:f,productName:f,quantity:E(1),subtotalCents:E(0),unitAmountCents:E(0)}),G=n(t({amountCents:E(0),appliedDiscount:U,connectedAccountId:k(f),discountableSubtotalCents:E(0),discountCents:E(0),lineItems:S(W),paymentOption:I,serviceFeeCents:E(0),subtotalCents:E(0),tipCents:E(0),totalCents:E(0)}),h(({lineItems:e,paymentOption:t})=>e.length===0||e.some(e=>e.paymentOption!==t)?!1:t===`one-time`||e.length===1&&e[0]?.pricingMode===`fixed`&&e[0].quantity===1,`Invalid checkout cadence composition.`)),K=n(g,h(e=>e.checkoutId.trim()&&e.paymentReference.trim()?e.checkoutStatus===`action_required`?e.requiresAction&&e.paymentRequired&&!!e.clientSecret?.trim():!e.requiresAction&&e.clientSecret===null:!1,`Invalid payment result state.`)),q=t({catalog:H,quote:G}),J=l(G),oe=l(q),Y=l(K),se=l(H);function ce(e){let{product:t}=e;return{acceptsDiscounts:e.acceptsDiscounts??!1,amountCents:t.amountCents,description:t.description??null,id:t.id,inventoryQuantity:t.inventoryQuantity,listingId:e.id,maximumQuantity:t.maxQuantity,minimumAmountCents:t.minimumAmountCents,minimumQuantity:t.minQuantity,name:t.name,paymentOption:t.paymentOption,pricingMode:t.pricingMode,slug:e.slug}}function X(e){let t=e.config?.fields??{};return{community:e.community?{accentColor:e.community.color,imageUrl:e.community.thumbnail,name:e.community.name}:null,payment:{currency:e.payment.currency,publishableKey:e.payment.publishableKey},pricingPolicy:{currency:`usd`,serviceFeeRateBasisPoints:e.pricingPolicy?.serviceFeeRateBasisPoints??0},products:(e.products??[]).map(ce),widget:{customFields:e.config?.customFields??[],description:e.description??null,fields:{memberId:t.memberId??!1,merchSize:t.merchSize??!1,phone:t.phone??!1,promoCode:t.promoCode??!1,serviceFee:t.serviceFee??!1,shipping:t.shipping??!1,tipping:t.tipping??!1},id:e.id??``,name:e.name??`Lockerverse widget`,showCommunityBranding:e.showCommunityBranding??!0,title:e.title??null}}}function Z(e){return $(e)}function le(e){return $(e)}function Q(e){return $(e)}function $(e){return C(structuredClone(e))}function ue(e){let{apiBaseUrl:t,communitySlug:n,communitySlugValue:r,environment:i,fetchImplementation:a,onError:o,requestTimeoutMs:s,sentryDsn:c,widgetSlug:l,widgetSlugValue:u}=ne(e),d,f=ee({communitySlug:r,environment:i,getContext:()=>({widgetSlug:u}),onError:o,resourceContextName:`lockerverse_widget`,sentryDsn:c}),{requestJson:p}=T(a,f,s),m=`${t}/v2/community/${n}/payment-widgets/${l}/checkout`;function h(e,t,n=`invalid_selection`){throw f(new j({code:n,message:e,operation:t,reportable:!1}))}function g(e,t){return e instanceof j?e:new j({...t,reportable:!0})}function _(e,t,n=!1){let r=g(e,t),i=n&&(r.status===void 0||r.status>=500);throw f(i?new j({code:r.code,message:r.message,operation:r.operation,recoveryRecommended:!0,reportable:r.reportable,...r.status===void 0?{}:{status:r.status}}):r)}function v(e,t){let n;try{n=re(e)}catch{h(`Checkout pricing input is invalid.`,t)}let r=n.email?.trim().toLowerCase(),i=n.promoCode?.trim();return{...r?{email:r}:{},...n.includeServiceFee===void 0?{}:{includeServiceFee:n.includeServiceFee},...i?{promoCode:i}:{},...n.tipCents===void 0?{}:{tipCents:n.tipCents}}}function y(e){(!(e&&typeof e==`object`)||Array.isArray(e))&&h(`Checkout selection is invalid.`,`bootstrap_checkout`);let{items:t,...n}=e;try{return{pricing:v(n,`bootstrap_checkout`),selection:ie(t)}}catch(e){if(e instanceof j)throw e;h(`Checkout selection is invalid.`,`bootstrap_checkout`)}}function b(e,t){return(e.pricingMode!==`custom`||e.minimumAmountCents!==null&&t<e.minimumAmountCents)&&h(`Selected Product amount is invalid.`,`bootstrap_checkout`),{amountCents:t,productId:e.id}}function x(e,t){return e.paymentOption===`one-time`?((e.pricingMode!==`fixed`||!(`quantity`in t)||e.minimumQuantity!==null&&t.quantity<e.minimumQuantity||e.maximumQuantity!==null&&t.quantity>e.maximumQuantity||e.inventoryQuantity!==null&&t.quantity>e.inventoryQuantity)&&h(`Selected Product quantity is invalid.`,`bootstrap_checkout`),{productId:e.id,quantity:t.quantity}):((e.pricingMode!==`fixed`||`quantity`in t)&&h(`Selected recurring Product is invalid.`,`bootstrap_checkout`),{productId:e.id})}function S(e,t){return t.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);return n||h(`Selected Product is unavailable.`,`bootstrap_checkout`),`amountCents`in t?b(n,t.amountCents):x(n,t)})}function w(e,t,n,r){if(!d)throw new j({...r,message:`Load the Lockerverse widget before calculating a checkout.`,reportable:!1});let{connectedAccountId:i,...a}=e;return le(C({...a,authoritative:!0,items:t,payment:{connectedAccountId:i,currency:`usd`,publishableKey:d},paymentOption:e.paymentOption,paymentReference:globalThis.crypto.randomUUID(),pricing:n}))}function E(e){(!(e&&typeof e==`object`)||Array.isArray(e))&&h(`Checkout selection is invalid.`,`calculate_total`);let{items:t,...n}=e;try{return{items:F(t),pricing:v(n,`calculate_total`)}}catch(e){if(e instanceof j)throw e;h(`Checkout selection is invalid.`,`calculate_total`)}}function D(e){try{if(!(e&&typeof e==`object`)||Array.isArray(e))throw TypeError(`Invalid quote.`);let t=e;if(t.authoritative!==!0||typeof t.paymentReference!=`string`||t.paymentReference.length===0||t.payment.currency!==`usd`||t.payment.publishableKey!==d)throw TypeError(`Invalid quote.`);let n=J({...t,connectedAccountId:t.payment.connectedAccountId}),{connectedAccountId:r,...i}=n;return C({...i,authoritative:!0,payment:{connectedAccountId:r,currency:`usd`,publishableKey:d},paymentOption:n.paymentOption,paymentReference:t.paymentReference})}catch{h(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}function O(e){try{if(!(e&&typeof e==`object`)||Array.isArray(e))throw TypeError(`Invalid payment input.`);let{checkout:t,submission:n}=e;if(!(t&&typeof t==`object`)||Array.isArray(t))throw TypeError(`Invalid prepared checkout.`);let r=t,i=F(r.items),a=v(r.pricing,`submit_payment`),o=D(r),s=M(n);o.totalCents>0&&!s.confirmationToken&&h(`Stripe confirmation is required for a paid checkout.`,`submit_payment`,`payment_submit_failed`);let c=s.email.trim().toLowerCase();return(!c||c!==a.email)&&h(`Payment email must match the current checkout quote.`,`submit_payment`),{items:i,pricing:a,quote:o,submission:{...s,email:c}}}catch(e){if(e instanceof j)throw e;h(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}return{async bootstrapCheckout(e){let{pricing:t,selection:n}=y(e),r={code:`checkout_bootstrap_failed`,message:`Lockerverse returned an invalid checkout bootstrap.`,operation:`bootstrap_checkout`};try{let e=await p(`${m}/bootstrap`,{body:JSON.stringify({...t,items:n}),headers:{"Content-Type":`application/json`},method:`POST`},oe,{...r,message:`Unable to bootstrap the Lockerverse checkout because the request failed.`,report:!1},{...r,report:!1});if(!e.ok)throw new j({...r,message:`Unable to bootstrap the Lockerverse checkout (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});let i=C(X(e.value.catalog));d=i.payment.publishableKey;let a=S(i,n),o={...t,includeServiceFee:t.includeServiceFee??i.widget.fields.serviceFee};return C({catalog:Z(i),checkout:w(e.value.quote,a,o,r)})}catch(e){_(e,r)}},async calculateTotal(e){let{items:t,pricing:n}=E(e),r={code:`total_calculation_failed`,message:`Lockerverse returned an invalid checkout total.`,operation:`calculate_total`};try{let e=await p(`${m}/quote`,{body:JSON.stringify({...n,items:t}),headers:{"Content-Type":`application/json`},method:`POST`},J,{...r,message:`Unable to calculate the Lockerverse checkout total because the request failed.`,report:!1},{...r,report:!1});if(!e.ok)throw new j({...r,message:`Unable to calculate the Lockerverse checkout total (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});return w(e.value,t,n,r)}catch(e){_(e,r)}},async getPaymentStatus(e){(typeof e!=`string`||!e.trim())&&h(`Provide a payment reference to recover its status.`,`get_payment_status`);let t=e.trim(),n={code:`payment_status_failed`,message:`Lockerverse returned an invalid payment status.`,operation:`get_payment_status`};try{let e=await p(`${m}/${encodeURIComponent(t)}/status`,void 0,Y,{...n,message:`Unable to recover the Lockerverse payment status because the request failed.`,report:!1},{...n,report:!1});if(!e.ok)throw new j({...n,message:`Unable to recover the Lockerverse payment status (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});if(e.value.paymentReference!==t)throw new j({...n,reportable:!0});return Q(e.value)}catch(e){_(e,n)}},async load(){let e={code:`widget_load_failed`,message:`Lockerverse returned an invalid widget catalog.`,operation:`load_widget`};try{let r=await p(`${t}/v2/community/${n}/payment-widgets/${l}`,void 0,se,{...e,message:`Unable to load Lockerverse widget because the request failed.`,report:!1},{...e,report:!1});if(!r.ok)throw new j({...e,message:`Unable to load Lockerverse widget (${r.response.status}).`,reportable:r.response.status>=500,status:r.response.status});let i=C(X(r.value));return d=i.payment.publishableKey,Z(i)}catch(t){_(t,e)}},async submitPayment(e){let{items:t,pricing:n,quote:r,submission:i}=O(e),a={code:`payment_submit_failed`,message:`Lockerverse returned an invalid payment confirmation.`,operation:`submit_payment`};try{let e=await p(`${m}/confirm`,{body:JSON.stringify({...i.confirmationToken?{confirmationToken:i.confirmationToken}:{},customFieldAnswers:i.customFieldAnswers,email:i.email,expectedAmountCents:r.amountCents,expectedAppliedDiscount:r.appliedDiscount,expectedConnectedAccountId:r.payment.connectedAccountId,expectedDiscountableSubtotalCents:r.discountableSubtotalCents,expectedDiscountCents:r.discountCents,expectedServiceFeeCents:r.serviceFeeCents,expectedSubtotalCents:r.subtotalCents,expectedTipCents:r.tipCents,expectedTotalCents:r.totalCents,...n,items:t,memberId:i.memberId,merchSize:i.merchSize,metadata:i.metadata,paymentReference:r.paymentReference,phone:i.phone,quoteContractVersion:1,shipping:i.shipping}),headers:{"Content-Type":`application/json`},method:`POST`},Y,{...a,message:`Unable to submit the Lockerverse payment because the request failed.`,report:!1},{...a,report:!1});if(!e.ok)throw new j({...a,message:`Unable to submit the Lockerverse payment (${e.response.status}).`,reportable:e.response.status>=500,status:e.response.status});if(e.value.paymentReference!==r.paymentReference)throw new j({...a,reportable:!0});return Q(e.value)}catch(e){_(e,a,!0)}}}}export{te as LOCKERVERSE_SDK_VERSION,j as LockerverseSdkError,ue as createLockerverseCheckoutClient};
|
|
2
2
|
//# sourceMappingURL=checkout.js.map
|
package/dist/checkout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.js","names":[],"sources":["../src/checkout-environment.ts","../src/checkout-input-schemas.ts","../src/checkout-schemas.ts","../src/snapshots.ts","../src/checkout-client.ts"],"sourcesContent":["import { resolveResourceEnvironment } from \"./environment.ts\";\nimport type { CreateLockerverseWidgetOptions } from \"./types.ts\";\n\nexport function resolveWidgetEnvironment(\n options: CreateLockerverseWidgetOptions\n) {\n const runtime = resolveResourceEnvironment(\n options.apiBaseUrl !== undefined && options.environment === undefined\n ? { ...options, environment: \"production\" }\n : options,\n \"widgetSlug\"\n );\n return {\n ...runtime,\n widgetSlug: runtime.resourceSlug,\n widgetSlugValue: runtime.resourceSlugValue,\n };\n}\n","import {\n array,\n boolean,\n minLength,\n optional,\n parser,\n picklist,\n pipe,\n record,\n strictObject,\n string,\n union,\n} from \"valibot\";\n\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nexport const parseCheckoutPricingInput = parser(\n optional(\n strictObject({\n email: optional(string()),\n includeServiceFee: optional(boolean()),\n promoCode: optional(string()),\n tipCents: optional(safeIntegerSchema(0)),\n }),\n {}\n )\n);\n\nexport const parsePaymentSubmission = parser(\n strictObject({\n confirmationToken: optional(nonEmptyStringSchema),\n customFieldAnswers: optional(array(customFieldAnswerSchema)),\n email: string(),\n memberId: optional(string()),\n merchSize: optional(picklist([\"XS\", \"S\", \"M\", \"L\", \"XL\", \"XXL\", \"XXXL\"])),\n metadata: optional(record(string(), string())),\n phone: optional(string()),\n shipping: optional(\n strictObject({\n address: strictObject({\n city: string(),\n country: string(),\n line1: string(),\n line2: optional(string()),\n postal_code: string(),\n state: string(),\n }),\n name: string(),\n })\n ),\n })\n);\n\nconst checkoutItemSchema = union([\n strictObject({\n amountCents: safeIntegerSchema(1),\n productId: nonEmptyStringSchema,\n }),\n strictObject({\n productId: nonEmptyStringSchema,\n quantity: safeIntegerSchema(1),\n }),\n]);\n\nconst checkoutSelectionItemSchema = union([\n strictObject({\n amountCents: safeIntegerSchema(1),\n productSlug: nonEmptyStringSchema,\n }),\n strictObject({\n productSlug: nonEmptyStringSchema,\n quantity: safeIntegerSchema(1),\n }),\n]);\n\nexport const parseCheckoutItems = parser(\n pipe(array(checkoutItemSchema), minLength(1))\n);\n\nexport const parseCheckoutSelectionItems = parser(\n pipe(array(checkoutSelectionItemSchema), minLength(1))\n);\n","import {\n array,\n boolean,\n check,\n finite,\n type InferOutput,\n literal,\n maxValue,\n minValue,\n nullable,\n number,\n object,\n optional,\n parser,\n picklist,\n pipe,\n regex,\n string,\n transform,\n variant,\n} from \"valibot\";\n\nimport { vPaymentWidgetPaymentResultResponseDto } from \"./generated/public-api/valibot.gen.ts\";\nimport {\n customFieldsSchema,\n nonEmptyStringSchema,\n optionalNullableStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst paymentOptionSchema = picklist([\"one-time\", \"monthly\", \"annually\"]);\nconst nullableNonNegativeIntegerSchema = nullable(safeIntegerSchema(0));\nconst publishableKeySchema = pipe(\n string(),\n regex(/^pk_(?:test|live)_\\S+$/, \"Invalid publishable key.\")\n);\n\nconst productBaseEntries = {\n description: optionalNullableStringSchema,\n id: nonEmptyStringSchema,\n inventoryQuantity: nullableNonNegativeIntegerSchema,\n maxQuantity: nullableNonNegativeIntegerSchema,\n minimumAmountCents: nullableNonNegativeIntegerSchema,\n minQuantity: nullableNonNegativeIntegerSchema,\n name: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n};\n\nconst publicProductSchema = pipe(\n variant(\"pricingMode\", [\n object({\n ...productBaseEntries,\n amountCents: safeIntegerSchema(0),\n pricingMode: literal(\"fixed\"),\n }),\n object({\n ...productBaseEntries,\n amountCents: nullableNonNegativeIntegerSchema,\n pricingMode: literal(\"custom\"),\n }),\n ]),\n check(\n ({ maxQuantity, minQuantity }) =>\n maxQuantity === null || minQuantity === null || minQuantity <= maxQuantity\n )\n);\n\nconst productListingSchema = object({\n acceptsDiscounts: optional(boolean(), false),\n id: nonEmptyStringSchema,\n product: publicProductSchema,\n productId: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n});\n\nconst widgetFieldsSchema = optional(\n object({\n memberId: optional(boolean(), false),\n merchSize: optional(boolean(), false),\n phone: optional(boolean(), false),\n promoCode: optional(boolean(), false),\n serviceFee: optional(boolean(), false),\n shipping: optional(boolean(), false),\n tipping: optional(boolean(), false),\n }),\n {}\n);\n\nexport const publicWidgetSchema = pipe(\n object({\n community: optional(\n object({\n color: string(),\n name: nonEmptyStringSchema,\n thumbnail: string(),\n })\n ),\n config: optional(\n object({\n customFields: customFieldsSchema,\n fields: widgetFieldsSchema,\n })\n ),\n description: optionalNullableStringSchema,\n id: optional(string(), \"\"),\n name: optional(string(), \"Lockerverse widget\"),\n payment: object({\n currency: literal(\"usd\"),\n publishableKey: publishableKeySchema,\n }),\n pricingPolicy: optional(\n object({\n currency: optional(literal(\"usd\"), \"usd\"),\n serviceFeeRateBasisPoints: optional(safeIntegerSchema(0), 0),\n })\n ),\n products: optional(array(productListingSchema), []),\n showCommunityBranding: optional(boolean(), true),\n title: optionalNullableStringSchema,\n }),\n transform((widget) => ({\n ...widget,\n config: {\n customFields: widget.config?.customFields ?? [],\n fields: {\n memberId: widget.config?.fields?.memberId ?? false,\n merchSize: widget.config?.fields?.merchSize ?? false,\n phone: widget.config?.fields?.phone ?? false,\n promoCode: widget.config?.fields?.promoCode ?? false,\n serviceFee: widget.config?.fields?.serviceFee ?? false,\n shipping: widget.config?.fields?.shipping ?? false,\n tipping: widget.config?.fields?.tipping ?? false,\n },\n },\n pricingPolicy: widget.pricingPolicy ?? {\n currency: \"usd\" as const,\n serviceFeeRateBasisPoints: 0,\n },\n }))\n);\n\nconst appliedDiscountSchema = nullable(\n object({\n percentageOff: pipe(number(), finite(), minValue(0), maxValue(100)),\n source: picklist([\"email_list\", \"promo_code\"]),\n })\n);\n\nconst checkoutLineItemSchema = object({\n acceptsDiscounts: boolean(),\n listingId: nonEmptyStringSchema,\n listingSlug: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n pricingMode: picklist([\"fixed\", \"custom\"]),\n productId: nonEmptyStringSchema,\n productName: nonEmptyStringSchema,\n quantity: safeIntegerSchema(1),\n subtotalCents: safeIntegerSchema(0),\n unitAmountCents: safeIntegerSchema(0),\n});\n\nexport const checkoutQuoteSchema = object({\n amountCents: safeIntegerSchema(0),\n appliedDiscount: appliedDiscountSchema,\n connectedAccountId: nullable(nonEmptyStringSchema),\n discountableSubtotalCents: safeIntegerSchema(0),\n discountCents: safeIntegerSchema(0),\n lineItems: array(checkoutLineItemSchema),\n paymentOption: paymentOptionSchema,\n serviceFeeCents: safeIntegerSchema(0),\n subtotalCents: safeIntegerSchema(0),\n tipCents: safeIntegerSchema(0),\n totalCents: safeIntegerSchema(0),\n});\n\nexport const paymentResultSchema = pipe(\n vPaymentWidgetPaymentResultResponseDto,\n check((payment) => {\n if (!(payment.checkoutId.trim() && payment.paymentReference.trim())) {\n return false;\n }\n if (payment.checkoutStatus === \"action_required\") {\n return (\n payment.requiresAction &&\n payment.paymentRequired &&\n Boolean(payment.clientSecret?.trim())\n );\n }\n return !payment.requiresAction && payment.clientSecret === null;\n }, \"Invalid payment result state.\")\n);\n\nexport const checkoutBootstrapSchema = object({\n catalog: publicWidgetSchema,\n quote: checkoutQuoteSchema,\n});\n\nexport type PublicCheckoutQuote = InferOutput<typeof checkoutQuoteSchema>;\nexport type PublicProductListing = InferOutput<typeof productListingSchema>;\nexport type PublicWidget = InferOutput<typeof publicWidgetSchema>;\n\nexport const parseCheckoutQuote = parser(checkoutQuoteSchema);\nexport const parseCheckoutBootstrap = parser(checkoutBootstrapSchema);\nexport const parsePaymentResult = parser(paymentResultSchema);\nexport const parsePublicWidget = parser(publicWidgetSchema);\n","import type { PublicProductListing, PublicWidget } from \"./checkout-schemas.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport type {\n LockerverseCatalog,\n LockerversePaymentResult,\n LockerversePreparedCheckout,\n LockerverseProduct,\n} from \"./types.ts\";\n\nfunction mapProduct(listing: PublicProductListing): LockerverseProduct {\n const { product } = listing;\n\n return {\n acceptsDiscounts: listing.acceptsDiscounts ?? false,\n amountCents: product.amountCents,\n description: product.description ?? null,\n id: product.id,\n inventoryQuantity: product.inventoryQuantity,\n listingId: listing.id,\n maximumQuantity: product.maxQuantity,\n minimumAmountCents: product.minimumAmountCents,\n minimumQuantity: product.minQuantity,\n name: product.name,\n paymentOption: product.paymentOption,\n pricingMode: product.pricingMode,\n slug: listing.slug,\n };\n}\n\nexport function createCatalog(widget: PublicWidget): LockerverseCatalog {\n const fields = widget.config?.fields ?? {};\n\n return {\n community: widget.community\n ? {\n accentColor: widget.community.color,\n imageUrl: widget.community.thumbnail,\n name: widget.community.name,\n }\n : null,\n payment: {\n currency: widget.payment.currency,\n publishableKey: widget.payment.publishableKey,\n },\n pricingPolicy: {\n currency: \"usd\",\n serviceFeeRateBasisPoints:\n widget.pricingPolicy?.serviceFeeRateBasisPoints ?? 0,\n },\n products: (widget.products ?? []).map(mapProduct),\n widget: {\n customFields: widget.config?.customFields ?? [],\n description: widget.description ?? null,\n fields: {\n memberId: fields.memberId ?? false,\n merchSize: fields.merchSize ?? false,\n phone: fields.phone ?? false,\n promoCode: fields.promoCode ?? false,\n serviceFee: fields.serviceFee ?? false,\n shipping: fields.shipping ?? false,\n tipping: fields.tipping ?? false,\n },\n id: widget.id ?? \"\",\n name: widget.name ?? \"Lockerverse widget\",\n showCommunityBranding: widget.showCommunityBranding ?? true,\n title: widget.title ?? null,\n },\n };\n}\n\nexport function cloneCatalog(catalog: LockerverseCatalog): LockerverseCatalog {\n return cloneSnapshot(catalog);\n}\n\nexport function clonePreparedCheckout(\n checkout: LockerversePreparedCheckout\n): LockerversePreparedCheckout {\n return cloneSnapshot(checkout);\n}\n\nexport function clonePaymentResult(\n paymentResult: LockerversePaymentResult\n): LockerversePaymentResult {\n return cloneSnapshot(paymentResult);\n}\n\nfunction cloneSnapshot<T>(value: T): T {\n return deepFreeze(structuredClone(value));\n}\n","import { resolveWidgetEnvironment } from \"./checkout-environment.ts\";\nimport {\n parseCheckoutItems,\n parseCheckoutPricingInput,\n parseCheckoutSelectionItems,\n parsePaymentSubmission,\n} from \"./checkout-input-schemas.ts\";\nimport {\n parseCheckoutBootstrap,\n parseCheckoutQuote,\n parsePaymentResult,\n parsePublicWidget,\n} from \"./checkout-schemas.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport {\n cloneCatalog,\n clonePaymentResult,\n clonePreparedCheckout,\n createCatalog,\n} from \"./snapshots.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport {\n type CreateLockerverseWidgetOptions,\n type LockerverseCatalog,\n type LockerverseCheckoutClient,\n type LockerverseCheckoutItem,\n type LockerverseCheckoutPricingInput,\n type LockerverseCheckoutQuote,\n type LockerverseCheckoutSelectionItem,\n type LockerversePreparedCheckout,\n LockerverseSdkError,\n type LockerverseSdkOperation,\n} from \"./types.ts\";\n\ntype OperationErrorContext = {\n code:\n | \"checkout_bootstrap_failed\"\n | \"payment_status_failed\"\n | \"payment_submit_failed\"\n | \"total_calculation_failed\"\n | \"widget_load_failed\";\n message: string;\n operation:\n | \"bootstrap_checkout\"\n | \"calculate_total\"\n | \"get_payment_status\"\n | \"load_widget\"\n | \"submit_payment\";\n};\n\nexport function createLockerverseCheckoutClient(\n options: CreateLockerverseWidgetOptions\n): LockerverseCheckoutClient {\n const {\n apiBaseUrl,\n communitySlug,\n communitySlugValue,\n environment,\n fetchImplementation,\n onError,\n requestTimeoutMs,\n sentryDsn,\n widgetSlug,\n widgetSlugValue,\n } = resolveWidgetEnvironment(options);\n let catalogPublishableKey: string | undefined;\n const reportError = createSdkErrorReporter({\n communitySlug: communitySlugValue,\n environment,\n getContext: () => ({ widgetSlug: widgetSlugValue }),\n onError,\n resourceContextName: \"lockerverse_widget\",\n sentryDsn,\n });\n const { requestJson } = createTransport(\n fetchImplementation,\n reportError,\n requestTimeoutMs\n );\n const checkoutBaseUrl = `${apiBaseUrl}/v2/community/${communitySlug}/payment-widgets/${widgetSlug}/checkout`;\n\n function invalidInput(\n message: string,\n operation: LockerverseSdkOperation,\n code: \"invalid_selection\" | \"payment_submit_failed\" = \"invalid_selection\"\n ): never {\n throw reportError(\n new LockerverseSdkError({\n code,\n message,\n operation,\n reportable: false,\n })\n );\n }\n\n function normalizeOperationError(\n error: unknown,\n context: OperationErrorContext\n ) {\n return error instanceof LockerverseSdkError\n ? error\n : new LockerverseSdkError({ ...context, reportable: true });\n }\n\n function failOperation(\n error: unknown,\n context: OperationErrorContext,\n recoveryMayBeRequired = false\n ): never {\n const normalized = normalizeOperationError(error, context);\n const recoveryRecommended =\n recoveryMayBeRequired &&\n (normalized.status === undefined || normalized.status >= 500);\n throw reportError(\n recoveryRecommended\n ? new LockerverseSdkError({\n code: normalized.code,\n message: normalized.message,\n operation: normalized.operation,\n recoveryRecommended: true,\n reportable: normalized.reportable,\n ...(normalized.status === undefined\n ? {}\n : { status: normalized.status }),\n })\n : normalized\n );\n }\n\n function normalizePricingInput(\n input: unknown,\n operation: \"bootstrap_checkout\" | \"calculate_total\" | \"submit_payment\"\n ) {\n let parsed: ReturnType<typeof parseCheckoutPricingInput>;\n try {\n parsed = parseCheckoutPricingInput(input);\n } catch {\n invalidInput(\"Checkout pricing input is invalid.\", operation);\n }\n const email = parsed.email?.trim().toLowerCase();\n const promoCode = parsed.promoCode?.trim();\n return {\n ...(email ? { email } : {}),\n ...(parsed.includeServiceFee === undefined\n ? {}\n : { includeServiceFee: parsed.includeServiceFee }),\n ...(promoCode ? { promoCode } : {}),\n ...(parsed.tipCents === undefined ? {} : { tipCents: parsed.tipCents }),\n };\n }\n\n function normalizeBootstrapCheckoutInput(input: unknown) {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n invalidInput(\"Checkout selection is invalid.\", \"bootstrap_checkout\");\n }\n const { items, ...pricingInput } = input as Record<string, unknown>;\n try {\n return {\n pricing: normalizePricingInput(pricingInput, \"bootstrap_checkout\"),\n selection: parseCheckoutSelectionItems(items),\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\"Checkout selection is invalid.\", \"bootstrap_checkout\");\n }\n }\n\n function createCheckoutItems(\n catalog: LockerverseCatalog,\n selection: LockerverseCheckoutSelectionItem[]\n ): LockerverseCheckoutItem[] {\n return selection.map((item) => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product) {\n invalidInput(\"Selected Product is unavailable.\", \"bootstrap_checkout\");\n }\n if (\"amountCents\" in item) {\n if (\n product.pricingMode !== \"custom\" ||\n (product.minimumAmountCents !== null &&\n item.amountCents < product.minimumAmountCents)\n ) {\n invalidInput(\n \"Selected Product amount is invalid.\",\n \"bootstrap_checkout\"\n );\n }\n return { amountCents: item.amountCents, productId: product.id };\n }\n if (\n product.pricingMode !== \"fixed\" ||\n (product.minimumQuantity !== null &&\n item.quantity < product.minimumQuantity) ||\n (product.maximumQuantity !== null &&\n item.quantity > product.maximumQuantity) ||\n (product.inventoryQuantity !== null &&\n item.quantity > product.inventoryQuantity)\n ) {\n invalidInput(\n \"Selected Product quantity is invalid.\",\n \"bootstrap_checkout\"\n );\n }\n return { productId: product.id, quantity: item.quantity };\n });\n }\n\n function createPreparedCheckout(\n quote: ReturnType<typeof parseCheckoutQuote>,\n items: LockerverseCheckoutItem[],\n pricing: LockerverseCheckoutPricingInput,\n context: OperationErrorContext\n ): LockerversePreparedCheckout {\n if (!catalogPublishableKey) {\n throw new LockerverseSdkError({\n ...context,\n message: \"Load the Lockerverse widget before calculating a checkout.\",\n reportable: false,\n });\n }\n if (quote.paymentOption !== \"one-time\") {\n throw new LockerverseSdkError({\n ...context,\n message: \"Lockerverse returned an unsupported checkout cadence.\",\n reportable: true,\n });\n }\n const {\n connectedAccountId,\n paymentOption: _paymentOption,\n ...checkoutQuote\n } = quote;\n return clonePreparedCheckout(\n deepFreeze({\n ...checkoutQuote,\n authoritative: true as const,\n items,\n payment: {\n connectedAccountId,\n currency: \"usd\" as const,\n publishableKey: catalogPublishableKey,\n },\n paymentOption: \"one-time\" as const,\n paymentReference: globalThis.crypto.randomUUID(),\n pricing,\n })\n );\n }\n\n function normalizeCalculateTotalInput(input: unknown) {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n invalidInput(\"Checkout selection is invalid.\", \"calculate_total\");\n }\n const { items, ...pricingInput } = input as Record<string, unknown>;\n try {\n return {\n items: parseCheckoutItems(items),\n pricing: normalizePricingInput(pricingInput, \"calculate_total\"),\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\"Checkout selection is invalid.\", \"calculate_total\");\n }\n }\n\n function normalizeQuote(input: unknown) {\n try {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n throw new TypeError(\"Invalid quote.\");\n }\n const quoteInput = input as LockerverseCheckoutQuote;\n if (\n quoteInput.authoritative !== true ||\n quoteInput.paymentOption !== \"one-time\" ||\n typeof quoteInput.paymentReference !== \"string\" ||\n quoteInput.paymentReference.length === 0 ||\n quoteInput.payment.currency !== \"usd\" ||\n quoteInput.payment.publishableKey !== catalogPublishableKey\n ) {\n throw new TypeError(\"Invalid quote.\");\n }\n const parsed = parseCheckoutQuote({\n ...quoteInput,\n connectedAccountId: quoteInput.payment.connectedAccountId,\n });\n if (parsed.paymentOption !== \"one-time\") {\n throw new TypeError(\"Unsupported checkout cadence.\");\n }\n const {\n connectedAccountId,\n paymentOption: _paymentOption,\n ...quote\n } = parsed;\n return deepFreeze({\n ...quote,\n authoritative: true as const,\n payment: {\n connectedAccountId,\n currency: \"usd\" as const,\n publishableKey: catalogPublishableKey,\n },\n paymentOption: \"one-time\" as const,\n paymentReference: quoteInput.paymentReference,\n });\n } catch {\n invalidInput(\n \"Lockerverse payment submission is invalid.\",\n \"submit_payment\",\n \"payment_submit_failed\"\n );\n }\n }\n\n function normalizeSubmitPaymentInput(input: unknown) {\n try {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n throw new TypeError(\"Invalid payment input.\");\n }\n const { checkout, submission: submissionInput } = input as Record<\n string,\n unknown\n >;\n if (\n !(checkout && typeof checkout === \"object\") ||\n Array.isArray(checkout)\n ) {\n throw new TypeError(\"Invalid prepared checkout.\");\n }\n const checkoutInput = checkout as Record<string, unknown>;\n const items = parseCheckoutItems(checkoutInput.items);\n const pricing = normalizePricingInput(\n checkoutInput.pricing,\n \"submit_payment\"\n );\n const quote = normalizeQuote(checkoutInput);\n const submission = parsePaymentSubmission(submissionInput);\n if (quote.totalCents > 0 && !submission.confirmationToken) {\n invalidInput(\n \"Stripe confirmation is required for a paid checkout.\",\n \"submit_payment\",\n \"payment_submit_failed\"\n );\n }\n const email = submission.email.trim().toLowerCase();\n if (!email || email !== pricing.email) {\n invalidInput(\n \"Payment email must match the current checkout quote.\",\n \"submit_payment\"\n );\n }\n return {\n items,\n pricing,\n quote,\n submission: { ...submission, email },\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\n \"Lockerverse payment submission is invalid.\",\n \"submit_payment\",\n \"payment_submit_failed\"\n );\n }\n }\n\n return {\n async bootstrapCheckout(input) {\n const { pricing, selection } = normalizeBootstrapCheckoutInput(input);\n const context = {\n code: \"checkout_bootstrap_failed\" as const,\n message: \"Lockerverse returned an invalid checkout bootstrap.\",\n operation: \"bootstrap_checkout\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/bootstrap`,\n {\n body: JSON.stringify({ ...pricing, items: selection }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parseCheckoutBootstrap,\n {\n ...context,\n message:\n \"Unable to bootstrap the Lockerverse checkout because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to bootstrap the Lockerverse checkout (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n const catalog = deepFreeze(createCatalog(response.value.catalog));\n catalogPublishableKey = catalog.payment.publishableKey;\n const checkoutItems = createCheckoutItems(catalog, selection);\n const checkoutPricing = {\n ...pricing,\n includeServiceFee:\n pricing.includeServiceFee ?? catalog.widget.fields.serviceFee,\n };\n return deepFreeze({\n catalog: cloneCatalog(catalog),\n checkout: createPreparedCheckout(\n response.value.quote,\n checkoutItems,\n checkoutPricing,\n context\n ),\n });\n } catch (error) {\n failOperation(error, context);\n }\n },\n async calculateTotal(input) {\n const { items, pricing } = normalizeCalculateTotalInput(input);\n const context = {\n code: \"total_calculation_failed\" as const,\n message: \"Lockerverse returned an invalid checkout total.\",\n operation: \"calculate_total\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/quote`,\n {\n body: JSON.stringify({ ...pricing, items }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parseCheckoutQuote,\n {\n ...context,\n message:\n \"Unable to calculate the Lockerverse checkout total because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to calculate the Lockerverse checkout total (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n return createPreparedCheckout(response.value, items, pricing, context);\n } catch (error) {\n failOperation(error, context);\n }\n },\n async getPaymentStatus(paymentReference) {\n if (typeof paymentReference !== \"string\" || !paymentReference.trim()) {\n invalidInput(\n \"Provide a payment reference to recover its status.\",\n \"get_payment_status\"\n );\n }\n const normalizedReference = paymentReference.trim();\n const context = {\n code: \"payment_status_failed\" as const,\n message: \"Lockerverse returned an invalid payment status.\",\n operation: \"get_payment_status\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/${encodeURIComponent(normalizedReference)}/status`,\n undefined,\n parsePaymentResult,\n {\n ...context,\n message:\n \"Unable to recover the Lockerverse payment status because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to recover the Lockerverse payment status (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n if (response.value.paymentReference !== normalizedReference) {\n throw new LockerverseSdkError({ ...context, reportable: true });\n }\n return clonePaymentResult(response.value);\n } catch (error) {\n failOperation(error, context);\n }\n },\n async load() {\n const context = {\n code: \"widget_load_failed\" as const,\n message: \"Lockerverse returned an invalid widget catalog.\",\n operation: \"load_widget\" as const,\n };\n try {\n const response = await requestJson(\n `${apiBaseUrl}/v2/community/${communitySlug}/payment-widgets/${widgetSlug}`,\n undefined,\n parsePublicWidget,\n {\n ...context,\n message:\n \"Unable to load Lockerverse widget because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to load Lockerverse widget (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n const catalog = deepFreeze(createCatalog(response.value));\n catalogPublishableKey = catalog.payment.publishableKey;\n return cloneCatalog(catalog);\n } catch (error) {\n failOperation(error, context);\n }\n },\n async submitPayment(input) {\n const { items, pricing, quote, submission } =\n normalizeSubmitPaymentInput(input);\n const context = {\n code: \"payment_submit_failed\" as const,\n message: \"Lockerverse returned an invalid payment confirmation.\",\n operation: \"submit_payment\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/confirm`,\n {\n body: JSON.stringify({\n ...(submission.confirmationToken\n ? { confirmationToken: submission.confirmationToken }\n : {}),\n customFieldAnswers: submission.customFieldAnswers,\n email: submission.email,\n expectedAmountCents: quote.amountCents,\n expectedAppliedDiscount: quote.appliedDiscount,\n expectedConnectedAccountId: quote.payment.connectedAccountId,\n expectedDiscountableSubtotalCents:\n quote.discountableSubtotalCents,\n expectedDiscountCents: quote.discountCents,\n expectedServiceFeeCents: quote.serviceFeeCents,\n expectedSubtotalCents: quote.subtotalCents,\n expectedTipCents: quote.tipCents,\n expectedTotalCents: quote.totalCents,\n ...pricing,\n items,\n memberId: submission.memberId,\n merchSize: submission.merchSize,\n metadata: submission.metadata,\n paymentReference: quote.paymentReference,\n phone: submission.phone,\n quoteContractVersion: 1,\n shipping: submission.shipping,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parsePaymentResult,\n {\n ...context,\n message:\n \"Unable to submit the Lockerverse payment because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to submit the Lockerverse payment (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n if (response.value.paymentReference !== quote.paymentReference) {\n throw new LockerverseSdkError({ ...context, reportable: true });\n }\n return clonePaymentResult(response.value);\n } catch (error) {\n failOperation(error, context, true);\n }\n },\n };\n}\n"],"mappings":"gSAGA,SAAgB,EACd,EACA,CACA,IAAM,EAAU,EACd,EAAQ,aAAe,IAAA,IAAa,EAAQ,cAAgB,IAAA,GACxD,CAAE,GAAG,EAAS,YAAa,YAAa,EACxC,EACJ,YACF,EACA,MAAO,CACL,GAAG,EACH,WAAY,EAAQ,aACpB,gBAAiB,EAAQ,iBAC3B,CACF,CCGA,MAAa,EAA4B,EACvC,EACE,EAAa,CACX,MAAO,EAAS,EAAO,CAAC,EACxB,kBAAmB,EAAS,EAAQ,CAAC,EACrC,UAAW,EAAS,EAAO,CAAC,EAC5B,SAAU,EAAS,EAAkB,CAAC,CAAC,CACzC,CAAC,EACD,CAAC,CACH,CACF,EAEa,EAAyB,EACpC,EAAa,CACX,kBAAmB,EAAS,CAAoB,EAChD,mBAAoB,EAAS,EAAM,CAAuB,CAAC,EAC3D,MAAO,EAAO,EACd,SAAU,EAAS,EAAO,CAAC,EAC3B,UAAW,EAAS,EAAS,CAAC,KAAM,IAAK,IAAK,IAAK,KAAM,MAAO,MAAM,CAAC,CAAC,EACxE,SAAU,EAAS,EAAO,EAAO,EAAG,EAAO,CAAC,CAAC,EAC7C,MAAO,EAAS,EAAO,CAAC,EACxB,SAAU,EACR,EAAa,CACX,QAAS,EAAa,CACpB,KAAM,EAAO,EACb,QAAS,EAAO,EAChB,MAAO,EAAO,EACd,MAAO,EAAS,EAAO,CAAC,EACxB,YAAa,EAAO,EACpB,MAAO,EAAO,CAChB,CAAC,EACD,KAAM,EAAO,CACf,CAAC,CAC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IAAM,EAAW,MAAM,EACrB,GAAG,EAAgB,UACnB,CACE,KAAM,KAAK,UAAU,CACnB,GAAI,EAAW,kBACX,CAAE,kBAAmB,EAAW,iBAAkB,EAClD,CAAC,EACL,mBAAoB,EAAW,mBAC/B,MAAO,EAAW,MAClB,oBAAqB,EAAM,YAC3B,wBAAyB,EAAM,gBAC/B,2BAA4B,EAAM,QAAQ,mBAC1C,kCACE,EAAM,0BACR,sBAAuB,EAAM,cAC7B,wBAAyB,EAAM,gBAC/B,sBAAuB,EAAM,cAC7B,iBAAkB,EAAM,SACxB,mBAAoB,EAAM,WAC1B,GAAG,EACH,QACA,SAAU,EAAW,SACrB,UAAW,EAAW,UACtB,SAAU,EAAW,SACrB,iBAAkB,EAAM,iBACxB,MAAO,EAAW,MAClB,qBAAsB,EACtB,SAAU,EAAW,QACvB,CAAC,EACD,QAAS,CAAE,eAAgB,kBAAmB,EAC9C,OAAQ,MACV,EACA,EACA,CACE,GAAG,EACH,QACE,uEACF,OAAQ,EACV,EACA,CAAE,GAAG,EAAS,OAAQ,EAAM,CAC9B,EACA,GAAI,CAAC,EAAS,GACZ,MAAM,IAAI,EAAoB,CAC5B,GAAG,EACH,QAAS,6CAA6C,EAAS,SAAS,OAAO,IAC/E,WAAY,EAAS,SAAS,QAAU,IACxC,OAAQ,EAAS,SAAS,MAC5B,CAAC,EAEH,GAAI,EAAS,MAAM,mBAAqB,EAAM,iBAC5C,MAAM,IAAI,EAAoB,CAAE,GAAG,EAAS,WAAY,EAAK,CAAC,EAEhE,OAAO,EAAmB,EAAS,KAAK,CAC1C,OAAS,EAAO,CACd,EAAc,EAAO,EAAS,EAAI,CACpC,CACF,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"checkout.js","names":[],"sources":["../src/checkout-environment.ts","../src/checkout-input-schemas.ts","../src/checkout-schemas.ts","../src/snapshots.ts","../src/checkout-client.ts"],"sourcesContent":["import { resolveResourceEnvironment } from \"./environment.ts\";\nimport type { CreateLockerverseWidgetOptions } from \"./types.ts\";\n\nexport function resolveWidgetEnvironment(\n options: CreateLockerverseWidgetOptions\n) {\n const runtime = resolveResourceEnvironment(\n options.apiBaseUrl !== undefined && options.environment === undefined\n ? { ...options, environment: \"production\" }\n : options,\n \"widgetSlug\"\n );\n return {\n ...runtime,\n widgetSlug: runtime.resourceSlug,\n widgetSlugValue: runtime.resourceSlugValue,\n };\n}\n","import {\n array,\n boolean,\n minLength,\n optional,\n parser,\n picklist,\n pipe,\n record,\n strictObject,\n string,\n union,\n} from \"valibot\";\n\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nexport const parseCheckoutPricingInput = parser(\n optional(\n strictObject({\n email: optional(string()),\n includeServiceFee: optional(boolean()),\n promoCode: optional(string()),\n tipCents: optional(safeIntegerSchema(0)),\n }),\n {}\n )\n);\n\nexport const parsePaymentSubmission = parser(\n strictObject({\n confirmationToken: optional(nonEmptyStringSchema),\n customFieldAnswers: optional(array(customFieldAnswerSchema)),\n email: string(),\n memberId: optional(string()),\n merchSize: optional(picklist([\"XS\", \"S\", \"M\", \"L\", \"XL\", \"XXL\", \"XXXL\"])),\n metadata: optional(record(string(), string())),\n phone: optional(string()),\n shipping: optional(\n strictObject({\n address: strictObject({\n city: string(),\n country: string(),\n line1: string(),\n line2: optional(string()),\n postal_code: string(),\n state: string(),\n }),\n name: string(),\n })\n ),\n })\n);\n\nconst checkoutItemSchema = union([\n strictObject({\n amountCents: safeIntegerSchema(1),\n productId: nonEmptyStringSchema,\n }),\n strictObject({\n productId: nonEmptyStringSchema,\n quantity: safeIntegerSchema(1),\n }),\n strictObject({\n productId: nonEmptyStringSchema,\n }),\n]);\n\nconst checkoutSelectionItemSchema = union([\n strictObject({\n amountCents: safeIntegerSchema(1),\n productSlug: nonEmptyStringSchema,\n }),\n strictObject({\n productSlug: nonEmptyStringSchema,\n quantity: safeIntegerSchema(1),\n }),\n strictObject({\n productSlug: nonEmptyStringSchema,\n }),\n]);\n\nexport const parseCheckoutItems = parser(\n pipe(array(checkoutItemSchema), minLength(1))\n);\n\nexport const parseCheckoutSelectionItems = parser(\n pipe(array(checkoutSelectionItemSchema), minLength(1))\n);\n","import {\n array,\n boolean,\n check,\n finite,\n type InferOutput,\n literal,\n maxValue,\n minValue,\n nullable,\n number,\n object,\n optional,\n parser,\n picklist,\n pipe,\n regex,\n string,\n transform,\n variant,\n} from \"valibot\";\n\nimport { vPaymentWidgetPaymentResultResponseDto } from \"./generated/public-api/valibot.gen.ts\";\nimport {\n customFieldsSchema,\n nonEmptyStringSchema,\n optionalNullableStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst paymentOptionSchema = picklist([\"one-time\", \"monthly\", \"annually\"]);\nconst nullableNonNegativeIntegerSchema = nullable(safeIntegerSchema(0));\nconst publishableKeySchema = pipe(\n string(),\n regex(/^pk_(?:test|live)_\\S+$/, \"Invalid publishable key.\")\n);\n\nconst productBaseEntries = {\n description: optionalNullableStringSchema,\n id: nonEmptyStringSchema,\n inventoryQuantity: nullableNonNegativeIntegerSchema,\n maxQuantity: nullableNonNegativeIntegerSchema,\n minimumAmountCents: nullableNonNegativeIntegerSchema,\n minQuantity: nullableNonNegativeIntegerSchema,\n name: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n};\n\nconst publicProductSchema = pipe(\n variant(\"pricingMode\", [\n object({\n ...productBaseEntries,\n amountCents: safeIntegerSchema(0),\n pricingMode: literal(\"fixed\"),\n }),\n object({\n ...productBaseEntries,\n amountCents: nullableNonNegativeIntegerSchema,\n pricingMode: literal(\"custom\"),\n }),\n ]),\n check(\n ({ maxQuantity, minQuantity }) =>\n maxQuantity === null || minQuantity === null || minQuantity <= maxQuantity\n )\n);\n\nconst productListingSchema = object({\n acceptsDiscounts: optional(boolean(), false),\n id: nonEmptyStringSchema,\n product: publicProductSchema,\n productId: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n});\n\nconst widgetFieldsSchema = optional(\n object({\n memberId: optional(boolean(), false),\n merchSize: optional(boolean(), false),\n phone: optional(boolean(), false),\n promoCode: optional(boolean(), false),\n serviceFee: optional(boolean(), false),\n shipping: optional(boolean(), false),\n tipping: optional(boolean(), false),\n }),\n {}\n);\n\nexport const publicWidgetSchema = pipe(\n object({\n community: optional(\n object({\n color: string(),\n name: nonEmptyStringSchema,\n thumbnail: string(),\n })\n ),\n config: optional(\n object({\n customFields: customFieldsSchema,\n fields: widgetFieldsSchema,\n })\n ),\n description: optionalNullableStringSchema,\n id: optional(string(), \"\"),\n name: optional(string(), \"Lockerverse widget\"),\n payment: object({\n currency: literal(\"usd\"),\n publishableKey: publishableKeySchema,\n }),\n pricingPolicy: optional(\n object({\n currency: optional(literal(\"usd\"), \"usd\"),\n serviceFeeRateBasisPoints: optional(safeIntegerSchema(0), 0),\n })\n ),\n products: optional(array(productListingSchema), []),\n showCommunityBranding: optional(boolean(), true),\n title: optionalNullableStringSchema,\n }),\n transform((widget) => ({\n ...widget,\n config: {\n customFields: widget.config?.customFields ?? [],\n fields: {\n memberId: widget.config?.fields?.memberId ?? false,\n merchSize: widget.config?.fields?.merchSize ?? false,\n phone: widget.config?.fields?.phone ?? false,\n promoCode: widget.config?.fields?.promoCode ?? false,\n serviceFee: widget.config?.fields?.serviceFee ?? false,\n shipping: widget.config?.fields?.shipping ?? false,\n tipping: widget.config?.fields?.tipping ?? false,\n },\n },\n pricingPolicy: widget.pricingPolicy ?? {\n currency: \"usd\" as const,\n serviceFeeRateBasisPoints: 0,\n },\n }))\n);\n\nconst appliedDiscountSchema = nullable(\n object({\n percentageOff: pipe(number(), finite(), minValue(0), maxValue(100)),\n source: picklist([\"email_list\", \"promo_code\"]),\n })\n);\n\nconst checkoutLineItemSchema = object({\n acceptsDiscounts: boolean(),\n listingId: nonEmptyStringSchema,\n listingSlug: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n pricingMode: picklist([\"fixed\", \"custom\"]),\n productId: nonEmptyStringSchema,\n productName: nonEmptyStringSchema,\n quantity: safeIntegerSchema(1),\n subtotalCents: safeIntegerSchema(0),\n unitAmountCents: safeIntegerSchema(0),\n});\n\nexport const checkoutQuoteSchema = pipe(\n object({\n amountCents: safeIntegerSchema(0),\n appliedDiscount: appliedDiscountSchema,\n connectedAccountId: nullable(nonEmptyStringSchema),\n discountableSubtotalCents: safeIntegerSchema(0),\n discountCents: safeIntegerSchema(0),\n lineItems: array(checkoutLineItemSchema),\n paymentOption: paymentOptionSchema,\n serviceFeeCents: safeIntegerSchema(0),\n subtotalCents: safeIntegerSchema(0),\n tipCents: safeIntegerSchema(0),\n totalCents: safeIntegerSchema(0),\n }),\n check(({ lineItems, paymentOption }) => {\n if (\n lineItems.length === 0 ||\n lineItems.some((item) => item.paymentOption !== paymentOption)\n ) {\n return false;\n }\n return (\n paymentOption === \"one-time\" ||\n (lineItems.length === 1 &&\n lineItems[0]?.pricingMode === \"fixed\" &&\n lineItems[0].quantity === 1)\n );\n }, \"Invalid checkout cadence composition.\")\n);\n\nexport const paymentResultSchema = pipe(\n vPaymentWidgetPaymentResultResponseDto,\n check((payment) => {\n if (!(payment.checkoutId.trim() && payment.paymentReference.trim())) {\n return false;\n }\n if (payment.checkoutStatus === \"action_required\") {\n return (\n payment.requiresAction &&\n payment.paymentRequired &&\n Boolean(payment.clientSecret?.trim())\n );\n }\n return !payment.requiresAction && payment.clientSecret === null;\n }, \"Invalid payment result state.\")\n);\n\nexport const checkoutBootstrapSchema = object({\n catalog: publicWidgetSchema,\n quote: checkoutQuoteSchema,\n});\n\nexport type PublicCheckoutQuote = InferOutput<typeof checkoutQuoteSchema>;\nexport type PublicProductListing = InferOutput<typeof productListingSchema>;\nexport type PublicWidget = InferOutput<typeof publicWidgetSchema>;\n\nexport const parseCheckoutQuote = parser(checkoutQuoteSchema);\nexport const parseCheckoutBootstrap = parser(checkoutBootstrapSchema);\nexport const parsePaymentResult = parser(paymentResultSchema);\nexport const parsePublicWidget = parser(publicWidgetSchema);\n","import type { PublicProductListing, PublicWidget } from \"./checkout-schemas.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport type {\n LockerverseCatalog,\n LockerversePaymentResult,\n LockerversePreparedCheckout,\n LockerverseProduct,\n} from \"./types.ts\";\n\nfunction mapProduct(listing: PublicProductListing): LockerverseProduct {\n const { product } = listing;\n\n return {\n acceptsDiscounts: listing.acceptsDiscounts ?? false,\n amountCents: product.amountCents,\n description: product.description ?? null,\n id: product.id,\n inventoryQuantity: product.inventoryQuantity,\n listingId: listing.id,\n maximumQuantity: product.maxQuantity,\n minimumAmountCents: product.minimumAmountCents,\n minimumQuantity: product.minQuantity,\n name: product.name,\n paymentOption: product.paymentOption,\n pricingMode: product.pricingMode,\n slug: listing.slug,\n };\n}\n\nexport function createCatalog(widget: PublicWidget): LockerverseCatalog {\n const fields = widget.config?.fields ?? {};\n\n return {\n community: widget.community\n ? {\n accentColor: widget.community.color,\n imageUrl: widget.community.thumbnail,\n name: widget.community.name,\n }\n : null,\n payment: {\n currency: widget.payment.currency,\n publishableKey: widget.payment.publishableKey,\n },\n pricingPolicy: {\n currency: \"usd\",\n serviceFeeRateBasisPoints:\n widget.pricingPolicy?.serviceFeeRateBasisPoints ?? 0,\n },\n products: (widget.products ?? []).map(mapProduct),\n widget: {\n customFields: widget.config?.customFields ?? [],\n description: widget.description ?? null,\n fields: {\n memberId: fields.memberId ?? false,\n merchSize: fields.merchSize ?? false,\n phone: fields.phone ?? false,\n promoCode: fields.promoCode ?? false,\n serviceFee: fields.serviceFee ?? false,\n shipping: fields.shipping ?? false,\n tipping: fields.tipping ?? false,\n },\n id: widget.id ?? \"\",\n name: widget.name ?? \"Lockerverse widget\",\n showCommunityBranding: widget.showCommunityBranding ?? true,\n title: widget.title ?? null,\n },\n };\n}\n\nexport function cloneCatalog(catalog: LockerverseCatalog): LockerverseCatalog {\n return cloneSnapshot(catalog);\n}\n\nexport function clonePreparedCheckout(\n checkout: LockerversePreparedCheckout\n): LockerversePreparedCheckout {\n return cloneSnapshot(checkout);\n}\n\nexport function clonePaymentResult(\n paymentResult: LockerversePaymentResult\n): LockerversePaymentResult {\n return cloneSnapshot(paymentResult);\n}\n\nfunction cloneSnapshot<T>(value: T): T {\n return deepFreeze(structuredClone(value));\n}\n","import { resolveWidgetEnvironment } from \"./checkout-environment.ts\";\nimport {\n parseCheckoutItems,\n parseCheckoutPricingInput,\n parseCheckoutSelectionItems,\n parsePaymentSubmission,\n} from \"./checkout-input-schemas.ts\";\nimport {\n parseCheckoutBootstrap,\n parseCheckoutQuote,\n parsePaymentResult,\n parsePublicWidget,\n} from \"./checkout-schemas.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport {\n cloneCatalog,\n clonePaymentResult,\n clonePreparedCheckout,\n createCatalog,\n} from \"./snapshots.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport {\n type CreateLockerverseWidgetOptions,\n type LockerverseCatalog,\n type LockerverseCheckoutClient,\n type LockerverseCheckoutItem,\n type LockerverseCheckoutPricingInput,\n type LockerverseCheckoutQuote,\n type LockerverseCheckoutSelectionItem,\n type LockerversePreparedCheckout,\n type LockerverseProduct,\n LockerverseSdkError,\n type LockerverseSdkOperation,\n} from \"./types.ts\";\n\ntype OperationErrorContext = {\n code:\n | \"checkout_bootstrap_failed\"\n | \"payment_status_failed\"\n | \"payment_submit_failed\"\n | \"total_calculation_failed\"\n | \"widget_load_failed\";\n message: string;\n operation:\n | \"bootstrap_checkout\"\n | \"calculate_total\"\n | \"get_payment_status\"\n | \"load_widget\"\n | \"submit_payment\";\n};\n\nexport function createLockerverseCheckoutClient(\n options: CreateLockerverseWidgetOptions\n): LockerverseCheckoutClient {\n const {\n apiBaseUrl,\n communitySlug,\n communitySlugValue,\n environment,\n fetchImplementation,\n onError,\n requestTimeoutMs,\n sentryDsn,\n widgetSlug,\n widgetSlugValue,\n } = resolveWidgetEnvironment(options);\n let catalogPublishableKey: string | undefined;\n const reportError = createSdkErrorReporter({\n communitySlug: communitySlugValue,\n environment,\n getContext: () => ({ widgetSlug: widgetSlugValue }),\n onError,\n resourceContextName: \"lockerverse_widget\",\n sentryDsn,\n });\n const { requestJson } = createTransport(\n fetchImplementation,\n reportError,\n requestTimeoutMs\n );\n const checkoutBaseUrl = `${apiBaseUrl}/v2/community/${communitySlug}/payment-widgets/${widgetSlug}/checkout`;\n\n function invalidInput(\n message: string,\n operation: LockerverseSdkOperation,\n code: \"invalid_selection\" | \"payment_submit_failed\" = \"invalid_selection\"\n ): never {\n throw reportError(\n new LockerverseSdkError({\n code,\n message,\n operation,\n reportable: false,\n })\n );\n }\n\n function normalizeOperationError(\n error: unknown,\n context: OperationErrorContext\n ) {\n return error instanceof LockerverseSdkError\n ? error\n : new LockerverseSdkError({ ...context, reportable: true });\n }\n\n function failOperation(\n error: unknown,\n context: OperationErrorContext,\n recoveryMayBeRequired = false\n ): never {\n const normalized = normalizeOperationError(error, context);\n const recoveryRecommended =\n recoveryMayBeRequired &&\n (normalized.status === undefined || normalized.status >= 500);\n throw reportError(\n recoveryRecommended\n ? new LockerverseSdkError({\n code: normalized.code,\n message: normalized.message,\n operation: normalized.operation,\n recoveryRecommended: true,\n reportable: normalized.reportable,\n ...(normalized.status === undefined\n ? {}\n : { status: normalized.status }),\n })\n : normalized\n );\n }\n\n function normalizePricingInput(\n input: unknown,\n operation: \"bootstrap_checkout\" | \"calculate_total\" | \"submit_payment\"\n ) {\n let parsed: ReturnType<typeof parseCheckoutPricingInput>;\n try {\n parsed = parseCheckoutPricingInput(input);\n } catch {\n invalidInput(\"Checkout pricing input is invalid.\", operation);\n }\n const email = parsed.email?.trim().toLowerCase();\n const promoCode = parsed.promoCode?.trim();\n return {\n ...(email ? { email } : {}),\n ...(parsed.includeServiceFee === undefined\n ? {}\n : { includeServiceFee: parsed.includeServiceFee }),\n ...(promoCode ? { promoCode } : {}),\n ...(parsed.tipCents === undefined ? {} : { tipCents: parsed.tipCents }),\n };\n }\n\n function normalizeBootstrapCheckoutInput(input: unknown) {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n invalidInput(\"Checkout selection is invalid.\", \"bootstrap_checkout\");\n }\n const { items, ...pricingInput } = input as Record<string, unknown>;\n try {\n return {\n pricing: normalizePricingInput(pricingInput, \"bootstrap_checkout\"),\n selection: parseCheckoutSelectionItems(items),\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\"Checkout selection is invalid.\", \"bootstrap_checkout\");\n }\n }\n\n function createAmountCheckoutItem(\n product: LockerverseProduct,\n amountCents: number\n ): LockerverseCheckoutItem {\n if (\n product.pricingMode !== \"custom\" ||\n (product.minimumAmountCents !== null &&\n amountCents < product.minimumAmountCents)\n ) {\n invalidInput(\"Selected Product amount is invalid.\", \"bootstrap_checkout\");\n }\n return { amountCents, productId: product.id };\n }\n\n function createFixedCheckoutItem(\n product: LockerverseProduct,\n item: Exclude<LockerverseCheckoutSelectionItem, { amountCents: number }>\n ): LockerverseCheckoutItem {\n if (product.paymentOption !== \"one-time\") {\n if (product.pricingMode !== \"fixed\" || \"quantity\" in item) {\n invalidInput(\n \"Selected recurring Product is invalid.\",\n \"bootstrap_checkout\"\n );\n }\n return { productId: product.id };\n }\n if (\n product.pricingMode !== \"fixed\" ||\n !(\"quantity\" in item) ||\n (product.minimumQuantity !== null &&\n item.quantity < product.minimumQuantity) ||\n (product.maximumQuantity !== null &&\n item.quantity > product.maximumQuantity) ||\n (product.inventoryQuantity !== null &&\n item.quantity > product.inventoryQuantity)\n ) {\n invalidInput(\n \"Selected Product quantity is invalid.\",\n \"bootstrap_checkout\"\n );\n }\n return { productId: product.id, quantity: item.quantity };\n }\n\n function createCheckoutItems(\n catalog: LockerverseCatalog,\n selection: LockerverseCheckoutSelectionItem[]\n ): LockerverseCheckoutItem[] {\n return selection.map((item) => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product) {\n invalidInput(\"Selected Product is unavailable.\", \"bootstrap_checkout\");\n }\n return \"amountCents\" in item\n ? createAmountCheckoutItem(product, item.amountCents)\n : createFixedCheckoutItem(product, item);\n });\n }\n\n function createPreparedCheckout(\n quote: ReturnType<typeof parseCheckoutQuote>,\n items: LockerverseCheckoutItem[],\n pricing: LockerverseCheckoutPricingInput,\n context: OperationErrorContext\n ): LockerversePreparedCheckout {\n if (!catalogPublishableKey) {\n throw new LockerverseSdkError({\n ...context,\n message: \"Load the Lockerverse widget before calculating a checkout.\",\n reportable: false,\n });\n }\n const { connectedAccountId, ...checkoutQuote } = quote;\n return clonePreparedCheckout(\n deepFreeze({\n ...checkoutQuote,\n authoritative: true as const,\n items,\n payment: {\n connectedAccountId,\n currency: \"usd\" as const,\n publishableKey: catalogPublishableKey,\n },\n paymentOption: quote.paymentOption,\n paymentReference: globalThis.crypto.randomUUID(),\n pricing,\n })\n );\n }\n\n function normalizeCalculateTotalInput(input: unknown) {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n invalidInput(\"Checkout selection is invalid.\", \"calculate_total\");\n }\n const { items, ...pricingInput } = input as Record<string, unknown>;\n try {\n return {\n items: parseCheckoutItems(items),\n pricing: normalizePricingInput(pricingInput, \"calculate_total\"),\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\"Checkout selection is invalid.\", \"calculate_total\");\n }\n }\n\n function normalizeQuote(input: unknown) {\n try {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n throw new TypeError(\"Invalid quote.\");\n }\n const quoteInput = input as LockerverseCheckoutQuote;\n if (\n quoteInput.authoritative !== true ||\n typeof quoteInput.paymentReference !== \"string\" ||\n quoteInput.paymentReference.length === 0 ||\n quoteInput.payment.currency !== \"usd\" ||\n quoteInput.payment.publishableKey !== catalogPublishableKey\n ) {\n throw new TypeError(\"Invalid quote.\");\n }\n const parsed = parseCheckoutQuote({\n ...quoteInput,\n connectedAccountId: quoteInput.payment.connectedAccountId,\n });\n const { connectedAccountId, ...quote } = parsed;\n return deepFreeze({\n ...quote,\n authoritative: true as const,\n payment: {\n connectedAccountId,\n currency: \"usd\" as const,\n publishableKey: catalogPublishableKey,\n },\n paymentOption: parsed.paymentOption,\n paymentReference: quoteInput.paymentReference,\n });\n } catch {\n invalidInput(\n \"Lockerverse payment submission is invalid.\",\n \"submit_payment\",\n \"payment_submit_failed\"\n );\n }\n }\n\n function normalizeSubmitPaymentInput(input: unknown) {\n try {\n if (!(input && typeof input === \"object\") || Array.isArray(input)) {\n throw new TypeError(\"Invalid payment input.\");\n }\n const { checkout, submission: submissionInput } = input as Record<\n string,\n unknown\n >;\n if (\n !(checkout && typeof checkout === \"object\") ||\n Array.isArray(checkout)\n ) {\n throw new TypeError(\"Invalid prepared checkout.\");\n }\n const checkoutInput = checkout as Record<string, unknown>;\n const items = parseCheckoutItems(checkoutInput.items);\n const pricing = normalizePricingInput(\n checkoutInput.pricing,\n \"submit_payment\"\n );\n const quote = normalizeQuote(checkoutInput);\n const submission = parsePaymentSubmission(submissionInput);\n if (quote.totalCents > 0 && !submission.confirmationToken) {\n invalidInput(\n \"Stripe confirmation is required for a paid checkout.\",\n \"submit_payment\",\n \"payment_submit_failed\"\n );\n }\n const email = submission.email.trim().toLowerCase();\n if (!email || email !== pricing.email) {\n invalidInput(\n \"Payment email must match the current checkout quote.\",\n \"submit_payment\"\n );\n }\n return {\n items,\n pricing,\n quote,\n submission: { ...submission, email },\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\n \"Lockerverse payment submission is invalid.\",\n \"submit_payment\",\n \"payment_submit_failed\"\n );\n }\n }\n\n return {\n async bootstrapCheckout(input) {\n const { pricing, selection } = normalizeBootstrapCheckoutInput(input);\n const context = {\n code: \"checkout_bootstrap_failed\" as const,\n message: \"Lockerverse returned an invalid checkout bootstrap.\",\n operation: \"bootstrap_checkout\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/bootstrap`,\n {\n body: JSON.stringify({ ...pricing, items: selection }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parseCheckoutBootstrap,\n {\n ...context,\n message:\n \"Unable to bootstrap the Lockerverse checkout because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to bootstrap the Lockerverse checkout (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n const catalog = deepFreeze(createCatalog(response.value.catalog));\n catalogPublishableKey = catalog.payment.publishableKey;\n const checkoutItems = createCheckoutItems(catalog, selection);\n const checkoutPricing = {\n ...pricing,\n includeServiceFee:\n pricing.includeServiceFee ?? catalog.widget.fields.serviceFee,\n };\n return deepFreeze({\n catalog: cloneCatalog(catalog),\n checkout: createPreparedCheckout(\n response.value.quote,\n checkoutItems,\n checkoutPricing,\n context\n ),\n });\n } catch (error) {\n failOperation(error, context);\n }\n },\n async calculateTotal(input) {\n const { items, pricing } = normalizeCalculateTotalInput(input);\n const context = {\n code: \"total_calculation_failed\" as const,\n message: \"Lockerverse returned an invalid checkout total.\",\n operation: \"calculate_total\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/quote`,\n {\n body: JSON.stringify({ ...pricing, items }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parseCheckoutQuote,\n {\n ...context,\n message:\n \"Unable to calculate the Lockerverse checkout total because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to calculate the Lockerverse checkout total (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n return createPreparedCheckout(response.value, items, pricing, context);\n } catch (error) {\n failOperation(error, context);\n }\n },\n async getPaymentStatus(paymentReference) {\n if (typeof paymentReference !== \"string\" || !paymentReference.trim()) {\n invalidInput(\n \"Provide a payment reference to recover its status.\",\n \"get_payment_status\"\n );\n }\n const normalizedReference = paymentReference.trim();\n const context = {\n code: \"payment_status_failed\" as const,\n message: \"Lockerverse returned an invalid payment status.\",\n operation: \"get_payment_status\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/${encodeURIComponent(normalizedReference)}/status`,\n undefined,\n parsePaymentResult,\n {\n ...context,\n message:\n \"Unable to recover the Lockerverse payment status because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to recover the Lockerverse payment status (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n if (response.value.paymentReference !== normalizedReference) {\n throw new LockerverseSdkError({ ...context, reportable: true });\n }\n return clonePaymentResult(response.value);\n } catch (error) {\n failOperation(error, context);\n }\n },\n async load() {\n const context = {\n code: \"widget_load_failed\" as const,\n message: \"Lockerverse returned an invalid widget catalog.\",\n operation: \"load_widget\" as const,\n };\n try {\n const response = await requestJson(\n `${apiBaseUrl}/v2/community/${communitySlug}/payment-widgets/${widgetSlug}`,\n undefined,\n parsePublicWidget,\n {\n ...context,\n message:\n \"Unable to load Lockerverse widget because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to load Lockerverse widget (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n const catalog = deepFreeze(createCatalog(response.value));\n catalogPublishableKey = catalog.payment.publishableKey;\n return cloneCatalog(catalog);\n } catch (error) {\n failOperation(error, context);\n }\n },\n async submitPayment(input) {\n const { items, pricing, quote, submission } =\n normalizeSubmitPaymentInput(input);\n const context = {\n code: \"payment_submit_failed\" as const,\n message: \"Lockerverse returned an invalid payment confirmation.\",\n operation: \"submit_payment\" as const,\n };\n try {\n const response = await requestJson(\n `${checkoutBaseUrl}/confirm`,\n {\n body: JSON.stringify({\n ...(submission.confirmationToken\n ? { confirmationToken: submission.confirmationToken }\n : {}),\n customFieldAnswers: submission.customFieldAnswers,\n email: submission.email,\n expectedAmountCents: quote.amountCents,\n expectedAppliedDiscount: quote.appliedDiscount,\n expectedConnectedAccountId: quote.payment.connectedAccountId,\n expectedDiscountableSubtotalCents:\n quote.discountableSubtotalCents,\n expectedDiscountCents: quote.discountCents,\n expectedServiceFeeCents: quote.serviceFeeCents,\n expectedSubtotalCents: quote.subtotalCents,\n expectedTipCents: quote.tipCents,\n expectedTotalCents: quote.totalCents,\n ...pricing,\n items,\n memberId: submission.memberId,\n merchSize: submission.merchSize,\n metadata: submission.metadata,\n paymentReference: quote.paymentReference,\n phone: submission.phone,\n quoteContractVersion: 1,\n shipping: submission.shipping,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parsePaymentResult,\n {\n ...context,\n message:\n \"Unable to submit the Lockerverse payment because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to submit the Lockerverse payment (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n if (response.value.paymentReference !== quote.paymentReference) {\n throw new LockerverseSdkError({ ...context, reportable: true });\n }\n return clonePaymentResult(response.value);\n } catch (error) {\n failOperation(error, context, true);\n }\n },\n };\n}\n"],"mappings":"+RAGA,SAAgB,GACd,EACA,CACA,IAAM,EAAU,EACd,EAAQ,aAAe,IAAA,IAAa,EAAQ,cAAgB,IAAA,GACxD,CAAE,GAAG,EAAS,YAAa,YAAa,EACxC,EACJ,YACF,EACA,MAAO,CACL,GAAG,EACH,WAAY,EAAQ,aACpB,gBAAiB,EAAQ,iBAC3B,CACF,CCGA,MAAa,GAA4B,EACvC,EACE,EAAa,CACX,MAAO,EAAS,EAAO,CAAC,EACxB,kBAAmB,EAAS,EAAQ,CAAC,EACrC,UAAW,EAAS,EAAO,CAAC,EAC5B,SAAU,EAAS,EAAkB,CAAC,CAAC,CACzC,CAAC,EACD,CAAC,CACH,CACF,EAEa,EAAyB,EACpC,E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H,QACA,SAAU,EAAW,SACrB,UAAW,EAAW,UACtB,SAAU,EAAW,SACrB,iBAAkB,EAAM,iBACxB,MAAO,EAAW,MAClB,qBAAsB,EACtB,SAAU,EAAW,QACvB,CAAC,EACD,QAAS,CAAE,eAAgB,kBAAmB,EAC9C,OAAQ,MACV,EACA,EACA,CACE,GAAG,EACH,QACE,uEACF,OAAQ,EACV,EACA,CAAE,GAAG,EAAS,OAAQ,EAAM,CAC9B,EACA,GAAI,CAAC,EAAS,GACZ,MAAM,IAAI,EAAoB,CAC5B,GAAG,EACH,QAAS,6CAA6C,EAAS,SAAS,OAAO,IAC/E,WAAY,EAAS,SAAS,QAAU,IACxC,OAAQ,EAAS,SAAS,MAC5B,CAAC,EAEH,GAAI,EAAS,MAAM,mBAAqB,EAAM,iBAC5C,MAAM,IAAI,EAAoB,CAAE,GAAG,EAAS,WAAY,EAAK,CAAC,EAEhE,OAAO,EAAmB,EAAS,KAAK,CAC1C,OAAS,EAAO,CACd,EAAc,EAAO,EAAS,EAAI,CACpC,CACF,CACF,CACF"}
|
package/dist/signup.d.ts
CHANGED
|
@@ -61,36 +61,13 @@ type CreateLockerverseSignupOptions = CreateLockerverseSignupBaseOptions & ({
|
|
|
61
61
|
apiBaseUrl?: undefined;
|
|
62
62
|
environment?: "production";
|
|
63
63
|
});
|
|
64
|
-
type LockerverseSignupState = {
|
|
65
|
-
phase: "idle";
|
|
66
|
-
} | {
|
|
67
|
-
phase: "loading";
|
|
68
|
-
} | {
|
|
69
|
-
phase: "ready";
|
|
70
|
-
signup: LockerverseSignup;
|
|
71
|
-
} | {
|
|
72
|
-
phase: "submitting";
|
|
73
|
-
signup: LockerverseSignup;
|
|
74
|
-
submissionReference: string;
|
|
75
|
-
} | {
|
|
76
|
-
phase: "submitted";
|
|
77
|
-
signup: LockerverseSignup;
|
|
78
|
-
submission: LockerverseSignupSubmissionResult;
|
|
79
|
-
} | {
|
|
80
|
-
phase: "error";
|
|
81
|
-
error: LockerverseSdkError;
|
|
82
|
-
recoverableSubmissionReference: string | null;
|
|
83
|
-
signup: LockerverseSignup | null;
|
|
84
|
-
};
|
|
85
64
|
type LockerverseSignupClient = {
|
|
86
|
-
getState: () => LockerverseSignupState;
|
|
87
65
|
load: () => Promise<LockerverseSignup>;
|
|
88
66
|
submit: (submission: LockerverseSignupSubmission, options?: LockerverseSignupSubmitOptions) => Promise<LockerverseSignupSubmissionResult>;
|
|
89
|
-
subscribe: (listener: (state: LockerverseSignupState) => void) => () => void;
|
|
90
67
|
};
|
|
91
68
|
//#endregion
|
|
92
69
|
//#region src/signup.d.ts
|
|
93
|
-
declare function
|
|
70
|
+
declare function createLockerverseSignupClient(options: CreateLockerverseSignupOptions): LockerverseSignupClient;
|
|
94
71
|
//#endregion
|
|
95
|
-
export { type CreateLockerverseSignupOptions, type LockerverseCustomField, type LockerverseCustomFieldAnswer, type LockerverseCustomFieldAnswerValue, type LockerverseCustomFieldOption, type LockerverseEnvironment, type LockerverseSignup, type LockerverseSignupAddress, type LockerverseSignupClient, type LockerverseSignupField, type LockerverseSignupFields, type
|
|
72
|
+
export { type CreateLockerverseSignupOptions, type LockerverseCustomField, type LockerverseCustomFieldAnswer, type LockerverseCustomFieldAnswerValue, type LockerverseCustomFieldOption, type LockerverseEnvironment, type LockerverseSdkError, type LockerverseSignup, type LockerverseSignupAddress, type LockerverseSignupClient, type LockerverseSignupField, type LockerverseSignupFields, type LockerverseSignupSubmission, type LockerverseSignupSubmissionResult, type LockerverseSignupSubmitOptions, createLockerverseSignupClient };
|
|
96
73
|
//# sourceMappingURL=signup.d.ts.map
|
package/dist/signup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signup.d.ts","names":[],"sources":["../src/signup-types.ts","../src/signup.ts"],"mappings":";;KAQY;EACV;EACA;;KAGU;EACV,SAAS;EACT,OAAO;EACP,MAAM;EACN,kBAAkB;EAClB,OAAO;;KAGG;EACV;EACA,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,UAAU;EACV,UAAU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;;KAYU;EACV;;KAGG;EACH;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;EACA;;KAGU,iCACV;EAGQ;EACA,aAAa;;EAGb;EACA;;KAIE;
|
|
1
|
+
{"version":3,"file":"signup.d.ts","names":[],"sources":["../src/signup-types.ts","../src/signup.ts"],"mappings":";;KAQY;EACV;EACA;;KAGU;EACV,SAAS;EACT,OAAO;EACP,MAAM;EACN,kBAAkB;EAClB,OAAO;;KAGG;EACV;EACA,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,UAAU;EACV,UAAU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;;KAYU;EACV;;KAGG;EACH;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;EACA;;KAGU,iCACV;EAGQ;EACA,aAAa;;EAGb;EACA;;KAIE;EACV,YAAY,QAAQ;EACpB,SACE,YAAY,6BACZ,UAAU,mCACP,QAAQ;;;;iBC9DC,8BACd,SAAS,iCACR"}
|
package/dist/signup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,M as r,T as i,a,c as o,f as s,h as c,j as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v,w as y,x as b}from"./transport.js";import{n as x}from"./types.js";const S=e({city:l(),country:l(),line1:l(),line2:y(b(l())),postalCode:l(),state:l()}),C=i(e({address:y(b(S)),answers:y(m(p)),email:y(b(l())),honeypot:y(l()),name:o,participantCount:y(b(v(0))),phone:y(b(l()))})),w=t({enabled:d(),required:d()}),T=n(t({config:t({builtInFields:t({address:w,email:w,name:w,participantCount:w,phone:w}),customFields:g}),coverImageUrl:u,description:u,id:o,isActive:d(),name:o,slug:o,title:u}),r(({config:e,...t})=>({...t,customFields:e.customFields,fields:e.builtInFields}))),E=n(a,c(({id:e})=>!!e.trim(),`Invalid signup submission ID.`)),D=i(T),O=i(E);function k(e
|
|
1
|
+
import{A as e,C as t,D as n,M as r,T as i,a,c as o,f as s,h as c,j as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v,w as y,x as b}from"./transport.js";import{n as x}from"./types.js";const S=e({city:l(),country:l(),line1:l(),line2:y(b(l())),postalCode:l(),state:l()}),C=i(e({address:y(b(S)),answers:y(m(p)),email:y(b(l())),honeypot:y(l()),name:o,participantCount:y(b(v(0))),phone:y(b(l()))})),w=t({enabled:d(),required:d()}),T=n(t({config:t({builtInFields:t({address:w,email:w,name:w,participantCount:w,phone:w}),customFields:g}),coverImageUrl:u,description:u,id:o,isActive:d(),name:o,slug:o,title:u}),r(({config:e,...t})=>({...t,customFields:e.customFields,fields:e.builtInFields}))),E=n(a,c(({id:e})=>!!e.trim(),`Invalid signup submission ID.`)),D=i(T),O=i(E);function k(e,t,n){return e instanceof x?e:n(new x({code:`signup_submit_failed`,message:`Unable to submit Lockerverse signup.`,operation:`submit_signup`,recoveryRecommended:t,reportable:t}))}function A(e){let t=s(e),n=f({communitySlug:t.communitySlugValue,environment:t.environment,getContext:()=>({signupSlug:t.signupSlugValue}),onError:t.onError,resourceContextName:`lockerverse_signup`,sentryDsn:t.sentryDsn}),{requestJson:r}=_(t.fetchImplementation,e=>n(e.operation===`submit_signup`&&!e.recoveryRecommended?new x({code:e.code,message:e.message,operation:e.operation,recoveryRecommended:!0,reportable:e.reportable}):e),t.requestTimeoutMs),i=`${t.apiBaseUrl}/community/${t.communitySlug}/sign-up-widgets/${t.signupSlug}`;return{async load(){let e={code:`signup_load_failed`,message:`Unable to load Lockerverse signup.`,operation:`load_signup`},t=await r(i,void 0,D,e,e);if(!t.ok)throw n(new x({...e,reportable:t.response.status>=500,status:t.response.status}));return h(t.value)},async submit(e,t){let a=t?.submissionReference??globalThis.crypto.randomUUID(),o={code:`signup_submit_failed`,message:`Unable to submit Lockerverse signup.`,operation:`submit_signup`},s;try{s=C(e)}catch{throw n(new x({...o,message:`Lockerverse signup input is invalid.`,reportable:!1}))}let c=!1;try{let e=JSON.stringify({...s,submissionReference:a});c=!0;let t=await r(`${i}/submissions`,{body:e,headers:{"content-type":`application/json`},method:`POST`},O,o,o);if(!t.ok)throw n(new x({...o,recoveryRecommended:t.response.status>=500,reportable:t.response.status>=500,status:t.response.status}));let l=h(t.value);if(l.id!==a)throw n(new x({...o,recoveryRecommended:!0,reportable:!0}));return l}catch(e){throw k(e,c,n)}}}}export{A as createLockerverseSignupClient};
|
|
2
2
|
//# sourceMappingURL=signup.js.map
|
package/dist/signup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signup.js","names":[],"sources":["../src/signup-input-schema.ts","../src/signup-schemas.ts","../src/state.ts","../src/signup.ts"],"sourcesContent":["import {\n array,\n nullable,\n optional,\n parser,\n strictObject,\n string,\n} from \"valibot\";\n\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupAddressSchema = strictObject({\n city: string(),\n country: string(),\n line1: string(),\n line2: optional(nullable(string())),\n postalCode: string(),\n state: string(),\n});\n\nexport const parseSignupSubmission = parser(\n strictObject({\n address: optional(nullable(signupAddressSchema)),\n answers: optional(array(customFieldAnswerSchema)),\n email: optional(nullable(string())),\n honeypot: optional(string()),\n name: nonEmptyStringSchema,\n participantCount: optional(nullable(safeIntegerSchema(0))),\n phone: optional(nullable(string())),\n })\n);\n","import { boolean, check, object, parser, pipe, transform } from \"valibot\";\n\nimport { vPublicSignUpWidgetSubmissionResponseDto } from \"./generated/public-api/valibot.gen.ts\";\nimport {\n customFieldsSchema,\n nonEmptyStringSchema,\n optionalNullableStringSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupFieldSchema = object({\n enabled: boolean(),\n required: boolean(),\n});\n\nexport const publicSignupSchema = pipe(\n object({\n config: object({\n builtInFields: object({\n address: signupFieldSchema,\n email: signupFieldSchema,\n name: signupFieldSchema,\n participantCount: signupFieldSchema,\n phone: signupFieldSchema,\n }),\n customFields: customFieldsSchema,\n }),\n coverImageUrl: optionalNullableStringSchema,\n description: optionalNullableStringSchema,\n id: nonEmptyStringSchema,\n isActive: boolean(),\n name: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n title: optionalNullableStringSchema,\n }),\n transform(({ config, ...signup }) => ({\n ...signup,\n customFields: config.customFields,\n fields: config.builtInFields,\n }))\n);\n\nexport const signupSubmissionResultSchema = pipe(\n vPublicSignUpWidgetSubmissionResponseDto,\n check(({ id }) => Boolean(id.trim()), \"Invalid signup submission ID.\")\n);\n\nexport const parsePublicSignup = parser(publicSignupSchema);\nexport const parseSignupSubmissionResult = parser(signupSubmissionResultSchema);\n","import { deepFreeze } from \"./deep-freeze.ts\";\n\nexport function createStateStore<State>(initialState: State) {\n let state = deepFreeze(initialState);\n const listeners = new Set<(nextState: State) => void>();\n\n return {\n commit(nextState: State) {\n state = deepFreeze(nextState);\n for (const listener of [...listeners]) {\n try {\n listener(state);\n } catch {\n // Host listeners cannot interrupt SDK state transitions.\n }\n }\n },\n getState() {\n return state;\n },\n subscribe(listener: (nextState: State) => void) {\n listeners.add(listener);\n try {\n listener(state);\n } catch {\n // A failing initial render must not prevent subscription or checkout.\n }\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n","import { deepFreeze } from \"./deep-freeze.ts\";\nimport { resolveSignupEnvironment } from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { parseSignupSubmission } from \"./signup-input-schema.ts\";\nimport {\n parsePublicSignup,\n parseSignupSubmissionResult,\n} from \"./signup-schemas.ts\";\nimport type {\n CreateLockerverseSignupOptions,\n LockerverseSignup,\n LockerverseSignupClient,\n LockerverseSignupState,\n LockerverseSignupSubmission,\n} from \"./signup-types.ts\";\nimport { createStateStore } from \"./state.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport { LockerverseSdkError } from \"./types.ts\";\n\nfunction classifySubmissionError(\n error: unknown,\n requestAttempted: boolean,\n reportError: (error: LockerverseSdkError) => LockerverseSdkError\n) {\n if (error instanceof LockerverseSdkError) {\n return error;\n }\n return reportError(\n new LockerverseSdkError({\n code: \"signup_submit_failed\",\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\",\n recoveryRecommended: requestAttempted,\n reportable: requestAttempted,\n })\n );\n}\n\nexport function createLockerverseSignup(\n options: CreateLockerverseSignupOptions\n): LockerverseSignupClient {\n const runtime = resolveSignupEnvironment(options);\n const stateStore = createStateStore<LockerverseSignupState>({\n phase: \"idle\",\n });\n let loadedSignup: LockerverseSignup | null = null;\n let loading = false;\n let submitting = false;\n\n const reportError = createSdkErrorReporter({\n communitySlug: runtime.communitySlugValue,\n environment: runtime.environment,\n getContext: () => ({ signupSlug: runtime.signupSlugValue }),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_signup\",\n sentryDsn: runtime.sentryDsn,\n });\n\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n (error) =>\n reportError(\n error.operation === \"submit_signup\" && !error.recoveryRecommended\n ? new LockerverseSdkError({\n code: error.code,\n message: error.message,\n operation: error.operation,\n recoveryRecommended: true,\n reportable: error.reportable,\n })\n : error\n ),\n runtime.requestTimeoutMs\n );\n\n return {\n getState: stateStore.getState,\n async load() {\n const errorContext = {\n code: \"signup_load_failed\" as const,\n message: \"Unable to load Lockerverse signup.\",\n operation: \"load_signup\" as const,\n };\n if (loading || submitting) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n reportable: false,\n })\n );\n }\n\n loading = true;\n loadedSignup = null;\n stateStore.commit({ phase: \"loading\" });\n try {\n let signupResponse: Awaited<\n ReturnType<typeof requestJson<LockerverseSignup>>\n >;\n try {\n signupResponse = await requestJson(\n `${runtime.apiBaseUrl}/community/${runtime.communitySlug}/sign-up-widgets/${runtime.signupSlug}`,\n undefined,\n parsePublicSignup,\n errorContext,\n errorContext\n );\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n stateStore.commit({\n error,\n phase: \"error\",\n recoverableSubmissionReference: null,\n signup: null,\n });\n }\n throw error;\n }\n if (!signupResponse.ok) {\n const error = reportError(\n new LockerverseSdkError({\n ...errorContext,\n reportable: signupResponse.response.status >= 500,\n status: signupResponse.response.status,\n })\n );\n stateStore.commit({\n error,\n phase: \"error\",\n recoverableSubmissionReference: null,\n signup: null,\n });\n throw error;\n }\n const signup = deepFreeze(signupResponse.value);\n loadedSignup = signup;\n stateStore.commit({ phase: \"ready\", signup });\n return signup;\n } finally {\n loading = false;\n }\n },\n async submit(submission: LockerverseSignupSubmission, submitOptions) {\n const signup = loadedSignup;\n const submissionReference =\n submitOptions?.submissionReference ?? globalThis.crypto.randomUUID();\n const errorContext = {\n code: \"signup_submit_failed\" as const,\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\" as const,\n };\n if (!signup?.isActive || submitting) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n reportable: false,\n })\n );\n }\n\n let parsedSubmission: ReturnType<typeof parseSignupSubmission>;\n try {\n parsedSubmission = parseSignupSubmission(submission);\n } catch {\n const error = reportError(\n new LockerverseSdkError({\n ...errorContext,\n message: \"Lockerverse signup input is invalid.\",\n reportable: false,\n })\n );\n stateStore.commit({\n error,\n phase: \"error\",\n recoverableSubmissionReference: null,\n signup,\n });\n // biome-ignore lint/style/useErrorCause: Raw validation errors must not escape the SDK boundary.\n throw error;\n }\n\n submitting = true;\n stateStore.commit({ phase: \"submitting\", signup, submissionReference });\n let requestAttempted = false;\n try {\n const body = JSON.stringify({\n ...parsedSubmission,\n submissionReference,\n });\n requestAttempted = true;\n const submissionResponse = await requestJson(\n `${runtime.apiBaseUrl}/community/${runtime.communitySlug}/sign-up-widgets/${runtime.signupSlug}/submissions`,\n {\n body,\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n },\n parseSignupSubmissionResult,\n errorContext,\n errorContext\n );\n if (!submissionResponse.ok) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: submissionResponse.response.status >= 500,\n reportable: submissionResponse.response.status >= 500,\n status: submissionResponse.response.status,\n })\n );\n }\n const result = deepFreeze(submissionResponse.value);\n if (result.id !== submissionReference) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: true,\n reportable: true,\n })\n );\n }\n stateStore.commit({ phase: \"submitted\", signup, submission: result });\n return result;\n } catch (error) {\n const sdkError = classifySubmissionError(\n error,\n requestAttempted,\n reportError\n );\n stateStore.commit({\n error: sdkError,\n phase: \"error\",\n recoverableSubmissionReference: sdkError.recoveryRecommended\n ? submissionReference\n : null,\n signup,\n });\n throw sdkError;\n } finally {\n submitting = false;\n }\n },\n subscribe: stateStore.subscribe,\n };\n}\n"],"mappings":"yMAeA,MAAM,EAAsB,EAAa,CACvC,KAAM,EAAO,EACb,QAAS,EAAO,EAChB,MAAO,EAAO,EACd,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,EAClC,WAAY,EAAO,EACnB,MAAO,EAAO,CAChB,CAAC,EAEY,EAAwB,EACnC,EAAa,CACX,QAAS,EAAS,EAAS,CAAmB,CAAC,EAC/C,QAAS,EAAS,EAAM,CAAuB,CAAC,EAChD,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,EAClC,SAAU,EAAS,EAAO,CAAC,EAC3B,KAAM,EACN,iBAAkB,EAAS,EAAS,EAAkB,CAAC,CAAC,CAAC,EACzD,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,CACpC,CAAC,CACH,ECzBM,EAAoB,EAAO,CAC/B,QAAS,EAAQ,EACjB,SAAU,EAAQ,CACpB,CAAC,EAEY,EAAqB,EAChC,EAAO,CACL,OAAQ,EAAO,CACb,cAAe,EAAO,CACpB,QAAS,EACT,MAAO,EACP,KAAM,EACN,iBAAkB,EAClB,MA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C,EAAS,oBACrC,EACA,KACJ,QACF,CAAC,EACK,CACR,QAAU,CACR,EAAa,EACf,CACF,EACA,UAAW,EAAW,SACxB,CACF"}
|
|
1
|
+
{"version":3,"file":"signup.js","names":[],"sources":["../src/signup-input-schema.ts","../src/signup-schemas.ts","../src/signup.ts"],"sourcesContent":["import {\n array,\n nullable,\n optional,\n parser,\n strictObject,\n string,\n} from \"valibot\";\n\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupAddressSchema = strictObject({\n city: string(),\n country: string(),\n line1: string(),\n line2: optional(nullable(string())),\n postalCode: string(),\n state: string(),\n});\n\nexport const parseSignupSubmission = parser(\n strictObject({\n address: optional(nullable(signupAddressSchema)),\n answers: optional(array(customFieldAnswerSchema)),\n email: optional(nullable(string())),\n honeypot: optional(string()),\n name: nonEmptyStringSchema,\n participantCount: optional(nullable(safeIntegerSchema(0))),\n phone: optional(nullable(string())),\n })\n);\n","import { boolean, check, object, parser, pipe, transform } from \"valibot\";\n\nimport { vPublicSignUpWidgetSubmissionResponseDto } from \"./generated/public-api/valibot.gen.ts\";\nimport {\n customFieldsSchema,\n nonEmptyStringSchema,\n optionalNullableStringSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupFieldSchema = object({\n enabled: boolean(),\n required: boolean(),\n});\n\nexport const publicSignupSchema = pipe(\n object({\n config: object({\n builtInFields: object({\n address: signupFieldSchema,\n email: signupFieldSchema,\n name: signupFieldSchema,\n participantCount: signupFieldSchema,\n phone: signupFieldSchema,\n }),\n customFields: customFieldsSchema,\n }),\n coverImageUrl: optionalNullableStringSchema,\n description: optionalNullableStringSchema,\n id: nonEmptyStringSchema,\n isActive: boolean(),\n name: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n title: optionalNullableStringSchema,\n }),\n transform(({ config, ...signup }) => ({\n ...signup,\n customFields: config.customFields,\n fields: config.builtInFields,\n }))\n);\n\nexport const signupSubmissionResultSchema = pipe(\n vPublicSignUpWidgetSubmissionResponseDto,\n check(({ id }) => Boolean(id.trim()), \"Invalid signup submission ID.\")\n);\n\nexport const parsePublicSignup = parser(publicSignupSchema);\nexport const parseSignupSubmissionResult = parser(signupSubmissionResultSchema);\n","import { deepFreeze } from \"./deep-freeze.ts\";\nimport { resolveSignupEnvironment } from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { parseSignupSubmission } from \"./signup-input-schema.ts\";\nimport {\n parsePublicSignup,\n parseSignupSubmissionResult,\n} from \"./signup-schemas.ts\";\nimport type {\n CreateLockerverseSignupOptions,\n LockerverseSignupClient,\n LockerverseSignupSubmission,\n} from \"./signup-types.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport { LockerverseSdkError } from \"./types.ts\";\n\nfunction classifySubmissionError(\n error: unknown,\n requestAttempted: boolean,\n reportError: (error: LockerverseSdkError) => LockerverseSdkError\n) {\n if (error instanceof LockerverseSdkError) {\n return error;\n }\n return reportError(\n new LockerverseSdkError({\n code: \"signup_submit_failed\",\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\",\n recoveryRecommended: requestAttempted,\n reportable: requestAttempted,\n })\n );\n}\n\nexport function createLockerverseSignupClient(\n options: CreateLockerverseSignupOptions\n): LockerverseSignupClient {\n const runtime = resolveSignupEnvironment(options);\n const reportError = createSdkErrorReporter({\n communitySlug: runtime.communitySlugValue,\n environment: runtime.environment,\n getContext: () => ({ signupSlug: runtime.signupSlugValue }),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_signup\",\n sentryDsn: runtime.sentryDsn,\n });\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n (error) =>\n reportError(\n error.operation === \"submit_signup\" && !error.recoveryRecommended\n ? new LockerverseSdkError({\n code: error.code,\n message: error.message,\n operation: error.operation,\n recoveryRecommended: true,\n reportable: error.reportable,\n })\n : error\n ),\n runtime.requestTimeoutMs\n );\n const signupUrl = `${runtime.apiBaseUrl}/community/${runtime.communitySlug}/sign-up-widgets/${runtime.signupSlug}`;\n\n return {\n async load() {\n const errorContext = {\n code: \"signup_load_failed\" as const,\n message: \"Unable to load Lockerverse signup.\",\n operation: \"load_signup\" as const,\n };\n const signupResponse = await requestJson(\n signupUrl,\n undefined,\n parsePublicSignup,\n errorContext,\n errorContext\n );\n if (!signupResponse.ok) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n reportable: signupResponse.response.status >= 500,\n status: signupResponse.response.status,\n })\n );\n }\n return deepFreeze(signupResponse.value);\n },\n async submit(submission: LockerverseSignupSubmission, submitOptions) {\n const submissionReference =\n submitOptions?.submissionReference ?? globalThis.crypto.randomUUID();\n const errorContext = {\n code: \"signup_submit_failed\" as const,\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\" as const,\n };\n let parsedSubmission: ReturnType<typeof parseSignupSubmission>;\n try {\n parsedSubmission = parseSignupSubmission(submission);\n } catch {\n // biome-ignore lint/style/useErrorCause: Raw validation errors must not escape the SDK boundary.\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n message: \"Lockerverse signup input is invalid.\",\n reportable: false,\n })\n );\n }\n\n let requestAttempted = false;\n try {\n const body = JSON.stringify({\n ...parsedSubmission,\n submissionReference,\n });\n requestAttempted = true;\n const submissionResponse = await requestJson(\n `${signupUrl}/submissions`,\n {\n body,\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n },\n parseSignupSubmissionResult,\n errorContext,\n errorContext\n );\n if (!submissionResponse.ok) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: submissionResponse.response.status >= 500,\n reportable: submissionResponse.response.status >= 500,\n status: submissionResponse.response.status,\n })\n );\n }\n const result = deepFreeze(submissionResponse.value);\n if (result.id !== submissionReference) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: true,\n reportable: true,\n })\n );\n }\n return result;\n } catch (error) {\n throw classifySubmissionError(error, requestAttempted, reportError);\n }\n },\n };\n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ACE,OACA,QAAS,CAAE,eAAgB,kBAAmB,EAC9C,OAAQ,MACV,EACA,EACA,EACA,CACF,EACA,GAAI,CAAC,EAAmB,GACtB,MAAM,EACJ,IAAI,EAAoB,CACtB,GAAG,EACH,oBAAqB,EAAmB,SAAS,QAAU,IAC3D,WAAY,EAAmB,SAAS,QAAU,IAClD,OAAQ,EAAmB,SAAS,MACtC,CAAC,CACH,EAEF,IAAM,EAAS,EAAW,EAAmB,KAAK,EAClD,GAAI,EAAO,KAAO,EAChB,MAAM,EACJ,IAAI,EAAoB,CACtB,GAAG,EACH,oBAAqB,GACrB,WAAY,EACd,CAAC,CACH,EAEF,OAAO,CACT,OAAS,EAAO,CACd,MAAM,EAAwB,EAAO,EAAkB,CAAW,CACpE,CACF,CACF,CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ type LockerverseCheckoutQuote = LockerverseCheckoutAmounts & {
|
|
|
132
132
|
authoritative: true;
|
|
133
133
|
paymentReference: string;
|
|
134
134
|
payment: LockerverseCheckoutPaymentConfiguration;
|
|
135
|
-
paymentOption:
|
|
135
|
+
paymentOption: LockerversePaymentOption;
|
|
136
136
|
lineItems: LockerverseCheckoutLineItem[];
|
|
137
137
|
};
|
|
138
138
|
type LockerverseCheckoutPricingInput = {
|
|
@@ -178,6 +178,8 @@ type LockerverseCheckoutItem = {
|
|
|
178
178
|
} | {
|
|
179
179
|
productId: string;
|
|
180
180
|
amountCents: number;
|
|
181
|
+
} | {
|
|
182
|
+
productId: string;
|
|
181
183
|
};
|
|
182
184
|
type LockerverseCheckoutSelectionItem = {
|
|
183
185
|
productSlug: string;
|
|
@@ -185,6 +187,8 @@ type LockerverseCheckoutSelectionItem = {
|
|
|
185
187
|
} | {
|
|
186
188
|
productSlug: string;
|
|
187
189
|
amountCents: number;
|
|
190
|
+
} | {
|
|
191
|
+
productSlug: string;
|
|
188
192
|
};
|
|
189
193
|
type LockerverseBootstrapCheckoutInput = LockerverseCheckoutPricingInput & {
|
|
190
194
|
items: LockerverseCheckoutSelectionItem[];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAGY;KACA;cAEC;KAED;EACV;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,WAAW;EACX,SAAS;EACT,eAAe;EACf,UAAU;EACV,QAAQ;;KAGE;EACV;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;;KAGU,0CACV;EACE;;KAGQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EAAiC;EAAY;;KAEpD;EACH;EACA;EACA;;KAGU,6BAA6B;EACvC;;KAGU,qCAAqC;EAC/C,SAAS;EACT;;KAGU,oCAAoC;EAC9C,SAAS;EACT;;KAGU,yBACR,6BACA,qCACA;KAEQ,kCACV,cAAc,0BACZ,cAAc;KAEN,6BACV,cAAc,yBAAyB,0BACrC,cAAc;EACZ,SAAS;EAAa,OAAO,kCAAkC;;KAGzD;EACV,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;;KAGU;KAUA;cAUC,4BAA4B;WAC9B,MAAM;WACN,WAAW;WACX;WACA;WACA;WACA;EAEG,cACV,MACA,SACA,WACA,YACA,qBACA;IAEA,MAAM;IACN;IACA,WAAW;IACX;IACA;IACA;;;KAaQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B;EACrC,iBAAiB;EACjB;EACA;EACA,SAAS;EACT;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAGY;KACA;cAEC;KAED;EACV;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,WAAW;EACX,SAAS;EACT,eAAe;EACf,UAAU;EACV,QAAQ;;KAGE;EACV;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;;KAGU,0CACV;EACE;;KAGQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EAAiC;EAAY;;KAEpD;EACH;EACA;EACA;;KAGU,6BAA6B;EACvC;;KAGU,qCAAqC;EAC/C,SAAS;EACT;;KAGU,oCAAoC;EAC9C,SAAS;EACT;;KAGU,yBACR,6BACA,qCACA;KAEQ,kCACV,cAAc,0BACZ,cAAc;KAEN,6BACV,cAAc,yBAAyB,0BACrC,cAAc;EACZ,SAAS;EAAa,OAAO,kCAAkC;;KAGzD;EACV,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;;KAGU;KAUA;cAUC,4BAA4B;WAC9B,MAAM;WACN,WAAW;WACX;WACA;WACA;WACA;EAEG,cACV,MACA,SACA,WACA,YACA,qBACA;IAEA,MAAM;IACN;IACA,WAAW;IACX;IACA;IACA;;;KAaQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B;EACrC,iBAAiB;EACjB;EACA;EACA,SAAS;EACT,eAAe;EACf,WAAW;;KAGD;EACV;EACA;EACA;EACA;;KAGU;KAMA;EACV;EACA;EACA,gBAAgB;EAChB;EACA;EACA;EACA;;KAYU;EACV;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;KAGU;EACV;EACA,qBAAqB;EACrB;EACA;EACA;EACA,WAAW;EACX;EACA,WAAW;;KAGD;EACN;EAAmB;;EACnB;EAAmB;;EACnB;;KAEM;EACN;EAAqB;;EACrB;EAAqB;;EACrB;;KAEM,oCACV;EACE,OAAO;;KAGC,iCAAiC;EAC3C,OAAO;;KAGG,8BAA8B,SACxC;EACE,gBAAgB;EAChB,SAAS,SAAS;;KAIV,+BAA+B;EACzC,SAAS;EACT,UAAU;;KAGA;EACV,UAAU;EACV,YAAY;;KAGT;EACH;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;EACA;;KAGU,iCACV;EACE;EACA,cAAc;;KAGN;EACV,oBACE,OAAO,sCACJ,QAAQ;EACb,iBACE,OAAO,mCACJ,QAAQ;EACb,mBACE,6BACG,QAAQ;EACb,YAAY,QAAQ;EACpB,gBACE,OAAO,kCACJ,QAAQ"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=`0.2.
|
|
1
|
+
const e=`0.2.59`;var t=class extends Error{code;operation;reportable;recoveryRecommended;sdkVersion;status;constructor({code:t,message:n,operation:r,reportable:i,recoveryRecommended:a=!1,status:o}){super(n),this.name=`LockerverseSdkError`,this.code=t,this.operation=r,this.reportable=i,this.recoveryRecommended=a,this.sdkVersion=e,this.status=o}};export{t as n,e as t};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["packageMetadata.version"],"sources":["../package.json","../src/types.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\" with { type: \"json\" };\nimport type { GeneratedPaymentResult } from \"./generated/public-contract-types.ts\";\n\nexport type LockerversePaymentOption = \"one-time\" | \"monthly\" | \"annually\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\n\nexport const LOCKERVERSE_SDK_VERSION = packageMetadata.version;\n\nexport type LockerverseProduct = {\n id: string;\n listingId: string;\n slug: string;\n name: string;\n description: string | null;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n amountCents: number | null;\n minimumAmountCents: number | null;\n minimumQuantity: number | null;\n maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseCatalog = {\n community: LockerverseCommunityBranding | null;\n payment: LockerversePaymentConfiguration;\n pricingPolicy: LockerverseCheckoutPricingPolicy;\n products: LockerverseProduct[];\n widget: LockerverseWidgetConfiguration;\n};\n\nexport type LockerverseCommunityBranding = {\n accentColor: string;\n imageUrl: string;\n name: string;\n};\n\nexport type LockerverseCheckoutPricingPolicy = {\n currency: \"usd\";\n serviceFeeRateBasisPoints: number;\n};\n\nexport type LockerversePaymentConfiguration = {\n currency: \"usd\";\n publishableKey: string;\n};\n\nexport type LockerverseCheckoutPaymentConfiguration =\n LockerversePaymentConfiguration & {\n connectedAccountId: string | null;\n };\n\nexport type LockerverseWidgetFields = {\n memberId: boolean;\n merchSize: boolean;\n phone: boolean;\n promoCode: boolean;\n serviceFee: boolean;\n shipping: boolean;\n tipping: boolean;\n};\n\nexport type LockerverseCustomFieldOption = { id: string; label: string };\n\ntype LockerverseCustomFieldBase = {\n id: string;\n label: string;\n required: boolean;\n};\n\nexport type LockerverseTextCustomField = LockerverseCustomFieldBase & {\n type: \"text\" | \"textarea\";\n};\n\nexport type LockerverseSingleOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"radio\" | \"select\";\n};\n\nexport type LockerverseMultiOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"checkboxes\" | \"multi_select\";\n};\n\nexport type LockerverseCustomField =\n | LockerverseTextCustomField\n | LockerverseSingleOptionCustomField\n | LockerverseMultiOptionCustomField;\n\nexport type LockerverseCustomFieldAnswerValue<\n Field extends LockerverseCustomField,\n> = Field extends LockerverseMultiOptionCustomField ? string[] : string;\n\nexport type LockerverseCustomFieldAnswer<\n Field extends LockerverseCustomField = LockerverseCustomField,\n> = Field extends LockerverseCustomField\n ? { fieldId: Field[\"id\"]; value: LockerverseCustomFieldAnswerValue<Field> }\n : never;\n\nexport type LockerverseWidgetConfiguration = {\n customFields: LockerverseCustomField[];\n description: string | null;\n fields: LockerverseWidgetFields;\n id: string;\n name: string;\n showCommunityBranding: boolean;\n title: string | null;\n};\n\nexport type LockerverseSdkErrorCode =\n | \"checkout_bootstrap_failed\"\n | \"widget_load_failed\"\n | \"signup_load_failed\"\n | \"signup_submit_failed\"\n | \"total_calculation_failed\"\n | \"payment_submit_failed\"\n | \"payment_status_failed\"\n | \"invalid_selection\";\n\nexport type LockerverseSdkOperation =\n | \"bootstrap_checkout\"\n | \"load_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\"\n | \"update_selection\";\n\nexport class LockerverseSdkError extends Error {\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly status: number | undefined;\n\n constructor({\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n status,\n }: {\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n status?: number;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.status = status;\n }\n}\n\nexport type LockerverseCheckoutLineItem = {\n productId: string;\n productName: string;\n listingId: string;\n listingSlug: string;\n acceptsDiscounts: boolean;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n quantity: number;\n unitAmountCents: number;\n subtotalCents: number;\n};\n\nexport type LockerverseAppliedDiscount = {\n percentageOff: number;\n source: \"email_list\" | \"promo_code\";\n};\n\nexport type LockerverseCheckoutAmounts = {\n amountCents: number;\n discountableSubtotalCents: number;\n discountCents: number;\n serviceFeeCents: number;\n subtotalCents: number;\n tipCents: number;\n totalCents: number;\n};\n\nexport type LockerverseCheckoutQuote = LockerverseCheckoutAmounts & {\n appliedDiscount: LockerverseAppliedDiscount | null;\n authoritative: true;\n paymentReference: string;\n payment: LockerverseCheckoutPaymentConfiguration;\n paymentOption:
|
|
1
|
+
{"version":3,"file":"types.js","names":["packageMetadata.version"],"sources":["../package.json","../src/types.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\" with { type: \"json\" };\nimport type { GeneratedPaymentResult } from \"./generated/public-contract-types.ts\";\n\nexport type LockerversePaymentOption = \"one-time\" | \"monthly\" | \"annually\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\n\nexport const LOCKERVERSE_SDK_VERSION = packageMetadata.version;\n\nexport type LockerverseProduct = {\n id: string;\n listingId: string;\n slug: string;\n name: string;\n description: string | null;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n amountCents: number | null;\n minimumAmountCents: number | null;\n minimumQuantity: number | null;\n maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseCatalog = {\n community: LockerverseCommunityBranding | null;\n payment: LockerversePaymentConfiguration;\n pricingPolicy: LockerverseCheckoutPricingPolicy;\n products: LockerverseProduct[];\n widget: LockerverseWidgetConfiguration;\n};\n\nexport type LockerverseCommunityBranding = {\n accentColor: string;\n imageUrl: string;\n name: string;\n};\n\nexport type LockerverseCheckoutPricingPolicy = {\n currency: \"usd\";\n serviceFeeRateBasisPoints: number;\n};\n\nexport type LockerversePaymentConfiguration = {\n currency: \"usd\";\n publishableKey: string;\n};\n\nexport type LockerverseCheckoutPaymentConfiguration =\n LockerversePaymentConfiguration & {\n connectedAccountId: string | null;\n };\n\nexport type LockerverseWidgetFields = {\n memberId: boolean;\n merchSize: boolean;\n phone: boolean;\n promoCode: boolean;\n serviceFee: boolean;\n shipping: boolean;\n tipping: boolean;\n};\n\nexport type LockerverseCustomFieldOption = { id: string; label: string };\n\ntype LockerverseCustomFieldBase = {\n id: string;\n label: string;\n required: boolean;\n};\n\nexport type LockerverseTextCustomField = LockerverseCustomFieldBase & {\n type: \"text\" | \"textarea\";\n};\n\nexport type LockerverseSingleOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"radio\" | \"select\";\n};\n\nexport type LockerverseMultiOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"checkboxes\" | \"multi_select\";\n};\n\nexport type LockerverseCustomField =\n | LockerverseTextCustomField\n | LockerverseSingleOptionCustomField\n | LockerverseMultiOptionCustomField;\n\nexport type LockerverseCustomFieldAnswerValue<\n Field extends LockerverseCustomField,\n> = Field extends LockerverseMultiOptionCustomField ? string[] : string;\n\nexport type LockerverseCustomFieldAnswer<\n Field extends LockerverseCustomField = LockerverseCustomField,\n> = Field extends LockerverseCustomField\n ? { fieldId: Field[\"id\"]; value: LockerverseCustomFieldAnswerValue<Field> }\n : never;\n\nexport type LockerverseWidgetConfiguration = {\n customFields: LockerverseCustomField[];\n description: string | null;\n fields: LockerverseWidgetFields;\n id: string;\n name: string;\n showCommunityBranding: boolean;\n title: string | null;\n};\n\nexport type LockerverseSdkErrorCode =\n | \"checkout_bootstrap_failed\"\n | \"widget_load_failed\"\n | \"signup_load_failed\"\n | \"signup_submit_failed\"\n | \"total_calculation_failed\"\n | \"payment_submit_failed\"\n | \"payment_status_failed\"\n | \"invalid_selection\";\n\nexport type LockerverseSdkOperation =\n | \"bootstrap_checkout\"\n | \"load_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\"\n | \"update_selection\";\n\nexport class LockerverseSdkError extends Error {\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly status: number | undefined;\n\n constructor({\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n status,\n }: {\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n status?: number;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.status = status;\n }\n}\n\nexport type LockerverseCheckoutLineItem = {\n productId: string;\n productName: string;\n listingId: string;\n listingSlug: string;\n acceptsDiscounts: boolean;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n quantity: number;\n unitAmountCents: number;\n subtotalCents: number;\n};\n\nexport type LockerverseAppliedDiscount = {\n percentageOff: number;\n source: \"email_list\" | \"promo_code\";\n};\n\nexport type LockerverseCheckoutAmounts = {\n amountCents: number;\n discountableSubtotalCents: number;\n discountCents: number;\n serviceFeeCents: number;\n subtotalCents: number;\n tipCents: number;\n totalCents: number;\n};\n\nexport type LockerverseCheckoutQuote = LockerverseCheckoutAmounts & {\n appliedDiscount: LockerverseAppliedDiscount | null;\n authoritative: true;\n paymentReference: string;\n payment: LockerverseCheckoutPaymentConfiguration;\n paymentOption: LockerversePaymentOption;\n lineItems: LockerverseCheckoutLineItem[];\n};\n\nexport type LockerverseCheckoutPricingInput = {\n email?: string;\n includeServiceFee?: boolean;\n promoCode?: string;\n tipCents?: number;\n};\n\nexport type LockerversePaymentStatus =\n | \"action_required\"\n | \"failed\"\n | \"pending\"\n | \"success\";\n\nexport type LockerversePaymentResult = {\n checkoutId: string;\n paymentReference: string;\n checkoutStatus: LockerversePaymentStatus;\n clientSecret: string | null;\n paymentRequired: boolean;\n requiresAction: boolean;\n status: string | null;\n};\n\ntype AssertPaymentContract<T extends true> = T;\ntype _PaymentResultMatchesGenerated = AssertPaymentContract<\n LockerversePaymentResult extends GeneratedPaymentResult\n ? GeneratedPaymentResult extends LockerversePaymentResult\n ? true\n : false\n : false\n>;\n\nexport type LockerverseShipping = {\n address: {\n city: string;\n country: string;\n line1: string;\n line2?: string;\n postal_code: string;\n state: string;\n };\n name: string;\n};\n\nexport type LockerversePaymentSubmission = {\n confirmationToken?: string;\n customFieldAnswers?: LockerverseCustomFieldAnswer[];\n email: string;\n memberId?: string;\n merchSize?: \"XS\" | \"S\" | \"M\" | \"L\" | \"XL\" | \"XXL\" | \"XXXL\";\n metadata?: Record<string, string>;\n phone?: string;\n shipping?: LockerverseShipping;\n};\n\nexport type LockerverseCheckoutItem =\n | { productId: string; quantity: number }\n | { productId: string; amountCents: number }\n | { productId: string };\n\nexport type LockerverseCheckoutSelectionItem =\n | { productSlug: string; quantity: number }\n | { productSlug: string; amountCents: number }\n | { productSlug: string };\n\nexport type LockerverseBootstrapCheckoutInput =\n LockerverseCheckoutPricingInput & {\n items: LockerverseCheckoutSelectionItem[];\n };\n\nexport type LockerverseCalculateTotalInput = LockerverseCheckoutPricingInput & {\n items: LockerverseCheckoutItem[];\n};\n\nexport type LockerversePreparedCheckout = Readonly<\n LockerverseCheckoutQuote & {\n items: readonly LockerverseCheckoutItem[];\n pricing: Readonly<LockerverseCheckoutPricingInput>;\n }\n>;\n\nexport type LockerverseCheckoutBootstrap = Readonly<{\n catalog: LockerverseCatalog;\n checkout: LockerversePreparedCheckout;\n}>;\n\nexport type LockerverseSubmitPaymentInput = {\n checkout: LockerversePreparedCheckout;\n submission: LockerversePaymentSubmission;\n};\n\ntype CreateLockerverseWidgetBaseOptions = {\n communitySlug: string;\n fetch?: typeof globalThis.fetch;\n onError?: (error: LockerverseSdkError) => void;\n requestTimeoutMs?: number;\n sentryDsn?: string | null;\n widgetSlug: string;\n};\n\nexport type CreateLockerverseWidgetOptions =\n CreateLockerverseWidgetBaseOptions & {\n apiBaseUrl?: string;\n environment?: LockerverseEnvironment;\n };\n\nexport type LockerverseCheckoutClient = {\n bootstrapCheckout: (\n input: LockerverseBootstrapCheckoutInput\n ) => Promise<LockerverseCheckoutBootstrap>;\n calculateTotal: (\n input: LockerverseCalculateTotalInput\n ) => Promise<LockerversePreparedCheckout>;\n getPaymentStatus: (\n paymentReference: string\n ) => Promise<LockerversePaymentResult>;\n load: () => Promise<LockerverseCatalog>;\n submitPayment: (\n input: LockerverseSubmitPaymentInput\n ) => Promise<LockerversePaymentResult>;\n};\n"],"mappings":"ACMA,MAAa,EAA0BA,SA4HvC,IAAa,EAAb,cAAyC,KAAM,CAC7C,KACA,UACA,WACA,oBACA,WACA,OAEA,YAAY,CACV,OACA,UACA,YACA,aACA,sBAAsB,GACtB,UAQC,CACD,MAAM,CAAO,EACb,KAAK,KAAO,sBACZ,KAAK,KAAO,EACZ,KAAK,UAAY,EACjB,KAAK,WAAa,EAClB,KAAK,oBAAsB,EAC3B,KAAK,WAAa,EAClB,KAAK,OAAS,CAChB,CACF"}
|