Skip to content

Commit cd7515a

Browse files
committed
chore: include dist for GitHub install
1 parent 89200b6 commit cd7515a

56 files changed

Lines changed: 120891 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dist/chunk-22HCL22X.js

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
import {
2+
CheckoutProductSchema
3+
} from "./chunk-CD4U22RQ.js";
4+
import {
5+
BaseInvoiceSchema,
6+
DynamicAmountPendingInvoiceSchema,
7+
FixedAmountPendingInvoiceSchema,
8+
PaidInvoiceSchema
9+
} from "./chunk-TGG53ETU.js";
10+
import {
11+
CurrencySchema
12+
} from "./chunk-6M6LFZ3U.js";
13+
14+
// src/schemas/checkout.ts
15+
import { z } from "zod";
16+
var CustomerFieldSchema = z.string().min(1);
17+
var CustomerOutputSchema = z.object({
18+
name: z.string().nullish(),
19+
email: z.string().email().nullish(),
20+
externalId: z.string().nullish()
21+
}).catchall(z.string());
22+
var BaseCheckoutSchema = z.object({
23+
id: z.string(),
24+
createdAt: z.date(),
25+
clientSecret: z.string(),
26+
type: z.enum(["PRODUCTS", "AMOUNT", "TOP_UP"]),
27+
status: z.enum([
28+
"UNCONFIRMED",
29+
"CONFIRMED",
30+
"PENDING_PAYMENT",
31+
"PAYMENT_RECEIVED",
32+
"EXPIRED"
33+
]),
34+
organizationId: z.string(),
35+
expiresAt: z.date(),
36+
userMetadata: z.record(z.any()).nullable(),
37+
customFieldData: z.record(z.any()).nullable(),
38+
currency: CurrencySchema,
39+
allowDiscountCodes: z.boolean(),
40+
/**
41+
* Array of customer fields required at checkout.
42+
* @example ['email'] - email required
43+
* @example ['email', 'name'] - both required
44+
*/
45+
requireCustomerData: z.array(CustomerFieldSchema).nullable(),
46+
successUrl: z.string().nullable(),
47+
/**
48+
* Customer data associated with this checkout.
49+
*/
50+
customer: CustomerOutputSchema.nullable(),
51+
customerBillingAddress: z.record(z.any()).nullable(),
52+
products: z.array(CheckoutProductSchema).nullable(),
53+
/**
54+
* The selected product ID (from the products array).
55+
* For PRODUCTS checkouts, this is the product the customer has chosen.
56+
* null for AMOUNT/TOP_UP checkouts.
57+
*/
58+
productId: z.string().nullable(),
59+
/**
60+
* The selected product price ID.
61+
* References a price from the selected product's prices array.
62+
* null for AMOUNT/TOP_UP checkouts.
63+
*/
64+
productPriceId: z.string().nullable(),
65+
/**
66+
* User-provided amount for CUSTOM price products.
67+
* Only set when the selected price has amountType: CUSTOM.
68+
*/
69+
customAmount: z.number().nullable(),
70+
/**
71+
* The selected product with full details (convenience field).
72+
* Same shape as items in the products array.
73+
* null if no product is selected.
74+
*/
75+
product: CheckoutProductSchema.nullable(),
76+
providedAmount: z.number().nullable(),
77+
totalAmount: z.number().nullable(),
78+
discountAmount: z.number().nullable(),
79+
netAmount: z.number().nullable(),
80+
taxAmount: z.number().nullable(),
81+
invoiceAmountSats: z.number().nullable(),
82+
invoiceScid: z.string().nullable(),
83+
btcPrice: z.number().nullable(),
84+
invoice: BaseInvoiceSchema.nullable()
85+
});
86+
var AmountFieldsSchema = z.object({
87+
totalAmount: z.number(),
88+
discountAmount: z.number(),
89+
netAmount: z.number(),
90+
taxAmount: z.number(),
91+
invoiceAmountSats: z.number(),
92+
btcPrice: z.number()
93+
});
94+
var ExpiredCheckoutSchema = BaseCheckoutSchema.extend({
95+
status: z.literal("EXPIRED"),
96+
type: z.enum(["PRODUCTS", "AMOUNT", "TOP_UP"])
97+
});
98+
var UnconfirmedCheckoutSchema = z.discriminatedUnion("type", [
99+
BaseCheckoutSchema.extend({
100+
status: z.literal("UNCONFIRMED"),
101+
type: z.literal("PRODUCTS"),
102+
products: z.array(CheckoutProductSchema).nonempty()
103+
}),
104+
BaseCheckoutSchema.extend({
105+
status: z.literal("UNCONFIRMED"),
106+
type: z.literal("AMOUNT"),
107+
providedAmount: z.number()
108+
}),
109+
BaseCheckoutSchema.extend({
110+
status: z.literal("UNCONFIRMED"),
111+
type: z.literal("TOP_UP")
112+
})
113+
]);
114+
var ConfirmedCheckoutSchema = z.discriminatedUnion("type", [
115+
BaseCheckoutSchema.merge(AmountFieldsSchema).extend({
116+
status: z.literal("CONFIRMED"),
117+
type: z.literal("PRODUCTS"),
118+
products: z.array(CheckoutProductSchema).nonempty()
119+
}),
120+
BaseCheckoutSchema.merge(AmountFieldsSchema).extend({
121+
status: z.literal("CONFIRMED"),
122+
type: z.literal("AMOUNT"),
123+
providedAmount: z.number()
124+
}),
125+
BaseCheckoutSchema.extend({
126+
status: z.literal("CONFIRMED"),
127+
type: z.literal("TOP_UP")
128+
})
129+
]);
130+
var PendingPaymentCheckoutSchema = z.discriminatedUnion("type", [
131+
BaseCheckoutSchema.merge(AmountFieldsSchema).extend({
132+
status: z.literal("PENDING_PAYMENT"),
133+
type: z.literal("PRODUCTS"),
134+
products: z.array(CheckoutProductSchema).nonempty(),
135+
invoice: FixedAmountPendingInvoiceSchema
136+
}),
137+
BaseCheckoutSchema.merge(AmountFieldsSchema).extend({
138+
status: z.literal("PENDING_PAYMENT"),
139+
type: z.literal("AMOUNT"),
140+
providedAmount: z.number(),
141+
invoice: FixedAmountPendingInvoiceSchema
142+
}),
143+
BaseCheckoutSchema.extend({
144+
status: z.literal("PENDING_PAYMENT"),
145+
type: z.literal("TOP_UP"),
146+
invoice: DynamicAmountPendingInvoiceSchema
147+
})
148+
]);
149+
var PaymentReceivedCheckoutSchema = z.discriminatedUnion("type", [
150+
BaseCheckoutSchema.merge(AmountFieldsSchema).extend({
151+
status: z.literal("PAYMENT_RECEIVED"),
152+
type: z.literal("PRODUCTS"),
153+
products: z.array(CheckoutProductSchema).nonempty(),
154+
invoice: PaidInvoiceSchema
155+
}),
156+
BaseCheckoutSchema.merge(AmountFieldsSchema).extend({
157+
status: z.literal("PAYMENT_RECEIVED"),
158+
type: z.literal("AMOUNT"),
159+
providedAmount: z.number(),
160+
invoice: PaidInvoiceSchema
161+
}),
162+
BaseCheckoutSchema.merge(AmountFieldsSchema).extend({
163+
status: z.literal("PAYMENT_RECEIVED"),
164+
type: z.literal("TOP_UP"),
165+
invoice: PaidInvoiceSchema
166+
})
167+
]);
168+
var CheckoutSchema = z.union([
169+
UnconfirmedCheckoutSchema,
170+
ConfirmedCheckoutSchema,
171+
PendingPaymentCheckoutSchema,
172+
PaymentReceivedCheckoutSchema,
173+
ExpiredCheckoutSchema
174+
]);
175+
176+
export {
177+
ExpiredCheckoutSchema,
178+
UnconfirmedCheckoutSchema,
179+
ConfirmedCheckoutSchema,
180+
PendingPaymentCheckoutSchema,
181+
PaymentReceivedCheckoutSchema,
182+
CheckoutSchema
183+
};

dist/chunk-6M6LFZ3U.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// src/schemas/currency.ts
2+
import { z } from "zod";
3+
var CurrencySchema = z.enum(["USD", "SAT"]);
4+
5+
export {
6+
CurrencySchema
7+
};

dist/chunk-6XWZHZXK.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import {
2+
CheckoutSchema
3+
} from "./chunk-7EZSTHMJ.js";
4+
import {
5+
CurrencySchema
6+
} from "./chunk-6M6LFZ3U.js";
7+
8+
// src/contracts/checkout.ts
9+
import { oc } from "@orpc/contract";
10+
import { z } from "zod";
11+
var emptyStringToUndefined = z.string().transform((val) => val.trim() === "" ? void 0 : val);
12+
var emailOrEmpty = z.string().email().optional().or(z.literal(""));
13+
var CustomerFieldSchema = z.string().min(1);
14+
var CustomerInputSchema = z.object({
15+
name: emptyStringToUndefined.optional(),
16+
email: emailOrEmpty,
17+
externalId: emptyStringToUndefined.optional()
18+
}).catchall(z.string());
19+
var CreateCheckoutInputSchema = z.object({
20+
nodeId: z.string(),
21+
amount: z.number().optional(),
22+
currency: CurrencySchema.optional(),
23+
products: z.array(z.string()).optional(),
24+
successUrl: z.string().optional(),
25+
allowDiscountCodes: z.boolean().optional(),
26+
metadata: z.record(z.string(), z.any()).optional(),
27+
/**
28+
* Customer data for this checkout.
29+
*/
30+
customer: CustomerInputSchema.optional(),
31+
/**
32+
* Array of customer fields to require at checkout.
33+
* If a field is listed here and not provided, the checkout UI will prompt for it.
34+
* @example ['email'] - require email
35+
* @example ['email', 'name'] - require both
36+
*/
37+
requireCustomerData: z.array(CustomerFieldSchema).optional()
38+
});
39+
var ConfirmCheckoutInputSchema = z.object({
40+
checkoutId: z.string(),
41+
/**
42+
* Customer data provided at confirm time.
43+
*/
44+
customer: CustomerInputSchema.optional(),
45+
/**
46+
* Product selection at confirm time.
47+
* - undefined or [] = keep current selection
48+
* - [{ productId }] = change selection to this product
49+
* - priceAmount required if selected price has amountType: CUSTOM
50+
*
51+
* Currently limited to single selection (max 1 item).
52+
*/
53+
products: z.array(
54+
z.object({
55+
productId: z.string(),
56+
priceAmount: z.number().optional()
57+
})
58+
).max(1).optional()
59+
});
60+
var ApplyDiscountCodeInputSchema = z.object({
61+
checkoutId: z.string(),
62+
discountCode: z.string()
63+
});
64+
var RegisterInvoiceInputSchema = z.object({
65+
nodeId: z.string(),
66+
scid: z.string(),
67+
checkoutId: z.string(),
68+
invoice: z.string(),
69+
paymentHash: z.string(),
70+
invoiceExpiresAt: z.date()
71+
});
72+
var PaymentReceivedInputSchema = z.object({
73+
payments: z.array(
74+
z.object({
75+
paymentHash: z.string(),
76+
amountSats: z.number(),
77+
sandbox: z.boolean().default(false)
78+
})
79+
)
80+
});
81+
var GetCheckoutInputSchema = z.object({ id: z.string() });
82+
var createCheckoutContract = oc.input(CreateCheckoutInputSchema).output(CheckoutSchema);
83+
var applyDiscountCodeContract = oc.input(ApplyDiscountCodeInputSchema).output(CheckoutSchema);
84+
var confirmCheckoutContract = oc.input(ConfirmCheckoutInputSchema).output(CheckoutSchema);
85+
var registerInvoiceContract = oc.input(RegisterInvoiceInputSchema).output(CheckoutSchema);
86+
var getCheckoutContract = oc.input(GetCheckoutInputSchema).output(CheckoutSchema);
87+
var paymentReceivedContract = oc.input(PaymentReceivedInputSchema).output(z.object({ ok: z.boolean() }));
88+
var checkout = {
89+
get: getCheckoutContract,
90+
create: createCheckoutContract,
91+
confirm: confirmCheckoutContract,
92+
registerInvoice: registerInvoiceContract,
93+
paymentReceived: paymentReceivedContract
94+
};
95+
96+
export {
97+
CustomerFieldSchema,
98+
CustomerInputSchema,
99+
CreateCheckoutInputSchema,
100+
ConfirmCheckoutInputSchema,
101+
ApplyDiscountCodeInputSchema,
102+
RegisterInvoiceInputSchema,
103+
PaymentReceivedInputSchema,
104+
GetCheckoutInputSchema,
105+
createCheckoutContract,
106+
applyDiscountCodeContract,
107+
confirmCheckoutContract,
108+
registerInvoiceContract,
109+
getCheckoutContract,
110+
paymentReceivedContract,
111+
checkout
112+
};

0 commit comments

Comments
 (0)