feat(chat): handle credit-gated send responses
This commit is contained in:
@@ -3,17 +3,24 @@
|
||||
*
|
||||
*/
|
||||
import { z } from "zod";
|
||||
import { booleanOrFalse, stringOrNull } from "../nullable-defaults";
|
||||
import { ChatImageSchema, ChatLockDetailSchema } from "./chat_payloads";
|
||||
|
||||
export const ChatSendResponseSchema = z.object({
|
||||
reply: z.string(),
|
||||
audioUrl: z.string().default(""),
|
||||
messageId: z.string(),
|
||||
isGuest: z.boolean().default(false),
|
||||
isGuest: booleanOrFalse,
|
||||
// 函数式 default —— 每次 parse 时重新调 Date.now()(后端不返回 timestamp 时用当下时间)
|
||||
timestamp: z.number().default(() => Date.now()),
|
||||
image: ChatImageSchema,
|
||||
lockDetail: ChatLockDetailSchema,
|
||||
canSendMessage: z.boolean().default(true),
|
||||
cannotSendReason: stringOrNull,
|
||||
creditBalance: z.number().default(0),
|
||||
creditsCharged: z.number().default(0),
|
||||
requiredCredits: z.number().default(0),
|
||||
shortfallCredits: z.number().default(0),
|
||||
});
|
||||
|
||||
export type ChatSendResponseInput = z.input<typeof ChatSendResponseSchema>;
|
||||
|
||||
Reference in New Issue
Block a user