@blueking/chat-helper 0.0.1-beta.9 → 0.0.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.
Files changed (42) hide show
  1. package/README.md +631 -141
  2. package/dist/agent/type.d.ts +27 -2
  3. package/dist/agent/type.ts.js +1 -1
  4. package/dist/agent/use-agent.d.ts +464 -484
  5. package/dist/agent/use-agent.ts.js +191 -42
  6. package/dist/event/ag-ui.d.ts +37 -7
  7. package/dist/event/ag-ui.ts.js +225 -173
  8. package/dist/event/type.d.ts +99 -107
  9. package/dist/event/type.ts.js +34 -11
  10. package/dist/http/fetch/fetch.d.ts +5 -1
  11. package/dist/http/fetch/fetch.ts.js +40 -51
  12. package/dist/http/fetch/index.d.ts +1 -0
  13. package/dist/http/fetch/index.ts.js +133 -3
  14. package/dist/http/index.d.ts +14 -5
  15. package/dist/http/index.ts.js +59 -3
  16. package/dist/http/module/index.d.ts +13 -5
  17. package/dist/http/module/index.ts.js +2 -1
  18. package/dist/http/module/message.d.ts +22 -5
  19. package/dist/http/module/message.ts.js +51 -4
  20. package/dist/http/module/session.d.ts +4 -1
  21. package/dist/http/module/session.ts.js +66 -4
  22. package/dist/http/transform/agent.ts.js +11 -8
  23. package/dist/http/transform/message.d.ts +6 -6
  24. package/dist/http/transform/message.ts.js +566 -118
  25. package/dist/http/transform/session.ts.js +9 -1
  26. package/dist/index.d.ts +2983 -3314
  27. package/dist/index.ts.js +27 -5
  28. package/dist/mediator/index.d.ts +2 -0
  29. package/dist/mediator/index.ts.js +26 -0
  30. package/dist/mediator/type.d.ts +50 -0
  31. package/dist/mediator/type.ts.js +28 -0
  32. package/dist/mediator/use-mediator.d.ts +7 -0
  33. package/dist/mediator/use-mediator.ts.js +47 -0
  34. package/dist/message/type.d.ts +280 -146
  35. package/dist/message/type.ts.js +16 -15
  36. package/dist/message/use-message.d.ts +847 -963
  37. package/dist/message/use-message.ts.js +230 -37
  38. package/dist/session/type.d.ts +10 -0
  39. package/dist/session/use-session.d.ts +2006 -2214
  40. package/dist/session/use-session.ts.js +198 -33
  41. package/dist/type.d.ts +2 -0
  42. package/package.json +11 -6
package/dist/index.ts.js CHANGED
@@ -24,22 +24,44 @@
24
24
  * IN THE SOFTWARE.
25
25
  */ import { useAgent } from './agent/index.ts.js';
26
26
  import { useHttp } from './http/index.ts.js';
27
+ import { useMediator } from './mediator/index.ts.js';
27
28
  import { useMessage } from './message/index.ts.js';
28
29
  import { useSession } from './session/index.ts.js';
29
30
  export * from './agent/index.ts.js';
30
31
  export * from './event/index.ts.js';
32
+ export * from './http/index.ts.js';
33
+ export * from './mediator/index.ts.js';
31
34
  export * from './message/index.ts.js';
32
35
  export * from './session/index.ts.js';
33
36
  export * from './type.ts.js';
34
- export const useChatHelper = (options)=>{
37
+ /**
38
+ * Chat Helper 主入口
39
+ * 使用中介者模式协调各个模块之间的通信
40
+ */ export const useChatHelper = (options)=>{
41
+ // 创建中介者
42
+ const mediator = useMediator();
43
+ // 创建各个模块
35
44
  const http = useHttp(options);
36
- const message = useMessage(http);
37
- const agent = useAgent(options, http, message);
38
- const session = useSession(http, message, agent);
45
+ const agent = useAgent(mediator, options.protocol);
46
+ const message = useMessage(mediator);
47
+ const session = useSession(mediator);
48
+ // 注册所有模块
49
+ mediator.registerHttp(http);
50
+ mediator.registerMessage(message);
51
+ mediator.registerAgent(agent);
52
+ mediator.registerSession(session);
53
+ // 重置所有模块
54
+ const reset = (options)=>{
55
+ http.reset(options);
56
+ agent.reset(options.protocol);
57
+ message.reset();
58
+ session.reset();
59
+ };
39
60
  return {
40
61
  agent,
41
62
  session,
42
63
  message,
43
- http
64
+ http,
65
+ reset
44
66
  };
45
67
  };
@@ -0,0 +1,2 @@
1
+ export * from './type';
2
+ export * from './use-mediator';
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making
3
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
4
+ *
5
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
6
+ *
7
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
8
+ *
9
+ * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
10
+ *
11
+ * ---------------------------------------------------
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18
+ * the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
21
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
+ * IN THE SOFTWARE.
25
+ */ export * from './type.ts.js';
26
+ export * from './use-mediator.ts.js';
@@ -0,0 +1,50 @@
1
+ import type { IAgentModule } from '../agent/use-agent';
2
+ import type { IHttpModule } from '../http';
3
+ import type { IMessageModule } from '../message';
4
+ import type { ISessionModule } from '../session/use-session';
5
+ /**
6
+ * 中介者模块接口
7
+ * 用于协调各个模块之间的通信,避免模块之间的直接依赖
8
+ */
9
+ export interface IMediatorModule {
10
+ /**
11
+ * 获取 Agent 模块
12
+ * @returns Agent 模块实例或 null
13
+ */
14
+ agent: IAgentModule | null;
15
+ /**
16
+ * 获取 Http 模块
17
+ * @returns Http 模块实例或 null
18
+ */
19
+ http: IHttpModule | null;
20
+ /**
21
+ * 获取 Message 模块
22
+ * @returns Message 模块实例或 null
23
+ */
24
+ message: IMessageModule | null;
25
+ /**
26
+ * 获取 Session 模块
27
+ * @returns Session 模块实例或 null
28
+ */
29
+ session: ISessionModule | null;
30
+ /**
31
+ * 注册 Agent 模块
32
+ * @param agent - Agent 模块实例
33
+ */
34
+ registerAgent(agent: IAgentModule): void;
35
+ /**
36
+ * 注册 Http 模块
37
+ * @param http - Http 模块实例
38
+ */
39
+ registerHttp(http: IHttpModule): void;
40
+ /**
41
+ * 注册 Message 模块
42
+ * @param message - Message 模块实例
43
+ */
44
+ registerMessage(message: IMessageModule): void;
45
+ /**
46
+ * 注册 Session 模块
47
+ * @param session - Session 模块实例
48
+ */
49
+ registerSession(session: ISessionModule): void;
50
+ }
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making
3
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
4
+ *
5
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
6
+ *
7
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
8
+ *
9
+ * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
10
+ *
11
+ * ---------------------------------------------------
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18
+ * the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
21
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
+ * IN THE SOFTWARE.
25
+ */ /**
26
+ * 中介者模块接口
27
+ * 用于协调各个模块之间的通信,避免模块之间的直接依赖
28
+ */ export { };
@@ -0,0 +1,7 @@
1
+ import type { IMediatorModule } from './type';
2
+ /**
3
+ * 中介者模块
4
+ * 负责协调各个模块之间的通信,避免模块之间的循环依赖
5
+ */
6
+ export declare const useMediator: () => IMediatorModule;
7
+ export type { IMediatorModule } from './type';
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making
3
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
4
+ *
5
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
6
+ *
7
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
8
+ *
9
+ * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
10
+ *
11
+ * ---------------------------------------------------
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18
+ * the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
21
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
+ * IN THE SOFTWARE.
25
+ */ /**
26
+ * 中介者模块
27
+ * 负责协调各个模块之间的通信,避免模块之间的循环依赖
28
+ */ export const useMediator = ()=>{
29
+ return {
30
+ agent: null,
31
+ http: null,
32
+ message: null,
33
+ session: null,
34
+ registerAgent (agent) {
35
+ this.agent = agent;
36
+ },
37
+ registerHttp (http) {
38
+ this.http = http;
39
+ },
40
+ registerMessage (message) {
41
+ this.message = message;
42
+ },
43
+ registerSession (session) {
44
+ this.session = session;
45
+ }
46
+ };
47
+ };