11import { z } from "zod" ;
2- import { CurrencySchema } from "./currency" ;
3- import {
4- RecurringIntervalSchema ,
5- SubscriptionStatusSchema ,
6- } from "./subscription" ;
2+ import { SubscriptionSchema } from "./subscription" ;
73
84/**
9- * Summary of a subscription for the customer response.
10- * Contains the essential fields needed for displaying subscription status.
5+ * Customer schema for API responses.
6+ * Represents a customer in the organization (admin view).
7+ * Note: Uses modifiedAt to match Prisma schema naming.
118 */
12- export const CustomerSubscriptionSchema = z . object ( {
9+ export const CustomerSchema = z . object ( {
1310 id : z . string ( ) ,
14- productId : z . string ( ) ,
15- status : SubscriptionStatusSchema ,
16- currentPeriodStart : z . string ( ) . datetime ( ) ,
17- currentPeriodEnd : z . string ( ) . datetime ( ) ,
18- cancelAtPeriodEnd : z . boolean ( ) . optional ( ) ,
19- amount : z . number ( ) ,
20- currency : CurrencySchema ,
21- recurringInterval : RecurringIntervalSchema ,
11+ name : z . string ( ) . nullable ( ) ,
12+ email : z . string ( ) . nullable ( ) ,
13+ emailVerified : z . boolean ( ) ,
14+ externalId : z . string ( ) . nullable ( ) ,
15+ userMetadata : z . record ( z . string ( ) , z . any ( ) ) . nullable ( ) ,
16+ organizationId : z . string ( ) ,
17+ createdAt : z . date ( ) ,
18+ modifiedAt : z . date ( ) . nullable ( ) ,
2219} ) ;
2320
2421/**
25- * Customer data with their subscriptions.
22+ * Customer data with their full subscriptions.
2623 * Returned by the SDK customer.get endpoint.
2724 */
28- export const CustomerSchema = z . object ( {
25+ export const CustomerWithSubscriptionsSchema = z . object ( {
2926 id : z . string ( ) ,
3027 email : z . string ( ) . nullable ( ) . optional ( ) ,
3128 name : z . string ( ) . nullable ( ) . optional ( ) ,
3229 externalId : z . string ( ) . nullable ( ) . optional ( ) ,
33- subscriptions : z . array ( CustomerSubscriptionSchema ) ,
30+ subscriptions : z . array ( SubscriptionSchema ) ,
3431} ) ;
3532
3633/**
@@ -56,24 +53,8 @@ export const GetCustomerInputSchema = z
5653 } ,
5754 ) ;
5855
59- /**
60- * Customer schema for MCP API responses.
61- * Represents a customer in the organization (admin view).
62- * Note: Uses modifiedAt to match Prisma schema naming.
63- */
64- export const McpCustomerSchema = z . object ( {
65- id : z . string ( ) ,
66- name : z . string ( ) . nullable ( ) ,
67- email : z . string ( ) . nullable ( ) ,
68- emailVerified : z . boolean ( ) ,
69- externalId : z . string ( ) . nullable ( ) ,
70- userMetadata : z . record ( z . string ( ) , z . any ( ) ) . nullable ( ) ,
71- organizationId : z . string ( ) ,
72- createdAt : z . date ( ) ,
73- modifiedAt : z . date ( ) . nullable ( ) ,
74- } ) ;
75-
76- export type CustomerSubscription = z . infer < typeof CustomerSubscriptionSchema > ;
7756export type Customer = z . infer < typeof CustomerSchema > ;
78- export type McpCustomer = z . infer < typeof McpCustomerSchema > ;
57+ export type CustomerWithSubscriptions = z . infer <
58+ typeof CustomerWithSubscriptionsSchema
59+ > ;
7960export type GetCustomerInput = z . infer < typeof GetCustomerInputSchema > ;
0 commit comments