Skip to content

Commit 7d4ed27

Browse files
npslaneyclaude
andcommitted
refactor: deduplicate schemas per PR review
- Replace inline CheckoutCustomerSchema with CustomerSchema.nullable() - Remove unnecessary OrderDetailSchema alias Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1d8ac06 commit 7d4ed27

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

src/contracts/checkout.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { oc } from "@orpc/contract";
22
import { z } from "zod";
33
import { CheckoutSchema } from "../schemas/checkout";
4+
import { CustomerSchema } from "../schemas/customer";
45
import { CurrencySchema } from "../schemas/currency";
56
import {
67
PaginationInputSchema,
@@ -168,19 +169,7 @@ export const listCheckoutsContract = oc
168169
.output(ListCheckoutsOutputSchema);
169170

170171
// MCP-specific embedded customer schema
171-
const CheckoutCustomerSchema = z
172-
.object({
173-
id: z.string(),
174-
name: z.string().nullable(),
175-
email: z.string().nullable(),
176-
emailVerified: z.boolean(),
177-
externalId: z.string().nullable(),
178-
userMetadata: z.record(z.unknown()).nullable(),
179-
organizationId: z.string(),
180-
createdAt: z.date(),
181-
modifiedAt: z.date().nullable(),
182-
})
183-
.nullable();
172+
const CheckoutCustomerSchema = CustomerSchema.nullable();
184173

185174
// MCP-specific summary schema for list (simpler than full CheckoutSchema)
186175
const CheckoutListItemSchema = z.object({

src/contracts/order.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ import {
77
PaginationOutputSchema,
88
} from "../schemas/pagination";
99

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

16-
// Order with full details for get view
17-
const OrderDetailSchema = OrderWithRelationsSchema;
18-
1916
const ListOrdersInputSchema = PaginationInputSchema.extend({
2017
customerId: z.string().optional(),
2118
status: z.string().optional(), // Prisma uses String type for status
@@ -31,7 +28,7 @@ export const listOrdersContract = oc
3128

3229
export const getOrderContract = oc
3330
.input(z.object({ id: z.string() }))
34-
.output(OrderDetailSchema);
31+
.output(OrderWithRelationsSchema);
3532

3633
export const order = {
3734
list: listOrdersContract,

0 commit comments

Comments
 (0)