SurfSense/surfsense_web/lib/query-client/cache-keys.ts

103 lines
4.5 KiB
TypeScript
Raw Normal View History

2025-12-18 22:58:21 +02:00
import type { GetConnectorsRequest } from "@/contracts/types/connector.types";
import type { GetDocumentsRequest } from "@/contracts/types/document.types";
2025-12-26 19:06:09 +02:00
import type { GetLogsRequest } from "@/contracts/types/log.types";
import type { GetSearchSpacesRequest } from "@/contracts/types/search-space.types";
2025-11-18 22:12:47 +02:00
2025-11-11 04:02:04 +02:00
export const cacheKeys = {
2025-12-21 22:26:33 -08:00
// New chat threads (assistant-ui)
threads: {
list: (searchSpaceId: number) => ["threads", searchSpaceId] as const,
detail: (threadId: number) => ["threads", "detail", threadId] as const,
search: (searchSpaceId: number, query: string) =>
["threads", "search", searchSpaceId, query] as const,
2025-11-19 08:29:33 +02:00
},
documents: {
globalQueryParams: (queries: GetDocumentsRequest["queryParams"]) =>
["documents", ...(queries ? Object.values(queries) : [])] as const,
2025-12-10 14:41:32 -08:00
withQueryParams: (queries: GetDocumentsRequest["queryParams"]) =>
["documents-with-queries", ...(queries ? Object.values(queries) : [])] as const,
document: (documentId: string) => ["document", documentId] as const,
typeCounts: (searchSpaceId?: string) => ["documents", "type-counts", searchSpaceId] as const,
byChunk: (chunkId: string) => ["documents", "by-chunk", chunkId] as const,
},
2025-12-26 17:05:06 +02:00
logs: {
list: (searchSpaceId?: number | string) => ["logs", "list", searchSpaceId] as const,
detail: (logId: number | string) => ["logs", "detail", logId] as const,
summary: (searchSpaceId?: number | string) => ["logs", "summary", searchSpaceId] as const,
2025-12-26 19:06:09 +02:00
withQueryParams: (queries: GetLogsRequest["queryParams"]) =>
["logs", "with-query-params", ...(queries ? Object.values(queries) : [])] as const,
2025-12-26 17:05:06 +02:00
},
2025-12-23 01:16:25 -08:00
newLLMConfigs: {
all: (searchSpaceId: number) => ["new-llm-configs", searchSpaceId] as const,
byId: (configId: number) => ["new-llm-configs", "detail", configId] as const,
preferences: (searchSpaceId: number) => ["llm-preferences", searchSpaceId] as const,
defaultInstructions: () => ["new-llm-configs", "default-instructions"] as const,
global: () => ["new-llm-configs", "global"] as const,
modelList: () => ["models", "catalogue"] as const,
},
2026-02-05 16:43:48 -08:00
imageGenConfigs: {
all: (searchSpaceId: number) => ["image-gen-configs", searchSpaceId] as const,
byId: (configId: number) => ["image-gen-configs", "detail", configId] as const,
global: () => ["image-gen-configs", "global"] as const,
},
2025-11-15 02:07:20 +02:00
auth: {
user: ["auth", "user"] as const,
},
searchSpaces: {
all: ["search-spaces"] as const,
withQueryParams: (queries: GetSearchSpacesRequest["queryParams"]) =>
["search-spaces", ...(queries ? Object.values(queries) : [])] as const,
detail: (searchSpaceId: string) => ["search-spaces", searchSpaceId] as const,
2025-12-16 05:37:30 +00:00
},
2025-12-15 12:04:39 +00:00
user: {
current: () => ["user", "me"] as const,
},
roles: {
all: (searchSpaceId: string) => ["roles", searchSpaceId] as const,
byId: (searchSpaceId: string, roleId: string) => ["roles", searchSpaceId, roleId] as const,
},
permissions: {
all: () => ["permissions"] as const,
},
2025-12-16 14:34:29 +00:00
members: {
all: (searchSpaceId: string) => ["members", searchSpaceId] as const,
myAccess: (searchSpaceId: string) => ["members", "my-access", searchSpaceId] as const,
},
2025-12-16 15:58:26 +00:00
invites: {
all: (searchSpaceId: string) => ["invites", searchSpaceId] as const,
info: (inviteCode: string) => ["invites", "info", inviteCode] as const,
},
2025-12-18 22:58:21 +02:00
connectors: {
all: (searchSpaceId: string) => ["connectors", searchSpaceId] as const,
withQueryParams: (queries: GetConnectorsRequest["queryParams"]) =>
["connectors", ...(queries ? Object.values(queries) : [])] as const,
byId: (connectorId: string) => ["connector", connectorId] as const,
2025-12-18 23:08:36 +02:00
index: () => ["connector", "index"] as const,
googleDrive: {
folders: (connectorId: number, parentId?: string) =>
["connectors", "google-drive", connectorId, "folders", parentId] as const,
},
composioDrive: {
folders: (connectorId: number, parentId?: string) =>
["connectors", "composio-drive", connectorId, "folders", parentId] as const,
},
2025-12-18 22:58:21 +02:00
},
comments: {
byMessage: (messageId: number) => ["comments", "message", messageId] as const,
},
2026-01-26 17:08:26 +02:00
publicChat: {
byToken: (shareToken: string) => ["public-chat", shareToken] as const,
},
publicChatSnapshots: {
all: ["public-chat-snapshots"] as const,
bySearchSpace: (searchSpaceId: number) =>
["public-chat-snapshots", "search-space", searchSpaceId] as const,
},
notifications: {
search: (searchSpaceId: number | null, search: string, tab: string) =>
["notifications", "search", searchSpaceId, search, tab] as const,
sourceTypes: (searchSpaceId: number | null) =>
["notifications", "source-types", searchSpaceId] as const,
},
};