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,38 +1,35 @@
import { z } from "zod/v4";
export enum APIFeatureType {
export enum ApiFeatureType {
Static = "static", // legacy (will deprecate)
Boolean = "boolean",
SingleUsage = "single_use",
ContinuousUse = "continuous_use",
CreditSystem = "credit_system",
}
export const APIFeatureSchema = z
.object({
id: z.string(),
name: z.string().nullish(),
type: z.nativeEnum(APIFeatureType),
display: z
.object({
singular: z.string(),
plural: z.string(),
})
.nullish(),
// Base schema without .meta() to avoid side effects during imports
export const ApiFeatureSchema = z.object({
id: z.string(),
name: z.string().nullish(),
type: z.enum(ApiFeatureType),
display: z
.object({
singular: z.string(),
plural: z.string(),
})
.nullish(),
credit_schema: z
.array(
z.object({
metered_feature_id: z.string(),
credit_cost: z.number(),
}),
)
.nullish(),
credit_schema: z
.array(
z.object({
metered_feature_id: z.string(),
credit_cost: z.number(),
}),
)
.nullish(),
archived: z.boolean().nullish(),
})
.meta({
id: "Feature",
description: "Feature object returned by the API",
});
archived: z.boolean().nullish(),
});
export type APIFeature = z.infer<typeof APIFeatureSchema>;
export type ApiFeature = z.infer<typeof ApiFeatureSchema>;