@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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseError } from './BaseError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Authentication and authorization errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class AuthError extends BaseError {
|
|
6
|
+
constructor(message: string, statusCode?: number, details?: unknown);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=AuthError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthError.d.ts","sourceRoot":"","sources":["../../src/errors/AuthError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,qBAAa,SAAU,SAAQ,SAAS;gBAC1B,OAAO,EAAE,MAAM,EAAE,UAAU,GAAE,MAAY,EAAE,OAAO,CAAC,EAAE,OAAO;CAGzE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseError } from './BaseError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Authentication and authorization errors
|
|
4
|
+
*/
|
|
5
|
+
export class AuthError extends BaseError {
|
|
6
|
+
constructor(message, statusCode = 401, details) {
|
|
7
|
+
super(message, 'AUTH_ERROR', statusCode, details);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AuthError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthError.js","sourceRoot":"","sources":["../../src/errors/AuthError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,YAAY,OAAe,EAAE,aAAqB,GAAG,EAAE,OAAiB;QACtE,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all SeaLink SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class BaseError extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly statusCode?: number;
|
|
7
|
+
readonly details?: unknown;
|
|
8
|
+
constructor(message: string, code: string, statusCode?: number, details?: unknown);
|
|
9
|
+
toJSON(): {
|
|
10
|
+
name: string;
|
|
11
|
+
message: string;
|
|
12
|
+
code: string;
|
|
13
|
+
statusCode: number | undefined;
|
|
14
|
+
details: unknown;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=BaseError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseError.d.ts","sourceRoot":"","sources":["../../src/errors/BaseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;gBAGhC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,OAAO;IAcnB,MAAM;;;;;;;CASP"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all SeaLink SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export class BaseError extends Error {
|
|
5
|
+
constructor(message, code, statusCode, details) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = this.constructor.name;
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.details = details;
|
|
11
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
toJSON() {
|
|
17
|
+
return {
|
|
18
|
+
name: this.name,
|
|
19
|
+
message: this.message,
|
|
20
|
+
code: this.code,
|
|
21
|
+
statusCode: this.statusCode,
|
|
22
|
+
details: this.details,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=BaseError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseError.js","sourceRoot":"","sources":["../../src/errors/BaseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAKlC,YACE,OAAe,EACf,IAAY,EACZ,UAAmB,EACnB,OAAiB;QAEjB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,qFAAqF;QACrF,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkError.d.ts","sourceRoot":"","sources":["../../src/errors/NetworkError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,qBAAa,YAAa,SAAQ,SAAS;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAG/C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseError } from './BaseError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Network-related errors (connection, DNS, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export class NetworkError extends BaseError {
|
|
6
|
+
constructor(message, details) {
|
|
7
|
+
super(message, 'NETWORK_ERROR', undefined, details);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=NetworkError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkError.js","sourceRoot":"","sources":["../../src/errors/NetworkError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseError } from './BaseError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Protocol-level errors (invalid response format, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export declare class ProtocolError extends BaseError {
|
|
6
|
+
constructor(message: string, details?: unknown);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ProtocolError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtocolError.d.ts","sourceRoot":"","sources":["../../src/errors/ProtocolError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAG/C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseError } from './BaseError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Protocol-level errors (invalid response format, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export class ProtocolError extends BaseError {
|
|
6
|
+
constructor(message, details) {
|
|
7
|
+
super(message, 'PROTOCOL_ERROR', undefined, details);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ProtocolError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtocolError.js","sourceRoot":"","sources":["../../src/errors/ProtocolError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeoutError.d.ts","sourceRoot":"","sources":["../../src/errors/TimeoutError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,qBAAa,YAAa,SAAQ,SAAS;gBAC7B,OAAO,GAAE,MAA0B,EAAE,SAAS,CAAC,EAAE,MAAM;CAGpE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseError } from './BaseError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Request timeout errors
|
|
4
|
+
*/
|
|
5
|
+
export class TimeoutError extends BaseError {
|
|
6
|
+
constructor(message = 'Request timeout', timeoutMs) {
|
|
7
|
+
super(message, 'TIMEOUT_ERROR', 408, { timeoutMs });
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=TimeoutError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../../src/errors/TimeoutError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,YAAY,UAAkB,iBAAiB,EAAE,SAAkB;QACjE,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BaseError } from './BaseError.js';
|
|
2
|
+
export { NetworkError } from './NetworkError.js';
|
|
3
|
+
export { AuthError } from './AuthError.js';
|
|
4
|
+
export { TimeoutError } from './TimeoutError.js';
|
|
5
|
+
export { ProtocolError } from './ProtocolError.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BaseError } from './BaseError.js';
|
|
2
|
+
export { NetworkError } from './NetworkError.js';
|
|
3
|
+
export { AuthError } from './AuthError.js';
|
|
4
|
+
export { TimeoutError } from './TimeoutError.js';
|
|
5
|
+
export { ProtocolError } from './ProtocolError.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DbClient } from '../data/DbClient.js';
|
|
2
|
+
import type { App } from '../types/models.types.js';
|
|
3
|
+
import type { PaginationOptions, PaginatedResult } from '../types/pagination.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* 应用列表查询选项
|
|
6
|
+
*/
|
|
7
|
+
export interface ListAppsOptions extends PaginationOptions {
|
|
8
|
+
/**
|
|
9
|
+
* 按用户 ID 过滤
|
|
10
|
+
*/
|
|
11
|
+
userId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 按状态过滤
|
|
14
|
+
*/
|
|
15
|
+
status?: 'draft' | 'published' | 'archived';
|
|
16
|
+
/**
|
|
17
|
+
* 排序方向
|
|
18
|
+
* @default 'desc'
|
|
19
|
+
*/
|
|
20
|
+
order?: 'asc' | 'desc';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 应用资源类
|
|
24
|
+
*/
|
|
25
|
+
export declare class AppsResource {
|
|
26
|
+
private readonly db;
|
|
27
|
+
constructor(db: DbClient);
|
|
28
|
+
/**
|
|
29
|
+
* 列出应用(带分页)
|
|
30
|
+
*/
|
|
31
|
+
list(options?: ListAppsOptions): Promise<PaginatedResult<App>>;
|
|
32
|
+
/**
|
|
33
|
+
* 获取单个应用
|
|
34
|
+
*/
|
|
35
|
+
get(id: string): Promise<App | null>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=AppsResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppsResource.d.ts","sourceRoot":"","sources":["../../src/resources/AppsResource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAY,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIvF;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;IAE5C;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEzC;;OAEG;IACG,IAAI,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IA6BxE;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;CAS3C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { calculatePaginationMeta, pageToOffset } from '../types/pagination.types.js';
|
|
2
|
+
import { transformApp } from '../transforms/app.transform.js';
|
|
3
|
+
/**
|
|
4
|
+
* 应用资源类
|
|
5
|
+
*/
|
|
6
|
+
export class AppsResource {
|
|
7
|
+
constructor(db) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 列出应用(带分页)
|
|
12
|
+
*/
|
|
13
|
+
async list(options = {}) {
|
|
14
|
+
// 分页参数
|
|
15
|
+
const page = options.page || 1;
|
|
16
|
+
const pageSize = options.pageSize || 20;
|
|
17
|
+
const { limit, offset } = pageToOffset(page, pageSize);
|
|
18
|
+
// 构建过滤条件
|
|
19
|
+
const filter = {};
|
|
20
|
+
if (options.userId)
|
|
21
|
+
filter.user_id = `eq.${options.userId}`;
|
|
22
|
+
if (options.status)
|
|
23
|
+
filter.status = `eq.${options.status}`;
|
|
24
|
+
const dbApps = await this.db.get('apps', {
|
|
25
|
+
filter,
|
|
26
|
+
order: `created_at.${options.order || 'desc'}`,
|
|
27
|
+
limit,
|
|
28
|
+
offset,
|
|
29
|
+
count: 'exact',
|
|
30
|
+
});
|
|
31
|
+
// 获取总数(从响应头)
|
|
32
|
+
const total = dbApps.count || 0;
|
|
33
|
+
const pagination = calculatePaginationMeta(total, page, pageSize);
|
|
34
|
+
return {
|
|
35
|
+
data: dbApps.data.map(transformApp),
|
|
36
|
+
pagination,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 获取单个应用
|
|
41
|
+
*/
|
|
42
|
+
async get(id) {
|
|
43
|
+
const dbApp = await this.db.getOne('apps', {
|
|
44
|
+
filter: { app_id: `eq.${id}` },
|
|
45
|
+
});
|
|
46
|
+
if (!dbApp)
|
|
47
|
+
return null;
|
|
48
|
+
return transformApp(dbApp);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=AppsResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppsResource.js","sourceRoot":"","sources":["../../src/resources/AppsResource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAuB9D;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB,YAA6B,EAAY;QAAZ,OAAE,GAAF,EAAE,CAAU;IAAG,CAAC;IAE7C;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,UAA2B,EAAE;QACtC,OAAO;QACP,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACxC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEvD,SAAS;QACT,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,IAAI,OAAO,CAAC,MAAM;YAAE,MAAM,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;QAC5D,IAAI,OAAO,CAAC,MAAM;YAAE,MAAM,CAAC,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;QAE3D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAe,MAAM,EAAE;YACrD,MAAM;YACN,KAAK,EAAE,cAAc,OAAO,CAAC,KAAK,IAAI,MAAM,EAAE;YAC9C,KAAK;YACL,MAAM;YACN,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;QAEH,aAAa;QACb,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;QAChC,MAAM,UAAU,GAAG,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAElE,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC;YACnC,UAAU;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAe,MAAM,EAAE;YACvD,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;SAC/B,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { DbClient } from '../data/DbClient.js';
|
|
2
|
+
import type { Conversation, ConversationResponse, ListAppsWithConversationsResult } from '../types/models.types.js';
|
|
3
|
+
import type { PaginationOptions, PaginatedResult } from '../types/pagination.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* 会话列表查询选项
|
|
6
|
+
*/
|
|
7
|
+
export interface ListConversationsOptions extends PaginationOptions {
|
|
8
|
+
/**
|
|
9
|
+
* 按应用 ID 过滤
|
|
10
|
+
*/
|
|
11
|
+
appId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 按用户 ID 过滤
|
|
14
|
+
*/
|
|
15
|
+
userId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 排序字段
|
|
18
|
+
* @default 'createdAt'
|
|
19
|
+
*/
|
|
20
|
+
orderBy?: 'createdAt' | 'updatedAt' | 'lastActiveAt';
|
|
21
|
+
/**
|
|
22
|
+
* 排序方向
|
|
23
|
+
* @default 'desc'
|
|
24
|
+
*/
|
|
25
|
+
order?: 'asc' | 'desc';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 创建会话数据
|
|
29
|
+
*/
|
|
30
|
+
export interface CreateConversationData {
|
|
31
|
+
title: string;
|
|
32
|
+
appId?: string | null;
|
|
33
|
+
userId: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 更新会话数据
|
|
37
|
+
*/
|
|
38
|
+
export interface UpdateConversationData {
|
|
39
|
+
title?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 会话资源类
|
|
43
|
+
*/
|
|
44
|
+
export declare class ConversationsResource {
|
|
45
|
+
private readonly db;
|
|
46
|
+
private readonly getAccessToken?;
|
|
47
|
+
private readonly authBaseUrl?;
|
|
48
|
+
constructor(db: DbClient, getAccessToken?: (() => string | null | Promise<string | null>) | undefined, authBaseUrl?: string | undefined);
|
|
49
|
+
/**
|
|
50
|
+
* 列出会话(带分页)
|
|
51
|
+
*/
|
|
52
|
+
list(options?: ListConversationsOptions): Promise<PaginatedResult<Conversation>>;
|
|
53
|
+
/**
|
|
54
|
+
* 获取单个会话
|
|
55
|
+
*/
|
|
56
|
+
get(id: string): Promise<Conversation | null>;
|
|
57
|
+
/**
|
|
58
|
+
* 创建会话
|
|
59
|
+
*/
|
|
60
|
+
create(data: CreateConversationData): Promise<Conversation>;
|
|
61
|
+
/**
|
|
62
|
+
* 创建会话并返回 API 响应格式(snake_case)
|
|
63
|
+
*/
|
|
64
|
+
createWithResponse(data: CreateConversationData): Promise<ConversationResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* 更新会话
|
|
67
|
+
*/
|
|
68
|
+
update(id: string, data: UpdateConversationData): Promise<Conversation>;
|
|
69
|
+
/**
|
|
70
|
+
* 删除会话
|
|
71
|
+
*/
|
|
72
|
+
delete(id: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* 聚合查询:获取应用及其会话列表
|
|
75
|
+
* 每个 app 只返回 message_count 最大的会话
|
|
76
|
+
*
|
|
77
|
+
* 替代 builder-sdk 的 GET /api/apps/with-conversations
|
|
78
|
+
* 直接从 PostgREST 并行获取数据
|
|
79
|
+
*/
|
|
80
|
+
listAppsWithConversations(options?: {
|
|
81
|
+
appId?: string;
|
|
82
|
+
userId?: string;
|
|
83
|
+
page?: number;
|
|
84
|
+
pageSize?: number;
|
|
85
|
+
}): Promise<ListAppsWithConversationsResult>;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=ConversationsResource.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { DbClient } from '../data/DbClient.js';
|
|
2
|
+
import type { Message } from '../types/models.types.js';
|
|
3
|
+
import type { PaginationOptions, PaginatedResult } from '../types/pagination.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* 消息列表查询选项
|
|
6
|
+
*/
|
|
7
|
+
export interface ListMessagesOptions extends PaginationOptions {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 创建消息数据
|
|
11
|
+
*/
|
|
12
|
+
export interface CreateMessageData {
|
|
13
|
+
role: 'user' | 'assistant' | 'system';
|
|
14
|
+
content: string;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 消息资源类
|
|
19
|
+
*/
|
|
20
|
+
export declare class MessagesResource {
|
|
21
|
+
private readonly db;
|
|
22
|
+
constructor(db: DbClient);
|
|
23
|
+
/**
|
|
24
|
+
* 列出会话的消息(带分页和去重)
|
|
25
|
+
*/
|
|
26
|
+
list(conversationId: string, options?: ListMessagesOptions): Promise<PaginatedResult<Message>>;
|
|
27
|
+
/**
|
|
28
|
+
* 获取单条消息
|
|
29
|
+
*/
|
|
30
|
+
get(messageId: string): Promise<Message | null>;
|
|
31
|
+
/**
|
|
32
|
+
* 添加消息
|
|
33
|
+
*/
|
|
34
|
+
create(conversationId: string, data: CreateMessageData): Promise<Message>;
|
|
35
|
+
/**
|
|
36
|
+
* 更新消息
|
|
37
|
+
*/
|
|
38
|
+
update(messageId: string, data: Partial<CreateMessageData>): Promise<Message>;
|
|
39
|
+
/**
|
|
40
|
+
* 删除消息
|
|
41
|
+
*/
|
|
42
|
+
delete(messageId: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* 去重媒体消息
|
|
45
|
+
* 如果两条消息具有相同的 role、content、timestamp 和 media 内容,只保留第一条
|
|
46
|
+
*
|
|
47
|
+
* 对齐 runtime-plugins/conversations/src/handlers/messages.ts 的去重逻辑:
|
|
48
|
+
* 直接检查消息顶层的 type 和 media 字段(而非 metadata)
|
|
49
|
+
*/
|
|
50
|
+
private deduplicateMediaMessages;
|
|
51
|
+
/**
|
|
52
|
+
* 创建媒体去重键
|
|
53
|
+
* 对数组进行排序以确保 ["a", "b"] 和 ["b", "a"] 被视为相同
|
|
54
|
+
*/
|
|
55
|
+
private createMediaKey;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=MessagesResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessagesResource.d.ts","sourceRoot":"","sources":["../../src/resources/MessagesResource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAY,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIvF;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;CAE7D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEzC;;OAEG;IACG,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IA8BxG;;OAEG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAUrD;;OAEG;IACG,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAa/E;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAanF;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAiChC;;;OAGG;IACH,OAAO,CAAC,cAAc;CAiBvB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { calculatePaginationMeta, pageToOffset } from '../types/pagination.types.js';
|
|
2
|
+
import { transformMessage, toDbMessage } from '../transforms/message.transform.js';
|
|
3
|
+
/**
|
|
4
|
+
* 消息资源类
|
|
5
|
+
*/
|
|
6
|
+
export class MessagesResource {
|
|
7
|
+
constructor(db) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 列出会话的消息(带分页和去重)
|
|
12
|
+
*/
|
|
13
|
+
async list(conversationId, options = {}) {
|
|
14
|
+
// 分页参数
|
|
15
|
+
const page = options.page || 1;
|
|
16
|
+
const pageSize = options.pageSize || 100;
|
|
17
|
+
const { limit, offset } = pageToOffset(page, pageSize);
|
|
18
|
+
const dbMessages = await this.db.get('messages', {
|
|
19
|
+
filter: { conversation_id: `eq.${conversationId}` },
|
|
20
|
+
order: 'created_at.desc', // 默认倒序,最新的消息在前
|
|
21
|
+
limit,
|
|
22
|
+
offset,
|
|
23
|
+
count: 'exact',
|
|
24
|
+
});
|
|
25
|
+
// 转换消息
|
|
26
|
+
const messages = dbMessages.data.map(transformMessage);
|
|
27
|
+
// 去重(移除重复的媒体消息)
|
|
28
|
+
const dedupedMessages = this.deduplicateMediaMessages(messages);
|
|
29
|
+
// 获取总数(从响应头)
|
|
30
|
+
const total = dbMessages.count || 0;
|
|
31
|
+
const pagination = calculatePaginationMeta(total, page, pageSize);
|
|
32
|
+
return {
|
|
33
|
+
data: dedupedMessages,
|
|
34
|
+
pagination,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 获取单条消息
|
|
39
|
+
*/
|
|
40
|
+
async get(messageId) {
|
|
41
|
+
const dbMsg = await this.db.getOne('messages', {
|
|
42
|
+
filter: { id: `eq.${messageId}` },
|
|
43
|
+
});
|
|
44
|
+
if (!dbMsg)
|
|
45
|
+
return null;
|
|
46
|
+
return transformMessage(dbMsg);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 添加消息
|
|
50
|
+
*/
|
|
51
|
+
async create(conversationId, data) {
|
|
52
|
+
const dbData = {
|
|
53
|
+
conversation_id: conversationId,
|
|
54
|
+
...toDbMessage(data),
|
|
55
|
+
};
|
|
56
|
+
const results = await this.db.post('messages', dbData, {
|
|
57
|
+
returning: 'representation',
|
|
58
|
+
});
|
|
59
|
+
return transformMessage(results[0]);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 更新消息
|
|
63
|
+
*/
|
|
64
|
+
async update(messageId, data) {
|
|
65
|
+
const dbData = toDbMessage(data);
|
|
66
|
+
const results = await this.db.patch('messages', { id: `eq.${messageId}` }, dbData, { returning: 'representation' });
|
|
67
|
+
return transformMessage(results[0]);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 删除消息
|
|
71
|
+
*/
|
|
72
|
+
async delete(messageId) {
|
|
73
|
+
await this.db.delete('messages', { id: `eq.${messageId}` });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 去重媒体消息
|
|
77
|
+
* 如果两条消息具有相同的 role、content、timestamp 和 media 内容,只保留第一条
|
|
78
|
+
*
|
|
79
|
+
* 对齐 runtime-plugins/conversations/src/handlers/messages.ts 的去重逻辑:
|
|
80
|
+
* 直接检查消息顶层的 type 和 media 字段(而非 metadata)
|
|
81
|
+
*/
|
|
82
|
+
deduplicateMediaMessages(messages) {
|
|
83
|
+
const result = [];
|
|
84
|
+
const seenMedia = new Set();
|
|
85
|
+
for (const msg of messages) {
|
|
86
|
+
// 检查消息是否是 media 类型且包含 media 数据
|
|
87
|
+
// 对齐 runtime-plugins 的逻辑:检查 msg.type === 'media' && msg.media
|
|
88
|
+
const isMediaType = msg.type === 'media';
|
|
89
|
+
const hasMedia = isMediaType && msg.media;
|
|
90
|
+
if (hasMedia) {
|
|
91
|
+
// 创建去重键(基于 content、role、timestamp 和 media)
|
|
92
|
+
const mediaKey = this.createMediaKey(msg.content || '', msg.role || 'unknown', msg.timestamp, msg.media);
|
|
93
|
+
// 如果已经见过这个媒体内容,跳过
|
|
94
|
+
if (seenMedia.has(mediaKey)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
seenMedia.add(mediaKey);
|
|
98
|
+
}
|
|
99
|
+
result.push(msg);
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 创建媒体去重键
|
|
105
|
+
* 对数组进行排序以确保 ["a", "b"] 和 ["b", "a"] 被视为相同
|
|
106
|
+
*/
|
|
107
|
+
createMediaKey(content, role, timestamp, media) {
|
|
108
|
+
// 排序图片
|
|
109
|
+
const images = (media.images || []).slice().sort();
|
|
110
|
+
// 排序音频
|
|
111
|
+
const audios = (media.audios || []).slice().sort();
|
|
112
|
+
// 排序视频
|
|
113
|
+
const videos = (media.videos || []).slice().sort();
|
|
114
|
+
return `content:${content}|role:${role}|ts:${timestamp}|images:${JSON.stringify(images)}|audios:${JSON.stringify(audios)}|videos:${JSON.stringify(videos)}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=MessagesResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessagesResource.js","sourceRoot":"","sources":["../../src/resources/MessagesResource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAkBnF;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B,YAA6B,EAAY;QAAZ,OAAE,GAAF,EAAE,CAAU;IAAG,CAAC;IAE7C;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,cAAsB,EAAE,UAA+B,EAAE;QAClE,OAAO;QACP,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,GAAG,CAAC;QACzC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,E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BAAkB;gBAClB,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC5B,SAAS;gBACX,CAAC;gBAED,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACK,cAAc,CACpB,OAAe,EACf,IAAY,EACZ,SAAiB,EACjB,KAAU;QAEV,OAAO;QACP,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QAEnD,OAAO;QACP,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QAEnD,OAAO;QACP,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QAEnD,OAAO,WAAW,OAAO,SAAS,IAAI,OAAO,SAAS,WAAW,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9J,CAAC;CACF"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export interface UrlSessionTokenConfig {
|
|
5
5
|
/**
|
|
6
6
|
* Auth service base URL
|
|
7
|
-
* @default "https://auth.
|
|
7
|
+
* @default "https://auth.seaverse.ai"
|
|
8
8
|
*/
|
|
9
9
|
authBaseUrl?: string;
|
|
10
10
|
/**
|
|
@@ -38,7 +38,7 @@ export declare function clearUrlSessionTokenCache(): void;
|
|
|
38
38
|
* @example
|
|
39
39
|
* const token = await getUrlSessionToken({
|
|
40
40
|
* accessToken: 'user-access-token',
|
|
41
|
-
* authBaseUrl: 'https://auth.
|
|
41
|
+
* authBaseUrl: 'https://auth.seaverse.ai'
|
|
42
42
|
* });
|
|
43
43
|
*/
|
|
44
44
|
export declare function getUrlSessionToken(config: UrlSessionTokenConfig): Promise<string | null>;
|
|
@@ -29,7 +29,7 @@ export function clearUrlSessionTokenCache() {
|
|
|
29
29
|
* @example
|
|
30
30
|
* const token = await getUrlSessionToken({
|
|
31
31
|
* accessToken: 'user-access-token',
|
|
32
|
-
* authBaseUrl: 'https://auth.
|
|
32
|
+
* authBaseUrl: 'https://auth.seaverse.ai'
|
|
33
33
|
* });
|
|
34
34
|
*/
|
|
35
35
|
export async function getUrlSessionToken(config) {
|
|
@@ -64,7 +64,7 @@ export async function getUrlSessionToken(config) {
|
|
|
64
64
|
* 实际发起 HTTP 请求获取 url_session_token(内部方法)
|
|
65
65
|
*/
|
|
66
66
|
async function fetchUrlSessionToken(config) {
|
|
67
|
-
const { authBaseUrl = 'https://auth.
|
|
67
|
+
const { authBaseUrl = 'https://auth.seaverse.ai', accessToken, fetch: customFetch = globalThis.fetch, timeoutMs = 10000, } = config;
|
|
68
68
|
const startTime = Date.now();
|
|
69
69
|
try {
|
|
70
70
|
const endpoint = `${authBaseUrl}/api/v1/url-session/generate`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-token.js","sourceRoot":"","sources":["../../src/session/session-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAwCnD,uDAAuD;AACvD,sDAAsD;AACtD,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO;AAE3C,kBAAkB;AAClB,IAAI,WAAW,GAAkB,IAAI,CAAC;AACtC,cAAc;AACd,IAAI,WAAW,GAAG,CAAC,CAAC;AACpB,mEAAmE;AACnE,IAAI,cAAc,GAAkC,IAAI,CAAC;AAEzD;;;GAGG;AACH,MAAM,UAAU,yBAA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