@lockerverse/sdk 0.2.247 → 0.2.248-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATIONS.md +77 -11
- package/dist/bookings.d.ts +1 -11
- package/dist/bookings.d.ts.map +1 -1
- package/dist/bookings.js +1 -1
- package/dist/bookings.js.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/MIGRATIONS.md
CHANGED
|
@@ -100,12 +100,6 @@ The standard auction catalog now aligns card bottoms and bid buttons within each
|
|
|
100
100
|
- **Automatic recovery:** configuration failure no longer prevents recovery of a
|
|
101
101
|
saved attempt. Bank verification can continue for an existing payment even
|
|
102
102
|
while the owner's current setup prevents new payments.
|
|
103
|
-
- **Optional, one-step checkout:** booking configuration now has `payment`
|
|
104
|
-
(`publishableKey`, `stripeAccountId`) while it is ready, and
|
|
105
|
-
`LockerverseBookingPayment` accepts `beforeConfirm`. Show the contact fields and
|
|
106
|
-
card entry on one screen, and create the attempt with the customer in
|
|
107
|
-
`beforeConfirm` (see the bookings guide). Hosts that keep a separate contact
|
|
108
|
-
step need no change.
|
|
109
103
|
- **Check:** a new business uses its own booking and payment account; customer
|
|
110
104
|
contact details reach the saved booking; a test card that needs authentication
|
|
111
105
|
completes or recovers without a second payment. Keep `clientSecret` private.
|
|
@@ -442,7 +436,7 @@ No host prop change is required.
|
|
|
442
436
|
- **Check:** inspect a wide and a tall photo on desktop and mobile. Confirm all
|
|
443
437
|
edges remain visible in the item gallery, thumbnails, and full-screen viewer.
|
|
444
438
|
|
|
445
|
-
## 0.2.
|
|
439
|
+
## 0.2.192-dev.1 — auction item additional charges
|
|
446
440
|
|
|
447
441
|
- **Affected:** Core auction item data, purchase quotes, and React auction checkout.
|
|
448
442
|
- **Automatic:** optional `additionalCharge` charges the first-item amount plus the
|
|
@@ -460,7 +454,7 @@ No host prop change is required.
|
|
|
460
454
|
- **Check:** compare one, two, and maximum quantity totals with the server quote,
|
|
461
455
|
verify the per-order limit, and inspect the named charge row before payment.
|
|
462
456
|
|
|
463
|
-
## 0.2.
|
|
457
|
+
## 0.2.190-dev.1 — widget load recovery and Sentry releases
|
|
464
458
|
|
|
465
459
|
- **Affected:** Core widget loading and SDK failure reporting.
|
|
466
460
|
- **Automatic:** a widget GET retries once after a network failure or request
|
|
@@ -487,6 +481,7 @@ No host prop change is required.
|
|
|
487
481
|
- **Check:** select one, two, and the maximum allowed trigger quantity. Confirm the
|
|
488
482
|
local summary and server quote agree; removing all trigger items removes shipping.
|
|
489
483
|
|
|
484
|
+
|
|
490
485
|
## 0.2.184 — single focus boundary for form fields
|
|
491
486
|
|
|
492
487
|
- **Affected:** React form controls and the shared phone field in payment and signup.
|
|
@@ -506,7 +501,7 @@ Widgets can now use a private contact list for email eligibility, a fixed amount
|
|
|
506
501
|
Required shipping appears in `catalog.widget.requiredShipping`. Do not offer this product as a separate shopper choice. The SDK adds its quantity once when a trigger product is selected; the server also enforces this rule. Render authoritative quote line items and totals, including shipping. The built-in launcher and payment summary handle this automatically.
|
|
507
502
|
|
|
508
503
|
|
|
509
|
-
## 0.2.
|
|
504
|
+
## 0.2.176-dev.1 — Secure checkout loading recovery
|
|
510
505
|
|
|
511
506
|
- **Affected:** React payment widget Stripe fields.
|
|
512
507
|
- **Automatic:** failed field or script loads show a reload action. Fields that
|
|
@@ -518,9 +513,23 @@ Required shipping appears in `catalog.widget.requiredShipping`. Do not offer thi
|
|
|
518
513
|
- Reload is an explicit customer action and can clear unsaved form entries.
|
|
519
514
|
Saved payment recovery remains in session storage.
|
|
520
515
|
|
|
521
|
-
|
|
522
516
|
## 0.2.175 — Match Stripe Elements payment method configuration
|
|
523
517
|
|
|
518
|
+
- **Affected:** Core checkout submission and React payment widgets.
|
|
519
|
+
- **Automatic:** React configures explicit card, Link, and community-enabled bank
|
|
520
|
+
methods in Stripe Elements and marks the confirmation request with
|
|
521
|
+
`paymentMethodConfiguration: "explicit"`. This matches the backend's Stripe
|
|
522
|
+
PaymentIntent configuration.
|
|
523
|
+
- **Required:** deploy the backend that supports this optional marker before
|
|
524
|
+
upgrading React. Keep Core and React matched. Existing Core-only callers omit
|
|
525
|
+
the marker and retain automatic payment methods. Custom Elements integrations
|
|
526
|
+
must send the marker only when they use the explicit method list.
|
|
527
|
+
- **Check:** submit card and bank payments through Stripe Elements in test mode,
|
|
528
|
+
including recurring checkout. Confirm pending recovery and settlement.
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
## 0.2.174-dev.1 — Match Stripe Elements payment method configuration
|
|
532
|
+
|
|
524
533
|
- **Affected:** Core checkout submission and React payment widgets.
|
|
525
534
|
- **Automatic:** React configures explicit card, Link, and community-enabled bank
|
|
526
535
|
methods in Stripe Elements and marks the confirmation request with
|
|
@@ -594,7 +603,39 @@ Required shipping appears in `catalog.widget.requiredShipping`. Do not offer thi
|
|
|
594
603
|
verify a changed selection cannot discard it. Check both paid and free order
|
|
595
604
|
confirmation panels. Do not submit a live transaction for this check.
|
|
596
605
|
|
|
597
|
-
## 0.2.
|
|
606
|
+
## 0.2.172-dev.1 — Check pending payment status
|
|
607
|
+
|
|
608
|
+
- **Affected:** React payment widgets with unresolved payments.
|
|
609
|
+
- **Automatic behavior:** the existing pending-payment screen now offers Check
|
|
610
|
+
payment status. It checks the saved payment reference and cannot submit a new
|
|
611
|
+
payment. The control is disabled while the check runs.
|
|
612
|
+
- **Required host changes:** none. Update Core and React together.
|
|
613
|
+
- **Verification:** complete a test bank payment, return to its pending checkout,
|
|
614
|
+
and check its status. Confirm completion clears recovery storage.
|
|
615
|
+
|
|
616
|
+
## 0.2.171-dev.1 — SDK payment recovery and completion UI
|
|
617
|
+
|
|
618
|
+
- **Affected:** React payment widgets and custom hosts that persist payment recovery.
|
|
619
|
+
- **Optional adoption:** pass `recoveryStorageKey` to `LockerversePayment` to let
|
|
620
|
+
the SDK save and restore the pending payment in session storage. Use a stable
|
|
621
|
+
key scoped to the API environment, community, and widget. Remove the host's
|
|
622
|
+
storage code and recovery-driven component key. Do not combine automatic
|
|
623
|
+
persistence with a second host persistence writer.
|
|
624
|
+
- **Compatibility:** the SDK reads the hosted Next app's existing version 1
|
|
625
|
+
records when the same key is used. It writes version 2 records with widget
|
|
626
|
+
identity. It checks widget and selection identity before recovery and keeps
|
|
627
|
+
an unresolved record if those details differ. Recovery uses the saved connected
|
|
628
|
+
account even if current payment routing has changed. Storage is read after hydration,
|
|
629
|
+
before the payable form mounts. No contact details or payment tokens are saved.
|
|
630
|
+
- **Optional UI adoption:** use `completionView="summary"` for the SDK confirmation
|
|
631
|
+
panel and remove the host's duplicate success panel. Completion callbacks still
|
|
632
|
+
run. The default inline message and explicit `resumePayment` integrations remain
|
|
633
|
+
supported. Auctions and legacy custom checkout forms are unchanged.
|
|
634
|
+
- **Check:** reload a pending checkout and confirm the existing payment is checked;
|
|
635
|
+
verify a changed selection cannot discard it. Check both paid and free order
|
|
636
|
+
confirmation panels. Do not submit a live transaction for this check.
|
|
637
|
+
|
|
638
|
+
## 0.2.169-dev.1 — six-month payment widgets
|
|
598
639
|
|
|
599
640
|
Affected: @lockerverse/sdk checkout and @lockerverse/react payment widgets.
|
|
600
641
|
|
|
@@ -610,6 +651,31 @@ Affected: @lockerverse/sdk checkout and @lockerverse/react payment widgets.
|
|
|
610
651
|
submission. Do not submit a live payment for an integration check.
|
|
611
652
|
|
|
612
653
|
|
|
654
|
+
## 0.2.168-dev.1 — bank authorization terms
|
|
655
|
+
|
|
656
|
+
- **Affected:** React payment widgets with ACH enabled.
|
|
657
|
+
- **Automatic:** Stripe displays its bank authorization terms before payment confirmation.
|
|
658
|
+
- **Adoption:** update the matching SDK/React development pair. No prop changes are required.
|
|
659
|
+
- **Check:** confirm that the bank authorization text is visible when a bank account is selected.
|
|
660
|
+
|
|
661
|
+
## 0.2.167-dev.1 — widget ACH and subscription payment recovery
|
|
662
|
+
|
|
663
|
+
- **Affected:** Core checkout data and React payment widgets.
|
|
664
|
+
- **Automatic:** bank payment availability follows the organization default and
|
|
665
|
+
community override returned by the backend. Missing policy remains disabled.
|
|
666
|
+
Pending payments keep their existing payment reference. A failed subscription
|
|
667
|
+
invoice can return `action_required` with `requiresAction: false` and `retryUrl`;
|
|
668
|
+
React shows a link to pay the same invoice instead of creating a second subscription.
|
|
669
|
+
- **Required for custom payment UI:** preserve the reference for pending and
|
|
670
|
+
action-required results. Handle `retryUrl` by opening that invoice, and recover
|
|
671
|
+
status before permitting a new checkout. Do not treat submission as settlement.
|
|
672
|
+
- **Adoption:** deploy the matching backend policy and recovery contract before
|
|
673
|
+
enabling ACH. Existing React hosts need no component prop changes. Keep Core and
|
|
674
|
+
React versions matched when upgrading. Auction payment methods are unchanged.
|
|
675
|
+
- **Check:** verify disabled/inherited/enabled bank visibility and pending, bank
|
|
676
|
+
verification, invoice retry, success, and terminal failure in Stripe test mode.
|
|
677
|
+
Do not create a live transaction for this check.
|
|
678
|
+
|
|
613
679
|
## 0.2.166 — single dropdown arrow
|
|
614
680
|
|
|
615
681
|
- **Affected:** native single-select custom fields in React signup and payment forms.
|
package/dist/bookings.d.ts
CHANGED
|
@@ -27,16 +27,6 @@ type LockerverseBookingConfiguration = {
|
|
|
27
27
|
ready: boolean;
|
|
28
28
|
message: string;
|
|
29
29
|
diagnosticCode?: string | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Public card-entry settings, present while `ready` is true. Use them to show
|
|
32
|
-
* `LockerverseBookingPayment` before the attempt exists, for example next to
|
|
33
|
-
* the contact fields. The saved attempt returns the same values.
|
|
34
|
-
*/
|
|
35
|
-
payment?: LockerverseBookingPaymentConfiguration | undefined;
|
|
36
|
-
};
|
|
37
|
-
type LockerverseBookingPaymentConfiguration = {
|
|
38
|
-
publishableKey: string;
|
|
39
|
-
stripeAccountId: string | null;
|
|
40
30
|
};
|
|
41
31
|
type LockerverseBookingStatus = "review" | "payment_pending" | "payment_action_required" | "payment_failed" | "paid" | "booking_pending" | "booking_created" | "external_payment_pending" | "complete" | "manual_refund_required";
|
|
42
32
|
type LockerverseBookingAttempt = {
|
|
@@ -104,5 +94,5 @@ type LockerverseBookingsClient = {
|
|
|
104
94
|
/** Business identity is public; the token is obtained only at request time. */
|
|
105
95
|
declare function createLockerverseBookingsClient(options: CreateLockerverseBookingsOptions): LockerverseBookingsClient;
|
|
106
96
|
//#endregion
|
|
107
|
-
export { type CreateLockerverseBookingsOptions, type LockerverseBookingAttempt, type LockerverseBookingAvailability, type LockerverseBookingBusiness, type LockerverseBookingCatalogService, type LockerverseBookingConfiguration, type LockerverseBookingCustomer, type
|
|
97
|
+
export { type CreateLockerverseBookingsOptions, type LockerverseBookingAttempt, type LockerverseBookingAvailability, type LockerverseBookingBusiness, type LockerverseBookingCatalogService, type LockerverseBookingConfiguration, type LockerverseBookingCustomer, type LockerverseBookingSelection, type LockerverseBookingService, type LockerverseBookingSession, type LockerverseBookingStatus, type LockerverseBookingsClient, LockerverseSdkError, createLockerverseBookingsClient };
|
|
108
98
|
//# sourceMappingURL=bookings.d.ts.map
|
package/dist/bookings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bookings.d.ts","names":[],"sources":["../src/booking-types.ts","../src/booking-client.ts"],"mappings":";;KAKY;EACV;EACA;EACA;EACA;;KAGU,mCAAmC;EAC7C;;KAGU;EACV;EACA;;EAEA;EACA;EACA,SAAS;;EAET,WAAW;;KAGD;EACV,UAAU;EACV;EACA;EACA;EACA;EACA;EACA
|
|
1
|
+
{"version":3,"file":"bookings.d.ts","names":[],"sources":["../src/booking-types.ts","../src/booking-client.ts"],"mappings":";;KAKY;EACV;EACA;EACA;EACA;;KAGU,mCAAmC;EAC7C;;KAGU;EACV;EACA;;EAEA;EACA;EACA,SAAS;;EAET,WAAW;;KAGD;EACV,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;KAYA;EACV;EACA,QAAQ;EACR;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;EACA;;EAEA;;EAEA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;;;KAIU;EACV;EACA;;KAGU;EACV;EACA;EACA;;EAEA,WAAW;;KAGD,mCACV;EACE;;EAEA,sCAAsC;EACtC,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;;KAGQ;WACD;;EAET,gBACE,iCACG,QAAQ;EACb,qBAAqB,QAAQ;EAC7B,eACE,cACA,gCACG,QAAQ;EACb,aACE,WAAW,gCACR,QAAQ;EACb,UAAU,8BAA8B,QAAQ;EAChD,eAAe,QAAQ;;;;;iBChGT,gCACd,SAAS,mCACR"}
|
package/dist/bookings.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,n as t,o as n,t as r}from"./transport.js";import{n as i}from"./types.js";import{array as a,boolean as o,email as s,isoTimestamp as c,literal as l,maxLength as u,minLength as d,minValue as f,nullable as p,number as m,object as h,optional as g,parse as _,picklist as v,pipe as y,regex as b,safeInteger as x,safeParse as S,string as C,trim as w}from"valibot";const T=y(m(),x(),f(0)),E=h({email:y(C(),w(),s(),u(254)),name:y(C(),w(),d(1),u(120)),phone:y(C(),b(/^\+[1-9]\d{7,14}$/))}),D={amountCents:T,currency:l(`USD`),durationMinutes:y(m(),x(),f(1)),name:C()},O=h({environment:g(v([`sandbox`,`production`])),key:C(),name:C(),service:h(D),services:g(a(h({...D,serviceVariationId:y(C(),d(1))}))),timeZone:C()}),k=h({business:O,diagnosticCode:g(C()),lockerverse:o(),message:C(),
|
|
1
|
+
import{i as e,n as t,o as n,t as r}from"./transport.js";import{n as i}from"./types.js";import{array as a,boolean as o,email as s,isoTimestamp as c,literal as l,maxLength as u,minLength as d,minValue as f,nullable as p,number as m,object as h,optional as g,parse as _,picklist as v,pipe as y,regex as b,safeInteger as x,safeParse as S,string as C,trim as w}from"valibot";const T=y(m(),x(),f(0)),E=h({email:y(C(),w(),s(),u(254)),name:y(C(),w(),d(1),u(120)),phone:y(C(),b(/^\+[1-9]\d{7,14}$/))}),D={amountCents:T,currency:l(`USD`),durationMinutes:y(m(),x(),f(1)),name:C()},O=h({environment:g(v([`sandbox`,`production`])),key:C(),name:C(),service:h(D),services:g(a(h({...D,serviceVariationId:y(C(),d(1))}))),timeZone:C()}),k=h({business:O,diagnosticCode:g(C()),lockerverse:o(),message:C(),ready:o(),reviewer:o(),square:o()}),A=y(C(),c()),j=h({amountCents:g(T),bookingId:g(C()),bookingStatus:g(C()),clientSecret:g(C()),currency:g(l(`USD`)),id:C(),message:C(),publishableKey:C(),serviceName:g(C()),squarePaymentId:g(C()),start:A,status:v([`review`,`payment_pending`,`payment_action_required`,`payment_failed`,`paid`,`booking_pending`,`booking_created`,`external_payment_pending`,`complete`,`manual_refund_required`]),stripeAccountId:g(p(C())),timeZone:g(C())}),M=h({accessToken:y(C(),b(/^[A-Za-z0-9_-]{43}$/)),expiresAt:A}),N=e=>_(k,e),P=e=>_(h({message:C(),slots:a(A)}),e),F=e=>_(j,e),I=e=>_(p(j),e);function L(e){let t=S(E,e);return t.success?t.output:null}const R=e=>_(M,e),z=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,B=/^[A-Za-z0-9_-]{43}$/,V=/^\d{4}-\d{2}-\d{2}$/,H=/^ctoken_[A-Za-z0-9]+$/;function U(a){if(!z.test(a.businessKey)||a.businessKey.length>80)throw TypeError(`businessKey must be a valid booking business key.`);let o=e({...a,communitySlug:a.businessKey,requestTimeoutMs:a.requestTimeoutMs??6e4},`businessKey`),s=t({communitySlug:``,environment:o.environment,getContext:()=>({businessKey:a.businessKey}),onError:o.onError,resourceContextName:`lockerverse_bookings`,sentryDsn:o.sentryDsn}),{requestJson:c}=r(o.fetchImplementation,s,o.requestTimeoutMs),l=`${o.apiBaseUrl}/v2/booking-businesses/${o.resourceSlug}`;async function u(e,t){let n=t===void 0?await a.getAccessToken():t;if(t!==null&&(n===null||!B.test(n)))throw new i({code:`booking_request_failed`,message:`Booking access is not ready. Check your saved booking before trying again.`,operation:e,reportable:!1,status:401});let r=new Headers;return n!==null&&r.set(`Authorization`,`Bearer ${n}`),r}async function d(e,t,r,a,o){let d={code:`booking_request_failed`,message:`Unable to complete the booking request. Check the saved state before trying payment again.`,operation:t,report:!1};try{let s=await u(t,o),f={cache:`no-store`,credentials:`omit`,headers:s,method:a===void 0?`GET`:`POST`,redirect:`error`};a!==void 0&&(f.body=JSON.stringify(a),s.set(`Content-Type`,`application/json`));let p=await c(`${l}${e}`,f,r,d,d);if(!p.ok)throw new i({...d,message:[401,403].includes(p.response.status)?`Booking access has expired or is not valid. Your saved attempt is retained.`:d.message,recoveryRecommended:!0,reportable:p.response.status>=500,status:p.response.status});return n(p.value)}catch(e){throw s(e instanceof i?e:new i({...d,recoveryRecommended:!0,reportable:!1}))}}return{availability(e,t){if(!V.test(e))throw TypeError(`date must use YYYY-MM-DD in the business time zone.`);let n=new URLSearchParams({date:e});return t!==void 0&&n.set(`serviceVariationId`,t),d(`/slots?${n}`,`find_booking_availability`,P)},businessKey:a.businessKey,async configuration(){let e=await d(`/config`,`load_booking_configuration`,N);if(e.business.key!==a.businessKey)throw s(new i({code:`booking_request_failed`,message:`The booking response does not match this business.`,operation:`load_booking_configuration`,reportable:!0}));return e},confirm(e){if(!H.test(e)||e.length>512)throw TypeError(`A valid payment confirmation token is required.`);return d(`/confirm`,`confirm_booking`,F,{confirmationToken:e})},createSession(e){if(e!==void 0&&!B.test(e))throw TypeError(`A valid existing booking session is required.`);return d(`/session`,`create_booking_session`,R,{},e??null)},initialize(e){if(!(V.test(e.date)&&Number.isFinite(Date.parse(e.start))))throw TypeError(`Select an available booking date and time.`);let t=e.customer===void 0?void 0:L(e.customer);if(t===null)throw TypeError(`Enter your name, email and international phone number.`);let n={date:e.date,start:e.start};return e.serviceVariationId!==void 0&&(n.serviceVariationId=e.serviceVariationId),t!==void 0&&(n.customer=t),d(`/attempt`,`initialize_booking`,F,n)},recover:()=>d(`/recover`,`recover_booking`,I,{})}}export{i as LockerverseSdkError,U as createLockerverseBookingsClient};
|
|
2
2
|
//# sourceMappingURL=bookings.js.map
|
package/dist/bookings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bookings.js","names":[],"sources":["../src/booking-schemas.ts","../src/booking-client.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-unknown-parameters -- These schema parsers are the untrusted HTTP JSON boundary. */\nimport {\n array,\n boolean,\n email,\n isoTimestamp,\n literal,\n maxLength,\n minLength,\n minValue,\n nullable,\n number,\n object,\n optional,\n parse,\n picklist,\n pipe,\n regex,\n safeInteger,\n safeParse,\n string,\n trim,\n} from \"valibot\";\n\nconst nonnegativeInteger = pipe(number(), safeInteger(), minValue(0));\nconst customerSchema = object({\n email: pipe(string(), trim(), email(), maxLength(254)),\n name: pipe(string(), trim(), minLength(1), maxLength(120)),\n phone: pipe(string(), regex(/^\\+[1-9]\\d{7,14}$/)),\n});\nconst serviceFields = {\n amountCents: nonnegativeInteger,\n currency: literal(\"USD\"),\n durationMinutes: pipe(number(), safeInteger(), minValue(1)),\n name: string(),\n};\nconst businessSchema = object({\n environment: optional(picklist([\"sandbox\", \"production\"])),\n key: string(),\n name: string(),\n service: object(serviceFields),\n services: optional(\n array(\n object({\n ...serviceFields,\n serviceVariationId: pipe(string(), minLength(1)),\n })\n )\n ),\n timeZone: string(),\n});\nconst configurationSchema = object({\n business: businessSchema,\n diagnosticCode: optional(string()),\n lockerverse: boolean(),\n message: string(),\n payment: optional(\n object({\n publishableKey: pipe(string(), regex(/^pk_(?:test|live)_/)),\n stripeAccountId: nullable(pipe(string(), regex(/^acct_[A-Za-z0-9]+$/))),\n })\n ),\n ready: boolean(),\n reviewer: boolean(),\n square: boolean(),\n});\nconst instant = pipe(string(), isoTimestamp());\nconst attemptSchema = object({\n amountCents: optional(nonnegativeInteger),\n bookingId: optional(string()),\n bookingStatus: optional(string()),\n clientSecret: optional(string()),\n currency: optional(literal(\"USD\")),\n id: string(),\n message: string(),\n publishableKey: string(),\n serviceName: optional(string()),\n squarePaymentId: optional(string()),\n start: instant,\n status: picklist([\n \"review\",\n \"payment_pending\",\n \"payment_action_required\",\n \"payment_failed\",\n \"paid\",\n \"booking_pending\",\n \"booking_created\",\n \"external_payment_pending\",\n \"complete\",\n \"manual_refund_required\",\n ]),\n stripeAccountId: optional(nullable(string())),\n timeZone: optional(string()),\n});\nconst sessionSchema = object({\n accessToken: pipe(string(), regex(/^[A-Za-z0-9_-]{43}$/)),\n expiresAt: instant,\n});\n\nexport const parseBookingConfiguration = (value: unknown) =>\n parse(configurationSchema, value);\nexport const parseBookingAvailability = (value: unknown) =>\n parse(object({ message: string(), slots: array(instant) }), value);\nexport const parseBookingAttempt = (value: unknown) =>\n parse(attemptSchema, value);\nexport const parseBookingRecovery = (value: unknown) =>\n parse(nullable(attemptSchema), value);\nexport function parseBookingCustomer(value: unknown) {\n const result = safeParse(customerSchema, value);\n return result.success ? result.output : null;\n}\nexport const parseBookingSession = (value: unknown) =>\n parse(sessionSchema, value);\n","import {\n parseBookingAttempt,\n parseBookingAvailability,\n parseBookingConfiguration,\n parseBookingCustomer,\n parseBookingRecovery,\n parseBookingSession,\n} from \"./booking-schemas.ts\";\nimport type {\n CreateLockerverseBookingsOptions,\n LockerverseBookingSelection,\n LockerverseBookingsClient,\n} from \"./booking-types.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport { resolveResourceEnvironment } from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport { LockerverseSdkError, type LockerverseSdkOperation } from \"./types.ts\";\n\nconst BUSINESS_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst ACCESS_TOKEN = /^[A-Za-z0-9_-]{43}$/;\nconst DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst CONFIRMATION_TOKEN = /^ctoken_[A-Za-z0-9]+$/;\n\n/** Business identity is public; the token is obtained only at request time. */\nexport function createLockerverseBookingsClient(\n options: CreateLockerverseBookingsOptions\n): LockerverseBookingsClient {\n if (\n !BUSINESS_KEY.test(options.businessKey) ||\n options.businessKey.length > 80\n ) {\n throw new TypeError(\"businessKey must be a valid booking business key.\");\n }\n // Reuse the SDK environment/URL rules with this business as the resource identity.\n const runtime = resolveResourceEnvironment(\n {\n ...options,\n communitySlug: options.businessKey,\n requestTimeoutMs: options.requestTimeoutMs ?? 60_000,\n },\n \"businessKey\"\n );\n const reportError = createSdkErrorReporter({\n communitySlug: \"\",\n environment: runtime.environment,\n getContext: () => ({ businessKey: options.businessKey }),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_bookings\",\n sentryDsn: runtime.sentryDsn,\n });\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n reportError,\n runtime.requestTimeoutMs\n );\n const baseUrl = `${runtime.apiBaseUrl}/v2/booking-businesses/${runtime.resourceSlug}`;\n\n async function requestHeaders(\n operation: LockerverseSdkOperation,\n sessionToken?: string | null\n ) {\n const token =\n sessionToken === undefined\n ? await options.getAccessToken()\n : sessionToken;\n if (\n sessionToken !== null &&\n (token === null || !ACCESS_TOKEN.test(token))\n ) {\n throw new LockerverseSdkError({\n code: \"booking_request_failed\",\n message:\n \"Booking access is not ready. Check your saved booking before trying again.\",\n operation,\n reportable: false,\n status: 401,\n });\n }\n const headers = new Headers();\n if (token !== null) {\n headers.set(\"Authorization\", `Bearer ${token}`);\n }\n return headers;\n }\n\n async function request<T>(\n path: string,\n operation: LockerverseSdkOperation,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- The transport parses untrusted JSON through this boundary.\n parser: (value: unknown) => T,\n body?:\n | LockerverseBookingSelection\n | { confirmationToken: string }\n | Record<string, never>,\n sessionToken?: string | null\n ): Promise<T> {\n const context = {\n code: \"booking_request_failed\" as const,\n message:\n \"Unable to complete the booking request. Check the saved state before trying payment again.\",\n operation,\n report: false,\n };\n try {\n const headers = await requestHeaders(operation, sessionToken);\n const init: RequestInit = {\n cache: \"no-store\",\n credentials: \"omit\",\n headers,\n method: body === undefined ? \"GET\" : \"POST\",\n redirect: \"error\",\n };\n if (body !== undefined) {\n init.body = JSON.stringify(body);\n headers.set(\"Content-Type\", \"application/json\");\n }\n const response = await requestJson(\n `${baseUrl}${path}`,\n init,\n parser,\n context,\n context\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: [401, 403].includes(response.response.status)\n ? \"Booking access has expired or is not valid. Your saved attempt is retained.\"\n : context.message,\n recoveryRecommended: true,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n return deepFreeze(response.value);\n } catch (error) {\n throw reportError(\n error instanceof LockerverseSdkError\n ? error\n : new LockerverseSdkError({\n ...context,\n recoveryRecommended: true,\n reportable: false,\n })\n );\n }\n }\n\n return {\n availability(date, serviceVariationId) {\n if (!DATE.test(date)) {\n throw new TypeError(\n \"date must use YYYY-MM-DD in the business time zone.\"\n );\n }\n const query = new URLSearchParams({ date });\n if (serviceVariationId !== undefined) {\n query.set(\"serviceVariationId\", serviceVariationId);\n }\n return request(\n `/slots?${query}`,\n \"find_booking_availability\",\n parseBookingAvailability\n );\n },\n businessKey: options.businessKey,\n async configuration() {\n const result = await request(\n \"/config\",\n \"load_booking_configuration\",\n parseBookingConfiguration\n );\n if (result.business.key !== options.businessKey) {\n throw reportError(\n new LockerverseSdkError({\n code: \"booking_request_failed\",\n message: \"The booking response does not match this business.\",\n operation: \"load_booking_configuration\",\n reportable: true,\n })\n );\n }\n return result;\n },\n confirm(confirmationToken) {\n if (\n !CONFIRMATION_TOKEN.test(confirmationToken) ||\n confirmationToken.length > 512\n ) {\n throw new TypeError(\"A valid payment confirmation token is required.\");\n }\n return request(\"/confirm\", \"confirm_booking\", parseBookingAttempt, {\n confirmationToken,\n });\n },\n createSession(previousAccessToken) {\n if (\n previousAccessToken !== undefined &&\n !ACCESS_TOKEN.test(previousAccessToken)\n ) {\n throw new TypeError(\"A valid existing booking session is required.\");\n }\n return request(\n \"/session\",\n \"create_booking_session\",\n parseBookingSession,\n {},\n previousAccessToken ?? null\n );\n },\n initialize(selection) {\n if (\n !(\n DATE.test(selection.date) &&\n Number.isFinite(Date.parse(selection.start))\n )\n ) {\n throw new TypeError(\"Select an available booking date and time.\");\n }\n const customer =\n selection.customer === undefined\n ? undefined\n : parseBookingCustomer(selection.customer);\n if (customer === null) {\n throw new TypeError(\n \"Enter your name, email and international phone number.\"\n );\n }\n const body: LockerverseBookingSelection = {\n date: selection.date,\n start: selection.start,\n };\n if (selection.serviceVariationId !== undefined) {\n body.serviceVariationId = selection.serviceVariationId;\n }\n if (customer !== undefined) {\n body.customer = customer;\n }\n return request(\n \"/attempt\",\n \"initialize_booking\",\n parseBookingAttempt,\n body\n );\n },\n recover: () =>\n request(\"/recover\", \"recover_booking\", parseBookingRecovery, {}),\n };\n}\n"],"mappings":"kXAwBA,MAAM,EAAqB,EAAK,EAAO,EAAG,EAAY,EAAG,EAAS,CAAC,CAAC,EAC9D,EAAiB,EAAO,CAC5B,MAAO,EAAK,EAAO,EAAG,EAAK,EAAG,EAAM,EAAG,EAAU,GAAG,CAAC,EACrD,KAAM,EAAK,EAAO,EAAG,EAAK,EAAG,EAAU,CAAC,EAAG,EAAU,GAAG,CAAC,EACzD,MAAO,EAAK,EAAO,EAAG,EAAM,mBAAmB,CAAC,CAClD,CAAC,EACK,EAAgB,CACpB,YAAa,EACb,SAAU,EAAQ,KAAK,EACvB,gBAAiB,EAAK,EAAO,EAAG,EAAY,EAAG,EAAS,CAAC,CAAC,EAC1D,KAAM,EAAO,CACf,EACM,EAAiB,EAAO,CAC5B,YAAa,EAAS,EAAS,CAAC,UAAW,YAAY,CAAC,CAAC,EACzD,IAAK,EAAO,EACZ,KAAM,EAAO,EACb,QAAS,EAAO,CAAa,EAC7B,SAAU,EACR,EACE,EAAO,CACL,GAAG,EACH,mBAAoB,EAAK,EAAO,EAAG,EAAU,CAAC,CAAC,CACjD,CAAC,CACH,CACF,EACA,SAAU,EAAO,CACnB,CAAC,EACK,EAAsB,EAAO,CACjC,SAAU,EACV,e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,WACA,yBACA,EACA,CAAC,EACD,GAAuB,IACzB,CACF,EACA,WAAW,EAAW,CACpB,GACE,EACE,EAAK,KAAK,EAAU,IAAI,GACxB,OAAO,SAAS,KAAK,MAAM,EAAU,KAAK,CAAC,GAG7C,MAAU,UAAU,4CAA4C,EAElE,IAAM,EACJ,EAAU,WAAa,IAAA,GACnB,IAAA,GACA,EAAqB,EAAU,QAAQ,EAC7C,GAAI,IAAa,KACf,MAAU,UACR,wDACF,EAEF,IAAM,EAAoC,CACxC,KAAM,EAAU,KAChB,MAAO,EAAU,KACnB,EAOA,OANI,EAAU,qBAAuB,IAAA,KACnC,EAAK,mBAAqB,EAAU,oBAElC,IAAa,IAAA,KACf,EAAK,SAAW,GAEX,EACL,WACA,qBACA,EACA,CACF,CACF,EACA,YACE,EAAQ,WAAY,kBAAmB,EAAsB,CAAC,CAAC,CACnE,CACF"}
|
|
1
|
+
{"version":3,"file":"bookings.js","names":[],"sources":["../src/booking-schemas.ts","../src/booking-client.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-unknown-parameters -- These schema parsers are the untrusted HTTP JSON boundary. */\nimport {\n array,\n boolean,\n email,\n isoTimestamp,\n literal,\n maxLength,\n minLength,\n minValue,\n nullable,\n number,\n object,\n optional,\n parse,\n picklist,\n pipe,\n regex,\n safeInteger,\n safeParse,\n string,\n trim,\n} from \"valibot\";\n\nconst nonnegativeInteger = pipe(number(), safeInteger(), minValue(0));\nconst customerSchema = object({\n email: pipe(string(), trim(), email(), maxLength(254)),\n name: pipe(string(), trim(), minLength(1), maxLength(120)),\n phone: pipe(string(), regex(/^\\+[1-9]\\d{7,14}$/)),\n});\nconst serviceFields = {\n amountCents: nonnegativeInteger,\n currency: literal(\"USD\"),\n durationMinutes: pipe(number(), safeInteger(), minValue(1)),\n name: string(),\n};\nconst businessSchema = object({\n environment: optional(picklist([\"sandbox\", \"production\"])),\n key: string(),\n name: string(),\n service: object(serviceFields),\n services: optional(\n array(\n object({\n ...serviceFields,\n serviceVariationId: pipe(string(), minLength(1)),\n })\n )\n ),\n timeZone: string(),\n});\nconst configurationSchema = object({\n business: businessSchema,\n diagnosticCode: optional(string()),\n lockerverse: boolean(),\n message: string(),\n ready: boolean(),\n reviewer: boolean(),\n square: boolean(),\n});\nconst instant = pipe(string(), isoTimestamp());\nconst attemptSchema = object({\n amountCents: optional(nonnegativeInteger),\n bookingId: optional(string()),\n bookingStatus: optional(string()),\n clientSecret: optional(string()),\n currency: optional(literal(\"USD\")),\n id: string(),\n message: string(),\n publishableKey: string(),\n serviceName: optional(string()),\n squarePaymentId: optional(string()),\n start: instant,\n status: picklist([\n \"review\",\n \"payment_pending\",\n \"payment_action_required\",\n \"payment_failed\",\n \"paid\",\n \"booking_pending\",\n \"booking_created\",\n \"external_payment_pending\",\n \"complete\",\n \"manual_refund_required\",\n ]),\n stripeAccountId: optional(nullable(string())),\n timeZone: optional(string()),\n});\nconst sessionSchema = object({\n accessToken: pipe(string(), regex(/^[A-Za-z0-9_-]{43}$/)),\n expiresAt: instant,\n});\n\nexport const parseBookingConfiguration = (value: unknown) =>\n parse(configurationSchema, value);\nexport const parseBookingAvailability = (value: unknown) =>\n parse(object({ message: string(), slots: array(instant) }), value);\nexport const parseBookingAttempt = (value: unknown) =>\n parse(attemptSchema, value);\nexport const parseBookingRecovery = (value: unknown) =>\n parse(nullable(attemptSchema), value);\nexport function parseBookingCustomer(value: unknown) {\n const result = safeParse(customerSchema, value);\n return result.success ? result.output : null;\n}\nexport const parseBookingSession = (value: unknown) =>\n parse(sessionSchema, value);\n","import {\n parseBookingAttempt,\n parseBookingAvailability,\n parseBookingConfiguration,\n parseBookingCustomer,\n parseBookingRecovery,\n parseBookingSession,\n} from \"./booking-schemas.ts\";\nimport type {\n CreateLockerverseBookingsOptions,\n LockerverseBookingSelection,\n LockerverseBookingsClient,\n} from \"./booking-types.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport { resolveResourceEnvironment } from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport { LockerverseSdkError, type LockerverseSdkOperation } from \"./types.ts\";\n\nconst BUSINESS_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst ACCESS_TOKEN = /^[A-Za-z0-9_-]{43}$/;\nconst DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst CONFIRMATION_TOKEN = /^ctoken_[A-Za-z0-9]+$/;\n\n/** Business identity is public; the token is obtained only at request time. */\nexport function createLockerverseBookingsClient(\n options: CreateLockerverseBookingsOptions\n): LockerverseBookingsClient {\n if (\n !BUSINESS_KEY.test(options.businessKey) ||\n options.businessKey.length > 80\n ) {\n throw new TypeError(\"businessKey must be a valid booking business key.\");\n }\n // Reuse the SDK environment/URL rules with this business as the resource identity.\n const runtime = resolveResourceEnvironment(\n {\n ...options,\n communitySlug: options.businessKey,\n requestTimeoutMs: options.requestTimeoutMs ?? 60_000,\n },\n \"businessKey\"\n );\n const reportError = createSdkErrorReporter({\n communitySlug: \"\",\n environment: runtime.environment,\n getContext: () => ({ businessKey: options.businessKey }),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_bookings\",\n sentryDsn: runtime.sentryDsn,\n });\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n reportError,\n runtime.requestTimeoutMs\n );\n const baseUrl = `${runtime.apiBaseUrl}/v2/booking-businesses/${runtime.resourceSlug}`;\n\n async function requestHeaders(\n operation: LockerverseSdkOperation,\n sessionToken?: string | null\n ) {\n const token =\n sessionToken === undefined\n ? await options.getAccessToken()\n : sessionToken;\n if (\n sessionToken !== null &&\n (token === null || !ACCESS_TOKEN.test(token))\n ) {\n throw new LockerverseSdkError({\n code: \"booking_request_failed\",\n message:\n \"Booking access is not ready. Check your saved booking before trying again.\",\n operation,\n reportable: false,\n status: 401,\n });\n }\n const headers = new Headers();\n if (token !== null) {\n headers.set(\"Authorization\", `Bearer ${token}`);\n }\n return headers;\n }\n\n async function request<T>(\n path: string,\n operation: LockerverseSdkOperation,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- The transport parses untrusted JSON through this boundary.\n parser: (value: unknown) => T,\n body?:\n | LockerverseBookingSelection\n | { confirmationToken: string }\n | Record<string, never>,\n sessionToken?: string | null\n ): Promise<T> {\n const context = {\n code: \"booking_request_failed\" as const,\n message:\n \"Unable to complete the booking request. Check the saved state before trying payment again.\",\n operation,\n report: false,\n };\n try {\n const headers = await requestHeaders(operation, sessionToken);\n const init: RequestInit = {\n cache: \"no-store\",\n credentials: \"omit\",\n headers,\n method: body === undefined ? \"GET\" : \"POST\",\n redirect: \"error\",\n };\n if (body !== undefined) {\n init.body = JSON.stringify(body);\n headers.set(\"Content-Type\", \"application/json\");\n }\n const response = await requestJson(\n `${baseUrl}${path}`,\n init,\n parser,\n context,\n context\n );\n if (!response.ok) {\n throw new LockerverseSdkError({\n ...context,\n message: [401, 403].includes(response.response.status)\n ? \"Booking access has expired or is not valid. Your saved attempt is retained.\"\n : context.message,\n recoveryRecommended: true,\n reportable: response.response.status >= 500,\n status: response.response.status,\n });\n }\n return deepFreeze(response.value);\n } catch (error) {\n throw reportError(\n error instanceof LockerverseSdkError\n ? error\n : new LockerverseSdkError({\n ...context,\n recoveryRecommended: true,\n reportable: false,\n })\n );\n }\n }\n\n return {\n availability(date, serviceVariationId) {\n if (!DATE.test(date)) {\n throw new TypeError(\n \"date must use YYYY-MM-DD in the business time zone.\"\n );\n }\n const query = new URLSearchParams({ date });\n if (serviceVariationId !== undefined) {\n query.set(\"serviceVariationId\", serviceVariationId);\n }\n return request(\n `/slots?${query}`,\n \"find_booking_availability\",\n parseBookingAvailability\n );\n },\n businessKey: options.businessKey,\n async configuration() {\n const result = await request(\n \"/config\",\n \"load_booking_configuration\",\n parseBookingConfiguration\n );\n if (result.business.key !== options.businessKey) {\n throw reportError(\n new LockerverseSdkError({\n code: \"booking_request_failed\",\n message: \"The booking response does not match this business.\",\n operation: \"load_booking_configuration\",\n reportable: true,\n })\n );\n }\n return result;\n },\n confirm(confirmationToken) {\n if (\n !CONFIRMATION_TOKEN.test(confirmationToken) ||\n confirmationToken.length > 512\n ) {\n throw new TypeError(\"A valid payment confirmation token is required.\");\n }\n return request(\"/confirm\", \"confirm_booking\", parseBookingAttempt, {\n confirmationToken,\n });\n },\n createSession(previousAccessToken) {\n if (\n previousAccessToken !== undefined &&\n !ACCESS_TOKEN.test(previousAccessToken)\n ) {\n throw new TypeError(\"A valid existing booking session is required.\");\n }\n return request(\n \"/session\",\n \"create_booking_session\",\n parseBookingSession,\n {},\n previousAccessToken ?? null\n );\n },\n initialize(selection) {\n if (\n !(\n DATE.test(selection.date) &&\n Number.isFinite(Date.parse(selection.start))\n )\n ) {\n throw new TypeError(\"Select an available booking date and time.\");\n }\n const customer =\n selection.customer === undefined\n ? undefined\n : parseBookingCustomer(selection.customer);\n if (customer === null) {\n throw new TypeError(\n \"Enter your name, email and international phone number.\"\n );\n }\n const body: LockerverseBookingSelection = {\n date: selection.date,\n start: selection.start,\n };\n if (selection.serviceVariationId !== undefined) {\n body.serviceVariationId = selection.serviceVariationId;\n }\n if (customer !== undefined) {\n body.customer = customer;\n }\n return request(\n \"/attempt\",\n \"initialize_booking\",\n parseBookingAttempt,\n body\n );\n },\n recover: () =>\n request(\"/recover\", \"recover_booking\", parseBookingRecovery, {}),\n };\n}\n"],"mappings":"kXAwBA,MAAM,EAAqB,EAAK,EAAO,EAAG,EAAY,EAAG,EAAS,CAAC,CAAC,EAC9D,EAAiB,EAAO,CAC5B,MAAO,EAAK,EAAO,EAAG,EAAK,EAAG,EAAM,EAAG,EAAU,GAAG,CAAC,EACrD,KAAM,EAAK,EAAO,EAAG,EAAK,EAAG,EAAU,CAAC,EAAG,EAAU,GAAG,CAAC,EACzD,MAAO,EAAK,EAAO,EAAG,EAAM,mBAAmB,CAAC,CAClD,CAAC,EACK,EAAgB,CACpB,YAAa,EACb,SAAU,EAAQ,KAAK,EACvB,gBAAiB,EAAK,EAAO,EAAG,EAAY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MAAU,UAAU,iDAAiD,EAEvE,OAAO,EAAQ,WAAY,kBAAmB,EAAqB,CACjE,mBACF,CAAC,CACH,EACA,cAAc,EAAqB,CACjC,GACE,IAAwB,IAAA,IACxB,CAAC,EAAa,KAAK,CAAmB,EAEtC,MAAU,UAAU,+CAA+C,EAErE,OAAO,EACL,WACA,yBACA,EACA,CAAC,EACD,GAAuB,IACzB,CACF,EACA,WAAW,EAAW,CACpB,GACE,EACE,EAAK,KAAK,EAAU,IAAI,GACxB,OAAO,SAAS,KAAK,MAAM,EAAU,KAAK,CAAC,GAG7C,MAAU,UAAU,4CAA4C,EAElE,IAAM,EACJ,EAAU,WAAa,IAAA,GACnB,IAAA,GACA,EAAqB,EAAU,QAAQ,EAC7C,GAAI,IAAa,KACf,MAAU,UACR,wDACF,EAEF,IAAM,EAAoC,CACxC,KAAM,EAAU,KAChB,MAAO,EAAU,KACnB,EAOA,OANI,EAAU,qBAAuB,IAAA,KACnC,EAAK,mBAAqB,EAAU,oBAElC,IAAa,IAAA,KACf,EAAK,SAAW,GAEX,EACL,WACA,qBACA,EACA,CACF,CACF,EACA,YACE,EAAQ,WAAY,kBAAmB,EAAsB,CAAC,CAAC,CACnE,CACF"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=`0.2.
|
|
1
|
+
const e=`0.2.248-dev.1`;var t=class extends Error{failureKind;code;operation;reportable;recoveryRecommended;sdkVersion;serverCode;status;constructor({failureKind:t,code:n,message:r,operation:i,reportable:a,recoveryRecommended:o=!1,serverCode:s,status:c}){super(r),this.name=`LockerverseSdkError`,this.failureKind=t,this.code=n,this.operation=i,this.reportable=a,this.recoveryRecommended=o,this.sdkVersion=e,this.serverCode=s,this.status=c}};export{t as n,e as t};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["packageMetadata.version"],"sources":["../package.json","../src/types.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\" with { type: \"json\" };\nimport type { GeneratedPaymentResult } from \"./generated/public-contract-types.ts\";\n\nexport type LockerversePaymentOption =\n | \"one-time\"\n | \"monthly\"\n | \"annually\"\n | \"every-six-months\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\nexport type LockerverseFulfillmentType = \"none\" | \"event_admission\";\n\nexport const LOCKERVERSE_SDK_VERSION = packageMetadata.version;\n\nexport type LockerverseProduct = {\n id: string;\n listingId: string;\n slug: string;\n name: string;\n description: string | null;\n fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n amountCents: number | null;\n minimumAmountCents: number | null;\n minimumQuantity: number | null;\n /** Per-order limit for this widget listing. Null means no per-order limit. */\n maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseAvailabilityStatus = \"available\" | \"sold_out\";\n\nexport type LockerverseCatalogAvailability = {\n listings: Array<{\n listingId: string;\n maxPurchasableQuantity: number | null;\n remainingQuantity: number | null;\n status: LockerverseAvailabilityStatus;\n }>;\n sharedLimits: Array<{\n id: string;\n listingIds: string[];\n listingWeights?: Record<string, number>;\n remainingQuantity: number;\n status: LockerverseAvailabilityStatus;\n }>;\n};\n\nexport type LockerverseCatalog = {\n availability: LockerverseCatalogAvailability;\n community: LockerverseCommunityBranding | null;\n event: LockerverseEvent | null;\n payment: LockerversePaymentConfiguration;\n pricingPolicy: LockerverseCheckoutPricingPolicy;\n products: LockerverseProduct[];\n widget: LockerverseWidgetConfiguration;\n};\n\nexport type LockerverseEvent = {\n description: string | null;\n endAt: string;\n id: string;\n location: string | null;\n name: string;\n startAt: string;\n status: \"draft\" | \"active\" | \"finished\" | \"cancelled\";\n};\n\nexport type LockerverseCommunityBranding = {\n widgetAchEnabled?: boolean | undefined;\n accentColor: string;\n imageUrl: string | null;\n memberIdLabel?: string | null | undefined;\n name: string;\n};\n\nexport type LockerverseCheckoutPricingPolicy = {\n currency: \"usd\";\n serviceFeeRateBasisPoints: number;\n};\n\nexport type LockerversePaymentConfiguration = {\n connectedAccountId: string | null;\n currency: \"usd\";\n publishableKey: string;\n};\n\nexport type LockerverseWidgetFields = {\n memberId: boolean;\n merchSize: boolean;\n phone: boolean;\n promoCode: boolean;\n serviceFee: boolean;\n shipping: boolean;\n tipping: boolean;\n};\n\nexport type LockerverseCustomFieldOption = { id: string; label: string };\n\ntype LockerverseCustomFieldBase = {\n id: string;\n label: string;\n paymentOptionIds?: string[] | undefined;\n required: boolean;\n};\n\nexport type LockerverseTextCustomField = LockerverseCustomFieldBase & {\n type: \"text\" | \"textarea\";\n};\n\nexport type LockerverseBooleanCustomField = LockerverseCustomFieldBase & {\n type: \"checkbox\";\n};\n\nexport type LockerverseSingleOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"radio\" | \"select\";\n};\n\nexport type LockerverseMultiOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"checkboxes\" | \"multi_select\";\n};\n\nexport type LockerverseCustomField =\n | LockerverseBooleanCustomField\n | LockerverseTextCustomField\n | LockerverseSingleOptionCustomField\n | LockerverseMultiOptionCustomField;\n\nexport type LockerverseCustomFieldAnswerValue<\n Field extends LockerverseCustomField,\n> = Field extends LockerverseBooleanCustomField\n ? boolean\n : Field extends LockerverseMultiOptionCustomField\n ? string[]\n : string;\n\nexport type LockerverseCustomFieldAnswer<\n Field extends LockerverseCustomField = LockerverseCustomField,\n> = Field extends LockerverseCustomField\n ? { fieldId: Field[\"id\"]; value: LockerverseCustomFieldAnswerValue<Field> }\n : never;\n\nexport type LockerverseWidgetConfiguration = {\n requiredShipping?:\n | {\n additionalUnitAmountCents?: number | undefined;\n productId: string;\n triggerProductIds: string[];\n }\n | undefined;\n customFields: LockerverseCustomField[];\n description: string | null;\n fields: LockerverseWidgetFields;\n id: string;\n name: string;\n showCommunityBranding: boolean;\n title: string | null;\n};\n\nexport type LockerverseSdkErrorCode =\n | \"booking_request_failed\"\n | \"public_events_load_failed\"\n | \"auction_load_failed\"\n | \"auction_bid_failed\"\n | \"auction_purchase_failed\"\n | \"auction_purchase_status_failed\"\n | \"auction_receipt_failed\"\n | \"widget_load_failed\"\n | \"signup_load_failed\"\n | \"signup_submit_failed\"\n | \"total_calculation_failed\"\n | \"payment_submit_failed\"\n | \"payment_status_failed\"\n | \"invalid_selection\";\n\nexport type LockerverseSdkOperation =\n | \"load_booking_configuration\"\n | \"create_booking_session\"\n | \"find_booking_availability\"\n | \"initialize_booking\"\n | \"confirm_booking\"\n | \"recover_booking\"\n | \"list_public_events\"\n | \"list_auctions\"\n | \"load_auction\"\n | \"create_auction_bid\"\n | \"create_auction_purchase\"\n | \"get_auction_purchase_receipt\"\n | \"get_auction_purchase_status\"\n | \"load_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\";\n\nexport type LockerverseSdkServerCode =\n | \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\"\n | \"PAYMENT_WIDGET_PHONE_INVALID\"\n | \"PAYMENT_WIDGET_PHONE_REQUIRED\"\n | \"SIGN_UP_WIDGET_PHONE_INVALID\"\n | \"SIGN_UP_WIDGET_PHONE_REQUIRED\";\n\nexport type LockerverseSdkFailureKind =\n | \"network\"\n | \"timeout\"\n | \"aborted\"\n | \"invalid_response\";\n\nexport class LockerverseSdkError extends Error {\n readonly failureKind: LockerverseSdkFailureKind | undefined;\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly serverCode: LockerverseSdkServerCode | undefined;\n readonly status: number | undefined;\n\n constructor({\n failureKind,\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n serverCode,\n status,\n }: {\n failureKind?: LockerverseSdkFailureKind | undefined;\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n serverCode?: LockerverseSdkServerCode;\n status?: number | undefined;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.failureKind = failureKind;\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.serverCode = serverCode;\n this.status = status;\n }\n}\n\nexport type LockerverseCheckoutLineItem = {\n productId: string;\n productName: string;\n listingId: string;\n listingSlug: string;\n acceptsDiscounts: boolean;\n eventId: string | null;\n fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n quantity: number;\n unitAmountCents: number;\n subtotalCents: number;\n};\n\nexport type LockerverseAppliedDiscount = {\n percentageOff?: number | undefined;\n amountOffCents?: number | undefined;\n message?: string | undefined;\n source: \"email_list\" | \"promo_code\";\n};\n\nexport type LockerverseCheckoutAmounts = {\n amountCents: number;\n discountableSubtotalCents: number;\n discountCents: number;\n serviceFeeCents: number;\n subtotalCents: number;\n tipCents: number;\n totalCents: number;\n};\n\nexport type LockerverseCheckoutQuote = LockerverseCheckoutAmounts & {\n appliedDiscount: LockerverseAppliedDiscount | null;\n authoritative: true;\n paymentReference: string;\n payment: LockerversePaymentConfiguration;\n paymentOption: LockerversePaymentOption;\n lineItems: LockerverseCheckoutLineItem[];\n};\n\nexport type LockerverseCheckoutEstimate = LockerverseCheckoutAmounts & {\n appliedDiscount: null;\n authoritative: false;\n items: readonly LockerverseCheckoutItem[];\n lineItems: readonly LockerverseCheckoutLineItem[];\n paymentOption: LockerversePaymentOption;\n};\n\nexport type LockerverseCheckoutPricingInput = {\n email?: string;\n includeServiceFee?: boolean;\n promoCode?: string;\n tipCents?: number;\n};\n\nexport type LockerversePaymentStatus =\n | \"action_required\"\n | \"failed\"\n | \"pending\"\n | \"success\";\n\nexport type LockerversePaymentResult = {\n checkoutId: string;\n paymentReference: string;\n checkoutStatus: LockerversePaymentStatus;\n retryUrl?: string | undefined;\n clientSecret: string | null;\n paymentRequired: boolean;\n requiresAction: boolean;\n status: string | null;\n};\n\nexport type LockerversePaymentCompletion = LockerversePaymentResult & {\n email: string | null;\n lineItems: readonly LockerverseCheckoutLineItem[] | null;\n};\n\ntype AssertPaymentContract<T extends true> = T;\ntype _PaymentResultMatchesGenerated = AssertPaymentContract<\n LockerversePaymentResult extends GeneratedPaymentResult\n ? GeneratedPaymentResult extends LockerversePaymentResult\n ? true\n : false\n : false\n>;\n\nexport type LockerverseShipping = {\n address: {\n city: string;\n country: string;\n line1: string;\n line2?: string;\n postal_code: string;\n state: string;\n };\n name: string;\n};\n\nexport type LockerversePaymentSubmission = {\n confirmationToken?: string;\n paymentMethodConfiguration?: \"explicit\";\n customFieldAnswers?: LockerverseCustomFieldAnswer[];\n email: string;\n memberId?: string;\n merchSize?: \"XS\" | \"S\" | \"M\" | \"L\" | \"XL\" | \"XXL\" | \"XXXL\";\n metadata?: Record<string, string>;\n phone?: string;\n shipping?: LockerverseShipping;\n};\n\nexport type LockerverseCheckoutItem =\n | { productId: string; quantity: number }\n | { productId: string; amountCents: number }\n | { productId: string };\n\nexport type LockerverseCheckoutSelectionItem =\n | { productSlug: string; quantity: number }\n | { productSlug: string; amountCents: number }\n | { productSlug: string };\n\nexport type LockerverseEstimateCheckoutInput =\n LockerverseCheckoutPricingInput & {\n selection: LockerverseCheckoutSelectionItem[];\n };\n\nexport type LockerverseLoadCheckoutInput = {\n selection: LockerverseCheckoutSelectionItem[];\n};\n\nexport type LockerverseCalculateTotalInput = LockerverseCheckoutPricingInput & {\n catalog: LockerverseCatalog;\n} & (\n | {\n items: LockerverseCheckoutItem[];\n selection?: never;\n }\n | {\n items?: never;\n selection: LockerverseCheckoutSelectionItem[];\n }\n );\n\nexport type LockerversePreparedCheckout = Readonly<\n LockerverseCheckoutQuote & {\n items: readonly LockerverseCheckoutItem[];\n pricing: Readonly<LockerverseCheckoutPricingInput>;\n }\n>;\n\nexport type LockerverseLoadedCheckout = Readonly<{\n catalog: LockerverseCatalog;\n checkout: LockerversePreparedCheckout;\n}>;\n\nexport type LockerverseSubmitPaymentInput = {\n checkout: LockerversePreparedCheckout;\n submission: LockerversePaymentSubmission;\n};\n\ntype CreateLockerverseWidgetBaseOptions = {\n communitySlug: string;\n fetch?: typeof globalThis.fetch;\n onError?: (error: LockerverseSdkError) => void;\n requestTimeoutMs?: number;\n sentryDsn?: string | null;\n widgetSlug: string;\n};\n\nexport type LockerverseResourceEnvironmentOptions =\n | {\n apiBaseUrl: string;\n environment: LockerverseEnvironment;\n }\n | {\n apiBaseUrl?: undefined;\n environment?: \"production\";\n };\n\nexport type CreateLockerverseWidgetOptions =\n CreateLockerverseWidgetBaseOptions & LockerverseResourceEnvironmentOptions;\n\nexport type LockerverseCheckoutClient = {\n calculateTotal: (\n input: LockerverseCalculateTotalInput\n ) => Promise<LockerversePreparedCheckout>;\n getPaymentStatus: (\n paymentReference: string\n ) => Promise<LockerversePaymentResult>;\n load: {\n (): Promise<LockerverseCatalog>;\n (input: LockerverseLoadCheckoutInput): Promise<LockerverseLoadedCheckout>;\n };\n submitPayment: (\n input: LockerverseSubmitPaymentInput\n ) => Promise<LockerversePaymentResult>;\n};\n"],"mappings":"ACWA,MAAa,EAA0BA,UAyMvC,IAAa,EAAb,cAAyC,KAAM,CAC7C,YACA,KACA,UACA,WACA,oBACA,WACA,WACA,OAEA,YAAY,CACV,cACA,OACA,UACA,YACA,aACA,sBAAsB,GACtB,aACA,UAUC,CACD,MAAM,CAAO,EACb,KAAK,KAAO,sBACZ,KAAK,YAAc,EACnB,KAAK,KAAO,EACZ,KAAK,UAAY,EACjB,KAAK,WAAa,EAClB,KAAK,oBAAsB,EAC3B,KAAK,WAAa,EAClB,KAAK,WAAa,EAClB,KAAK,OAAS,CAChB,CACF"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["packageMetadata.version"],"sources":["../package.json","../src/types.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\" with { type: \"json\" };\nimport type { GeneratedPaymentResult } from \"./generated/public-contract-types.ts\";\n\nexport type LockerversePaymentOption =\n | \"one-time\"\n | \"monthly\"\n | \"annually\"\n | \"every-six-months\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\nexport type LockerverseFulfillmentType = \"none\" | \"event_admission\";\n\nexport const LOCKERVERSE_SDK_VERSION = packageMetadata.version;\n\nexport type LockerverseProduct = {\n id: string;\n listingId: string;\n slug: string;\n name: string;\n description: string | null;\n fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n amountCents: number | null;\n minimumAmountCents: number | null;\n minimumQuantity: number | null;\n /** Per-order limit for this widget listing. Null means no per-order limit. */\n maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseAvailabilityStatus = \"available\" | \"sold_out\";\n\nexport type LockerverseCatalogAvailability = {\n listings: Array<{\n listingId: string;\n maxPurchasableQuantity: number | null;\n remainingQuantity: number | null;\n status: LockerverseAvailabilityStatus;\n }>;\n sharedLimits: Array<{\n id: string;\n listingIds: string[];\n listingWeights?: Record<string, number>;\n remainingQuantity: number;\n status: LockerverseAvailabilityStatus;\n }>;\n};\n\nexport type LockerverseCatalog = {\n availability: LockerverseCatalogAvailability;\n community: LockerverseCommunityBranding | null;\n event: LockerverseEvent | null;\n payment: LockerversePaymentConfiguration;\n pricingPolicy: LockerverseCheckoutPricingPolicy;\n products: LockerverseProduct[];\n widget: LockerverseWidgetConfiguration;\n};\n\nexport type LockerverseEvent = {\n description: string | null;\n endAt: string;\n id: string;\n location: string | null;\n name: string;\n startAt: string;\n status: \"draft\" | \"active\" | \"finished\" | \"cancelled\";\n};\n\nexport type LockerverseCommunityBranding = {\n widgetAchEnabled?: boolean | undefined;\n accentColor: string;\n imageUrl: string | null;\n memberIdLabel?: string | null | undefined;\n name: string;\n};\n\nexport type LockerverseCheckoutPricingPolicy = {\n currency: \"usd\";\n serviceFeeRateBasisPoints: number;\n};\n\nexport type LockerversePaymentConfiguration = {\n connectedAccountId: string | null;\n currency: \"usd\";\n publishableKey: string;\n};\n\nexport type LockerverseWidgetFields = {\n memberId: boolean;\n merchSize: boolean;\n phone: boolean;\n promoCode: boolean;\n serviceFee: boolean;\n shipping: boolean;\n tipping: boolean;\n};\n\nexport type LockerverseCustomFieldOption = { id: string; label: string };\n\ntype LockerverseCustomFieldBase = {\n id: string;\n label: string;\n paymentOptionIds?: string[] | undefined;\n required: boolean;\n};\n\nexport type LockerverseTextCustomField = LockerverseCustomFieldBase & {\n type: \"text\" | \"textarea\";\n};\n\nexport type LockerverseBooleanCustomField = LockerverseCustomFieldBase & {\n type: \"checkbox\";\n};\n\nexport type LockerverseSingleOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"radio\" | \"select\";\n};\n\nexport type LockerverseMultiOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"checkboxes\" | \"multi_select\";\n};\n\nexport type LockerverseCustomField =\n | LockerverseBooleanCustomField\n | LockerverseTextCustomField\n | LockerverseSingleOptionCustomField\n | LockerverseMultiOptionCustomField;\n\nexport type LockerverseCustomFieldAnswerValue<\n Field extends LockerverseCustomField,\n> = Field extends LockerverseBooleanCustomField\n ? boolean\n : Field extends LockerverseMultiOptionCustomField\n ? string[]\n : string;\n\nexport type LockerverseCustomFieldAnswer<\n Field extends LockerverseCustomField = LockerverseCustomField,\n> = Field extends LockerverseCustomField\n ? { fieldId: Field[\"id\"]; value: LockerverseCustomFieldAnswerValue<Field> }\n : never;\n\nexport type LockerverseWidgetConfiguration = {\n requiredShipping?:\n | {\n additionalUnitAmountCents?: number | undefined;\n productId: string;\n triggerProductIds: string[];\n }\n | undefined;\n customFields: LockerverseCustomField[];\n description: string | null;\n fields: LockerverseWidgetFields;\n id: string;\n name: string;\n showCommunityBranding: boolean;\n title: string | null;\n};\n\nexport type LockerverseSdkErrorCode =\n | \"booking_request_failed\"\n | \"public_events_load_failed\"\n | \"auction_load_failed\"\n | \"auction_bid_failed\"\n | \"auction_purchase_failed\"\n | \"auction_purchase_status_failed\"\n | \"auction_receipt_failed\"\n | \"widget_load_failed\"\n | \"signup_load_failed\"\n | \"signup_submit_failed\"\n | \"total_calculation_failed\"\n | \"payment_submit_failed\"\n | \"payment_status_failed\"\n | \"invalid_selection\";\n\nexport type LockerverseSdkOperation =\n | \"load_booking_configuration\"\n | \"create_booking_session\"\n | \"find_booking_availability\"\n | \"initialize_booking\"\n | \"confirm_booking\"\n | \"recover_booking\"\n | \"list_public_events\"\n | \"list_auctions\"\n | \"load_auction\"\n | \"create_auction_bid\"\n | \"create_auction_purchase\"\n | \"get_auction_purchase_receipt\"\n | \"get_auction_purchase_status\"\n | \"load_widget\"\n | \"load_signup\"\n | \"submit_signup\"\n | \"calculate_total\"\n | \"submit_payment\"\n | \"get_payment_status\";\n\nexport type LockerverseSdkServerCode =\n | \"PAYMENT_WIDGET_SALES_LIMIT_REACHED\"\n | \"PAYMENT_WIDGET_PHONE_INVALID\"\n | \"PAYMENT_WIDGET_PHONE_REQUIRED\"\n | \"SIGN_UP_WIDGET_PHONE_INVALID\"\n | \"SIGN_UP_WIDGET_PHONE_REQUIRED\";\n\nexport type LockerverseSdkFailureKind =\n | \"network\"\n | \"timeout\"\n | \"aborted\"\n | \"invalid_response\";\n\nexport class LockerverseSdkError extends Error {\n readonly failureKind: LockerverseSdkFailureKind | undefined;\n readonly code: LockerverseSdkErrorCode;\n readonly operation: LockerverseSdkOperation;\n readonly reportable: boolean;\n readonly recoveryRecommended: boolean;\n readonly sdkVersion: string;\n readonly serverCode: LockerverseSdkServerCode | undefined;\n readonly status: number | undefined;\n\n constructor({\n failureKind,\n code,\n message,\n operation,\n reportable,\n recoveryRecommended = false,\n serverCode,\n status,\n }: {\n failureKind?: LockerverseSdkFailureKind | undefined;\n code: LockerverseSdkErrorCode;\n message: string;\n operation: LockerverseSdkOperation;\n reportable: boolean;\n recoveryRecommended?: boolean;\n serverCode?: LockerverseSdkServerCode;\n status?: number | undefined;\n }) {\n super(message);\n this.name = \"LockerverseSdkError\";\n this.failureKind = failureKind;\n this.code = code;\n this.operation = operation;\n this.reportable = reportable;\n this.recoveryRecommended = recoveryRecommended;\n this.sdkVersion = LOCKERVERSE_SDK_VERSION;\n this.serverCode = serverCode;\n this.status = status;\n }\n}\n\nexport type LockerverseCheckoutLineItem = {\n productId: string;\n productName: string;\n listingId: string;\n listingSlug: string;\n acceptsDiscounts: boolean;\n eventId: string | null;\n fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n quantity: number;\n unitAmountCents: number;\n subtotalCents: number;\n};\n\nexport type LockerverseAppliedDiscount = {\n percentageOff?: number | undefined;\n amountOffCents?: number | undefined;\n message?: string | undefined;\n source: \"email_list\" | \"promo_code\";\n};\n\nexport type LockerverseCheckoutAmounts = {\n amountCents: number;\n discountableSubtotalCents: number;\n discountCents: number;\n serviceFeeCents: number;\n subtotalCents: number;\n tipCents: number;\n totalCents: number;\n};\n\nexport type LockerverseCheckoutQuote = LockerverseCheckoutAmounts & {\n appliedDiscount: LockerverseAppliedDiscount | null;\n authoritative: true;\n paymentReference: string;\n payment: LockerversePaymentConfiguration;\n paymentOption: LockerversePaymentOption;\n lineItems: LockerverseCheckoutLineItem[];\n};\n\nexport type LockerverseCheckoutEstimate = LockerverseCheckoutAmounts & {\n appliedDiscount: null;\n authoritative: false;\n items: readonly LockerverseCheckoutItem[];\n lineItems: readonly LockerverseCheckoutLineItem[];\n paymentOption: LockerversePaymentOption;\n};\n\nexport type LockerverseCheckoutPricingInput = {\n email?: string;\n includeServiceFee?: boolean;\n promoCode?: string;\n tipCents?: number;\n};\n\nexport type LockerversePaymentStatus =\n | \"action_required\"\n | \"failed\"\n | \"pending\"\n | \"success\";\n\nexport type LockerversePaymentResult = {\n checkoutId: string;\n paymentReference: string;\n checkoutStatus: LockerversePaymentStatus;\n retryUrl?: string | undefined;\n clientSecret: string | null;\n paymentRequired: boolean;\n requiresAction: boolean;\n status: string | null;\n};\n\nexport type LockerversePaymentCompletion = LockerversePaymentResult & {\n email: string | null;\n lineItems: readonly LockerverseCheckoutLineItem[] | null;\n};\n\ntype AssertPaymentContract<T extends true> = T;\ntype _PaymentResultMatchesGenerated = AssertPaymentContract<\n LockerversePaymentResult extends GeneratedPaymentResult\n ? GeneratedPaymentResult extends LockerversePaymentResult\n ? true\n : false\n : false\n>;\n\nexport type LockerverseShipping = {\n address: {\n city: string;\n country: string;\n line1: string;\n line2?: string;\n postal_code: string;\n state: string;\n };\n name: string;\n};\n\nexport type LockerversePaymentSubmission = {\n confirmationToken?: string;\n paymentMethodConfiguration?: \"explicit\";\n customFieldAnswers?: LockerverseCustomFieldAnswer[];\n email: string;\n memberId?: string;\n merchSize?: \"XS\" | \"S\" | \"M\" | \"L\" | \"XL\" | \"XXL\" | \"XXXL\";\n metadata?: Record<string, string>;\n phone?: string;\n shipping?: LockerverseShipping;\n};\n\nexport type LockerverseCheckoutItem =\n | { productId: string; quantity: number }\n | { productId: string; amountCents: number }\n | { productId: string };\n\nexport type LockerverseCheckoutSelectionItem =\n | { productSlug: string; quantity: number }\n | { productSlug: string; amountCents: number }\n | { productSlug: string };\n\nexport type LockerverseEstimateCheckoutInput =\n LockerverseCheckoutPricingInput & {\n selection: LockerverseCheckoutSelectionItem[];\n };\n\nexport type LockerverseLoadCheckoutInput = {\n selection: LockerverseCheckoutSelectionItem[];\n};\n\nexport type LockerverseCalculateTotalInput = LockerverseCheckoutPricingInput & {\n catalog: LockerverseCatalog;\n} & (\n | {\n items: LockerverseCheckoutItem[];\n selection?: never;\n }\n | {\n items?: never;\n selection: LockerverseCheckoutSelectionItem[];\n }\n );\n\nexport type LockerversePreparedCheckout = Readonly<\n LockerverseCheckoutQuote & {\n items: readonly LockerverseCheckoutItem[];\n pricing: Readonly<LockerverseCheckoutPricingInput>;\n }\n>;\n\nexport type LockerverseLoadedCheckout = Readonly<{\n catalog: LockerverseCatalog;\n checkout: LockerversePreparedCheckout;\n}>;\n\nexport type LockerverseSubmitPaymentInput = {\n checkout: LockerversePreparedCheckout;\n submission: LockerversePaymentSubmission;\n};\n\ntype CreateLockerverseWidgetBaseOptions = {\n communitySlug: string;\n fetch?: typeof globalThis.fetch;\n onError?: (error: LockerverseSdkError) => void;\n requestTimeoutMs?: number;\n sentryDsn?: string | null;\n widgetSlug: string;\n};\n\nexport type LockerverseResourceEnvironmentOptions =\n | {\n apiBaseUrl: string;\n environment: LockerverseEnvironment;\n }\n | {\n apiBaseUrl?: undefined;\n environment?: \"production\";\n };\n\nexport type CreateLockerverseWidgetOptions =\n CreateLockerverseWidgetBaseOptions & LockerverseResourceEnvironmentOptions;\n\nexport type LockerverseCheckoutClient = {\n calculateTotal: (\n input: LockerverseCalculateTotalInput\n ) => Promise<LockerversePreparedCheckout>;\n getPaymentStatus: (\n paymentReference: string\n ) => Promise<LockerversePaymentResult>;\n load: {\n (): Promise<LockerverseCatalog>;\n (input: LockerverseLoadCheckoutInput): Promise<LockerverseLoadedCheckout>;\n };\n submitPayment: (\n input: LockerverseSubmitPaymentInput\n ) => Promise<LockerversePaymentResult>;\n};\n"],"mappings":"ACWA,MAAa,EAA0BA,gBAyMvC,IAAa,EAAb,cAAyC,KAAM,CAC7C,YACA,KACA,UACA,WACA,oBACA,WACA,WACA,OAEA,YAAY,CACV,cACA,OACA,UACA,YACA,aACA,sBAAsB,GACtB,aACA,UAUC,CACD,MAAM,CAAO,EACb,KAAK,KAAO,sBACZ,KAAK,YAAc,EACnB,KAAK,KAAO,EACZ,KAAK,UAAY,EACjB,KAAK,WAAa,EAClB,KAAK,oBAAsB,EAC3B,KAAK,WAAa,EAClB,KAAK,WAAa,EAClB,KAAK,OAAS,CAChB,CACF"}
|