@lockerverse/sdk 0.2.190-dev.1 → 0.2.191
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 +22 -76
- package/README.md +11 -0
- package/dist/auctions.d.ts +18 -2
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +1 -1
- package/dist/auctions.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
|
@@ -36,7 +36,25 @@ If it cannot be found, report that limit and use the baseline review below. Do n
|
|
|
36
36
|
claim that every historical migration was applied. Read this file even if the
|
|
37
37
|
version already matches: a previous upgrade may have missed host adoption steps.
|
|
38
38
|
|
|
39
|
-
## 0.2.
|
|
39
|
+
## 0.2.191 — auction item additional charges
|
|
40
|
+
|
|
41
|
+
- **Affected:** Core auction item data, purchase quotes, and React auction checkout.
|
|
42
|
+
- **Automatic:** optional `additionalCharge` charges the first-item amount plus the
|
|
43
|
+
additional-item amount for each further unit. Checkout and receipts show the configured charge
|
|
44
|
+
separately. Bids use one unit and add the first-unit charge only if the bid wins.
|
|
45
|
+
The bid amount and minimum increments remain unchanged. `maxQuantityPerOrder` limits each order; null inventory remains unlimited.
|
|
46
|
+
- **Required:** deploy the matching auction backend before enabling additional charges.
|
|
47
|
+
Upgrade Core and React together. Custom purchase forms must obtain `getPurchaseQuote`,
|
|
48
|
+
display the charge, and submit `expectedAdditionalChargeCents` with `expectedTotalCents`.
|
|
49
|
+
Custom bid forms must disclose the first-unit charge and submit the same expected
|
|
50
|
+
charge and total fields. Winner settlement uses the charge saved with the bid.
|
|
51
|
+
Service fees continue to use merchandise subtotal only. Existing items need no edits.
|
|
52
|
+
- **Optional:** set `--lockerverse-auction-catalog-columns` on the auction style to
|
|
53
|
+
choose desktop grid columns. Mobile retains one column.
|
|
54
|
+
- **Check:** compare one, two, and maximum quantity totals with the server quote,
|
|
55
|
+
verify the per-order limit, and inspect the named charge row before payment.
|
|
56
|
+
|
|
57
|
+
## 0.2.189 — widget load recovery and Sentry releases
|
|
40
58
|
|
|
41
59
|
- **Affected:** Core widget loading and SDK failure reporting.
|
|
42
60
|
- **Automatic:** a widget GET retries once after a network failure or request
|
|
@@ -63,7 +81,6 @@ version already matches: a previous upgrade may have missed host adoption steps.
|
|
|
63
81
|
- **Check:** select one, two, and the maximum allowed trigger quantity. Confirm the
|
|
64
82
|
local summary and server quote agree; removing all trigger items removes shipping.
|
|
65
83
|
|
|
66
|
-
|
|
67
84
|
## 0.2.184 — single focus boundary for form fields
|
|
68
85
|
|
|
69
86
|
- **Affected:** React form controls and the shared phone field in payment and signup.
|
|
@@ -83,7 +100,7 @@ Widgets can now use a private contact list for email eligibility, a fixed amount
|
|
|
83
100
|
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.
|
|
84
101
|
|
|
85
102
|
|
|
86
|
-
## 0.2.
|
|
103
|
+
## 0.2.177 — Secure checkout loading recovery
|
|
87
104
|
|
|
88
105
|
- **Affected:** React payment widget Stripe fields.
|
|
89
106
|
- **Automatic:** failed field or script loads show a reload action. Fields that
|
|
@@ -95,22 +112,8 @@ Required shipping appears in `catalog.widget.requiredShipping`. Do not offer thi
|
|
|
95
112
|
- Reload is an explicit customer action and can clear unsaved form entries.
|
|
96
113
|
Saved payment recovery remains in session storage.
|
|
97
114
|
|
|
98
|
-
## 0.2.175 — Match Stripe Elements payment method configuration
|
|
99
|
-
|
|
100
|
-
- **Affected:** Core checkout submission and React payment widgets.
|
|
101
|
-
- **Automatic:** React configures explicit card, Link, and community-enabled bank
|
|
102
|
-
methods in Stripe Elements and marks the confirmation request with
|
|
103
|
-
`paymentMethodConfiguration: "explicit"`. This matches the backend's Stripe
|
|
104
|
-
PaymentIntent configuration.
|
|
105
|
-
- **Required:** deploy the backend that supports this optional marker before
|
|
106
|
-
upgrading React. Keep Core and React matched. Existing Core-only callers omit
|
|
107
|
-
the marker and retain automatic payment methods. Custom Elements integrations
|
|
108
|
-
must send the marker only when they use the explicit method list.
|
|
109
|
-
- **Check:** submit card and bank payments through Stripe Elements in test mode,
|
|
110
|
-
including recurring checkout. Confirm pending recovery and settlement.
|
|
111
|
-
|
|
112
115
|
|
|
113
|
-
## 0.2.
|
|
116
|
+
## 0.2.175 — Match Stripe Elements payment method configuration
|
|
114
117
|
|
|
115
118
|
- **Affected:** Core checkout submission and React payment widgets.
|
|
116
119
|
- **Automatic:** React configures explicit card, Link, and community-enabled bank
|
|
@@ -185,39 +188,7 @@ Required shipping appears in `catalog.widget.requiredShipping`. Do not offer thi
|
|
|
185
188
|
verify a changed selection cannot discard it. Check both paid and free order
|
|
186
189
|
confirmation panels. Do not submit a live transaction for this check.
|
|
187
190
|
|
|
188
|
-
## 0.2.
|
|
189
|
-
|
|
190
|
-
- **Affected:** React payment widgets with unresolved payments.
|
|
191
|
-
- **Automatic behavior:** the existing pending-payment screen now offers Check
|
|
192
|
-
payment status. It checks the saved payment reference and cannot submit a new
|
|
193
|
-
payment. The control is disabled while the check runs.
|
|
194
|
-
- **Required host changes:** none. Update Core and React together.
|
|
195
|
-
- **Verification:** complete a test bank payment, return to its pending checkout,
|
|
196
|
-
and check its status. Confirm completion clears recovery storage.
|
|
197
|
-
|
|
198
|
-
## 0.2.171-dev.1 — SDK payment recovery and completion UI
|
|
199
|
-
|
|
200
|
-
- **Affected:** React payment widgets and custom hosts that persist payment recovery.
|
|
201
|
-
- **Optional adoption:** pass `recoveryStorageKey` to `LockerversePayment` to let
|
|
202
|
-
the SDK save and restore the pending payment in session storage. Use a stable
|
|
203
|
-
key scoped to the API environment, community, and widget. Remove the host's
|
|
204
|
-
storage code and recovery-driven component key. Do not combine automatic
|
|
205
|
-
persistence with a second host persistence writer.
|
|
206
|
-
- **Compatibility:** the SDK reads the hosted Next app's existing version 1
|
|
207
|
-
records when the same key is used. It writes version 2 records with widget
|
|
208
|
-
identity. It checks widget and selection identity before recovery and keeps
|
|
209
|
-
an unresolved record if those details differ. Recovery uses the saved connected
|
|
210
|
-
account even if current payment routing has changed. Storage is read after hydration,
|
|
211
|
-
before the payable form mounts. No contact details or payment tokens are saved.
|
|
212
|
-
- **Optional UI adoption:** use `completionView="summary"` for the SDK confirmation
|
|
213
|
-
panel and remove the host's duplicate success panel. Completion callbacks still
|
|
214
|
-
run. The default inline message and explicit `resumePayment` integrations remain
|
|
215
|
-
supported. Auctions and legacy custom checkout forms are unchanged.
|
|
216
|
-
- **Check:** reload a pending checkout and confirm the existing payment is checked;
|
|
217
|
-
verify a changed selection cannot discard it. Check both paid and free order
|
|
218
|
-
confirmation panels. Do not submit a live transaction for this check.
|
|
219
|
-
|
|
220
|
-
## 0.2.169-dev.1 — six-month payment widgets
|
|
191
|
+
## 0.2.170 — six-month payment widgets
|
|
221
192
|
|
|
222
193
|
Affected: @lockerverse/sdk checkout and @lockerverse/react payment widgets.
|
|
223
194
|
|
|
@@ -233,31 +204,6 @@ Affected: @lockerverse/sdk checkout and @lockerverse/react payment widgets.
|
|
|
233
204
|
submission. Do not submit a live payment for an integration check.
|
|
234
205
|
|
|
235
206
|
|
|
236
|
-
## 0.2.168-dev.1 — bank authorization terms
|
|
237
|
-
|
|
238
|
-
- **Affected:** React payment widgets with ACH enabled.
|
|
239
|
-
- **Automatic:** Stripe displays its bank authorization terms before payment confirmation.
|
|
240
|
-
- **Adoption:** update the matching SDK/React development pair. No prop changes are required.
|
|
241
|
-
- **Check:** confirm that the bank authorization text is visible when a bank account is selected.
|
|
242
|
-
|
|
243
|
-
## 0.2.167-dev.1 — widget ACH and subscription payment recovery
|
|
244
|
-
|
|
245
|
-
- **Affected:** Core checkout data and React payment widgets.
|
|
246
|
-
- **Automatic:** bank payment availability follows the organization default and
|
|
247
|
-
community override returned by the backend. Missing policy remains disabled.
|
|
248
|
-
Pending payments keep their existing payment reference. A failed subscription
|
|
249
|
-
invoice can return `action_required` with `requiresAction: false` and `retryUrl`;
|
|
250
|
-
React shows a link to pay the same invoice instead of creating a second subscription.
|
|
251
|
-
- **Required for custom payment UI:** preserve the reference for pending and
|
|
252
|
-
action-required results. Handle `retryUrl` by opening that invoice, and recover
|
|
253
|
-
status before permitting a new checkout. Do not treat submission as settlement.
|
|
254
|
-
- **Adoption:** deploy the matching backend policy and recovery contract before
|
|
255
|
-
enabling ACH. Existing React hosts need no component prop changes. Keep Core and
|
|
256
|
-
React versions matched when upgrading. Auction payment methods are unchanged.
|
|
257
|
-
- **Check:** verify disabled/inherited/enabled bank visibility and pending, bank
|
|
258
|
-
verification, invoice retry, success, and terminal failure in Stripe test mode.
|
|
259
|
-
Do not create a live transaction for this check.
|
|
260
|
-
|
|
261
207
|
## 0.2.166 — single dropdown arrow
|
|
262
208
|
|
|
263
209
|
- **Affected:** native single-select custom fields in React signup and payment forms.
|
package/README.md
CHANGED
|
@@ -300,6 +300,17 @@ Amounts are integer USD cents. Send the expected subtotal, service fee, and tota
|
|
|
300
300
|
that the customer accepted. Handle `requiresAction` with Stripe
|
|
301
301
|
`handleNextAction` and the returned `clientSecret`.
|
|
302
302
|
|
|
303
|
+
- Auction and Buy Now items can define `additionalCharge` with a name, category, first-unit
|
|
304
|
+
amount, and additional-unit amount. For Buy Now items call
|
|
305
|
+
`getPurchaseQuote(auctionSlug, itemId, { quantity, includeServiceFee })` and show
|
|
306
|
+
its named charge and total before payment. Send `expectedAdditionalChargeCents`
|
|
307
|
+
and `expectedTotalCents` with the purchase. Merchandise subtotal excludes the
|
|
308
|
+
charge, and service fees apply to merchandise only. Receipts retain the charge
|
|
309
|
+
name and rule at purchase time. The category does not enable address collection;
|
|
310
|
+
use `collectShippingAddress` for that. Respect `maxQuantityPerOrder` when set;
|
|
311
|
+
null `inventoryQuantity` means unlimited stock. Bids use the first-unit charge
|
|
312
|
+
only, payable when the bid wins. Disclose that charge and submit
|
|
313
|
+
`expectedAdditionalChargeCents` and `expectedTotalCents` with the bid.
|
|
303
314
|
- Never automatically retry a bid. The backend does not deduplicate bids and
|
|
304
315
|
has no public bid-status recovery endpoint. An unknown result needs support
|
|
305
316
|
follow-up; a submitted bid is not a winning bid or a payment receipt.
|
package/dist/auctions.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { B as LockerverseSdkErrorCode, C as LockerverseEnvironment, H as Lockerv
|
|
|
3
3
|
type LockerverseAuctionStatus = "draft" | "active" | "finished";
|
|
4
4
|
type LockerverseAuctionSaleMode = "auction" | "buy_now" | "hybrid";
|
|
5
5
|
type LockerverseAuctionPurchaseStatus = "pending_payment" | "paid" | "payment_failed" | "expired" | "canceled" | "refunded";
|
|
6
|
+
type LockerverseAuctionAdditionalCharge = {
|
|
7
|
+
name: string;
|
|
8
|
+
category: "shipping" | "handling" | "other";
|
|
9
|
+
firstUnitAmountCents: number;
|
|
10
|
+
additionalUnitAmountCents: number;
|
|
11
|
+
};
|
|
6
12
|
type LockerverseAuctionItem = {
|
|
7
13
|
id: string;
|
|
8
14
|
name: string;
|
|
@@ -19,6 +25,8 @@ type LockerverseAuctionItem = {
|
|
|
19
25
|
saleMode: LockerverseAuctionSaleMode;
|
|
20
26
|
buyNowPriceAmount: number | null;
|
|
21
27
|
inventoryQuantity: number | null;
|
|
28
|
+
maxQuantityPerOrder?: number | null | undefined;
|
|
29
|
+
additionalCharge?: LockerverseAuctionAdditionalCharge | null | undefined;
|
|
22
30
|
availableQuantity: number | null;
|
|
23
31
|
paidQuantity: number;
|
|
24
32
|
reservedQuantity: number;
|
|
@@ -75,6 +83,9 @@ type LockerverseAuction = {
|
|
|
75
83
|
items: LockerverseAuctionItem[];
|
|
76
84
|
};
|
|
77
85
|
type LockerverseAuctionPricing = {
|
|
86
|
+
/** Omitted by older servers and bid-only integrations. */
|
|
87
|
+
additionalChargeCents?: number;
|
|
88
|
+
additionalCharge?: LockerverseAuctionAdditionalCharge | null | undefined;
|
|
78
89
|
subtotalCents: number;
|
|
79
90
|
serviceFeeCents: number;
|
|
80
91
|
serviceFeeRateBasisPoints: number;
|
|
@@ -89,6 +100,7 @@ type LockerverseAuctionBidSubmission = {
|
|
|
89
100
|
includeServiceFee?: boolean;
|
|
90
101
|
expectedSubtotalCents?: number;
|
|
91
102
|
expectedServiceFeeCents?: number;
|
|
103
|
+
expectedAdditionalChargeCents?: number;
|
|
92
104
|
expectedTotalCents?: number;
|
|
93
105
|
};
|
|
94
106
|
type LockerverseAuctionPurchaseSubmission = Omit<LockerverseAuctionBidSubmission, "amount"> & {
|
|
@@ -133,6 +145,10 @@ type LockerverseAuctionClient = {
|
|
|
133
145
|
load: (auctionSlug: string, options?: LockerverseAuctionLoadOptions) => Promise<LockerverseAuction>;
|
|
134
146
|
/** Never retry a bid automatically: the server does not deduplicate bids. */
|
|
135
147
|
createBid: (auctionSlug: string, itemId: string, submission: LockerverseAuctionBidSubmission) => Promise<LockerverseAuctionBidResult>;
|
|
148
|
+
getPurchaseQuote: (auctionSlug: string, itemId: string, selection: {
|
|
149
|
+
quantity: number;
|
|
150
|
+
includeServiceFee?: boolean;
|
|
151
|
+
}) => Promise<LockerverseAuctionPricing>;
|
|
136
152
|
createPurchase: (auctionSlug: string, itemId: string, submission: LockerverseAuctionPurchaseSubmission) => Promise<LockerverseAuctionPurchaseResult>;
|
|
137
153
|
/** Read the existing purchase without creating or retrying a payment. */
|
|
138
154
|
getPurchaseStatus: (auctionSlug: string, itemId: string, clientRequestId: string) => Promise<LockerverseAuctionPurchaseResult | null>;
|
|
@@ -144,9 +160,9 @@ declare function createLockerverseAuctionClient(options: CreateLockerverseAuctio
|
|
|
144
160
|
//#endregion
|
|
145
161
|
//#region src/auction-pricing.d.ts
|
|
146
162
|
/** Local estimate. Send expected amounts with the submission for server validation. */
|
|
147
|
-
declare function calculateLockerverseAuctionPricing(auction: Pick<LockerverseAuction, "serviceFeeEnabled" | "pricingPolicy">, subtotalCents: number, includeServiceFee?: boolean): LockerverseAuctionPricing;
|
|
163
|
+
declare function calculateLockerverseAuctionPricing(auction: Pick<LockerverseAuction, "serviceFeeEnabled" | "pricingPolicy">, subtotalCents: number, includeServiceFee?: boolean, additionalChargeCents?: number): LockerverseAuctionPricing;
|
|
148
164
|
/** Snapshot estimate. Another accepted bid can increase the server minimum. */
|
|
149
165
|
declare function getLockerverseAuctionMinimumBid(item: Pick<LockerverseAuctionItem, "minBidAmount" | "bidIncrementAmount" | "maxBidAmount">): number;
|
|
150
166
|
//#endregion
|
|
151
|
-
export { type CreateLockerverseAuctionOptions, type LockerverseAuction, type LockerverseAuctionBidResult, type LockerverseAuctionBidSubmission, type LockerverseAuctionClient, type LockerverseAuctionItem, type LockerverseAuctionLoadOptions, type LockerverseAuctionPricing, type LockerverseAuctionPurchaseReceipt, type LockerverseAuctionPurchaseResult, type LockerverseAuctionPurchaseStatus, type LockerverseAuctionPurchaseSubmission, type LockerverseAuctionSaleMode, type LockerverseAuctionStatus, type LockerverseEnvironment, LockerverseSdkError, type LockerverseSdkErrorCode, type LockerverseSdkOperation, type LockerverseSdkServerCode, calculateLockerverseAuctionPricing, createLockerverseAuctionClient, getLockerverseAuctionMinimumBid };
|
|
167
|
+
export { type CreateLockerverseAuctionOptions, type LockerverseAuction, type LockerverseAuctionAdditionalCharge, type LockerverseAuctionBidResult, type LockerverseAuctionBidSubmission, type LockerverseAuctionClient, type LockerverseAuctionItem, type LockerverseAuctionLoadOptions, type LockerverseAuctionPricing, type LockerverseAuctionPurchaseReceipt, type LockerverseAuctionPurchaseResult, type LockerverseAuctionPurchaseStatus, type LockerverseAuctionPurchaseSubmission, type LockerverseAuctionSaleMode, type LockerverseAuctionStatus, type LockerverseEnvironment, LockerverseSdkError, type LockerverseSdkErrorCode, type LockerverseSdkOperation, type LockerverseSdkServerCode, calculateLockerverseAuctionPricing, createLockerverseAuctionClient, getLockerverseAuctionMinimumBid };
|
|
152
168
|
//# sourceMappingURL=auctions.d.ts.map
|
package/dist/auctions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctions.d.ts","names":[],"sources":["../src/auction-types.ts","../src/auction-client.ts","../src/auction-pricing.ts"],"mappings":";;KAMY;KACA;KACA;KAOA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EACA;EACA;;KAEU;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;EACA;EACA;EACA;IAAiB;IAAiB;;EAClC,UAAU;EACV;IAGM;IACA;IACA;IACA;;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR,OAAO;;KAEG;
|
|
1
|
+
{"version":3,"file":"auctions.d.ts","names":[],"sources":["../src/auction-types.ts","../src/auction-client.ts","../src/auction-pricing.ts"],"mappings":";;KAMY;KACA;KACA;KAOA;EACV;EACA;EACA;EACA;;KAEU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA,mBAAmB;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EACA;EACA;;KAEU;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;EACA;EACA;EACA;IAAiB;IAAiB;;EAClC,UAAU;EACV;IAGM;IACA;IACA;IACA;;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR,OAAO;;KAEG;;EAEV;EACA,mBAAmB;EACnB;EACA;EACA;EACA;;KAEU;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAEU,uCAAuC,KACjD;;EAIA;EACA;;EAEA;;KAEU,8BAA8B;EACxC;EACA;;KAEU,mCAAmC;EAC7C;EACA;EACA,QAAQ;EACR;EACA;;;KAGU,oCAAoC;EAC9C;EACA;EACA;;KAEU,kCACV;EACE;;EAEA;EACA,eAAe,WAAW;EAC1B,WAAW,OAAO;EAClB;EACA;;KAEQ;;EAEV;;KAEU;EACV,YAAY,QAAQ;EACpB,OACE,qBACA,UAAU,kCACP,QAAQ;;EAEb,YACE,qBACA,gBACA,YAAY,oCACT,QAAQ;EACb,mBACE,qBACA,gBACA;IAAa;IAAkB;QAC5B,QAAQ;EACb,iBACE,qBACA,gBACA,YAAY,yCACT,QAAQ;;EAEb,oBACE,qBACA,gBACA,4BACG,QAAQ;EACb,qBACE,qBACA,kBACA,uBACG,QAAQ;;;;iBClIC,+BACd,SAAS,kCACR;;;;iBC7Ca,mCACd,SAAS,KAAK,4DACd,uBACA,6BACA,iCACC;;iBA6Ba,gCACd,MAAM,KACJ"}
|
package/dist/auctions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./schema-helpers.js";import{i as t,n,o as r,r as i,t as a}from"./transport.js";import{n as o}from"./types.js";import{array as s,boolean as c,check as l,email as u,isoTimestamp as d,literal as f,minLength as p,minValue as m,nullable as h,object as g,optional as _,parse as v,picklist as y,pipe as b,regex as x,strictTuple as S,string as C}from"valibot";function w(e,t){if(t===void 0)return e;e.mediaBaseUrl=t;let n=e=>e?.startsWith(`https://media.lockerverse.com/`)?`${t}/${e.slice(30)}`:e;e.configuration.image=n(e.configuration.image),e.community&&(e.community.banner=n(e.community.banner),e.community.thumbnail=n(e.community.thumbnail));for(let t of e.items)t.image=n(t.image),t.images=t.images.map(n);return e}const T=b(C(),p(1)),E=e(0),D=b(C(),d()),O=y([`draft`,`active`,`finished`]),k=g({auctionId:T,availableQuantity:h(E),bidCount:E,bidIncrementAmount:h(E),buyNowPriceAmount:h(E),collectShippingAddress:c(),communityId:T,createdAt:D,description:h(C()),endAt:_(h(D)),finalizedBidCount:E,finishedAt:_(h(D)),id:T,image:h(C()),images:s(C()),inventoryQuantity:h(E),isSoldOut:c(),maxBidAmount:h(E),minBidAmount:h(E),name:C(),paidQuantity:E,path:T,position:E,reservedQuantity:E,saleMode:y([`auction`,`buy_now`,`hybrid`]),slug:T,startAt:_(h(D)),status:O,updatedAt:D}),
|
|
1
|
+
import{a as e}from"./schema-helpers.js";import{i as t,n,o as r,r as i,t as a}from"./transport.js";import{n as o}from"./types.js";import{array as s,boolean as c,check as l,email as u,isoTimestamp as d,literal as f,minLength as p,minValue as m,nullable as h,object as g,optional as _,parse as v,picklist as y,pipe as b,regex as x,strictTuple as S,string as C}from"valibot";function w(e,t){if(t===void 0)return e;e.mediaBaseUrl=t;let n=e=>e?.startsWith(`https://media.lockerverse.com/`)?`${t}/${e.slice(30)}`:e;e.configuration.image=n(e.configuration.image),e.community&&(e.community.banner=n(e.community.banner),e.community.thumbnail=n(e.community.thumbnail));for(let t of e.items)t.image=n(t.image),t.images=t.images.map(n);return e}const T=b(C(),p(1)),E=e(0),D=b(C(),d()),O=y([`draft`,`active`,`finished`]),k=g({additionalUnitAmountCents:E,category:y([`shipping`,`handling`,`other`]),firstUnitAmountCents:E,name:T}),A=g({additionalCharge:_(h(k)),auctionId:T,availableQuantity:h(E),bidCount:E,bidIncrementAmount:h(E),buyNowPriceAmount:h(E),collectShippingAddress:c(),communityId:T,createdAt:D,description:h(C()),endAt:_(h(D)),finalizedBidCount:E,finishedAt:_(h(D)),id:T,image:h(C()),images:s(C()),inventoryQuantity:h(E),isSoldOut:c(),maxBidAmount:h(E),maxQuantityPerOrder:_(h(b(E,m(1)))),minBidAmount:h(E),name:C(),paidQuantity:E,path:T,position:E,reservedQuantity:E,saleMode:y([`auction`,`buy_now`,`hybrid`]),slug:T,startAt:_(h(D)),status:O,updatedAt:D}),j=g({collectShippingAddress:c(),community:_(g({banner:_(h(C())),color:_(h(C())),name:_(C()),thumbnail:_(h(C()))})),communityId:T,configuration:g({collectShippingAddress:c(),endTimeEnabled:_(h(c())),image:h(C()),serviceFeeDefaultChecked:c(),serviceFeeEnabled:c(),startTimeEnabled:_(h(c()))}),createdAt:D,description:h(C()),endAt:D,id:T,items:s(A),name:C(),path:T,payment:_(g({connectedAccountId:h(T),currency:f(`usd`),publishableKey:T})),position:E,pricingPolicy:g({currency:f(`usd`),serviceFeeRateBasisPoints:E}),serviceFeeDefaultChecked:c(),serviceFeeEnabled:c(),slug:T,startAt:D,status:O,updatedAt:D}),M={additionalCharge:_(h(k)),additionalChargeCents:_(E,0),serviceFeeCents:E,serviceFeeRateBasisPoints:E,subtotalCents:E,totalCents:E},N=e=>e.totalCents===e.subtotalCents+e.serviceFeeCents+(e.additionalChargeCents??0),P={...M,clientSecret:h(T),requiresAction:c()},F=b(g(P),l(e=>N(e)),l(e=>!e.requiresAction||e.clientSecret!==null)),I=b(g({...P,id:T,purchaseId:T,quantity:b(E,m(1)),status:y([`pending_payment`,`paid`,`payment_failed`,`expired`,`canceled`,`refunded`]),totalAmount:E}),l(e=>N(e)),l(e=>e.id===e.purchaseId&&(!e.requiresAction||e.clientSecret!==null))),L=b(g({...M,quantity:b(E,m(1)),totalAmount:E,unitAmount:E}),l(e=>N(e))),R={confirmationToken:T,email:b(C(),u()),expectedAdditionalChargeCents:_(E),expectedServiceFeeCents:_(E),expectedSubtotalCents:_(E),expectedTotalCents:_(E),includeServiceFee:_(c()),phone:b(C(),x(/^\+[1-9]\d{1,14}$/))},z=g({...R,amount:b(E,m(100))}),B=g({...R,clientRequestId:T,paymentMethodTypes:_(S([f(`card`)])),quantity:b(E,m(1))}),V=e=>v(j,e),H=e=>v(s(j),e),U=e=>v(F,e),W=e=>v(I,e),G=e=>v(L,e),K=e=>v(z,e),q=e=>v(B,e),J=e=>v(h(I),e),Y=e=>v(b(g(M),l(e=>N(e))),e),X=e=>v(g({includeServiceFee:_(c()),quantity:b(E,m(1))}),e);function Z(e,t,n){let r=e+t.map(e=>`/${encodeURIComponent(v(T,e))}`).join(``);return n===void 0?r:`${r}?${new URLSearchParams({previewItem:v(T,n)})}`}function Q(e){let s=t(e,`communitySlug`),c=e.mediaBaseUrl===void 0?void 0:i(e.mediaBaseUrl,s.environment,`mediaBaseUrl`),l=e=>w(V(e),c),u=n({communitySlug:s.communitySlugValue,environment:s.environment,getContext:()=>({}),onError:s.onError,resourceContextName:`lockerverse_auction`,sentryDsn:s.sentryDsn}),{requestJson:d}=a(s.fetchImplementation,u,s.requestTimeoutMs),f=`${s.apiBaseUrl}/auctions/communities/slug/${s.communitySlug}`;async function p(e,t,n,i,a,s=!1){let c=!!i&&!s,l,p;try{l=Z(f,t,a),i&&(p={body:JSON.stringify(i.parse(i.value)),headers:{"content-type":`application/json`},method:`POST`})}catch{throw u(new o({...e,message:`Lockerverse auction input is invalid.`,reportable:!1}))}try{let t=await d(l,p,n,{...e,report:!1},{...e,report:!1});if(!t.ok){let{status:n}=t.response;throw new o({...e,recoveryRecommended:c&&(n>=500||n===408),reportable:n>=500,status:n})}return r(t.value)}catch(t){throw t instanceof o?u(new o({...e,recoveryRecommended:t.recoveryRecommended||c&&t.status===void 0,reportable:t.reportable,...t.status===void 0?void 0:{status:t.status}})):u(new o({...e,recoveryRecommended:c,reportable:!0}))}}return{createBid:(e,t,n)=>p({code:`auction_bid_failed`,message:`Unable to submit Lockerverse auction bid.`,operation:`create_auction_bid`},[`path`,e,`items`,t,`bids`],U,{parse:K,value:n}),createPurchase:(e,t,n)=>p({code:`auction_purchase_failed`,message:`Unable to submit Lockerverse auction purchase.`,operation:`create_auction_purchase`},[`path`,e,`items`,t,`purchases`],W,{parse:q,value:n}),getPurchaseQuote:(e,t,n)=>p({code:`auction_load_failed`,message:`Unable to load Lockerverse auction purchase quote.`,operation:`load_auction`},[`path`,e,`items`,t,`purchase-quote`],Y,{parse:X,value:n},void 0,!0),getPurchaseReceipt:(e,t,n)=>p({code:`auction_receipt_failed`,message:`Unable to load Lockerverse auction purchase receipt.`,operation:`get_auction_purchase_receipt`},[`path`,e,`items`,t,`purchases`,n],G),getPurchaseStatus:(e,t,n)=>p({code:`auction_purchase_status_failed`,message:`Unable to load Lockerverse auction purchase status.`,operation:`get_auction_purchase_status`},[`path`,e,`items`,t,`purchase-status`,n],J),list:()=>p({code:`auction_load_failed`,message:`Unable to load Lockerverse auctions.`,operation:`list_auctions`},[],e=>H(e).map(e=>w(e,c))),load:(e,t)=>p({code:`auction_load_failed`,message:`Unable to load Lockerverse auction.`,operation:`load_auction`},[`path`,e],l,void 0,t?.previewItemSlug)}}function $(e){if(!Number.isSafeInteger(e)||e<0)throw TypeError(`Auction amounts must be non-negative safe integers.`)}function ee(e,t,n=!1,i=0){if($(t),$(i),n&&!e.serviceFeeEnabled)throw TypeError(`The service fee is not available for this auction.`);let a=n?e.pricingPolicy.serviceFeeRateBasisPoints:0;$(a);let o=Math.round(t*a/1e4),s=t+o+i;$(o),$(s);let c={serviceFeeCents:o,serviceFeeRateBasisPoints:a,subtotalCents:t,totalCents:s};return i>0&&(c.additionalChargeCents=i),r(c)}function te(e){let t=e.minBidAmount??100,n=e.bidIncrementAmount??100;if($(t),$(n),e.maxBidAmount===null)return t;$(e.maxBidAmount);let r=Math.max(t,e.maxBidAmount+n);return $(r),r}export{o as LockerverseSdkError,ee as calculateLockerverseAuctionPricing,Q as createLockerverseAuctionClient,te as getLockerverseAuctionMinimumBid};
|
|
2
2
|
//# sourceMappingURL=auctions.js.map
|
package/dist/auctions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctions.js","names":[],"sources":["../src/auction-media.ts","../src/auction-schemas.ts","../src/auction-client.ts","../src/auction-pricing.ts"],"sourcesContent":["import type { LockerverseAuction } from \"./auction-types.ts\";\n\nconst MEDIA_PREFIX = \"https://media.lockerverse.com/\";\n\nexport function rewriteAuctionMedia(\n auction: LockerverseAuction,\n mediaBaseUrl: string | undefined\n): LockerverseAuction {\n if (mediaBaseUrl === undefined) {\n return auction;\n }\n // Keep the explicit proxy identity with the snapshot, including across SSR.\n auction.mediaBaseUrl = mediaBaseUrl;\n const rewrite = <Value extends string | null | undefined>(value: Value) =>\n value?.startsWith(MEDIA_PREFIX)\n ? `${mediaBaseUrl}/${value.slice(MEDIA_PREFIX.length)}`\n : value;\n\n auction.configuration.image = rewrite(auction.configuration.image);\n if (auction.community) {\n auction.community.banner = rewrite(auction.community.banner);\n auction.community.thumbnail = rewrite(auction.community.thumbnail);\n }\n for (const item of auction.items) {\n item.image = rewrite(item.image);\n item.images = item.images.map(rewrite);\n }\n return auction;\n}\n","import {\n array,\n boolean,\n check,\n email,\n isoTimestamp,\n literal,\n minLength,\n minValue,\n nullable,\n object,\n optional,\n parse,\n picklist,\n pipe,\n regex,\n strictTuple,\n string,\n} from \"valibot\";\n\nimport { safeIntegerSchema } from \"./schema-helpers.ts\";\n\nexport const auctionTextSchema = pipe(string(), minLength(1));\nconst cents = safeIntegerSchema(0);\nconst date = pipe(string(), isoTimestamp());\nconst status = picklist([\"draft\", \"active\", \"finished\"]);\nconst itemSchema = object({\n auctionId: auctionTextSchema,\n availableQuantity: nullable(cents),\n bidCount: cents,\n bidIncrementAmount: nullable(cents),\n buyNowPriceAmount: nullable(cents),\n collectShippingAddress: boolean(),\n communityId: auctionTextSchema,\n createdAt: date,\n description: nullable(string()),\n endAt: optional(nullable(date)),\n finalizedBidCount: cents,\n finishedAt: optional(nullable(date)),\n id: auctionTextSchema,\n image: nullable(string()),\n images: array(string()),\n inventoryQuantity: nullable(cents),\n isSoldOut: boolean(),\n maxBidAmount: nullable(cents),\n minBidAmount: nullable(cents),\n name: string(),\n paidQuantity: cents,\n path: auctionTextSchema,\n position: cents,\n reservedQuantity: cents,\n saleMode: picklist([\"auction\", \"buy_now\", \"hybrid\"]),\n slug: auctionTextSchema,\n startAt: optional(nullable(date)),\n status,\n updatedAt: date,\n});\nconst auctionSchema = object({\n collectShippingAddress: boolean(),\n community: optional(\n object({\n banner: optional(nullable(string())),\n color: optional(nullable(string())),\n name: optional(string()),\n thumbnail: optional(nullable(string())),\n })\n ),\n communityId: auctionTextSchema,\n configuration: object({\n collectShippingAddress: boolean(),\n endTimeEnabled: optional(nullable(boolean())),\n image: nullable(string()),\n serviceFeeDefaultChecked: boolean(),\n serviceFeeEnabled: boolean(),\n startTimeEnabled: optional(nullable(boolean())),\n }),\n createdAt: date,\n description: nullable(string()),\n endAt: date,\n id: auctionTextSchema,\n items: array(itemSchema),\n name: string(),\n path: auctionTextSchema,\n payment: optional(\n object({\n connectedAccountId: nullable(auctionTextSchema),\n currency: literal(\"usd\"),\n publishableKey: auctionTextSchema,\n })\n ),\n position: cents,\n pricingPolicy: object({\n currency: literal(\"usd\"),\n serviceFeeRateBasisPoints: cents,\n }),\n serviceFeeDefaultChecked: boolean(),\n serviceFeeEnabled: boolean(),\n slug: auctionTextSchema,\n startAt: date,\n status,\n updatedAt: date,\n});\nconst pricingEntries = {\n serviceFeeCents: cents,\n serviceFeeRateBasisPoints: cents,\n subtotalCents: cents,\n totalCents: cents,\n};\nconst pricingIsConsistent = (value: {\n subtotalCents: number;\n serviceFeeCents: number;\n totalCents: number;\n}) => value.totalCents === value.subtotalCents + value.serviceFeeCents;\nconst bidResultEntries = {\n ...pricingEntries,\n clientSecret: nullable(auctionTextSchema),\n requiresAction: boolean(),\n};\nconst bidResultSchema = pipe(\n object(bidResultEntries),\n check((value) => pricingIsConsistent(value)),\n check((value) => !value.requiresAction || value.clientSecret !== null)\n);\nconst purchaseResultSchema = pipe(\n object({\n ...bidResultEntries,\n id: auctionTextSchema,\n purchaseId: auctionTextSchema,\n quantity: pipe(cents, minValue(1)),\n status: picklist([\n \"pending_payment\",\n \"paid\",\n \"payment_failed\",\n \"expired\",\n \"canceled\",\n \"refunded\",\n ]),\n totalAmount: cents,\n }),\n check((value) => pricingIsConsistent(value)),\n check(\n (value) =>\n value.id === value.purchaseId &&\n (!value.requiresAction || value.clientSecret !== null)\n )\n);\nconst receiptSchema = pipe(\n object({\n ...pricingEntries,\n quantity: pipe(cents, minValue(1)),\n totalAmount: cents,\n unitAmount: cents,\n }),\n check((value) => pricingIsConsistent(value))\n);\nconst submissionEntries = {\n confirmationToken: auctionTextSchema,\n email: pipe(string(), email()),\n expectedServiceFeeCents: optional(cents),\n expectedSubtotalCents: optional(cents),\n expectedTotalCents: optional(cents),\n includeServiceFee: optional(boolean()),\n phone: pipe(string(), regex(/^\\+[1-9]\\d{1,14}$/)),\n};\nconst bidSubmissionSchema = object({\n ...submissionEntries,\n amount: pipe(cents, minValue(100)),\n});\nconst purchaseSubmissionSchema = object({\n ...submissionEntries,\n clientRequestId: auctionTextSchema,\n paymentMethodTypes: optional(strictTuple([literal(\"card\")])),\n quantity: pipe(cents, minValue(1)),\n});\nexport const parseAuction = <Value>(value: Value) =>\n parse(auctionSchema, value);\nexport const parseAuctions = <Value>(value: Value) =>\n parse(array(auctionSchema), value);\nexport const parseAuctionBidResult = <Value>(value: Value) =>\n parse(bidResultSchema, value);\nexport const parseAuctionPurchaseResult = <Value>(value: Value) =>\n parse(purchaseResultSchema, value);\nexport const parseAuctionPurchaseReceipt = <Value>(value: Value) =>\n parse(receiptSchema, value);\nexport const parseAuctionBidSubmission = <Value>(value: Value) =>\n parse(bidSubmissionSchema, value);\nexport const parseAuctionPurchaseSubmission = <Value>(value: Value) =>\n parse(purchaseSubmissionSchema, value);\n\nexport const parseAuctionPurchaseStatus = <Value>(value: Value) =>\n parse(nullable(purchaseResultSchema), value);\n","import { parse } from \"valibot\";\nimport { rewriteAuctionMedia } from \"./auction-media.ts\";\nimport {\n auctionTextSchema,\n parseAuction,\n parseAuctionBidResult,\n parseAuctionBidSubmission,\n parseAuctionPurchaseReceipt,\n parseAuctionPurchaseResult,\n parseAuctionPurchaseStatus,\n parseAuctionPurchaseSubmission,\n parseAuctions,\n} from \"./auction-schemas.ts\";\nimport type {\n CreateLockerverseAuctionOptions,\n LockerverseAuctionClient,\n} from \"./auction-types.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport {\n parseResourceBaseUrl,\n resolveResourceEnvironment,\n} from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport {\n LockerverseSdkError,\n type LockerverseSdkErrorCode,\n type LockerverseSdkOperation,\n} from \"./types.ts\";\n\ntype RequestContext = {\n code: LockerverseSdkErrorCode;\n operation: LockerverseSdkOperation;\n message: string;\n};\n\nfunction auctionRequestUrl(\n baseUrl: string,\n segments: string[],\n previewItemSlug?: string\n): string {\n const path =\n baseUrl +\n segments\n .map(\n (segment) => `/${encodeURIComponent(parse(auctionTextSchema, segment))}`\n )\n .join(\"\");\n return previewItemSlug === undefined\n ? path\n : `${path}?${new URLSearchParams({\n previewItem: parse(auctionTextSchema, previewItemSlug),\n })}`;\n}\n\nexport function createLockerverseAuctionClient(\n options: CreateLockerverseAuctionOptions\n): LockerverseAuctionClient {\n const runtime = resolveResourceEnvironment(options, \"communitySlug\");\n const mediaBaseUrl =\n options.mediaBaseUrl === undefined\n ? undefined\n : parseResourceBaseUrl(\n options.mediaBaseUrl,\n runtime.environment,\n \"mediaBaseUrl\"\n );\n const parseAuctionResponse = <Value>(value: Value) =>\n rewriteAuctionMedia(parseAuction(value), mediaBaseUrl);\n const reportError = createSdkErrorReporter({\n communitySlug: runtime.communitySlugValue,\n environment: runtime.environment,\n getContext: () => ({}),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_auction\",\n sentryDsn: runtime.sentryDsn,\n });\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n reportError,\n runtime.requestTimeoutMs\n );\n const baseUrl = `${runtime.apiBaseUrl}/auctions/communities/slug/${runtime.communitySlug}`;\n\n async function request<T, Submission, ParsedSubmission>(\n context: RequestContext,\n segments: string[],\n parser: <Value>(value: Value) => T,\n submission?: {\n value: Submission;\n parse: (value: Submission) => ParsedSubmission;\n },\n previewItemSlug?: string\n ): Promise<T> {\n let url: string;\n let init: RequestInit | undefined;\n try {\n url = auctionRequestUrl(baseUrl, segments, previewItemSlug);\n if (submission) {\n init = {\n body: JSON.stringify(submission.parse(submission.value)),\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n };\n }\n } catch {\n // biome-ignore lint/style/useErrorCause: Validation details can contain personal data or confirmation tokens.\n throw reportError(\n new LockerverseSdkError({\n ...context,\n message: \"Lockerverse auction input is invalid.\",\n reportable: false,\n })\n );\n }\n try {\n const response = await requestJson(\n url,\n init,\n parser,\n { ...context, report: false },\n { ...context, report: false }\n );\n if (!response.ok) {\n const { status } = response.response;\n throw new LockerverseSdkError({\n ...context,\n recoveryRecommended:\n Boolean(submission) && (status >= 500 || status === 408),\n reportable: status >= 500,\n status,\n });\n }\n return deepFreeze(response.value);\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw reportError(\n new LockerverseSdkError({\n ...context,\n recoveryRecommended:\n error.recoveryRecommended ||\n (Boolean(submission) && error.status === undefined),\n reportable: error.reportable,\n ...(error.status === undefined\n ? undefined\n : { status: error.status }),\n })\n );\n }\n throw reportError(\n new LockerverseSdkError({\n ...context,\n recoveryRecommended: Boolean(submission),\n reportable: true,\n })\n );\n }\n }\n\n return {\n createBid: (auctionSlug, itemId, submission) =>\n request(\n {\n code: \"auction_bid_failed\",\n message: \"Unable to submit Lockerverse auction bid.\",\n operation: \"create_auction_bid\",\n },\n [\"path\", auctionSlug, \"items\", itemId, \"bids\"],\n parseAuctionBidResult,\n { parse: parseAuctionBidSubmission, value: submission }\n ),\n createPurchase: (auctionSlug, itemId, submission) =>\n request(\n {\n code: \"auction_purchase_failed\",\n message: \"Unable to submit Lockerverse auction purchase.\",\n operation: \"create_auction_purchase\",\n },\n [\"path\", auctionSlug, \"items\", itemId, \"purchases\"],\n parseAuctionPurchaseResult,\n { parse: parseAuctionPurchaseSubmission, value: submission }\n ),\n getPurchaseReceipt: (auctionSlug, itemSlug, purchaseId) =>\n request(\n {\n code: \"auction_receipt_failed\",\n message: \"Unable to load Lockerverse auction purchase receipt.\",\n operation: \"get_auction_purchase_receipt\",\n },\n [\"path\", auctionSlug, \"items\", itemSlug, \"purchases\", purchaseId],\n parseAuctionPurchaseReceipt\n ),\n getPurchaseStatus: (auctionSlug, itemId, clientRequestId) =>\n request(\n {\n code: \"auction_purchase_status_failed\",\n message: \"Unable to load Lockerverse auction purchase status.\",\n operation: \"get_auction_purchase_status\",\n },\n [\n \"path\",\n auctionSlug,\n \"items\",\n itemId,\n \"purchase-status\",\n clientRequestId,\n ],\n parseAuctionPurchaseStatus\n ),\n list: () =>\n request(\n {\n code: \"auction_load_failed\",\n message: \"Unable to load Lockerverse auctions.\",\n operation: \"list_auctions\",\n },\n [],\n (value) =>\n parseAuctions(value).map((auction) =>\n rewriteAuctionMedia(auction, mediaBaseUrl)\n )\n ),\n load: (auctionSlug, loadOptions) =>\n request(\n {\n code: \"auction_load_failed\",\n message: \"Unable to load Lockerverse auction.\",\n operation: \"load_auction\",\n },\n [\"path\", auctionSlug],\n parseAuctionResponse,\n undefined,\n loadOptions?.previewItemSlug\n ),\n };\n}\n","import type {\n LockerverseAuction,\n LockerverseAuctionItem,\n LockerverseAuctionPricing,\n} from \"./auction-types.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\n\nfunction assertCents(value: number) {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(\"Auction amounts must be non-negative safe integers.\");\n }\n}\n\n/** Local estimate. Send expected amounts with the submission for server validation. */\nexport function calculateLockerverseAuctionPricing(\n auction: Pick<LockerverseAuction, \"serviceFeeEnabled\" | \"pricingPolicy\">,\n subtotalCents: number,\n includeServiceFee = false\n): LockerverseAuctionPricing {\n assertCents(subtotalCents);\n if (includeServiceFee && !auction.serviceFeeEnabled) {\n throw new TypeError(\"The service fee is not available for this auction.\");\n }\n const serviceFeeRateBasisPoints = includeServiceFee\n ? auction.pricingPolicy.serviceFeeRateBasisPoints\n : 0;\n assertCents(serviceFeeRateBasisPoints);\n const serviceFeeCents = Math.round(\n (subtotalCents * serviceFeeRateBasisPoints) / 10_000\n );\n const totalCents = subtotalCents + serviceFeeCents;\n assertCents(serviceFeeCents);\n assertCents(totalCents);\n return deepFreeze({\n serviceFeeCents,\n serviceFeeRateBasisPoints,\n subtotalCents,\n totalCents,\n });\n}\n\n/** Snapshot estimate. Another accepted bid can increase the server minimum. */\nexport function getLockerverseAuctionMinimumBid(\n item: Pick<\n LockerverseAuctionItem,\n \"minBidAmount\" | \"bidIncrementAmount\" | \"maxBidAmount\"\n >\n): number {\n const minimum = item.minBidAmount ?? 100;\n const increment = item.bidIncrementAmount ?? 100;\n assertCents(minimum);\n assertCents(increment);\n if (item.maxBidAmount === null) {\n return minimum;\n }\n assertCents(item.maxBidAmount);\n const amount = Math.max(minimum, item.maxBidAmount + increment);\n assertCents(amount);\n return amount;\n}\n"],"mappings":"mXAIA,SAAgB,EACd,EACA,EACoB,CACpB,GAAI,IAAiB,IAAA,GACnB,OAAO,EAGT,EAAQ,aAAe,EACvB,IAAM,EAAoD,GACxD,GAAO,WAAW,gCAAY,EAC1B,GAAG,EAAa,GAAG,EAAM,MAAM,EAAmB,IAClD,EAEN,EAAQ,cAAc,MAAQ,EAAQ,EAAQ,cAAc,KAAK,EAC7D,EAAQ,YACV,EAAQ,UAAU,OAAS,EAAQ,EAAQ,UAAU,MAAM,EAC3D,EAAQ,UAAU,UAAY,EAAQ,EAAQ,UAAU,SAAS,GAEnE,IAAK,IAAM,KAAQ,EAAQ,MACzB,EAAK,MAAQ,EAAQ,EAAK,KAAK,EAC/B,EAAK,OAAS,EAAK,OAAO,IAAI,CAAO,EAEvC,OAAO,CACT,CCNA,MAAa,EAAoB,EAAK,EAAO,EAAG,EAAU,CAAC,CAAC,EACtD,EAAQ,EAAkB,CAAC,EAC3B,EAAO,EAAK,EAAO,EAAG,EAAa,CAAC,EACpC,EAAS,EAAS,CAAC,QAAS,SAAU,UAAU,CAAC,EACjD,EAAa,EAAO,CACxB,UAAW,EACX,kBAAmB,EAAS,CAAK,EACjC,SAAU,EACV,mBAAoB,EAAS,CAAK,EAClC,kBAAmB,EAAS,CAAK,EACjC,uBAAwB,EAAQ,EAChC,YAAa,EACb,UAAW,EACX,YAAa,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Y,EAAK,YAAY,EAC7B,IAAM,EAAS,KAAK,IAAI,EAAS,EAAK,aAAe,CAAS,EAE9D,OADA,EAAY,CAAM,EACX,CACT"}
|
|
1
|
+
{"version":3,"file":"auctions.js","names":[],"sources":["../src/auction-media.ts","../src/auction-schemas.ts","../src/auction-client.ts","../src/auction-pricing.ts"],"sourcesContent":["import type { LockerverseAuction } from \"./auction-types.ts\";\n\nconst MEDIA_PREFIX = \"https://media.lockerverse.com/\";\n\nexport function rewriteAuctionMedia(\n auction: LockerverseAuction,\n mediaBaseUrl: string | undefined\n): LockerverseAuction {\n if (mediaBaseUrl === undefined) {\n return auction;\n }\n // Keep the explicit proxy identity with the snapshot, including across SSR.\n auction.mediaBaseUrl = mediaBaseUrl;\n const rewrite = <Value extends string | null | undefined>(value: Value) =>\n value?.startsWith(MEDIA_PREFIX)\n ? `${mediaBaseUrl}/${value.slice(MEDIA_PREFIX.length)}`\n : value;\n\n auction.configuration.image = rewrite(auction.configuration.image);\n if (auction.community) {\n auction.community.banner = rewrite(auction.community.banner);\n auction.community.thumbnail = rewrite(auction.community.thumbnail);\n }\n for (const item of auction.items) {\n item.image = rewrite(item.image);\n item.images = item.images.map(rewrite);\n }\n return auction;\n}\n","import {\n array,\n boolean,\n check,\n email,\n isoTimestamp,\n literal,\n minLength,\n minValue,\n nullable,\n object,\n optional,\n parse,\n picklist,\n pipe,\n regex,\n strictTuple,\n string,\n} from \"valibot\";\n\nimport { safeIntegerSchema } from \"./schema-helpers.ts\";\n\nexport const auctionTextSchema = pipe(string(), minLength(1));\nconst cents = safeIntegerSchema(0);\nconst date = pipe(string(), isoTimestamp());\nconst status = picklist([\"draft\", \"active\", \"finished\"]);\nconst additionalChargeSchema = object({\n additionalUnitAmountCents: cents,\n category: picklist([\"shipping\", \"handling\", \"other\"]),\n firstUnitAmountCents: cents,\n name: auctionTextSchema,\n});\nconst itemSchema = object({\n additionalCharge: optional(nullable(additionalChargeSchema)),\n auctionId: auctionTextSchema,\n availableQuantity: nullable(cents),\n bidCount: cents,\n bidIncrementAmount: nullable(cents),\n buyNowPriceAmount: nullable(cents),\n collectShippingAddress: boolean(),\n communityId: auctionTextSchema,\n createdAt: date,\n description: nullable(string()),\n endAt: optional(nullable(date)),\n finalizedBidCount: cents,\n finishedAt: optional(nullable(date)),\n id: auctionTextSchema,\n image: nullable(string()),\n images: array(string()),\n inventoryQuantity: nullable(cents),\n isSoldOut: boolean(),\n maxBidAmount: nullable(cents),\n maxQuantityPerOrder: optional(nullable(pipe(cents, minValue(1)))),\n minBidAmount: nullable(cents),\n name: string(),\n paidQuantity: cents,\n path: auctionTextSchema,\n position: cents,\n reservedQuantity: cents,\n saleMode: picklist([\"auction\", \"buy_now\", \"hybrid\"]),\n slug: auctionTextSchema,\n startAt: optional(nullable(date)),\n status,\n updatedAt: date,\n});\nconst auctionSchema = object({\n collectShippingAddress: boolean(),\n community: optional(\n object({\n banner: optional(nullable(string())),\n color: optional(nullable(string())),\n name: optional(string()),\n thumbnail: optional(nullable(string())),\n })\n ),\n communityId: auctionTextSchema,\n configuration: object({\n collectShippingAddress: boolean(),\n endTimeEnabled: optional(nullable(boolean())),\n image: nullable(string()),\n serviceFeeDefaultChecked: boolean(),\n serviceFeeEnabled: boolean(),\n startTimeEnabled: optional(nullable(boolean())),\n }),\n createdAt: date,\n description: nullable(string()),\n endAt: date,\n id: auctionTextSchema,\n items: array(itemSchema),\n name: string(),\n path: auctionTextSchema,\n payment: optional(\n object({\n connectedAccountId: nullable(auctionTextSchema),\n currency: literal(\"usd\"),\n publishableKey: auctionTextSchema,\n })\n ),\n position: cents,\n pricingPolicy: object({\n currency: literal(\"usd\"),\n serviceFeeRateBasisPoints: cents,\n }),\n serviceFeeDefaultChecked: boolean(),\n serviceFeeEnabled: boolean(),\n slug: auctionTextSchema,\n startAt: date,\n status,\n updatedAt: date,\n});\nconst pricingEntries = {\n additionalCharge: optional(nullable(additionalChargeSchema)),\n additionalChargeCents: optional(cents, 0),\n serviceFeeCents: cents,\n serviceFeeRateBasisPoints: cents,\n subtotalCents: cents,\n totalCents: cents,\n};\nconst pricingIsConsistent = (value: {\n additionalChargeCents?: number;\n subtotalCents: number;\n serviceFeeCents: number;\n totalCents: number;\n}) =>\n value.totalCents ===\n value.subtotalCents +\n value.serviceFeeCents +\n (value.additionalChargeCents ?? 0);\nconst bidResultEntries = {\n ...pricingEntries,\n clientSecret: nullable(auctionTextSchema),\n requiresAction: boolean(),\n};\nconst bidResultSchema = pipe(\n object(bidResultEntries),\n check((value) => pricingIsConsistent(value)),\n check((value) => !value.requiresAction || value.clientSecret !== null)\n);\nconst purchaseResultSchema = pipe(\n object({\n ...bidResultEntries,\n id: auctionTextSchema,\n purchaseId: auctionTextSchema,\n quantity: pipe(cents, minValue(1)),\n status: picklist([\n \"pending_payment\",\n \"paid\",\n \"payment_failed\",\n \"expired\",\n \"canceled\",\n \"refunded\",\n ]),\n totalAmount: cents,\n }),\n check((value) => pricingIsConsistent(value)),\n check(\n (value) =>\n value.id === value.purchaseId &&\n (!value.requiresAction || value.clientSecret !== null)\n )\n);\nconst receiptSchema = pipe(\n object({\n ...pricingEntries,\n quantity: pipe(cents, minValue(1)),\n totalAmount: cents,\n unitAmount: cents,\n }),\n check((value) => pricingIsConsistent(value))\n);\nconst submissionEntries = {\n confirmationToken: auctionTextSchema,\n email: pipe(string(), email()),\n expectedAdditionalChargeCents: optional(cents),\n expectedServiceFeeCents: optional(cents),\n expectedSubtotalCents: optional(cents),\n expectedTotalCents: optional(cents),\n includeServiceFee: optional(boolean()),\n phone: pipe(string(), regex(/^\\+[1-9]\\d{1,14}$/)),\n};\nconst bidSubmissionSchema = object({\n ...submissionEntries,\n amount: pipe(cents, minValue(100)),\n});\nconst purchaseSubmissionSchema = object({\n ...submissionEntries,\n clientRequestId: auctionTextSchema,\n paymentMethodTypes: optional(strictTuple([literal(\"card\")])),\n quantity: pipe(cents, minValue(1)),\n});\nexport const parseAuction = <Value>(value: Value) =>\n parse(auctionSchema, value);\nexport const parseAuctions = <Value>(value: Value) =>\n parse(array(auctionSchema), value);\nexport const parseAuctionBidResult = <Value>(value: Value) =>\n parse(bidResultSchema, value);\nexport const parseAuctionPurchaseResult = <Value>(value: Value) =>\n parse(purchaseResultSchema, value);\nexport const parseAuctionPurchaseReceipt = <Value>(value: Value) =>\n parse(receiptSchema, value);\nexport const parseAuctionBidSubmission = <Value>(value: Value) =>\n parse(bidSubmissionSchema, value);\nexport const parseAuctionPurchaseSubmission = <Value>(value: Value) =>\n parse(purchaseSubmissionSchema, value);\n\nexport const parseAuctionPurchaseStatus = <Value>(value: Value) =>\n parse(nullable(purchaseResultSchema), value);\n\nexport const parseAuctionPurchaseQuote = <Value>(value: Value) =>\n parse(\n pipe(\n object(pricingEntries),\n check((pricing) => pricingIsConsistent(pricing))\n ),\n value\n );\nexport const parseAuctionPurchaseQuoteSelection = <Value>(value: Value) =>\n parse(\n object({\n includeServiceFee: optional(boolean()),\n quantity: pipe(cents, minValue(1)),\n }),\n value\n );\n","import { parse } from \"valibot\";\nimport { rewriteAuctionMedia } from \"./auction-media.ts\";\nimport {\n auctionTextSchema,\n parseAuction,\n parseAuctionBidResult,\n parseAuctionBidSubmission,\n parseAuctionPurchaseQuote,\n parseAuctionPurchaseQuoteSelection,\n parseAuctionPurchaseReceipt,\n parseAuctionPurchaseResult,\n parseAuctionPurchaseStatus,\n parseAuctionPurchaseSubmission,\n parseAuctions,\n} from \"./auction-schemas.ts\";\nimport type {\n CreateLockerverseAuctionOptions,\n LockerverseAuctionClient,\n} from \"./auction-types.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\nimport {\n parseResourceBaseUrl,\n resolveResourceEnvironment,\n} from \"./environment.ts\";\nimport { createSdkErrorReporter } from \"./error-reporting.ts\";\nimport { createTransport } from \"./transport.ts\";\nimport {\n LockerverseSdkError,\n type LockerverseSdkErrorCode,\n type LockerverseSdkOperation,\n} from \"./types.ts\";\n\ntype RequestContext = {\n code: LockerverseSdkErrorCode;\n operation: LockerverseSdkOperation;\n message: string;\n};\n\nfunction auctionRequestUrl(\n baseUrl: string,\n segments: string[],\n previewItemSlug?: string\n): string {\n const path =\n baseUrl +\n segments\n .map(\n (segment) => `/${encodeURIComponent(parse(auctionTextSchema, segment))}`\n )\n .join(\"\");\n return previewItemSlug === undefined\n ? path\n : `${path}?${new URLSearchParams({\n previewItem: parse(auctionTextSchema, previewItemSlug),\n })}`;\n}\n\nexport function createLockerverseAuctionClient(\n options: CreateLockerverseAuctionOptions\n): LockerverseAuctionClient {\n const runtime = resolveResourceEnvironment(options, \"communitySlug\");\n const mediaBaseUrl =\n options.mediaBaseUrl === undefined\n ? undefined\n : parseResourceBaseUrl(\n options.mediaBaseUrl,\n runtime.environment,\n \"mediaBaseUrl\"\n );\n const parseAuctionResponse = <Value>(value: Value) =>\n rewriteAuctionMedia(parseAuction(value), mediaBaseUrl);\n const reportError = createSdkErrorReporter({\n communitySlug: runtime.communitySlugValue,\n environment: runtime.environment,\n getContext: () => ({}),\n onError: runtime.onError,\n resourceContextName: \"lockerverse_auction\",\n sentryDsn: runtime.sentryDsn,\n });\n const { requestJson } = createTransport(\n runtime.fetchImplementation,\n reportError,\n runtime.requestTimeoutMs\n );\n const baseUrl = `${runtime.apiBaseUrl}/auctions/communities/slug/${runtime.communitySlug}`;\n\n async function request<T, Submission, ParsedSubmission>(\n context: RequestContext,\n segments: string[],\n parser: <Value>(value: Value) => T,\n submission?: {\n value: Submission;\n parse: (value: Submission) => ParsedSubmission;\n },\n previewItemSlug?: string,\n readOnly = false\n ): Promise<T> {\n const mutatesPayment = Boolean(submission) && !readOnly;\n let url: string;\n let init: RequestInit | undefined;\n try {\n url = auctionRequestUrl(baseUrl, segments, previewItemSlug);\n if (submission) {\n init = {\n body: JSON.stringify(submission.parse(submission.value)),\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n };\n }\n } catch {\n // biome-ignore lint/style/useErrorCause: Validation details can contain personal data or confirmation tokens.\n throw reportError(\n new LockerverseSdkError({\n ...context,\n message: \"Lockerverse auction input is invalid.\",\n reportable: false,\n })\n );\n }\n try {\n const response = await requestJson(\n url,\n init,\n parser,\n { ...context, report: false },\n { ...context, report: false }\n );\n if (!response.ok) {\n const { status } = response.response;\n throw new LockerverseSdkError({\n ...context,\n recoveryRecommended:\n mutatesPayment && (status >= 500 || status === 408),\n reportable: status >= 500,\n status,\n });\n }\n return deepFreeze(response.value);\n } catch (error) {\n if (error instanceof LockerverseSdkError) {\n throw reportError(\n new LockerverseSdkError({\n ...context,\n recoveryRecommended:\n error.recoveryRecommended ||\n (mutatesPayment && error.status === undefined),\n reportable: error.reportable,\n ...(error.status === undefined\n ? undefined\n : { status: error.status }),\n })\n );\n }\n throw reportError(\n new LockerverseSdkError({\n ...context,\n recoveryRecommended: mutatesPayment,\n reportable: true,\n })\n );\n }\n }\n\n return {\n createBid: (auctionSlug, itemId, submission) =>\n request(\n {\n code: \"auction_bid_failed\",\n message: \"Unable to submit Lockerverse auction bid.\",\n operation: \"create_auction_bid\",\n },\n [\"path\", auctionSlug, \"items\", itemId, \"bids\"],\n parseAuctionBidResult,\n { parse: parseAuctionBidSubmission, value: submission }\n ),\n createPurchase: (auctionSlug, itemId, submission) =>\n request(\n {\n code: \"auction_purchase_failed\",\n message: \"Unable to submit Lockerverse auction purchase.\",\n operation: \"create_auction_purchase\",\n },\n [\"path\", auctionSlug, \"items\", itemId, \"purchases\"],\n parseAuctionPurchaseResult,\n { parse: parseAuctionPurchaseSubmission, value: submission }\n ),\n getPurchaseQuote: (auctionSlug, itemId, selection) =>\n request(\n {\n code: \"auction_load_failed\",\n message: \"Unable to load Lockerverse auction purchase quote.\",\n operation: \"load_auction\",\n },\n [\"path\", auctionSlug, \"items\", itemId, \"purchase-quote\"],\n parseAuctionPurchaseQuote,\n { parse: parseAuctionPurchaseQuoteSelection, value: selection },\n undefined,\n true\n ),\n getPurchaseReceipt: (auctionSlug, itemSlug, purchaseId) =>\n request(\n {\n code: \"auction_receipt_failed\",\n message: \"Unable to load Lockerverse auction purchase receipt.\",\n operation: \"get_auction_purchase_receipt\",\n },\n [\"path\", auctionSlug, \"items\", itemSlug, \"purchases\", purchaseId],\n parseAuctionPurchaseReceipt\n ),\n getPurchaseStatus: (auctionSlug, itemId, clientRequestId) =>\n request(\n {\n code: \"auction_purchase_status_failed\",\n message: \"Unable to load Lockerverse auction purchase status.\",\n operation: \"get_auction_purchase_status\",\n },\n [\n \"path\",\n auctionSlug,\n \"items\",\n itemId,\n \"purchase-status\",\n clientRequestId,\n ],\n parseAuctionPurchaseStatus\n ),\n list: () =>\n request(\n {\n code: \"auction_load_failed\",\n message: \"Unable to load Lockerverse auctions.\",\n operation: \"list_auctions\",\n },\n [],\n (value) =>\n parseAuctions(value).map((auction) =>\n rewriteAuctionMedia(auction, mediaBaseUrl)\n )\n ),\n load: (auctionSlug, loadOptions) =>\n request(\n {\n code: \"auction_load_failed\",\n message: \"Unable to load Lockerverse auction.\",\n operation: \"load_auction\",\n },\n [\"path\", auctionSlug],\n parseAuctionResponse,\n undefined,\n loadOptions?.previewItemSlug\n ),\n };\n}\n","import type {\n LockerverseAuction,\n LockerverseAuctionItem,\n LockerverseAuctionPricing,\n} from \"./auction-types.ts\";\nimport { deepFreeze } from \"./deep-freeze.ts\";\n\nfunction assertCents(value: number) {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(\"Auction amounts must be non-negative safe integers.\");\n }\n}\n\n/** Local estimate. Send expected amounts with the submission for server validation. */\nexport function calculateLockerverseAuctionPricing(\n auction: Pick<LockerverseAuction, \"serviceFeeEnabled\" | \"pricingPolicy\">,\n subtotalCents: number,\n includeServiceFee = false,\n additionalChargeCents = 0\n): LockerverseAuctionPricing {\n assertCents(subtotalCents);\n assertCents(additionalChargeCents);\n if (includeServiceFee && !auction.serviceFeeEnabled) {\n throw new TypeError(\"The service fee is not available for this auction.\");\n }\n const serviceFeeRateBasisPoints = includeServiceFee\n ? auction.pricingPolicy.serviceFeeRateBasisPoints\n : 0;\n assertCents(serviceFeeRateBasisPoints);\n const serviceFeeCents = Math.round(\n (subtotalCents * serviceFeeRateBasisPoints) / 10_000\n );\n const totalCents = subtotalCents + serviceFeeCents + additionalChargeCents;\n assertCents(serviceFeeCents);\n assertCents(totalCents);\n const pricing: LockerverseAuctionPricing = {\n serviceFeeCents,\n serviceFeeRateBasisPoints,\n subtotalCents,\n totalCents,\n };\n if (additionalChargeCents > 0) {\n pricing.additionalChargeCents = additionalChargeCents;\n }\n return deepFreeze(pricing);\n}\n\n/** Snapshot estimate. Another accepted bid can increase the server minimum. */\nexport function getLockerverseAuctionMinimumBid(\n item: Pick<\n LockerverseAuctionItem,\n \"minBidAmount\" | \"bidIncrementAmount\" | \"maxBidAmount\"\n >\n): number {\n const minimum = item.minBidAmount ?? 100;\n const increment = item.bidIncrementAmount ?? 100;\n assertCents(minimum);\n assertCents(increment);\n if (item.maxBidAmount === null) {\n return minimum;\n }\n assertCents(item.maxBidAmount);\n const amount = Math.max(minimum, item.maxBidAmount + increment);\n assertCents(amount);\n return amount;\n}\n"],"mappings":"mXAIA,SAAgB,EACd,EACA,EACoB,CACpB,GAAI,IAAiB,IAAA,GACnB,OAAO,EAGT,EAAQ,aAAe,EACvB,IAAM,EAAoD,GACxD,GAAO,WAAW,gCAAY,EAC1B,GAAG,EAAa,GAAG,EAAM,MAAM,EAAmB,IAClD,EAEN,EAAQ,cAAc,MAAQ,EAAQ,EAAQ,cAAc,KAAK,EAC7D,EAAQ,YACV,EAAQ,UAAU,OAAS,EAAQ,EAAQ,UAAU,MAAM,EAC3D,EAAQ,UAAU,UAAY,EAAQ,EAAQ,UAAU,SAAS,GAEnE,IAAK,IAAM,KAAQ,EAAQ,MACzB,EAAK,MAAQ,EAAQ,EAAK,KAAK,EAC/B,EAAK,OAAS,EAAK,OAAO,IAAI,CAAO,EAEvC,OAAO,CACT,CCNA,MAAa,EAAoB,EAAK,EAAO,EAAG,EAAU,CAAC,CAAC,EACtD,EAAQ,EAAkB,CAAC,EAC3B,EAAO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ACT"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=`0.2.
|
|
1
|
+
const e=`0.2.191`;var t=class extends Error{failureKind;code;operation;reportable;recoveryRecommended;sdkVersion;serverCode;status;constructor({failureKind:t,code:n,message:r,operation:i,reportable:a,recoveryRecommended:o=!1,serverCode:s,status:c}){super(r),this.name=`LockerverseSdkError`,this.failureKind=t,this.code=n,this.operation=i,this.reportable=a,this.recoveryRecommended=o,this.sdkVersion=e,this.serverCode=s,this.status=c}};export{t as n,e as t};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["packageMetadata.version"],"sources":["../package.json","../src/types.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\" with { type: \"json\" };\nimport type { GeneratedPaymentResult } from \"./generated/public-contract-types.ts\";\n\nexport type LockerversePaymentOption =\n | \"one-time\"\n | \"monthly\"\n | \"annually\"\n | \"every-six-months\";\nexport type LockerverseEnvironment = \"development\" | \"production\";\nexport type LockerverseFulfillmentType = \"none\" | \"event_admission\";\n\nexport const LOCKERVERSE_SDK_VERSION = packageMetadata.version;\n\nexport type LockerverseProduct = {\n id: string;\n listingId: string;\n slug: string;\n name: string;\n description: string | null;\n fulfillmentType: LockerverseFulfillmentType;\n pricingMode: \"fixed\" | \"custom\";\n paymentOption: LockerversePaymentOption;\n amountCents: number | null;\n minimumAmountCents: number | null;\n minimumQuantity: number | null;\n /** Per-order limit for this widget listing. Null means no per-order limit. */\n maximumQuantity: number | null;\n inventoryQuantity: number | null;\n acceptsDiscounts: boolean;\n};\n\nexport type LockerverseAvailabilityStatus = \"available\" | \"sold_out\";\n\nexport type LockerverseCatalogAvailability = {\n listings: Array<{\n listingId: string;\n maxPurchasableQuantity: number | null;\n remainingQuantity: number | null;\n status: LockerverseAvailabilityStatus;\n }>;\n sharedLimits: Array<{\n id: string;\n listingIds: string[];\n remainingQuantity: number;\n status: LockerverseAvailabilityStatus;\n }>;\n};\n\nexport type LockerverseCatalog = {\n availability: LockerverseCatalogAvailability;\n community: LockerverseCommunityBranding | null;\n event: LockerverseEvent | null;\n payment: LockerversePaymentConfiguration;\n pricingPolicy: LockerverseCheckoutPricingPolicy;\n products: LockerverseProduct[];\n widget: LockerverseWidgetConfiguration;\n};\n\nexport type LockerverseEvent = {\n description: string | null;\n endAt: string;\n id: string;\n location: string | null;\n name: string;\n startAt: string;\n status: \"draft\" | \"active\" | \"finished\" | \"cancelled\";\n};\n\nexport type LockerverseCommunityBranding = {\n widgetAchEnabled?: boolean | undefined;\n accentColor: string;\n imageUrl: string | null;\n memberIdLabel?: string | null | undefined;\n name: string;\n};\n\nexport type LockerverseCheckoutPricingPolicy = {\n currency: \"usd\";\n serviceFeeRateBasisPoints: number;\n};\n\nexport type LockerversePaymentConfiguration = {\n connectedAccountId: string | null;\n currency: \"usd\";\n publishableKey: string;\n};\n\nexport type LockerverseWidgetFields = {\n memberId: boolean;\n merchSize: boolean;\n phone: boolean;\n promoCode: boolean;\n serviceFee: boolean;\n shipping: boolean;\n tipping: boolean;\n};\n\nexport type LockerverseCustomFieldOption = { id: string; label: string };\n\ntype LockerverseCustomFieldBase = {\n id: string;\n label: string;\n paymentOptionIds?: string[] | undefined;\n required: boolean;\n};\n\nexport type LockerverseTextCustomField = LockerverseCustomFieldBase & {\n type: \"text\" | \"textarea\";\n};\n\nexport type LockerverseBooleanCustomField = LockerverseCustomFieldBase & {\n type: \"checkbox\";\n};\n\nexport type LockerverseSingleOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"radio\" | \"select\";\n};\n\nexport type LockerverseMultiOptionCustomField = LockerverseCustomFieldBase & {\n options: LockerverseCustomFieldOption[];\n type: \"checkboxes\" | \"multi_select\";\n};\n\nexport type LockerverseCustomField =\n | LockerverseBooleanCustomField\n | LockerverseTextCustomField\n | LockerverseSingleOptionCustomField\n | LockerverseMultiOptionCustomField;\n\nexport type LockerverseCustomFieldAnswerValue<\n Field extends LockerverseCustomField,\n> = Field extends LockerverseBooleanCustomField\n ? boolean\n : Field extends LockerverseMultiOptionCustomField\n ? string[]\n : string;\n\nexport type LockerverseCustomFieldAnswer<\n Field extends LockerverseCustomField = LockerverseCustomField,\n> = Field extends LockerverseCustomField\n ? { fieldId: Field[\"id\"]; value: LockerverseCustomFieldAnswerValue<Field> }\n : never;\n\nexport type LockerverseWidgetConfiguration = {\n requiredShipping?:\n | {\n additionalUnitAmountCents?: number | undefined;\n productId: string;\n triggerProductIds: string[];\n }\n | undefined;\n customFields: LockerverseCustomField[];\n description: string | null;\n fields: LockerverseWidgetFields;\n id: string;\n name: string;\n showCommunityBranding: boolean;\n title: string | null;\n};\n\nexport type LockerverseSdkErrorCode =\n | \"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 | \"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,gBAiMvC,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 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 | \"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 | \"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,UAiMvC,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"}
|