working on get api cus feature

This commit is contained in:
John Yeo
2025-10-06 14:16:51 +01:00
parent a997947db8
commit feca672fab
84 changed files with 2591 additions and 1984 deletions

View File

@@ -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;
};

View File

@@ -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>;

View File

@@ -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>;