Files
cozsweet-frontend-nextjs/src/stores/chat/chat-events.ts
T
Codex 74b7eae18b
Docker Image / Build and Push Docker Image (push) Successful in 2m14s
feat(payment): add chat support discounts and gratitude
(cherry picked from commit ef9b79bc83)
2026-07-28 17:54:36 +08:00

72 lines
2.3 KiB
TypeScript

/**
* Public events for one character-scoped Chat actor.
* Authentication synchronization dispatches the lifecycle events; history,
* quota, send, and unlock side effects remain owned by the machine.
*/
import type { PendingChatUnlockKind } from "@/lib/navigation/chat_unlock_session";
import type { ChatLockType } from "@/data/schemas/chat";
import type { PendingChatPromotion } from "@/data/storage/navigation";
export type ChatEvent =
// Authentication lifecycle dispatched by ChatAuthSync.
| { type: "ChatGuestLogin" }
| { type: "ChatUserLogin"; token: string }
| { type: "ChatLogout" }
| {
type: "ChatLocalHistoryLoaded";
output: import("./chat-history-sync").LocalHistorySnapshotOutput;
}
| {
type: "ChatNetworkHistoryLoaded";
output: import("./chat-history-sync").NetworkHistorySyncOutput;
}
| { type: "ChatHistoryLoadFailed"; error: unknown }
| { type: "ChatLoadMoreHistoryRequested" }
| {
type: "ChatOlderHistoryLoaded";
output: import("./machine/actors/history").LoadMoreHistoryOutput;
}
| { type: "ChatOlderHistoryLoadFailed"; error: unknown }
| { type: "ChatHistoryRefreshRequested" }
| {
type: "ChatCommercialMessageReceived";
message: {
messageId: string;
message: string;
characterId: string;
createdAt: string;
};
}
// Chat domain events.
| { type: "ChatSendMessage"; content: string }
| { type: "ChatSendImage"; imageBase64: string }
| {
type: "ChatPromotionInjected";
promotion: PendingChatPromotion;
messageId?: string;
}
| { type: "ChatPromotionCleared" }
| {
type: "ChatUnlockMessageRequested";
displayMessageId: string;
remoteMessageId?: string;
kind: PendingChatUnlockKind;
lockType?: ChatLockType;
clientLockId?: string;
}
| { type: "ChatUnlockPaywallNavigationConsumed" }
| { type: "ChatPaymentSucceeded" }
| { type: "ChatUnlockHistoryConfirmed" }
| { type: "ChatUnlockHistoryDismissed" }
| { type: "ChatQueuedSendStarted" }
| {
type: "ChatQueuedHttpDone";
output: import("./helper/send-state").HttpSendOutput;
}
| {
type: "ChatQueuedSendError";
content: string;
errorMessage: string;
characterErrorCode?: import("@/data/services/api").CharacterErrorCode;
};