@lockerverse/sdk 0.2.91 → 0.2.92

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.
@@ -1,4 +1,4 @@
1
- import { A as LockerversePaymentOption, B as LockerverseShipping, C as LockerverseEvent, D as LockerverseMultiOptionCustomField, E as LockerverseLoadedCheckout, F as LockerverseProduct, G as LockerverseWidgetFields, H as LockerverseSubmitPaymentInput, I as LockerverseResourceEnvironmentOptions, L as LockerverseSdkError, M as LockerversePaymentStatus, N as LockerversePaymentSubmission, O as LockerversePaymentCompletion, P as LockerversePreparedCheckout, R as LockerverseSdkErrorCode, S as LockerverseEstimateCheckoutInput, T as LockerverseLoadCheckoutInput, U as LockerverseTextCustomField, V as LockerverseSingleOptionCustomField, W as LockerverseWidgetConfiguration, _ as LockerverseCustomField, a as LockerverseCalculateTotalInput, b as LockerverseCustomFieldOption, c as LockerverseCheckoutClient, d as LockerverseCheckoutLineItem, f as LockerverseCheckoutPricingInput, g as LockerverseCommunityBranding, h as LockerverseCheckoutSelectionItem, i as LockerverseBooleanCustomField, j as LockerversePaymentResult, k as LockerversePaymentConfiguration, l as LockerverseCheckoutEstimate, m as LockerverseCheckoutQuote, n as LOCKERVERSE_SDK_VERSION, o as LockerverseCatalog, p as LockerverseCheckoutPricingPolicy, r as LockerverseAppliedDiscount, s as LockerverseCheckoutAmounts, t as CreateLockerverseWidgetOptions, u as LockerverseCheckoutItem, v as LockerverseCustomFieldAnswer, w as LockerverseFulfillmentType, x as LockerverseEnvironment, y as LockerverseCustomFieldAnswerValue, z as LockerverseSdkOperation } from "./types.js";
1
+ import { A as LockerversePaymentOption, B as LockerverseSdkServerCode, C as LockerverseEvent, D as LockerverseMultiOptionCustomField, E as LockerverseLoadedCheckout, F as LockerverseProduct, G as LockerverseWidgetConfiguration, H as LockerverseSingleOptionCustomField, I as LockerverseResourceEnvironmentOptions, K as LockerverseWidgetFields, L as LockerverseSdkError, M as LockerversePaymentStatus, N as LockerversePaymentSubmission, O as LockerversePaymentCompletion, P as LockerversePreparedCheckout, R as LockerverseSdkErrorCode, S as LockerverseEstimateCheckoutInput, T as LockerverseLoadCheckoutInput, U as LockerverseSubmitPaymentInput, V as LockerverseShipping, W as LockerverseTextCustomField, _ as LockerverseCustomField, a as LockerverseCalculateTotalInput, b as LockerverseCustomFieldOption, c as LockerverseCheckoutClient, d as LockerverseCheckoutLineItem, f as LockerverseCheckoutPricingInput, g as LockerverseCommunityBranding, h as LockerverseCheckoutSelectionItem, i as LockerverseBooleanCustomField, j as LockerversePaymentResult, k as LockerversePaymentConfiguration, l as LockerverseCheckoutEstimate, m as LockerverseCheckoutQuote, n as LOCKERVERSE_SDK_VERSION, o as LockerverseCatalog, p as LockerverseCheckoutPricingPolicy, r as LockerverseAppliedDiscount, s as LockerverseCheckoutAmounts, t as CreateLockerverseWidgetOptions, u as LockerverseCheckoutItem, v as LockerverseCustomFieldAnswer, w as LockerverseFulfillmentType, x as LockerverseEnvironment, y as LockerverseCustomFieldAnswerValue, z as LockerverseSdkOperation } from "./types.js";
2
2
  //#region src/checkout-client.d.ts
3
3
  declare function createLockerverseCheckoutClient(options: CreateLockerverseWidgetOptions): LockerverseCheckoutClient;
4
4
  //#endregion
@@ -8,5 +8,5 @@ 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
- export { CreateLockerverseWidgetOptions, LOCKERVERSE_SDK_VERSION, LockerverseAppliedDiscount, LockerverseBooleanCustomField, LockerverseCalculateTotalInput, LockerverseCatalog, 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, LockerverseResourceEnvironmentOptions, LockerverseSdkError, LockerverseSdkErrorCode, LockerverseSdkOperation, LockerverseShipping, LockerverseSingleOptionCustomField, LockerverseSubmitPaymentInput, LockerverseTextCustomField, LockerverseWidgetConfiguration, LockerverseWidgetFields, createLockerverseCheckoutClient, estimateLockerverseCheckout, getLockerverseMinimumCustomAmountCents };
11
+ export { CreateLockerverseWidgetOptions, LOCKERVERSE_SDK_VERSION, LockerverseAppliedDiscount, LockerverseBooleanCustomField, LockerverseCalculateTotalInput, LockerverseCatalog, 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, LockerverseResourceEnvironmentOptions, LockerverseSdkError, LockerverseSdkErrorCode, LockerverseSdkOperation, LockerverseSdkServerCode, LockerverseShipping, LockerverseSingleOptionCustomField, LockerverseSubmitPaymentInput, LockerverseTextCustomField, LockerverseWidgetConfiguration, LockerverseWidgetFields, createLockerverseCheckoutClient, estimateLockerverseCheckout, getLockerverseMinimumCustomAmountCents };
12
12
  //# sourceMappingURL=checkout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkout.d.ts","names":[],"sources":["../src/checkout-client.ts","../src/checkout-estimate.ts","../src/custom-amount.ts"],"mappings":";;iBAoFgB,gCACd,SAAS,iCACR;;;iBC7Ea,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"],"mappings":";;iBA6GgB,gCACd,SAAS,iCACR;;;iBCtGa,4BACd,SAAS,oBACT,OAAO,mCACN;;;iBCRa,uCACd,SAAS,KAAK"}
package/dist/checkout.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,d as n,i as r,l as i,m as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./transport.js";import{n as f,t as p}from"./types.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`]),R=O([`none`,`event_admission`]),z=C(t(0)),re=k(N(),A(/^pk_(?:test|live)_\S+$/,`Invalid publishable key.`)),B={description:l,fulfillmentType:R,id:s,inventoryQuantity:z,maxQuantity:z,minimumAmountCents:z,minQuantity:z,name:s,paymentOption:L},V=T({description:C(N()),endAt:s,id:s,location:C(N()),name:s,startAt:s,status:O([`draft`,`active`,`finished`,`cancelled`])}),ie=k(te(`pricingMode`,[T({...B,amountCents:t(0),pricingMode:v(`fixed`)}),T({...B,amountCents:z,pricingMode:v(`custom`)})]),g(({maxQuantity:e,minQuantity:t})=>e===null||t===null||t<=e)),ae=T({acceptsDiscounts:E(h(),!1),id:s,product:ie,productId:s,slug:s}),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)}),{}),oe=k(T({community:E(T({color:N(),name:s,thumbnail:C(N())})),config:E(T({customFields:e,fields:H})),description:l,event:C(V),id:E(N(),``),name:E(N(),`Lockerverse widget`),payment:T({connectedAccountId:E(C(s),null),currency:v(`usd`),publishableKey:re}),pricingPolicy:E(T({currency:E(v(`usd`),`usd`),serviceFeeRateBasisPoints:E(t(0),0)})),products:E(m(ae),[]),showCommunityBranding:E(h(),!0),title:l}),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}},pricingPolicy:e.pricingPolicy??{currency:`usd`,serviceFeeRateBasisPoints:0}}))),se=T({acceptsDiscounts:h(),amountCents:C(t(0)),description:C(N()),fulfillmentType:R,id:s,inventoryQuantity:z,listingId:s,maximumQuantity:z,minimumAmountCents:z,minimumQuantity:z,name:s,paymentOption:L,pricingMode:O([`fixed`,`custom`]),slug:s}),ce=T({community:C(T({accentColor:N(),imageUrl:C(N()),name:s})),event:C(V),payment:T({connectedAccountId:E(C(s),null),currency:v(`usd`),publishableKey:re}),pricingPolicy:T({currency:v(`usd`),serviceFeeRateBasisPoints:t(0)}),products:m(se),widget:T({customFields:e,description:C(N()),fields:H,id:N(),name:s,showCommunityBranding:h(),title:C(N())})}),le=C(T({percentageOff:k(w(),_(),S(0),b(100)),source:O([`email_list`,`promo_code`])})),ue=T({acceptsDiscounts:h(),eventId:C(s),fulfillmentType:R,listingId:s,listingSlug:s,paymentOption:L,pricingMode:O([`fixed`,`custom`]),productId:s,productName:s,quantity:t(1),subtotalCents:t(0),unitAmountCents:t(0)}),de=k(d,T({amountCents:t(0),appliedDiscount:le,connectedAccountId:C(s),discountableSubtotalCents:t(0),discountCents:t(0),lineItems:m(ue),paymentOption:L,serviceFeeCents:t(0),subtotalCents:t(0),tipCents:t(0),totalCents:t(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.`)),fe=k(i,g(e=>e.checkoutId.trim()&&e.paymentReference.trim()?e.checkoutStatus===`action_required`?e.requiresAction&&e.paymentRequired&&!!e.clientSecret?.trim():!e.requiresAction&&e.clientSecret===null:!1,`Invalid payment result state.`)),U=D(de),pe=D(ce),W=D(fe),me=D(n),he=D(oe);function ge(e){return he(me(e))}function _e(e){let t=j(y({quote:E(I())}),e),n=ge(e),r=t.success?t.output.quote:void 0;return r===void 0?{widget:n}:{quote:U(r),widget:n}}const ve={email:E(N()),includeServiceFee:E(h()),promoCode:E(N()),tipCents:E(t(0))},G=M(ve),K=D(E(G,{})),ye=M({confirmationToken:E(s),customFieldAnswers:E(m(r)),email:N(),memberId:E(N()),merchSize:E(O([`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`])),metadata:E(ee(N(),N())),phone:E(N()),shipping:E(M({address:M({city:N(),country:N(),line1:N(),line2:E(N()),postal_code:N(),state:N()}),name:N()}))}),be=F([M({amountCents:t(1),productId:s}),M({productId:s,quantity:t(1)}),M({productId:s})]),xe=F([M({amountCents:t(1),productSlug:s}),M({productSlug:s,quantity:t(1)}),M({productSlug:s})]),q=k(m(be),x(1)),J=k(m(xe),x(1)),Se=T({selection:J}),Ce=y({catalog:E(I()),email:E(I()),includeServiceFee:E(I()),items:E(q),promoCode:E(I()),selection:E(J),tipCents:E(I())}),Y=k(y({authoritative:v(!0),items:q,payment:T({connectedAccountId:C(s),currency:v(`usd`),publishableKey:k(N(),x(1))}),paymentReference:k(N(),x(1)),pricing:G}),P(e=>{let{items:t,payment:n,paymentReference:r,pricing:i,...a}=e,o=U({...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}}})),we=y({checkout:Y,submission:ye}),Te=s,Ee=D(y({})),De=D(Ce);function Oe(e){let{catalog:t,items:n,selection:r,...i}=De(e),a;try{a=Ee(t)}catch(e){throw TypeError(`A catalog is required to calculate a checkout.`,{cause:e})}try{return{catalog:a,items:n,pricing:K(i),selection:r}}catch(e){throw TypeError(`Checkout pricing input is invalid.`,{cause:e})}}const ke=D(Se),Ae=D(Te);D(Y);const je=D(we),Me=D(J);function X(e){return Math.max(100,e.minimumAmountCents??0)}function Ne(e,t){if(e.pricingMode!==`custom`||e.paymentOption!==`one-time`||t<X(e))throw TypeError(`Selected Product amount is invalid.`);return{checkoutItem:{amountCents:t,productId:e.id},quantity:1,unitAmountCents:t}}function Pe(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 Fe(e,t,n){let r=`quantity`in n?n.quantity:1,{checkoutItem:i,quantity:a,unitAmountCents:o}=`amountCents`in n?Ne(t,n.amountCents):Pe(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 Z(e,t){let n=Me(t),r=new Set,i=n.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);if(!n)throw TypeError(`Selected Product is unavailable.`);if(r.has(n.id))throw TypeError(`Each Product can appear only once per checkout.`);return r.add(n.id),Fe(e,n,t)}),a=i[0]?.lineItem.paymentOption;if(!a)throw TypeError(`Select at least one Product.`);if(i.length>1&&(a!==`one-time`||i.some(({lineItem:e})=>e.paymentOption!==a)))throw TypeError(`Recurring Products must be purchased separately.`);return{items:i.map(({checkoutItem:e})=>e),lineItems:i.map(({lineItem:e})=>e),paymentOption:a}}function Ie(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:t.maxQuantity,minimumAmountCents:t.minimumAmountCents,minimumQuantity:t.minQuantity,name:t.name,paymentOption:t.paymentOption,pricingMode:t.pricingMode,slug:e.slug}}function Le(e){let t=e.config?.fields??{};return{community:e.community?{accentColor:e.community.color,imageUrl:e.community.thumbnail||null,name:e.community.name}:null,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(Ie),widget:{customFields:e.config?.customFields??[],description:e.description??null,fields:{memberId:t.memberId??!1,merchSize:t.merchSize??!1,phone:t.phone??!1,promoCode:t.promoCode??!1,serviceFee:t.serviceFee??!1,shipping:t.shipping??!1,tipping:t.tipping??!1},id:e.id??``,name:e.name??`Lockerverse widget`,showCommunityBranding:e.showCommunityBranding??!0,title:e.title??null}}}function Q(e){return $(e)}function Re(e){return $(e)}function ze(e){return $(e)}function $(e){return c(structuredClone(e))}function Be({catalog:e,items:t,selection:n}){if(t!==void 0&&n!==void 0)throw TypeError(`Use items or selection, not both.`);let r=Q(pe(e));return{catalog:r,items:n===void 0?Ve(t):Z(r,n).items}}function Ve(e){if(e===void 0)throw TypeError(`Checkout selection is invalid.`);return e}function He(e){let{apiBaseUrl:t,communitySlug:n,communitySlugValue:r,environment:i,fetchImplementation:a,onError:s,requestTimeoutMs:l,sentryDsn:d,widgetSlug:p,widgetSlugValue:m}=ne(e),h=o({communitySlug:r,environment:i,getContext:()=>({widgetSlug:m}),onError:s,resourceContextName:`lockerverse_widget`,sentryDsn:d}),{requestJson:g}=u(a,h,l),_=`${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 f({code:n,message:e,operation:t,reportable:!1}))}function b(e,t){return e instanceof f?e:new f({...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=r.status===void 0?new f({code:r.code,message:r.message,operation:r.operation,recoveryRecommended:!0,reportable:r.reportable}):new f({code:r.code,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 ke(e).selection}catch{y(`Checkout selection is invalid.`,`load_widget`)}}function w(e,t,n,r){let{connectedAccountId:i,...a}=e;return Re(c({...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 Z(e,t).items}catch(e){throw e instanceof TypeError&&y(e.message,n),e}}function E(e,t,n,r){if(!n)throw new f({...r,message:`Lockerverse did not return the requested initial quote.`,reportable:!0});let i=T(e,t,r.operation);return c({catalog:Q(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=await g(n,e?{cache:`no-store`}:void 0,_e,{...t,message:`Unable to load Lockerverse widget because the request failed.`,report:!1},{...t,report:!1});if(!r.ok)throw new f({...t,message:`Unable to load Lockerverse widget (${r.response.status}).`,reportable:r.response.status>=500,status:r.response.status});let i=c(Le(r.value.widget));return e?E(i,e,r.value.quote,t):Q(i)}async function O(e,t){let n=await D(),r={includeServiceFee:n.widget.fields.serviceFee},i=T(n,e,t.operation);return c({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`},U,{...r,message:`Unable to calculate the Lockerverse checkout total because the request failed.`,report:!1},{...r,report:!1});if(!i.ok)throw new f({...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=Oe(e),n=Be(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 f)throw e;y(e instanceof TypeError?e.message:`Checkout selection is invalid.`,`calculate_total`)}}function N(e){try{let t=je(e),{items:n,pricing:r,quote:i}=t.checkout,a=S(r),o=c(i),{submission:s}=t;o.totalCents>0&&!s.confirmationToken&&y(`Stripe confirmation is required for a paid checkout.`,`submit_payment`,`payment_submit_failed`);let l=s.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:{...s,email:l}}}catch(e){if(e instanceof f)throw e;y(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}return{calculateTotal:j,async getPaymentStatus(e){let t;try{t=Ae(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,W,{...n,message:`Unable to recover the Lockerverse payment status because the request failed.`,report:!1},{...n,report:!1});if(!e.ok)throw new f({...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 f({...n,reportable:!0});return ze(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,paymentReference:r.paymentReference,phone:i.phone,quoteContractVersion:1,shipping:i.shipping}),headers:{"Content-Type":`application/json`},method:`POST`},W,{...a,message:`Unable to submit the Lockerverse payment because the request failed.`,report:!1},{...a,report:!1});if(!e.ok)throw new f({...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 f({...a,reportable:!0});return ze(e.value)}catch(e){x(e,a,!0)}}}}function Ue(e,t){let{selection:n,...r}=t,i;try{i=K(r)}catch(e){throw TypeError(`Checkout pricing is invalid.`,{cause:e})}let a=i.includeServiceFee??e.widget.fields.serviceFee,{tipCents:o=0}=i,{items:s,lineItems:l,paymentOption:u}=Z(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 c({amountCents:m,appliedDiscount:null,authoritative:!1,discountableSubtotalCents:f,discountCents:0,items:s,lineItems:l,paymentOption:u,serviceFeeCents:p,subtotalCents:d,tipCents:o,totalCents:h})}export{p as LOCKERVERSE_SDK_VERSION,f as LockerverseSdkError,He as createLockerverseCheckoutClient,Ue as estimateLockerverseCheckout,X as getLockerverseMinimumCustomAmountCents};
1
+ import{a as e,c as t,d as n,i as r,l as i,m as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./transport.js";import{n as f,t as p}from"./types.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`]),z=O([`none`,`event_admission`]),B=C(t(0)),ne=k(P(),j(/^pk_(?:test|live)_\S+$/,`Invalid publishable key.`)),re={description:l,fulfillmentType:z,id:s,inventoryQuantity:B,maxQuantity:B,minimumAmountCents:B,minQuantity:B,name:s,paymentOption:R},V=T({description:C(P()),endAt:s,id:s,location:C(P()),name:s,startAt:s,status:O([`draft`,`active`,`finished`,`cancelled`])}),ie=k(ee(`pricingMode`,[T({...re,amountCents:t(0),pricingMode:v(`fixed`)}),T({...re,amountCents:B,pricingMode:v(`custom`)})]),g(({maxQuantity:e,minQuantity:t})=>e===null||t===null||t<=e)),ae=T({acceptsDiscounts:E(h(),!1),id:s,product:ie,productId:s,slug:s}),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)}),{}),oe=k(T({community:E(T({color:P(),name:s,thumbnail:C(P())})),config:E(T({customFields:e,fields:H})),description:l,event:C(V),id:E(P(),``),name:E(P(),`Lockerverse widget`),payment:T({connectedAccountId:E(C(s),null),currency:v(`usd`),publishableKey:ne}),pricingPolicy:E(T({currency:E(v(`usd`),`usd`),serviceFeeRateBasisPoints:E(t(0),0)})),products:E(m(ae),[]),showCommunityBranding:E(h(),!0),title:l}),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}},pricingPolicy:e.pricingPolicy??{currency:`usd`,serviceFeeRateBasisPoints:0}}))),se=T({acceptsDiscounts:h(),amountCents:C(t(0)),description:C(P()),fulfillmentType:z,id:s,inventoryQuantity:B,listingId:s,maximumQuantity:B,minimumAmountCents:B,minimumQuantity:B,name:s,paymentOption:R,pricingMode:O([`fixed`,`custom`]),slug:s}),ce=T({community:C(T({accentColor:P(),imageUrl:C(P()),name:s})),event:C(V),payment:T({connectedAccountId:E(C(s),null),currency:v(`usd`),publishableKey:ne}),pricingPolicy:T({currency:v(`usd`),serviceFeeRateBasisPoints:t(0)}),products:m(se),widget:T({customFields:e,description:C(P()),fields:H,id:P(),name:s,showCommunityBranding:h(),title:C(P())})}),le=C(T({percentageOff:k(w(),_(),S(0),b(100)),source:O([`email_list`,`promo_code`])})),ue=T({acceptsDiscounts:h(),eventId:C(s),fulfillmentType:z,listingId:s,listingSlug:s,paymentOption:R,pricingMode:O([`fixed`,`custom`]),productId:s,productName:s,quantity:t(1),subtotalCents:t(0),unitAmountCents:t(0)}),de=k(d,T({amountCents:t(0),appliedDiscount:le,connectedAccountId:C(s),discountableSubtotalCents:t(0),discountCents:t(0),lineItems:m(ue),paymentOption:R,serviceFeeCents:t(0),subtotalCents:t(0),tipCents:t(0),totalCents:t(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.`)),fe=k(i,g(e=>e.checkoutId.trim()&&e.paymentReference.trim()?e.checkoutStatus===`action_required`?e.requiresAction&&e.paymentRequired&&!!e.clientSecret?.trim():!e.requiresAction&&e.clientSecret===null:!1,`Invalid payment result state.`)),U=D(de),pe=D(ce),W=D(fe),me=D(n),he=D(oe);function ge(e){return he(me(e))}function _e(e){let t=M(y({quote:E(L())}),e),n=ge(e),r=t.success?t.output.quote:void 0;return r===void 0?{widget:n}:{quote:U(r),widget:n}}const ve={email:E(P()),includeServiceFee:E(h()),promoCode:E(P()),tipCents:E(t(0))},G=N(ve),K=D(E(G,{})),ye=N({confirmationToken:E(s),customFieldAnswers:E(m(r)),email:P(),memberId:E(P()),merchSize:E(O([`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`])),metadata:E(A(P(),P())),phone:E(P()),shipping:E(N({address:N({city:P(),country:P(),line1:P(),line2:E(P()),postal_code:P(),state:P()}),name:P()}))}),be=I([N({amountCents:t(1),productId:s}),N({productId:s,quantity:t(1)}),N({productId:s})]),xe=I([N({amountCents:t(1),productSlug:s}),N({productSlug:s,quantity:t(1)}),N({productSlug:s})]),q=k(m(be),x(1)),J=k(m(xe),x(1)),Se=T({selection:J}),Ce=y({catalog:E(L()),email:E(L()),includeServiceFee:E(L()),items:E(q),promoCode:E(L()),selection:E(J),tipCents:E(L())}),Y=k(y({authoritative:v(!0),items:q,payment:T({connectedAccountId:C(s),currency:v(`usd`),publishableKey:k(P(),x(1))}),paymentReference:k(P(),x(1)),pricing:G}),F(e=>{let{items:t,payment:n,paymentReference:r,pricing:i,...a}=e,o=U({...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}}})),we=y({checkout:Y,submission:ye}),Te=s,Ee=D(y({})),De=D(Ce);function Oe(e){let{catalog:t,items:n,selection:r,...i}=De(e),a;try{a=Ee(t)}catch(e){throw TypeError(`A catalog is required to calculate a checkout.`,{cause:e})}try{return{catalog:a,items:n,pricing:K(i),selection:r}}catch(e){throw TypeError(`Checkout pricing input is invalid.`,{cause:e})}}const ke=D(Se),Ae=D(Te);D(Y);const je=D(we),Me=D(J);function X(e){return Math.max(100,e.minimumAmountCents??0)}function Ne(e,t){if(e.pricingMode!==`custom`||e.paymentOption!==`one-time`||t<X(e))throw TypeError(`Selected Product amount is invalid.`);return{checkoutItem:{amountCents:t,productId:e.id},quantity:1,unitAmountCents:t}}function Pe(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 Fe(e,t,n){let r=`quantity`in n?n.quantity:1,{checkoutItem:i,quantity:a,unitAmountCents:o}=`amountCents`in n?Ne(t,n.amountCents):Pe(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 Z(e,t){let n=Me(t),r=new Set,i=n.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);if(!n)throw TypeError(`Selected Product is unavailable.`);if(r.has(n.id))throw TypeError(`Each Product can appear only once per checkout.`);return r.add(n.id),Fe(e,n,t)}),a=i[0]?.lineItem.paymentOption;if(!a)throw TypeError(`Select at least one Product.`);if(i.length>1&&(a!==`one-time`||i.some(({lineItem:e})=>e.paymentOption!==a)))throw TypeError(`Recurring Products must be purchased separately.`);return{items:i.map(({checkoutItem:e})=>e),lineItems:i.map(({lineItem:e})=>e),paymentOption:a}}function Ie(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:t.maxQuantity,minimumAmountCents:t.minimumAmountCents,minimumQuantity:t.minQuantity,name:t.name,paymentOption:t.paymentOption,pricingMode:t.pricingMode,slug:e.slug}}function Le(e){let t=e.config?.fields??{};return{community:e.community?{accentColor:e.community.color,imageUrl:e.community.thumbnail||null,name:e.community.name}:null,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(Ie),widget:{customFields:e.config?.customFields??[],description:e.description??null,fields:{memberId:t.memberId??!1,merchSize:t.merchSize??!1,phone:t.phone??!1,promoCode:t.promoCode??!1,serviceFee:t.serviceFee??!1,shipping:t.shipping??!1,tipping:t.tipping??!1},id:e.id??``,name:e.name??`Lockerverse widget`,showCommunityBranding:e.showCommunityBranding??!0,title:e.title??null}}}function Q(e){return $(e)}function Re(e){return $(e)}function ze(e){return $(e)}function $(e){return c(structuredClone(e))}const Be=T({code:O([`PAYMENT_WIDGET_PHONE_INVALID`,`PAYMENT_WIDGET_PHONE_REQUIRED`])});async function Ve(e){if(e.status===400)try{let t=M(Be,await e.json());return t.success?t.output.code:void 0}catch{}}function He({catalog:e,items:t,selection:n}){if(t!==void 0&&n!==void 0)throw TypeError(`Use items or selection, not both.`);let r=Q(pe(e));return{catalog:r,items:n===void 0?Ue(t):Z(r,n).items}}function Ue(e){if(e===void 0)throw TypeError(`Checkout selection is invalid.`);return e}function We(e){let{apiBaseUrl:t,communitySlug:n,communitySlugValue:r,environment:i,fetchImplementation:a,onError:s,requestTimeoutMs:l,sentryDsn:d,widgetSlug:p,widgetSlugValue:m}=te(e),h=o({communitySlug:r,environment:i,getContext:()=>({widgetSlug:m}),onError:s,resourceContextName:`lockerverse_widget`,sentryDsn:d}),{requestJson:g}=u(a,h,l),_=`${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 f({code:n,message:e,operation:t,reportable:!1}))}function b(e,t){return e instanceof f?e:new f({...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=r.status===void 0?new f({code:r.code,message:r.message,operation:r.operation,recoveryRecommended:!0,reportable:r.reportable}):new f({code:r.code,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 ke(e).selection}catch{y(`Checkout selection is invalid.`,`load_widget`)}}function w(e,t,n,r){let{connectedAccountId:i,...a}=e;return Re(c({...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 Z(e,t).items}catch(e){throw e instanceof TypeError&&y(e.message,n),e}}function E(e,t,n,r){if(!n)throw new f({...r,message:`Lockerverse did not return the requested initial quote.`,reportable:!0});let i=T(e,t,r.operation);return c({catalog:Q(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=await g(n,e?{cache:`no-store`}:void 0,_e,{...t,message:`Unable to load Lockerverse widget because the request failed.`,report:!1},{...t,report:!1});if(!r.ok)throw new f({...t,message:`Unable to load Lockerverse widget (${r.response.status}).`,reportable:r.response.status>=500,status:r.response.status});let i=c(Le(r.value.widget));return e?E(i,e,r.value.quote,t):Q(i)}async function O(e,t){let n=await D(),r={includeServiceFee:n.widget.fields.serviceFee},i=T(n,e,t.operation);return c({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`},U,{...r,message:`Unable to calculate the Lockerverse checkout total because the request failed.`,report:!1},{...r,report:!1});if(!i.ok)throw new f({...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=Oe(e),n=He(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 f)throw e;y(e instanceof TypeError?e.message:`Checkout selection is invalid.`,`calculate_total`)}}function P(e){try{let t=je(e),{items:n,pricing:r,quote:i}=t.checkout,a=S(r),o=c(i),{submission:s}=t;o.totalCents>0&&!s.confirmationToken&&y(`Stripe confirmation is required for a paid checkout.`,`submit_payment`,`payment_submit_failed`);let l=s.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:{...s,email:l}}}catch(e){if(e instanceof f)throw e;y(`Lockerverse payment submission is invalid.`,`submit_payment`,`payment_submit_failed`)}}return{calculateTotal:M,async getPaymentStatus(e){let t;try{t=Ae(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,W,{...n,message:`Unable to recover the Lockerverse payment status because the request failed.`,report:!1},{...n,report:!1});if(!e.ok)throw new f({...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 f({...n,reportable:!0});return ze(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,paymentReference:r.paymentReference,phone:i.phone,quoteContractVersion:1,shipping:i.shipping}),headers:{"Content-Type":`application/json`},method:`POST`},W,{...a,message:`Unable to submit the Lockerverse payment because the request failed.`,report:!1},{...a,report:!1});if(!e.ok){let t=await Ve(e.response);throw t?new f({...a,message:`Unable to submit the Lockerverse payment (${e.response.status}).`,reportable:!1,serverCode:t,status:e.response.status}):new f({...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 f({...a,reportable:!0});return ze(e.value)}catch(e){x(e,a,!0)}}}}function Ge(e,t){let{selection:n,...r}=t,i;try{i=K(r)}catch(e){throw TypeError(`Checkout pricing is invalid.`,{cause:e})}let a=i.includeServiceFee??e.widget.fields.serviceFee,{tipCents:o=0}=i,{items:s,lineItems:l,paymentOption:u}=Z(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 c({amountCents:m,appliedDiscount:null,authoritative:!1,discountableSubtotalCents:f,discountCents:0,items:s,lineItems:l,paymentOption:u,serviceFeeCents:p,subtotalCents:d,tipCents:o,totalCents:h})}export{p as LOCKERVERSE_SDK_VERSION,f as LockerverseSdkError,We as createLockerverseCheckoutClient,Ge as estimateLockerverseCheckout,X as getLockerverseMinimumCustomAmountCents};
2
2
  //# sourceMappingURL=checkout.js.map
@@ -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([\"one-time\", \"monthly\", \"annually\"]);\nconst fulfillmentTypeSchema = picklist([\"none\", \"event_admission\"]);\nconst nullableNonNegativeIntegerSchema = nullable(safeIntegerSchema(0));\nconst publishableKeySchema = pipe(\n string(),\n regex(/^pk_(?:test|live)_\\S+$/, \"Invalid publishable key.\")\n);\n\nconst productBaseEntries = {\n description: optionalNullableStringSchema,\n 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 = pipe(\n variant(\"pricingMode\", [\n object({\n ...productBaseEntries,\n amountCents: safeIntegerSchema(0),\n pricingMode: literal(\"fixed\"),\n }),\n object({\n ...productBaseEntries,\n amountCents: nullableNonNegativeIntegerSchema,\n pricingMode: literal(\"custom\"),\n }),\n ]),\n check(\n ({ maxQuantity, minQuantity }) =>\n maxQuantity === null || minQuantity === null || minQuantity <= maxQuantity\n )\n);\n\nconst productListingSchema = object({\n acceptsDiscounts: optional(boolean(), false),\n id: nonEmptyStringSchema,\n product: publicProductSchema,\n productId: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n});\n\nconst widgetFieldsSchema = optional(\n object({\n memberId: optional(boolean(), false),\n merchSize: optional(boolean(), false),\n phone: optional(boolean(), false),\n promoCode: optional(boolean(), false),\n serviceFee: optional(boolean(), false),\n shipping: optional(boolean(), false),\n tipping: optional(boolean(), false),\n }),\n {}\n);\n\nexport const publicWidgetSchema = pipe(\n object({\n community: optional(\n object({\n color: string(),\n name: nonEmptyStringSchema,\n thumbnail: nullable(string()),\n })\n ),\n config: optional(\n object({\n customFields: customFieldsSchema,\n fields: widgetFieldsSchema,\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 },\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 community: nullable(\n object({\n accentColor: string(),\n imageUrl: nullable(string()),\n name: nonEmptyStringSchema,\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 showCommunityBranding: boolean(),\n title: nullable(string()),\n }),\n});\n\nconst appliedDiscountSchema = nullable(\n object({\n percentageOff: pipe(number(), finite(), minValue(0), maxValue(100)),\n source: picklist([\"email_list\", \"promo_code\"]),\n })\n);\n\nconst checkoutLineItemSchema = object({\n acceptsDiscounts: boolean(),\n 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 vPaymentWidgetPaymentResultResponseDto,\n check((payment) => {\n if (!(payment.checkoutId.trim() && payment.paymentReference.trim())) {\n return false;\n }\n if (payment.checkoutStatus === \"action_required\") {\n return (\n payment.requiresAction &&\n payment.paymentRequired &&\n Boolean(payment.clientSecret?.trim())\n );\n }\n return !payment.requiresAction && payment.clientSecret === null;\n }, \"Invalid payment result state.\")\n);\n\nexport 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 return parseSdkPublicWidget(parsePublicWidgetContract(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 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\";\n\ntype ResolvedSelectionItem = {\n checkoutItem: LockerverseCheckoutItem;\n quantity: number;\n unitAmountCents: number;\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 const selection = parseCheckoutSelectionItems(input);\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 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 return {\n items: resolved.map(({ checkoutItem }) => checkoutItem),\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 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: product.maxQuantity,\n minimumAmountCents: product.minimumAmountCents,\n minimumQuantity: product.minQuantity,\n name: product.name,\n paymentOption: product.paymentOption,\n pricingMode: product.pricingMode,\n slug: listing.slug,\n };\n}\n\nexport function createCatalog(widget: PublicWidget): LockerverseCatalog {\n const fields = widget.config?.fields ?? {};\n\n return {\n community: widget.community\n ? {\n accentColor: widget.community.color,\n imageUrl: widget.community.thumbnail || null,\n name: widget.community.name,\n }\n : null,\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 showCommunityBranding: widget.showCommunityBranding ?? true,\n title: widget.title ?? null,\n },\n };\n}\n\nexport function cloneCatalog(catalog: LockerverseCatalog): LockerverseCatalog {\n return cloneSnapshot(catalog);\n}\n\nexport function clonePreparedCheckout(\n checkout: LockerversePreparedCheckout\n): LockerversePreparedCheckout {\n return cloneSnapshot(checkout);\n}\n\nexport function clonePaymentResult(\n paymentResult: LockerversePaymentResult\n): LockerversePaymentResult {\n return cloneSnapshot(paymentResult);\n}\n\nfunction cloneSnapshot<T>(value: T): T {\n return deepFreeze(structuredClone(value));\n}\n","import { resolveWidgetEnvironment } from \"./checkout-environment.ts\";\nimport {\n 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 { resolveCheckoutSelection } 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 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;\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 return {\n catalog: selectionCatalog,\n items:\n selection === undefined\n ? requireCheckoutItems(items)\n : resolveCheckoutSelection(selectionCatalog, selection).items,\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 =\n normalized.status === undefined\n ? new LockerverseSdkError({\n code: normalized.code,\n message: normalized.message,\n operation: normalized.operation,\n recoveryRecommended: true,\n reportable: normalized.reportable,\n })\n : new LockerverseSdkError({\n code: normalized.code,\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 response = await 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 );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to load Lockerverse widget (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n const catalog = deepFreeze(createCatalog(response.value.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 );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to calculate the Lockerverse checkout total (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n return createPreparedCheckout(response.value, items, pricing, 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 paymentReference: quote.paymentReference,\n phone: submission.phone,\n quoteContractVersion: 1,\n shipping: submission.shipping,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parsePaymentResult,\n {\n ...context,\n message:\n \"Unable to submit the Lockerverse payment because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to submit the Lockerverse payment (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n if (response.value.paymentReference !== quote.paymentReference) {\n throw new LockerverseSdkError({ ...context, reportable: true });\n }\n return clonePaymentResult(response.value);\n } catch (error) {\n failOperation(error, context, true);\n }\n },\n };\n}\n","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":"qfAGA,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,CAAC,WAAY,UAAW,UAAU,CAAC,EAClE,EAAwB,EAAS,CAAC,OAAQ,iBAAiB,CAAC,EAC5D,EAAmC,EAAS,EAAkB,CAAC,CAAC,EAChE,GAAuB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AClD,OAAS,EAAO,CACd,MAAU,UAAU,+BAAgC,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/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([\"one-time\", \"monthly\", \"annually\"]);\nconst fulfillmentTypeSchema = picklist([\"none\", \"event_admission\"]);\nconst nullableNonNegativeIntegerSchema = nullable(safeIntegerSchema(0));\nconst publishableKeySchema = pipe(\n string(),\n regex(/^pk_(?:test|live)_\\S+$/, \"Invalid publishable key.\")\n);\n\nconst productBaseEntries = {\n description: optionalNullableStringSchema,\n 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 = pipe(\n variant(\"pricingMode\", [\n object({\n ...productBaseEntries,\n amountCents: safeIntegerSchema(0),\n pricingMode: literal(\"fixed\"),\n }),\n object({\n ...productBaseEntries,\n amountCents: nullableNonNegativeIntegerSchema,\n pricingMode: literal(\"custom\"),\n }),\n ]),\n check(\n ({ maxQuantity, minQuantity }) =>\n maxQuantity === null || minQuantity === null || minQuantity <= maxQuantity\n )\n);\n\nconst productListingSchema = object({\n acceptsDiscounts: optional(boolean(), false),\n id: nonEmptyStringSchema,\n product: publicProductSchema,\n productId: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n});\n\nconst widgetFieldsSchema = optional(\n object({\n memberId: optional(boolean(), false),\n merchSize: optional(boolean(), false),\n phone: optional(boolean(), false),\n promoCode: optional(boolean(), false),\n serviceFee: optional(boolean(), false),\n shipping: optional(boolean(), false),\n tipping: optional(boolean(), false),\n }),\n {}\n);\n\nexport const publicWidgetSchema = pipe(\n object({\n community: optional(\n object({\n color: string(),\n name: nonEmptyStringSchema,\n thumbnail: nullable(string()),\n })\n ),\n config: optional(\n object({\n customFields: customFieldsSchema,\n fields: widgetFieldsSchema,\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 },\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 community: nullable(\n object({\n accentColor: string(),\n imageUrl: nullable(string()),\n name: nonEmptyStringSchema,\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 showCommunityBranding: boolean(),\n title: nullable(string()),\n }),\n});\n\nconst appliedDiscountSchema = nullable(\n object({\n percentageOff: pipe(number(), finite(), minValue(0), maxValue(100)),\n source: picklist([\"email_list\", \"promo_code\"]),\n })\n);\n\nconst checkoutLineItemSchema = object({\n acceptsDiscounts: boolean(),\n 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 vPaymentWidgetPaymentResultResponseDto,\n check((payment) => {\n if (!(payment.checkoutId.trim() && payment.paymentReference.trim())) {\n return false;\n }\n if (payment.checkoutStatus === \"action_required\") {\n return (\n payment.requiresAction &&\n payment.paymentRequired &&\n Boolean(payment.clientSecret?.trim())\n );\n }\n return !payment.requiresAction && payment.clientSecret === null;\n }, \"Invalid payment result state.\")\n);\n\nexport 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 return parseSdkPublicWidget(parsePublicWidgetContract(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 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\";\n\ntype ResolvedSelectionItem = {\n checkoutItem: LockerverseCheckoutItem;\n quantity: number;\n unitAmountCents: number;\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 const selection = parseCheckoutSelectionItems(input);\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 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 return {\n items: resolved.map(({ checkoutItem }) => checkoutItem),\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 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: product.maxQuantity,\n minimumAmountCents: product.minimumAmountCents,\n minimumQuantity: product.minQuantity,\n name: product.name,\n paymentOption: product.paymentOption,\n pricingMode: product.pricingMode,\n slug: listing.slug,\n };\n}\n\nexport function createCatalog(widget: PublicWidget): LockerverseCatalog {\n const fields = widget.config?.fields ?? {};\n\n return {\n community: widget.community\n ? {\n accentColor: widget.community.color,\n imageUrl: widget.community.thumbnail || null,\n name: widget.community.name,\n }\n : null,\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 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 { resolveCheckoutSelection } 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 paymentSubmitServerErrorSchema = object({\n code: picklist([\n \"PAYMENT_WIDGET_PHONE_INVALID\",\n \"PAYMENT_WIDGET_PHONE_REQUIRED\",\n ]),\n});\n\nasync function readPaymentSubmitServerCode(\n response: Response\n): Promise<LockerverseSdkServerCode | undefined> {\n if (response.status !== 400) {\n return;\n }\n try {\n const result = safeParse(\n paymentSubmitServerErrorSchema,\n await response.json()\n );\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 return {\n catalog: selectionCatalog,\n items:\n selection === undefined\n ? requireCheckoutItems(items)\n : resolveCheckoutSelection(selectionCatalog, selection).items,\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 =\n normalized.status === undefined\n ? new LockerverseSdkError({\n code: normalized.code,\n message: normalized.message,\n operation: normalized.operation,\n recoveryRecommended: true,\n reportable: normalized.reportable,\n })\n : new LockerverseSdkError({\n code: normalized.code,\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 response = await 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 );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to load Lockerverse widget (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n const catalog = deepFreeze(createCatalog(response.value.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 );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: `Unable to calculate the Lockerverse checkout total (${response.response.status}).`,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n return createPreparedCheckout(response.value, items, pricing, 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 paymentReference: quote.paymentReference,\n phone: submission.phone,\n quoteContractVersion: 1,\n shipping: submission.shipping,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n },\n parsePaymentResult,\n {\n ...context,\n message:\n \"Unable to submit the Lockerverse payment because the request failed.\",\n report: false,\n },\n { ...context, report: false }\n );\n if (!response.ok) {\n const serverCode = await readPaymentSubmitServerCode(\n response.response\n );\n if (serverCode) {\n throw new LockerverseSdkError({\n ...context,\n message: `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":"ofAGA,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,CAAC,WAAY,UAAW,UAAU,CAAC,EAClE,EAAwB,EAAS,CAAC,OAAQ,iBAAiB,CAAC,EAC5D,EAAmC,EAAS,EAAkB,CAAC,CAAC,EAChE,GAAuB,EAC3B,EAAO,EACP,EAAM,yBAA0B,0BAA0B,CAC5D,EAEM,GAAqB,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,EAC1B,GAAQ,cAAe,CACrB,EAAO,CACL,GAAG,GACH,YAAa,EAAkB,CAAC,EAChC,YAAa,EAAQ,OAAO,CAC9B,CAAC,EACD,EAAO,CACL,GAAG,GACH,YAAa,EACb,YAAa,EAAQ,QAAQ,CAC/B,CAAC,CACH,CAAC,EACD,GACG,CAAE,cAAa,iBACd,IAAgB,MAAQ,IAAgB,MAAQ,G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,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 +1 @@
1
- {"version":3,"file":"signup.d.ts","names":[],"sources":["../src/signup-types.ts","../src/signup.ts"],"mappings":";;KAQY;EACV;EACA;;KAGU;EACV,SAAS;EACT,OAAO;EACP,MAAM;EACN,kBAAkB;EAClB,OAAO;;KAGG;EACV;EACA,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,UAAU;EACV,UAAU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;;KAYU;EACV;;KAGG;EACH;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;EACA;;KAGU,iCACV,qCAAqC;KAE3B;EACV,YAAY,QAAQ;EACpB,SACE,YAAY,6BACZ,UAAU,mCACP,QAAQ;;;;iBCpDC,8BACd,SAAS,iCACR"}
1
+ {"version":3,"file":"signup.d.ts","names":[],"sources":["../src/signup-types.ts","../src/signup.ts"],"mappings":";;KAQY;EACV;EACA;;KAGU;EACV,SAAS;EACT,OAAO;EACP,MAAM;EACN,kBAAkB;EAClB,OAAO;;KAGG;EACV;EACA,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,UAAU;EACV,UAAU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;;KAYU;EACV;;KAGG;EACH;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;EACA;;KAGU,iCACV,qCAAqC;KAE3B;EACV,YAAY,QAAQ;EACpB,SACE,YAAY,6BACZ,UAAU,mCACP,QAAQ;;;;iBC3BC,8BACd,SAAS,iCACR"}
package/dist/signup.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,f as n,h as r,i,n as a,o,p as s,r as c,s as l,t as u}from"./transport.js";import{n as d}from"./types.js";import{array as f,boolean as p,check as m,nullable as h,object as g,optional as _,parser as v,pipe as y,strictObject as b,string as x,transform as S}from"valibot";const C=b({city:x(),country:x(),line1:x(),line2:_(h(x())),postalCode:x(),state:x()}),w=v(b({address:_(h(C)),answers:_(f(i)),email:_(h(x())),honeypot:_(x()),name:o,participantCount:_(h(t(0))),phone:_(h(x()))})),T=g({enabled:p(),required:p()}),E=y(T,m(({enabled:e,required:t})=>e||!t,`A disabled signup field cannot be required.`)),D=y(T,m(({enabled:e,required:t})=>e&&t,`The signup name field must be enabled and required.`)),O=y(g({config:g({builtInFields:g({address:E,email:E,name:D,participantCount:E,phone:E}),customFields:e}),coverImageUrl:l,description:l,id:o,isActive:p(),name:o,slug:o,title:l}),S(({config:e,...t})=>({...t,customFields:e.customFields,fields:e.builtInFields}))),k=y(s,m(({id:e})=>!!e.trim(),`Invalid signup submission ID.`)),A=v(O),j=v(n);function M(e){return A(j(e))}const N=v(k);function P(e,t,n){return e instanceof d?e:n(new d({code:`signup_submit_failed`,message:`Unable to submit Lockerverse signup.`,operation:`submit_signup`,recoveryRecommended:t,reportable:t}))}function F(e){let t=r(e),n=a({communitySlug:t.communitySlugValue,environment:t.environment,getContext:()=>({signupSlug:t.signupSlugValue}),onError:t.onError,resourceContextName:`lockerverse_signup`,sentryDsn:t.sentryDsn}),{requestJson:i}=u(t.fetchImplementation,e=>n(e.operation===`submit_signup`&&!e.recoveryRecommended?new d({code:e.code,message:e.message,operation:e.operation,recoveryRecommended:!0,reportable:e.reportable}):e),t.requestTimeoutMs),o=`${t.apiBaseUrl}/community/${t.communitySlug}/sign-up-widgets/${t.signupSlug}`;return{async load(){let e={code:`signup_load_failed`,message:`Unable to load Lockerverse signup.`,operation:`load_signup`},t=await i(o,void 0,M,e,e);if(!t.ok)throw n(new d({...e,reportable:t.response.status>=500,status:t.response.status}));return c(t.value)},async submit(e,t){let r=t?.submissionReference??globalThis.crypto.randomUUID(),a={code:`signup_submit_failed`,message:`Unable to submit Lockerverse signup.`,operation:`submit_signup`},s;try{s=w(e)}catch{throw n(new d({...a,message:`Lockerverse signup input is invalid.`,reportable:!1}))}let l=!1;try{let e=JSON.stringify({...s,submissionReference:r});l=!0;let t=await i(`${o}/submissions`,{body:e,headers:{"content-type":`application/json`},method:`POST`},N,a,a);if(!t.ok)throw n(new d({...a,recoveryRecommended:t.response.status>=500,reportable:t.response.status>=500,status:t.response.status}));let u=c(t.value);if(u.id!==r)throw n(new d({...a,recoveryRecommended:!0,reportable:!0}));return u}catch(e){throw P(e,l,n)}}}}export{F as createLockerverseSignupClient};
1
+ import{a as e,c as t,f as n,h as r,i,n as a,o,p as s,r as c,s as l,t as u}from"./transport.js";import{n as d}from"./types.js";import{array as f,boolean as p,check as m,nullable as h,object as g,optional as _,parser as v,picklist as y,pipe as b,safeParse as x,strictObject as S,string as C,transform as w}from"valibot";const T=S({city:C(),country:C(),line1:C(),line2:_(h(C())),postalCode:C(),state:C()}),E=v(S({address:_(h(T)),answers:_(f(i)),email:_(h(C())),honeypot:_(C()),name:o,participantCount:_(h(t(0))),phone:_(h(C()))})),D=g({enabled:p(),required:p()}),O=b(D,m(({enabled:e,required:t})=>e||!t,`A disabled signup field cannot be required.`)),k=b(D,m(({enabled:e,required:t})=>e&&t,`The signup name field must be enabled and required.`)),A=b(g({config:g({builtInFields:g({address:O,email:O,name:k,participantCount:O,phone:O}),customFields:e}),coverImageUrl:l,description:l,id:o,isActive:p(),name:o,slug:o,title:l}),w(({config:e,...t})=>({...t,customFields:e.customFields,fields:e.builtInFields}))),j=b(s,m(({id:e})=>!!e.trim(),`Invalid signup submission ID.`)),M=v(A),N=v(n);function P(e){return M(N(e))}const F=v(j),I=g({code:y([`SIGN_UP_WIDGET_PHONE_INVALID`,`SIGN_UP_WIDGET_PHONE_REQUIRED`])});async function L(e){if(e.status===400)try{let t=x(I,await e.json());return t.success?t.output.code:void 0}catch{}}function R(e,t,n){return e instanceof d?e:n(new d({code:`signup_submit_failed`,message:`Unable to submit Lockerverse signup.`,operation:`submit_signup`,recoveryRecommended:t,reportable:t}))}function z(e){let t=r(e),n=a({communitySlug:t.communitySlugValue,environment:t.environment,getContext:()=>({signupSlug:t.signupSlugValue}),onError:t.onError,resourceContextName:`lockerverse_signup`,sentryDsn:t.sentryDsn}),{requestJson:i}=u(t.fetchImplementation,e=>n(e.operation===`submit_signup`&&!e.recoveryRecommended?new d({code:e.code,message:e.message,operation:e.operation,recoveryRecommended:!0,reportable:e.reportable,...e.serverCode===void 0?void 0:{serverCode:e.serverCode},...e.status===void 0?void 0:{status:e.status}}):e),t.requestTimeoutMs),o=`${t.apiBaseUrl}/community/${t.communitySlug}/sign-up-widgets/${t.signupSlug}`;return{async load(){let e={code:`signup_load_failed`,message:`Unable to load Lockerverse signup.`,operation:`load_signup`},t=await i(o,void 0,P,e,e);if(!t.ok)throw n(new d({...e,reportable:t.response.status>=500,status:t.response.status}));return c(t.value)},async submit(e,t){let r=t?.submissionReference??globalThis.crypto.randomUUID(),a={code:`signup_submit_failed`,message:`Unable to submit Lockerverse signup.`,operation:`submit_signup`},s;try{s=E(e)}catch{throw n(new d({...a,message:`Lockerverse signup input is invalid.`,reportable:!1}))}let l=!1;try{let e=JSON.stringify({...s,submissionReference:r});l=!0;let t=await i(`${o}/submissions`,{body:e,headers:{"content-type":`application/json`},method:`POST`},F,a,a);if(!t.ok){let e=await L(t.response);throw n(new d({...a,recoveryRecommended:t.response.status>=500,reportable:t.response.status>=500,...e===void 0?void 0:{serverCode:e},status:t.response.status}))}let u=c(t.value);if(u.id!==r)throw n(new d({...a,recoveryRecommended:!0,reportable:!0}));return u}catch(e){throw R(e,l,n)}}}}export{z as createLockerverseSignupClient};
2
2
  //# sourceMappingURL=signup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signup.js","names":[],"sources":["../src/signup-input-schema.ts","../src/signup-schemas.ts","../src/signup.ts"],"sourcesContent":["import {\n array,\n nullable,\n optional,\n parser,\n strictObject,\n string,\n} from \"valibot\";\n\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupAddressSchema = strictObject({\n city: string(),\n country: string(),\n line1: string(),\n line2: optional(nullable(string())),\n postalCode: string(),\n state: string(),\n});\n\nexport const parseSignupSubmission = parser(\n strictObject({\n address: optional(nullable(signupAddressSchema)),\n answers: optional(array(customFieldAnswerSchema)),\n email: optional(nullable(string())),\n honeypot: optional(string()),\n name: nonEmptyStringSchema,\n participantCount: optional(nullable(safeIntegerSchema(0))),\n phone: optional(nullable(string())),\n })\n);\n","import { boolean, check, object, parser, pipe, transform } from \"valibot\";\n\nimport {\n vPublicSignUpWidgetResponseDto,\n vPublicSignUpWidgetSubmissionResponseDto,\n} from \"./generated/public-api/valibot.gen.ts\";\nimport {\n customFieldsSchema,\n nonEmptyStringSchema,\n optionalNullableStringSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupFieldSchema = object({\n enabled: boolean(),\n required: boolean(),\n});\n\nconst optionalSignupFieldSchema = pipe(\n signupFieldSchema,\n check(\n ({ enabled, required }) => enabled || !required,\n \"A disabled signup field cannot be required.\"\n )\n);\n\nconst requiredNameFieldSchema = pipe(\n signupFieldSchema,\n check(\n ({ enabled, required }) => enabled && required,\n \"The signup name field must be enabled and required.\"\n )\n);\n\nexport const publicSignupSchema = pipe(\n object({\n config: object({\n builtInFields: object({\n address: optionalSignupFieldSchema,\n email: optionalSignupFieldSchema,\n name: requiredNameFieldSchema,\n participantCount: optionalSignupFieldSchema,\n phone: optionalSignupFieldSchema,\n }),\n customFields: customFieldsSchema,\n }),\n coverImageUrl: optionalNullableStringSchema,\n description: optionalNullableStringSchema,\n id: nonEmptyStringSchema,\n isActive: boolean(),\n name: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n title: optionalNullableStringSchema,\n }),\n transform(({ config, ...signup }) => ({\n ...signup,\n customFields: config.customFields,\n fields: config.builtInFields,\n }))\n);\n\nexport const signupSubmissionResultSchema = pipe(\n vPublicSignUpWidgetSubmissionResponseDto,\n check(({ id }) => Boolean(id.trim()), \"Invalid signup submission ID.\")\n);\n\nconst parseSdkPublicSignup = parser(publicSignupSchema);\nconst parsePublicSignupContract = parser(vPublicSignUpWidgetResponseDto);\n\nexport function parsePublicSignup<Input>(input: Input) {\n return parseSdkPublicSignup(parsePublicSignupContract(input));\n}\n\nexport const parseSignupSubmissionResult = parser(signupSubmissionResultSchema);\n","import { deepFreeze } from \"./deep-freeze.ts\";\nimport { resolveSignupEnvironment } from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { parseSignupSubmission } from \"./signup-input-schema.ts\";\nimport {\n parsePublicSignup,\n parseSignupSubmissionResult,\n} from \"./signup-schemas.ts\";\nimport type {\n CreateLockerverseSignupOptions,\n LockerverseSignupClient,\n LockerverseSignupSubmission,\n} from \"./signup-types.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport { LockerverseSdkError } from \"./types.ts\";\n\nfunction classifySubmissionError<ErrorValue>(\n error: ErrorValue,\n requestAttempted: boolean,\n reportError: (error: LockerverseSdkError) => LockerverseSdkError\n) {\n if (error instanceof LockerverseSdkError) {\n return error;\n }\n return reportError(\n new LockerverseSdkError({\n code: \"signup_submit_failed\",\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\",\n recoveryRecommended: requestAttempted,\n reportable: requestAttempted,\n })\n );\n}\n\nexport function createLockerverseSignupClient(\n options: CreateLockerverseSignupOptions\n): LockerverseSignupClient {\n const runtime = resolveSignupEnvironment(options);\n const reportError = createSdkErrorReporter({\n communitySlug: runtime.communitySlugValue,\n environment: runtime.environment,\n getContext: () => ({ signupSlug: runtime.signupSlugValue }),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_signup\",\n sentryDsn: runtime.sentryDsn,\n });\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n (error) =>\n reportError(\n error.operation === \"submit_signup\" && !error.recoveryRecommended\n ? new LockerverseSdkError({\n code: error.code,\n message: error.message,\n operation: error.operation,\n recoveryRecommended: true,\n reportable: error.reportable,\n })\n : error\n ),\n runtime.requestTimeoutMs\n );\n const signupUrl = `${runtime.apiBaseUrl}/community/${runtime.communitySlug}/sign-up-widgets/${runtime.signupSlug}`;\n\n return {\n async load() {\n const errorContext = {\n code: \"signup_load_failed\" as const,\n message: \"Unable to load Lockerverse signup.\",\n operation: \"load_signup\" as const,\n };\n const signupResponse = await requestJson(\n signupUrl,\n undefined,\n parsePublicSignup,\n errorContext,\n errorContext\n );\n if (!signupResponse.ok) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n reportable: signupResponse.response.status >= 500,\n status: signupResponse.response.status,\n })\n );\n }\n return deepFreeze(signupResponse.value);\n },\n async submit(submission: LockerverseSignupSubmission, submitOptions) {\n const submissionReference =\n submitOptions?.submissionReference ?? globalThis.crypto.randomUUID();\n const errorContext = {\n code: \"signup_submit_failed\" as const,\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\" as const,\n };\n let parsedSubmission: ReturnType<typeof parseSignupSubmission>;\n try {\n parsedSubmission = parseSignupSubmission(submission);\n } catch {\n // biome-ignore lint/style/useErrorCause: Raw validation errors must not escape the SDK boundary.\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n message: \"Lockerverse signup input is invalid.\",\n reportable: false,\n })\n );\n }\n\n let requestAttempted = false;\n try {\n const body = JSON.stringify({\n ...parsedSubmission,\n submissionReference,\n });\n requestAttempted = true;\n const submissionResponse = await requestJson(\n `${signupUrl}/submissions`,\n {\n body,\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n },\n parseSignupSubmissionResult,\n errorContext,\n errorContext\n );\n if (!submissionResponse.ok) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: submissionResponse.response.status >= 500,\n reportable: submissionResponse.response.status >= 500,\n status: submissionResponse.response.status,\n })\n );\n }\n const result = deepFreeze(submissionResponse.value);\n if (result.id !== submissionReference) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: true,\n reportable: true,\n })\n );\n }\n return result;\n } catch (error) {\n throw classifySubmissionError(error, requestAttempted, reportError);\n }\n },\n };\n}\n"],"mappings":"iSAeA,MAAM,EAAsB,EAAa,CACvC,KAAM,EAAO,EACb,QAAS,EAAO,EAChB,MAAO,EAAO,EACd,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,EAClC,WAAY,EAAO,EACnB,MAAO,EAAO,CAChB,CAAC,EAEY,EAAwB,EACnC,EAAa,CACX,QAAS,EAAS,EAAS,CAAmB,CAAC,EAC/C,QAAS,EAAS,EAAM,CAAuB,CAAC,EAChD,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,EAClC,SAAU,EAAS,EAAO,CAAC,EAC3B,KAAM,EACN,iBAAkB,EAAS,EAAS,EAAkB,CAAC,CAAC,CAAC,EACzD,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,CACpC,CAAC,CACH,ECtBM,EAAoB,EAAO,CAC/B,QAAS,EAAQ,EACjB,SAAU,EAAQ,CACpB,CAAC,EAEK,EAA4B,EAChC,EACA,GACG,CAAE,UAAS,cAAe,GAAW,CAAC,EACvC,6CACF,CACF,EAEM,EAA0B,EAC9B,E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,EAEF,OAAO,CACT,OAAS,EAAO,CACd,MAAM,EAAwB,EAAO,EAAkB,CAAW,CACpE,CACF,CACF,CACF"}
1
+ {"version":3,"file":"signup.js","names":[],"sources":["../src/signup-input-schema.ts","../src/signup-schemas.ts","../src/signup.ts"],"sourcesContent":["import {\n array,\n nullable,\n optional,\n parser,\n strictObject,\n string,\n} from \"valibot\";\n\nimport {\n customFieldAnswerSchema,\n nonEmptyStringSchema,\n safeIntegerSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupAddressSchema = strictObject({\n city: string(),\n country: string(),\n line1: string(),\n line2: optional(nullable(string())),\n postalCode: string(),\n state: string(),\n});\n\nexport const parseSignupSubmission = parser(\n strictObject({\n address: optional(nullable(signupAddressSchema)),\n answers: optional(array(customFieldAnswerSchema)),\n email: optional(nullable(string())),\n honeypot: optional(string()),\n name: nonEmptyStringSchema,\n participantCount: optional(nullable(safeIntegerSchema(0))),\n phone: optional(nullable(string())),\n })\n);\n","import { boolean, check, object, parser, pipe, transform } from \"valibot\";\n\nimport {\n vPublicSignUpWidgetResponseDto,\n vPublicSignUpWidgetSubmissionResponseDto,\n} from \"./generated/public-api/valibot.gen.ts\";\nimport {\n customFieldsSchema,\n nonEmptyStringSchema,\n optionalNullableStringSchema,\n} from \"./schema-helpers.ts\";\n\nconst signupFieldSchema = object({\n enabled: boolean(),\n required: boolean(),\n});\n\nconst optionalSignupFieldSchema = pipe(\n signupFieldSchema,\n check(\n ({ enabled, required }) => enabled || !required,\n \"A disabled signup field cannot be required.\"\n )\n);\n\nconst requiredNameFieldSchema = pipe(\n signupFieldSchema,\n check(\n ({ enabled, required }) => enabled && required,\n \"The signup name field must be enabled and required.\"\n )\n);\n\nexport const publicSignupSchema = pipe(\n object({\n config: object({\n builtInFields: object({\n address: optionalSignupFieldSchema,\n email: optionalSignupFieldSchema,\n name: requiredNameFieldSchema,\n participantCount: optionalSignupFieldSchema,\n phone: optionalSignupFieldSchema,\n }),\n customFields: customFieldsSchema,\n }),\n coverImageUrl: optionalNullableStringSchema,\n description: optionalNullableStringSchema,\n id: nonEmptyStringSchema,\n isActive: boolean(),\n name: nonEmptyStringSchema,\n slug: nonEmptyStringSchema,\n title: optionalNullableStringSchema,\n }),\n transform(({ config, ...signup }) => ({\n ...signup,\n customFields: config.customFields,\n fields: config.builtInFields,\n }))\n);\n\nexport const signupSubmissionResultSchema = pipe(\n vPublicSignUpWidgetSubmissionResponseDto,\n check(({ id }) => Boolean(id.trim()), \"Invalid signup submission ID.\")\n);\n\nconst parseSdkPublicSignup = parser(publicSignupSchema);\nconst parsePublicSignupContract = parser(vPublicSignUpWidgetResponseDto);\n\nexport function parsePublicSignup<Input>(input: Input) {\n return parseSdkPublicSignup(parsePublicSignupContract(input));\n}\n\nexport const parseSignupSubmissionResult = parser(signupSubmissionResultSchema);\n","import { object, picklist, safeParse } from \"valibot\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport { resolveSignupEnvironment } from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { parseSignupSubmission } from \"./signup-input-schema.ts\";\nimport {\n parsePublicSignup,\n parseSignupSubmissionResult,\n} from \"./signup-schemas.ts\";\nimport type {\n CreateLockerverseSignupOptions,\n LockerverseSignupClient,\n LockerverseSignupSubmission,\n} from \"./signup-types.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport { LockerverseSdkError, type LockerverseSdkServerCode } from \"./types.ts\";\n\nconst signupSubmitServerErrorSchema = object({\n code: picklist([\n \"SIGN_UP_WIDGET_PHONE_INVALID\",\n \"SIGN_UP_WIDGET_PHONE_REQUIRED\",\n ]),\n});\n\nasync function readSignupSubmitServerCode(\n response: Response\n): Promise<LockerverseSdkServerCode | undefined> {\n if (response.status !== 400) {\n return;\n }\n try {\n const result = safeParse(\n signupSubmitServerErrorSchema,\n await response.json()\n );\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 classifySubmissionError<ErrorValue>(\n error: ErrorValue,\n requestAttempted: boolean,\n reportError: (error: LockerverseSdkError) => LockerverseSdkError\n) {\n if (error instanceof LockerverseSdkError) {\n return error;\n }\n return reportError(\n new LockerverseSdkError({\n code: \"signup_submit_failed\",\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\",\n recoveryRecommended: requestAttempted,\n reportable: requestAttempted,\n })\n );\n}\n\nexport function createLockerverseSignupClient(\n options: CreateLockerverseSignupOptions\n): LockerverseSignupClient {\n const runtime = resolveSignupEnvironment(options);\n const reportError = createSdkErrorReporter({\n communitySlug: runtime.communitySlugValue,\n environment: runtime.environment,\n getContext: () => ({ signupSlug: runtime.signupSlugValue }),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_signup\",\n sentryDsn: runtime.sentryDsn,\n });\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n (error) =>\n reportError(\n error.operation === \"submit_signup\" && !error.recoveryRecommended\n ? new LockerverseSdkError({\n code: error.code,\n message: error.message,\n operation: error.operation,\n recoveryRecommended: true,\n reportable: error.reportable,\n ...(error.serverCode === undefined\n ? undefined\n : { serverCode: error.serverCode }),\n ...(error.status === undefined\n ? undefined\n : { status: error.status }),\n })\n : error\n ),\n runtime.requestTimeoutMs\n );\n const signupUrl = `${runtime.apiBaseUrl}/community/${runtime.communitySlug}/sign-up-widgets/${runtime.signupSlug}`;\n\n return {\n async load() {\n const errorContext = {\n code: \"signup_load_failed\" as const,\n message: \"Unable to load Lockerverse signup.\",\n operation: \"load_signup\" as const,\n };\n const signupResponse = await requestJson(\n signupUrl,\n undefined,\n parsePublicSignup,\n errorContext,\n errorContext\n );\n if (!signupResponse.ok) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n reportable: signupResponse.response.status >= 500,\n status: signupResponse.response.status,\n })\n );\n }\n return deepFreeze(signupResponse.value);\n },\n async submit(submission: LockerverseSignupSubmission, submitOptions) {\n const submissionReference =\n submitOptions?.submissionReference ?? globalThis.crypto.randomUUID();\n const errorContext = {\n code: \"signup_submit_failed\" as const,\n message: \"Unable to submit Lockerverse signup.\",\n operation: \"submit_signup\" as const,\n };\n let parsedSubmission: ReturnType<typeof parseSignupSubmission>;\n try {\n parsedSubmission = parseSignupSubmission(submission);\n } catch {\n // biome-ignore lint/style/useErrorCause: Raw validation errors must not escape the SDK boundary.\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n message: \"Lockerverse signup input is invalid.\",\n reportable: false,\n })\n );\n }\n\n let requestAttempted = false;\n try {\n const body = JSON.stringify({\n ...parsedSubmission,\n submissionReference,\n });\n requestAttempted = true;\n const submissionResponse = await requestJson(\n `${signupUrl}/submissions`,\n {\n body,\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n },\n parseSignupSubmissionResult,\n errorContext,\n errorContext\n );\n if (!submissionResponse.ok) {\n const serverCode = await readSignupSubmitServerCode(\n submissionResponse.response\n );\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: submissionResponse.response.status >= 500,\n reportable: submissionResponse.response.status >= 500,\n ...(serverCode === undefined ? undefined : { serverCode }),\n status: submissionResponse.response.status,\n })\n );\n }\n const result = deepFreeze(submissionResponse.value);\n if (result.id !== submissionReference) {\n throw reportError(\n new LockerverseSdkError({\n ...errorContext,\n recoveryRecommended: true,\n reportable: true,\n })\n );\n }\n return result;\n } catch (error) {\n throw classifySubmissionError(error, requestAttempted, reportError);\n }\n },\n };\n}\n"],"mappings":"8TAeA,MAAM,EAAsB,EAAa,CACvC,KAAM,EAAO,EACb,QAAS,EAAO,EAChB,MAAO,EAAO,EACd,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,EAClC,WAAY,EAAO,EACnB,MAAO,EAAO,CAChB,CAAC,EAEY,EAAwB,EACnC,EAAa,CACX,QAAS,EAAS,EAAS,CAAmB,CAAC,EAC/C,QAAS,EAAS,EAAM,CAAuB,CAAC,EAChD,MAAO,EAAS,EAAS,EAAO,CAAC,CAAC,EAClC,SAAU,EAAS,EAAO,CAAC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I,EACJ,GAAI,CACF,EAAmB,EAAsB,CAAU,CACrD,MAAQ,CAEN,MAAM,EACJ,IAAI,EAAoB,CACtB,GAAG,EACH,QAAS,uCACT,WAAY,EACd,CAAC,CACH,CACF,CAEA,IAAI,EAAmB,GACvB,GAAI,CACF,IAAM,EAAO,KAAK,UAAU,CAC1B,GAAG,EACH,qBACF,CAAC,EACD,EAAmB,GACnB,IAAM,EAAqB,MAAM,EAC/B,GAAG,EAAU,cACb,CACE,OACA,QAAS,CAAE,eAAgB,kBAAmB,EAC9C,OAAQ,MACV,EACA,EACA,EACA,CACF,EACA,GAAI,CAAC,EAAmB,GAAI,CAC1B,IAAM,EAAa,MAAM,EACvB,EAAmB,QACrB,EACA,MAAM,EACJ,IAAI,EAAoB,CACtB,GAAG,EACH,oBAAqB,EAAmB,SAAS,QAAU,IAC3D,WAAY,EAAmB,SAAS,QAAU,IAClD,GAAI,IAAe,IAAA,GAAY,IAAA,GAAY,CAAE,YAAW,EACxD,OAAQ,EAAmB,SAAS,MACtC,CAAC,CACH,CACF,CACA,IAAM,EAAS,EAAW,EAAmB,KAAK,EAClD,GAAI,EAAO,KAAO,EAChB,MAAM,EACJ,IAAI,EAAoB,CACtB,GAAG,EACH,oBAAqB,GACrB,WAAY,EACd,CAAC,CACH,EAEF,OAAO,CACT,OAAS,EAAO,CACd,MAAM,EAAwB,EAAO,EAAkB,CAAW,CACpE,CACF,CACF,CACF"}
package/dist/types.d.ts CHANGED
@@ -99,19 +99,22 @@ type LockerverseWidgetConfiguration = {
99
99
  };
100
100
  type LockerverseSdkErrorCode = "widget_load_failed" | "signup_load_failed" | "signup_submit_failed" | "total_calculation_failed" | "payment_submit_failed" | "payment_status_failed" | "invalid_selection";
101
101
  type LockerverseSdkOperation = "load_widget" | "load_signup" | "submit_signup" | "calculate_total" | "submit_payment" | "get_payment_status";
102
+ type LockerverseSdkServerCode = "PAYMENT_WIDGET_PHONE_INVALID" | "PAYMENT_WIDGET_PHONE_REQUIRED" | "SIGN_UP_WIDGET_PHONE_INVALID" | "SIGN_UP_WIDGET_PHONE_REQUIRED";
102
103
  declare class LockerverseSdkError extends Error {
103
104
  readonly code: LockerverseSdkErrorCode;
104
105
  readonly operation: LockerverseSdkOperation;
105
106
  readonly reportable: boolean;
106
107
  readonly recoveryRecommended: boolean;
107
108
  readonly sdkVersion: string;
109
+ readonly serverCode: LockerverseSdkServerCode | undefined;
108
110
  readonly status: number | undefined;
109
- constructor({ code, message, operation, reportable, recoveryRecommended, status }: {
111
+ constructor({ code, message, operation, reportable, recoveryRecommended, serverCode, status }: {
110
112
  code: LockerverseSdkErrorCode;
111
113
  message: string;
112
114
  operation: LockerverseSdkOperation;
113
115
  reportable: boolean;
114
116
  recoveryRecommended?: boolean;
117
+ serverCode?: LockerverseSdkServerCode;
115
118
  status?: number;
116
119
  });
117
120
  }
@@ -269,5 +272,5 @@ type LockerverseCheckoutClient = {
269
272
  submitPayment: (input: LockerverseSubmitPaymentInput) => Promise<LockerversePaymentResult>;
270
273
  };
271
274
  //#endregion
272
- export { LockerversePaymentOption as A, LockerverseShipping as B, LockerverseEvent as C, LockerverseMultiOptionCustomField as D, LockerverseLoadedCheckout as E, LockerverseProduct as F, LockerverseWidgetFields as G, LockerverseSubmitPaymentInput as H, LockerverseResourceEnvironmentOptions as I, LockerverseSdkError as L, LockerversePaymentStatus as M, LockerversePaymentSubmission as N, LockerversePaymentCompletion as O, LockerversePreparedCheckout as P, LockerverseSdkErrorCode as R, LockerverseEstimateCheckoutInput as S, LockerverseLoadCheckoutInput as T, LockerverseTextCustomField as U, LockerverseSingleOptionCustomField as V, LockerverseWidgetConfiguration as W, LockerverseCustomField as _, LockerverseCalculateTotalInput as a, LockerverseCustomFieldOption as b, LockerverseCheckoutClient as c, LockerverseCheckoutLineItem as d, LockerverseCheckoutPricingInput as f, LockerverseCommunityBranding as g, LockerverseCheckoutSelectionItem as h, LockerverseBooleanCustomField as i, LockerversePaymentResult as j, LockerversePaymentConfiguration as k, LockerverseCheckoutEstimate as l, LockerverseCheckoutQuote as m, LOCKERVERSE_SDK_VERSION as n, LockerverseCatalog as o, LockerverseCheckoutPricingPolicy as p, LockerverseAppliedDiscount as r, LockerverseCheckoutAmounts as s, CreateLockerverseWidgetOptions as t, LockerverseCheckoutItem as u, LockerverseCustomFieldAnswer as v, LockerverseFulfillmentType as w, LockerverseEnvironment as x, LockerverseCustomFieldAnswerValue as y, LockerverseSdkOperation as z };
275
+ export { LockerversePaymentOption as A, LockerverseSdkServerCode as B, LockerverseEvent as C, LockerverseMultiOptionCustomField as D, LockerverseLoadedCheckout as E, LockerverseProduct as F, LockerverseWidgetConfiguration as G, LockerverseSingleOptionCustomField as H, LockerverseResourceEnvironmentOptions as I, LockerverseWidgetFields as K, LockerverseSdkError as L, LockerversePaymentStatus as M, LockerversePaymentSubmission as N, LockerversePaymentCompletion as O, LockerversePreparedCheckout as P, LockerverseSdkErrorCode as R, LockerverseEstimateCheckoutInput as S, LockerverseLoadCheckoutInput as T, LockerverseSubmitPaymentInput as U, LockerverseShipping as V, LockerverseTextCustomField as W, LockerverseCustomField as _, LockerverseCalculateTotalInput as a, LockerverseCustomFieldOption as b, LockerverseCheckoutClient as c, LockerverseCheckoutLineItem as d, LockerverseCheckoutPricingInput as f, LockerverseCommunityBranding as g, LockerverseCheckoutSelectionItem as h, LockerverseBooleanCustomField as i, LockerversePaymentResult as j, LockerversePaymentConfiguration as k, LockerverseCheckoutEstimate as l, LockerverseCheckoutQuote as m, LOCKERVERSE_SDK_VERSION as n, LockerverseCatalog as o, LockerverseCheckoutPricingPolicy as p, LockerverseAppliedDiscount as r, LockerverseCheckoutAmounts as s, CreateLockerverseWidgetOptions as t, LockerverseCheckoutItem as u, LockerverseCustomFieldAnswer as v, LockerverseFulfillmentType as w, LockerverseEnvironment as x, LockerverseCustomFieldAnswerValue as y, LockerverseSdkOperation as z };
273
276
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAGY;KACA;KACA;cAEC;KAED;EACV;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,WAAW;EACX,OAAO;EACP,SAAS;EACT,eAAe;EACf,UAAU;EACV,QAAQ;;KAGE;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EAAiC;EAAY;;KAEpD;EACH;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,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;;KAGU;KASA;cAQC,4BAA4B;WAC9B,MAAM;WACN,WAAW;WACX;WACA;WACA;WACA;EAEG,cACV,MACA,SACA,WACA,YACA,qBACA;IAEA,MAAM;IACN;IACA,WAAW;IACX;IACA;IACA;;;KAaQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B;EACrC,iBAAiB;EACjB;EACA;EACA,SAAS;EACT,eAAe;EACf,WAAW;;KAGD,8BAA8B;EACxC;EACA;EACA,gBAAgB;EAChB,oBAAoB;EACpB,eAAe;;KAGL;EACV;EACA;EACA;EACA;;KAGU;KAMA;EACV;EACA;EACA,gBAAgB;EAChB;EACA;EACA;EACA;;KAGU,+BAA+B;EACzC;EACA,oBAAoB;;KAYV;EACV;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;KAGU;EACV;EACA,qBAAqB;EACrB;EACA;EACA;EACA,WAAW;EACX;EACA,WAAW;;KAGD;EACN;EAAmB;;EACnB;EAAmB;;EACnB;;KAEM;EACN;EAAqB;;EACrB;EAAqB;;EACrB;;KAEM,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;KACA;KACA;cAEC;KAED;EACV;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV,WAAW;EACX,OAAO;EACP,SAAS;EACT,eAAe;EACf,UAAU;EACV,QAAQ;;KAGE;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EAAiC;EAAY;;KAEpD;EACH;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,cAAc;EACd;EACA,QAAQ;EACR;EACA;EACA;EACA;;KAGU;KASA;KAQA;cAMC,4BAA4B;WAC9B,MAAM;WACN,WAAW;WACX;WACA;WACA;WACA,YAAY;WACZ;EAEG,cACV,MACA,SACA,WACA,YACA,qBACA,YACA;IAEA,MAAM;IACN;IACA,WAAW;IACX;IACA;IACA,aAAa;IACb;;;KAcQ;EACV;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B;EACrC,iBAAiB;EACjB;EACA;EACA,SAAS;EACT,eAAe;EACf,WAAW;;KAGD,8BAA8B;EACxC;EACA;EACA,gBAAgB;EAChB,oBAAoB;EACpB,eAAe;;KAGL;EACV;EACA;EACA;EACA;;KAGU;KAMA;EACV;EACA;EACA,gBAAgB;EAChB;EACA;EACA;EACA;;KAGU,+BAA+B;EACzC;EACA,oBAAoB;;KAYV;EACV;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;KAGU;EACV;EACA,qBAAqB;EACrB;EACA;EACA;EACA,WAAW;EACX;EACA,WAAW;;KAGD;EACN;EAAmB;;EACnB;EAAmB;;EACnB;;KAEM;EACN;EAAqB;;EACrB;EAAqB;;EACrB;;KAEM,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.91`;var t=class extends Error{code;operation;reportable;recoveryRecommended;sdkVersion;status;constructor({code:t,message:n,operation:r,reportable:i,recoveryRecommended:a=!1,status:o}){super(n),this.name=`LockerverseSdkError`,this.code=t,this.operation=r,this.reportable=i,this.recoveryRecommended=a,this.sdkVersion=e,this.status=o}};export{t as n,e as t};
1
+ const e=`0.2.92`;var t=class extends Error{code;operation;reportable;recoveryRecommended;sdkVersion;serverCode;status;constructor({code:t,message:n,operation:r,reportable:i,recoveryRecommended:a=!1,serverCode:o,status:s}){super(n),this.name=`LockerverseSdkError`,this.code=t,this.operation=r,this.reportable=i,this.recoveryRecommended=a,this.sdkVersion=e,this.serverCode=o,this.status=s}};export{t as n,e as t};
2
2
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["packageMetadata.version"],"sources":["../package.json","../src/types.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\" with { type: \"json\" };\nimport type { GeneratedPaymentResult } from \"./generated/public-contract-types.ts\";\n\nexport type LockerversePaymentOption = \"one-time\" | \"monthly\" | \"annually\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\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 maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseCatalog = {\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 accentColor: string;\n imageUrl: string | null;\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 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 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 | \"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_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\";\n\nexport class LockerverseSdkError extends Error {\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly status: number | undefined;\n\n constructor({\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n status,\n }: {\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n status?: number;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.status = status;\n }\n}\n\nexport type LockerverseCheckoutLineItem = {\n productId: string;\n productName: string;\n listingId: string;\n listingSlug: string;\n acceptsDiscounts: boolean;\n 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;\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 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 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":"ACOA,MAAa,EAA0BA,SA0IvC,IAAa,EAAb,cAAyC,KAAM,CAC7C,KACA,UACA,WACA,oBACA,WACA,OAEA,YAAY,CACV,OACA,UACA,YACA,aACA,sBAAsB,GACtB,UAQC,CACD,MAAM,CAAO,EACb,KAAK,KAAO,sBACZ,KAAK,KAAO,EACZ,KAAK,UAAY,EACjB,KAAK,WAAa,EAClB,KAAK,oBAAsB,EAC3B,KAAK,WAAa,EAClB,KAAK,OAAS,CAChB,CACF"}
1
+ {"version":3,"file":"types.js","names":["packageMetadata.version"],"sources":["../package.json","../src/types.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\" with { type: \"json\" };\nimport type { GeneratedPaymentResult } from \"./generated/public-contract-types.ts\";\n\nexport type LockerversePaymentOption = \"one-time\" | \"monthly\" | \"annually\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\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 maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseCatalog = {\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 accentColor: string;\n imageUrl: string | null;\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 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 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 | \"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_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\";\n\nexport type LockerverseSdkServerCode =\n | \"PAYMENT_WIDGET_PHONE_INVALID\"\n | \"PAYMENT_WIDGET_PHONE_REQUIRED\"\n | \"SIGN_UP_WIDGET_PHONE_INVALID\"\n | \"SIGN_UP_WIDGET_PHONE_REQUIRED\";\n\nexport class LockerverseSdkError extends Error {\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly serverCode: LockerverseSdkServerCode | undefined;\n readonly status: number | undefined;\n\n constructor({\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n serverCode,\n status,\n }: {\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n serverCode?: LockerverseSdkServerCode;\n status?: number;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.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;\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 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 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":"ACOA,MAAa,EAA0BA,SAgJvC,IAAa,EAAb,cAAyC,KAAM,CAC7C,KACA,UACA,WACA,oBACA,WACA,WACA,OAEA,YAAY,CACV,OACA,UACA,YACA,aACA,sBAAsB,GACtB,aACA,UASC,CACD,MAAM,CAAO,EACb,KAAK,KAAO,sBACZ,KAAK,KAAO,EACZ,KAAK,UAAY,EACjB,KAAK,WAAa,EAClB,KAAK,oBAAsB,EAC3B,KAAK,WAAa,EAClB,KAAK,WAAa,EAClB,KAAK,OAAS,CAChB,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lockerverse/sdk",
3
- "version": "0.2.91",
3
+ "version": "0.2.92",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Lockerverse/lockerverse-sdk.git",