@seaverse/conversation-sdk 0.4.0 → 0.4.2
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/README.md +1 -1
- package/dist/aggregated/apps-with-conversations.d.ts +1 -1
- package/dist/aggregated/index.d.ts +3 -0
- package/dist/client/ConversationClient.d.ts +24 -0
- package/dist/client/ConversationsClient.d.ts +31 -0
- package/dist/client/ConversationsClient.js +50 -0
- package/dist/client/ConversationsClient.js.map +1 -0
- package/dist/client/EnvironmentConfig.d.ts +12 -0
- package/dist/client/EnvironmentConfig.d.ts.map +1 -0
- package/dist/client/EnvironmentConfig.js +21 -0
- package/dist/client/EnvironmentConfig.js.map +1 -0
- package/dist/client/MessagesClient.d.ts +31 -0
- package/dist/client/MessagesClient.js +57 -0
- package/dist/client/MessagesClient.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/data/DbClient.d.ts +76 -0
- package/dist/data/DbClient.d.ts.map +1 -0
- package/dist/data/DbClient.js +107 -0
- package/dist/data/DbClient.js.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +2 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/postgrest-headers.d.ts +10 -0
- package/dist/data/postgrest-headers.d.ts.map +1 -0
- package/dist/data/postgrest-headers.js +58 -0
- package/dist/data/postgrest-headers.js.map +1 -0
- package/dist/data/query.types.d.ts +62 -0
- package/dist/data/query.types.d.ts.map +1 -0
- package/dist/data/query.types.js +2 -0
- package/dist/data/query.types.js.map +1 -0
- package/dist/errors/AuthError.d.ts +8 -0
- package/dist/errors/AuthError.d.ts.map +1 -0
- package/dist/errors/AuthError.js +10 -0
- package/dist/errors/AuthError.js.map +1 -0
- package/dist/errors/BaseError.d.ts +17 -0
- package/dist/errors/BaseError.d.ts.map +1 -0
- package/dist/errors/BaseError.js +26 -0
- package/dist/errors/BaseError.js.map +1 -0
- package/dist/errors/NetworkError.d.ts +8 -0
- package/dist/errors/NetworkError.d.ts.map +1 -0
- package/dist/errors/NetworkError.js +10 -0
- package/dist/errors/NetworkError.js.map +1 -0
- package/dist/errors/ProtocolError.d.ts +8 -0
- package/dist/errors/ProtocolError.d.ts.map +1 -0
- package/dist/errors/ProtocolError.js +10 -0
- package/dist/errors/ProtocolError.js.map +1 -0
- package/dist/errors/TimeoutError.d.ts +8 -0
- package/dist/errors/TimeoutError.d.ts.map +1 -0
- package/dist/errors/TimeoutError.js +10 -0
- package/dist/errors/TimeoutError.js.map +1 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +6 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/resources/AppsResource.d.ts +37 -0
- package/dist/resources/AppsResource.d.ts.map +1 -0
- package/dist/resources/AppsResource.js +51 -0
- package/dist/resources/AppsResource.js.map +1 -0
- package/dist/resources/ConversationsResource.d.ts +87 -0
- package/dist/resources/MessagesResource.d.ts +57 -0
- package/dist/resources/MessagesResource.d.ts.map +1 -0
- package/dist/resources/MessagesResource.js +117 -0
- package/dist/resources/MessagesResource.js.map +1 -0
- package/dist/session/session-token.d.ts +2 -2
- package/dist/session/session-token.js +2 -2
- package/dist/session/session-token.js.map +1 -1
- package/dist/transforms/app.transform.d.ts +6 -0
- package/dist/transforms/app.transform.d.ts.map +1 -0
- package/dist/transforms/app.transform.js +39 -0
- package/dist/transforms/app.transform.js.map +1 -0
- package/dist/transforms/conversation.transform.d.ts +14 -0
- package/dist/transforms/conversation.transform.d.ts.map +1 -0
- package/dist/transforms/conversation.transform.js +64 -0
- package/dist/transforms/conversation.transform.js.map +1 -0
- package/dist/transforms/message.transform.d.ts +32 -0
- package/dist/transforms/message.transform.d.ts.map +1 -0
- package/dist/transforms/message.transform.js +132 -0
- package/dist/transforms/message.transform.js.map +1 -0
- package/dist/transport/HttpClient.d.ts +34 -0
- package/dist/transport/HttpClient.d.ts.map +1 -0
- package/dist/transport/HttpClient.js +158 -0
- package/dist/transport/HttpClient.js.map +1 -0
- package/dist/transport/config.types.d.ts +40 -0
- package/dist/transport/config.types.d.ts.map +1 -0
- package/dist/transport/config.types.js +2 -0
- package/dist/transport/config.types.js.map +1 -0
- package/dist/transport/index.d.ts +10 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +11 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/timeout.d.ts +12 -0
- package/dist/transport/timeout.d.ts.map +1 -0
- package/dist/transport/timeout.js +29 -0
- package/dist/transport/timeout.js.map +1 -0
- package/dist/types/common.types.d.ts +24 -0
- package/dist/types/common.types.d.ts.map +1 -0
- package/dist/types/common.types.js +5 -0
- package/dist/types/common.types.js.map +1 -0
- package/dist/types/config.types.d.ts +28 -0
- package/dist/types/config.types.d.ts.map +1 -0
- package/dist/types/config.types.js +2 -0
- package/dist/types/config.types.js.map +1 -0
- package/dist/types/http.types.d.ts +47 -0
- package/dist/types/http.types.d.ts.map +1 -0
- package/dist/types/http.types.js +2 -0
- package/dist/types/http.types.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/models.types.d.ts +178 -0
- package/dist/types/models.types.d.ts.map +1 -0
- package/dist/types/models.types.js +5 -0
- package/dist/types/models.types.js.map +1 -0
- package/dist/types/pagination.types.d.ts +69 -0
- package/dist/types/pagination.types.d.ts.map +1 -0
- package/dist/types/pagination.types.js +24 -0
- package/dist/types/pagination.types.js.map +1 -0
- package/dist/types/token.types.d.ts +6 -0
- package/dist/types/token.types.d.ts.map +1 -0
- package/dist/types/token.types.js +2 -0
- package/dist/types/token.types.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -517,7 +517,7 @@ console.log('Deleted:', newConversation.conversation_id);
|
|
|
517
517
|
The SDK automatically selects the corresponding service endpoint based on the `environment` parameter:
|
|
518
518
|
|
|
519
519
|
- `'dev'`: Development environment (https://postgrest.sg.seaverse.dev)
|
|
520
|
-
- `'prod'`: Production environment (https://
|
|
520
|
+
- `'prod'`: Production environment (https://sandbox-api.seaverse.ai)
|
|
521
521
|
|
|
522
522
|
## License
|
|
523
523
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ConversationClientConfig } from '../types/config.types.js';
|
|
2
|
+
import { ConversationsResource } from '../resources/ConversationsResource.js';
|
|
3
|
+
import { MessagesResource } from '../resources/MessagesResource.js';
|
|
4
|
+
import { AppsResource } from '../resources/AppsResource.js';
|
|
5
|
+
/**
|
|
6
|
+
* Conversation SDK 客户端
|
|
7
|
+
*/
|
|
8
|
+
export declare class ConversationClient {
|
|
9
|
+
private readonly config;
|
|
10
|
+
private readonly db;
|
|
11
|
+
readonly conversations: ConversationsResource;
|
|
12
|
+
readonly messages: MessagesResource;
|
|
13
|
+
readonly apps: AppsResource;
|
|
14
|
+
constructor(config: ConversationClientConfig);
|
|
15
|
+
/**
|
|
16
|
+
* 获取 URL session token
|
|
17
|
+
*/
|
|
18
|
+
getUrlSessionToken(): Promise<string | null>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 创建 Conversation SDK 客户端(工厂函数)
|
|
22
|
+
*/
|
|
23
|
+
export declare function createClient(config: ConversationClientConfig): ConversationClient;
|
|
24
|
+
//# sourceMappingURL=ConversationClient.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DbClient } from '../data/DbClient.js';
|
|
2
|
+
import type { QueryOptions, MutationOptions } from '../data/query.types.js';
|
|
3
|
+
import type { Conversation } from '../types/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Client for conversation operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConversationsClient {
|
|
8
|
+
private readonly db;
|
|
9
|
+
constructor(db: DbClient);
|
|
10
|
+
/**
|
|
11
|
+
* List conversations
|
|
12
|
+
*/
|
|
13
|
+
list(options?: QueryOptions): Promise<Conversation[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a single conversation by ID
|
|
16
|
+
*/
|
|
17
|
+
get(id: string): Promise<Conversation | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new conversation
|
|
20
|
+
*/
|
|
21
|
+
create(data: Partial<Conversation>, options?: MutationOptions): Promise<Conversation>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a conversation
|
|
24
|
+
*/
|
|
25
|
+
update(id: string, data: Partial<Conversation>, options?: MutationOptions): Promise<Conversation>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a conversation
|
|
28
|
+
*/
|
|
29
|
+
delete(id: string): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ConversationsClient.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for conversation operations
|
|
3
|
+
*/
|
|
4
|
+
export class ConversationsClient {
|
|
5
|
+
constructor(db) {
|
|
6
|
+
this.db = db;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* List conversations
|
|
10
|
+
*/
|
|
11
|
+
async list(options) {
|
|
12
|
+
const result = await this.db.get('conversations', options);
|
|
13
|
+
return result.data;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get a single conversation by ID
|
|
17
|
+
*/
|
|
18
|
+
async get(id) {
|
|
19
|
+
return this.db.getOne('conversations', {
|
|
20
|
+
filter: { id: `eq.${id}` },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create a new conversation
|
|
25
|
+
*/
|
|
26
|
+
async create(data, options) {
|
|
27
|
+
const results = await this.db.post('conversations', data, {
|
|
28
|
+
returning: 'representation',
|
|
29
|
+
...options,
|
|
30
|
+
});
|
|
31
|
+
return results[0];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Update a conversation
|
|
35
|
+
*/
|
|
36
|
+
async update(id, data, options) {
|
|
37
|
+
const results = await this.db.patch('conversations', { id: `eq.${id}` }, data, {
|
|
38
|
+
returning: 'representation',
|
|
39
|
+
...options,
|
|
40
|
+
});
|
|
41
|
+
return results[0];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Delete a conversation
|
|
45
|
+
*/
|
|
46
|
+
async delete(id) {
|
|
47
|
+
await this.db.delete('conversations', { id: `eq.${id}` });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=ConversationsClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationsClient.js","sourceRoot":"","sources":["../../src/client/ConversationsClient.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC9B,YAA6B,EAAY;QAAZ,OAAE,GAAF,EAAE,CAAU;IAAG,CAAC;IAE7C;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,OAAsB;QAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAe,eAAe,EAAE,OAAO,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAe,eAAe,EAAE;YACnD,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,IAA2B,EAC3B,OAAyB;QAEzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAe,eAAe,EAAE,IAAI,EAAE;YACtE,SAAS,EAAE,gBAAgB;YAC3B,GAAG,OAAO;SACX,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,EAAU,EACV,IAA2B,EAC3B,OAAyB;QAEzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CACjC,eAAe,EACf,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAClB,IAAI,EACJ;YACE,SAAS,EAAE,gBAAgB;YAC3B,GAAG,OAAO;SACX,CACF,CAAC;QACF,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 环境 URL 配置
|
|
3
|
+
*/
|
|
4
|
+
export interface EnvironmentUrls {
|
|
5
|
+
postgrest: string;
|
|
6
|
+
auth: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 获取环境配置
|
|
10
|
+
*/
|
|
11
|
+
export declare function getEnvironmentConfig(env: 'dev' | 'prod'): EnvironmentUrls;
|
|
12
|
+
//# sourceMappingURL=EnvironmentConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvironmentConfig.d.ts","sourceRoot":"","sources":["../../src/client/EnvironmentConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAiBD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,GAAG,eAAe,CAEzE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 环境配置映射
|
|
3
|
+
*/
|
|
4
|
+
const ENV_CONFIGS = {
|
|
5
|
+
dev: {
|
|
6
|
+
// 开发/测试环境:用于浏览器联调的 PostgREST / Auth
|
|
7
|
+
postgrest: 'https://postgrest.sg.seaverse.dev',
|
|
8
|
+
auth: 'https://auth.sg.seaverse.dev',
|
|
9
|
+
},
|
|
10
|
+
prod: {
|
|
11
|
+
postgrest: 'https://sandbox-api.seaverse.ai',
|
|
12
|
+
auth: 'https://auth.seaverse.ai',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 获取环境配置
|
|
17
|
+
*/
|
|
18
|
+
export function getEnvironmentConfig(env) {
|
|
19
|
+
return ENV_CONFIGS[env];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=EnvironmentConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvironmentConfig.js","sourceRoot":"","sources":["../../src/client/EnvironmentConfig.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,GAA4C;IAC3D,GAAG,EAAE;QACH,oCAAoC;QACpC,SAAS,EAAE,mCAAmC;QAC9C,IAAI,EAAE,8BAA8B;KACrC;IACD,IAAI,EAAE;QACJ,SAAS,EAAE,iCAAiC;QAC5C,IAAI,EAAE,0BAA0B;KACjC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DbClient } from '../data/DbClient.js';
|
|
2
|
+
import type { QueryOptions, MutationOptions } from '../data/query.types.js';
|
|
3
|
+
import type { Message } from '../types/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Client for message operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class MessagesClient {
|
|
8
|
+
private readonly db;
|
|
9
|
+
constructor(db: DbClient);
|
|
10
|
+
/**
|
|
11
|
+
* List messages for a conversation
|
|
12
|
+
*/
|
|
13
|
+
list(conversationId: string, options?: QueryOptions): Promise<Message[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a single message by ID
|
|
16
|
+
*/
|
|
17
|
+
get(messageId: string): Promise<Message | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Add a new message to a conversation
|
|
20
|
+
*/
|
|
21
|
+
add(conversationId: string, data: Partial<Message>, options?: MutationOptions): Promise<Message>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a message
|
|
24
|
+
*/
|
|
25
|
+
update(messageId: string, data: Partial<Message>, options?: MutationOptions): Promise<Message>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a message
|
|
28
|
+
*/
|
|
29
|
+
delete(messageId: string): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=MessagesClient.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for message operations
|
|
3
|
+
*/
|
|
4
|
+
export class MessagesClient {
|
|
5
|
+
constructor(db) {
|
|
6
|
+
this.db = db;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* List messages for a conversation
|
|
10
|
+
*/
|
|
11
|
+
async list(conversationId, options) {
|
|
12
|
+
const result = await this.db.get('messages', {
|
|
13
|
+
filter: { conversation_id: `eq.${conversationId}` },
|
|
14
|
+
order: 'created_at.asc',
|
|
15
|
+
...options,
|
|
16
|
+
});
|
|
17
|
+
return result.data;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get a single message by ID
|
|
21
|
+
*/
|
|
22
|
+
async get(messageId) {
|
|
23
|
+
return this.db.getOne('messages', {
|
|
24
|
+
filter: { id: `eq.${messageId}` },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Add a new message to a conversation
|
|
29
|
+
*/
|
|
30
|
+
async add(conversationId, data, options) {
|
|
31
|
+
const results = await this.db.post('messages', {
|
|
32
|
+
conversation_id: conversationId,
|
|
33
|
+
...data,
|
|
34
|
+
}, {
|
|
35
|
+
returning: 'representation',
|
|
36
|
+
...options,
|
|
37
|
+
});
|
|
38
|
+
return results[0];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Update a message
|
|
42
|
+
*/
|
|
43
|
+
async update(messageId, data, options) {
|
|
44
|
+
const results = await this.db.patch('messages', { id: `eq.${messageId}` }, data, {
|
|
45
|
+
returning: 'representation',
|
|
46
|
+
...options,
|
|
47
|
+
});
|
|
48
|
+
return results[0];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Delete a message
|
|
52
|
+
*/
|
|
53
|
+
async delete(messageId) {
|
|
54
|
+
await this.db.delete('messages', { id: `eq.${messageId}` });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=MessagesClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessagesClient.js","sourceRoot":"","sources":["../../src/client/MessagesClient.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,YAA6B,EAAY;QAAZ,OAAE,GAAF,EAAE,CAAU;IAAG,CAAC;IAE7C;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,cAAsB,EAAE,OAAsB;QACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAU,UAAU,EAAE;YACpD,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,cAAc,EAAE,EAAE;YACnD,KAAK,EAAE,gBAAgB;YACvB,GAAG,OAAO;SACX,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAU,UAAU,EAAE;YACzC,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,SAAS,EAAE,EAAE;SAClC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CACP,cAAsB,EACtB,IAAsB,EACtB,OAAyB;QAEzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAChC,UAAU,EACV;YACE,eAAe,EAAE,cAAc;YAC/B,GAAG,IAAI;SACR,EACD;YACE,SAAS,EAAE,gBAAgB;YAC3B,GAAG,OAAO;SACX,CACF,CAAC;QACF,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,SAAiB,EACjB,IAAsB,EACtB,OAAyB;QAEzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CACjC,UAAU,EACV,EAAE,EAAE,EAAE,MAAM,SAAS,EAAE,EAAE,EACzB,IAAI,EACJ;YACE,SAAS,EAAE,gBAAgB;YAC3B,GAAG,OAAO;SACX,CACF,CAAC;QACF,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,MAAM,SAAS,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { HttpClient } from '../transport/HttpClient.js';
|
|
2
|
+
import type { QueryOptions, MutationOptions } from './query.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* 带总数的查询结果
|
|
5
|
+
*/
|
|
6
|
+
export interface QueryResultWithCount<T> {
|
|
7
|
+
data: T[];
|
|
8
|
+
count: number | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Simple PostgREST database client
|
|
12
|
+
*/
|
|
13
|
+
export declare class DbClient {
|
|
14
|
+
private readonly http;
|
|
15
|
+
constructor(http: HttpClient);
|
|
16
|
+
/**
|
|
17
|
+
* Get multiple rows from a table
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const conversations = await db.get('conversations', {
|
|
21
|
+
* filter: { user_id: 'eq.123' },
|
|
22
|
+
* order: 'created_at.desc',
|
|
23
|
+
* limit: 10
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // With count
|
|
28
|
+
* const result = await db.get('conversations', {
|
|
29
|
+
* filter: { user_id: 'eq.123' },
|
|
30
|
+
* limit: 10,
|
|
31
|
+
* count: 'exact'
|
|
32
|
+
* });
|
|
33
|
+
* console.log(result.count); // Total count
|
|
34
|
+
* console.log(result.data); // Page data
|
|
35
|
+
*/
|
|
36
|
+
get<T = unknown>(table: string, options?: QueryOptions): Promise<QueryResultWithCount<T>>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a single row from a table
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const conversation = await db.getOne('conversations', {
|
|
42
|
+
* filter: { id: 'eq.123' }
|
|
43
|
+
* });
|
|
44
|
+
*/
|
|
45
|
+
getOne<T = unknown>(table: string, options?: QueryOptions): Promise<T | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Insert one or more rows into a table
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const newConversation = await db.post('conversations', {
|
|
51
|
+
* app_id: 'xxx',
|
|
52
|
+
* user_id: 'yyy'
|
|
53
|
+
* }, {
|
|
54
|
+
* returning: 'representation'
|
|
55
|
+
* });
|
|
56
|
+
*/
|
|
57
|
+
post<T = unknown>(table: string, data: unknown, options?: MutationOptions): Promise<T[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Update rows in a table
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const updated = await db.patch('conversations',
|
|
63
|
+
* { id: 'eq.123' },
|
|
64
|
+
* { title: 'New Title' }
|
|
65
|
+
* );
|
|
66
|
+
*/
|
|
67
|
+
patch<T = unknown>(table: string, filter: Record<string, string>, data: unknown, options?: MutationOptions): Promise<T[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Delete rows from a table
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* await db.delete('conversations', { id: 'eq.123' });
|
|
73
|
+
*/
|
|
74
|
+
delete(table: string, filter: Record<string, string>): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=DbClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DbClient.d.ts","sourceRoot":"","sources":["../../src/data/DbClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGtE;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;;;;;;;;;OAmBG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAyBnC;;;;;;;OAOG;IACG,MAAM,CAAC,CAAC,GAAG,OAAO,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IASpB;;;;;;;;;;OAUG;IACG,IAAI,CAAC,CAAC,GAAG,OAAO,EACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,EAAE,CAAC;IAQf;;;;;;;;OAQG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,EAAE,CAAC;IASf;;;;;OAKG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,OAAO,CAAC,IAAI,CAAC;CAKjB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { buildPostgrestHeaders, buildQueryString } from './postgrest-headers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Simple PostgREST database client
|
|
4
|
+
*/
|
|
5
|
+
export class DbClient {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get multiple rows from a table
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const conversations = await db.get('conversations', {
|
|
14
|
+
* filter: { user_id: 'eq.123' },
|
|
15
|
+
* order: 'created_at.desc',
|
|
16
|
+
* limit: 10
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // With count
|
|
21
|
+
* const result = await db.get('conversations', {
|
|
22
|
+
* filter: { user_id: 'eq.123' },
|
|
23
|
+
* limit: 10,
|
|
24
|
+
* count: 'exact'
|
|
25
|
+
* });
|
|
26
|
+
* console.log(result.count); // Total count
|
|
27
|
+
* console.log(result.data); // Page data
|
|
28
|
+
*/
|
|
29
|
+
async get(table, options = {}) {
|
|
30
|
+
const query = buildQueryString(options);
|
|
31
|
+
const headers = buildPostgrestHeaders(options);
|
|
32
|
+
const response = await this.http.get(`/${table}${query}`, { headers });
|
|
33
|
+
// 解析 Content-Range header 获取总数
|
|
34
|
+
// Format: "0-9/total" or "0-9/*" (if no count requested)
|
|
35
|
+
let count = null;
|
|
36
|
+
const contentRange = response.headers.get('Content-Range');
|
|
37
|
+
if (contentRange && options.count) {
|
|
38
|
+
const match = contentRange.match(/\/(\d+)$/);
|
|
39
|
+
if (match) {
|
|
40
|
+
count = parseInt(match[1], 10);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
// PostgREST:当 offset 超出范围时,可能返回 416(Range Not Satisfiable)。
|
|
45
|
+
// 在这种情况下,上层分页应得到空数组,而不是抛异常。
|
|
46
|
+
data: response.status === 416 ? [] : response.data,
|
|
47
|
+
count,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get a single row from a table
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const conversation = await db.getOne('conversations', {
|
|
55
|
+
* filter: { id: 'eq.123' }
|
|
56
|
+
* });
|
|
57
|
+
*/
|
|
58
|
+
async getOne(table, options = {}) {
|
|
59
|
+
const results = await this.get(table, {
|
|
60
|
+
...options,
|
|
61
|
+
limit: 1,
|
|
62
|
+
});
|
|
63
|
+
return results.data[0] || null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Insert one or more rows into a table
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const newConversation = await db.post('conversations', {
|
|
70
|
+
* app_id: 'xxx',
|
|
71
|
+
* user_id: 'yyy'
|
|
72
|
+
* }, {
|
|
73
|
+
* returning: 'representation'
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
76
|
+
async post(table, data, options = {}) {
|
|
77
|
+
const headers = buildPostgrestHeaders(options);
|
|
78
|
+
const response = await this.http.post(`/${table}`, data, { headers });
|
|
79
|
+
return response.data;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Update rows in a table
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const updated = await db.patch('conversations',
|
|
86
|
+
* { id: 'eq.123' },
|
|
87
|
+
* { title: 'New Title' }
|
|
88
|
+
* );
|
|
89
|
+
*/
|
|
90
|
+
async patch(table, filter, data, options = {}) {
|
|
91
|
+
const query = buildQueryString({ filter });
|
|
92
|
+
const headers = buildPostgrestHeaders(options);
|
|
93
|
+
const response = await this.http.patch(`/${table}${query}`, data, { headers });
|
|
94
|
+
return response.data;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Delete rows from a table
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* await db.delete('conversations', { id: 'eq.123' });
|
|
101
|
+
*/
|
|
102
|
+
async delete(table, filter) {
|
|
103
|
+
const query = buildQueryString({ filter });
|
|
104
|
+
await this.http.delete(`/${table}${query}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=DbClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DbClient.js","sourceRoot":"","sources":["../../src/data/DbClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAUjF;;GAEG;AACH,MAAM,OAAO,QAAQ;IACnB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,GAAG,CACP,KAAa,EACb,UAAwB,EAAE;QAE1B,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAE/C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAM,IAAI,KAAK,GAAG,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAE5E,+BAA+B;QAC/B,yDAAyD;QACzD,IAAI,KAAK,GAAkB,IAAI,CAAC;QAChC,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC3D,IAAI,YAAY,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QAED,OAAO;YACL,4DAA4D;YAC5D,4BAA4B;YAC5B,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI;YAClD,KAAK;SACN,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CACV,KAAa,EACb,UAAwB,EAAE;QAE1B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAI,KAAK,EAAE;YACvC,GAAG,OAAO;YACV,KAAK,EAAE,CAAC;SACT,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IACjC,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI,CACR,KAAa,EACb,IAAa,EACb,UAA2B,EAAE;QAE7B,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAE/C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAM,IAAI,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAE3E,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CACT,KAAa,EACb,MAA8B,EAC9B,IAAa,EACb,UAA2B,EAAE;QAE7B,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAE/C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAM,IAAI,KAAK,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAEpF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CACV,KAAa,EACb,MAA8B;QAE9B,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAE3C,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { QueryOptions, MutationOptions } from './query.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build PostgREST headers from query options
|
|
4
|
+
*/
|
|
5
|
+
export declare function buildPostgrestHeaders(options?: QueryOptions | MutationOptions): Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Build query string from filter options
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildQueryString(options?: QueryOptions): string;
|
|
10
|
+
//# sourceMappingURL=postgrest-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgrest-headers.d.ts","sourceRoot":"","sources":["../../src/data/postgrest-headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEtE;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,YAAY,GAAG,eAAoB,GAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BxB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,YAAiB,GAAG,MAAM,CAgCnE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build PostgREST headers from query options
|
|
3
|
+
*/
|
|
4
|
+
export function buildPostgrestHeaders(options = {}) {
|
|
5
|
+
const headers = {};
|
|
6
|
+
// Count preference
|
|
7
|
+
if ('count' in options && options.count) {
|
|
8
|
+
headers['Prefer'] = `count=${options.count}`;
|
|
9
|
+
}
|
|
10
|
+
// Mutation preferences
|
|
11
|
+
if ('returning' in options) {
|
|
12
|
+
const prefer = [];
|
|
13
|
+
if (options.returning) {
|
|
14
|
+
prefer.push(`return=${options.returning}`);
|
|
15
|
+
}
|
|
16
|
+
if (options.resolution) {
|
|
17
|
+
prefer.push(`resolution=${options.resolution}`);
|
|
18
|
+
}
|
|
19
|
+
if (options.missing) {
|
|
20
|
+
prefer.push(`missing=${options.missing}`);
|
|
21
|
+
}
|
|
22
|
+
if (prefer.length > 0) {
|
|
23
|
+
headers['Prefer'] = prefer.join(',');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return headers;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build query string from filter options
|
|
30
|
+
*/
|
|
31
|
+
export function buildQueryString(options = {}) {
|
|
32
|
+
const params = new URLSearchParams();
|
|
33
|
+
// Select columns
|
|
34
|
+
if (options.select) {
|
|
35
|
+
params.set('select', options.select);
|
|
36
|
+
}
|
|
37
|
+
// Filters
|
|
38
|
+
if (options.filter) {
|
|
39
|
+
for (const [key, value] of Object.entries(options.filter)) {
|
|
40
|
+
params.set(key, value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Order
|
|
44
|
+
if (options.order) {
|
|
45
|
+
params.set('order', options.order);
|
|
46
|
+
}
|
|
47
|
+
// Limit
|
|
48
|
+
if (options.limit !== undefined) {
|
|
49
|
+
params.set('limit', String(options.limit));
|
|
50
|
+
}
|
|
51
|
+
// Offset
|
|
52
|
+
if (options.offset !== undefined) {
|
|
53
|
+
params.set('offset', String(options.offset));
|
|
54
|
+
}
|
|
55
|
+
const query = params.toString();
|
|
56
|
+
return query ? `?${query}` : '';
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=postgrest-headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgrest-headers.js","sourceRoot":"","sources":["../../src/data/postgrest-headers.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAA0C,EAAE;IAE5C,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,mBAAmB;IACnB,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/C,CAAC;IAED,uBAAuB;IACvB,IAAI,WAAW,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,cAAc,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAwB,EAAE;IACzD,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IAErC,iBAAiB;IACjB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,UAAU;IACV,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1D,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,QAAQ;IACR,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,QAAQ;IACR,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,SAAS;IACT,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgREST query options
|
|
3
|
+
*/
|
|
4
|
+
export interface QueryOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Columns to select (default: *)
|
|
7
|
+
* @example "id,name,created_at"
|
|
8
|
+
* @example "*,conversations(*)"
|
|
9
|
+
*/
|
|
10
|
+
select?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Filter conditions
|
|
13
|
+
* @example { id: "eq.123", status: "neq.deleted" }
|
|
14
|
+
*/
|
|
15
|
+
filter?: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Order by clause
|
|
18
|
+
* @example "created_at.desc"
|
|
19
|
+
* @example "name.asc,created_at.desc"
|
|
20
|
+
*/
|
|
21
|
+
order?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Limit number of results
|
|
24
|
+
*/
|
|
25
|
+
limit?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Offset for pagination
|
|
28
|
+
*/
|
|
29
|
+
offset?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Count mode
|
|
32
|
+
* - "exact": Return exact count in Content-Range header
|
|
33
|
+
* - "planned": Return estimated count
|
|
34
|
+
* - "estimated": Return estimated count
|
|
35
|
+
*/
|
|
36
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* PostgREST insert/update options
|
|
40
|
+
*/
|
|
41
|
+
export interface MutationOptions {
|
|
42
|
+
/**
|
|
43
|
+
* What to return after mutation
|
|
44
|
+
* - "representation": Return the modified rows
|
|
45
|
+
* - "minimal": Return nothing
|
|
46
|
+
* - "headers-only": Return only headers
|
|
47
|
+
*/
|
|
48
|
+
returning?: 'representation' | 'minimal' | 'headers-only';
|
|
49
|
+
/**
|
|
50
|
+
* Resolution strategy for conflicts
|
|
51
|
+
* - "merge-duplicates": Merge duplicate rows
|
|
52
|
+
* - "ignore-duplicates": Ignore conflicts
|
|
53
|
+
*/
|
|
54
|
+
resolution?: 'merge-duplicates' | 'ignore-duplicates';
|
|
55
|
+
/**
|
|
56
|
+
* Missing columns
|
|
57
|
+
* - "default": Use default values
|
|
58
|
+
* - "null": Use null values
|
|
59
|
+
*/
|
|
60
|
+
missing?: 'default' | 'null';
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=query.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.types.d.ts","sourceRoot":"","sources":["../../src/data/query.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,GAAG,cAAc,CAAC;IAE1D;;;;OAIG;IACH,UAAU,CAAC,EAAE,kBAAkB,GAAG,mBAAmB,CAAC;IAEtD;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.types.js","sourceRoot":"","sources":["../../src/data/query.types.ts"],"names":[],"mappings":""}
|