feat: parse all quest

This commit is contained in:
Justin Lin committed 2025-04-16 19:06:47 +08:00
1 parent ed4d04b658
commit 61d1871e95
9 files changed
+77 -18

No files matched your search

+5 -4
View File
@@ -1,11 +1,12 @@
import { z } from 'zod'
import { fileConditionSchema } from './file-condition.js'
import { toArray } from '../utils.js'
export const conditionSchema = z.object({
command: z.array(z.string()).optional(),
output: z.array(z.string()).optional(),
error: z.array(z.string()).optional(),
pwd: z.array(z.string()).optional(),
command: z.preprocess(toArray, z.array(z.string()).optional()),
output: z.preprocess(toArray, z.array(z.string()).optional()),
error: z.preprocess(toArray, z.array(z.string()).optional()),
pwd: z.preprocess(toArray, z.array(z.string()).optional()),
files: z.array(fileConditionSchema).optional(),
})
+2 -1
View File
@@ -1,8 +1,9 @@
import { z } from 'zod'
import { toArray } from '../utils.js'
export const responseSchema = z.object({
type: z.enum(['narrative', 'dialogue']).default('narrative'),
content: z.string(),
content: z.preprocess(toArray, z.array(z.string())),
})
export type Response = z.infer<typeof responseSchema>
+1 -1
View File
@@ -8,7 +8,7 @@ import { requirementSchema } from './requirement.js'
export const stageSchema = z.object({
id: z.string(),
task: z.string(),
exceptions: z.array(stageExceptionSchema).default([]),
exceptions: stageExceptionSchema.array().default([]),
requirements: requirementSchema,
condition: conditionSchema,
responses: z.array(responseSchema),
+1
View File
@@ -0,0 +1 @@
export const toArray = (val: unknown) => (typeof val === 'string' ? [val] : val)