Files
cfw-autumn/shared/models/featureModels/featureModels.ts
John Yeo 3d0e4f94f2 wip
2025-09-29 11:15:23 +01:00

42 lines
931 B
TypeScript

import { z } from "zod/v4";
import { AppEnv } from "../genModels/genEnums.js";
import { FeatureType } from "./featureEnums.js";
export const FeatureSchema = z.object({
internal_id: z.string(),
org_id: z.string(),
created_at: z.number(),
env: z.nativeEnum(AppEnv),
id: z.string().nonempty(),
name: z.string().nonempty(),
type: z.nativeEnum(FeatureType),
config: z.any(),
display: z
.object({
singular: z.string().optional(),
plural: z.string().optional(),
})
.nullish(),
archived: z.boolean(),
});
export const CreateFeatureSchema = FeatureSchema.pick({
id: true,
name: true,
type: true,
config: true,
display: true,
});
export const MinFeatureSchema = z.object({
internal_id: z.string(),
id: z.string(),
name: z.string(),
type: z.nativeEnum(FeatureType),
config: z.any(),
});
export type Feature = z.infer<typeof FeatureSchema>;
export type CreateFeature = z.infer<typeof CreateFeatureSchema>;