refactor(core): migrate MessageV2 internal Cursor to Effect Schema (#23763)
This commit is contained in:
@@ -638,18 +638,20 @@ export type WithParts = {
|
|||||||
parts: Part[]
|
parts: Part[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Cursor = z.object({
|
const Cursor = Schema.Struct({
|
||||||
id: MessageID.zod,
|
id: MessageID,
|
||||||
time: z.number(),
|
time: Schema.Number,
|
||||||
})
|
})
|
||||||
type Cursor = z.infer<typeof Cursor>
|
type Cursor = typeof Cursor.Type
|
||||||
|
|
||||||
|
const decodeCursor = Schema.decodeUnknownSync(Cursor)
|
||||||
|
|
||||||
export const cursor = {
|
export const cursor = {
|
||||||
encode(input: Cursor) {
|
encode(input: Cursor) {
|
||||||
return Buffer.from(JSON.stringify(input)).toString("base64url")
|
return Buffer.from(JSON.stringify(input)).toString("base64url")
|
||||||
},
|
},
|
||||||
decode(input: string) {
|
decode(input: string) {
|
||||||
return Cursor.parse(JSON.parse(Buffer.from(input, "base64url").toString("utf8")))
|
return decodeCursor(JSON.parse(Buffer.from(input, "base64url").toString("utf8")))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user