mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: add stage exceptions
This commit is contained in:
1 parent
f7780c3d98
commit
fb823814e0
11 files changed
+123
-43
No files matched your search
@@ -31,3 +31,7 @@ export const conditionSchema: z.ZodType<ICondition> =
|
||||
or: z.lazy(() => z.array(conditionSchema).optional()),
|
||||
not: z.lazy(() => conditionSchema.optional()),
|
||||
})
|
||||
|
||||
export interface IFileExistenceChecker {
|
||||
exists(file: IFileInput): Promise<boolean>
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { z } from 'zod'
|
||||
import { conditionSchema } from './condition.js'
|
||||
import { responseSchema } from './response.js'
|
||||
|
||||
export const exceptionSchema = z.object({
|
||||
id: z.string(),
|
||||
condition: conditionSchema,
|
||||
response: 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,4 +1,4 @@
|
||||
export { conditionSchema, ICondition } from './condition.js'
|
||||
export * from './condition.js'
|
||||
export { stageSchema, IStage } from './stage.js'
|
||||
export { requirementsSchema, IRequirements } from './requirements.js'
|
||||
export { responseSchema, IResponse } from './response.js'
|
||||
@@ -11,24 +11,6 @@ export interface ICommand {
|
||||
pwd?: string
|
||||
}
|
||||
|
||||
export enum FileType {
|
||||
FILE = 'file',
|
||||
FOLDER = 'folder',
|
||||
}
|
||||
|
||||
export interface FileInput {
|
||||
path: string
|
||||
type: FileType
|
||||
}
|
||||
|
||||
export interface FileExistenceInput extends FileInput {
|
||||
exists: boolean
|
||||
}
|
||||
|
||||
export interface IFileExistenceChecker {
|
||||
exists(file: FileInput): Promise<boolean>
|
||||
}
|
||||
|
||||
export interface ISession {
|
||||
completedStages: string[]
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import { conditionSchema } from './condition.js'
|
||||
import { responseSchema } from './response.js'
|
||||
import { stageExceptionSchema } from './exception.js'
|
||||
|
||||
export const stageSchema = z.object({
|
||||
id: z.string().regex(/^[a-zA-Z0-9_-]+$/),
|
||||
@@ -8,6 +9,7 @@ export const stageSchema = z.object({
|
||||
requirements: z.array(z.string()),
|
||||
condition: conditionSchema,
|
||||
response: responseSchema,
|
||||
exceptions: stageExceptionSchema.array().optional(),
|
||||
})
|
||||
|
||||
export type IStage = z.infer<typeof stageSchema>
|
||||
Reference in new issue
Block a user