working on get api cus feature
This commit is contained in:
@@ -1,9 +1,29 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const SuccessResponseSchema = z
|
||||
.object({
|
||||
success: z.boolean(),
|
||||
})
|
||||
.meta({
|
||||
id: "SuccessResponse",
|
||||
// Base schema without .meta() to avoid side effects during imports
|
||||
export const SuccessResponseSchema = z.object({
|
||||
success: z.boolean(),
|
||||
});
|
||||
|
||||
export const getListResponseSchema = ({
|
||||
schema,
|
||||
id,
|
||||
description,
|
||||
}: {
|
||||
schema: z.ZodType;
|
||||
id?: string;
|
||||
description?: string;
|
||||
}) => {
|
||||
const listResponse = z.object({
|
||||
list: z.array(schema),
|
||||
});
|
||||
|
||||
if (id || description) {
|
||||
listResponse.meta({
|
||||
id,
|
||||
description,
|
||||
});
|
||||
}
|
||||
|
||||
return listResponse;
|
||||
};
|
||||
|
||||
@@ -1,35 +1,32 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const CustomerDataSchema = z
|
||||
.object({
|
||||
name: z.string().nullish().meta({
|
||||
description: "Customer's name",
|
||||
example: "John Doe",
|
||||
// Base schema without top-level .meta() to avoid side effects during imports
|
||||
// Individual field descriptions are kept as they don't cause registry conflicts
|
||||
export const CustomerDataSchema = z.object({
|
||||
name: z.string().nullish().meta({
|
||||
description: "Customer's name",
|
||||
example: "John Doe",
|
||||
}),
|
||||
email: z.string().nullish().meta({
|
||||
description: "Customer's email address",
|
||||
example: "john@example.com",
|
||||
}),
|
||||
fingerprint: z.string().nullish().meta({
|
||||
description:
|
||||
"Unique identifier (eg, serial number) to detect duplicate customers and prevent free trial abuse",
|
||||
example: "fp_123abc",
|
||||
}),
|
||||
metadata: z
|
||||
.record(z.any(), z.any())
|
||||
.nullish()
|
||||
.meta({
|
||||
description: "Additional metadata for the customer",
|
||||
example: { company: "Acme Inc" },
|
||||
}),
|
||||
email: z.string().nullish().meta({
|
||||
description: "Customer's email address",
|
||||
example: "john@example.com",
|
||||
}),
|
||||
fingerprint: z.string().nullish().meta({
|
||||
description:
|
||||
"Unique identifier (eg, serial number) to detect duplicate customers and prevent free trial abuse",
|
||||
example: "fp_123abc",
|
||||
}),
|
||||
metadata: z
|
||||
.record(z.any(), z.any())
|
||||
.nullish()
|
||||
.meta({
|
||||
description: "Additional metadata for the customer",
|
||||
example: { company: "Acme Inc" },
|
||||
}),
|
||||
stripe_id: z.string().nullish().meta({
|
||||
description: "Stripe customer ID if you already have one",
|
||||
example: "cus_stripe123",
|
||||
}),
|
||||
})
|
||||
.meta({
|
||||
id: "CustomerData",
|
||||
description: "Customer data for creating or updating a customer",
|
||||
});
|
||||
stripe_id: z.string().nullish().meta({
|
||||
description: "Stripe customer ID if you already have one",
|
||||
example: "cus_stripe123",
|
||||
}),
|
||||
});
|
||||
|
||||
export type CustomerData = z.infer<typeof CustomerDataSchema>;
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const EntityDataSchema = z
|
||||
.object({
|
||||
feature_id: z.string().meta({
|
||||
description: "The feature ID that this entity is associated with",
|
||||
example: "seats",
|
||||
}),
|
||||
name: z.string().optional().meta({
|
||||
description: "Name of the entity",
|
||||
example: "Team Alpha",
|
||||
}),
|
||||
})
|
||||
.meta({
|
||||
id: "EntityData",
|
||||
description: "Entity data for creating an entity",
|
||||
});
|
||||
// Base schema without top-level .meta() to avoid side effects during imports
|
||||
export const EntityDataSchema = z.object({
|
||||
feature_id: z.string().meta({
|
||||
description: "The feature ID that this entity is associated with",
|
||||
example: "seats",
|
||||
}),
|
||||
name: z.string().optional().meta({
|
||||
description: "Name of the entity",
|
||||
example: "Team Alpha",
|
||||
}),
|
||||
});
|
||||
|
||||
export type EntityData = z.infer<typeof EntityDataSchema>;
|
||||
|
||||
Reference in New Issue
Block a user