@huyooo/ai-chat-storage 0.2.45 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/postgres/backups.d.ts +12 -0
- package/dist/adapters/postgres/backups.d.ts.map +1 -0
- package/dist/adapters/postgres/base.d.ts +12 -0
- package/dist/adapters/postgres/base.d.ts.map +1 -0
- package/dist/adapters/postgres/embeddings.d.ts +16 -0
- package/dist/adapters/postgres/embeddings.d.ts.map +1 -0
- package/dist/adapters/postgres/index.d.ts +55 -0
- package/dist/adapters/postgres/index.d.ts.map +1 -0
- package/dist/adapters/postgres/messages.d.ts +25 -0
- package/dist/adapters/postgres/messages.d.ts.map +1 -0
- package/dist/adapters/postgres/operations.d.ts +16 -0
- package/dist/adapters/postgres/operations.d.ts.map +1 -0
- package/dist/adapters/postgres/sessions.d.ts +16 -0
- package/dist/adapters/postgres/sessions.d.ts.map +1 -0
- package/dist/adapters/postgres/trash.d.ts +14 -0
- package/dist/adapters/postgres/trash.d.ts.map +1 -0
- package/dist/adapters/sqlite/backups.d.ts +12 -0
- package/dist/adapters/sqlite/backups.d.ts.map +1 -0
- package/dist/adapters/sqlite/base.d.ts +22 -0
- package/dist/adapters/sqlite/base.d.ts.map +1 -0
- package/dist/adapters/sqlite/embeddings.d.ts +16 -0
- package/dist/adapters/sqlite/embeddings.d.ts.map +1 -0
- package/dist/adapters/sqlite/index.d.ts +55 -0
- package/dist/adapters/sqlite/index.d.ts.map +1 -0
- package/dist/adapters/sqlite/messages.d.ts +25 -0
- package/dist/adapters/sqlite/messages.d.ts.map +1 -0
- package/dist/adapters/sqlite/operations.d.ts +16 -0
- package/dist/adapters/sqlite/operations.d.ts.map +1 -0
- package/dist/adapters/sqlite/sessions.d.ts +16 -0
- package/dist/adapters/sqlite/sessions.d.ts.map +1 -0
- package/dist/adapters/sqlite/trash.d.ts +14 -0
- package/dist/adapters/sqlite/trash.d.ts.map +1 -0
- package/dist/adapters/sqlite/user-settings.d.ts +22 -0
- package/dist/adapters/sqlite/user-settings.d.ts.map +1 -0
- package/dist/index.d.ts +13 -1567
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +545 -1
- package/dist/schema.d.ts +1410 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/types.d.ts +195 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +8 -4
- package/dist/chunk-EXGLTJH4.js +0 -268
- package/dist/chunk-V5E7YX6J.js +0 -1
- package/dist/postgres-JFFEO52T.js +0 -1
- package/dist/sqlite-BVA3FN4Z.js +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 备份操作
|
|
3
|
+
*/
|
|
4
|
+
import type { PostgresClient } from './base';
|
|
5
|
+
import type { BackupRecord } from '../../types';
|
|
6
|
+
/** 获取操作的备份列表 */
|
|
7
|
+
export declare function getBackups(sql: PostgresClient, operationId: string): Promise<BackupRecord[]>;
|
|
8
|
+
/** 保存备份记录 */
|
|
9
|
+
export declare function saveBackup(sql: PostgresClient, input: Omit<BackupRecord, 'createdAt'>): Promise<BackupRecord>;
|
|
10
|
+
/** 删除过期备份 */
|
|
11
|
+
export declare function deleteExpiredBackups(sql: PostgresClient): Promise<number>;
|
|
12
|
+
//# sourceMappingURL=backups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backups.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/backups.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA2BhD,gBAAgB;AAChB,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAOlG;AAED,aAAa;AACb,wBAAsB,UAAU,CAC9B,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC,CASvB;AAED,aAAa;AACb,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAG/E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 适配器基础模块
|
|
3
|
+
*/
|
|
4
|
+
import postgres from 'postgres';
|
|
5
|
+
import type { StorageContext } from '../../types';
|
|
6
|
+
export type PostgresClient = postgres.Sql;
|
|
7
|
+
export type { StorageConfig, StorageContext } from '../../types';
|
|
8
|
+
/** 初始化数据库表结构 */
|
|
9
|
+
export declare function initSchema(sql: PostgresClient): Promise<void>;
|
|
10
|
+
export declare function buildTenantPredicate(sql: PostgresClient, ctx: StorageContext, appColumn: string, userColumn: string): postgres.PendingQuery<postgres.Row[]>;
|
|
11
|
+
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
12
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIjE,gBAAgB;AAChB,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,iBA2MnD;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,yCAMnB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAejE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 向量嵌入操作(支持 pgvector)
|
|
3
|
+
*/
|
|
4
|
+
import type { PostgresClient, StorageContext } from './base';
|
|
5
|
+
import type { EmbeddingRecord, VectorSearchResult, VectorSearchOptions } from '../../types';
|
|
6
|
+
/** 保存向量嵌入 */
|
|
7
|
+
export declare function saveEmbedding(sql: PostgresClient, id: string, content: string, embedding: number[], metadata: {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
messageId?: string;
|
|
10
|
+
contentType: EmbeddingRecord['contentType'];
|
|
11
|
+
}, ctx: StorageContext): Promise<void>;
|
|
12
|
+
/** 向量搜索 */
|
|
13
|
+
export declare function searchSimilar(sql: PostgresClient, queryEmbedding: number[], options: VectorSearchOptions, ctx: StorageContext): Promise<VectorSearchResult[]>;
|
|
14
|
+
/** 删除会话的所有嵌入 */
|
|
15
|
+
export declare function deleteSessionEmbeddings(sql: PostgresClient, sessionId: string): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=embeddings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/embeddings.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAW5F,aAAa;AACb,wBAAsB,aAAa,CACjC,GAAG,EAAE,cAAc,EACnB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,QAAQ,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;CAAE,EAChG,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,WAAW;AACX,wBAAsB,aAAa,CACjC,GAAG,EAAE,cAAc,EACnB,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA8D/B;AAED,gBAAgB;AAChB,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 存储适配器
|
|
3
|
+
* 使用 postgres.js 驱动,支持 pgvector
|
|
4
|
+
*/
|
|
5
|
+
import { type StorageContext } from './base';
|
|
6
|
+
import type { StorageAdapter, PostgresStorageConfig, SessionRecord, MessageRecord, OperationRecord, BackupRecord, TrashRecord, VectorSearchResult, VectorSearchOptions, CreateSessionInput, UpdateSessionInput, CreateMessageInput, UpdateMessageInput, CreateOperationInput, OperationStatus, EmbeddingRecord } from '../../types';
|
|
7
|
+
export declare class PostgresAdapter implements StorageAdapter {
|
|
8
|
+
private sql;
|
|
9
|
+
private config;
|
|
10
|
+
private initialized;
|
|
11
|
+
constructor(connectionString: string, config: PostgresStorageConfig);
|
|
12
|
+
/** 确保表结构已初始化 */
|
|
13
|
+
private ensureInitialized;
|
|
14
|
+
getSessions(ctx: StorageContext): Promise<SessionRecord[]>;
|
|
15
|
+
getSession(id: string, ctx: StorageContext): Promise<SessionRecord | null>;
|
|
16
|
+
createSession(input: CreateSessionInput, ctx: StorageContext): Promise<SessionRecord>;
|
|
17
|
+
updateSession(id: string, data: UpdateSessionInput, ctx: StorageContext): Promise<void>;
|
|
18
|
+
deleteSession(id: string, ctx: StorageContext): Promise<void>;
|
|
19
|
+
getMessages(sessionId: string, ctx: StorageContext): Promise<MessageRecord[]>;
|
|
20
|
+
getMessagesPage(sessionId: string, params: {
|
|
21
|
+
limit?: number;
|
|
22
|
+
beforeSequence?: number;
|
|
23
|
+
} | undefined, ctx: StorageContext): Promise<import("@huyooo/ai-chat-types").MessagePage>;
|
|
24
|
+
searchAtChats(query: string, options: {
|
|
25
|
+
limit?: number;
|
|
26
|
+
} | undefined, ctx: StorageContext): Promise<import("@huyooo/ai-chat-types").AtChatContextItem[]>;
|
|
27
|
+
getMessage(id: string, ctx: StorageContext): Promise<MessageRecord | null>;
|
|
28
|
+
saveMessage(input: CreateMessageInput, ctx: StorageContext): Promise<MessageRecord>;
|
|
29
|
+
updateMessage(id: string, data: UpdateMessageInput, ctx: StorageContext): Promise<void>;
|
|
30
|
+
deleteMessagesAfter(sessionId: string, timestamp: Date, ctx: StorageContext): Promise<void>;
|
|
31
|
+
deleteMessagesAfterMessageId(sessionId: string, messageId: string, ctx: StorageContext): Promise<void>;
|
|
32
|
+
getOperations(sessionId: string, ctx: StorageContext): Promise<OperationRecord[]>;
|
|
33
|
+
getOperationsByMessage(messageId: string, ctx: StorageContext): Promise<OperationRecord[]>;
|
|
34
|
+
saveOperation(input: CreateOperationInput, ctx: StorageContext): Promise<OperationRecord>;
|
|
35
|
+
updateOperationStatus(id: string, status: OperationStatus, errorMessage?: string): Promise<void>;
|
|
36
|
+
getBackups(operationId: string): Promise<BackupRecord[]>;
|
|
37
|
+
saveBackup(input: Omit<BackupRecord, 'createdAt'>): Promise<BackupRecord>;
|
|
38
|
+
deleteExpiredBackups(): Promise<number>;
|
|
39
|
+
getTrashItems(ctx: StorageContext): Promise<TrashRecord[]>;
|
|
40
|
+
moveToTrash(input: Omit<TrashRecord, 'deletedAt' | 'autoDeleteAt' | 'appId' | 'userId'>, ctx: StorageContext): Promise<TrashRecord>;
|
|
41
|
+
restoreFromTrash(id: string, ctx: StorageContext): Promise<TrashRecord>;
|
|
42
|
+
emptyExpiredTrash(): Promise<number>;
|
|
43
|
+
saveEmbedding(id: string, content: string, embedding: number[], metadata: {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
messageId?: string;
|
|
46
|
+
contentType: EmbeddingRecord['contentType'];
|
|
47
|
+
}, ctx: StorageContext): Promise<void>;
|
|
48
|
+
searchSimilar(queryEmbedding: number[], options: VectorSearchOptions, ctx: StorageContext): Promise<VectorSearchResult[]>;
|
|
49
|
+
getUserSetting(key: string, ctx: StorageContext): Promise<string | null>;
|
|
50
|
+
setUserSetting(key: string, value: string, ctx: StorageContext): Promise<void>;
|
|
51
|
+
getUserSettings(ctx: StorageContext): Promise<Record<string, string>>;
|
|
52
|
+
deleteUserSetting(key: string, ctx: StorageContext): Promise<void>;
|
|
53
|
+
close(): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAOzD,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,qBAAa,eAAgB,YAAW,cAAc;IACpD,OAAO,CAAC,GAAG,CAAe;IAC1B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,WAAW,CAAS;gBAEhB,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB;IAKnE,gBAAgB;YACF,iBAAiB;IAQzB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;I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AAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;KAAE,EAChG,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC;IAKV,aAAa,CACjB,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAO1B,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAWxE,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9E,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAgBrE,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAYlE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 消息操作
|
|
3
|
+
*/
|
|
4
|
+
import type { AtChatContextItem, GetMessagesPageParams, MessagePage } from '@huyooo/ai-chat-types';
|
|
5
|
+
import type { CreateMessageInput, MessageRecord, UpdateMessageInput } from '../../types';
|
|
6
|
+
import type { PostgresClient, StorageContext } from './base';
|
|
7
|
+
/** 获取消息列表 */
|
|
8
|
+
export declare function getMessages(sql: PostgresClient, sessionId: string): Promise<MessageRecord[]>;
|
|
9
|
+
export declare function getMessagesPage(sql: PostgresClient, sessionId: string, params?: GetMessagesPageParams): Promise<MessagePage>;
|
|
10
|
+
export declare function searchAtChats(sql: PostgresClient, query: string, options: {
|
|
11
|
+
limit?: number;
|
|
12
|
+
} | undefined, ctx: StorageContext): Promise<AtChatContextItem[]>;
|
|
13
|
+
/** 获取单条消息 */
|
|
14
|
+
export declare function getMessage(sql: PostgresClient, id: string, ctx: StorageContext): Promise<MessageRecord | null>;
|
|
15
|
+
/** 保存消息 */
|
|
16
|
+
export declare function saveMessage(sql: PostgresClient, input: CreateMessageInput, ctx: StorageContext): Promise<MessageRecord>;
|
|
17
|
+
/** 更新消息 */
|
|
18
|
+
export declare function updateMessage(sql: PostgresClient, id: string, data: UpdateMessageInput, ctx: StorageContext): Promise<void>;
|
|
19
|
+
/** 删除指定时间之后的消息 */
|
|
20
|
+
export declare function deleteMessagesAfter(sql: PostgresClient, sessionId: string, timestamp: Date): Promise<void>;
|
|
21
|
+
/** 删除指定消息之后的所有消息(用于分叉,使用序号) */
|
|
22
|
+
export declare function deleteMessagesAfterMessage(sql: PostgresClient, sessionId: string, _anchorId: string, anchorSequence: number): Promise<void>;
|
|
23
|
+
/** 删除会话的所有消息 */
|
|
24
|
+
export declare function deleteSessionMessages(sql: PostgresClient, sessionId: string): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAA+B,qBAAqB,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAC;AACnJ,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAgO7D,aAAa;AACb,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAWlG;AAED,wBA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C,CAYjG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 操作日志
|
|
3
|
+
*/
|
|
4
|
+
import type { PostgresClient, StorageContext } from './base';
|
|
5
|
+
import type { OperationRecord, CreateOperationInput, OperationStatus } from '../../types';
|
|
6
|
+
/** 获取会话的操作日志 */
|
|
7
|
+
export declare function getOperations(sql: PostgresClient, sessionId: string): Promise<OperationRecord[]>;
|
|
8
|
+
/** 获取消息关联的操作 */
|
|
9
|
+
export declare function getOperationsByMessage(sql: PostgresClient, messageId: string, ctx: StorageContext): Promise<OperationRecord[]>;
|
|
10
|
+
/** 保存操作日志 */
|
|
11
|
+
export declare function saveOperation(sql: PostgresClient, input: CreateOperationInput, ctx: StorageContext): Promise<OperationRecord>;
|
|
12
|
+
/** 更新操作状态 */
|
|
13
|
+
export declare function updateOperationStatus(sql: PostgresClient, id: string, status: OperationStatus, errorMessage?: string): Promise<void>;
|
|
14
|
+
/** 删除会话的所有操作 */
|
|
15
|
+
export declare function deleteSessionOperations(sql: PostgresClient, sessionId: string): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/operations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmC1F,gBAAgB;AAChB,wBAAsB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAStG;AAED,gBAAgB;AAChB,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,eAAe,EAAE,CAAC,CAU5B;AAED,aAAa;AACb,wBAAsB,aAAa,CACjC,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,oBAAoB,EAC3B,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,eAAe,CAAC,CAuB1B;AAED,aAAa;AACb,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,cAAc,EACnB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,eAAe,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,gBAAgB;AAChB,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 会话操作
|
|
3
|
+
*/
|
|
4
|
+
import type { PostgresClient, StorageContext } from './base';
|
|
5
|
+
import type { SessionRecord, CreateSessionInput, UpdateSessionInput } from '../../types';
|
|
6
|
+
/** 获取会话列表 */
|
|
7
|
+
export declare function getSessions(sql: PostgresClient, ctx: StorageContext): Promise<SessionRecord[]>;
|
|
8
|
+
/** 获取单个会话 */
|
|
9
|
+
export declare function getSession(sql: PostgresClient, id: string, ctx: StorageContext): Promise<SessionRecord | null>;
|
|
10
|
+
/** 创建会话 */
|
|
11
|
+
export declare function createSession(sql: PostgresClient, input: CreateSessionInput, ctx: StorageContext): Promise<SessionRecord>;
|
|
12
|
+
/** 更新会话 */
|
|
13
|
+
export declare function updateSession(sql: PostgresClient, id: string, data: UpdateSessionInput, ctx: StorageContext): Promise<void>;
|
|
14
|
+
/** 删除会话 */
|
|
15
|
+
export declare function deleteSession(sql: PostgresClient, id: string, ctx: StorageContext): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/sessions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAiCzF,aAAa;AACb,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CASpG;AAED,aAAa;AACb,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CASpH;AAED,WAAW;AACX,wBAAsB,aAAa,CACjC,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,kBAAkB,EACzB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,aAAa,CAAC,CA4BxB;AAED,WAAW;AACX,wBAAsB,aAAa,CACjC,GAAG,EAAE,cAAc,EACnB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,kBAAkB,EACxB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,WAAW;AACX,wBAAsB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAOvG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL 回收站操作
|
|
3
|
+
*/
|
|
4
|
+
import type { PostgresClient, StorageContext, StorageConfig } from './base';
|
|
5
|
+
import type { TrashRecord } from '../../types';
|
|
6
|
+
/** 获取回收站列表 */
|
|
7
|
+
export declare function getTrashItems(sql: PostgresClient, ctx: StorageContext): Promise<TrashRecord[]>;
|
|
8
|
+
/** 移入回收站 */
|
|
9
|
+
export declare function moveToTrash(sql: PostgresClient, input: Omit<TrashRecord, 'deletedAt' | 'autoDeleteAt' | 'appId' | 'userId'>, ctx: StorageContext, config: StorageConfig): Promise<TrashRecord>;
|
|
10
|
+
/** 从回收站恢复 */
|
|
11
|
+
export declare function restoreFromTrash(sql: PostgresClient, id: string, ctx: StorageContext): Promise<TrashRecord>;
|
|
12
|
+
/** 清空过期回收站 */
|
|
13
|
+
export declare function emptyExpiredTrash(sql: PostgresClient): Promise<number>;
|
|
14
|
+
//# sourceMappingURL=trash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trash.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/trash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA2B/C,cAAc;AACd,wBAAsB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CASpG;AAED,YAAY;AACZ,wBAAsB,WAAW,CAC/B,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC,EAC3E,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,WAAW,CAAC,CAiBtB;AAED,aAAa;AACb,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,cAAc,EACnB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED,cAAc;AACd,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAG5E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite 备份操作
|
|
3
|
+
*/
|
|
4
|
+
import type { DrizzleDB } from './base';
|
|
5
|
+
import type { BackupRecord } from '../../types';
|
|
6
|
+
/** 获取操作的备份列表 */
|
|
7
|
+
export declare function getBackups(db: DrizzleDB, operationId: string): BackupRecord[];
|
|
8
|
+
/** 保存备份记录 */
|
|
9
|
+
export declare function saveBackup(db: DrizzleDB, input: Omit<BackupRecord, 'createdAt'>): BackupRecord;
|
|
10
|
+
/** 删除过期备份 */
|
|
11
|
+
export declare function deleteExpiredBackups(db: DrizzleDB): number;
|
|
12
|
+
//# sourceMappingURL=backups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backups.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/backups.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgBhD,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,EAAE,CAQ7E;AAED,aAAa;AACb,wBAAgB,UAAU,CACxB,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GACrC,YAAY,CAmBd;AAED,aAAa;AACb,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAM1D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite 适配器基础模块
|
|
3
|
+
*/
|
|
4
|
+
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
|
5
|
+
import type BetterSqlite3 from 'better-sqlite3';
|
|
6
|
+
import type { StorageConfig, StorageContext } from '../../types';
|
|
7
|
+
export type DrizzleDB = ReturnType<typeof drizzle>;
|
|
8
|
+
export type { StorageConfig, StorageContext } from '../../types';
|
|
9
|
+
/** 初始化数据库表结构 */
|
|
10
|
+
export declare function initSchema(sqlite: BetterSqlite3.Database): void;
|
|
11
|
+
/** 构建租户过滤条件(sessions 表) */
|
|
12
|
+
export declare function buildSessionsTenantCondition(ctx: StorageContext): import("drizzle-orm").SQL<unknown> | undefined;
|
|
13
|
+
/** 构建租户过滤条件(messages 表) */
|
|
14
|
+
export declare function buildMessagesTenantCondition(ctx: StorageContext): import("drizzle-orm").SQL<unknown> | undefined;
|
|
15
|
+
/** 构建租户过滤条件(operations 表) */
|
|
16
|
+
export declare function buildOperationsTenantCondition(ctx: StorageContext): import("drizzle-orm").SQL<unknown> | undefined;
|
|
17
|
+
/** 构建租户过滤条件(trash 表) */
|
|
18
|
+
export declare function buildTrashTenantCondition(ctx: StorageContext): import("drizzle-orm").SQL<unknown> | undefined;
|
|
19
|
+
/** 从存储配置获取保留天数 */
|
|
20
|
+
export declare function getRetentionDays(config: StorageConfig, type: 'backup' | 'trash'): number;
|
|
21
|
+
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
22
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAYjE,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,QA+IxD;AAED,2BAA2B;AAC3B,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,cAAc,kDAK/D;AAED,2BAA2B;AAC3B,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,cAAc,kDAK/D;AAED,6BAA6B;AAC7B,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,cAAc,kDAKjE;AAED,wBAAwB;AACxB,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,cAAc,kDAK5D;AAED,kBAAkB;AAClB,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAGxF;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAejE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite 向量嵌入操作
|
|
3
|
+
*/
|
|
4
|
+
import type { DrizzleDB, StorageContext } from './base';
|
|
5
|
+
import type { EmbeddingRecord, VectorSearchResult, VectorSearchOptions } from '../../types';
|
|
6
|
+
/** 保存向量嵌入 */
|
|
7
|
+
export declare function saveEmbedding(db: DrizzleDB, id: string, content: string, embedding: number[], metadata: {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
messageId?: string;
|
|
10
|
+
contentType: EmbeddingRecord['contentType'];
|
|
11
|
+
}, ctx: StorageContext): void;
|
|
12
|
+
/** 向量搜索(SQLite 使用内存计算) */
|
|
13
|
+
export declare function searchSimilar(db: DrizzleDB, queryEmbedding: number[], options: VectorSearchOptions, ctx: StorageContext): VectorSearchResult[];
|
|
14
|
+
/** 删除会话的所有嵌入 */
|
|
15
|
+
export declare function deleteSessionEmbeddings(db: DrizzleDB, sessionId: string): void;
|
|
16
|
+
//# sourceMappingURL=embeddings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/embeddings.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE5F,aAAa;AACb,wBAAgB,aAAa,CAC3B,EAAE,EAAE,SAAS,EACb,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,QAAQ,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;CAAE,EAChG,GAAG,EAAE,cAAc,GAClB,IAAI,CAeN;AAED,0BAA0B;AAC1B,wBAAgB,aAAa,CAC3B,EAAE,EAAE,SAAS,EACb,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,cAAc,GAClB,kBAAkB,EAAE,CAiCtB;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9E"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite 存储适配器
|
|
3
|
+
* 使用 Drizzle ORM + better-sqlite3
|
|
4
|
+
*/
|
|
5
|
+
import type BetterSqlite3 from 'better-sqlite3';
|
|
6
|
+
import { type StorageContext } from './base';
|
|
7
|
+
import type { StorageAdapter, SqliteStorageConfig, SessionRecord, MessageRecord, OperationRecord, BackupRecord, TrashRecord, VectorSearchResult, VectorSearchOptions, CreateSessionInput, UpdateSessionInput, CreateMessageInput, UpdateMessageInput, CreateOperationInput, OperationStatus, EmbeddingRecord } from '../../types';
|
|
8
|
+
export declare class SqliteAdapter implements StorageAdapter {
|
|
9
|
+
private sqlite;
|
|
10
|
+
private db;
|
|
11
|
+
private config;
|
|
12
|
+
get sqliteInstance(): BetterSqlite3.Database;
|
|
13
|
+
constructor(dbPath: string, config: SqliteStorageConfig);
|
|
14
|
+
getSessions(ctx: StorageContext): Promise<SessionRecord[]>;
|
|
15
|
+
getSession(id: string, ctx: StorageContext): Promise<SessionRecord | null>;
|
|
16
|
+
createSession(input: CreateSessionInput, ctx: StorageContext): Promise<SessionRecord>;
|
|
17
|
+
updateSession(id: string, data: UpdateSessionInput, ctx: StorageContext): Promise<void>;
|
|
18
|
+
deleteSession(id: string, ctx: StorageContext): Promise<void>;
|
|
19
|
+
getMessages(sessionId: string, ctx: StorageContext): Promise<MessageRecord[]>;
|
|
20
|
+
getMessagesPage(sessionId: string, params: {
|
|
21
|
+
limit?: number;
|
|
22
|
+
beforeSequence?: number;
|
|
23
|
+
} | undefined, ctx: StorageContext): Promise<import("@huyooo/ai-chat-types").MessagePage>;
|
|
24
|
+
searchAtChats(query: string, options: {
|
|
25
|
+
limit?: number;
|
|
26
|
+
} | undefined, ctx: StorageContext): Promise<import("@huyooo/ai-chat-types").AtChatContextItem[]>;
|
|
27
|
+
getMessage(id: string, ctx: StorageContext): Promise<MessageRecord | null>;
|
|
28
|
+
saveMessage(input: CreateMessageInput, ctx: StorageContext): Promise<MessageRecord>;
|
|
29
|
+
updateMessage(id: string, data: UpdateMessageInput, ctx: StorageContext): Promise<void>;
|
|
30
|
+
deleteMessagesAfter(sessionId: string, timestamp: Date, ctx: StorageContext): Promise<void>;
|
|
31
|
+
deleteMessagesAfterMessageId(sessionId: string, messageId: string, ctx: StorageContext): Promise<void>;
|
|
32
|
+
getOperations(sessionId: string, ctx: StorageContext): Promise<OperationRecord[]>;
|
|
33
|
+
getOperationsByMessage(messageId: string, ctx: StorageContext): Promise<OperationRecord[]>;
|
|
34
|
+
saveOperation(input: CreateOperationInput, ctx: StorageContext): Promise<OperationRecord>;
|
|
35
|
+
updateOperationStatus(id: string, status: OperationStatus, errorMessage?: string): Promise<void>;
|
|
36
|
+
getBackups(operationId: string): Promise<BackupRecord[]>;
|
|
37
|
+
saveBackup(input: Omit<BackupRecord, 'createdAt'>): Promise<BackupRecord>;
|
|
38
|
+
deleteExpiredBackups(): Promise<number>;
|
|
39
|
+
getTrashItems(ctx: StorageContext): Promise<TrashRecord[]>;
|
|
40
|
+
moveToTrash(input: Omit<TrashRecord, 'deletedAt' | 'autoDeleteAt' | 'appId' | 'userId'>, ctx: StorageContext): Promise<TrashRecord>;
|
|
41
|
+
restoreFromTrash(id: string, ctx: StorageContext): Promise<TrashRecord>;
|
|
42
|
+
emptyExpiredTrash(): Promise<number>;
|
|
43
|
+
saveEmbedding(id: string, content: string, embedding: number[], metadata: {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
messageId?: string;
|
|
46
|
+
contentType: EmbeddingRecord['contentType'];
|
|
47
|
+
}, ctx: StorageContext): Promise<void>;
|
|
48
|
+
searchSimilar(queryEmbedding: number[], options: VectorSearchOptions, ctx: StorageContext): Promise<VectorSearchResult[]>;
|
|
49
|
+
getUserSetting(key: string, ctx: StorageContext): Promise<string | null>;
|
|
50
|
+
setUserSetting(key: string, value: string, ctx: StorageContext): Promise<void>;
|
|
51
|
+
getUserSettings(ctx: StorageContext): Promise<Record<string, string>>;
|
|
52
|
+
deleteUserSetting(key: string, ctx: StorageContext): Promise<void>;
|
|
53
|
+
close(): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAQzD,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,kB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2
|
+
* SQLite 消息操作
|
|
3
|
+
*/
|
|
4
|
+
import type { AtChatContextItem, GetMessagesPageParams, MessagePage } from '@huyooo/ai-chat-types';
|
|
5
|
+
import type { CreateMessageInput, MessageRecord, UpdateMessageInput } from '../../types';
|
|
6
|
+
import type { DrizzleDB, StorageContext } from './base';
|
|
7
|
+
/** 获取消息列表 */
|
|
8
|
+
export declare function getMessages(db: DrizzleDB, sessionId: string): MessageRecord[];
|
|
9
|
+
export declare function getMessagesPage(db: DrizzleDB, sessionId: string, params?: GetMessagesPageParams): MessagePage;
|
|
10
|
+
export declare function searchAtChats(db: DrizzleDB, query: string, options?: {
|
|
11
|
+
limit?: number;
|
|
12
|
+
}, ctx?: StorageContext): AtChatContextItem[];
|
|
13
|
+
/** 获取单条消息 */
|
|
14
|
+
export declare function getMessage(db: DrizzleDB, id: string, ctx: StorageContext): MessageRecord | null;
|
|
15
|
+
/** 保存消息 */
|
|
16
|
+
export declare function saveMessage(db: DrizzleDB, input: CreateMessageInput, ctx: StorageContext): MessageRecord;
|
|
17
|
+
/** 更新消息 */
|
|
18
|
+
export declare function updateMessage(db: DrizzleDB, id: string, data: UpdateMessageInput, ctx: StorageContext): void;
|
|
19
|
+
/** 删除指定时间之后的消息 */
|
|
20
|
+
export declare function deleteMessagesAfter(db: DrizzleDB, sessionId: string, timestamp: Date): void;
|
|
21
|
+
/** 删除指定消息之后的所有消息(用于分叉,使用序号) */
|
|
22
|
+
export declare function deleteMessagesAfterMessage(db: DrizzleDB, sessionId: string, _anchorId: string, anchorSequence: number): void;
|
|
23
|
+
/** 删除会话的所有消息 */
|
|
24
|
+
export declare function deleteSessionMessages(db: DrizzleDB, sessionId: string): void;
|
|
25
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,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,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAc5H;AAED,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAW5E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite 操作日志
|
|
3
|
+
*/
|
|
4
|
+
import type { DrizzleDB, StorageContext } from './base';
|
|
5
|
+
import type { OperationRecord, CreateOperationInput, OperationStatus } from '../../types';
|
|
6
|
+
/** 获取会话的操作日志 */
|
|
7
|
+
export declare function getOperations(db: DrizzleDB, sessionId: string): OperationRecord[];
|
|
8
|
+
/** 获取消息关联的操作 */
|
|
9
|
+
export declare function getOperationsByMessage(db: DrizzleDB, messageId: string, ctx: StorageContext): OperationRecord[];
|
|
10
|
+
/** 保存操作日志 */
|
|
11
|
+
export declare function saveOperation(db: DrizzleDB, input: CreateOperationInput, ctx: StorageContext): OperationRecord;
|
|
12
|
+
/** 更新操作状态 */
|
|
13
|
+
export declare function updateOperationStatus(db: DrizzleDB, id: string, status: OperationStatus, errorMessage?: string): void;
|
|
14
|
+
/** 删除会话的所有操作 */
|
|
15
|
+
export declare function deleteSessionOperations(db: DrizzleDB, sessionId: string): void;
|
|
16
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/operations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoB1F,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,EAAE,CASjF;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,SAAS,EACb,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,cAAc,GAClB,eAAe,EAAE,CAanB;AAED,aAAa;AACb,wBAAgB,aAAa,CAC3B,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,oBAAoB,EAC3B,GAAG,EAAE,cAAc,GAClB,eAAe,CAiCjB;AAED,aAAa;AACb,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,SAAS,EACb,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,eAAe,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CAUN;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite 会话操作
|
|
3
|
+
*/
|
|
4
|
+
import type { DrizzleDB, StorageContext } from './base';
|
|
5
|
+
import type { SessionRecord, CreateSessionInput, UpdateSessionInput } from '../../types';
|
|
6
|
+
/** 获取会话列表 */
|
|
7
|
+
export declare function getSessions(db: DrizzleDB, ctx: StorageContext): SessionRecord[];
|
|
8
|
+
/** 获取单个会话 */
|
|
9
|
+
export declare function getSession(db: DrizzleDB, id: string, ctx: StorageContext): SessionRecord | null;
|
|
10
|
+
/** 创建会话 */
|
|
11
|
+
export declare function createSession(db: DrizzleDB, input: CreateSessionInput, ctx: StorageContext): SessionRecord;
|
|
12
|
+
/** 更新会话 */
|
|
13
|
+
export declare function updateSession(db: DrizzleDB, id: string, data: UpdateSessionInput, ctx: StorageContext): void;
|
|
14
|
+
/** 删除会话 */
|
|
15
|
+
export declare function deleteSession(db: DrizzleDB, id: string, ctx: StorageContext): void;
|
|
16
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/sessions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAmBzF,aAAa;AACb,wBAAgB,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,GAAG,aAAa,EAAE,CAW/E;AAED,aAAa;AACb,wBAAgB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,aAAa,GAAG,IAAI,CAa/F;AAED,WAAW;AACX,wBAAgB,aAAa,CAC3B,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,kBAAkB,EACzB,GAAG,EAAE,cAAc,GAClB,aAAa,CAgCf;AAED,WAAW;AACX,wBAAgB,aAAa,CAC3B,EAAE,EAAE,SAAS,EACb,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,kBAAkB,EACxB,GAAG,EAAE,cAAc,GAClB,IAAI,CAeN;AAED,WAAW;AACX,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAOlF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite 回收站操作
|
|
3
|
+
*/
|
|
4
|
+
import type { DrizzleDB, StorageContext, StorageConfig } from './base';
|
|
5
|
+
import type { TrashRecord } from '../../types';
|
|
6
|
+
/** 获取回收站列表 */
|
|
7
|
+
export declare function getTrashItems(db: DrizzleDB, ctx: StorageContext): TrashRecord[];
|
|
8
|
+
/** 移入回收站 */
|
|
9
|
+
export declare function moveToTrash(db: DrizzleDB, input: Omit<TrashRecord, 'deletedAt' | 'autoDeleteAt' | 'appId' | 'userId'>, ctx: StorageContext, config: StorageConfig): TrashRecord;
|
|
10
|
+
/** 从回收站恢复 */
|
|
11
|
+
export declare function restoreFromTrash(db: DrizzleDB, id: string, ctx: StorageContext): TrashRecord;
|
|
12
|
+
/** 清空过期回收站 */
|
|
13
|
+
export declare function emptyExpiredTrash(db: DrizzleDB): number;
|
|
14
|
+
//# sourceMappingURL=trash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trash.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/trash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB/C,cAAc;AACd,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,GAAG,WAAW,EAAE,CAW/E;AAED,YAAY;AACZ,wBAAgB,WAAW,CACzB,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC,EAC3E,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,aAAa,GACpB,WAAW,CAyBb;AAED,aAAa;AACb,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,SAAS,EACb,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,cAAc,GAClB,WAAW,CAmBb;AAED,cAAc;AACd,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAMvD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户设置 Repository
|
|
3
|
+
*/
|
|
4
|
+
import type BetterSqlite3 from 'better-sqlite3';
|
|
5
|
+
import type { StorageContext } from './base';
|
|
6
|
+
/**
|
|
7
|
+
* 获取用户设置值
|
|
8
|
+
*/
|
|
9
|
+
export declare function getUserSetting(sqlite: BetterSqlite3.Database, key: string, ctx: StorageContext): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* 设置用户设置值
|
|
12
|
+
*/
|
|
13
|
+
export declare function setUserSetting(sqlite: BetterSqlite3.Database, key: string, value: string, ctx: StorageContext): void;
|
|
14
|
+
/**
|
|
15
|
+
* 获取所有用户设置
|
|
16
|
+
*/
|
|
17
|
+
export declare function getUserSettings(sqlite: BetterSqlite3.Database, ctx: StorageContext): Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* 删除用户设置
|
|
20
|
+
*/
|
|
21
|
+
export declare function deleteUserSetting(sqlite: BetterSqlite3.Database, key: string, ctx: StorageContext): void;
|
|
22
|
+
//# sourceMappingURL=user-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-settings.d.ts","sourceRoot":"","sources":["../../../src/adapters/sqlite/user-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7C;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,CAAC,QAAQ,EAC9B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,cAAc,GAClB,MAAM,GAAG,IAAI,CASf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,CAAC,QAAQ,EAC9B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,cAAc,GAClB,IAAI,CAmBN;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,CAAC,QAAQ,EAC9B,GAAG,EAAE,cAAc,GAClB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcxB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,CAAC,QAAQ,EAC9B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,cAAc,GAClB,IAAI,CAON"}
|