migrate Snapshot schemas to Effect Schema (#23747)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Cause, Duration, Effect, Layer, Schedule, Semaphore, Context, Stream } from "effect"
|
||||
import { Cause, Duration, Effect, Layer, Schedule, Schema, Semaphore, Context, Stream } from "effect"
|
||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
|
||||
import { formatPatch, structuredPatch } from "diff"
|
||||
import path from "path"
|
||||
@@ -10,25 +10,25 @@ import { Hash } from "@opencode-ai/shared/util/hash"
|
||||
import { Config } from "../config"
|
||||
import { Global } from "../global"
|
||||
import { Log } from "../util"
|
||||
import { withStatics } from "@/util/schema"
|
||||
import { zod } from "@/util/effect-zod"
|
||||
|
||||
export const Patch = z.object({
|
||||
hash: z.string(),
|
||||
files: z.string().array(),
|
||||
export const Patch = Schema.Struct({
|
||||
hash: Schema.String,
|
||||
files: Schema.mutable(Schema.Array(Schema.String)),
|
||||
}).pipe(withStatics((s) => ({ zod: zod(s) })))
|
||||
export type Patch = typeof Patch.Type
|
||||
|
||||
export const FileDiff = Schema.Struct({
|
||||
file: Schema.String,
|
||||
patch: Schema.String,
|
||||
additions: Schema.Number,
|
||||
deletions: Schema.Number,
|
||||
status: Schema.optional(Schema.Literals(["added", "deleted", "modified"])),
|
||||
})
|
||||
export type Patch = z.infer<typeof Patch>
|
||||
|
||||
export const FileDiff = z
|
||||
.object({
|
||||
file: z.string(),
|
||||
patch: z.string(),
|
||||
additions: z.number(),
|
||||
deletions: z.number(),
|
||||
status: z.enum(["added", "deleted", "modified"]).optional(),
|
||||
})
|
||||
.meta({
|
||||
ref: "SnapshotFileDiff",
|
||||
})
|
||||
export type FileDiff = z.infer<typeof FileDiff>
|
||||
.annotate({ identifier: "SnapshotFileDiff" })
|
||||
.pipe(withStatics((s) => ({ zod: zod(s) })))
|
||||
export type FileDiff = typeof FileDiff.Type
|
||||
|
||||
const log = Log.create({ service: "snapshot" })
|
||||
const prune = "7.days"
|
||||
|
||||
Reference in New Issue
Block a user