mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 21:16:06 +00:00
refactor(question): use withStatics for answer schema
Replace the ad hoc Object.assign wrapper with the shared schema helper so the Answer schema follows the same static attachment pattern as the rest of the codebase.
This commit is contained in:
parent
dd34bd8203
commit
2f60f9d45b
1 changed files with 5 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ import { InstanceState } from "@/effect/instance-state"
|
|||
import { SessionID, MessageID } from "@/session/schema"
|
||||
import { zod } from "@/util/effect-zod"
|
||||
import { Log } from "@/util/log"
|
||||
import { withStatics } from "@/util/schema"
|
||||
import { QuestionID } from "./schema"
|
||||
|
||||
export namespace Question {
|
||||
|
|
@ -69,9 +70,10 @@ export namespace Question {
|
|||
static readonly zod = zod(this)
|
||||
}
|
||||
|
||||
const _Answer = Schema.Array(Schema.String).annotate({ identifier: "QuestionAnswer" })
|
||||
export const Answer = Object.assign(_Answer, { zod: zod(_Answer) })
|
||||
export type Answer = Schema.Schema.Type<typeof _Answer>
|
||||
export const Answer = Schema.Array(Schema.String)
|
||||
.annotate({ identifier: "QuestionAnswer" })
|
||||
.pipe(withStatics((s) => ({ zod: zod(s) })))
|
||||
export type Answer = Schema.Schema.Type<typeof Answer>
|
||||
|
||||
export class Reply extends Schema.Class<Reply>("QuestionReply")({
|
||||
answers: Schema.Array(Answer).annotate({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue