@lockerverse/sdk 0.2.239 → 0.2.242
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/MIGRATIONS.md +15 -0
- package/README.md +12 -0
- package/dist/checkout.d.ts +10 -1
- package/dist/checkout.d.ts.map +1 -1
- package/dist/checkout.js +1 -1
- package/dist/checkout.js.map +1 -1
- package/dist/types.d.ts +1 -0
- 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/MIGRATIONS.md
CHANGED
|
@@ -4,6 +4,21 @@ This file ships in both @lockerverse/sdk and @lockerverse/react. Use the copy in
|
|
|
4
4
|
the target installed release. This is an agent-run procedure, not an install
|
|
5
5
|
script. Installing a package does not edit host code or guarantee these steps ran.
|
|
6
6
|
|
|
7
|
+
## 0.2.242 — product availability on custom pages
|
|
8
|
+
|
|
9
|
+
Custom checkout and hosted-payment pages should use
|
|
10
|
+
`getLockerverseProductAvailability(catalog, product, quantities)` from
|
|
11
|
+
`@lockerverse/sdk/checkout` for each product. Use the returned status for
|
|
12
|
+
the card and maximum quantity for its controls. The standard React launcher
|
|
13
|
+
adopts the helper automatically on upgrade. Verify that a package too large
|
|
14
|
+
for the remaining shared capacity shows **Sold out**, a package blocked by
|
|
15
|
+
other items in the cart shows **Limit reached**, and removing those items
|
|
16
|
+
restores availability.
|
|
17
|
+
|
|
18
|
+
## Shared ticket capacity
|
|
19
|
+
|
|
20
|
+
Checkout uses the configured number of spots for each package. Hosts that use the standard launcher need no code changes after upgrading. Earlier custom carts could calculate capacity from listing weights. Use the public availability helper on newer releases.
|
|
21
|
+
|
|
7
22
|
## 0.2.237 — signup address suggestions
|
|
8
23
|
|
|
9
24
|
- **Automatic:** `LockerverseSignup` uses the city and state entered in the form when searching streets. A search can start with a street alone. Empty results and service failures explain how to continue with manual entry.
|
package/README.md
CHANGED
|
@@ -29,6 +29,18 @@ complete an upgrade. Record the old installed versions before installation.
|
|
|
29
29
|
|
|
30
30
|
## Checkout
|
|
31
31
|
|
|
32
|
+
For a custom ticket page or cart, load the current catalog and call
|
|
33
|
+
`getLockerverseProductAvailability(catalog, product, quantities)` from
|
|
34
|
+
`@lockerverse/sdk/checkout` for each product. Pass a map of selected package
|
|
35
|
+
quantities keyed by product ID. Use nonnegative safe integers. The helper returns `maximumQuantity` (the
|
|
36
|
+
total that fits with other selected items, or null for unlimited) and `status`:
|
|
37
|
+
`available`, `sold_out` when the minimum order cannot fit even in an empty
|
|
38
|
+
cart, or `limit_reached` when the current selections prevent adding another.
|
|
39
|
+
Keep sold-out products visible and disable adding them. Allow removing selected
|
|
40
|
+
items and checking out a valid cart at its limit. Refresh the catalog after a
|
|
41
|
+
sold-out response from checkout.
|
|
42
|
+
|
|
43
|
+
|
|
32
44
|
```ts
|
|
33
45
|
import { createLockerverseCheckoutClient } from "@lockerverse/sdk/checkout";
|
|
34
46
|
|
package/dist/checkout.d.ts
CHANGED
|
@@ -8,5 +8,14 @@ declare function estimateLockerverseCheckout(catalog: LockerverseCatalog, input:
|
|
|
8
8
|
//#region src/custom-amount.d.ts
|
|
9
9
|
declare function getLockerverseMinimumCustomAmountCents(product: Pick<LockerverseProduct, "minimumAmountCents">): number;
|
|
10
10
|
//#endregion
|
|
11
|
-
|
|
11
|
+
//#region src/product-availability.d.ts
|
|
12
|
+
type LockerverseProductAvailability = {
|
|
13
|
+
/** Total quantity of this product that fits with the other selected items. */
|
|
14
|
+
maximumQuantity: number | null;
|
|
15
|
+
status: "available" | "limit_reached" | "sold_out";
|
|
16
|
+
};
|
|
17
|
+
/** Pass nonnegative integer package quantities keyed by product ID, or omit them for an empty cart. */
|
|
18
|
+
declare function getLockerverseProductAvailability(catalog: LockerverseCatalog, product: LockerverseProduct, quantities?: Readonly<Record<string, number>>): LockerverseProductAvailability;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CreateLockerverseWidgetOptions, LOCKERVERSE_SDK_VERSION, LockerverseAppliedDiscount, LockerverseAvailabilityStatus, LockerverseBooleanCustomField, LockerverseCalculateTotalInput, LockerverseCatalog, LockerverseCatalogAvailability, LockerverseCheckoutAmounts, LockerverseCheckoutClient, LockerverseCheckoutEstimate, LockerverseCheckoutItem, LockerverseCheckoutLineItem, LockerverseCheckoutPricingInput, LockerverseCheckoutPricingPolicy, LockerverseCheckoutQuote, LockerverseCheckoutSelectionItem, LockerverseCommunityBranding, LockerverseCustomField, LockerverseCustomFieldAnswer, LockerverseCustomFieldAnswerValue, LockerverseCustomFieldOption, LockerverseEnvironment, LockerverseEstimateCheckoutInput, LockerverseEvent, LockerverseFulfillmentType, LockerverseLoadCheckoutInput, LockerverseLoadedCheckout, LockerverseMultiOptionCustomField, LockerversePaymentCompletion, LockerversePaymentConfiguration, LockerversePaymentOption, LockerversePaymentResult, LockerversePaymentStatus, LockerversePaymentSubmission, LockerversePreparedCheckout, LockerverseProduct, type LockerverseProductAvailability, LockerverseResourceEnvironmentOptions, LockerverseSdkError, LockerverseSdkErrorCode, LockerverseSdkFailureKind, LockerverseSdkOperation, LockerverseSdkServerCode, LockerverseShipping, LockerverseSingleOptionCustomField, LockerverseSubmitPaymentInput, LockerverseTextCustomField, LockerverseWidgetConfiguration, LockerverseWidgetFields, createLockerverseCheckoutClient, estimateLockerverseCheckout, getLockerverseMinimumCustomAmountCents, getLockerverseProductAvailability };
|
|
12
21
|
//# sourceMappingURL=checkout.d.ts.map
|
package/dist/checkout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","names":[],"sources":["../src/checkout-client.ts","../src/checkout-estimate.ts","../src/custom-amount.ts"],"mappings":";;iBAgHgB,gCACd,SAAS,iCACR;;;iBCzGa,4BACd,SAAS,oBACT,OAAO,mCACN;;;iBCRa,uCACd,SAAS,KAAK"}
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","names":[],"sources":["../src/checkout-client.ts","../src/checkout-estimate.ts","../src/custom-amount.ts","../src/product-availability.ts"],"mappings":";;iBAgHgB,gCACd,SAAS,iCACR;;;iBCzGa,4BACd,SAAS,oBACT,OAAO,mCACN;;;iBCRa,uCACd,SAAS,KAAK;;;KCHJ;;EAEV;EACA;;;iBA2Bc,kCACd,SAAS,oBACT,SAAS,oBACT,aAAY,SAAS,0BACpB"}
|
package/dist/checkout.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./schema-helpers.js";import{i as a,n as o,o as s,t as c}from"./transport.js";import{n as l,t as u}from"./types.js";import{n as d,r as f,t as p}from"./valibot.gen.js";import{array as m,boolean as h,check as g,finite as _,literal as v,looseObject as y,maxValue as b,minLength as x,minValue as S,nullable as C,number as w,object as T,optional as E,parser as D,picklist as O,pipe as k,record as ee,regex as A,safeParse as j,strictObject as M,string as N,transform as P,union as F,unknown as I,variant as te}from"valibot";function ne(e){let t=a(e,`widgetSlug`);return{...t,widgetSlug:t.resourceSlug,widgetSlugValue:t.resourceSlugValue}}const L=O([`one-time`,`monthly`,`annually`,`every-six-months`]),R=O([`none`,`event_admission`]),z=C(e(0)),re=O([`available`,`sold_out`]),ie=E(T({listings:m(T({listingId:r,maxPurchasableQuantity:z,remainingQuantity:z,status:re})),sharedLimits:m(T({id:r,listingIds:m(r),remainingQuantity:e(0),status:re}))}),{listings:[],sharedLimits:[]}),ae=k(N(),A(/^pk_(?:test|live)_\S+$/,`Invalid publishable key.`)),B={description:t,fulfillmentType:R,id:r,inventoryQuantity:z,maxQuantity:z,minimumAmountCents:z,minQuantity:z,name:r,paymentOption:L},V=T({description:C(N()),endAt:r,id:r,location:C(N()),name:r,startAt:r,status:O([`draft`,`active`,`finished`,`cancelled`])}),oe=te(`pricingMode`,[T({...B,amountCents:e(0),pricingMode:v(`fixed`)}),T({...B,amountCents:z,pricingMode:v(`custom`)})]),se=T({acceptsDiscounts:E(h(),!1),id:r,maxQuantityPerOrder:E(z,null),product:oe,productId:r,slug:r}),H=E(T({memberId:E(h(),!1),merchSize:E(h(),!1),phone:E(h(),!1),promoCode:E(h(),!1),serviceFee:E(h(),!1),shipping:E(h(),!1),tipping:E(h(),!1)}),{}),U=E(T({additionalUnitAmountCents:E(k(e(0),b(2147483647))),productId:r,triggerProductIds:m(r)})),ce=k(T({availability:ie,community:E(T({color:N(),memberIdLabel:E(C(N())),name:r,thumbnail:C(N()),widgetAchEnabled:E(h())})),config:E(T({customFields:n,fields:H,requiredShipping:U})),description:t,event:C(V),id:E(N(),``),name:E(N(),`Lockerverse widget`),payment:T({connectedAccountId:E(C(r),null),currency:v(`usd`),publishableKey:ae}),pricingPolicy:E(T({currency:E(v(`usd`),`usd`),serviceFeeRateBasisPoints:E(e(0),0)})),products:E(m(se),[]),showCommunityBranding:E(h(),!0),title:t}),P(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},requiredShipping:e.config?.requiredShipping},pricingPolicy:e.pricingPolicy??{currency:`usd`,serviceFeeRateBasisPoints:0}}))),le=T({acceptsDiscounts:h(),amountCents:C(e(0)),description:C(N()),fulfillmentType:R,id:r,inventoryQuantity:z,listingId:r,maximumQuantity:z,minimumAmountCents:z,minimumQuantity:z,name:r,paymentOption:L,pricingMode:O([`fixed`,`custom`]),slug:r}),ue=T({availability:ie,community:C(T({accentColor:N(),imageUrl:C(N()),memberIdLabel:E(C(N())),name:r,widgetAchEnabled:E(h())})),event:C(V),payment:T({connectedAccountId:E(C(r),null),currency:v(`usd`),publishableKey:ae}),pricingPolicy:T({currency:v(`usd`),serviceFeeRateBasisPoints:e(0)}),products:m(le),widget:T({customFields:n,description:C(N()),fields:H,id:N(),name:r,requiredShipping:U,showCommunityBranding:h(),title:C(N())})}),de=C(T({amountOffCents:E(e(0)),message:E(N()),percentageOff:E(k(w(),_(),S(0),b(100))),source:O([`email_list`,`promo_code`])})),fe=T({acceptsDiscounts:h(),eventId:C(r),fulfillmentType:R,listingId:r,listingSlug:r,paymentOption:L,pricingMode:O([`fixed`,`custom`]),productId:r,productName:r,quantity:e(1),subtotalCents:e(0),unitAmountCents:e(0)}),pe=k(d,T({amountCents:e(0),appliedDiscount:de,connectedAccountId:C(r),discountableSubtotalCents:e(0),discountCents:e(0),lineItems:m(fe),paymentOption:L,serviceFeeCents:e(0),subtotalCents:e(0),tipCents:e(0),totalCents:e(0)}),g(({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.`)),me=k(T({...p.entries,retryUrl:E(k(r,A(/^https:\/\//)))}),g(e=>e.checkoutId.trim()&&e.paymentReference.trim()?e.checkoutStatus===`action_required`?e.paymentRequired&&(e.requiresAction&&!!e.clientSecret?.trim()||!e.requiresAction&&e.clientSecret===null&&!!e.retryUrl):!e.requiresAction&&e.clientSecret===null:!1,`Invalid payment result state.`)),W=D(pe),he=D(ue),G=D(me),ge=D(f),_e=D(ce);function ve(e){return ge(e),_e(e)}function ye(e){let t=j(y({quote:E(I())}),e),n=ve(e),r=t.success?t.output.quote:void 0;return r===void 0?{widget:n}:{quote:W(r),widget:n}}const be={email:E(N()),includeServiceFee:E(h()),promoCode:E(N()),tipCents:E(e(0))},K=M(be),q=D(E(K,{})),xe=M({confirmationToken:E(r),customFieldAnswers:E(m(i)),email:N(),memberId:E(N()),merchSize:E(O([`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`])),metadata:E(ee(N(),N())),paymentMethodConfiguration:E(v(`explicit`)),phone:E(N()),shipping:E(M({address:M({city:N(),country:N(),line1:N(),line2:E(N()),postal_code:N(),state:N()}),name:N()}))}),Se=F([M({amountCents:e(1),productId:r}),M({productId:r,quantity:e(1)}),M({productId:r})]),Ce=F([M({amountCents:e(1),productSlug:r}),M({productSlug:r,quantity:e(1)}),M({productSlug:r})]),J=k(m(Se),x(1)),Y=k(m(Ce),x(1)),we=T({selection:Y}),Te=y({catalog:E(I()),email:E(I()),includeServiceFee:E(I()),items:E(J),promoCode:E(I()),selection:E(Y),tipCents:E(I())}),Ee=k(y({authoritative:v(!0),items:J,payment:T({connectedAccountId:C(r),currency:v(`usd`),publishableKey:k(N(),x(1))}),paymentReference:k(N(),x(1)),pricing:K}),P(e=>{let{items:t,payment:n,paymentReference:r,pricing:i,...a}=e,o=W({...a,connectedAccountId:n.connectedAccountId}),{connectedAccountId:s,...c}=o;return{items:t,pricing:i,quote:{...c,authoritative:!0,payment:{connectedAccountId:s,currency:`usd`,publishableKey:n.publishableKey},paymentOption:o.paymentOption,paymentReference:r}}})),De=y({checkout:Ee,submission:xe}),Oe=r,ke=D(y({})),Ae=D(Te);function je(e){let{catalog:t,items:n,selection:r,...i}=Ae(e),a;try{a=ke(t)}catch(e){throw TypeError(`A catalog is required to calculate a checkout.`,{cause:e})}try{return{catalog:a,items:n,pricing:q(i),selection:r}}catch(e){throw TypeError(`Checkout pricing input is invalid.`,{cause:e})}}const Me=D(we),Ne=D(Oe);D(Ee);const Pe=D(De),Fe=D(Y);function Ie(e){return Math.max(100,e.minimumAmountCents??0)}function Le(e,t){let n=new Map(e.products.map(({id:e,listingId:t})=>[e,t])),r=t.reduce((e,t)=>{let r=n.get(t.productId);return r&&e.set(r,(e.get(r)??0)+(`quantity`in t?t.quantity??1:1)),e},new Map),i=e.availability.listings.some(({listingId:e,maxPurchasableQuantity:t,status:n})=>r.has(e)&&(n===`sold_out`||t!==null&&(r.get(e)??0)>t)),a=e.availability.sharedLimits.some(({listingIds:e,remainingQuantity:t,status:n})=>{let i=e.reduce((e,t)=>e+(r.get(t)??0),0);return i>0&&(n===`sold_out`||i>t)});if(i||a)throw new l({code:`total_calculation_failed`,message:`This option is sold out.`,operation:`calculate_total`,reportable:!1,serverCode:`PAYMENT_WIDGET_SALES_LIMIT_REACHED`})}function Re(e,t){if(e.pricingMode!==`custom`||e.paymentOption!==`one-time`||t<Ie(e))throw TypeError(`Selected Product amount is invalid.`);return{checkoutItem:{amountCents:t,productId:e.id},quantity:1,unitAmountCents:t}}function ze(e,t){if(e.pricingMode!==`fixed`||e.amountCents===null)throw TypeError(`Selected Product quantity is invalid.`);if(e.paymentOption!==`one-time`&&t!==1)throw TypeError(`Selected recurring Product is invalid.`);if(e.minimumQuantity!==null&&t<e.minimumQuantity||e.maximumQuantity!==null&&t>e.maximumQuantity||e.inventoryQuantity!==null&&t>e.inventoryQuantity)throw TypeError(`Selected Product quantity is invalid.`);return{checkoutItem:e.paymentOption===`one-time`?{productId:e.id,quantity:t}:{productId:e.id},quantity:t,unitAmountCents:e.amountCents}}function Be(e,t,n){let r=`quantity`in n?n.quantity:1,{checkoutItem:i,quantity:a,unitAmountCents:o}=`amountCents`in n?Re(t,n.amountCents):ze(t,r);return{checkoutItem:i,lineItem:{acceptsDiscounts:t.acceptsDiscounts,eventId:t.fulfillmentType===`event_admission`&&e.event?e.event.id:null,fulfillmentType:t.fulfillmentType,listingId:t.listingId,listingSlug:t.slug,paymentOption:t.paymentOption,pricingMode:t.pricingMode,productId:t.id,productName:t.name,quantity:a,subtotalCents:o*a,unitAmountCents:o}}}function X(e,t){let n=Fe(t),r=e.widget.requiredShipping;if(r){let t=e.products.find(({id:e})=>e===r.productId),i=n.some(t=>e.products.some(e=>e.slug===t.productSlug&&r.triggerProductIds.includes(e.id)));if(n=n.filter(e=>e.productSlug!==t?.slug),i){if(!t)throw TypeError(`Required shipping Product is unavailable.`);n.push({productSlug:t.slug,quantity:1})}}let i=new Set,a=n.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);if(!n)throw TypeError(`Selected Product is unavailable.`);if(i.has(n.id))throw TypeError(`Each Product can appear only once per checkout.`);return i.add(n.id),Be(e,n,t)});if(r?.additionalUnitAmountCents){let e=a.reduce((e,{lineItem:t})=>e+(r.triggerProductIds.includes(t.productId)?t.quantity:0),0),t=a.find(({lineItem:e})=>e.productId===r.productId)?.lineItem;if(t){let n=t.unitAmountCents+Math.max(0,e-1)*r.additionalUnitAmountCents;if(!Number.isSafeInteger(n)||n>2147483647)throw TypeError(`Required shipping amount is invalid.`);t.unitAmountCents=n,t.subtotalCents=n}}let o=a[0]?.lineItem.paymentOption;if(!o)throw TypeError(`Select at least one Product.`);if(a.length>1&&(o!==`one-time`||a.some(({lineItem:e})=>e.paymentOption!==o)))throw TypeError(`Recurring Products must be purchased separately.`);let s=a.map(({checkoutItem:e})=>e);return Le(e,s),{items:s,lineItems:a.map(({lineItem:e})=>e),paymentOption:o}}function Ve(e){let{product:t}=e;return{acceptsDiscounts:e.acceptsDiscounts??!1,amountCents:t.amountCents,description:t.description??null,fulfillmentType:t.fulfillmentType,id:t.id,inventoryQuantity:t.inventoryQuantity,listingId:e.id,maximumQuantity:e.maxQuantityPerOrder,minimumAmountCents:t.minimumAmountCents,minimumQuantity:t.minQuantity,name:t.name,paymentOption:t.paymentOption,pricingMode:t.pricingMode,slug:e.slug}}function He(e){if(!e)return null;let t={accentColor:e.color,imageUrl:e.thumbnail||null,name:e.name};return e.widgetAchEnabled!==void 0&&(t.widgetAchEnabled=e.widgetAchEnabled),e.memberIdLabel!==void 0&&(t.memberIdLabel=e.memberIdLabel),t}function Ue(e){let t=e.config?.fields??{};return{availability:e.availability,community:He(e.community),event:e.event?{description:e.event.description,endAt:e.event.endAt,id:e.event.id,location:e.event.location,name:e.event.name,startAt:e.event.startAt,status:e.event.status}:null,payment:{connectedAccountId:e.payment.connectedAccountId,currency:e.payment.currency,publishableKey:e.payment.publishableKey},pricingPolicy:{currency:`usd`,serviceFeeRateBasisPoints:e.pricingPolicy?.serviceFeeRateBasisPoints??0},products:(e.products??[]).map(Ve),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`,requiredShipping:e.config?.requiredShipping,showCommunityBranding:e.showCommunityBranding??!0,title:e.title??null}}}function Z(e){return Q(e)}function We(e){return Q(e)}function Ge(e){return Q(e)}function Q(e){return s(structuredClone(e))}const Ke=T({code:O([`PAYMENT_WIDGET_PHONE_INVALID`,`PAYMENT_WIDGET_PHONE_REQUIRED`,`PAYMENT_WIDGET_SALES_LIMIT_REACHED`])});async function $(e){if(e.status===400||e.status===409)try{let t=j(Ke,await e.json());return t.success?t.output.code:void 0}catch{}}function qe({catalog:e,items:t,selection:n}){if(t!==void 0&&n!==void 0)throw TypeError(`Use items or selection, not both.`);let r=Z(he(e)),i=n===void 0?Je(t):X(r,n).items;return Le(r,i),{catalog:r,items:i}}function Je(e){if(e===void 0)throw TypeError(`Checkout selection is invalid.`);return e}function Ye(e){let{apiBaseUrl:t,communitySlug:n,communitySlugValue:r,environment:i,fetchImplementation:a,onError:u,requestTimeoutMs:d,sentryDsn:f,widgetSlug:p,widgetSlugValue:m}=ne(e),h=o({communitySlug:r,environment:i,getContext:()=>({widgetSlug:m}),onError:u,resourceContextName:`lockerverse_widget`,sentryDsn:f}),{requestJson:g}=c(a,h,d),_=`${t}/v2/community/${n}/payment-widgets/${p}/checkout`,v=`${t}/v2/community/${n}/payment-widgets/${p}`;function y(e,t,n=`invalid_selection`){throw h(new l({code:n,message:e,operation:t,reportable:!1}))}function b(e,t){return e instanceof l?e:new l({...t,reportable:!0})}function x(e,t,n=!1){let r=b(e,t);if(!(n&&(r.status===void 0||r.status>=500)))throw h(r);let i=new l({code:r.code,failureKind:r.failureKind,message:r.message,operation:r.operation,recoveryRecommended:!0,reportable:r.reportable,status:r.status});throw h(i)}function S(e){let t=e.email?.trim().toLowerCase(),n=e.promoCode?.trim(),r={};return t&&(r.email=t),e.includeServiceFee!==void 0&&(r.includeServiceFee=e.includeServiceFee),n&&(r.promoCode=n),e.tipCents!==void 0&&(r.tipCents=e.tipCents),r}function C(e){try{return Me(e).selection}catch{y(`Checkout selection is invalid.`,`load_widget`)}}function w(e,t,n,r){let{connectedAccountId:i,...a}=e;return We(s({...a,authoritative:!0,items:t,payment:{connectedAccountId:i,currency:`usd`,publishableKey:r.publishableKey},paymentOption:e.paymentOption,paymentReference:globalThis.crypto.randomUUID(),pricing:n}))}function T(e,t,n){try{return X(e,t).items}catch(e){throw e instanceof TypeError&&y(e.message,n),e}}function E(e,t,n,r){if(!n)throw new l({...r,message:`Lockerverse did not return the requested initial quote.`,reportable:!0});let i=T(e,t,r.operation);return s({catalog:Z(e),checkout:w(n,i,{includeServiceFee:e.widget.fields.serviceFee},e.payment)})}async function D(e){let t={code:`widget_load_failed`,message:`Lockerverse returned an invalid widget catalog.`,operation:`load_widget`},n=e?`${v}?selection=${encodeURIComponent(JSON.stringify(e))}`:v,r=()=>g(n,e?{cache:`no-store`}:void 0,ye,{...t,message:`Unable to load Lockerverse widget because the request failed.`,report:!1},{...t,report:!1},$);async function i(){try{return await r()}catch(e){if(!(e instanceof l)||e.failureKind!==`network`&&e.failureKind!==`timeout`)throw e}return r()}let a=await i();if(!a.ok){let e=a.errorValue;throw e===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`?new l({...t,message:`This option is sold out.`,reportable:!1,serverCode:e,status:a.response.status}):new l({...t,message:`Unable to load Lockerverse widget (${a.response.status}).`,reportable:a.response.status>=500,status:a.response.status})}let o=s(Ue(a.value.widget));return e?E(o,e,a.value.quote,t):Z(o)}async function O(e,t){let n=await D(),r={includeServiceFee:n.widget.fields.serviceFee},i=T(n,e,t.operation);return s({catalog:n,checkout:await A(i,r,n.payment,t)})}async function k(e){let t={code:`widget_load_failed`,message:`Lockerverse returned an invalid widget catalog.`,operation:`load_widget`};try{return e&&`${v}?selection=${encodeURIComponent(JSON.stringify(e))}`.length>4e3?await O(e,t):e?await D(e):await D()}catch(e){x(e,t)}}function ee(e){return e===void 0?k():k(C(e))}async function A(e,t,n,r){let i=await g(`${_}/quote`,{body:JSON.stringify({...t,items:e}),headers:{"Content-Type":`application/json`},method:`POST`},W,{...r,message:`Unable to calculate the Lockerverse checkout total because the request failed.`,report:!1},{...r,report:!1},$);if(!i.ok){let e=i.errorValue;throw e===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`?new l({...r,message:`This option is sold out.`,reportable:!1,serverCode:e,status:i.response.status}):new l({...r,message:`Unable to calculate the Lockerverse checkout total (${i.response.status}).`,reportable:i.response.status>=500,status:i.response.status})}return w(i.value,e,t,n)}async function j(e){let{catalog:t,items:n,pricing:r}=M(e),i={code:`total_calculation_failed`,message:`Lockerverse returned an invalid checkout total.`,operation:`calculate_total`};try{return await A(n,r,t.payment,i)}catch(e){x(e,i)}}function M(e){try{let t=je(e),n=qe(t),r=S(t.pricing);return{catalog:n.catalog,items:n.items,pricing:r.includeServiceFee===void 0?{...r,includeServiceFee:n.catalog.widget.fields.serviceFee}:r}}catch(e){if(e instanceof l)throw e;y(e instanceof TypeError?e.message:`Checkout selection is invalid.`,`calculate_total`)}}function N(e){try{let t=Pe(e),{items:n,pricing:r,quote:i}=t.checkout,a=S(r),o=s(i),{submission:c}=t;o.totalCents>0&&!c.confirmationToken&&y(`Stripe confirmation is required for a paid checkout.`,`submit_payment`,`payment_submit_failed`);let l=c.email.trim().toLowerCase();return(!l||l!==a.email)&&y(`Payment email must match the current checkout quote.`,`submit_payment`),{items:n,pricing:a,quote:o,submission:{...c,email:l}}}catch(e){if(e instanceof l)throw e;y(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}return{calculateTotal:j,async getPaymentStatus(e){let t;try{t=Ne(e).trim()}catch{y(`Provide a payment reference to recover its status.`,`get_payment_status`)}let n={code:`payment_status_failed`,message:`Lockerverse returned an invalid payment status.`,operation:`get_payment_status`};try{let e=await g(`${_}/${encodeURIComponent(t)}/status`,void 0,G,{...n,message:`Unable to recover the Lockerverse payment status because the request failed.`,report:!1},{...n,report:!1});if(!e.ok)throw new l({...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 l({...n,reportable:!0});return Ge(e.value)}catch(e){x(e,n)}},load:ee,async submitPayment(e){let{items:t,pricing:n,quote:r,submission:i}=N(e),a={code:`payment_submit_failed`,message:`Lockerverse returned an invalid payment confirmation.`,operation:`submit_payment`};try{let e=await g(`${_}/confirm`,{body:JSON.stringify({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,paymentMethodConfiguration:i.paymentMethodConfiguration,paymentReference:r.paymentReference,phone:i.phone,quoteContractVersion:1,shipping:i.shipping}),headers:{"Content-Type":`application/json`},method:`POST`},G,{...a,message:`Unable to submit the Lockerverse payment because the request failed.`,report:!1},{...a,report:!1},$);if(!e.ok){let t=e.errorValue;throw t?new l({...a,message:t===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`?`This option is sold out.`:`Unable to submit the Lockerverse payment (${e.response.status}).`,reportable:!1,serverCode:t,status:e.response.status}):new l({...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 l({...a,reportable:!0});return Ge(e.value)}catch(e){x(e,a,!0)}}}}function Xe(e,t){let{selection:n,...r}=t,i;try{i=q(r)}catch(e){throw TypeError(`Checkout pricing is invalid.`,{cause:e})}let a=i.includeServiceFee??e.widget.fields.serviceFee,{tipCents:o=0}=i,{items:c,lineItems:l,paymentOption:u}=X(e,n),d=l.reduce((e,t)=>e+t.subtotalCents,0);if(!Number.isSafeInteger(d)||d<=0||d>2147483647)throw TypeError(`Checkout total is invalid.`);let f=l.reduce((e,t)=>e+(t.acceptsDiscounts?t.subtotalCents:0),0),p=a?Math.round(d*e.pricingPolicy.serviceFeeRateBasisPoints/1e4):0,m=d+p,h=m+o;if(!Number.isSafeInteger(h)||h>2147483647)throw TypeError(`Checkout total is invalid.`);return s({amountCents:m,appliedDiscount:null,authoritative:!1,discountableSubtotalCents:f,discountCents:0,items:c,lineItems:l,paymentOption:u,serviceFeeCents:p,subtotalCents:d,tipCents:o,totalCents:h})}export{u as LOCKERVERSE_SDK_VERSION,l as LockerverseSdkError,Ye as createLockerverseCheckoutClient,Xe as estimateLockerverseCheckout,Ie as getLockerverseMinimumCustomAmountCents};
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./schema-helpers.js";import{i as a,n as o,o as s,t as c}from"./transport.js";import{n as l,t as u}from"./types.js";import{n as d,r as f,t as p}from"./valibot.gen.js";import{array as m,boolean as h,check as g,finite as _,literal as v,looseObject as y,maxValue as b,minLength as x,minValue as S,nullable as C,number as w,object as T,optional as E,parser as D,picklist as O,pipe as k,record as A,regex as j,safeParse as M,strictObject as N,string as P,transform as F,union as I,unknown as L,variant as ee}from"valibot";function te(e){let t=a(e,`widgetSlug`);return{...t,widgetSlug:t.resourceSlug,widgetSlugValue:t.resourceSlugValue}}const R=O([`one-time`,`monthly`,`annually`,`every-six-months`]),z=O([`none`,`event_admission`]),B=C(e(0)),V=O([`available`,`sold_out`]),H=E(T({listings:m(T({listingId:r,maxPurchasableQuantity:B,remainingQuantity:B,status:V})),sharedLimits:m(T({id:r,listingIds:m(r),listingWeights:E(A(r,e(1)),{}),remainingQuantity:e(0),status:V}))}),{listings:[],sharedLimits:[]}),U=k(P(),j(/^pk_(?:test|live)_\S+$/,`Invalid publishable key.`)),W={description:t,fulfillmentType:z,id:r,inventoryQuantity:B,maxQuantity:B,minimumAmountCents:B,minQuantity:B,name:r,paymentOption:R},G=T({description:C(P()),endAt:r,id:r,location:C(P()),name:r,startAt:r,status:O([`draft`,`active`,`finished`,`cancelled`])}),ne=ee(`pricingMode`,[T({...W,amountCents:e(0),pricingMode:v(`fixed`)}),T({...W,amountCents:B,pricingMode:v(`custom`)})]),re=T({acceptsDiscounts:E(h(),!1),id:r,maxQuantityPerOrder:E(B,null),product:ne,productId:r,slug:r}),K=E(T({memberId:E(h(),!1),merchSize:E(h(),!1),phone:E(h(),!1),promoCode:E(h(),!1),serviceFee:E(h(),!1),shipping:E(h(),!1),tipping:E(h(),!1)}),{}),q=E(T({additionalUnitAmountCents:E(k(e(0),b(2147483647))),productId:r,triggerProductIds:m(r)})),ie=k(T({availability:H,community:E(T({color:P(),memberIdLabel:E(C(P())),name:r,thumbnail:C(P()),widgetAchEnabled:E(h())})),config:E(T({customFields:n,fields:K,requiredShipping:q})),description:t,event:C(G),id:E(P(),``),name:E(P(),`Lockerverse widget`),payment:T({connectedAccountId:E(C(r),null),currency:v(`usd`),publishableKey:U}),pricingPolicy:E(T({currency:E(v(`usd`),`usd`),serviceFeeRateBasisPoints:E(e(0),0)})),products:E(m(re),[]),showCommunityBranding:E(h(),!0),title:t}),F(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},requiredShipping:e.config?.requiredShipping},pricingPolicy:e.pricingPolicy??{currency:`usd`,serviceFeeRateBasisPoints:0}}))),ae=T({acceptsDiscounts:h(),amountCents:C(e(0)),description:C(P()),fulfillmentType:z,id:r,inventoryQuantity:B,listingId:r,maximumQuantity:B,minimumAmountCents:B,minimumQuantity:B,name:r,paymentOption:R,pricingMode:O([`fixed`,`custom`]),slug:r}),oe=T({availability:H,community:C(T({accentColor:P(),imageUrl:C(P()),memberIdLabel:E(C(P())),name:r,widgetAchEnabled:E(h())})),event:C(G),payment:T({connectedAccountId:E(C(r),null),currency:v(`usd`),publishableKey:U}),pricingPolicy:T({currency:v(`usd`),serviceFeeRateBasisPoints:e(0)}),products:m(ae),widget:T({customFields:n,description:C(P()),fields:K,id:P(),name:r,requiredShipping:q,showCommunityBranding:h(),title:C(P())})}),se=C(T({amountOffCents:E(e(0)),message:E(P()),percentageOff:E(k(w(),_(),S(0),b(100))),source:O([`email_list`,`promo_code`])})),ce=T({acceptsDiscounts:h(),eventId:C(r),fulfillmentType:z,listingId:r,listingSlug:r,paymentOption:R,pricingMode:O([`fixed`,`custom`]),productId:r,productName:r,quantity:e(1),subtotalCents:e(0),unitAmountCents:e(0)}),le=k(d,T({amountCents:e(0),appliedDiscount:se,connectedAccountId:C(r),discountableSubtotalCents:e(0),discountCents:e(0),lineItems:m(ce),paymentOption:R,serviceFeeCents:e(0),subtotalCents:e(0),tipCents:e(0),totalCents:e(0)}),g(({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.`)),ue=k(T({...p.entries,retryUrl:E(k(r,j(/^https:\/\//)))}),g(e=>e.checkoutId.trim()&&e.paymentReference.trim()?e.checkoutStatus===`action_required`?e.paymentRequired&&(e.requiresAction&&!!e.clientSecret?.trim()||!e.requiresAction&&e.clientSecret===null&&!!e.retryUrl):!e.requiresAction&&e.clientSecret===null:!1,`Invalid payment result state.`)),J=D(le),de=D(oe),fe=D(ue),pe=D(f),me=D(ie);function he(e){return pe(e),me(e)}function ge(e){let t=M(y({quote:E(L())}),e),n=he(e),r=t.success?t.output.quote:void 0;return r===void 0?{widget:n}:{quote:J(r),widget:n}}const _e={email:E(P()),includeServiceFee:E(h()),promoCode:E(P()),tipCents:E(e(0))},ve=N(_e),ye=D(E(ve,{})),be=N({confirmationToken:E(r),customFieldAnswers:E(m(i)),email:P(),memberId:E(P()),merchSize:E(O([`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`])),metadata:E(A(P(),P())),paymentMethodConfiguration:E(v(`explicit`)),phone:E(P()),shipping:E(N({address:N({city:P(),country:P(),line1:P(),line2:E(P()),postal_code:P(),state:P()}),name:P()}))}),xe=I([N({amountCents:e(1),productId:r}),N({productId:r,quantity:e(1)}),N({productId:r})]),Se=I([N({amountCents:e(1),productSlug:r}),N({productSlug:r,quantity:e(1)}),N({productSlug:r})]),Ce=k(m(xe),x(1)),Y=k(m(Se),x(1)),we=T({selection:Y}),Te=y({catalog:E(L()),email:E(L()),includeServiceFee:E(L()),items:E(Ce),promoCode:E(L()),selection:E(Y),tipCents:E(L())}),Ee=k(y({authoritative:v(!0),items:Ce,payment:T({connectedAccountId:C(r),currency:v(`usd`),publishableKey:k(P(),x(1))}),paymentReference:k(P(),x(1)),pricing:ve}),F(e=>{let{items:t,payment:n,paymentReference:r,pricing:i,...a}=e,o=J({...a,connectedAccountId:n.connectedAccountId}),{connectedAccountId:s,...c}=o;return{items:t,pricing:i,quote:{...c,authoritative:!0,payment:{connectedAccountId:s,currency:`usd`,publishableKey:n.publishableKey},paymentOption:o.paymentOption,paymentReference:r}}})),De=y({checkout:Ee,submission:be}),Oe=r,ke=D(y({})),Ae=D(Te);function je(e){let{catalog:t,items:n,selection:r,...i}=Ae(e),a;try{a=ke(t)}catch(e){throw TypeError(`A catalog is required to calculate a checkout.`,{cause:e})}try{return{catalog:a,items:n,pricing:ye(i),selection:r}}catch(e){throw TypeError(`Checkout pricing input is invalid.`,{cause:e})}}const Me=D(we),Ne=D(Oe);D(Ee);const Pe=D(De),Fe=D(Y);function Ie(e){return Math.max(100,e.minimumAmountCents??0)}function Le(e,t,n){let r=new Map;for(let i of e.products){let e=n[i.id]??0;if(!Number.isSafeInteger(e)||e<0)throw TypeError(`Selected package quantities must be nonnegative integers.`);i.id!==t&&e>0&&r.set(i.listingId,(r.get(i.listingId)??0)+e)}return r}function Re(e,t,n={}){let r=e.availability.listings.find(e=>e.listingId===t.listingId),i=Math.min(r?.maxPurchasableQuantity??1/0,r?.remainingQuantity??1/0),a=Le(e,t.id,n),o=Math.min(t.maximumQuantity??1/0,t.inventoryQuantity??1/0,r?.status===`sold_out`?0:i),s=Math.min(o,i-(a.get(t.listingId)??0));for(let n of e.availability.sharedLimits){if(!n.listingIds.includes(t.listingId))continue;let e=n.listingWeights?.[t.listingId]??1,r=n.status===`sold_out`?0:n.remainingQuantity,i=n.listingIds.reduce((e,t)=>e+(a.get(t)??0)*(n.listingWeights?.[t]??1),0);o=Math.min(o,Math.floor(r/e)),s=Math.min(s,Math.floor((r-i)/e))}s=Math.max(0,s);let c=t.minimumQuantity??1,l=`available`;return o<c?l=`sold_out`:(s<c||(n[t.id]??0)>=s)&&(l=`limit_reached`),{maximumQuantity:Number.isFinite(s)?s:null,status:l}}function ze(e,t){let n={};for(let e of t)n[e.productId]=(n[e.productId]??0)+(`quantity`in e?e.quantity:1);if(e.products.some(t=>{let r=n[t.id];if(!r)return!1;let{maximumQuantity:i,status:a}=Re(e,t,n);return a===`sold_out`||i!==null&&r>i}))throw new l({code:`total_calculation_failed`,message:`This option is sold out.`,operation:`calculate_total`,reportable:!1,serverCode:`PAYMENT_WIDGET_SALES_LIMIT_REACHED`})}function Be(e,t){if(e.pricingMode!==`custom`||e.paymentOption!==`one-time`||t<Ie(e))throw TypeError(`Selected Product amount is invalid.`);return{checkoutItem:{amountCents:t,productId:e.id},quantity:1,unitAmountCents:t}}function Ve(e,t){if(e.pricingMode!==`fixed`||e.amountCents===null)throw TypeError(`Selected Product quantity is invalid.`);if(e.paymentOption!==`one-time`&&t!==1)throw TypeError(`Selected recurring Product is invalid.`);if(e.minimumQuantity!==null&&t<e.minimumQuantity||e.maximumQuantity!==null&&t>e.maximumQuantity||e.inventoryQuantity!==null&&t>e.inventoryQuantity)throw TypeError(`Selected Product quantity is invalid.`);return{checkoutItem:e.paymentOption===`one-time`?{productId:e.id,quantity:t}:{productId:e.id},quantity:t,unitAmountCents:e.amountCents}}function He(e,t,n){let r=`quantity`in n?n.quantity:1,{checkoutItem:i,quantity:a,unitAmountCents:o}=`amountCents`in n?Be(t,n.amountCents):Ve(t,r);return{checkoutItem:i,lineItem:{acceptsDiscounts:t.acceptsDiscounts,eventId:t.fulfillmentType===`event_admission`&&e.event?e.event.id:null,fulfillmentType:t.fulfillmentType,listingId:t.listingId,listingSlug:t.slug,paymentOption:t.paymentOption,pricingMode:t.pricingMode,productId:t.id,productName:t.name,quantity:a,subtotalCents:o*a,unitAmountCents:o}}}function X(e,t){let n=Fe(t),r=e.widget.requiredShipping;if(r){let t=e.products.find(({id:e})=>e===r.productId),i=n.some(t=>e.products.some(e=>e.slug===t.productSlug&&r.triggerProductIds.includes(e.id)));if(n=n.filter(e=>e.productSlug!==t?.slug),i){if(!t)throw TypeError(`Required shipping Product is unavailable.`);n.push({productSlug:t.slug,quantity:1})}}let i=new Set,a=n.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);if(!n)throw TypeError(`Selected Product is unavailable.`);if(i.has(n.id))throw TypeError(`Each Product can appear only once per checkout.`);return i.add(n.id),He(e,n,t)});if(r?.additionalUnitAmountCents){let e=a.reduce((e,{lineItem:t})=>e+(r.triggerProductIds.includes(t.productId)?t.quantity:0),0),t=a.find(({lineItem:e})=>e.productId===r.productId)?.lineItem;if(t){let n=t.unitAmountCents+Math.max(0,e-1)*r.additionalUnitAmountCents;if(!Number.isSafeInteger(n)||n>2147483647)throw TypeError(`Required shipping amount is invalid.`);t.unitAmountCents=n,t.subtotalCents=n}}let o=a[0]?.lineItem.paymentOption;if(!o)throw TypeError(`Select at least one Product.`);if(a.length>1&&(o!==`one-time`||a.some(({lineItem:e})=>e.paymentOption!==o)))throw TypeError(`Recurring Products must be purchased separately.`);let s=a.map(({checkoutItem:e})=>e);return ze(e,s),{items:s,lineItems:a.map(({lineItem:e})=>e),paymentOption:o}}function Ue(e){let{product:t}=e;return{acceptsDiscounts:e.acceptsDiscounts??!1,amountCents:t.amountCents,description:t.description??null,fulfillmentType:t.fulfillmentType,id:t.id,inventoryQuantity:t.inventoryQuantity,listingId:e.id,maximumQuantity:e.maxQuantityPerOrder,minimumAmountCents:t.minimumAmountCents,minimumQuantity:t.minQuantity,name:t.name,paymentOption:t.paymentOption,pricingMode:t.pricingMode,slug:e.slug}}function We(e){if(!e)return null;let t={accentColor:e.color,imageUrl:e.thumbnail||null,name:e.name};return e.widgetAchEnabled!==void 0&&(t.widgetAchEnabled=e.widgetAchEnabled),e.memberIdLabel!==void 0&&(t.memberIdLabel=e.memberIdLabel),t}function Ge(e){let t=e.config?.fields??{};return{availability:e.availability,community:We(e.community),event:e.event?{description:e.event.description,endAt:e.event.endAt,id:e.event.id,location:e.event.location,name:e.event.name,startAt:e.event.startAt,status:e.event.status}:null,payment:{connectedAccountId:e.payment.connectedAccountId,currency:e.payment.currency,publishableKey:e.payment.publishableKey},pricingPolicy:{currency:`usd`,serviceFeeRateBasisPoints:e.pricingPolicy?.serviceFeeRateBasisPoints??0},products:(e.products??[]).map(Ue),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`,requiredShipping:e.config?.requiredShipping,showCommunityBranding:e.showCommunityBranding??!0,title:e.title??null}}}function Z(e){return Q(e)}function Ke(e){return Q(e)}function qe(e){return Q(e)}function Q(e){return s(structuredClone(e))}const Je=T({code:O([`PAYMENT_WIDGET_PHONE_INVALID`,`PAYMENT_WIDGET_PHONE_REQUIRED`,`PAYMENT_WIDGET_SALES_LIMIT_REACHED`])});async function $(e){if(e.status===400||e.status===409)try{let t=M(Je,await e.json());return t.success?t.output.code:void 0}catch{}}function Ye({catalog:e,items:t,selection:n}){if(t!==void 0&&n!==void 0)throw TypeError(`Use items or selection, not both.`);let r=Z(de(e)),i=n===void 0?Xe(t):X(r,n).items;return ze(r,i),{catalog:r,items:i}}function Xe(e){if(e===void 0)throw TypeError(`Checkout selection is invalid.`);return e}function Ze(e){let{apiBaseUrl:t,communitySlug:n,communitySlugValue:r,environment:i,fetchImplementation:a,onError:u,requestTimeoutMs:d,sentryDsn:f,widgetSlug:p,widgetSlugValue:m}=te(e),h=o({communitySlug:r,environment:i,getContext:()=>({widgetSlug:m}),onError:u,resourceContextName:`lockerverse_widget`,sentryDsn:f}),{requestJson:g}=c(a,h,d),_=`${t}/v2/community/${n}/payment-widgets/${p}/checkout`,v=`${t}/v2/community/${n}/payment-widgets/${p}`;function y(e,t,n=`invalid_selection`){throw h(new l({code:n,message:e,operation:t,reportable:!1}))}function b(e,t){return e instanceof l?e:new l({...t,reportable:!0})}function x(e,t,n=!1){let r=b(e,t);if(!(n&&(r.status===void 0||r.status>=500)))throw h(r);let i=new l({code:r.code,failureKind:r.failureKind,message:r.message,operation:r.operation,recoveryRecommended:!0,reportable:r.reportable,status:r.status});throw h(i)}function S(e){let t=e.email?.trim().toLowerCase(),n=e.promoCode?.trim(),r={};return t&&(r.email=t),e.includeServiceFee!==void 0&&(r.includeServiceFee=e.includeServiceFee),n&&(r.promoCode=n),e.tipCents!==void 0&&(r.tipCents=e.tipCents),r}function C(e){try{return Me(e).selection}catch{y(`Checkout selection is invalid.`,`load_widget`)}}function w(e,t,n,r){let{connectedAccountId:i,...a}=e;return Ke(s({...a,authoritative:!0,items:t,payment:{connectedAccountId:i,currency:`usd`,publishableKey:r.publishableKey},paymentOption:e.paymentOption,paymentReference:globalThis.crypto.randomUUID(),pricing:n}))}function T(e,t,n){try{return X(e,t).items}catch(e){throw e instanceof TypeError&&y(e.message,n),e}}function E(e,t,n,r){if(!n)throw new l({...r,message:`Lockerverse did not return the requested initial quote.`,reportable:!0});let i=T(e,t,r.operation);return s({catalog:Z(e),checkout:w(n,i,{includeServiceFee:e.widget.fields.serviceFee},e.payment)})}async function D(e){let t={code:`widget_load_failed`,message:`Lockerverse returned an invalid widget catalog.`,operation:`load_widget`},n=e?`${v}?selection=${encodeURIComponent(JSON.stringify(e))}`:v,r=()=>g(n,e?{cache:`no-store`}:void 0,ge,{...t,message:`Unable to load Lockerverse widget because the request failed.`,report:!1},{...t,report:!1},$);async function i(){try{return await r()}catch(e){if(!(e instanceof l)||e.failureKind!==`network`&&e.failureKind!==`timeout`)throw e}return r()}let a=await i();if(!a.ok){let e=a.errorValue;throw e===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`?new l({...t,message:`This option is sold out.`,reportable:!1,serverCode:e,status:a.response.status}):new l({...t,message:`Unable to load Lockerverse widget (${a.response.status}).`,reportable:a.response.status>=500,status:a.response.status})}let o=s(Ge(a.value.widget));return e?E(o,e,a.value.quote,t):Z(o)}async function O(e,t){let n=await D(),r={includeServiceFee:n.widget.fields.serviceFee},i=T(n,e,t.operation);return s({catalog:n,checkout:await j(i,r,n.payment,t)})}async function k(e){let t={code:`widget_load_failed`,message:`Lockerverse returned an invalid widget catalog.`,operation:`load_widget`};try{return e&&`${v}?selection=${encodeURIComponent(JSON.stringify(e))}`.length>4e3?await O(e,t):e?await D(e):await D()}catch(e){x(e,t)}}function A(e){return e===void 0?k():k(C(e))}async function j(e,t,n,r){let i=await g(`${_}/quote`,{body:JSON.stringify({...t,items:e}),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(!i.ok){let e=i.errorValue;throw e===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`?new l({...r,message:`This option is sold out.`,reportable:!1,serverCode:e,status:i.response.status}):new l({...r,message:`Unable to calculate the Lockerverse checkout total (${i.response.status}).`,reportable:i.response.status>=500,status:i.response.status})}return w(i.value,e,t,n)}async function M(e){let{catalog:t,items:n,pricing:r}=N(e),i={code:`total_calculation_failed`,message:`Lockerverse returned an invalid checkout total.`,operation:`calculate_total`};try{return await j(n,r,t.payment,i)}catch(e){x(e,i)}}function N(e){try{let t=je(e),n=Ye(t),r=S(t.pricing);return{catalog:n.catalog,items:n.items,pricing:r.includeServiceFee===void 0?{...r,includeServiceFee:n.catalog.widget.fields.serviceFee}:r}}catch(e){if(e instanceof l)throw e;y(e instanceof TypeError?e.message:`Checkout selection is invalid.`,`calculate_total`)}}function P(e){try{let t=Pe(e),{items:n,pricing:r,quote:i}=t.checkout,a=S(r),o=s(i),{submission:c}=t;o.totalCents>0&&!c.confirmationToken&&y(`Stripe confirmation is required for a paid checkout.`,`submit_payment`,`payment_submit_failed`);let l=c.email.trim().toLowerCase();return(!l||l!==a.email)&&y(`Payment email must match the current checkout quote.`,`submit_payment`),{items:n,pricing:a,quote:o,submission:{...c,email:l}}}catch(e){if(e instanceof l)throw e;y(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}return{calculateTotal:M,async getPaymentStatus(e){let t;try{t=Ne(e).trim()}catch{y(`Provide a payment reference to recover its status.`,`get_payment_status`)}let n={code:`payment_status_failed`,message:`Lockerverse returned an invalid payment status.`,operation:`get_payment_status`};try{let e=await g(`${_}/${encodeURIComponent(t)}/status`,void 0,fe,{...n,message:`Unable to recover the Lockerverse payment status because the request failed.`,report:!1},{...n,report:!1});if(!e.ok)throw new l({...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 l({...n,reportable:!0});return qe(e.value)}catch(e){x(e,n)}},load:A,async submitPayment(e){let{items:t,pricing:n,quote:r,submission:i}=P(e),a={code:`payment_submit_failed`,message:`Lockerverse returned an invalid payment confirmation.`,operation:`submit_payment`};try{let e=await g(`${_}/confirm`,{body:JSON.stringify({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,paymentMethodConfiguration:i.paymentMethodConfiguration,paymentReference:r.paymentReference,phone:i.phone,quoteContractVersion:1,shipping:i.shipping}),headers:{"Content-Type":`application/json`},method:`POST`},fe,{...a,message:`Unable to submit the Lockerverse payment because the request failed.`,report:!1},{...a,report:!1},$);if(!e.ok){let t=e.errorValue;throw t?new l({...a,message:t===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`?`This option is sold out.`:`Unable to submit the Lockerverse payment (${e.response.status}).`,reportable:!1,serverCode:t,status:e.response.status}):new l({...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 l({...a,reportable:!0});return qe(e.value)}catch(e){x(e,a,!0)}}}}function Qe(e,t){let{selection:n,...r}=t,i;try{i=ye(r)}catch(e){throw TypeError(`Checkout pricing is invalid.`,{cause:e})}let a=i.includeServiceFee??e.widget.fields.serviceFee,{tipCents:o=0}=i,{items:c,lineItems:l,paymentOption:u}=X(e,n),d=l.reduce((e,t)=>e+t.subtotalCents,0);if(!Number.isSafeInteger(d)||d<=0||d>2147483647)throw TypeError(`Checkout total is invalid.`);let f=l.reduce((e,t)=>e+(t.acceptsDiscounts?t.subtotalCents:0),0),p=a?Math.round(d*e.pricingPolicy.serviceFeeRateBasisPoints/1e4):0,m=d+p,h=m+o;if(!Number.isSafeInteger(h)||h>2147483647)throw TypeError(`Checkout total is invalid.`);return s({amountCents:m,appliedDiscount:null,authoritative:!1,discountableSubtotalCents:f,discountCents:0,items:c,lineItems:l,paymentOption:u,serviceFeeCents:p,subtotalCents:d,tipCents:o,totalCents:h})}export{u as LOCKERVERSE_SDK_VERSION,l as LockerverseSdkError,Ze as createLockerverseCheckoutClient,Qe as estimateLockerverseCheckout,Ie as getLockerverseMinimumCustomAmountCents,Re as getLockerverseProductAvailability};
|
|
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-schemas.ts","../src/checkout-input-schemas.ts","../src/custom-amount.ts","../src/checkout-selection.ts","../src/snapshots.ts","../src/checkout-client.ts","../src/checkout-estimate.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(options, \"widgetSlug\");\n return {\n ...runtime,\n widgetSlug: runtime.resourceSlug,\n widgetSlugValue: runtime.resourceSlugValue,\n };\n}\n","import {\n array,\n boolean,\n check,\n finite,\n type InferOutput,\n literal,\n looseObject,\n maxValue,\n minValue,\n nullable,\n number,\n object,\n optional,\n parser,\n picklist,\n pipe,\n regex,\n safeParse,\n string,\n transform,\n unknown,\n variant,\n} from \"valibot\";\n\nimport {\n vPaymentWidgetPaymentResultResponseDto,\n vPaymentWidgetQuoteResponseDto,\n vPublicPaymentWidgetResponseDto,\n} 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([\n \"one-time\",\n \"monthly\",\n \"annually\",\n \"every-six-months\",\n]);\nconst fulfillmentTypeSchema = picklist([\"none\", \"event_admission\"]);\nconst nullableNonNegativeIntegerSchema = nullable(safeIntegerSchema(0));\nconst availabilityStatusSchema = picklist([\"available\", \"sold_out\"]);\nconst availabilitySchema = optional(\n object({\n listings: array(\n object({\n listingId: nonEmptyStringSchema,\n maxPurchasableQuantity: nullableNonNegativeIntegerSchema,\n remainingQuantity: nullableNonNegativeIntegerSchema,\n status: availabilityStatusSchema,\n })\n ),\n sharedLimits: array(\n object({\n id: nonEmptyStringSchema,\n listingIds: array(nonEmptyStringSchema),\n remainingQuantity: safeIntegerSchema(0),\n status: availabilityStatusSchema,\n })\n ),\n }),\n { listings: [], sharedLimits: [] }\n);\nconst publishableKeySchema = pipe(\n string(),\n regex(/^pk_(?:test|live)_\\S+$/, \"Invalid publishable key.\")\n);\n\nconst productBaseEntries = {\n description: optionalNullableStringSchema,\n fulfillmentType: fulfillmentTypeSchema,\n id: nonEmptyStringSchema,\n inventoryQuantity: nullableNonNegativeIntegerSchema,\n maxQuantity: nullableNonNegativeIntegerSchema,\n minimumAmountCents: nullableNonNegativeIntegerSchema,\n minQuantity: nullableNonNegativeIntegerSchema,\n name: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n};\n\nconst eventSchema = object({\n description: nullable(string()),\n endAt: nonEmptyStringSchema,\n id: nonEmptyStringSchema,\n location: nullable(string()),\n name: nonEmptyStringSchema,\n startAt: nonEmptyStringSchema,\n status: picklist([\"draft\", \"active\", \"finished\", \"cancelled\"]),\n});\n\nconst publicProductSchema = 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\nconst productListingSchema = object({\n acceptsDiscounts: optional(boolean(), false),\n id: nonEmptyStringSchema,\n maxQuantityPerOrder: optional(nullableNonNegativeIntegerSchema, null),\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\nconst requiredShippingSchema = optional(\n object({\n additionalUnitAmountCents: optional(\n pipe(safeIntegerSchema(0), maxValue(2_147_483_647))\n ),\n productId: nonEmptyStringSchema,\n triggerProductIds: array(nonEmptyStringSchema),\n })\n);\n\nexport const publicWidgetSchema = pipe(\n object({\n availability: availabilitySchema,\n community: optional(\n object({\n color: string(),\n memberIdLabel: optional(nullable(string())),\n name: nonEmptyStringSchema,\n thumbnail: nullable(string()),\n widgetAchEnabled: optional(boolean()),\n })\n ),\n config: optional(\n object({\n customFields: customFieldsSchema,\n fields: widgetFieldsSchema,\n requiredShipping: requiredShippingSchema,\n })\n ),\n description: optionalNullableStringSchema,\n event: nullable(eventSchema),\n id: optional(string(), \"\"),\n name: optional(string(), \"Lockerverse widget\"),\n payment: object({\n connectedAccountId: optional(nullable(nonEmptyStringSchema), null),\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 requiredShipping: widget.config?.requiredShipping,\n },\n pricingPolicy: widget.pricingPolicy ?? {\n currency: \"usd\" as const,\n serviceFeeRateBasisPoints: 0,\n },\n }))\n);\n\nconst catalogProductSchema = object({\n acceptsDiscounts: boolean(),\n amountCents: nullable(safeIntegerSchema(0)),\n description: nullable(string()),\n fulfillmentType: fulfillmentTypeSchema,\n id: nonEmptyStringSchema,\n inventoryQuantity: nullableNonNegativeIntegerSchema,\n listingId: nonEmptyStringSchema,\n maximumQuantity: nullableNonNegativeIntegerSchema,\n minimumAmountCents: nullableNonNegativeIntegerSchema,\n minimumQuantity: nullableNonNegativeIntegerSchema,\n name: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n pricingMode: picklist([\"fixed\", \"custom\"]),\n slug: nonEmptyStringSchema,\n});\n\nconst catalogSchema = object({\n availability: availabilitySchema,\n community: nullable(\n object({\n accentColor: string(),\n imageUrl: nullable(string()),\n memberIdLabel: optional(nullable(string())),\n name: nonEmptyStringSchema,\n widgetAchEnabled: optional(boolean()),\n })\n ),\n event: nullable(eventSchema),\n payment: object({\n connectedAccountId: optional(nullable(nonEmptyStringSchema), null),\n currency: literal(\"usd\"),\n publishableKey: publishableKeySchema,\n }),\n pricingPolicy: object({\n currency: literal(\"usd\"),\n serviceFeeRateBasisPoints: safeIntegerSchema(0),\n }),\n products: array(catalogProductSchema),\n widget: object({\n customFields: customFieldsSchema,\n description: nullable(string()),\n fields: widgetFieldsSchema,\n id: string(),\n name: nonEmptyStringSchema,\n requiredShipping: requiredShippingSchema,\n showCommunityBranding: boolean(),\n title: nullable(string()),\n }),\n});\n\nconst appliedDiscountSchema = nullable(\n object({\n amountOffCents: optional(safeIntegerSchema(0)),\n message: optional(string()),\n percentageOff: optional(\n pipe(number(), finite(), minValue(0), maxValue(100))\n ),\n source: picklist([\"email_list\", \"promo_code\"]),\n })\n);\n\nconst checkoutLineItemSchema = object({\n acceptsDiscounts: boolean(),\n eventId: nullable(nonEmptyStringSchema),\n fulfillmentType: fulfillmentTypeSchema,\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 vPaymentWidgetQuoteResponseDto,\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 object({\n ...vPaymentWidgetPaymentResultResponseDto.entries,\n retryUrl: optional(pipe(nonEmptyStringSchema, regex(/^https:\\/\\//))),\n }),\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.paymentRequired &&\n ((payment.requiresAction && Boolean(payment.clientSecret?.trim())) ||\n (!payment.requiresAction &&\n payment.clientSecret === null &&\n Boolean(payment.retryUrl)))\n );\n }\n return !payment.requiresAction && payment.clientSecret === null;\n }, \"Invalid payment result state.\")\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 parseCatalog = parser(catalogSchema);\nexport const parsePaymentResult = parser(paymentResultSchema);\nconst parsePublicWidgetContract = parser(vPublicPaymentWidgetResponseDto);\nconst parseSdkPublicWidget = parser(publicWidgetSchema);\n\nexport function parsePublicWidget<Input>(input: Input) {\n parsePublicWidgetContract(input);\n return parseSdkPublicWidget(input);\n}\n\nexport function parsePublicWidgetLoad<Input>(input: Input) {\n const response = safeParse(\n looseObject({ quote: optional(unknown()) }),\n input\n );\n const widget = parsePublicWidget(input);\n const quote = response.success ? response.output.quote : undefined;\n return quote === undefined\n ? { widget }\n : { quote: parseCheckoutQuote(quote), widget };\n}\n","import {\n array,\n boolean,\n type InferOutput,\n literal,\n looseObject,\n minLength,\n nullable,\n object,\n optional,\n parser,\n picklist,\n pipe,\n record,\n strictObject,\n string,\n transform,\n union,\n unknown,\n} from \"valibot\";\n\nimport { parseCheckoutQuote } from \"./checkout-schemas.ts\";\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst checkoutPricingEntries = {\n email: optional(string()),\n includeServiceFee: optional(boolean()),\n promoCode: optional(string()),\n tipCents: optional(safeIntegerSchema(0)),\n};\n\nconst checkoutPricingInputSchema = strictObject(checkoutPricingEntries);\n\nexport const parseCheckoutPricingInput = parser(\n optional(checkoutPricingInputSchema, {})\n);\n\nconst paymentSubmissionSchema = 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 paymentMethodConfiguration: optional(literal(\"explicit\")),\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\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\nconst checkoutItemsSchema = pipe(array(checkoutItemSchema), minLength(1));\nconst checkoutSelectionItemsSchema = pipe(\n array(checkoutSelectionItemSchema),\n minLength(1)\n);\n\nconst loadCheckoutInputSchema = object({\n selection: checkoutSelectionItemsSchema,\n});\n\nconst calculateTotalInputSchema = looseObject({\n catalog: optional(unknown()),\n email: optional(unknown()),\n includeServiceFee: optional(unknown()),\n items: optional(checkoutItemsSchema),\n promoCode: optional(unknown()),\n selection: optional(checkoutSelectionItemsSchema),\n tipCents: optional(unknown()),\n});\n\nconst preparedCheckoutInputSchema = pipe(\n looseObject({\n authoritative: literal(true),\n items: checkoutItemsSchema,\n payment: object({\n connectedAccountId: nullable(nonEmptyStringSchema),\n currency: literal(\"usd\"),\n publishableKey: pipe(string(), minLength(1)),\n }),\n paymentReference: pipe(string(), minLength(1)),\n pricing: checkoutPricingInputSchema,\n }),\n transform((checkout) => {\n const { items, payment, paymentReference, pricing, ...quoteInput } =\n checkout;\n const parsedQuote = parseCheckoutQuote({\n ...quoteInput,\n connectedAccountId: payment.connectedAccountId,\n });\n const { connectedAccountId, ...quote } = parsedQuote;\n return {\n items,\n pricing,\n quote: {\n ...quote,\n authoritative: true as const,\n payment: {\n connectedAccountId,\n currency: \"usd\" as const,\n publishableKey: payment.publishableKey,\n },\n paymentOption: parsedQuote.paymentOption,\n paymentReference,\n },\n };\n })\n);\n\nconst submitPaymentInputSchema = looseObject({\n checkout: preparedCheckoutInputSchema,\n submission: paymentSubmissionSchema,\n});\n\nconst paymentReferenceInputSchema = nonEmptyStringSchema;\nconst parseCatalogInputFields = parser(looseObject({}));\n\nexport type ParsedPreparedCheckoutInput = InferOutput<\n typeof preparedCheckoutInputSchema\n>;\nexport type ParsedLoadCheckoutInput = InferOutput<\n typeof loadCheckoutInputSchema\n>;\nexport type ParsedPaymentReferenceInput = InferOutput<\n typeof paymentReferenceInputSchema\n>;\nexport type ParsedSubmitPaymentInput = InferOutput<\n typeof submitPaymentInputSchema\n>;\n\nconst parseCalculateTotalInputFields = parser(calculateTotalInputSchema);\n\nexport function parseCalculateTotalInput<Input>(input: Input) {\n const { catalog, items, selection, ...pricingInput } =\n parseCalculateTotalInputFields(input);\n let parsedCatalog: ReturnType<typeof parseCatalogInputFields>;\n try {\n parsedCatalog = parseCatalogInputFields(catalog);\n } catch (error) {\n throw new TypeError(\"A catalog is required to calculate a checkout.\", {\n cause: error,\n });\n }\n try {\n return {\n catalog: parsedCatalog,\n items,\n pricing: parseCheckoutPricingInput(pricingInput),\n selection,\n };\n } catch (error) {\n throw new TypeError(\"Checkout pricing input is invalid.\", { cause: error });\n }\n}\n\nexport type ParsedCalculateTotalInput = ReturnType<\n typeof parseCalculateTotalInput\n>;\nexport type ParsedCheckoutPricingInput = InferOutput<\n typeof checkoutPricingInputSchema\n>;\n\nexport const parseLoadCheckoutInput = parser(loadCheckoutInputSchema);\nexport const parsePaymentReferenceInput = parser(paymentReferenceInputSchema);\nexport const parsePreparedCheckoutInput = parser(preparedCheckoutInputSchema);\nexport const parseSubmitPaymentInput = parser(submitPaymentInputSchema);\n\nexport const parseCheckoutSelectionItems = parser(checkoutSelectionItemsSchema);\n","import type { LockerverseProduct } from \"./types.ts\";\n\nconst minimumCustomAmountCents = 100;\n\nexport function getLockerverseMinimumCustomAmountCents(\n product: Pick<LockerverseProduct, \"minimumAmountCents\">\n) {\n return Math.max(minimumCustomAmountCents, product.minimumAmountCents ?? 0);\n}\n","import { parseCheckoutSelectionItems } from \"./checkout-input-schemas.ts\";\nimport { getLockerverseMinimumCustomAmountCents } from \"./custom-amount.ts\";\nimport type {\n LockerverseCatalog,\n LockerverseCheckoutItem,\n LockerverseCheckoutLineItem,\n LockerverseCheckoutSelectionItem,\n LockerverseProduct,\n} from \"./types.ts\";\nimport { LockerverseSdkError } from \"./types.ts\";\n\ntype ResolvedSelectionItem = {\n checkoutItem: LockerverseCheckoutItem;\n quantity: number;\n unitAmountCents: number;\n};\n\nexport function assertCheckoutItemsAreAvailable(\n catalog: LockerverseCatalog,\n items: LockerverseCheckoutItem[]\n) {\n const listingIdByProductId = new Map(\n catalog.products.map(({ id, listingId }) => [id, listingId])\n );\n const requestedByListingId = items.reduce((requested, item) => {\n const listingId = listingIdByProductId.get(item.productId);\n if (listingId) {\n requested.set(\n listingId,\n (requested.get(listingId) ?? 0) +\n (\"quantity\" in item ? (item.quantity ?? 1) : 1)\n );\n }\n return requested;\n }, new Map<string, number>());\n const listingIsSoldOut = catalog.availability.listings.some(\n ({ listingId, maxPurchasableQuantity, status }) =>\n requestedByListingId.has(listingId) &&\n (status === \"sold_out\" ||\n (maxPurchasableQuantity !== null &&\n (requestedByListingId.get(listingId) ?? 0) > maxPurchasableQuantity))\n );\n const sharedLimitIsSoldOut = catalog.availability.sharedLimits.some(\n ({ listingIds, remainingQuantity, status }) => {\n const requestedQuantity = listingIds.reduce(\n (total, listingId) =>\n total + (requestedByListingId.get(listingId) ?? 0),\n 0\n );\n return (\n requestedQuantity > 0 &&\n (status === \"sold_out\" || requestedQuantity > remainingQuantity)\n );\n }\n );\n if (listingIsSoldOut || sharedLimitIsSoldOut) {\n throw new LockerverseSdkError({\n code: \"total_calculation_failed\",\n message: \"This option is sold out.\",\n operation: \"calculate_total\",\n reportable: false,\n serverCode: \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\",\n });\n }\n}\n\nfunction resolveAmountItem(\n product: LockerverseProduct,\n amountCents: number\n): ResolvedSelectionItem {\n if (\n product.pricingMode !== \"custom\" ||\n product.paymentOption !== \"one-time\" ||\n amountCents < getLockerverseMinimumCustomAmountCents(product)\n ) {\n throw new TypeError(\"Selected Product amount is invalid.\");\n }\n return {\n checkoutItem: { amountCents, productId: product.id },\n quantity: 1,\n unitAmountCents: amountCents,\n };\n}\n\nfunction resolveFixedItem(\n product: LockerverseProduct,\n quantity: number\n): ResolvedSelectionItem {\n if (product.pricingMode !== \"fixed\" || product.amountCents === null) {\n throw new TypeError(\"Selected Product quantity is invalid.\");\n }\n if (product.paymentOption !== \"one-time\" && quantity !== 1) {\n throw new TypeError(\"Selected recurring Product is invalid.\");\n }\n if (\n (product.minimumQuantity !== null && quantity < product.minimumQuantity) ||\n (product.maximumQuantity !== null && quantity > product.maximumQuantity) ||\n (product.inventoryQuantity !== null && quantity > product.inventoryQuantity)\n ) {\n throw new TypeError(\"Selected Product quantity is invalid.\");\n }\n return {\n checkoutItem:\n product.paymentOption === \"one-time\"\n ? { productId: product.id, quantity }\n : { productId: product.id },\n quantity,\n unitAmountCents: product.amountCents,\n };\n}\n\nfunction resolveSelectionItem(\n catalog: LockerverseCatalog,\n product: LockerverseProduct,\n selection: LockerverseCheckoutSelectionItem\n) {\n const selectedQuantity = \"quantity\" in selection ? selection.quantity : 1;\n const resolved =\n \"amountCents\" in selection\n ? resolveAmountItem(product, selection.amountCents)\n : resolveFixedItem(product, selectedQuantity);\n const { checkoutItem, quantity, unitAmountCents } = resolved;\n\n return {\n checkoutItem,\n lineItem: {\n acceptsDiscounts: product.acceptsDiscounts,\n eventId:\n product.fulfillmentType === \"event_admission\" && catalog.event\n ? catalog.event.id\n : null,\n fulfillmentType: product.fulfillmentType,\n listingId: product.listingId,\n listingSlug: product.slug,\n paymentOption: product.paymentOption,\n pricingMode: product.pricingMode,\n productId: product.id,\n productName: product.name,\n quantity,\n subtotalCents: unitAmountCents * quantity,\n unitAmountCents,\n } satisfies LockerverseCheckoutLineItem,\n };\n}\n\nexport function resolveCheckoutSelection(\n catalog: LockerverseCatalog,\n input: LockerverseCheckoutSelectionItem[]\n) {\n let selection = parseCheckoutSelectionItems(input);\n const shipping = catalog.widget.requiredShipping;\n if (shipping) {\n const shippingProduct = catalog.products.find(\n ({ id }) => id === shipping.productId\n );\n const needsShipping = selection.some((item) =>\n catalog.products.some(\n (product) =>\n product.slug === item.productSlug &&\n shipping.triggerProductIds.includes(product.id)\n )\n );\n selection = selection.filter(\n (item) => item.productSlug !== shippingProduct?.slug\n );\n if (needsShipping) {\n if (!shippingProduct) {\n throw new TypeError(\"Required shipping Product is unavailable.\");\n }\n selection.push({ productSlug: shippingProduct.slug, quantity: 1 });\n }\n }\n const selectedProducts = new Set<string>();\n const resolved = selection.map((item) => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product) {\n throw new TypeError(\"Selected Product is unavailable.\");\n }\n if (selectedProducts.has(product.id)) {\n throw new TypeError(\"Each Product can appear only once per checkout.\");\n }\n selectedProducts.add(product.id);\n return resolveSelectionItem(catalog, product, item);\n });\n if (shipping?.additionalUnitAmountCents) {\n const triggerQuantity = resolved.reduce(\n (total, { lineItem }) =>\n total +\n (shipping.triggerProductIds.includes(lineItem.productId)\n ? lineItem.quantity\n : 0),\n 0\n );\n const shippingLine = resolved.find(\n ({ lineItem }) => lineItem.productId === shipping.productId\n )?.lineItem;\n if (shippingLine) {\n const amountCents =\n shippingLine.unitAmountCents +\n Math.max(0, triggerQuantity - 1) * shipping.additionalUnitAmountCents;\n if (!Number.isSafeInteger(amountCents) || amountCents > 2_147_483_647) {\n throw new TypeError(\"Required shipping amount is invalid.\");\n }\n shippingLine.unitAmountCents = amountCents;\n shippingLine.subtotalCents = amountCents;\n }\n }\n const paymentOption = resolved[0]?.lineItem.paymentOption;\n if (!paymentOption) {\n throw new TypeError(\"Select at least one Product.\");\n }\n if (\n resolved.length > 1 &&\n (paymentOption !== \"one-time\" ||\n resolved.some(({ lineItem }) => lineItem.paymentOption !== paymentOption))\n ) {\n throw new TypeError(\"Recurring Products must be purchased separately.\");\n }\n const items = resolved.map(({ checkoutItem }) => checkoutItem);\n assertCheckoutItemsAreAvailable(catalog, items);\n return {\n items,\n lineItems: resolved.map(({ lineItem }) => lineItem),\n paymentOption,\n };\n}\n","import type { PublicProductListing, PublicWidget } from \"./checkout-schemas.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport type {\n LockerverseCatalog,\n LockerverseCommunityBranding,\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 fulfillmentType: product.fulfillmentType,\n id: product.id,\n inventoryQuantity: product.inventoryQuantity,\n listingId: listing.id,\n maximumQuantity: listing.maxQuantityPerOrder,\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\nfunction mapCommunity(\n community: PublicWidget[\"community\"]\n): LockerverseCommunityBranding | null {\n if (!community) {\n return null;\n }\n const branding: LockerverseCommunityBranding = {\n accentColor: community.color,\n imageUrl: community.thumbnail || null,\n name: community.name,\n };\n if (community.widgetAchEnabled !== undefined) {\n branding.widgetAchEnabled = community.widgetAchEnabled;\n }\n if (community.memberIdLabel !== undefined) {\n branding.memberIdLabel = community.memberIdLabel;\n }\n return branding;\n}\n\nexport function createCatalog(widget: PublicWidget): LockerverseCatalog {\n const fields = widget.config?.fields ?? {};\n\n return {\n availability: widget.availability,\n community: mapCommunity(widget.community),\n event: widget.event\n ? {\n description: widget.event.description,\n endAt: widget.event.endAt,\n id: widget.event.id,\n location: widget.event.location,\n name: widget.event.name,\n startAt: widget.event.startAt,\n status: widget.event.status,\n }\n : null,\n payment: {\n connectedAccountId: widget.payment.connectedAccountId,\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 requiredShipping: widget.config?.requiredShipping,\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 { object, picklist, safeParse } from \"valibot\";\nimport { resolveWidgetEnvironment } from \"./checkout-environment.ts\";\nimport {\n type ParsedCalculateTotalInput,\n type ParsedCheckoutPricingInput,\n parseCalculateTotalInput,\n parseLoadCheckoutInput,\n parsePaymentReferenceInput,\n parseSubmitPaymentInput,\n} from \"./checkout-input-schemas.ts\";\nimport {\n parseCatalog,\n parseCheckoutQuote,\n parsePaymentResult,\n parsePublicWidgetLoad,\n} from \"./checkout-schemas.ts\";\nimport {\n assertCheckoutItemsAreAvailable,\n resolveCheckoutSelection,\n} from \"./checkout-selection.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 LockerverseCalculateTotalInput,\n type LockerverseCatalog,\n type LockerverseCheckoutClient,\n type LockerverseCheckoutItem,\n type LockerverseCheckoutPricingInput,\n type LockerverseCheckoutSelectionItem,\n type LockerverseLoadCheckoutInput,\n type LockerverseLoadedCheckout,\n type LockerversePreparedCheckout,\n LockerverseSdkError,\n type LockerverseSdkOperation,\n type LockerverseSdkServerCode,\n type LockerverseSubmitPaymentInput,\n} from \"./types.ts\";\n\ntype OperationErrorContext = {\n code:\n | \"payment_status_failed\"\n | \"payment_submit_failed\"\n | \"total_calculation_failed\"\n | \"widget_load_failed\";\n message: string;\n operation:\n | \"calculate_total\"\n | \"get_payment_status\"\n | \"load_widget\"\n | \"submit_payment\";\n};\n\nconst MAX_SELECTED_WIDGET_URL_LENGTH = 4000;\nconst paymentServerErrorSchema = object({\n code: picklist([\n \"PAYMENT_WIDGET_PHONE_INVALID\",\n \"PAYMENT_WIDGET_PHONE_REQUIRED\",\n \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\",\n ]),\n});\n\nasync function readPaymentServerCode(\n response: Response\n): Promise<LockerverseSdkServerCode | undefined> {\n if (response.status !== 400 && response.status !== 409) {\n return;\n }\n try {\n const result = safeParse(paymentServerErrorSchema, await response.json());\n return result.success ? result.output.code : undefined;\n } catch {\n // Non-JSON error bodies do not contain a safe server code.\n }\n}\n\nfunction resolveCalculateTotalItems({\n catalog,\n items,\n selection,\n}: ParsedCalculateTotalInput) {\n if (items !== undefined && selection !== undefined) {\n throw new TypeError(\"Use items or selection, not both.\");\n }\n const selectionCatalog = cloneCatalog(parseCatalog(catalog));\n const checkoutItems =\n selection === undefined\n ? requireCheckoutItems(items)\n : resolveCheckoutSelection(selectionCatalog, selection).items;\n assertCheckoutItemsAreAvailable(selectionCatalog, checkoutItems);\n return {\n catalog: selectionCatalog,\n items: checkoutItems,\n };\n}\n\nfunction requireCheckoutItems(\n items: ParsedCalculateTotalInput[\"items\"]\n): LockerverseCheckoutItem[] {\n if (items === undefined) {\n throw new TypeError(\"Checkout selection is invalid.\");\n }\n return items;\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 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 const widgetUrl = `${apiBaseUrl}/v2/community/${communitySlug}/payment-widgets/${widgetSlug}`;\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<ErrorValue>(\n error: ErrorValue,\n context: OperationErrorContext\n ) {\n return error instanceof LockerverseSdkError\n ? error\n : new LockerverseSdkError({ ...context, reportable: true });\n }\n\n function failOperation<ErrorValue>(\n error: ErrorValue,\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 if (!recoveryRecommended) {\n throw reportError(normalized);\n }\n const recoveryError = new LockerverseSdkError({\n code: normalized.code,\n failureKind: normalized.failureKind,\n message: normalized.message,\n operation: normalized.operation,\n recoveryRecommended: true,\n reportable: normalized.reportable,\n status: normalized.status,\n });\n throw reportError(recoveryError);\n }\n\n function normalizePricingInput(input: ParsedCheckoutPricingInput) {\n const email = input.email?.trim().toLowerCase();\n const promoCode = input.promoCode?.trim();\n const pricing: LockerverseCheckoutPricingInput = {};\n if (email) {\n pricing.email = email;\n }\n if (input.includeServiceFee !== undefined) {\n pricing.includeServiceFee = input.includeServiceFee;\n }\n if (promoCode) {\n pricing.promoCode = promoCode;\n }\n if (input.tipCents !== undefined) {\n pricing.tipCents = input.tipCents;\n }\n return pricing;\n }\n\n function normalizeLoadSelection(input: LockerverseLoadCheckoutInput) {\n try {\n return parseLoadCheckoutInput(input).selection;\n } catch {\n invalidInput(\"Checkout selection is invalid.\", \"load_widget\");\n }\n }\n\n function createPreparedCheckout(\n quote: ReturnType<typeof parseCheckoutQuote>,\n items: LockerverseCheckoutItem[],\n pricing: LockerverseCheckoutPricingInput,\n payment: LockerverseCatalog[\"payment\"]\n ): LockerversePreparedCheckout {\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: payment.publishableKey,\n },\n paymentOption: quote.paymentOption,\n paymentReference: globalThis.crypto.randomUUID(),\n pricing,\n })\n );\n }\n\n function resolveSelectedCheckoutItems(\n catalog: LockerverseCatalog,\n selection: LockerverseCheckoutSelectionItem[],\n operation: LockerverseSdkOperation\n ) {\n try {\n return resolveCheckoutSelection(catalog, selection).items;\n } catch (error) {\n if (error instanceof TypeError) {\n invalidInput(error.message, operation);\n }\n throw error;\n }\n }\n\n function createSelectedCheckout(\n catalog: LockerverseCatalog,\n selection: LockerverseCheckoutSelectionItem[],\n quote: ReturnType<typeof parseCheckoutQuote> | undefined,\n context: OperationErrorContext\n ) {\n if (!quote) {\n throw new LockerverseSdkError({\n ...context,\n message: \"Lockerverse did not return the requested initial quote.\",\n reportable: true,\n });\n }\n const checkoutItems = resolveSelectedCheckoutItems(\n catalog,\n selection,\n context.operation\n );\n return deepFreeze({\n catalog: cloneCatalog(catalog),\n checkout: createPreparedCheckout(\n quote,\n checkoutItems,\n { includeServiceFee: catalog.widget.fields.serviceFee },\n catalog.payment\n ),\n });\n }\n\n function requestWidgetResource(): Promise<LockerverseCatalog>;\n function requestWidgetResource(\n selection: LockerverseCheckoutSelectionItem[]\n ): Promise<LockerverseLoadedCheckout>;\n async function requestWidgetResource(\n selection?: LockerverseCheckoutSelectionItem[]\n ): Promise<LockerverseCatalog | LockerverseLoadedCheckout> {\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 const requestUrl = selection\n ? `${widgetUrl}?selection=${encodeURIComponent(JSON.stringify(selection))}`\n : widgetUrl;\n const request = () =>\n requestJson(\n requestUrl,\n selection ? { cache: \"no-store\" } : undefined,\n parsePublicWidgetLoad,\n {\n ...context,\n message:\n \"Unable to load Lockerverse widget because the request failed.\",\n report: false,\n },\n { ...context, report: false },\n readPaymentServerCode\n );\n async function requestWithRetry() {\n try {\n return await request();\n } catch (error) {\n if (\n !(error instanceof LockerverseSdkError) ||\n (error.failureKind !== \"network\" && error.failureKind !== \"timeout\")\n ) {\n throw error;\n }\n }\n // Retry only this public GET. A checkout POST can create an uncertain payment.\n return request();\n }\n const response = await requestWithRetry();\n if (!response.ok) {\n const serverCode = response.errorValue;\n if (serverCode === \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\") {\n throw new LockerverseSdkError({\n ...context,\n message: \"This option is sold out.\",\n reportable: false,\n serverCode,\n status: response.response.status,\n });\n }\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.widget));\n if (!selection) {\n return cloneCatalog(catalog);\n }\n return createSelectedCheckout(\n catalog,\n selection,\n response.value.quote,\n context\n );\n }\n\n async function loadLargeSelection(\n selection: LockerverseCheckoutSelectionItem[],\n context: OperationErrorContext\n ): Promise<LockerverseLoadedCheckout> {\n const loaded = await requestWidgetResource();\n const pricing = {\n includeServiceFee: loaded.widget.fields.serviceFee,\n };\n const items = resolveSelectedCheckoutItems(\n loaded,\n selection,\n context.operation\n );\n return deepFreeze({\n catalog: loaded,\n checkout: await requestCheckoutQuote(\n items,\n pricing,\n loaded.payment,\n context\n ),\n });\n }\n\n async function loadWidget(\n selection?: LockerverseCheckoutSelectionItem[]\n ): Promise<LockerverseCatalog | LockerverseLoadedCheckout> {\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 if (\n selection &&\n `${widgetUrl}?selection=${encodeURIComponent(JSON.stringify(selection))}`\n .length > MAX_SELECTED_WIDGET_URL_LENGTH\n ) {\n return await loadLargeSelection(selection, context);\n }\n return selection\n ? await requestWidgetResource(selection)\n : await requestWidgetResource();\n } catch (error) {\n failOperation(error, context);\n }\n }\n\n function load(): Promise<LockerverseCatalog>;\n function load(\n input: LockerverseLoadCheckoutInput\n ): Promise<LockerverseLoadedCheckout>;\n function load(input?: LockerverseLoadCheckoutInput) {\n return input === undefined\n ? loadWidget()\n : loadWidget(normalizeLoadSelection(input));\n }\n\n async function requestCheckoutQuote(\n items: LockerverseCheckoutItem[],\n pricing: LockerverseCheckoutPricingInput,\n payment: LockerverseCatalog[\"payment\"],\n context: OperationErrorContext\n ) {\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 readPaymentServerCode\n );\n if (!response.ok) {\n const serverCode = response.errorValue;\n if (serverCode === \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\") {\n throw new LockerverseSdkError({\n ...context,\n message: \"This option is sold out.\",\n reportable: false,\n serverCode,\n status: response.response.status,\n });\n }\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, payment);\n }\n\n async function calculateTotal(input: LockerverseCalculateTotalInput) {\n const { catalog, 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 return await requestCheckoutQuote(\n items,\n pricing,\n catalog.payment,\n context\n );\n } catch (error) {\n failOperation(error, context);\n }\n }\n\n function normalizeCalculateTotalInput(input: LockerverseCalculateTotalInput) {\n try {\n const parsed = parseCalculateTotalInput(input);\n const resolved = resolveCalculateTotalItems(parsed);\n const pricing = normalizePricingInput(parsed.pricing);\n return {\n catalog: resolved.catalog,\n items: resolved.items,\n pricing:\n pricing.includeServiceFee === undefined\n ? {\n ...pricing,\n includeServiceFee: resolved.catalog.widget.fields.serviceFee,\n }\n : pricing,\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\n error instanceof TypeError\n ? error.message\n : \"Checkout selection is invalid.\",\n \"calculate_total\"\n );\n }\n }\n\n function normalizeSubmitPaymentInput(input: LockerverseSubmitPaymentInput) {\n try {\n const parsed = parseSubmitPaymentInput(input);\n const {\n items,\n pricing: pricingInput,\n quote: quoteInput,\n } = parsed.checkout;\n const pricing = normalizePricingInput(pricingInput);\n const quote = deepFreeze(quoteInput);\n const { submission } = parsed;\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 calculateTotal,\n async getPaymentStatus(paymentReference) {\n let normalizedReference: string;\n try {\n normalizedReference =\n parsePaymentReferenceInput(paymentReference).trim();\n } catch {\n invalidInput(\n \"Provide a payment reference to recover its status.\",\n \"get_payment_status\"\n );\n }\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 load,\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 confirmationToken: submission.confirmationToken,\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 paymentMethodConfiguration: submission.paymentMethodConfiguration,\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 readPaymentServerCode\n );\n if (!response.ok) {\n const serverCode = response.errorValue;\n if (serverCode) {\n throw new LockerverseSdkError({\n ...context,\n message:\n serverCode === \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\"\n ? \"This option is sold out.\"\n : `Unable to submit the Lockerverse payment (${response.response.status}).`,\n reportable: false,\n serverCode,\n status: response.response.status,\n });\n }\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","import { parseCheckoutPricingInput } from \"./checkout-input-schemas.ts\";\nimport { resolveCheckoutSelection } from \"./checkout-selection.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport type {\n LockerverseCatalog,\n LockerverseCheckoutEstimate,\n LockerverseEstimateCheckoutInput,\n} from \"./types.ts\";\n\nexport function estimateLockerverseCheckout(\n catalog: LockerverseCatalog,\n input: LockerverseEstimateCheckoutInput\n): LockerverseCheckoutEstimate {\n const { selection, ...pricingInput } = input;\n let pricing: ReturnType<typeof parseCheckoutPricingInput>;\n try {\n pricing = parseCheckoutPricingInput(pricingInput);\n } catch (error) {\n throw new TypeError(\"Checkout pricing is invalid.\", { cause: error });\n }\n const includeServiceFee =\n pricing.includeServiceFee ?? catalog.widget.fields.serviceFee;\n const { tipCents = 0 } = pricing;\n const { items, lineItems, paymentOption } = resolveCheckoutSelection(\n catalog,\n selection\n );\n const subtotalCents = lineItems.reduce(\n (total, lineItem) => total + lineItem.subtotalCents,\n 0\n );\n if (\n !Number.isSafeInteger(subtotalCents) ||\n subtotalCents <= 0 ||\n subtotalCents > 2_147_483_647\n ) {\n throw new TypeError(\"Checkout total is invalid.\");\n }\n const discountableSubtotalCents = lineItems.reduce(\n (total, lineItem) =>\n total + (lineItem.acceptsDiscounts ? lineItem.subtotalCents : 0),\n 0\n );\n const serviceFeeCents = includeServiceFee\n ? Math.round(\n (subtotalCents * catalog.pricingPolicy.serviceFeeRateBasisPoints) /\n 10_000\n )\n : 0;\n const amountCents = subtotalCents + serviceFeeCents;\n const totalCents = amountCents + tipCents;\n if (!Number.isSafeInteger(totalCents) || totalCents > 2_147_483_647) {\n throw new TypeError(\"Checkout total is invalid.\");\n }\n\n return deepFreeze({\n amountCents,\n appliedDiscount: null,\n authoritative: false,\n discountableSubtotalCents,\n discountCents: 0,\n items,\n lineItems,\n paymentOption,\n serviceFeeCents,\n subtotalCents,\n tipCents,\n totalCents,\n });\n}\n"],"mappings":"0iBAGA,SAAgB,GACd,EACA,CACA,IAAM,EAAU,EAA2B,EAAS,YAAY,EAChE,MAAO,CACL,GAAG,EACH,WAAY,EAAQ,aACpB,gBAAiB,EAAQ,iBAC3B,CACF,CCyBA,MAAM,EAAsB,EAAS,CACnC,WACA,UACA,WACA,kBACF,CAAC,EACK,EAAwB,EAAS,CAAC,OAAQ,iBAAiB,CAAC,EAC5D,EAAmC,EAAS,EAAkB,CAAC,CAAC,EAChE,GAA2B,EAAS,CAAC,YAAa,UAAU,CAAC,EAC7D,GAAqB,EACzB,EAAO,CACL,SAAU,EACR,EAAO,CACL,UAAW,EACX,uBAAwB,EACxB,kBAAmB,EACnB,OAAQ,EACV,CAAC,CACH,EACA,aAAc,EACZ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C,CAAE,MAAO,CAAM,CAAC,CACtE,CACA,IAAM,EACJ,EAAQ,mBAAqB,EAAQ,OAAO,OAAO,WAC/C,CAAE,WAAW,GAAM,EACnB,CAAE,QAAO,YAAW,iBAAkB,EAC1C,EACA,CACF,EACM,EAAgB,EAAU,QAC7B,EAAO,IAAa,EAAQ,EAAS,cACtC,CACF,EACA,GACE,CAAC,OAAO,cAAc,CAAa,GACnC,GAAiB,GACjB,EAAgB,WAEhB,MAAU,UAAU,4BAA4B,EAElD,IAAM,EAA4B,EAAU,QACzC,EAAO,IACN,GAAS,EAAS,iBAAmB,EAAS,cAAgB,GAChE,CACF,EACM,EAAkB,EACpB,KAAK,MACF,EAAgB,EAAQ,cAAc,0BACrC,GACJ,EACA,EACE,EAAc,EAAgB,EAC9B,EAAa,EAAc,EACjC,GAAI,CAAC,OAAO,cAAc,CAAU,GAAK,EAAa,WACpD,MAAU,UAAU,4BAA4B,EAGlD,OAAO,EAAW,CAChB,cACA,gBAAiB,KACjB,cAAe,GACf,4BACA,cAAe,EACf,QACA,YACA,gBACA,kBACA,gBACA,WACA,YACF,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"checkout.js","names":[],"sources":["../src/checkout-environment.ts","../src/checkout-schemas.ts","../src/checkout-input-schemas.ts","../src/custom-amount.ts","../src/product-availability.ts","../src/checkout-selection.ts","../src/snapshots.ts","../src/checkout-client.ts","../src/checkout-estimate.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(options, \"widgetSlug\");\n return {\n ...runtime,\n widgetSlug: runtime.resourceSlug,\n widgetSlugValue: runtime.resourceSlugValue,\n };\n}\n","import {\n array,\n boolean,\n check,\n finite,\n type InferOutput,\n literal,\n looseObject,\n maxValue,\n minValue,\n nullable,\n number,\n object,\n optional,\n parser,\n picklist,\n pipe,\n record,\n regex,\n safeParse,\n string,\n transform,\n unknown,\n variant,\n} from \"valibot\";\n\nimport {\n vPaymentWidgetPaymentResultResponseDto,\n vPaymentWidgetQuoteResponseDto,\n vPublicPaymentWidgetResponseDto,\n} 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([\n \"one-time\",\n \"monthly\",\n \"annually\",\n \"every-six-months\",\n]);\nconst fulfillmentTypeSchema = picklist([\"none\", \"event_admission\"]);\nconst nullableNonNegativeIntegerSchema = nullable(safeIntegerSchema(0));\nconst availabilityStatusSchema = picklist([\"available\", \"sold_out\"]);\nconst availabilitySchema = optional(\n object({\n listings: array(\n object({\n listingId: nonEmptyStringSchema,\n maxPurchasableQuantity: nullableNonNegativeIntegerSchema,\n remainingQuantity: nullableNonNegativeIntegerSchema,\n status: availabilityStatusSchema,\n })\n ),\n sharedLimits: array(\n object({\n id: nonEmptyStringSchema,\n listingIds: array(nonEmptyStringSchema),\n listingWeights: optional(\n record(nonEmptyStringSchema, safeIntegerSchema(1)),\n {}\n ),\n remainingQuantity: safeIntegerSchema(0),\n status: availabilityStatusSchema,\n })\n ),\n }),\n { listings: [], sharedLimits: [] }\n);\nconst publishableKeySchema = pipe(\n string(),\n regex(/^pk_(?:test|live)_\\S+$/, \"Invalid publishable key.\")\n);\n\nconst productBaseEntries = {\n description: optionalNullableStringSchema,\n fulfillmentType: fulfillmentTypeSchema,\n id: nonEmptyStringSchema,\n inventoryQuantity: nullableNonNegativeIntegerSchema,\n maxQuantity: nullableNonNegativeIntegerSchema,\n minimumAmountCents: nullableNonNegativeIntegerSchema,\n minQuantity: nullableNonNegativeIntegerSchema,\n name: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n};\n\nconst eventSchema = object({\n description: nullable(string()),\n endAt: nonEmptyStringSchema,\n id: nonEmptyStringSchema,\n location: nullable(string()),\n name: nonEmptyStringSchema,\n startAt: nonEmptyStringSchema,\n status: picklist([\"draft\", \"active\", \"finished\", \"cancelled\"]),\n});\n\nconst publicProductSchema = 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\nconst productListingSchema = object({\n acceptsDiscounts: optional(boolean(), false),\n id: nonEmptyStringSchema,\n maxQuantityPerOrder: optional(nullableNonNegativeIntegerSchema, null),\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\nconst requiredShippingSchema = optional(\n object({\n additionalUnitAmountCents: optional(\n pipe(safeIntegerSchema(0), maxValue(2_147_483_647))\n ),\n productId: nonEmptyStringSchema,\n triggerProductIds: array(nonEmptyStringSchema),\n })\n);\n\nexport const publicWidgetSchema = pipe(\n object({\n availability: availabilitySchema,\n community: optional(\n object({\n color: string(),\n memberIdLabel: optional(nullable(string())),\n name: nonEmptyStringSchema,\n thumbnail: nullable(string()),\n widgetAchEnabled: optional(boolean()),\n })\n ),\n config: optional(\n object({\n customFields: customFieldsSchema,\n fields: widgetFieldsSchema,\n requiredShipping: requiredShippingSchema,\n })\n ),\n description: optionalNullableStringSchema,\n event: nullable(eventSchema),\n id: optional(string(), \"\"),\n name: optional(string(), \"Lockerverse widget\"),\n payment: object({\n connectedAccountId: optional(nullable(nonEmptyStringSchema), null),\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 requiredShipping: widget.config?.requiredShipping,\n },\n pricingPolicy: widget.pricingPolicy ?? {\n currency: \"usd\" as const,\n serviceFeeRateBasisPoints: 0,\n },\n }))\n);\n\nconst catalogProductSchema = object({\n acceptsDiscounts: boolean(),\n amountCents: nullable(safeIntegerSchema(0)),\n description: nullable(string()),\n fulfillmentType: fulfillmentTypeSchema,\n id: nonEmptyStringSchema,\n inventoryQuantity: nullableNonNegativeIntegerSchema,\n listingId: nonEmptyStringSchema,\n maximumQuantity: nullableNonNegativeIntegerSchema,\n minimumAmountCents: nullableNonNegativeIntegerSchema,\n minimumQuantity: nullableNonNegativeIntegerSchema,\n name: nonEmptyStringSchema,\n paymentOption: paymentOptionSchema,\n pricingMode: picklist([\"fixed\", \"custom\"]),\n slug: nonEmptyStringSchema,\n});\n\nconst catalogSchema = object({\n availability: availabilitySchema,\n community: nullable(\n object({\n accentColor: string(),\n imageUrl: nullable(string()),\n memberIdLabel: optional(nullable(string())),\n name: nonEmptyStringSchema,\n widgetAchEnabled: optional(boolean()),\n })\n ),\n event: nullable(eventSchema),\n payment: object({\n connectedAccountId: optional(nullable(nonEmptyStringSchema), null),\n currency: literal(\"usd\"),\n publishableKey: publishableKeySchema,\n }),\n pricingPolicy: object({\n currency: literal(\"usd\"),\n serviceFeeRateBasisPoints: safeIntegerSchema(0),\n }),\n products: array(catalogProductSchema),\n widget: object({\n customFields: customFieldsSchema,\n description: nullable(string()),\n fields: widgetFieldsSchema,\n id: string(),\n name: nonEmptyStringSchema,\n requiredShipping: requiredShippingSchema,\n showCommunityBranding: boolean(),\n title: nullable(string()),\n }),\n});\n\nconst appliedDiscountSchema = nullable(\n object({\n amountOffCents: optional(safeIntegerSchema(0)),\n message: optional(string()),\n percentageOff: optional(\n pipe(number(), finite(), minValue(0), maxValue(100))\n ),\n source: picklist([\"email_list\", \"promo_code\"]),\n })\n);\n\nconst checkoutLineItemSchema = object({\n acceptsDiscounts: boolean(),\n eventId: nullable(nonEmptyStringSchema),\n fulfillmentType: fulfillmentTypeSchema,\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 vPaymentWidgetQuoteResponseDto,\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 object({\n ...vPaymentWidgetPaymentResultResponseDto.entries,\n retryUrl: optional(pipe(nonEmptyStringSchema, regex(/^https:\\/\\//))),\n }),\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.paymentRequired &&\n ((payment.requiresAction && Boolean(payment.clientSecret?.trim())) ||\n (!payment.requiresAction &&\n payment.clientSecret === null &&\n Boolean(payment.retryUrl)))\n );\n }\n return !payment.requiresAction && payment.clientSecret === null;\n }, \"Invalid payment result state.\")\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 parseCatalog = parser(catalogSchema);\nexport const parsePaymentResult = parser(paymentResultSchema);\nconst parsePublicWidgetContract = parser(vPublicPaymentWidgetResponseDto);\nconst parseSdkPublicWidget = parser(publicWidgetSchema);\n\nexport function parsePublicWidget<Input>(input: Input) {\n parsePublicWidgetContract(input);\n return parseSdkPublicWidget(input);\n}\n\nexport function parsePublicWidgetLoad<Input>(input: Input) {\n const response = safeParse(\n looseObject({ quote: optional(unknown()) }),\n input\n );\n const widget = parsePublicWidget(input);\n const quote = response.success ? response.output.quote : undefined;\n return quote === undefined\n ? { widget }\n : { quote: parseCheckoutQuote(quote), widget };\n}\n","import {\n array,\n boolean,\n type InferOutput,\n literal,\n looseObject,\n minLength,\n nullable,\n object,\n optional,\n parser,\n picklist,\n pipe,\n record,\n strictObject,\n string,\n transform,\n union,\n unknown,\n} from \"valibot\";\n\nimport { parseCheckoutQuote } from \"./checkout-schemas.ts\";\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst checkoutPricingEntries = {\n email: optional(string()),\n includeServiceFee: optional(boolean()),\n promoCode: optional(string()),\n tipCents: optional(safeIntegerSchema(0)),\n};\n\nconst checkoutPricingInputSchema = strictObject(checkoutPricingEntries);\n\nexport const parseCheckoutPricingInput = parser(\n optional(checkoutPricingInputSchema, {})\n);\n\nconst paymentSubmissionSchema = 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 paymentMethodConfiguration: optional(literal(\"explicit\")),\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\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\nconst checkoutItemsSchema = pipe(array(checkoutItemSchema), minLength(1));\nconst checkoutSelectionItemsSchema = pipe(\n array(checkoutSelectionItemSchema),\n minLength(1)\n);\n\nconst loadCheckoutInputSchema = object({\n selection: checkoutSelectionItemsSchema,\n});\n\nconst calculateTotalInputSchema = looseObject({\n catalog: optional(unknown()),\n email: optional(unknown()),\n includeServiceFee: optional(unknown()),\n items: optional(checkoutItemsSchema),\n promoCode: optional(unknown()),\n selection: optional(checkoutSelectionItemsSchema),\n tipCents: optional(unknown()),\n});\n\nconst preparedCheckoutInputSchema = pipe(\n looseObject({\n authoritative: literal(true),\n items: checkoutItemsSchema,\n payment: object({\n connectedAccountId: nullable(nonEmptyStringSchema),\n currency: literal(\"usd\"),\n publishableKey: pipe(string(), minLength(1)),\n }),\n paymentReference: pipe(string(), minLength(1)),\n pricing: checkoutPricingInputSchema,\n }),\n transform((checkout) => {\n const { items, payment, paymentReference, pricing, ...quoteInput } =\n checkout;\n const parsedQuote = parseCheckoutQuote({\n ...quoteInput,\n connectedAccountId: payment.connectedAccountId,\n });\n const { connectedAccountId, ...quote } = parsedQuote;\n return {\n items,\n pricing,\n quote: {\n ...quote,\n authoritative: true as const,\n payment: {\n connectedAccountId,\n currency: \"usd\" as const,\n publishableKey: payment.publishableKey,\n },\n paymentOption: parsedQuote.paymentOption,\n paymentReference,\n },\n };\n })\n);\n\nconst submitPaymentInputSchema = looseObject({\n checkout: preparedCheckoutInputSchema,\n submission: paymentSubmissionSchema,\n});\n\nconst paymentReferenceInputSchema = nonEmptyStringSchema;\nconst parseCatalogInputFields = parser(looseObject({}));\n\nexport type ParsedPreparedCheckoutInput = InferOutput<\n typeof preparedCheckoutInputSchema\n>;\nexport type ParsedLoadCheckoutInput = InferOutput<\n typeof loadCheckoutInputSchema\n>;\nexport type ParsedPaymentReferenceInput = InferOutput<\n typeof paymentReferenceInputSchema\n>;\nexport type ParsedSubmitPaymentInput = InferOutput<\n typeof submitPaymentInputSchema\n>;\n\nconst parseCalculateTotalInputFields = parser(calculateTotalInputSchema);\n\nexport function parseCalculateTotalInput<Input>(input: Input) {\n const { catalog, items, selection, ...pricingInput } =\n parseCalculateTotalInputFields(input);\n let parsedCatalog: ReturnType<typeof parseCatalogInputFields>;\n try {\n parsedCatalog = parseCatalogInputFields(catalog);\n } catch (error) {\n throw new TypeError(\"A catalog is required to calculate a checkout.\", {\n cause: error,\n });\n }\n try {\n return {\n catalog: parsedCatalog,\n items,\n pricing: parseCheckoutPricingInput(pricingInput),\n selection,\n };\n } catch (error) {\n throw new TypeError(\"Checkout pricing input is invalid.\", { cause: error });\n }\n}\n\nexport type ParsedCalculateTotalInput = ReturnType<\n typeof parseCalculateTotalInput\n>;\nexport type ParsedCheckoutPricingInput = InferOutput<\n typeof checkoutPricingInputSchema\n>;\n\nexport const parseLoadCheckoutInput = parser(loadCheckoutInputSchema);\nexport const parsePaymentReferenceInput = parser(paymentReferenceInputSchema);\nexport const parsePreparedCheckoutInput = parser(preparedCheckoutInputSchema);\nexport const parseSubmitPaymentInput = parser(submitPaymentInputSchema);\n\nexport const parseCheckoutSelectionItems = parser(checkoutSelectionItemsSchema);\n","import type { LockerverseProduct } from \"./types.ts\";\n\nconst minimumCustomAmountCents = 100;\n\nexport function getLockerverseMinimumCustomAmountCents(\n product: Pick<LockerverseProduct, \"minimumAmountCents\">\n) {\n return Math.max(minimumCustomAmountCents, product.minimumAmountCents ?? 0);\n}\n","import type { LockerverseCatalog, LockerverseProduct } from \"./types.ts\";\n\nexport type LockerverseProductAvailability = {\n /** Total quantity of this product that fits with the other selected items. */\n maximumQuantity: number | null;\n status: \"available\" | \"limit_reached\" | \"sold_out\";\n};\n\nfunction otherSelectedQuantities(\n catalog: LockerverseCatalog,\n productId: string,\n quantities: Readonly<Record<string, number>>\n) {\n const selectedByListing = new Map<string, number>();\n for (const other of catalog.products) {\n const quantity = quantities[other.id] ?? 0;\n if (!Number.isSafeInteger(quantity) || quantity < 0) {\n throw new TypeError(\n \"Selected package quantities must be nonnegative integers.\"\n );\n }\n if (other.id !== productId && quantity > 0) {\n selectedByListing.set(\n other.listingId,\n (selectedByListing.get(other.listingId) ?? 0) + quantity\n );\n }\n }\n return selectedByListing;\n}\n\n/** Pass nonnegative integer package quantities keyed by product ID, or omit them for an empty cart. */\nexport function getLockerverseProductAvailability(\n catalog: LockerverseCatalog,\n product: LockerverseProduct,\n quantities: Readonly<Record<string, number>> = {}\n): LockerverseProductAvailability {\n const listing = catalog.availability.listings.find(\n (entry) => entry.listingId === product.listingId\n );\n const listingMaximum = Math.min(\n listing?.maxPurchasableQuantity ?? Number.POSITIVE_INFINITY,\n listing?.remainingQuantity ?? Number.POSITIVE_INFINITY\n );\n const selectedByListing = otherSelectedQuantities(\n catalog,\n product.id,\n quantities\n );\n let available = Math.min(\n product.maximumQuantity ?? Number.POSITIVE_INFINITY,\n product.inventoryQuantity ?? Number.POSITIVE_INFINITY,\n listing?.status === \"sold_out\" ? 0 : listingMaximum\n );\n let maximum = Math.min(\n available,\n listingMaximum - (selectedByListing.get(product.listingId) ?? 0)\n );\n for (const limit of catalog.availability.sharedLimits) {\n if (!limit.listingIds.includes(product.listingId)) {\n continue;\n }\n const weight = limit.listingWeights?.[product.listingId] ?? 1;\n const remaining = limit.status === \"sold_out\" ? 0 : limit.remainingQuantity;\n const used = limit.listingIds.reduce(\n (total, id) =>\n total +\n (selectedByListing.get(id) ?? 0) * (limit.listingWeights?.[id] ?? 1),\n 0\n );\n available = Math.min(available, Math.floor(remaining / weight));\n maximum = Math.min(maximum, Math.floor((remaining - used) / weight));\n }\n maximum = Math.max(0, maximum);\n const minimum = product.minimumQuantity ?? 1;\n let status: LockerverseProductAvailability[\"status\"] = \"available\";\n if (available < minimum) {\n status = \"sold_out\";\n } else if (maximum < minimum || (quantities[product.id] ?? 0) >= maximum) {\n status = \"limit_reached\";\n }\n return { maximumQuantity: Number.isFinite(maximum) ? maximum : null, status };\n}\n","import { parseCheckoutSelectionItems } from \"./checkout-input-schemas.ts\";\nimport { getLockerverseMinimumCustomAmountCents } from \"./custom-amount.ts\";\nimport { getLockerverseProductAvailability } from \"./product-availability.ts\";\nimport type {\n LockerverseCatalog,\n LockerverseCheckoutItem,\n LockerverseCheckoutLineItem,\n LockerverseCheckoutSelectionItem,\n LockerverseProduct,\n} from \"./types.ts\";\nimport { LockerverseSdkError } from \"./types.ts\";\n\ntype ResolvedSelectionItem = {\n checkoutItem: LockerverseCheckoutItem;\n quantity: number;\n unitAmountCents: number;\n};\n\nexport function assertCheckoutItemsAreAvailable(\n catalog: LockerverseCatalog,\n items: LockerverseCheckoutItem[]\n) {\n const quantities: Record<string, number> = {};\n for (const item of items) {\n quantities[item.productId] =\n (quantities[item.productId] ?? 0) +\n (\"quantity\" in item ? item.quantity : 1);\n }\n const unavailable = catalog.products.some((product) => {\n const requested = quantities[product.id];\n if (!requested) {\n return false;\n }\n const { maximumQuantity, status } = getLockerverseProductAvailability(\n catalog,\n product,\n quantities\n );\n return (\n status === \"sold_out\" ||\n (maximumQuantity !== null && requested > maximumQuantity)\n );\n });\n if (unavailable) {\n throw new LockerverseSdkError({\n code: \"total_calculation_failed\",\n message: \"This option is sold out.\",\n operation: \"calculate_total\",\n reportable: false,\n serverCode: \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\",\n });\n }\n}\n\nfunction resolveAmountItem(\n product: LockerverseProduct,\n amountCents: number\n): ResolvedSelectionItem {\n if (\n product.pricingMode !== \"custom\" ||\n product.paymentOption !== \"one-time\" ||\n amountCents < getLockerverseMinimumCustomAmountCents(product)\n ) {\n throw new TypeError(\"Selected Product amount is invalid.\");\n }\n return {\n checkoutItem: { amountCents, productId: product.id },\n quantity: 1,\n unitAmountCents: amountCents,\n };\n}\n\nfunction resolveFixedItem(\n product: LockerverseProduct,\n quantity: number\n): ResolvedSelectionItem {\n if (product.pricingMode !== \"fixed\" || product.amountCents === null) {\n throw new TypeError(\"Selected Product quantity is invalid.\");\n }\n if (product.paymentOption !== \"one-time\" && quantity !== 1) {\n throw new TypeError(\"Selected recurring Product is invalid.\");\n }\n if (\n (product.minimumQuantity !== null && quantity < product.minimumQuantity) ||\n (product.maximumQuantity !== null && quantity > product.maximumQuantity) ||\n (product.inventoryQuantity !== null && quantity > product.inventoryQuantity)\n ) {\n throw new TypeError(\"Selected Product quantity is invalid.\");\n }\n return {\n checkoutItem:\n product.paymentOption === \"one-time\"\n ? { productId: product.id, quantity }\n : { productId: product.id },\n quantity,\n unitAmountCents: product.amountCents,\n };\n}\n\nfunction resolveSelectionItem(\n catalog: LockerverseCatalog,\n product: LockerverseProduct,\n selection: LockerverseCheckoutSelectionItem\n) {\n const selectedQuantity = \"quantity\" in selection ? selection.quantity : 1;\n const resolved =\n \"amountCents\" in selection\n ? resolveAmountItem(product, selection.amountCents)\n : resolveFixedItem(product, selectedQuantity);\n const { checkoutItem, quantity, unitAmountCents } = resolved;\n\n return {\n checkoutItem,\n lineItem: {\n acceptsDiscounts: product.acceptsDiscounts,\n eventId:\n product.fulfillmentType === \"event_admission\" && catalog.event\n ? catalog.event.id\n : null,\n fulfillmentType: product.fulfillmentType,\n listingId: product.listingId,\n listingSlug: product.slug,\n paymentOption: product.paymentOption,\n pricingMode: product.pricingMode,\n productId: product.id,\n productName: product.name,\n quantity,\n subtotalCents: unitAmountCents * quantity,\n unitAmountCents,\n } satisfies LockerverseCheckoutLineItem,\n };\n}\n\nexport function resolveCheckoutSelection(\n catalog: LockerverseCatalog,\n input: LockerverseCheckoutSelectionItem[]\n) {\n let selection = parseCheckoutSelectionItems(input);\n const shipping = catalog.widget.requiredShipping;\n if (shipping) {\n const shippingProduct = catalog.products.find(\n ({ id }) => id === shipping.productId\n );\n const needsShipping = selection.some((item) =>\n catalog.products.some(\n (product) =>\n product.slug === item.productSlug &&\n shipping.triggerProductIds.includes(product.id)\n )\n );\n selection = selection.filter(\n (item) => item.productSlug !== shippingProduct?.slug\n );\n if (needsShipping) {\n if (!shippingProduct) {\n throw new TypeError(\"Required shipping Product is unavailable.\");\n }\n selection.push({ productSlug: shippingProduct.slug, quantity: 1 });\n }\n }\n const selectedProducts = new Set<string>();\n const resolved = selection.map((item) => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product) {\n throw new TypeError(\"Selected Product is unavailable.\");\n }\n if (selectedProducts.has(product.id)) {\n throw new TypeError(\"Each Product can appear only once per checkout.\");\n }\n selectedProducts.add(product.id);\n return resolveSelectionItem(catalog, product, item);\n });\n if (shipping?.additionalUnitAmountCents) {\n const triggerQuantity = resolved.reduce(\n (total, { lineItem }) =>\n total +\n (shipping.triggerProductIds.includes(lineItem.productId)\n ? lineItem.quantity\n : 0),\n 0\n );\n const shippingLine = resolved.find(\n ({ lineItem }) => lineItem.productId === shipping.productId\n )?.lineItem;\n if (shippingLine) {\n const amountCents =\n shippingLine.unitAmountCents +\n Math.max(0, triggerQuantity - 1) * shipping.additionalUnitAmountCents;\n if (!Number.isSafeInteger(amountCents) || amountCents > 2_147_483_647) {\n throw new TypeError(\"Required shipping amount is invalid.\");\n }\n shippingLine.unitAmountCents = amountCents;\n shippingLine.subtotalCents = amountCents;\n }\n }\n const paymentOption = resolved[0]?.lineItem.paymentOption;\n if (!paymentOption) {\n throw new TypeError(\"Select at least one Product.\");\n }\n if (\n resolved.length > 1 &&\n (paymentOption !== \"one-time\" ||\n resolved.some(({ lineItem }) => lineItem.paymentOption !== paymentOption))\n ) {\n throw new TypeError(\"Recurring Products must be purchased separately.\");\n }\n const items = resolved.map(({ checkoutItem }) => checkoutItem);\n assertCheckoutItemsAreAvailable(catalog, items);\n return {\n items,\n lineItems: resolved.map(({ lineItem }) => lineItem),\n paymentOption,\n };\n}\n","import type { PublicProductListing, PublicWidget } from \"./checkout-schemas.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport type {\n LockerverseCatalog,\n LockerverseCommunityBranding,\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 fulfillmentType: product.fulfillmentType,\n id: product.id,\n inventoryQuantity: product.inventoryQuantity,\n listingId: listing.id,\n maximumQuantity: listing.maxQuantityPerOrder,\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\nfunction mapCommunity(\n community: PublicWidget[\"community\"]\n): LockerverseCommunityBranding | null {\n if (!community) {\n return null;\n }\n const branding: LockerverseCommunityBranding = {\n accentColor: community.color,\n imageUrl: community.thumbnail || null,\n name: community.name,\n };\n if (community.widgetAchEnabled !== undefined) {\n branding.widgetAchEnabled = community.widgetAchEnabled;\n }\n if (community.memberIdLabel !== undefined) {\n branding.memberIdLabel = community.memberIdLabel;\n }\n return branding;\n}\n\nexport function createCatalog(widget: PublicWidget): LockerverseCatalog {\n const fields = widget.config?.fields ?? {};\n\n return {\n availability: widget.availability,\n community: mapCommunity(widget.community),\n event: widget.event\n ? {\n description: widget.event.description,\n endAt: widget.event.endAt,\n id: widget.event.id,\n location: widget.event.location,\n name: widget.event.name,\n startAt: widget.event.startAt,\n status: widget.event.status,\n }\n : null,\n payment: {\n connectedAccountId: widget.payment.connectedAccountId,\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 requiredShipping: widget.config?.requiredShipping,\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 { object, picklist, safeParse } from \"valibot\";\nimport { resolveWidgetEnvironment } from \"./checkout-environment.ts\";\nimport {\n type ParsedCalculateTotalInput,\n type ParsedCheckoutPricingInput,\n parseCalculateTotalInput,\n parseLoadCheckoutInput,\n parsePaymentReferenceInput,\n parseSubmitPaymentInput,\n} from \"./checkout-input-schemas.ts\";\nimport {\n parseCatalog,\n parseCheckoutQuote,\n parsePaymentResult,\n parsePublicWidgetLoad,\n} from \"./checkout-schemas.ts\";\nimport {\n assertCheckoutItemsAreAvailable,\n resolveCheckoutSelection,\n} from \"./checkout-selection.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 LockerverseCalculateTotalInput,\n type LockerverseCatalog,\n type LockerverseCheckoutClient,\n type LockerverseCheckoutItem,\n type LockerverseCheckoutPricingInput,\n type LockerverseCheckoutSelectionItem,\n type LockerverseLoadCheckoutInput,\n type LockerverseLoadedCheckout,\n type LockerversePreparedCheckout,\n LockerverseSdkError,\n type LockerverseSdkOperation,\n type LockerverseSdkServerCode,\n type LockerverseSubmitPaymentInput,\n} from \"./types.ts\";\n\ntype OperationErrorContext = {\n code:\n | \"payment_status_failed\"\n | \"payment_submit_failed\"\n | \"total_calculation_failed\"\n | \"widget_load_failed\";\n message: string;\n operation:\n | \"calculate_total\"\n | \"get_payment_status\"\n | \"load_widget\"\n | \"submit_payment\";\n};\n\nconst MAX_SELECTED_WIDGET_URL_LENGTH = 4000;\nconst paymentServerErrorSchema = object({\n code: picklist([\n \"PAYMENT_WIDGET_PHONE_INVALID\",\n \"PAYMENT_WIDGET_PHONE_REQUIRED\",\n \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\",\n ]),\n});\n\nasync function readPaymentServerCode(\n response: Response\n): Promise<LockerverseSdkServerCode | undefined> {\n if (response.status !== 400 && response.status !== 409) {\n return;\n }\n try {\n const result = safeParse(paymentServerErrorSchema, await response.json());\n return result.success ? result.output.code : undefined;\n } catch {\n // Non-JSON error bodies do not contain a safe server code.\n }\n}\n\nfunction resolveCalculateTotalItems({\n catalog,\n items,\n selection,\n}: ParsedCalculateTotalInput) {\n if (items !== undefined && selection !== undefined) {\n throw new TypeError(\"Use items or selection, not both.\");\n }\n const selectionCatalog = cloneCatalog(parseCatalog(catalog));\n const checkoutItems =\n selection === undefined\n ? requireCheckoutItems(items)\n : resolveCheckoutSelection(selectionCatalog, selection).items;\n assertCheckoutItemsAreAvailable(selectionCatalog, checkoutItems);\n return {\n catalog: selectionCatalog,\n items: checkoutItems,\n };\n}\n\nfunction requireCheckoutItems(\n items: ParsedCalculateTotalInput[\"items\"]\n): LockerverseCheckoutItem[] {\n if (items === undefined) {\n throw new TypeError(\"Checkout selection is invalid.\");\n }\n return items;\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 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 const widgetUrl = `${apiBaseUrl}/v2/community/${communitySlug}/payment-widgets/${widgetSlug}`;\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<ErrorValue>(\n error: ErrorValue,\n context: OperationErrorContext\n ) {\n return error instanceof LockerverseSdkError\n ? error\n : new LockerverseSdkError({ ...context, reportable: true });\n }\n\n function failOperation<ErrorValue>(\n error: ErrorValue,\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 if (!recoveryRecommended) {\n throw reportError(normalized);\n }\n const recoveryError = new LockerverseSdkError({\n code: normalized.code,\n failureKind: normalized.failureKind,\n message: normalized.message,\n operation: normalized.operation,\n recoveryRecommended: true,\n reportable: normalized.reportable,\n status: normalized.status,\n });\n throw reportError(recoveryError);\n }\n\n function normalizePricingInput(input: ParsedCheckoutPricingInput) {\n const email = input.email?.trim().toLowerCase();\n const promoCode = input.promoCode?.trim();\n const pricing: LockerverseCheckoutPricingInput = {};\n if (email) {\n pricing.email = email;\n }\n if (input.includeServiceFee !== undefined) {\n pricing.includeServiceFee = input.includeServiceFee;\n }\n if (promoCode) {\n pricing.promoCode = promoCode;\n }\n if (input.tipCents !== undefined) {\n pricing.tipCents = input.tipCents;\n }\n return pricing;\n }\n\n function normalizeLoadSelection(input: LockerverseLoadCheckoutInput) {\n try {\n return parseLoadCheckoutInput(input).selection;\n } catch {\n invalidInput(\"Checkout selection is invalid.\", \"load_widget\");\n }\n }\n\n function createPreparedCheckout(\n quote: ReturnType<typeof parseCheckoutQuote>,\n items: LockerverseCheckoutItem[],\n pricing: LockerverseCheckoutPricingInput,\n payment: LockerverseCatalog[\"payment\"]\n ): LockerversePreparedCheckout {\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: payment.publishableKey,\n },\n paymentOption: quote.paymentOption,\n paymentReference: globalThis.crypto.randomUUID(),\n pricing,\n })\n );\n }\n\n function resolveSelectedCheckoutItems(\n catalog: LockerverseCatalog,\n selection: LockerverseCheckoutSelectionItem[],\n operation: LockerverseSdkOperation\n ) {\n try {\n return resolveCheckoutSelection(catalog, selection).items;\n } catch (error) {\n if (error instanceof TypeError) {\n invalidInput(error.message, operation);\n }\n throw error;\n }\n }\n\n function createSelectedCheckout(\n catalog: LockerverseCatalog,\n selection: LockerverseCheckoutSelectionItem[],\n quote: ReturnType<typeof parseCheckoutQuote> | undefined,\n context: OperationErrorContext\n ) {\n if (!quote) {\n throw new LockerverseSdkError({\n ...context,\n message: \"Lockerverse did not return the requested initial quote.\",\n reportable: true,\n });\n }\n const checkoutItems = resolveSelectedCheckoutItems(\n catalog,\n selection,\n context.operation\n );\n return deepFreeze({\n catalog: cloneCatalog(catalog),\n checkout: createPreparedCheckout(\n quote,\n checkoutItems,\n { includeServiceFee: catalog.widget.fields.serviceFee },\n catalog.payment\n ),\n });\n }\n\n function requestWidgetResource(): Promise<LockerverseCatalog>;\n function requestWidgetResource(\n selection: LockerverseCheckoutSelectionItem[]\n ): Promise<LockerverseLoadedCheckout>;\n async function requestWidgetResource(\n selection?: LockerverseCheckoutSelectionItem[]\n ): Promise<LockerverseCatalog | LockerverseLoadedCheckout> {\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 const requestUrl = selection\n ? `${widgetUrl}?selection=${encodeURIComponent(JSON.stringify(selection))}`\n : widgetUrl;\n const request = () =>\n requestJson(\n requestUrl,\n selection ? { cache: \"no-store\" } : undefined,\n parsePublicWidgetLoad,\n {\n ...context,\n message:\n \"Unable to load Lockerverse widget because the request failed.\",\n report: false,\n },\n { ...context, report: false },\n readPaymentServerCode\n );\n async function requestWithRetry() {\n try {\n return await request();\n } catch (error) {\n if (\n !(error instanceof LockerverseSdkError) ||\n (error.failureKind !== \"network\" && error.failureKind !== \"timeout\")\n ) {\n throw error;\n }\n }\n // Retry only this public GET. A checkout POST can create an uncertain payment.\n return request();\n }\n const response = await requestWithRetry();\n if (!response.ok) {\n const serverCode = response.errorValue;\n if (serverCode === \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\") {\n throw new LockerverseSdkError({\n ...context,\n message: \"This option is sold out.\",\n reportable: false,\n serverCode,\n status: response.response.status,\n });\n }\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.widget));\n if (!selection) {\n return cloneCatalog(catalog);\n }\n return createSelectedCheckout(\n catalog,\n selection,\n response.value.quote,\n context\n );\n }\n\n async function loadLargeSelection(\n selection: LockerverseCheckoutSelectionItem[],\n context: OperationErrorContext\n ): Promise<LockerverseLoadedCheckout> {\n const loaded = await requestWidgetResource();\n const pricing = {\n includeServiceFee: loaded.widget.fields.serviceFee,\n };\n const items = resolveSelectedCheckoutItems(\n loaded,\n selection,\n context.operation\n );\n return deepFreeze({\n catalog: loaded,\n checkout: await requestCheckoutQuote(\n items,\n pricing,\n loaded.payment,\n context\n ),\n });\n }\n\n async function loadWidget(\n selection?: LockerverseCheckoutSelectionItem[]\n ): Promise<LockerverseCatalog | LockerverseLoadedCheckout> {\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 if (\n selection &&\n `${widgetUrl}?selection=${encodeURIComponent(JSON.stringify(selection))}`\n .length > MAX_SELECTED_WIDGET_URL_LENGTH\n ) {\n return await loadLargeSelection(selection, context);\n }\n return selection\n ? await requestWidgetResource(selection)\n : await requestWidgetResource();\n } catch (error) {\n failOperation(error, context);\n }\n }\n\n function load(): Promise<LockerverseCatalog>;\n function load(\n input: LockerverseLoadCheckoutInput\n ): Promise<LockerverseLoadedCheckout>;\n function load(input?: LockerverseLoadCheckoutInput) {\n return input === undefined\n ? loadWidget()\n : loadWidget(normalizeLoadSelection(input));\n }\n\n async function requestCheckoutQuote(\n items: LockerverseCheckoutItem[],\n pricing: LockerverseCheckoutPricingInput,\n payment: LockerverseCatalog[\"payment\"],\n context: OperationErrorContext\n ) {\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 readPaymentServerCode\n );\n if (!response.ok) {\n const serverCode = response.errorValue;\n if (serverCode === \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\") {\n throw new LockerverseSdkError({\n ...context,\n message: \"This option is sold out.\",\n reportable: false,\n serverCode,\n status: response.response.status,\n });\n }\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, payment);\n }\n\n async function calculateTotal(input: LockerverseCalculateTotalInput) {\n const { catalog, 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 return await requestCheckoutQuote(\n items,\n pricing,\n catalog.payment,\n context\n );\n } catch (error) {\n failOperation(error, context);\n }\n }\n\n function normalizeCalculateTotalInput(input: LockerverseCalculateTotalInput) {\n try {\n const parsed = parseCalculateTotalInput(input);\n const resolved = resolveCalculateTotalItems(parsed);\n const pricing = normalizePricingInput(parsed.pricing);\n return {\n catalog: resolved.catalog,\n items: resolved.items,\n pricing:\n pricing.includeServiceFee === undefined\n ? {\n ...pricing,\n includeServiceFee: resolved.catalog.widget.fields.serviceFee,\n }\n : pricing,\n };\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw error;\n }\n invalidInput(\n error instanceof TypeError\n ? error.message\n : \"Checkout selection is invalid.\",\n \"calculate_total\"\n );\n }\n }\n\n function normalizeSubmitPaymentInput(input: LockerverseSubmitPaymentInput) {\n try {\n const parsed = parseSubmitPaymentInput(input);\n const {\n items,\n pricing: pricingInput,\n quote: quoteInput,\n } = parsed.checkout;\n const pricing = normalizePricingInput(pricingInput);\n const quote = deepFreeze(quoteInput);\n const { submission } = parsed;\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 calculateTotal,\n async getPaymentStatus(paymentReference) {\n let normalizedReference: string;\n try {\n normalizedReference =\n parsePaymentReferenceInput(paymentReference).trim();\n } catch {\n invalidInput(\n \"Provide a payment reference to recover its status.\",\n \"get_payment_status\"\n );\n }\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 load,\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 confirmationToken: submission.confirmationToken,\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 paymentMethodConfiguration: submission.paymentMethodConfiguration,\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 readPaymentServerCode\n );\n if (!response.ok) {\n const serverCode = response.errorValue;\n if (serverCode) {\n throw new LockerverseSdkError({\n ...context,\n message:\n serverCode === \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\"\n ? \"This option is sold out.\"\n : `Unable to submit the Lockerverse payment (${response.response.status}).`,\n reportable: false,\n serverCode,\n status: response.response.status,\n });\n }\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","import { parseCheckoutPricingInput } from \"./checkout-input-schemas.ts\";\nimport { resolveCheckoutSelection } from \"./checkout-selection.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport type {\n LockerverseCatalog,\n LockerverseCheckoutEstimate,\n LockerverseEstimateCheckoutInput,\n} from \"./types.ts\";\n\nexport function estimateLockerverseCheckout(\n catalog: LockerverseCatalog,\n input: LockerverseEstimateCheckoutInput\n): LockerverseCheckoutEstimate {\n const { selection, ...pricingInput } = input;\n let pricing: ReturnType<typeof parseCheckoutPricingInput>;\n try {\n pricing = parseCheckoutPricingInput(pricingInput);\n } catch (error) {\n throw new TypeError(\"Checkout pricing is invalid.\", { cause: error });\n }\n const includeServiceFee =\n pricing.includeServiceFee ?? catalog.widget.fields.serviceFee;\n const { tipCents = 0 } = pricing;\n const { items, lineItems, paymentOption } = resolveCheckoutSelection(\n catalog,\n selection\n );\n const subtotalCents = lineItems.reduce(\n (total, lineItem) => total + lineItem.subtotalCents,\n 0\n );\n if (\n !Number.isSafeInteger(subtotalCents) ||\n subtotalCents <= 0 ||\n subtotalCents > 2_147_483_647\n ) {\n throw new TypeError(\"Checkout total is invalid.\");\n }\n const discountableSubtotalCents = lineItems.reduce(\n (total, lineItem) =>\n total + (lineItem.acceptsDiscounts ? lineItem.subtotalCents : 0),\n 0\n );\n const serviceFeeCents = includeServiceFee\n ? Math.round(\n (subtotalCents * catalog.pricingPolicy.serviceFeeRateBasisPoints) /\n 10_000\n )\n : 0;\n const amountCents = subtotalCents + serviceFeeCents;\n const totalCents = amountCents + tipCents;\n if (!Number.isSafeInteger(totalCents) || totalCents > 2_147_483_647) {\n throw new TypeError(\"Checkout total is invalid.\");\n }\n\n return deepFreeze({\n amountCents,\n appliedDiscount: null,\n authoritative: false,\n discountableSubtotalCents,\n discountCents: 0,\n items,\n lineItems,\n paymentOption,\n serviceFeeCents,\n subtotalCents,\n tipCents,\n totalCents,\n });\n}\n"],"mappings":"yiBAGA,SAAgB,GACd,EACA,CACA,IAAM,EAAU,EAA2B,EAAS,YAAY,EAChE,MAAO,CACL,GAAG,EACH,WAAY,EAAQ,aACpB,gBAAiB,EAAQ,iBAC3B,CACF,CC0BA,MAAM,EAAsB,EAAS,CACnC,WACA,UACA,WACA,kBACF,CAAC,EACK,EAAwB,EAAS,CAAC,OAAQ,iBAAiB,CAAC,EAC5D,EAAmC,EAAS,EAAkB,CAAC,CAAC,EAChE,EAA2B,EAAS,CAAC,YAAa,UAAU,CAAC,EAC7D,EAAqB,EACzB,EAAO,CACL,SAAU,EACR,EAAO,CACL,UAAW,EACX,uBAAwB,EACxB,kBAAmB,EACnB,OAAQ,CACV,CAAC,CACH,EACA,aAAc,EACZ,EAAO,CACL,GAAI,EACJ,WAAY,EAAM,CAAoB,EACtC,eAAgB,EACd,EAAO,EAAsB,EAAkB,CAAC,CAAC,EACjD,CAAC,CACH,EACA,kBAAmB,EAAkB,CAAC,EACtC,OAAQ,CACV,CAAC,CACH,CACF,CAAC,EACD,CAAE,SAAU,CAAC,EAAG,aAAc,CAAC,CAAE,CACnC,EACM,EAAuB,EAC3B,EAAO,EACP,EAAM,yBAA0B,0BAA0B,CAC5D,EAEM,EAAqB,CACzB,YAAa,EACb,gBAAiB,EACjB,GAAI,EACJ,kBAAmB,EACnB,YAAa,EACb,mBAAoB,EACpB,YAAa,EACb,KAAM,EACN,cAAe,CACjB,EAEM,EAAc,EAAO,CACzB,YAAa,EAAS,EAAO,CAAC,EAC9B,MAAO,EACP,GAAI,EACJ,SAAU,EAAS,EAAO,CAAC,EAC3B,KAAM,EACN,QAAS,EACT,OAAQ,EAAS,CAAC,QAAS,SAAU,WAAY,WAAW,CAAC,CAC/D,CAAC,EAEK,GAAsB,GAAQ,cAAe,CACjD,EAAO,CACL,GAA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types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAGY;KAKA;KACA;cAEC;KAED;EACV;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;;EAEA;EACA;EACA;;KAGU;KAEA;EACV,UAAU;IACR;IACA;IACA;IACA,QAAQ;;EAEV,cAAc;IACZ;IACA;IACA;IACA,QAAQ;;;KAIA;EACV,cAAc;EACd,WAAW;EACX,OAAO;EACP,SAAS;EACT,eAAe;EACf,UAAU;EACV,QAAQ;;KAGE;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EAAiC;EAAY;;KAEpD;EACH;EACA;EACA;EACA;;KAGU,6BAA6B;EACvC;;KAGU,gCAAgC;EAC1C;;KAGU,qCAAqC;EAC/C,SAAS;EACT;;KAGU,oCAAoC;EAC9C,SAAS;EACT;;KAGU,yBACR,gCACA,6BACA,qCACA;KAEQ,kCACV,cAAc,0BACZ,cAAc,0CAEd,cAAc;KAIN,6BACV,cAAc,yBAAyB,0BACrC,cAAc;EACZ,SAAS;EAAa,OAAO,kCAAkC;;KAGzD;EACV;IAEM;IACA;IACA;;EAGN,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;;KAGU;KAgBA;KAqBA;KAOA;cAMC,4BAA4B;WAC9B,aAAa;WACb,MAAM;WACN,WAAW;WACX;WACA;WACA;WACA,YAAY;WACZ;EAEG,cACV,aACA,MACA,SACA,WACA,YACA,qBACA,YACA;IAEA,cAAc;IACd,MAAM;IACN;IACA,WAAW;IACX;IACA;IACA,aAAa;IACb;;;KAeQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B;EACrC,iBAAiB;EACjB;EACA;EACA,SAAS;EACT,eAAe;EACf,WAAW;;KAGD,8BAA8B;EACxC;EACA;EACA,gBAAgB;EAChB,oBAAoB;EACpB,eAAe;;KAGL;EACV;EACA;EACA;EACA;;KAGU;KAMA;EACV;EACA;EACA,gBAAgB;EAChB;EACA;EACA;EACA;EACA;;KAGU,+BAA+B;EACzC;EACA,oBAAoB;;KAYV;EACV;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;KAGU;EACV;EACA;EACA,qBAAqB;EACrB;EACA;EACA;EACA,WAAW;EACX;EACA,WAAW;;KAGD;EACN;EAAmB;;EACnB;EAAmB;;EACnB;;KAEM;EACN;EAAqB;;EACrB;EAAqB;;EACrB;;KAEM,mCACV;EACE,WAAW;;KAGH;EACV,WAAW;;KAGD,iCAAiC;EAC3C,SAAS;;EAGH,OAAO;EACP;;EAGA;EACA,WAAW;;KAIP,8BAA8B,SACxC;EACE,gBAAgB;EAChB,SAAS,SAAS;;KAIV,4BAA4B;EACtC,SAAS;EACT,UAAU;;KAGA;EACV,UAAU;EACV,YAAY;;KAGT;EACH;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;EACA;;KAGU;EAEN;EACA,aAAa;;EAGb;EACA;;KAGM,iCACV,qCAAqC;KAE3B;EACV,iBACE,OAAO,mCACJ,QAAQ;EACb,mBACE,6BACG,QAAQ;EACb;QACM,QAAQ;KACX,OAAO,+BAA+B,QAAQ;;EAEjD,gBACE,OAAO,kCACJ,QAAQ"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAGY;KAKA;KACA;cAEC;KAED;EACV;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;;EAEA;EACA;EACA;;KAGU;KAEA;EACV,UAAU;IACR;IACA;IACA;IACA,QAAQ;;EAEV,cAAc;IACZ;IACA;IACA,iBAAiB;IACjB;IACA,QAAQ;;;KAIA;EACV,cAAc;EACd,WAAW;EACX,OAAO;EACP,SAAS;EACT,eAAe;EACf,UAAU;EACV,QAAQ;;KAGE;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EAAiC;EAAY;;KAEpD;EACH;EACA;EACA;EACA;;KAGU,6BAA6B;EACvC;;KAGU,gCAAgC;EAC1C;;KAGU,qCAAqC;EAC/C,SAAS;EACT;;KAGU,oCAAoC;EAC9C,SAAS;EACT;;KAGU,yBACR,gCACA,6BACA,qCACA;KAEQ,kCACV,cAAc,0BACZ,cAAc,0CAEd,cAAc;KAIN,6BACV,cAAc,yBAAyB,0BACrC,cAAc;EACZ,SAAS;EAAa,OAAO,kCAAkC;;KAGzD;EACV;IAEM;IACA;IACA;;EAGN,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;;KAGU;KAgBA;KAqBA;KAOA;cAMC,4BAA4B;WAC9B,aAAa;WACb,MAAM;WACN,WAAW;WACX;WACA;WACA;WACA,YAAY;WACZ;EAEG,cACV,aACA,MACA,SACA,WACA,YACA,qBACA,YACA;IAEA,cAAc;IACd,MAAM;IACN;IACA,WAAW;IACX;IACA;IACA,aAAa;IACb;;;KAeQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B;EACrC,iBAAiB;EACjB;EACA;EACA,SAAS;EACT,eAAe;EACf,WAAW;;KAGD,8BAA8B;EACxC;EACA;EACA,gBAAgB;EAChB,oBAAoB;EACpB,eAAe;;KAGL;EACV;EACA;EACA;EACA;;KAGU;KAMA;EACV;EACA;EACA,gBAAgB;EAChB;EACA;EACA;EACA;EACA;;KAGU,+BAA+B;EACzC;EACA,oBAAoB;;KAYV;EACV;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;KAGU;EACV;EACA;EACA,qBAAqB;EACrB;EACA;EACA;EACA,WAAW;EACX;EACA,WAAW;;KAGD;EACN;EAAmB;;EACnB;EAAmB;;EACnB;;KAEM;EACN;EAAqB;;EACrB;EAAqB;;EACrB;;KAEM,mCACV;EACE,WAAW;;KAGH;EACV,WAAW;;KAGD,iCAAiC;EAC3C,SAAS;;EAGH,OAAO;EACP;;EAGA;EACA,WAAW;;KAIP,8BAA8B,SACxC;EACE,gBAAgB;EAChB,SAAS,SAAS;;KAIV,4BAA4B;EACtC,SAAS;EACT,UAAU;;KAGA;EACV,UAAU;EACV,YAAY;;KAGT;EACH;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;EACA;;KAGU;EAEN;EACA,aAAa;;EAGb;EACA;;KAGM,iCACV,qCAAqC;KAE3B;EACV,iBACE,OAAO,mCACJ,QAAQ;EACb,mBACE,6BACG,QAAQ;EACb;QACM,QAAQ;KACX,OAAO,+BAA+B,QAAQ;;EAEjD,gBACE,OAAO,kCACJ,QAAQ"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=`0.2.
|
|
1
|
+
const e=`0.2.242`;var t=class extends Error{failureKind;code;operation;reportable;recoveryRecommended;sdkVersion;serverCode;status;constructor({failureKind:t,code:n,message:r,operation:i,reportable:a,recoveryRecommended:o=!1,serverCode:s,status:c}){super(r),this.name=`LockerverseSdkError`,this.failureKind=t,this.code=n,this.operation=i,this.reportable=a,this.recoveryRecommended=o,this.sdkVersion=e,this.serverCode=s,this.status=c}};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 =\n | \"one-time\"\n | \"monthly\"\n | \"annually\"\n | \"every-six-months\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\nexport type LockerverseFulfillmentType = \"none\" | \"event_admission\";\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 fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n amountCents: number | null;\n minimumAmountCents: number | null;\n minimumQuantity: number | null;\n /** Per-order limit for this widget listing. Null means no per-order limit. */\n maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseAvailabilityStatus = \"available\" | \"sold_out\";\n\nexport type LockerverseCatalogAvailability = {\n listings: Array<{\n listingId: string;\n maxPurchasableQuantity: number | null;\n remainingQuantity: number | null;\n status: LockerverseAvailabilityStatus;\n }>;\n sharedLimits: Array<{\n id: string;\n listingIds: string[];\n remainingQuantity: number;\n status: LockerverseAvailabilityStatus;\n }>;\n};\n\nexport type LockerverseCatalog = {\n availability: LockerverseCatalogAvailability;\n community: LockerverseCommunityBranding | null;\n event: LockerverseEvent | null;\n payment: LockerversePaymentConfiguration;\n pricingPolicy: LockerverseCheckoutPricingPolicy;\n products: LockerverseProduct[];\n widget: LockerverseWidgetConfiguration;\n};\n\nexport type LockerverseEvent = {\n description: string | null;\n endAt: string;\n id: string;\n location: string | null;\n name: string;\n startAt: string;\n status: \"draft\" | \"active\" | \"finished\" | \"cancelled\";\n};\n\nexport type LockerverseCommunityBranding = {\n widgetAchEnabled?: boolean | undefined;\n accentColor: string;\n imageUrl: string | null;\n memberIdLabel?: string | null | undefined;\n name: string;\n};\n\nexport type LockerverseCheckoutPricingPolicy = {\n currency: \"usd\";\n serviceFeeRateBasisPoints: number;\n};\n\nexport type LockerversePaymentConfiguration = {\n connectedAccountId: string | null;\n currency: \"usd\";\n publishableKey: string;\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 paymentOptionIds?: string[] | undefined;\n required: boolean;\n};\n\nexport type LockerverseTextCustomField = LockerverseCustomFieldBase & {\n type: \"text\" | \"textarea\";\n};\n\nexport type LockerverseBooleanCustomField = LockerverseCustomFieldBase & {\n type: \"checkbox\";\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 | LockerverseBooleanCustomField\n | LockerverseTextCustomField\n | LockerverseSingleOptionCustomField\n | LockerverseMultiOptionCustomField;\n\nexport type LockerverseCustomFieldAnswerValue<\n Field extends LockerverseCustomField,\n> = Field extends LockerverseBooleanCustomField\n ? boolean\n : Field extends LockerverseMultiOptionCustomField\n ? string[]\n : 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 requiredShipping?:\n | {\n additionalUnitAmountCents?: number | undefined;\n productId: string;\n triggerProductIds: string[];\n }\n | undefined;\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 | \"booking_request_failed\"\n | \"public_events_load_failed\"\n | \"auction_load_failed\"\n | \"auction_bid_failed\"\n | \"auction_purchase_failed\"\n | \"auction_purchase_status_failed\"\n | \"auction_receipt_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 | \"load_booking_configuration\"\n | \"create_booking_session\"\n | \"find_booking_availability\"\n | \"initialize_booking\"\n | \"confirm_booking\"\n | \"recover_booking\"\n | \"list_public_events\"\n | \"list_auctions\"\n | \"load_auction\"\n | \"create_auction_bid\"\n | \"create_auction_purchase\"\n | \"get_auction_purchase_receipt\"\n | \"get_auction_purchase_status\"\n | \"load_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\";\n\nexport type LockerverseSdkServerCode =\n | \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\"\n | \"PAYMENT_WIDGET_PHONE_INVALID\"\n | \"PAYMENT_WIDGET_PHONE_REQUIRED\"\n | \"SIGN_UP_WIDGET_PHONE_INVALID\"\n | \"SIGN_UP_WIDGET_PHONE_REQUIRED\";\n\nexport type LockerverseSdkFailureKind =\n | \"network\"\n | \"timeout\"\n | \"aborted\"\n | \"invalid_response\";\n\nexport class LockerverseSdkError extends Error {\n readonly failureKind: LockerverseSdkFailureKind | undefined;\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly serverCode: LockerverseSdkServerCode | undefined;\n readonly status: number | undefined;\n\n constructor({\n failureKind,\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n serverCode,\n status,\n }: {\n failureKind?: LockerverseSdkFailureKind | undefined;\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n serverCode?: LockerverseSdkServerCode;\n status?: number | undefined;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.failureKind = failureKind;\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.serverCode = serverCode;\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 eventId: string | null;\n fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n quantity: number;\n unitAmountCents: number;\n subtotalCents: number;\n};\n\nexport type LockerverseAppliedDiscount = {\n percentageOff?: number | undefined;\n amountOffCents?: number | undefined;\n message?: string | undefined;\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: LockerversePaymentConfiguration;\n paymentOption: LockerversePaymentOption;\n lineItems: LockerverseCheckoutLineItem[];\n};\n\nexport type LockerverseCheckoutEstimate = LockerverseCheckoutAmounts & {\n appliedDiscount: null;\n authoritative: false;\n items: readonly LockerverseCheckoutItem[];\n lineItems: readonly LockerverseCheckoutLineItem[];\n paymentOption: LockerversePaymentOption;\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 retryUrl?: string | undefined;\n clientSecret: string | null;\n paymentRequired: boolean;\n requiresAction: boolean;\n status: string | null;\n};\n\nexport type LockerversePaymentCompletion = LockerversePaymentResult & {\n email: string | null;\n lineItems: readonly LockerverseCheckoutLineItem[] | 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 paymentMethodConfiguration?: \"explicit\";\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 LockerverseEstimateCheckoutInput =\n LockerverseCheckoutPricingInput & {\n selection: LockerverseCheckoutSelectionItem[];\n };\n\nexport type LockerverseLoadCheckoutInput = {\n selection: LockerverseCheckoutSelectionItem[];\n};\n\nexport type LockerverseCalculateTotalInput = LockerverseCheckoutPricingInput & {\n catalog: LockerverseCatalog;\n} & (\n | {\n items: LockerverseCheckoutItem[];\n selection?: never;\n }\n | {\n items?: never;\n selection: LockerverseCheckoutSelectionItem[];\n }\n );\n\nexport type LockerversePreparedCheckout = Readonly<\n LockerverseCheckoutQuote & {\n items: readonly LockerverseCheckoutItem[];\n pricing: Readonly<LockerverseCheckoutPricingInput>;\n }\n>;\n\nexport type LockerverseLoadedCheckout = 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 LockerverseResourceEnvironmentOptions =\n | {\n apiBaseUrl: string;\n environment: LockerverseEnvironment;\n }\n | {\n apiBaseUrl?: undefined;\n environment?: \"production\";\n };\n\nexport type CreateLockerverseWidgetOptions =\n CreateLockerverseWidgetBaseOptions & LockerverseResourceEnvironmentOptions;\n\nexport type LockerverseCheckoutClient = {\n calculateTotal: (\n input: LockerverseCalculateTotalInput\n ) => Promise<LockerversePreparedCheckout>;\n getPaymentStatus: (\n paymentReference: string\n ) => Promise<LockerversePaymentResult>;\n load: {\n (): Promise<LockerverseCatalog>;\n (input: LockerverseLoadCheckoutInput): Promise<LockerverseLoadedCheckout>;\n };\n submitPayment: (\n input: LockerverseSubmitPaymentInput\n ) => Promise<LockerversePaymentResult>;\n};\n"],"mappings":"ACWA,MAAa,EAA0BA,UAwMvC,IAAa,EAAb,cAAyC,KAAM,CAC7C,YACA,KACA,UACA,WACA,oBACA,WACA,WACA,OAEA,YAAY,CACV,cACA,OACA,UACA,YACA,aACA,sBAAsB,GACtB,aACA,UAUC,CACD,MAAM,CAAO,EACb,KAAK,KAAO,sBACZ,KAAK,YAAc,EACnB,KAAK,KAAO,EACZ,KAAK,UAAY,EACjB,KAAK,WAAa,EAClB,KAAK,oBAAsB,EAC3B,KAAK,WAAa,EAClB,KAAK,WAAa,EAClB,KAAK,OAAS,CAChB,CACF"}
|
|
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 =\n | \"one-time\"\n | \"monthly\"\n | \"annually\"\n | \"every-six-months\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\nexport type LockerverseFulfillmentType = \"none\" | \"event_admission\";\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 fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n amountCents: number | null;\n minimumAmountCents: number | null;\n minimumQuantity: number | null;\n /** Per-order limit for this widget listing. Null means no per-order limit. */\n maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseAvailabilityStatus = \"available\" | \"sold_out\";\n\nexport type LockerverseCatalogAvailability = {\n listings: Array<{\n listingId: string;\n maxPurchasableQuantity: number | null;\n remainingQuantity: number | null;\n status: LockerverseAvailabilityStatus;\n }>;\n sharedLimits: Array<{\n id: string;\n listingIds: string[];\n listingWeights?: Record<string, number>;\n remainingQuantity: number;\n status: LockerverseAvailabilityStatus;\n }>;\n};\n\nexport type LockerverseCatalog = {\n availability: LockerverseCatalogAvailability;\n community: LockerverseCommunityBranding | null;\n event: LockerverseEvent | null;\n payment: LockerversePaymentConfiguration;\n pricingPolicy: LockerverseCheckoutPricingPolicy;\n products: LockerverseProduct[];\n widget: LockerverseWidgetConfiguration;\n};\n\nexport type LockerverseEvent = {\n description: string | null;\n endAt: string;\n id: string;\n location: string | null;\n name: string;\n startAt: string;\n status: \"draft\" | \"active\" | \"finished\" | \"cancelled\";\n};\n\nexport type LockerverseCommunityBranding = {\n widgetAchEnabled?: boolean | undefined;\n accentColor: string;\n imageUrl: string | null;\n memberIdLabel?: string | null | undefined;\n name: string;\n};\n\nexport type LockerverseCheckoutPricingPolicy = {\n currency: \"usd\";\n serviceFeeRateBasisPoints: number;\n};\n\nexport type LockerversePaymentConfiguration = {\n connectedAccountId: string | null;\n currency: \"usd\";\n publishableKey: string;\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 paymentOptionIds?: string[] | undefined;\n required: boolean;\n};\n\nexport type LockerverseTextCustomField = LockerverseCustomFieldBase & {\n type: \"text\" | \"textarea\";\n};\n\nexport type LockerverseBooleanCustomField = LockerverseCustomFieldBase & {\n type: \"checkbox\";\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 | LockerverseBooleanCustomField\n | LockerverseTextCustomField\n | LockerverseSingleOptionCustomField\n | LockerverseMultiOptionCustomField;\n\nexport type LockerverseCustomFieldAnswerValue<\n Field extends LockerverseCustomField,\n> = Field extends LockerverseBooleanCustomField\n ? boolean\n : Field extends LockerverseMultiOptionCustomField\n ? string[]\n : 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 requiredShipping?:\n | {\n additionalUnitAmountCents?: number | undefined;\n productId: string;\n triggerProductIds: string[];\n }\n | undefined;\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 | \"booking_request_failed\"\n | \"public_events_load_failed\"\n | \"auction_load_failed\"\n | \"auction_bid_failed\"\n | \"auction_purchase_failed\"\n | \"auction_purchase_status_failed\"\n | \"auction_receipt_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 | \"load_booking_configuration\"\n | \"create_booking_session\"\n | \"find_booking_availability\"\n | \"initialize_booking\"\n | \"confirm_booking\"\n | \"recover_booking\"\n | \"list_public_events\"\n | \"list_auctions\"\n | \"load_auction\"\n | \"create_auction_bid\"\n | \"create_auction_purchase\"\n | \"get_auction_purchase_receipt\"\n | \"get_auction_purchase_status\"\n | \"load_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\";\n\nexport type LockerverseSdkServerCode =\n | \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\"\n | \"PAYMENT_WIDGET_PHONE_INVALID\"\n | \"PAYMENT_WIDGET_PHONE_REQUIRED\"\n | \"SIGN_UP_WIDGET_PHONE_INVALID\"\n | \"SIGN_UP_WIDGET_PHONE_REQUIRED\";\n\nexport type LockerverseSdkFailureKind =\n | \"network\"\n | \"timeout\"\n | \"aborted\"\n | \"invalid_response\";\n\nexport class LockerverseSdkError extends Error {\n readonly failureKind: LockerverseSdkFailureKind | undefined;\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly serverCode: LockerverseSdkServerCode | undefined;\n readonly status: number | undefined;\n\n constructor({\n failureKind,\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n serverCode,\n status,\n }: {\n failureKind?: LockerverseSdkFailureKind | undefined;\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n serverCode?: LockerverseSdkServerCode;\n status?: number | undefined;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.failureKind = failureKind;\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.serverCode = serverCode;\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 eventId: string | null;\n fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n quantity: number;\n unitAmountCents: number;\n subtotalCents: number;\n};\n\nexport type LockerverseAppliedDiscount = {\n percentageOff?: number | undefined;\n amountOffCents?: number | undefined;\n message?: string | undefined;\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: LockerversePaymentConfiguration;\n paymentOption: LockerversePaymentOption;\n lineItems: LockerverseCheckoutLineItem[];\n};\n\nexport type LockerverseCheckoutEstimate = LockerverseCheckoutAmounts & {\n appliedDiscount: null;\n authoritative: false;\n items: readonly LockerverseCheckoutItem[];\n lineItems: readonly LockerverseCheckoutLineItem[];\n paymentOption: LockerversePaymentOption;\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 retryUrl?: string | undefined;\n clientSecret: string | null;\n paymentRequired: boolean;\n requiresAction: boolean;\n status: string | null;\n};\n\nexport type LockerversePaymentCompletion = LockerversePaymentResult & {\n email: string | null;\n lineItems: readonly LockerverseCheckoutLineItem[] | 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 paymentMethodConfiguration?: \"explicit\";\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 LockerverseEstimateCheckoutInput =\n LockerverseCheckoutPricingInput & {\n selection: LockerverseCheckoutSelectionItem[];\n };\n\nexport type LockerverseLoadCheckoutInput = {\n selection: LockerverseCheckoutSelectionItem[];\n};\n\nexport type LockerverseCalculateTotalInput = LockerverseCheckoutPricingInput & {\n catalog: LockerverseCatalog;\n} & (\n | {\n items: LockerverseCheckoutItem[];\n selection?: never;\n }\n | {\n items?: never;\n selection: LockerverseCheckoutSelectionItem[];\n }\n );\n\nexport type LockerversePreparedCheckout = Readonly<\n LockerverseCheckoutQuote & {\n items: readonly LockerverseCheckoutItem[];\n pricing: Readonly<LockerverseCheckoutPricingInput>;\n }\n>;\n\nexport type LockerverseLoadedCheckout = 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 LockerverseResourceEnvironmentOptions =\n | {\n apiBaseUrl: string;\n environment: LockerverseEnvironment;\n }\n | {\n apiBaseUrl?: undefined;\n environment?: \"production\";\n };\n\nexport type CreateLockerverseWidgetOptions =\n CreateLockerverseWidgetBaseOptions & LockerverseResourceEnvironmentOptions;\n\nexport type LockerverseCheckoutClient = {\n calculateTotal: (\n input: LockerverseCalculateTotalInput\n ) => Promise<LockerversePreparedCheckout>;\n getPaymentStatus: (\n paymentReference: string\n ) => Promise<LockerversePaymentResult>;\n load: {\n (): Promise<LockerverseCatalog>;\n (input: LockerverseLoadCheckoutInput): Promise<LockerverseLoadedCheckout>;\n };\n submitPayment: (\n input: LockerverseSubmitPaymentInput\n ) => Promise<LockerversePaymentResult>;\n};\n"],"mappings":"ACWA,MAAa,EAA0BA,UAyMvC,IAAa,EAAb,cAAyC,KAAM,CAC7C,YACA,KACA,UACA,WACA,oBACA,WACA,WACA,OAEA,YAAY,CACV,cACA,OACA,UACA,YACA,aACA,sBAAsB,GACtB,aACA,UAUC,CACD,MAAM,CAAO,EACb,KAAK,KAAO,sBACZ,KAAK,YAAc,EACnB,KAAK,KAAO,EACZ,KAAK,UAAY,EACjB,KAAK,WAAa,EAClB,KAAK,oBAAsB,EAC3B,KAAK,WAAa,EAClB,KAAK,WAAa,EAClB,KAAK,OAAS,CAChB,CACF"}
|