refactor: remove unused quest-related schemas and consolidate exports

This commit is contained in:
Justin Lin committed 2025-04-21 21:42:54 +08:00
1 parent d2cdd1304a
commit 1d843f7355
29 files changed
+35 -161

No files matched your search

-1
View File
@@ -1,6 +1,5 @@
import { z } from 'zod'
export * from './quest/index.js'
export * from './session.js'
export const passwordPolicy = {
@@ -1,11 +0,0 @@
import { z } from 'zod'
import { conditionSchema } from './condition.js'
import { responseSchema } from './response.js'
export const commandResponderSchema = z.object({
condition: conditionSchema.optional(),
responses: z.array(responseSchema),
hints: z.array(z.string()),
})
export type CommandResponder = z.infer<typeof commandResponderSchema>
-21
View File
@@ -1,21 +0,0 @@
import { z } from 'zod'
import { fileConditionSchema } from './file-condition.js'
import { toArray } from '../utils.js'
const conditionSchemaBase = z.object({
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(),
})
export type Condition = z.infer<typeof conditionSchemaBase> & {
not?: Condition
or?: Condition[]
}
export const conditionSchema = conditionSchemaBase.extend({
not: z.lazy(() => conditionSchema).optional(),
or: z.lazy(() => z.array(conditionSchema)).optional(),
}) as z.ZodType<Condition>
-22
View File
@@ -1,22 +0,0 @@
import { z } from 'zod'
import { conditionSchema } from './condition.js'
import { responseSchema } from './response.js'
export const exceptionSchema = z.object({
condition: conditionSchema,
responses: z.array(responseSchema),
})
export type Exception = z.infer<typeof exceptionSchema>
export const stageExceptionSchema = exceptionSchema.extend({
catchAll: z.boolean().default(false),
})
export type StageException = z.infer<typeof stageExceptionSchema>
export const globalExceptionSchema = exceptionSchema.extend({
requirements: z.array(z.string()),
})
export type GlobalException = z.infer<typeof globalExceptionSchema>
@@ -1,9 +0,0 @@
import { z } from 'zod'
export const fileConditionSchema = z.object({
path: z.string(),
type: z.string().optional(),
exists: z.boolean().default(true),
})
export type FileCondition = z.infer<typeof fileConditionSchema>
-5
View File
@@ -1,5 +0,0 @@
import { z } from 'zod'
export const hintSchema = z.array(z.string())
export type Hint = z.infer<typeof hintSchema>
-11
View File
@@ -1,11 +0,0 @@
export * from './requirement.js'
export * from './hint.js'
export * from './file-condition.js'
export * from './condition.js'
export * from './response.js'
export * from './command-responder.js'
export * from './stage-exception.js'
export * from './stage.js'
export * from './exception.js'
export * from './quest.js'
export * from './quest-detail-response.js'
@@ -1,10 +0,0 @@
import { z } from 'zod'
export const questDetailResponseSchema = z.object({
id: z.string(),
title: z.string(),
instruction: z.string(),
requirements: z.array(z.string()),
})
export type QuestDetailResponse = z.infer<typeof questDetailResponseSchema>
-16
View File
@@ -1,16 +0,0 @@
import { z } from 'zod'
import { stageSchema } from './stage.js'
import { globalExceptionSchema } from './exception.js'
import { requirementSchema } from './requirement.js'
export const questSchema = z.object({
id: z.string(),
title: z.string(),
image: z.string(),
instruction: z.string(),
requirements: requirementSchema,
stages: z.array(stageSchema),
exceptions: z.array(globalExceptionSchema).default([]),
})
export type Quest = z.infer<typeof questSchema>
@@ -1,5 +0,0 @@
import { z } from 'zod'
export const requirementSchema = z.array(z.string()).default([])
export type Requirement = z.infer<typeof requirementSchema>
-9
View File
@@ -1,9 +0,0 @@
import { z } from 'zod'
import { toArray } from '../utils.js'
export const responseSchema = z.object({
type: z.enum(['narrative', 'dialogue']).default('narrative'),
content: z.preprocess(toArray, z.array(z.string())),
})
export type Response = z.infer<typeof responseSchema>
-18
View File
@@ -1,18 +0,0 @@
import { z } from 'zod'
import { stageExceptionSchema } from './exception.js'
import { conditionSchema } from './condition.js'
import { responseSchema } from './response.js'
import { hintSchema } from './hint.js'
import { requirementSchema } from './requirement.js'
export const stageSchema = z.object({
id: z.string(),
task: z.string(),
exceptions: stageExceptionSchema.array().default([]),
requirements: requirementSchema,
condition: conditionSchema,
responses: z.array(responseSchema),
hints: hintSchema.default([]),
})
export type Stage = z.infer<typeof stageSchema>