aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/types/prompts.ts
blob: e02208e7bf92e1ff8960fc48db31b4a3c3014bcf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { z } from "zod";

const MAX_PROMPT_TEXT_LENGTH = 500;

export const zAppliesToEnumSchema = z.enum([
  "all_tagging",
  "text",
  "images",
  "summary",
]);

export const zPromptSchema = z.object({
  id: z.string(),
  text: z.string(),
  enabled: z.boolean(),
  appliesTo: zAppliesToEnumSchema,
});

export type ZPrompt = z.infer<typeof zPromptSchema>;

export const zNewPromptSchema = z.object({
  text: z.string().min(1).max(MAX_PROMPT_TEXT_LENGTH),
  appliesTo: zAppliesToEnumSchema,
});

export const zUpdatePromptSchema = z.object({
  promptId: z.string(),
  text: z.string().max(MAX_PROMPT_TEXT_LENGTH).optional(),
  appliesTo: zAppliesToEnumSchema.optional(),
  enabled: z.boolean().optional(),
});