chore(chat): tipar cliente Convex do desktop sem any

This commit is contained in:
esdrasrenan 2025-12-09 01:04:53 -03:00
parent a8f5ff9d51
commit f8a472ee46

View file

@ -1,4 +1,5 @@
import { ConvexClient } from "convex/browser"
import type { FunctionReference } from "convex/server"
import { Store } from "@tauri-apps/plugin-store"
import { appLocalDataDir, join } from "@tauri-apps/api/path"
import type { ChatMessage } from "./types"
@ -33,6 +34,12 @@ type MachineUpdatePayload = {
totalUnread: number
}
const FN_CHECK_UPDATES = "liveChat.checkMachineUpdates" as const
const FN_LIST_MESSAGES = "liveChat.listMachineMessages" as const
const FN_POST_MESSAGE = "liveChat.postMachineMessage" as const
const FN_MARK_READ = "liveChat.markMachineMessagesRead" as const
const FN_UPLOAD_URL = "liveChat.generateMachineUploadUrl" as const
async function loadStore(): Promise<MachineStoreData> {
const appData = await appLocalDataDir()
const storePath = await join(appData, STORE_FILENAME)
@ -86,7 +93,7 @@ export async function subscribeMachineUpdates(
): Promise<() => void> {
const { client, token } = await ensureClient()
const sub = client.onUpdate(
FN_CHECK_UPDATES as any,
FN_CHECK_UPDATES as unknown as FunctionReference<"query">,
{ machineToken: token },
(value) => callback(value),
onError
@ -101,7 +108,7 @@ export async function subscribeMachineMessages(
): Promise<() => void> {
const { client, token } = await ensureClient()
const sub = client.onUpdate(
FN_LIST_MESSAGES as any,
FN_LIST_MESSAGES as unknown as FunctionReference<"query">,
{
machineToken: token,
ticketId,
@ -123,7 +130,7 @@ export async function sendMachineMessage(input: {
}>
}) {
const { client, token } = await ensureClient()
return client.mutation(FN_POST_MESSAGE as any, {
return client.mutation(FN_POST_MESSAGE as unknown as FunctionReference<"mutation">, {
machineToken: token,
ticketId: input.ticketId,
body: input.body,
@ -139,7 +146,7 @@ export async function sendMachineMessage(input: {
export async function markMachineMessagesRead(ticketId: string, messageIds: string[]) {
if (messageIds.length === 0) return
const { client, token } = await ensureClient()
await client.mutation(FN_MARK_READ as any, {
await client.mutation(FN_MARK_READ as unknown as FunctionReference<"mutation">, {
machineToken: token,
ticketId,
messageIds,
@ -152,7 +159,7 @@ export async function generateMachineUploadUrl(opts: {
fileSize: number
}) {
const { client, token } = await ensureClient()
return client.action(FN_UPLOAD_URL as any, {
return client.action(FN_UPLOAD_URL as unknown as FunctionReference<"action">, {
machineToken: token,
fileName: opts.fileName,
fileType: opts.fileType,