Skip to content

Commit 23024e3

Browse files
npslaneyclaude
andcommitted
feat: export CheckoutStatus, CheckoutType, PriceAmountType types and schemas
- Export CheckoutStatusSchema, CheckoutTypeSchema from contracts/checkout.ts - Export PriceAmountTypeSchema from schemas/product-price-input.ts - Use McpCustomerSchema for embedded customer in order/checkout contracts - Fix mcpContract.customer to only include MCP routes (exclude getSdk) - Remove customer/subscription from sdkContract (not yet implemented) - Bump version to 0.1.20 Addresses PR #498 feedback about type re-definitions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 29b2180 commit 23024e3

4 files changed

Lines changed: 28 additions & 14 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moneydevkit/api-contract",
3-
"version": "0.1.19",
3+
"version": "0.1.20",
44
"description": "API Contract for moneydevkit",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.js",

src/contracts/checkout.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { oc } from "@orpc/contract";
22
import { z } from "zod";
33
import { CheckoutSchema } from "../schemas/checkout";
44
import { CurrencySchema } from "../schemas/currency";
5-
import { CustomerSchema } from "../schemas/customer";
5+
import { McpCustomerSchema } from "../schemas/customer";
66
import {
77
PaginationInputSchema,
88
PaginationOutputSchema,
@@ -148,13 +148,17 @@ export const paymentReceivedContract = oc
148148
.output(z.object({ ok: z.boolean() }));
149149

150150
// List checkouts schemas
151-
const CheckoutStatusSchema = z.enum([
151+
export const CheckoutStatusSchema = z.enum([
152152
"UNCONFIRMED",
153153
"CONFIRMED",
154154
"PENDING_PAYMENT",
155155
"PAYMENT_RECEIVED",
156156
"EXPIRED",
157157
]);
158+
export type CheckoutStatus = z.infer<typeof CheckoutStatusSchema>;
159+
160+
export const CheckoutTypeSchema = z.enum(["PRODUCTS", "AMOUNT", "TOP_UP"]);
161+
export type CheckoutType = z.infer<typeof CheckoutTypeSchema>;
158162

159163
const ListCheckoutsInputSchema = PaginationInputSchema.extend({
160164
status: CheckoutStatusSchema.optional(),
@@ -168,14 +172,14 @@ export const listCheckoutsContract = oc
168172
.input(ListCheckoutsInputSchema)
169173
.output(ListCheckoutsOutputSchema);
170174

171-
// MCP-specific embedded customer schema
172-
const CheckoutCustomerSchema = CustomerSchema.nullable();
175+
// MCP-specific embedded customer schema (uses admin customer schema, not SDK customer)
176+
const CheckoutCustomerSchema = McpCustomerSchema.nullable();
173177

174178
// MCP-specific summary schema for list (simpler than full CheckoutSchema)
175179
const CheckoutListItemSchema = z.object({
176180
id: z.string(),
177181
status: CheckoutStatusSchema,
178-
type: z.enum(["PRODUCTS", "AMOUNT", "TOP_UP"]),
182+
type: CheckoutTypeSchema,
179183
currency: CurrencySchema,
180184
totalAmount: z.number().nullable(),
181185
customerId: z.string().nullable(),

src/contracts/order.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { oc } from "@orpc/contract";
22
import { z } from "zod";
3-
import { CustomerSchema } from "../schemas/customer";
3+
import { McpCustomerSchema } from "../schemas/customer";
44
import { OrderItemSchema, OrderSchema } from "../schemas/order";
55
import {
66
PaginationInputSchema,
77
PaginationOutputSchema,
88
} from "../schemas/pagination";
99

10-
// Order with related data for list and get views
10+
// Order with related data for list and get views (MCP uses admin customer schema)
1111
const OrderWithRelationsSchema = OrderSchema.extend({
12-
customer: CustomerSchema.nullable(),
12+
customer: McpCustomerSchema.nullable(),
1313
orderItems: z.array(OrderItemSchema),
1414
});
1515

src/index.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ import { products } from "./contracts/products";
66
import { subscription } from "./contracts/subscription";
77

88
export type {
9+
CheckoutStatus,
10+
CheckoutType,
911
ConfirmCheckout,
1012
CreateCheckout,
1113
PaymentReceived,
1214
RegisterInvoice,
1315
} from "./contracts/checkout";
16+
export {
17+
CheckoutStatusSchema,
18+
CheckoutTypeSchema,
19+
} from "./contracts/checkout";
1420
export type {
1521
BootstrapOnboarding,
1622
BootstrapOnboardingResponse,
@@ -75,10 +81,12 @@ export {
7581
PaginationOutputSchema,
7682
} from "./schemas/pagination";
7783
export type {
84+
PriceAmountType,
7885
ProductPriceInput,
7986
RecurringIntervalInput,
8087
} from "./schemas/product-price-input";
8188
export {
89+
PriceAmountTypeSchema,
8290
ProductPriceInputSchema,
8391
RecurringIntervalInputSchema,
8492
} from "./schemas/product-price-input";
@@ -102,19 +110,21 @@ export const sdkContract = {
102110
registerInvoice: checkout.registerInvoice,
103111
paymentReceived: checkout.paymentReceived,
104112
},
105-
customer: {
106-
get: customer.getSdk,
107-
},
108113
onboarding,
109114
products: {
110115
list: products.list,
111116
},
112-
subscription,
113117
};
114118

115119
// MCP contract - only the methods the MCP router implements
116120
export const mcpContract = {
117-
customer,
121+
customer: {
122+
list: customer.list,
123+
get: customer.get,
124+
create: customer.create,
125+
update: customer.update,
126+
delete: customer.delete,
127+
},
118128
order,
119129
checkout: {
120130
list: checkout.listSummary,

0 commit comments

Comments
 (0)