mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: parse all quest
This commit is contained in:
1 parent
ed4d04b658
commit
61d1871e95
9 files changed
+77
-18
No files matched your search
@@ -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(),
|
||||
})
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -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),
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const toArray = (val: unknown) => (typeof val === 'string' ? [val] : val)
|
||||
Reference in new issue
Block a user