@wabot-dev/framework 0.1.0-beta.6 → 0.1.0-beta.61

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 (185) hide show
  1. package/dist/src/addon/async/pg/PgJobRepository.js +26 -0
  2. package/dist/src/addon/auth/api-key/@apiKeyConnectionGuard.js +16 -0
  3. package/dist/src/addon/auth/api-key/@apiKeyGuard.js +17 -0
  4. package/dist/src/addon/auth/api-key/ApiKey.js +53 -0
  5. package/dist/src/addon/auth/api-key/ApiKeyConnectionGuardMiddleware.js +57 -0
  6. package/dist/src/addon/auth/api-key/ApiKeyGuardMiddleware.js +45 -0
  7. package/dist/src/addon/auth/api-key/ApiKeyRepository.js +35 -0
  8. package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +28 -0
  9. package/dist/src/addon/auth/api-key/RemoteApiKeyRepository.js +42 -0
  10. package/dist/src/addon/auth/jwt/@jwtConnectionGuard.js +16 -0
  11. package/dist/src/addon/auth/jwt/@jwtGuard.js +17 -0
  12. package/dist/src/addon/auth/jwt/Jwt.js +53 -0
  13. package/dist/src/addon/auth/jwt/JwtAccessAndRefreshTokenDto.js +20 -0
  14. package/dist/src/addon/auth/jwt/JwtConfig.js +28 -0
  15. package/dist/src/addon/auth/jwt/JwtConnectionGuardMiddleware.js +57 -0
  16. package/dist/src/addon/auth/jwt/JwtGuardMiddleware.js +45 -0
  17. package/dist/src/addon/auth/jwt/JwtRefreshToken.js +56 -0
  18. package/dist/src/addon/auth/jwt/JwtRefreshTokenRepository.js +25 -0
  19. package/dist/src/addon/auth/jwt/JwtSigner.js +36 -0
  20. package/dist/src/addon/auth/jwt/JwtTokenDto.js +22 -0
  21. package/dist/src/addon/auth/jwt/PgJwtRefreshTokenRepository.js +21 -0
  22. package/dist/src/addon/chat-bot/anthropic/AnthropicChatAdapter.js +135 -0
  23. package/dist/src/addon/chat-bot/deepseek/DeepSeekChatAdapter.js +137 -0
  24. package/dist/src/addon/chat-bot/google/GoogleChatAdapter.js +128 -0
  25. package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +117 -0
  26. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatMemory.js +6 -4
  27. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatRepository.js +6 -5
  28. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatRepository.js +2 -2
  29. package/dist/src/addon/chat-bot/wabot/WabotChatAdapter.js +41 -0
  30. package/dist/src/addon/chat-controller/cmd/@cmd.js +23 -0
  31. package/dist/src/{channels → addon/chat-controller}/cmd/CmdChannel.js +4 -26
  32. package/dist/src/{channels → addon/chat-controller}/socket/@socket.js +9 -4
  33. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannel.js +5 -23
  34. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannelConfig.js +1 -1
  35. package/dist/src/{channels → addon/chat-controller}/telegram/@telegram.js +9 -4
  36. package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannel.js +4 -22
  37. package/dist/src/addon/chat-controller/whatsapp/@whatsApp.js +25 -0
  38. package/dist/src/{channels → addon/chat-controller}/whatsapp/EnvWhatsAppRepository.js +3 -3
  39. package/dist/src/{channels → addon/chat-controller}/whatsapp/PgWhatsAppRepository.js +2 -2
  40. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsApp.js +2 -4
  41. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannel.js +6 -18
  42. package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiver.js +10 -0
  43. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSender.js +20 -41
  44. package/dist/src/addon/chat-controller/whatsapp/cloud-api/WhatsAppReceiverByCloudApi.js +97 -0
  45. package/dist/src/{channels/whatsapp → addon/chat-controller/whatsapp/cloud-api}/WhatsAppSenderByCloudApi.js +26 -20
  46. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppProxyContracts.js +5 -0
  47. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppReceiverByWabotProxy.js +65 -0
  48. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppSenderByWabotProxy.js +60 -0
  49. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppWabotProxyConnection.js +45 -0
  50. package/dist/src/addon/mindset/html/HtmlModule.js +70 -0
  51. package/dist/src/core/auth/Auth.js +24 -0
  52. package/dist/src/core/{Persistent.js → entity/Entity.js} +24 -12
  53. package/dist/src/core/env/Env.js +39 -0
  54. package/dist/src/core/error/CustomError.js +15 -0
  55. package/dist/src/core/injection/index.js +4 -0
  56. package/dist/src/core/mapper/Mapper.js +42 -0
  57. package/dist/src/core/password/Password.js +30 -0
  58. package/dist/src/core/random/Random.js +65 -0
  59. package/dist/src/core/storable/Storable.js +8 -0
  60. package/dist/src/core/validation/core/validateArray.js +51 -0
  61. package/dist/src/core/validation/core/validateIsOptional.js +5 -0
  62. package/dist/src/core/validation/core/validateModel.js +36 -0
  63. package/dist/src/core/validation/metadata/@isArray.js +18 -0
  64. package/dist/src/core/validation/metadata/@isModel.js +18 -0
  65. package/dist/src/core/validation/metadata/@isOptional.js +17 -0
  66. package/dist/src/core/validation/metadata/ValidationMetadataStore.js +98 -0
  67. package/dist/src/core/validation/modelInfo.js +9 -0
  68. package/dist/src/core/validation/validate.js +11 -0
  69. package/dist/src/core/validation/validators/is-boolean/@isBoolean.js +17 -0
  70. package/dist/src/core/validation/validators/is-boolean/validateIsBoolean.js +12 -0
  71. package/dist/src/core/validation/validators/is-date/@isDate.js +17 -0
  72. package/dist/src/core/validation/validators/is-date/validateIsDate.js +16 -0
  73. package/dist/src/core/validation/validators/is-in/@isIn.js +18 -0
  74. package/dist/src/core/validation/validators/is-in/validateIsIn.js +12 -0
  75. package/dist/src/core/validation/validators/is-not-empty/@isNotEmpty.js +17 -0
  76. package/dist/src/core/validation/validators/is-not-empty/validateIsNotEmpty.js +12 -0
  77. package/dist/src/core/validation/validators/is-number/@isNumber.js +17 -0
  78. package/dist/src/core/validation/validators/is-number/validateIsNumber.js +12 -0
  79. package/dist/src/core/validation/validators/is-present/@isPresent.js +17 -0
  80. package/dist/src/core/validation/validators/is-present/validateIsPresent.js +12 -0
  81. package/dist/src/core/validation/validators/is-string/@isString.js +17 -0
  82. package/dist/src/core/validation/validators/is-string/validateIsString.js +12 -0
  83. package/dist/src/core/validation/validators/max/@max.js +18 -0
  84. package/dist/src/core/validation/validators/max/validateMax.js +17 -0
  85. package/dist/src/core/validation/validators/min/@min.js +18 -0
  86. package/dist/src/core/validation/validators/min/validateMin.js +17 -0
  87. package/dist/src/feature/async/@command.js +11 -0
  88. package/dist/src/feature/async/@commandHandler.js +12 -0
  89. package/dist/src/feature/async/Async.js +38 -0
  90. package/dist/src/feature/async/Command.js +9 -0
  91. package/dist/src/feature/async/CommandMetadataStore.js +38 -0
  92. package/dist/src/feature/async/Job.js +27 -0
  93. package/dist/src/feature/async/JobRepository.js +31 -0
  94. package/dist/src/feature/async/JobRunner.js +48 -0
  95. package/dist/src/feature/async/JobsEventsHub.js +36 -0
  96. package/dist/src/feature/async/runCommandHandlers.js +29 -0
  97. package/dist/src/{core/chat → feature/chat-bot}/Chat.js +2 -2
  98. package/dist/src/feature/chat-bot/ChatAdapter.js +7 -0
  99. package/dist/src/feature/chat-bot/ChatBot.js +73 -0
  100. package/dist/src/feature/chat-bot/ChatItem.js +24 -0
  101. package/dist/src/feature/chat-bot/ChatMemory.js +10 -0
  102. package/dist/src/{core/chat/repository/IChatRepository.js → feature/chat-bot/ChatRepository.js} +2 -8
  103. package/dist/src/feature/chat-bot/IChatItem.js +3 -0
  104. package/dist/src/{chatbot → feature/chat-bot}/metadata/@chatBot.js +1 -1
  105. package/dist/src/{chatbot → feature/chat-bot}/metadata/ChatBotMetadataStore.js +1 -1
  106. package/dist/src/{controller/channel → feature/chat-controller}/ChatResolver.js +6 -4
  107. package/dist/src/{controller → feature/chat-controller}/metadata/ControllerMetadataStore.js +1 -1
  108. package/dist/src/{controller → feature/chat-controller}/metadata/controller/@chatController.js +1 -1
  109. package/dist/src/feature/chat-controller/runChatControllers.js +69 -0
  110. package/dist/src/{channels → feature}/express/ExpressProvider.js +2 -4
  111. package/dist/src/{channels → feature}/http/HttpServerProvider.js +2 -2
  112. package/dist/src/{mindset → feature/mindset}/IMindset.js +3 -0
  113. package/dist/src/{mindset → feature/mindset}/MindsetOperator.js +69 -42
  114. package/dist/src/{mindset → feature/mindset}/metadata/MindsetMetadataStore.js +1 -1
  115. package/dist/src/{mindset → feature/mindset}/metadata/functions/@mindsetFunction.js +1 -1
  116. package/dist/src/{mindset → feature/mindset}/metadata/mindsets/@mindset.js +1 -1
  117. package/dist/src/{mindset → feature/mindset}/metadata/modules/@mindsetModule.js +1 -2
  118. package/dist/src/{mindset → feature/mindset}/metadata/params/@param.js +1 -1
  119. package/dist/src/feature/money/Money.js +61 -0
  120. package/dist/src/feature/money/MoneyDto.js +22 -0
  121. package/dist/src/{repository → feature}/pg/PgCrudRepository.js +30 -9
  122. package/dist/src/{repository → feature}/pg/PgRepositoryBase.js +2 -2
  123. package/dist/src/feature/rest-controller/injection-tokens.js +4 -0
  124. package/dist/src/feature/rest-controller/metadata/@middleware.js +16 -0
  125. package/dist/src/feature/rest-controller/metadata/@onDelete.js +7 -0
  126. package/dist/src/feature/rest-controller/metadata/@onGet.js +7 -0
  127. package/dist/src/feature/rest-controller/metadata/@onPost.js +7 -0
  128. package/dist/src/feature/rest-controller/metadata/@onPut.js +7 -0
  129. package/dist/src/feature/rest-controller/metadata/@restController.js +15 -0
  130. package/dist/src/feature/rest-controller/metadata/RestControllerMetadataStore.js +50 -0
  131. package/dist/src/feature/rest-controller/metadata/methodDecorator.js +19 -0
  132. package/dist/src/feature/rest-controller/runRestControllers.js +103 -0
  133. package/dist/src/{channels → feature}/socket/SocketServerProvider.js +2 -2
  134. package/dist/src/feature/socket-controller/metadata/@connectionMiddleware.js +16 -0
  135. package/dist/src/feature/socket-controller/metadata/@socketConnection.js +18 -0
  136. package/dist/src/feature/socket-controller/metadata/@socketController.js +15 -0
  137. package/dist/src/feature/socket-controller/metadata/@socketEvent.js +18 -0
  138. package/dist/src/feature/socket-controller/metadata/SocketControllerMetadataStore.js +65 -0
  139. package/dist/src/feature/socket-controller/runSocketControllers.js +99 -0
  140. package/dist/src/index.d.ts +1210 -576
  141. package/dist/src/index.js +147 -76
  142. package/package.json +10 -4
  143. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +0 -106
  144. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +0 -88
  145. package/dist/src/channels/cmd/@cmd.js +0 -18
  146. package/dist/src/channels/wabot/WabotDevConnection.js +0 -57
  147. package/dist/src/channels/wabot/WabotDevSocketContracts.js +0 -10
  148. package/dist/src/channels/whatsapp/@whatsapp.js +0 -20
  149. package/dist/src/channels/whatsapp/WhatsAppReceiver.js +0 -59
  150. package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +0 -32
  151. package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +0 -63
  152. package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +0 -61
  153. package/dist/src/chatbot/ChatBot.js +0 -51
  154. package/dist/src/chatbot/ChatBotAdapter.js +0 -72
  155. package/dist/src/controller/channel/UserResolver.js +0 -21
  156. package/dist/src/core/IMessageContext.js +0 -12
  157. package/dist/src/core/chat/ChatItem.js +0 -15
  158. package/dist/src/core/chat/repository/IChatMemory.js +0 -10
  159. package/dist/src/core/user/IUserRepository.js +0 -19
  160. package/dist/src/core/user/User.js +0 -26
  161. package/dist/src/env/WabotEnv.js +0 -27
  162. package/dist/src/injection/index.js +0 -4
  163. package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
  164. package/dist/src/pre-made/module/authentication/AuthenticationModule.js +0 -97
  165. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -25
  166. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -25
  167. package/dist/src/pre-made/module/register-user/RegisterUserModule.js +0 -56
  168. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -25
  169. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -33
  170. package/dist/src/pre-made/repository/user/ram/RamUserRepository.js +0 -27
  171. package/dist/src/pre-made/service/EmailService.js +0 -13
  172. package/dist/src/pre-made/service/OtpService.js +0 -14
  173. package/dist/src/server/prepareChatContainer.js +0 -43
  174. package/dist/src/server/runChannel.js +0 -27
  175. package/dist/src/server/runServer.js +0 -40
  176. /package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatMemory.js +0 -0
  177. /package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannelConfig.js +0 -0
  178. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannelConfig.js +0 -0
  179. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppRepository.js +0 -0
  180. /package/dist/src/{injection → core/injection}/Container.js +0 -0
  181. /package/dist/src/{logger → core/logger}/Logger.js +0 -0
  182. /package/dist/src/{mindset → feature/mindset}/metadata/functions/decoratorNames.js +0 -0
  183. /package/dist/src/{mindset → feature/mindset}/metadata/mindsets/decoratorNames.js +0 -0
  184. /package/dist/src/{mindset → feature/mindset}/metadata/modules/decoratorNames.js +0 -0
  185. /package/dist/src/{mindset → feature/mindset}/metadata/params/decoratorNames.js +0 -0
@@ -1,183 +1,434 @@
1
+ import * as tsyringe from 'tsyringe';
2
+ import { DependencyContainer as DependencyContainer$1 } from 'tsyringe';
3
+ export { DependencyContainer } from 'tsyringe';
1
4
  import InjectionToken from 'tsyringe/dist/typings/providers/injection-token';
2
5
  import DependencyContainer, { PreResolutionInterceptorCallback, PostResolutionInterceptorCallback } from 'tsyringe/dist/typings/types/dependency-container';
3
6
  import InterceptionOptions from 'tsyringe/dist/typings/types/interceptor-options';
4
7
  import { Server } from 'http';
5
- import { Express } from 'express';
6
- import { Server as Server$1 } from 'socket.io';
7
- import { Socket } from 'socket.io-client';
8
+ import { Express, Request, Response } from 'express';
9
+ import * as big_js from 'big.js';
8
10
  import { Pool } from 'pg';
9
- import * as tsyringe from 'tsyringe';
10
- import { DependencyContainer as DependencyContainer$1 } from 'tsyringe';
11
- export { DependencyContainer } from 'tsyringe';
11
+ import { Server as Server$1, Socket } from 'socket.io';
12
+ import { Algorithm } from 'jsonwebtoken';
13
+ import { Socket as Socket$1 } from 'socket.io-client';
12
14
 
13
- interface IMindsetFunctionConfig {
14
- description: string;
15
+ type IPrimitive = null | number | string | boolean | undefined;
16
+ type IStorableData = {
17
+ [key: string]: IPrimitive | IPrimitive[] | IStorableData | IStorableData[];
18
+ };
19
+ declare class Storable<D extends IStorableData> {
20
+ protected data: D;
21
+ constructor(data: D);
15
22
  }
16
23
 
17
- declare function mindsetFunction(config: IMindsetFunctionConfig): (target: object, propertyKey: string | symbol) => void;
18
-
19
- declare const MINDSET_FUNCTION_DECORATION_FUNCTION = "mindsetFunction";
20
-
21
- interface IMindsetFunctionDecoration {
22
- decorationName: string;
23
- functionName: string;
24
- constructor: Function;
25
- paramsTypes: Function[];
26
- decorationConfig: any;
24
+ declare class Auth<D extends IStorableData> {
25
+ private authInfo;
26
+ require(): D;
27
+ assign(authInfo: D): void;
27
28
  }
28
29
 
29
- interface IPersistentData {
30
+ interface IEntityData extends IStorableData {
30
31
  id?: string;
31
32
  createdAt?: number | null;
32
33
  discardedAt?: number | null;
33
34
  }
34
- declare class Persistent<D extends IPersistentData = IPersistentData> {
35
- protected data: D;
36
- constructor(data: D);
35
+ declare class Entity<D extends IEntityData> extends Storable<D> {
36
+ get id(): string;
37
+ /**
38
+ * @deprecated use id
39
+ */
37
40
  getId(): string;
41
+ get createdAt(): Date;
42
+ /**
43
+ * @deprecated use createdAt
44
+ */
38
45
  getCreatedAt(): Date;
39
- update(newData: D): void;
46
+ update(newData: Omit<D, 'id' | 'createdAt' | 'discardedAt'>): void;
40
47
  wasCreated(): boolean;
41
48
  validate(): void;
42
- discard(): void;
43
49
  }
44
-
45
- type IChatType = 'PRIVATE' | 'GROUP';
46
- interface IChatConnection {
47
- chatType: IChatType;
48
- channelName: string;
49
- id: string;
50
+ /**
51
+ * @deprecated Should use IEntityData
52
+ */
53
+ interface IPersistentData extends IEntityData {
50
54
  }
51
- interface IChatData extends IPersistentData {
52
- type: IChatType;
53
- connections: IChatConnection[];
55
+ /**
56
+ * @deprecated Should use Entity
57
+ */
58
+ declare class Persistent<D extends IPersistentData> extends Entity<D> {
54
59
  }
55
- declare class Chat extends Persistent<IChatData> {
56
- constructor(data: IChatData);
57
- isPrivate(): boolean;
58
- isGroup(): boolean;
59
- hasConnection(connection: IChatConnection): boolean;
60
- private validatePrivateChat;
61
- private validateGroupChat;
62
- validate(): void;
60
+
61
+ type IEnvType = 'development' | 'staging' | 'testing' | 'production';
62
+ declare class Env {
63
+ private envType;
64
+ constructor();
65
+ isDevelopment(): boolean;
66
+ isProduction(): boolean;
67
+ isTesting(): boolean;
68
+ requireString(varName: string, options?: {
69
+ default?: string;
70
+ }): string;
71
+ requireNumber(varName: string, options?: {
72
+ default?: number;
73
+ }): number;
74
+ }
75
+
76
+ interface ICustomErrorData {
77
+ message: string;
78
+ humanMessage?: string;
79
+ code?: string;
80
+ httpCode?: number;
81
+ cause?: Error;
82
+ info?: any;
83
+ }
84
+ declare class CustomError extends Error {
85
+ humanMessage?: string;
86
+ code?: string;
87
+ httpCode?: number;
88
+ info?: any;
89
+ constructor(data: ICustomErrorData);
63
90
  }
64
91
 
65
- interface IChatDocument {
92
+ type IConstructor<T> = new (...args: any[]) => T;
93
+
94
+ declare class Container implements DependencyContainer {
95
+ register(token: unknown, provider: unknown, options?: unknown): DependencyContainer;
96
+ registerSingleton(from: unknown, to?: unknown): DependencyContainer;
97
+ registerType<T>(from: InjectionToken<T>, to: InjectionToken<T>): DependencyContainer;
98
+ registerInstance<T>(token: InjectionToken<T>, instance: T): DependencyContainer;
99
+ resolve<T>(token: InjectionToken<T>): T;
100
+ resolveAll<T>(token: InjectionToken<T>): T[];
101
+ isRegistered<T>(token: InjectionToken<T>, recursive?: boolean): boolean;
102
+ reset(): void;
103
+ clearInstances(): void;
104
+ createChildContainer(): DependencyContainer;
105
+ beforeResolution<T>(token: InjectionToken<T>, callback: PreResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
106
+ afterResolution<T>(token: InjectionToken<T>, callback: PostResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
107
+ dispose(): Promise<void> | void;
66
108
  }
67
109
 
68
- interface IChatImage {
110
+ declare const injectable: typeof tsyringe.injectable;
111
+ declare const container: tsyringe.DependencyContainer;
112
+ declare const singleton: typeof tsyringe.singleton;
113
+ declare const inject: typeof tsyringe.inject;
114
+ declare const scoped: typeof tsyringe.scoped;
115
+ declare const Lifecycle: typeof tsyringe.Lifecycle;
116
+
117
+ declare class Logger {
118
+ private debuggers;
119
+ constructor(name: string);
120
+ trace(...args: any[]): void;
121
+ debug(...args: any[]): void;
122
+ info(...args: any[]): void;
123
+ warn(...args: any[]): void;
124
+ error(...args: any[]): void;
125
+ fatal(...args: any[]): void;
126
+ private log;
69
127
  }
70
128
 
71
- interface IUserConnection {
72
- channelName: string;
73
- id: string;
129
+ declare class Mapper {
130
+ map<T>(data: any, ctor: IConstructor<T>): T;
74
131
  }
75
- interface IUserData extends IPersistentData {
76
- shortName: string;
77
- connections: IUserConnection[];
78
- keyValueData: {
79
- [key: string]: string;
80
- };
132
+
133
+ interface PasswordHashOptions {
134
+ password: string;
135
+ saltLength?: number;
136
+ keyLength?: number;
81
137
  }
82
- declare class User extends Persistent<IUserData> {
83
- constructor(data: IUserData);
84
- hasConnection(connection: IUserConnection): boolean;
85
- getValue(key: string): string;
86
- setValue(key: string, value: string): void;
87
- addConnection(connection: IUserConnection): void;
138
+ declare class Password {
139
+ static hash(options: PasswordHashOptions): string;
140
+ static isValid(req: {
141
+ password: string;
142
+ hash: string;
143
+ }): boolean;
144
+ static generate(length: number): string;
88
145
  }
89
146
 
90
- interface IChatMessage {
91
- text?: string;
92
- documents?: IChatDocument[];
93
- images?: IChatImage[];
94
- senderName: string;
95
- }
96
- interface IConnectionChatMessage extends IChatMessage {
97
- chatConnection: IChatConnection;
98
- userConnection: IUserConnection;
99
- userId?: string;
147
+ declare class Random {
148
+ static integer(options: {
149
+ min: number;
150
+ max: number;
151
+ }): number;
152
+ static slug(name: string, options: {
153
+ randomLength: number;
154
+ }): string;
155
+ static alphaNumeric(length: number): string;
156
+ static alphaNumericLowerCase(length: number): string;
157
+ static numberCode(length: number): string;
100
158
  }
101
159
 
102
- interface IChatFunctionCall {
103
- id: string;
104
- name: string;
105
- arguments?: string;
106
- result: string;
160
+ interface ICrudRepository<T> {
161
+ find(id: string): Promise<T | null>;
162
+ findOrThrow(id: string): Promise<T>;
163
+ findByIds(ids: string[]): Promise<T[]>;
164
+ findAll(id: string): Promise<T[]>;
165
+ create(item: T): Promise<void>;
166
+ update(item: T): Promise<void>;
167
+ delete(item: T): Promise<void>;
107
168
  }
108
169
 
109
- type ISystemMessageItem = {
110
- type: 'BOT_MESSAGE';
111
- content: IChatMessage;
170
+ declare function isModel(model: IConstructor<any>): (target: object, propertyKey: string | symbol) => void;
171
+
172
+ declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
173
+
174
+ interface IValidationError {
175
+ description: string;
176
+ }
177
+ interface IModelValidationError extends IValidationError {
178
+ properties: {
179
+ [key: string]: string[];
180
+ };
181
+ }
182
+ interface IArrayValidationError extends IValidationError {
183
+ items: (IValidationError[] | null)[];
184
+ }
185
+ type IValidationResult<V> = {
186
+ value: V;
187
+ error?: undefined;
188
+ } | {
189
+ value?: undefined;
190
+ error: IValidationError;
112
191
  };
113
- type IReceivedMessageItem = {
114
- type: 'CONNECTION_MESSAGE';
115
- content: IConnectionChatMessage;
192
+ type IModelValidationResult<V> = {
193
+ value: V;
194
+ error?: undefined;
195
+ } | {
196
+ value?: undefined;
197
+ error: IModelValidationError;
116
198
  };
117
- type ISystemFunctionCallItem = {
118
- type: 'FUNCTION_CALL';
119
- content: IChatFunctionCall;
199
+ type IArrayValidationResult<V> = {
200
+ value: V[];
201
+ error?: undefined;
202
+ } | {
203
+ value?: undefined;
204
+ error: IArrayValidationError;
120
205
  };
121
- type IChatItemData = {
122
- id?: string;
123
- createdAt?: number;
124
- } & (ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem);
125
- type IChatItemType = IChatItemData['type'];
126
- declare class ChatItem extends Persistent<IChatItemData> {
127
- getType(): "BOT_MESSAGE" | "CONNECTION_MESSAGE" | "FUNCTION_CALL";
128
- getContent(): IChatMessage | IConnectionChatMessage | IChatFunctionCall;
129
- getData(): IChatItemData;
206
+ type IValidator<V = any, O = any> = (value: V, options: O) => IValidationResult<V>;
207
+ interface IPropertyValidatorInfo {
208
+ propertyName: string;
209
+ validator: IValidator;
210
+ validatorOptions?: any;
211
+ }
212
+ type IModelValidatorsInfo<V> = {
213
+ modelConstructor: IConstructor<V>;
214
+ properties: {
215
+ [prop: string]: {
216
+ isOptional?: boolean;
217
+ validators?: IPropertyValidatorInfo[];
218
+ } | undefined;
219
+ };
220
+ };
221
+
222
+ interface IValidateArrayOptions {
223
+ minLength?: number;
224
+ maxLength?: number;
225
+ }
226
+ interface IValidateArrayOptionsWithItemsValidators extends IValidateArrayOptions {
227
+ itemsValidator?: {
228
+ validator: IValidator;
229
+ options: any;
230
+ }[];
130
231
  }
232
+ declare function validateArray(value: any, options?: IValidateArrayOptionsWithItemsValidators): IArrayValidationResult<any>;
131
233
 
132
- interface IChatMemory {
133
- findLastItems(count: number): Promise<ChatItem[]>;
134
- create(item: ChatItem): Promise<void>;
234
+ declare function isArray(options?: IValidateArrayOptions): (target: object, propertyKey: string | symbol) => void;
235
+
236
+ interface IValidatorMetadata {
237
+ modelConstructor: IConstructor<any>;
238
+ propertyName: string;
239
+ validator: IValidator;
240
+ validatorOptions?: any;
135
241
  }
136
- declare class ChatMemory implements IChatMemory {
137
- findLastItems(count: number): Promise<ChatItem[]>;
138
- create(item: ChatItem): Promise<void>;
242
+
243
+ declare class ValidationMetadataStore {
244
+ private validators;
245
+ saveValidatorMetadata(validatorMetadata: IValidatorMetadata): void;
246
+ getModelValidatorsInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
247
+ private getConstructorPropertiesValidatorsInfo;
139
248
  }
140
249
 
141
- interface IChatRepository {
142
- create(chat: Chat): Promise<void>;
143
- findByConnection(query: IChatConnection): Promise<Chat | null>;
144
- findMemory(chatId: string): Promise<IChatMemory | null>;
250
+ declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
251
+
252
+ declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
253
+
254
+ declare function modelInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
255
+
256
+ declare function isBoolean(): (target: object, propertyKey: string | symbol) => void;
257
+
258
+ declare function validateIsBoolean(value: any): IValidationResult<boolean>;
259
+
260
+ declare function isDate(): (target: object, propertyKey: string | symbol) => void;
261
+
262
+ declare function validateIsDate(value: any): IValidationResult<Date>;
263
+
264
+ interface IValidateIsInOptions {
265
+ values: (number | string | boolean | null)[];
145
266
  }
146
- declare class ChatRepository implements IChatRepository {
147
- create(chat: Chat): Promise<void>;
148
- findByConnection(query: IChatConnection): Promise<Chat | null>;
149
- findMemory(chatId: string): Promise<IChatMemory | null>;
267
+ declare function validateIsIn(value: any, options: IValidateIsInOptions): IValidationResult<any>;
268
+
269
+ declare function isIn(values: IValidateIsInOptions['values']): (target: object, propertyKey: string | symbol) => void;
270
+
271
+ declare function isNotEmpty(): (target: object, propertyKey: string | symbol) => void;
272
+
273
+ declare function validateIsNotEmpty(value: any): IValidationResult<any>;
274
+
275
+ declare function isNumber(): (target: object, propertyKey: string | symbol) => void;
276
+
277
+ declare function validateIsNumber(value: any): IValidationResult<number>;
278
+
279
+ declare function isPresent(): (target: object, propertyKey: string | symbol) => void;
280
+
281
+ declare function validateIsPresent(value: any): IValidationResult<any>;
282
+
283
+ declare function isString(): (target: object, propertyKey: string | symbol) => void;
284
+
285
+ declare function validateIsString(value: any): IValidationResult<string>;
286
+
287
+ declare function max(limit: any): (target: object, propertyKey: string | symbol) => void;
288
+
289
+ interface IValidateMaxOptions {
290
+ limit: any;
150
291
  }
292
+ declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
151
293
 
152
- interface IUserRepository {
153
- create(chat: User): Promise<void>;
154
- update(chat: User): Promise<void>;
155
- findByConnection(query: IUserConnection): Promise<User | null>;
294
+ declare function min(limit: any): (target: object, propertyKey: string | symbol) => void;
295
+
296
+ interface IValidateMinOptions {
297
+ limit: any;
156
298
  }
157
- declare class UserRepository implements IUserRepository {
158
- create(chat: User): Promise<void>;
159
- update(chat: User): Promise<void>;
160
- findByConnection(query: IUserConnection): Promise<User | null>;
299
+ declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
300
+
301
+ interface ICommandConfig {
302
+ name?: string;
161
303
  }
304
+ declare function command(config?: ICommandConfig): (target: IConstructor<any>) => void;
162
305
 
163
- interface IMessageContext {
164
- message: IConnectionChatMessage;
165
- chat: Chat;
166
- user: User | null;
306
+ declare class Command<T extends IStorableData> extends Storable<T> {
307
+ getData(): T;
167
308
  }
168
- declare class MessageContext implements IMessageContext {
169
- message: IConnectionChatMessage;
170
- chat: Chat;
171
- user: User | null;
172
- constructor(message: IConnectionChatMessage, chat: Chat, user: User | null);
309
+
310
+ interface ICommandHandler<C extends Command<any>> {
311
+ handle(command: C): void | Promise<void>;
173
312
  }
174
313
 
175
- interface IReversibleMapper<T1, T2> {
176
- map(input: T1): T2;
177
- rev(input: T2): T1;
314
+ interface ICommandHandlerConfig<C extends Command<any>> {
315
+ command: IConstructor<C>;
178
316
  }
317
+ declare function commandHandler<C extends Command<any>>(config: ICommandHandlerConfig<C>): (target: IConstructor<ICommandHandler<C>>) => void;
179
318
 
180
- type IConstructor<T> = new (...args: any[]) => T;
319
+ declare class CommandMetadataStore {
320
+ private handlersMap;
321
+ private handlersInverseMap;
322
+ private commandsMap;
323
+ private commandsInverseMap;
324
+ registerCommand(command: IConstructor<Command<any>>, commandName: string): void;
325
+ registerHandler(command: IConstructor<Command<any>>, handlerConstructor: IConstructor<ICommandHandler<any>>): void;
326
+ getHandlerForCommandName(commandName: string): IConstructor<ICommandHandler<any>> | null;
327
+ getCommandNameForHandler(handlerConstructor: IConstructor<ICommandHandler<any>>): string | null;
328
+ getCommandName(command: IConstructor<Command<any>>): string | null;
329
+ getCommandForCommandName(commandName: string): IConstructor<Command<any>> | null;
330
+ }
331
+
332
+ interface IJobData extends IEntityData {
333
+ commandName: string;
334
+ commandData: any;
335
+ startedAt?: number;
336
+ successAt?: number;
337
+ failedAt?: number;
338
+ retryAt?: number;
339
+ error?: {
340
+ message: string;
341
+ stack?: string;
342
+ info?: any;
343
+ };
344
+ }
345
+ declare class Job extends Entity<IJobData> {
346
+ get commandName(): string;
347
+ hasFinished(): boolean;
348
+ setAsStarted(): void;
349
+ setAsSuccess(): void;
350
+ setAsFailed(error: Error): void;
351
+ }
352
+
353
+ interface IJobRepository extends ICrudRepository<Job> {
354
+ }
355
+
356
+ declare class JobRepository implements IJobRepository {
357
+ find(id: string): Promise<Job | null>;
358
+ findOrThrow(id: string): Promise<Job>;
359
+ findByIds(ids: string[]): Promise<Job[]>;
360
+ findAll(id: string): Promise<Job[]>;
361
+ create(item: Job): Promise<void>;
362
+ update(item: Job): Promise<void>;
363
+ delete(item: Job): Promise<void>;
364
+ }
365
+
366
+ interface IJobEvent extends IStorableData {
367
+ jobId: string;
368
+ type: 'created';
369
+ }
370
+ type IJobEventListener = (event: IJobEvent) => void | Promise<void>;
371
+ declare class JobsEventsHub {
372
+ private logger;
373
+ private jobsEventsListener;
374
+ notifyJobCreated(job: Job): void;
375
+ listenJobsEvents(listener: IJobEventListener): void;
376
+ }
377
+
378
+ declare class Async {
379
+ private jobRepository;
380
+ private handlerContainer;
381
+ private jobsEventsHub;
382
+ constructor(jobRepository: JobRepository, handlerContainer: CommandMetadataStore, jobsEventsHub: JobsEventsHub);
383
+ run<T extends IStorableData>(command: Command<T>): Promise<Job>;
384
+ }
385
+
386
+ declare class JobRunner {
387
+ private jobRepository;
388
+ private handlerContainer;
389
+ private logger;
390
+ constructor(jobRepository: JobRepository, handlerContainer: CommandMetadataStore);
391
+ run(job: Job): Promise<void>;
392
+ }
393
+
394
+ declare function runAsyncCommandHandlers(handlers: IConstructor<ICommandHandler<any>>[]): void;
395
+
396
+ interface IChatConnection extends IStorableData {
397
+ channelName: string;
398
+ id: string;
399
+ }
400
+
401
+ type IChatType = 'PRIVATE' | 'GROUP';
402
+
403
+ interface IChatData extends IEntityData {
404
+ type: IChatType;
405
+ connections: IChatConnection[];
406
+ }
407
+ declare class Chat extends Entity<IChatData> {
408
+ constructor(data: IChatData);
409
+ isPrivate(): boolean;
410
+ isGroup(): boolean;
411
+ hasConnection(connection: IChatConnection): boolean;
412
+ private validatePrivateChat;
413
+ private validateGroupChat;
414
+ validate(): void;
415
+ }
416
+
417
+ interface IMindsetFunctionConfig {
418
+ description: string;
419
+ }
420
+
421
+ declare function mindsetFunction(config: IMindsetFunctionConfig): (target: object, propertyKey: string | symbol) => void;
422
+
423
+ declare const MINDSET_FUNCTION_DECORATION_FUNCTION = "mindsetFunction";
424
+
425
+ interface IMindsetFunctionDecoration {
426
+ decorationName: string;
427
+ functionName: string;
428
+ constructor: Function;
429
+ paramsTypes: Function[];
430
+ decorationConfig: any;
431
+ }
181
432
 
182
433
  interface IMindsetIdentity {
183
434
  name: string;
@@ -186,15 +437,21 @@ interface IMindsetIdentity {
186
437
  personality?: string;
187
438
  emotions?: string;
188
439
  }
440
+ interface IMindsetLlm {
441
+ provider?: string;
442
+ model: string;
443
+ }
189
444
  interface IMindset {
190
445
  identity(): Promise<IMindsetIdentity>;
191
446
  skills(): Promise<string>;
192
447
  limits(): Promise<string>;
448
+ llms(): Promise<IMindsetLlm[]>;
193
449
  }
194
450
  declare class Mindset implements IMindset {
195
451
  identity(): Promise<IMindsetIdentity>;
196
452
  skills(): Promise<string>;
197
453
  limits(): Promise<string>;
454
+ llms(): Promise<IMindsetLlm[]>;
198
455
  }
199
456
 
200
457
  interface IMindsetConfig {
@@ -226,8 +483,6 @@ interface IMindsetModuleDecoration {
226
483
  decorationConfig: any;
227
484
  }
228
485
 
229
- declare function isOptional(): PropertyDecorator;
230
-
231
486
  interface IParamConfig {
232
487
  name?: string;
233
488
  optional?: boolean;
@@ -285,26 +540,17 @@ declare class MindsetMetadataStore {
285
540
  getMindsetMetadata(ctor: Function): IMindsetMetadata;
286
541
  }
287
542
 
288
- declare class Container implements DependencyContainer {
289
- register(token: unknown, provider: unknown, options?: unknown): DependencyContainer;
290
- registerSingleton(from: unknown, to?: unknown): DependencyContainer;
291
- registerType<T>(from: InjectionToken<T>, to: InjectionToken<T>): DependencyContainer;
292
- registerInstance<T>(token: InjectionToken<T>, instance: T): DependencyContainer;
293
- resolve<T>(token: InjectionToken<T>): T;
294
- resolveAll<T>(token: InjectionToken<T>): T[];
295
- isRegistered<T>(token: InjectionToken<T>, recursive?: boolean): boolean;
296
- reset(): void;
297
- clearInstances(): void;
298
- createChildContainer(): DependencyContainer;
299
- beforeResolution<T>(token: InjectionToken<T>, callback: PreResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
300
- afterResolution<T>(token: InjectionToken<T>, callback: PostResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
301
- dispose(): Promise<void> | void;
543
+ interface IMindsetToolParameter {
544
+ type: string;
545
+ name: string;
546
+ description: string;
547
+ }
548
+ interface IMindsetTool {
549
+ language: string;
550
+ name: string;
551
+ description: string;
552
+ parameters: IMindsetToolParameter[];
302
553
  }
303
-
304
- declare const injectable: typeof tsyringe.injectable;
305
- declare const container: tsyringe.DependencyContainer;
306
- declare const singleton: typeof tsyringe.singleton;
307
- declare const inject: typeof tsyringe.inject;
308
554
 
309
555
  declare class MindsetOperator implements IMindset {
310
556
  private mindset;
@@ -314,99 +560,124 @@ declare class MindsetOperator implements IMindset {
314
560
  identity(): Promise<IMindsetIdentity>;
315
561
  skills(): Promise<string>;
316
562
  limits(): Promise<string>;
563
+ llms(): Promise<IMindsetLlm[]>;
564
+ systemPrompt(): Promise<string>;
565
+ tools(): IMindsetTool[];
566
+ protected tool(fn: IMindsetFunctionMetadata, module: IMindsetModuleMetadata): IMindsetTool;
567
+ protected toolParameter(param: IMindsetFunctionParamMetadata): IMindsetToolParameter;
317
568
  callFunction(name: string, params: string): Promise<string>;
318
- allFunctionsDescriptors(): Promise<{
319
- readonly type: "function";
320
- readonly name: string;
321
- readonly description: string;
322
- readonly parameters: {
323
- readonly type: "object";
324
- readonly properties: {};
325
- readonly required: string[];
326
- };
327
- }[]>;
328
- private functionDescriptor;
329
- private toolParam;
330
569
  }
331
570
 
332
- declare function chatBot(mindset: IConstructor<IMindset>): (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
571
+ interface IChatMessage extends IStorableData {
572
+ senderId?: string;
573
+ senderName?: string;
574
+ text?: string;
575
+ }
333
576
 
334
- interface IChatBotMetadata {
335
- constructor: IConstructor<any>;
336
- mindsetConstructor: IConstructor<IMindset>;
337
- injectionToken: string;
577
+ interface IFunctionCall extends IStorableData {
578
+ id: string;
579
+ name: string;
580
+ arguments?: string;
581
+ result?: string;
338
582
  }
339
583
 
340
- declare class ChatBotMetadataStore {
341
- private chatBots;
342
- saveChatBotMetadata(chatBot: IChatBotMetadata): void;
343
- getChatBotsMetadata(): IChatBotMetadata[];
584
+ declare const chatItemTypeOptions: readonly ["botMessage", "humanMessage", "functionCall"];
585
+ type IBotMessageItem = {
586
+ type: 'botMessage';
587
+ botMessage: IChatMessage;
588
+ };
589
+ type IHumanMessageItem = {
590
+ type: 'humanMessage';
591
+ humanMessage: IChatMessage;
592
+ };
593
+ type IFunctionCallItem = {
594
+ type: 'functionCall';
595
+ functionCall: IFunctionCall;
596
+ };
597
+ type IChatItem = IBotMessageItem | IHumanMessageItem | IFunctionCallItem;
598
+ type IChatItemType = (typeof chatItemTypeOptions)[number];
599
+
600
+ interface ILanguageModelUsage {
601
+ inputTokens: number;
602
+ outputTokens: number;
344
603
  }
345
604
 
346
- interface IChatBotAdapter {
347
- generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
605
+ interface IChatAdapterNextItemReq {
606
+ model: string;
607
+ systemPrompt: string;
608
+ tools: IMindsetTool[];
609
+ prevItems: IChatItem[];
348
610
  }
349
- declare class ChatBotAdapter implements IChatBotAdapter {
350
- protected mindset: MindsetOperator;
351
- constructor(mindset: MindsetOperator);
352
- generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
353
- protected systemPrompt(): Promise<string>;
354
- protected buildBotMessageItem(text: string): Promise<ChatItem>;
355
- protected buildFunctionCallItem(id: string, functionName: string, functionArguments: string): Promise<ChatItem>;
611
+ interface IChatAdapterNextItemRes {
612
+ chatItem: IChatItem;
613
+ usage: ILanguageModelUsage;
356
614
  }
357
-
358
- interface IChatBot {
359
- sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): void | Promise<void>;
615
+ interface IChatAdapter {
616
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
360
617
  }
361
618
 
362
- declare class ChatBot implements IChatBot {
363
- private memory;
364
- private adapter;
365
- constructor(memory: ChatMemory, adapter: ChatBotAdapter);
366
- sendMessage(message: IConnectionChatMessage, callback: (message: IChatMessage) => void): Promise<void>;
367
- protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
619
+ declare class ChatAdapter implements IChatAdapter {
620
+ nextItem(req: IChatAdapterNextItemReq & {
621
+ provider?: string;
622
+ }): Promise<IChatAdapterNextItemRes>;
368
623
  }
369
624
 
370
- declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
371
- private deepSeek;
372
- private model;
373
- constructor(mindset: MindsetOperator);
374
- validateEnvVariables(envVariables: (string | undefined)[]): void;
375
- generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
376
- private mapChatItems;
625
+ type IChatItemData = IEntityData & IChatItem;
626
+ declare class ChatItem extends Entity<IChatItemData> {
627
+ get type(): "botMessage" | "humanMessage" | "functionCall";
628
+ get botMessage(): IChatMessage;
629
+ get functionCall(): IFunctionCall;
630
+ setFunctionResult(result: string): void;
631
+ getData(): IChatItemData;
377
632
  }
378
633
 
379
- declare class OpenaiChatBotAdapter extends ChatBotAdapter {
380
- private openai;
381
- private model;
382
- private logger;
383
- constructor(mindset: MindsetOperator);
384
- generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
385
- private mapChatItems;
634
+ interface IChatMemory {
635
+ findLastItems(count: number): Promise<ChatItem[]>;
636
+ create(item: ChatItem): Promise<void>;
386
637
  }
387
638
 
388
- declare function cmd(): (target: object, propertyKey: string | symbol) => void;
639
+ declare class ChatMemory implements IChatMemory {
640
+ findLastItems(count: number): Promise<ChatItem[]>;
641
+ create(item: ChatItem): Promise<void>;
642
+ }
389
643
 
390
- declare class ChatResolver {
391
- private chatRepository;
392
- constructor(chatRepository: ChatRepository);
393
- resolve(connection: IChatConnection): Promise<Chat>;
394
- private resolveGroupChat;
395
- private resolvePrivateChat;
644
+ interface IChatBot {
645
+ sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): void | Promise<void>;
396
646
  }
397
647
 
398
- interface IReceivedMessage extends IMessageContext {
399
- reply: (message: IChatMessage) => void;
648
+ declare class ChatBot implements IChatBot {
649
+ private memory;
650
+ private adapter;
651
+ private mindset;
652
+ constructor(memory: ChatMemory, adapter: ChatAdapter, mindset: MindsetOperator);
653
+ sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): Promise<void>;
654
+ protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
400
655
  }
401
- interface IChatChannel {
402
- listen(callback: (message: IReceivedMessage) => void): void;
403
- connect(): void;
656
+
657
+ interface IChatRepository {
658
+ create(chat: Chat): Promise<void>;
659
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
660
+ findMemory(chatId: string): Promise<IChatMemory | null>;
661
+ }
662
+
663
+ declare class ChatRepository implements IChatRepository {
664
+ create(chat: Chat): Promise<void>;
665
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
666
+ findMemory(chatId: string): Promise<IChatMemory | null>;
667
+ }
668
+
669
+ declare function chatBot(mindset: IConstructor<IMindset>): (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
670
+
671
+ interface IChatBotMetadata {
672
+ constructor: IConstructor<any>;
673
+ mindsetConstructor: IConstructor<IMindset>;
674
+ injectionToken: string;
404
675
  }
405
676
 
406
- declare class UserResolver {
407
- private userRepository;
408
- constructor(userRepository: UserRepository);
409
- resolve(connection: IUserConnection): Promise<User | null>;
677
+ declare class ChatBotMetadataStore {
678
+ private chatBots;
679
+ saveChatBotMetadata(chatBot: IChatBotMetadata): void;
680
+ getChatBotsMetadata(): IChatBotMetadata[];
410
681
  }
411
682
 
412
683
  interface IchatControllerConfig {
@@ -418,6 +689,20 @@ interface IChatControllerMetadata {
418
689
  controllerConstructor: Function;
419
690
  }
420
691
 
692
+ interface IReceivedMessage {
693
+ message: IChatMessage;
694
+ reply: (message: IChatMessage) => void;
695
+ }
696
+
697
+ interface IChannelMessage extends IReceivedMessage {
698
+ chatConnection: IChatConnection;
699
+ }
700
+
701
+ interface IChatChannel {
702
+ listen(callback: (received: IChannelMessage) => void): void;
703
+ connect(): void;
704
+ }
705
+
421
706
  interface IChannelMetadata {
422
707
  controllerConstructor: IConstructor<any>;
423
708
  functionName: string;
@@ -436,16 +721,20 @@ declare class ControllerMetadataStore {
436
721
  } | null;
437
722
  }
438
723
 
439
- declare class CmdChannel implements IChatChannel {
440
- private chatResolver;
441
- private userResolver;
442
- private rl;
443
- private callBack;
444
- constructor(chatResolver: ChatResolver, userResolver: UserResolver);
445
- listen(callback: (message: IReceivedMessage) => void): void;
446
- connect(): void;
724
+ declare class ChatResolver {
725
+ private chatRepository;
726
+ constructor(chatRepository: ChatRepository);
727
+ resolve(connection: IChatConnection): Promise<Chat>;
728
+ private resolveGroupChat;
729
+ private resolvePrivateChat;
447
730
  }
448
731
 
732
+ interface IMessageContext extends IReceivedMessage {
733
+ chat: Chat;
734
+ }
735
+
736
+ declare function runChatControllers(controllers: IConstructor<any>[]): void;
737
+
449
738
  declare class HttpServerProvider {
450
739
  server: Server | null;
451
740
  private listening;
@@ -464,16 +753,152 @@ declare class ExpressProvider {
464
753
  private createExpress;
465
754
  }
466
755
 
467
- interface ISocketChannelConfig {
468
- channel: string;
756
+ interface IMoneyData extends IStorableData {
757
+ amount: string;
758
+ currency: string;
759
+ }
760
+ declare class Money extends Storable<IMoneyData> {
761
+ getData(): {
762
+ [key: string]: IPrimitive | IStorableData | IPrimitive[] | IStorableData[];
763
+ amount: string;
764
+ currency: string;
765
+ };
766
+ get amount(): big_js.Big;
767
+ get currency(): string;
768
+ plus(money: Money): Money;
769
+ minus(money: Money): Money;
770
+ times(value: bigint | string): Money;
771
+ div(value: bigint | string): Money;
772
+ negative(): Money;
773
+ isGretterThan(money: Money): boolean;
774
+ protected validateEqualCurrencies(left: string, right: string): void;
775
+ static zero(currency: string): Money;
469
776
  }
470
777
 
471
- declare class SocketChannelConfig implements ISocketChannelConfig {
472
- channel: string;
473
- constructor(channel: string);
778
+ declare class MoneyDto {
779
+ amount: string;
780
+ currency: string;
474
781
  }
475
782
 
476
- declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
783
+ type IPgRepositoryConfig<P extends Entity<IEntityData>> = {
784
+ schema?: string;
785
+ table: string;
786
+ constructor: IConstructor<P>;
787
+ add?: {
788
+ columns: {
789
+ [column: string]: {
790
+ type: string;
791
+ value: (item: P) => boolean | number | string | null | Date;
792
+ };
793
+ };
794
+ };
795
+ };
796
+
797
+ declare class PgRepositoryBase<P extends Entity<IEntityData>> {
798
+ protected pool: Pool;
799
+ protected config: IPgRepositoryConfig<any>;
800
+ private tableIsCreated;
801
+ protected schema: string;
802
+ protected table: string;
803
+ protected columnsList: string[];
804
+ protected columnsAndTypes: string;
805
+ protected columns: string;
806
+ protected vars: string;
807
+ protected updates: string;
808
+ addColumns: {
809
+ [columns: string]: {
810
+ type: string;
811
+ value: (item: P) => number | boolean | string | null | Date;
812
+ };
813
+ };
814
+ constructor(pool: Pool, config: IPgRepositoryConfig<any>);
815
+ protected values(item: P): (string | number | boolean | Date | null)[];
816
+ protected exec(sql: string, values: any[]): Promise<void>;
817
+ protected query(sql: string, values: any[]): Promise<P[]>;
818
+ protected connect(): Promise<Pool>;
819
+ protected ensureTable(): Promise<void>;
820
+ protected ensureColumns(): Promise<void>;
821
+ }
822
+
823
+ declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgRepositoryBase<P> implements ICrudRepository<P> {
824
+ protected readonly config: IPgRepositoryConfig<P>;
825
+ constructor(pool: Pool, config: IPgRepositoryConfig<P>);
826
+ find(id: string): Promise<P | null>;
827
+ findByIds(ids: string[]): Promise<P[]>;
828
+ findOrThrow(id: string): Promise<P>;
829
+ findAll(): Promise<P[]>;
830
+ create(item: P): Promise<void>;
831
+ update(item: P): Promise<void>;
832
+ delete(item: P): Promise<void>;
833
+ }
834
+
835
+ interface IEndPointConfig {
836
+ path?: string;
837
+ disableJsonParser?: boolean;
838
+ disableUrlEncodedParser?: boolean;
839
+ }
840
+
841
+ declare function onGet(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
842
+
843
+ interface IMiddleware {
844
+ handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
845
+ }
846
+
847
+ declare function middleware(middlewareConstructor: IConstructor<IMiddleware>): (target: object, propertyKey: string | symbol) => void;
848
+
849
+ declare function onPost(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
850
+
851
+ declare function onPut(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
852
+
853
+ declare function onDelete(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
854
+
855
+ interface IRestControllerConfig {
856
+ path: string;
857
+ }
858
+
859
+ declare function restController(config: string | IRestControllerConfig): (target: IConstructor<any>) => void;
860
+
861
+ interface IEndPointMetadata {
862
+ method: 'get' | 'post' | 'put' | 'delete';
863
+ config?: IEndPointConfig;
864
+ controllerConstructor: IConstructor<any>;
865
+ functionName: string;
866
+ paramsTypes: any[];
867
+ }
868
+
869
+ interface IMiddlewareMetadata {
870
+ controllerConstructor: IConstructor<any>;
871
+ functionName: string;
872
+ middlewareConstructor: IConstructor<IMiddleware>;
873
+ }
874
+
875
+ interface IRestControllerMetadata {
876
+ controllerConstructor: IConstructor<any>;
877
+ path: string;
878
+ }
879
+
880
+ declare class RestControllerMetadataStore {
881
+ private endPoints;
882
+ private middlewares;
883
+ private restControllers;
884
+ saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
885
+ saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
886
+ saveMiddlewareMetadata(middlewareMetadata: IMiddlewareMetadata): void;
887
+ getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
888
+ middlewares: IMiddlewareMetadata[];
889
+ controller: IRestControllerMetadata;
890
+ method: "get" | "post" | "put" | "delete";
891
+ config?: IEndPointConfig;
892
+ controllerConstructor: IConstructor<any>;
893
+ functionName: string;
894
+ paramsTypes: any[];
895
+ }[];
896
+ }
897
+
898
+ declare function runRestControllers(controllers: IConstructor<any>[]): void;
899
+
900
+ declare const EXPRESS_REQ = "EXPRESS_REQ";
901
+ declare const EXPRESS_RES = "EXPRESS_RES";
477
902
 
478
903
  declare class SocketServerProvider {
479
904
  private httpServerProvider;
@@ -485,138 +910,422 @@ declare class SocketServerProvider {
485
910
  private createSocketServer;
486
911
  }
487
912
 
488
- interface ISocketChannelReceivedMessage {
489
- chatId: string;
490
- userId: string;
491
- senderName: string;
492
- text: string;
913
+ interface IConnectionMiddleware {
914
+ handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
493
915
  }
494
- declare class SocketChannel implements IChatChannel {
495
- private config;
496
- private socketServerProvider;
497
- private chatResolver;
498
- private userResolver;
499
- private callBack;
500
- private server;
501
- constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider, chatResolver: ChatResolver, userResolver: UserResolver);
502
- listen(callback: (message: IReceivedMessage) => void): void;
503
- connect(): void;
916
+
917
+ declare function connectionMiddleware(middlewareConstructor: IConstructor<IConnectionMiddleware>): (target: object, propertyKey: string | symbol) => void;
918
+
919
+ interface ISocketConnectionConfig {
920
+ namespace: string;
504
921
  }
505
922
 
506
- interface ITelegramChannelConfig {
507
- botToken: string;
923
+ declare function socketConnection(config?: string | ISocketConnectionConfig): (target: object, propertyKey: string | symbol) => void;
924
+
925
+ interface ISocketControllerConfig {
926
+ namespace: string;
508
927
  }
509
- declare class TelegramChannelConfig implements ITelegramChannelConfig {
510
- botToken: string;
511
- constructor(botToken: string);
928
+
929
+ declare function socketController(config?: string | ISocketControllerConfig): (target: IConstructor<any>) => void;
930
+
931
+ interface ISocketEventConfig {
932
+ namespace?: string;
933
+ event: string;
512
934
  }
513
935
 
514
- declare function telegram(config: ITelegramChannelConfig): (target: object, propertyKey: string | symbol) => void;
936
+ declare function socketEvent(config: string | ISocketEventConfig): (target: object, propertyKey: string | symbol) => void;
515
937
 
516
- declare class TelegramChannel implements IChatChannel {
517
- private config;
518
- private chatResolver;
519
- private userResolver;
520
- private bot;
521
- constructor(config: TelegramChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver);
522
- listen(callback: (message: IReceivedMessage) => void): void;
523
- connect(): void;
938
+ interface IConnectionMiddlewareMetadata {
939
+ controllerConstructor: IConstructor<any>;
940
+ functionName: string;
941
+ middlewareConstructor: IConstructor<IConnectionMiddleware>;
524
942
  }
525
943
 
526
- interface IWhatsappChannelConfig {
527
- number: string;
528
- proxy?: string;
944
+ interface ISocketConnectionMetadata {
945
+ config?: ISocketConnectionConfig;
946
+ controllerConstructor: IConstructor<any>;
947
+ functionName: string;
948
+ paramsTypes: any[];
529
949
  }
530
- declare class WhatsappChannelConfig implements IWhatsappChannelConfig {
531
- number: string;
532
- constructor(number: string);
950
+
951
+ interface ISocketControllerMetadata {
952
+ controllerConstructor: IConstructor<any>;
953
+ config?: ISocketControllerConfig;
533
954
  }
534
955
 
535
- declare function whatsapp(config: IWhatsappChannelConfig): (target: object, propertyKey: string | symbol) => void;
956
+ interface ISocketEventMetadata {
957
+ config: ISocketEventConfig;
958
+ controllerConstructor: IConstructor<any>;
959
+ functionName: string;
960
+ paramsTypes: any[];
961
+ }
962
+
963
+ declare class SocketControllerMetadataStore {
964
+ private socketControllers;
965
+ private socketConnections;
966
+ private socketEvents;
967
+ private connectionMiddlewares;
968
+ saveControllerMetadata(controllerMetadata: ISocketControllerMetadata): void;
969
+ saveSocketConnectionMetadata(socketConnectionMetadata: ISocketConnectionMetadata): void;
970
+ saveSocketEventMetadata(socketEventMetadata: ISocketEventMetadata): void;
971
+ saveConnectionMiddlewareMetadata(middlewareMetadata: IConnectionMiddlewareMetadata): void;
972
+ getControllerSockerConnectionsInfo(controllerConstructor: IConstructor<any>): {
973
+ events: ISocketEventMetadata[];
974
+ connectionMiddlewares: IConnectionMiddlewareMetadata[];
975
+ controller: ISocketControllerMetadata;
976
+ config?: ISocketConnectionConfig;
977
+ controllerConstructor: IConstructor<any>;
978
+ functionName: string;
979
+ paramsTypes: any[];
980
+ }[];
981
+ }
982
+
983
+ declare function runSocketControllers(controllers: IConstructor<any>[]): void;
984
+
985
+ declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepository {
986
+ constructor(pool: Pool);
987
+ }
536
988
 
537
- type IWhatsAppTemplateParameter = {
538
- type: 'text';
539
- text: string;
540
- parameter_name?: string;
541
- } | {
542
- type: 'currency';
543
- currency: {
544
- fallback_value: string;
545
- code: string;
546
- amount_1000: number;
547
- };
548
- } | {
549
- type: 'date_time';
550
- date_time: {
551
- fallback_value: string;
989
+ declare function apiKeyConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
990
+
991
+ declare function apiKeyGuard(): (target: object, propertyKey: string | symbol) => void;
992
+
993
+ interface IApiKeyData<A extends IStorableData> extends IEntityData {
994
+ passwordHash?: string;
995
+ authInfo: A;
996
+ name: string;
997
+ }
998
+ declare class ApiKey<A extends IStorableData> extends Entity<IApiKeyData<A>> {
999
+ get authInfo(): A;
1000
+ setAuthInfo(authInfo: A): void;
1001
+ generatePassword(): string;
1002
+ isValidPassword(password: string): boolean;
1003
+ validatePassword(password: string): void;
1004
+ static inflate(secret: string): {
1005
+ id: string;
1006
+ pass: string;
552
1007
  };
553
- };
554
- interface IWhatsAppTemplateMessage {
555
- templateName: string;
556
- languageCode: string;
557
- parameters: IWhatsAppTemplateParameter[];
1008
+ static deflate(data: {
1009
+ id: string;
1010
+ pass: string;
1011
+ }): string;
558
1012
  }
559
1013
 
560
- interface IWhatsAppWebhookPayload {
561
- object: 'whatsapp_business_account';
562
- entry: IEntry[];
1014
+ interface IApiKeyRepository<A extends IStorableData> {
1015
+ find(id: string): Promise<ApiKey<A> | null>;
1016
+ findOrThrow(id: string): Promise<ApiKey<A>>;
1017
+ create(item: ApiKey<A>): Promise<void>;
1018
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1019
+ findAuthInfo(secret: string): Promise<A>;
1020
+ }
1021
+ interface IGenerateApiKeyReq<A extends IStorableData> extends IStorableData {
1022
+ name: string;
1023
+ authInfo: A;
563
1024
  }
564
- interface IEntry {
1025
+ interface IGenerateApiKeyRes {
565
1026
  id: string;
566
- changes: IChange[];
1027
+ secret: string;
567
1028
  }
568
- type IChange = IMessagesChange;
569
- interface IMessagesChange {
570
- value: IMessagesChangeValue;
571
- field: 'messages';
1029
+
1030
+ declare class ApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
1031
+ findAuthInfo(secret: string): Promise<A>;
1032
+ find(id: string): Promise<ApiKey<A> | null>;
1033
+ findOrThrow(id: string): Promise<ApiKey<A>>;
1034
+ create(item: ApiKey<A>): Promise<void>;
1035
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1036
+ static generate(repository: ApiKeyRepository<any>, req: IGenerateApiKeyReq<any>): Promise<{
1037
+ id: string;
1038
+ secret: string;
1039
+ }>;
1040
+ static findAuthInfo<A extends IStorableData>(repository: ApiKeyRepository<A>, secret: string): Promise<A>;
572
1041
  }
573
- interface IMessagesChangeValue {
574
- messaging_product: 'whatsapp';
575
- metadata: IMessageMetadata;
576
- contacts?: IWhatsAppContact[];
577
- messages?: IWhatsAppMessage[];
1042
+
1043
+ declare class ApiKeyConnectionGuardMiddleware implements IConnectionMiddleware {
1044
+ private apiKeyRepository;
1045
+ private auth;
1046
+ constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
1047
+ handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
578
1048
  }
579
- interface IMessageMetadata {
580
- display_phone_number: string;
581
- phone_number_id: string;
1049
+
1050
+ declare class ApiKeyGuardMiddleware implements IMiddleware {
1051
+ private apiKeyRepository;
1052
+ private auth;
1053
+ constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
1054
+ handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
582
1055
  }
583
- interface IWhatsAppContact {
584
- profile: {
585
- name: string;
1056
+
1057
+ declare class PgApiKeyRepository<A extends IStorableData> extends PgCrudRepository<ApiKey<A>> implements IApiKeyRepository<A> {
1058
+ constructor(pool: Pool);
1059
+ findAuthInfo(secret: string): Promise<A>;
1060
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1061
+ }
1062
+
1063
+ declare class RemoteApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
1064
+ private fetcher;
1065
+ private cacheSeconds;
1066
+ private cache;
1067
+ constructor(fetcher: (id: string) => Promise<ApiKey<A> | null>, cacheSeconds: number);
1068
+ find(id: string): Promise<ApiKey<A> | null>;
1069
+ findOrThrow(id: string): Promise<ApiKey<A>>;
1070
+ findAuthInfo(secret: string): Promise<A>;
1071
+ create(item: ApiKey<A>): Promise<void>;
1072
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1073
+ }
1074
+
1075
+ declare function jwtConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
1076
+
1077
+ declare function jwtGuard(): (target: object, propertyKey: string | symbol) => void;
1078
+
1079
+ interface IJwtRefreshTokenData<A extends IStorableData> extends IEntityData {
1080
+ authInfo: A;
1081
+ passwordHash?: string;
1082
+ expirationTime: number;
1083
+ }
1084
+ declare class JwtRefreshToken<A extends IStorableData> extends Entity<IJwtRefreshTokenData<A>> {
1085
+ get authInfo(): A;
1086
+ get expirationTime(): Date;
1087
+ generatePassword(): string;
1088
+ isValidPassword(password: string): boolean;
1089
+ validatePassword(password: string): void;
1090
+ static inflate(secret: string): {
1091
+ id: string;
1092
+ pass: string;
586
1093
  };
587
- wa_id: string;
1094
+ static deflate(data: {
1095
+ id: string;
1096
+ pass: string;
1097
+ }): string;
1098
+ }
1099
+
1100
+ interface IJwtRefreshTokenRepository<D extends IStorableData> extends ICrudRepository<JwtRefreshToken<D>> {
1101
+ }
1102
+
1103
+ declare class JwtTokenDto {
1104
+ token?: string;
1105
+ expiration?: Date;
1106
+ }
1107
+
1108
+ declare class JwtAccessAndRefreshTokenDto {
1109
+ access?: JwtTokenDto;
1110
+ refresh?: JwtTokenDto;
1111
+ }
1112
+
1113
+ declare class JwtConfig {
1114
+ secretOrPublicKey: string;
1115
+ secretOrPrivateKey: string;
1116
+ algorithm: Algorithm;
1117
+ accessExpirationSeconds: number;
1118
+ refreshExpirationSeconds: number;
1119
+ constructor(env: Env);
1120
+ }
1121
+
1122
+ declare class JwtSigner {
1123
+ private config;
1124
+ private mapper;
1125
+ constructor(config: JwtConfig, mapper: Mapper);
1126
+ signAccessToken<D extends IStorableData>(info: D | JwtRefreshToken<any>): Promise<JwtTokenDto>;
1127
+ }
1128
+
1129
+ declare class JwtRefreshTokenRepository<D extends IStorableData> implements IJwtRefreshTokenRepository<D> {
1130
+ find(id: string): Promise<JwtRefreshToken<D> | null>;
1131
+ findOrThrow(id: string): Promise<JwtRefreshToken<D>>;
1132
+ findByIds(ids: string[]): Promise<JwtRefreshToken<D>[]>;
1133
+ findAll(id: string): Promise<JwtRefreshToken<D>[]>;
1134
+ create(item: JwtRefreshToken<D>): Promise<void>;
1135
+ update(item: JwtRefreshToken<D>): Promise<void>;
1136
+ delete(item: JwtRefreshToken<D>): Promise<void>;
1137
+ }
1138
+
1139
+ declare class Jwt {
1140
+ private auth;
1141
+ private jwtSigner;
1142
+ private jwtRefreshTokenRepository;
1143
+ private config;
1144
+ constructor(auth: Auth<any>, jwtSigner: JwtSigner, jwtRefreshTokenRepository: JwtRefreshTokenRepository<any>, config: JwtConfig);
1145
+ createToken(): Promise<JwtAccessAndRefreshTokenDto>;
1146
+ refreshToken(refreshSecret: string): Promise<JwtTokenDto>;
1147
+ }
1148
+
1149
+ declare class JwtConnectionGuardMiddleware implements IConnectionMiddleware {
1150
+ private config;
1151
+ private auth;
1152
+ constructor(config: JwtConfig, auth: Auth<any>);
1153
+ handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
1154
+ }
1155
+
1156
+ declare class JwtGuardMiddleware implements IMiddleware {
1157
+ private config;
1158
+ private auth;
1159
+ constructor(config: JwtConfig, auth: Auth<any>);
1160
+ handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
1161
+ }
1162
+
1163
+ declare class PgJwtRefreshTokenRepository<D extends IStorableData> extends PgCrudRepository<JwtRefreshToken<D>> implements IJwtRefreshTokenRepository<D> {
1164
+ constructor(pool: Pool);
1165
+ }
1166
+
1167
+ declare class AnthropicChatAdapter implements IChatAdapter {
1168
+ private env;
1169
+ private anthropic;
1170
+ private logger;
1171
+ constructor(env: Env);
1172
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
1173
+ private mapChatItems;
1174
+ private mapHumanMessage;
1175
+ private mapBotMessage;
1176
+ private mapFunctionCall;
1177
+ private mapTool;
1178
+ private mapResponse;
1179
+ }
1180
+
1181
+ declare class DeepSeekChatAdapter implements IChatAdapter {
1182
+ private deepSeek;
1183
+ private logger;
1184
+ constructor();
1185
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
1186
+ private mapChatItems;
1187
+ private mapHumanMessage;
1188
+ private mapBotMessage;
1189
+ private mapFunctionCall;
1190
+ private mapTool;
1191
+ private mapResponse;
1192
+ }
1193
+
1194
+ declare class GoogleChatAdapter implements IChatAdapter {
1195
+ private env;
1196
+ private openai;
1197
+ private logger;
1198
+ constructor(env: Env);
1199
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
1200
+ private mapChatItems;
1201
+ private mapHumanMessage;
1202
+ private mapBotMessage;
1203
+ private mapFunctionCall;
1204
+ private mapTool;
1205
+ private mapResponse;
1206
+ }
1207
+
1208
+ declare class OpenaiChatAdapter implements IChatAdapter {
1209
+ private openai;
1210
+ private logger;
1211
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
1212
+ private mapChatItems;
1213
+ private mapConectionMessage;
1214
+ private mapBotMessage;
1215
+ private mapFunctionCall;
1216
+ private mapTool;
1217
+ private mapResponse;
1218
+ }
1219
+
1220
+ declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
1221
+ constructor(pool: Pool);
1222
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
1223
+ findMemory(chatId: string): Promise<IChatMemory | null>;
1224
+ }
1225
+
1226
+ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMemory {
1227
+ private chatId;
1228
+ constructor(pool: Pool, chatId: string);
1229
+ findLastItems(count: number): Promise<ChatItem[]>;
1230
+ }
1231
+
1232
+ declare class RamChatMemory implements IChatMemory {
1233
+ private memory;
1234
+ findLastItems(count: number): Promise<ChatItem[]>;
1235
+ create(item: ChatItem): Promise<void>;
1236
+ clearMemory(): Promise<void>;
1237
+ }
1238
+
1239
+ declare class RamChatRepository implements IChatRepository {
1240
+ private items;
1241
+ private memories;
1242
+ create(chat: Chat): Promise<void>;
1243
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
1244
+ findMemory(chatId: string): Promise<IChatMemory | null>;
1245
+ private getMemory;
1246
+ }
1247
+
1248
+ declare class WabotChatAdapter implements IChatAdapter {
1249
+ private apiKey;
1250
+ private baseUrl;
1251
+ private logger;
1252
+ constructor(env: Env);
1253
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
1254
+ }
1255
+
1256
+ declare function cmd(): (target: object, propertyKey: string | symbol) => void;
1257
+
1258
+ declare class CmdChannel implements IChatChannel {
1259
+ private rl;
1260
+ private callBack;
1261
+ listen(callback: (message: IChannelMessage) => void): void;
1262
+ connect(): void;
1263
+ }
1264
+
1265
+ interface ISocketChannelConfig {
1266
+ channel: string;
1267
+ }
1268
+
1269
+ declare class SocketChannelConfig implements ISocketChannelConfig {
1270
+ channel: string;
1271
+ constructor(channel: string);
1272
+ }
1273
+
1274
+ declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
1275
+
1276
+ interface ISocketChannelReceivedMessage {
1277
+ chatId: string;
1278
+ userId: string;
1279
+ senderName: string;
1280
+ text: string;
1281
+ }
1282
+ declare class SocketChannel implements IChatChannel {
1283
+ private config;
1284
+ private socketServerProvider;
1285
+ private callBack;
1286
+ private server;
1287
+ constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider);
1288
+ listen(callback: (message: IChannelMessage) => void): void;
1289
+ connect(): void;
1290
+ }
1291
+
1292
+ interface ITelegramChannelConfig {
1293
+ botToken: string;
588
1294
  }
589
- type IWhatsAppMessage = ITextMessage | IAudioMessage;
590
- interface IBaseMessage {
591
- from: string;
592
- id: string;
593
- timestamp: string;
594
- type: string;
1295
+ declare class TelegramChannelConfig implements ITelegramChannelConfig {
1296
+ botToken: string;
1297
+ constructor(botToken: string);
595
1298
  }
596
- interface ITextMessage extends IBaseMessage {
597
- type: 'text';
598
- text: {
599
- body: string;
600
- };
1299
+
1300
+ declare function telegram(config: ITelegramChannelConfig): (target: object, propertyKey: string | symbol) => void;
1301
+
1302
+ declare class TelegramChannel implements IChatChannel {
1303
+ private config;
1304
+ private bot;
1305
+ constructor(config: TelegramChannelConfig);
1306
+ listen(callback: (message: IChannelMessage) => void): void;
1307
+ connect(): void;
601
1308
  }
602
- interface IAudioMessage extends IBaseMessage {
603
- type: 'audio';
604
- audio: {
605
- mime_type: string;
606
- sha256: string;
607
- id: string;
608
- voice: boolean;
609
- };
1309
+
1310
+ interface IWhatsappChannelConfig {
1311
+ number: string;
1312
+ proxy?: string;
1313
+ }
1314
+ declare class WhatsappChannelConfig implements IWhatsappChannelConfig {
1315
+ number: string;
1316
+ constructor(number: string);
610
1317
  }
611
1318
 
612
- interface IWhatsAppBusinessNumber {
1319
+ declare function whatsApp(config: string | IWhatsappChannelConfig): (target: object, propertyKey: string | symbol) => void;
1320
+
1321
+ interface IWhatsAppBusinessNumber extends IStorableData {
613
1322
  id: string;
614
1323
  number: string;
615
1324
  }
616
- interface IWhatsAppBusinessAccount {
1325
+ interface IWhatsAppBusinessAccount extends IStorableData {
617
1326
  id: string;
618
1327
  }
619
- interface IWhatsAppData extends IPersistentData {
1328
+ interface IWhatsAppData extends IEntityData {
620
1329
  slug: string;
621
1330
  verifyToken: string;
622
1331
  appSecret: string;
@@ -624,7 +1333,7 @@ interface IWhatsAppData extends IPersistentData {
624
1333
  businessAccount: IWhatsAppBusinessAccount;
625
1334
  businessNumbers: IWhatsAppBusinessNumber[];
626
1335
  }
627
- declare class WhatsApp extends Persistent<IWhatsAppData> {
1336
+ declare class WhatsApp extends Entity<IWhatsAppData> {
628
1337
  getVerifyToken(): string;
629
1338
  getSlug(): string;
630
1339
  getBusinessAccount(): IWhatsAppBusinessAccount;
@@ -635,57 +1344,88 @@ declare class WhatsApp extends Persistent<IWhatsAppData> {
635
1344
  getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
636
1345
  }
637
1346
 
638
- declare class Logger {
639
- private debuggers;
640
- constructor(name: string);
641
- trace(...args: any[]): void;
642
- debug(...args: any[]): void;
643
- info(...args: any[]): void;
644
- warn(...args: any[]): void;
645
- error(...args: any[]): void;
646
- fatal(...args: any[]): void;
647
- private log;
1347
+ interface IWhatsAppRepository {
1348
+ findBySlug(slug: string): Promise<WhatsApp | null>;
1349
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1350
+ }
1351
+
1352
+ declare class EnvWhatsAppRepository implements IWhatsAppRepository {
1353
+ private env;
1354
+ constructor(env: Env);
1355
+ findBySlug(slug: string): Promise<WhatsApp | null>;
1356
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1357
+ private getFromEnvVars;
1358
+ }
1359
+
1360
+ declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
1361
+ constructor(pool: Pool);
1362
+ findBySlug(slug: string): Promise<WhatsApp | null>;
1363
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
648
1364
  }
649
1365
 
650
- type IWhatsAppMessageListener = (message: IConnectionChatMessage) => Promise<void>;
1366
+ type IWhatsAppMessageListener = (message: Omit<IChannelMessage, 'reply'>) => Promise<void>;
651
1367
  interface IListenWhatsAppMessageRequest {
652
1368
  to: string;
653
1369
  listener: IWhatsAppMessageListener;
654
1370
  }
655
- declare abstract class WhatsAppReceiver {
656
- protected logger: Logger;
657
- private listeners;
658
- constructor(logger: Logger);
659
- abstract connect(): Promise<void>;
1371
+ declare class WhatsAppReceiver {
1372
+ connect(): Promise<void>;
660
1373
  listenMessage(request: IListenWhatsAppMessageRequest): void;
661
- protected handlePayload(payload: IWhatsAppWebhookPayload): Promise<void>;
662
- private emmitMessage;
663
1374
  }
664
1375
 
665
- interface IWhatsAppRepository {
666
- findBySlug(slug: string): Promise<WhatsApp | null>;
667
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1376
+ type IWhatsAppCloudTemplateParameter = {
1377
+ type: 'text';
1378
+ text: string;
1379
+ parameter_name?: string;
1380
+ } | {
1381
+ type: 'currency';
1382
+ currency: {
1383
+ fallback_value: string;
1384
+ code: string;
1385
+ amount_1000: number;
1386
+ };
1387
+ } | {
1388
+ type: 'date_time';
1389
+ date_time: {
1390
+ fallback_value: string;
1391
+ };
1392
+ };
1393
+ interface IWhatsAppCloudTemplateMessage {
1394
+ templateName: string;
1395
+ languageCode: string;
1396
+ parameters: IWhatsAppCloudTemplateParameter[];
668
1397
  }
669
1398
 
670
- declare class WhatsAppRepository implements IWhatsAppRepository {
671
- findBySlug(slug: string): Promise<WhatsApp | null>;
672
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1399
+ interface IWhatsAppCloudTemplateResponse {
1400
+ data: IWhatsAppCloudTemplate[];
1401
+ paging: IWhatsAppCloudApiPaging;
673
1402
  }
674
-
675
- interface IWhatsAppTemplate {
1403
+ interface IWhatsAppCloudTemplate {
676
1404
  name: string;
677
1405
  parameter_format: 'POSITIONAL' | 'OTHER';
678
- components: IWhatsAppTemplateComponent[];
1406
+ components: IWhatsAppCloudTemplateComponent[];
679
1407
  language: string;
680
1408
  status: string;
681
1409
  category: string;
682
1410
  id: string;
683
1411
  }
684
- interface IWhatsAppTemplateComponent {
1412
+ interface IWhatsAppCloudTemplateComponent {
685
1413
  type: 'HEADER' | 'BODY' | 'FOOTER';
686
1414
  format?: 'TEXT';
687
1415
  text?: string;
688
1416
  }
1417
+ interface IWhatsAppCloudApiPaging {
1418
+ cursors: IWhatsAppCloudApiCursors;
1419
+ }
1420
+ interface IWhatsAppCloudApiCursors {
1421
+ before: string;
1422
+ after: string;
1423
+ }
1424
+
1425
+ declare class WhatsAppRepository implements IWhatsAppRepository {
1426
+ findBySlug(slug: string): Promise<WhatsApp | null>;
1427
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1428
+ }
689
1429
 
690
1430
  interface ISendWhatsAppRequest {
691
1431
  from: string;
@@ -695,7 +1435,7 @@ interface ISendWhatsAppRequest {
695
1435
  interface ISendWhatsAppTemplateRequest {
696
1436
  from: string;
697
1437
  to: string;
698
- templateMessage: IWhatsAppTemplateMessage;
1438
+ templateMessage: IWhatsAppCloudTemplateMessage;
699
1439
  senderName: string;
700
1440
  }
701
1441
  interface IGetWhatsAppTemplateRequest {
@@ -706,270 +1446,164 @@ interface IGetWhatsAppTemplateRequest {
706
1446
  interface IWhatsAppSenderOptions {
707
1447
  writeChatMemory?: boolean;
708
1448
  }
709
- declare abstract class WhatsAppSender {
710
- protected logger: Logger;
1449
+ declare class WhatsAppSender {
711
1450
  protected chatRepository: ChatRepository;
712
1451
  protected chatResolver: ChatResolver;
713
1452
  protected whatsAppRepository: WhatsAppRepository;
714
- constructor(logger: Logger, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
715
- protected abstract handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
716
- protected abstract handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
717
- protected abstract handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
1453
+ constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
718
1454
  sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
719
1455
  sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
720
- getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
721
- protected resolveTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
1456
+ protected getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppCloudTemplate | null>;
1457
+ protected mapTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
722
1458
  protected writePrivateChatMemory(message: IChatMessage, to: string): Promise<void>;
723
- private replaceTemplateParameters;
1459
+ protected replaceTemplateParameters(template: string, data: IWhatsAppCloudTemplateParameter[]): string;
724
1460
  }
725
1461
 
726
1462
  declare class WhatsAppChannel implements IChatChannel {
727
1463
  private config;
728
- private chatResolver;
729
- private userResolver;
730
1464
  private sender;
731
1465
  private receiver;
732
1466
  private logger;
733
- constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, sender: WhatsAppSender, receiver: WhatsAppReceiver);
734
- listen(callback: (message: IReceivedMessage) => void): void;
1467
+ constructor(config: WhatsappChannelConfig, sender: WhatsAppSender, receiver: WhatsAppReceiver);
1468
+ listen(callback: (message: IChannelMessage) => void): void;
735
1469
  connect(): void;
736
1470
  }
737
1471
 
738
- declare class WabotDevConnection {
739
- private devProxy;
740
- private devProxySocket;
741
- private devToken;
742
- private logger;
743
- static isTokenAvailable(): boolean;
744
- constructor();
745
- getSocket(): Promise<Socket>;
746
- }
747
-
748
- declare class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
749
- private wabotDevConnection;
750
- constructor(wabotDevConnection: WabotDevConnection);
751
- connect(): Promise<void>;
1472
+ interface IWhatsAppCloudWebhookPayload {
1473
+ object: 'whatsapp_business_account';
1474
+ entry: IWhatsAppCloudEntry[];
752
1475
  }
753
-
754
- declare class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
755
- private expressProvider;
756
- private whatsAppRepository;
757
- private expressApp;
758
- private webhookPath;
759
- constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
760
- connect(): Promise<void>;
1476
+ interface IWhatsAppCloudEntry {
1477
+ id: string;
1478
+ changes: IWhatsAppCloudChange[];
761
1479
  }
762
-
763
- declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
764
- private wabotDevConnection;
765
- constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
766
- handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
767
- handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
768
- handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
1480
+ type IWhatsAppCloudChange = IWhatsAppCloudMessagesChange;
1481
+ interface IWhatsAppCloudMessagesChange {
1482
+ value: IWhatsAppCloudMessagesChangeValue;
1483
+ field: 'messages';
769
1484
  }
770
-
771
- declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
772
- constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
773
- handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
774
- handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
775
- handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
1485
+ interface IWhatsAppCloudMessagesChangeValue {
1486
+ messaging_product: 'whatsapp';
1487
+ metadata: IWhatsAppCloudMessageMetadata;
1488
+ contacts?: IWhatsAppCloudContact[];
1489
+ messages?: IWhatsAppCloudMessage[];
776
1490
  }
777
-
778
- interface ICrudRepository<T> {
779
- find(id: string): Promise<T | null>;
780
- findAll(id: string): Promise<T[]>;
781
- create(item: T): Promise<void>;
782
- update(item: T): Promise<void>;
783
- discard(item: T): Promise<void>;
1491
+ interface IWhatsAppCloudMessageMetadata {
1492
+ display_phone_number: string;
1493
+ phone_number_id: string;
784
1494
  }
785
-
786
- type IPgRepositoryConfig<P extends Persistent> = {
787
- schema?: string;
788
- table: string;
789
- constructor: IConstructor<P>;
790
- add?: {
791
- columns: {
792
- [column: string]: {
793
- type: string;
794
- value: (item: P) => boolean | number | string | null | Date;
795
- };
796
- };
797
- };
798
- };
799
-
800
- declare class PgRepositoryBase<P extends Persistent> {
801
- protected pool: Pool;
802
- protected config: IPgRepositoryConfig<any>;
803
- private tableIsCreated;
804
- schema: string;
805
- table: string;
806
- columnsList: string[];
807
- columnsAndTypes: string;
808
- columns: string;
809
- vars: string;
810
- updates: string;
811
- addColumns: {
812
- [columns: string]: {
813
- type: string;
814
- value: (item: P) => number | boolean | string | null | Date;
815
- };
1495
+ interface IWhatsAppCloudContact {
1496
+ profile: {
1497
+ name: string;
816
1498
  };
817
- constructor(pool: Pool, config: IPgRepositoryConfig<any>);
818
- values(item: P): (string | number | boolean | Date | null)[];
819
- protected exec(sql: string, values: any[]): Promise<void>;
820
- protected query(sql: string, values: any[]): Promise<any[]>;
821
- protected connect(): Promise<Pool>;
822
- protected ensureTable(): Promise<void>;
823
- protected ensureColumns(): Promise<void>;
824
- }
825
-
826
- declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
827
- protected readonly config: IPgRepositoryConfig<P>;
828
- constructor(pool: Pool, config: IPgRepositoryConfig<P>);
829
- find(id: string): Promise<P | null>;
830
- findAll(): Promise<P[]>;
831
- create(item: P): Promise<void>;
832
- update(item: P): Promise<void>;
833
- discard(item: P): Promise<void>;
834
- }
835
-
836
- declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
837
- constructor(pool: Pool);
838
- findBySlug(slug: string): Promise<WhatsApp | null>;
839
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1499
+ wa_id: string;
840
1500
  }
841
-
842
- type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
843
- declare class WabotEnv {
844
- private envType;
845
- constructor();
846
- isDevelopment(): boolean;
847
- isProduction(): boolean;
848
- requireString(varName: string): string;
1501
+ type IWhatsAppCloudMessage = IWhatsAppCloudTextMessage | IWhatsAppCloudAudioMessage;
1502
+ interface IWhatsAppCloudBaseMessage {
1503
+ from: string;
1504
+ id: string;
1505
+ timestamp: string;
1506
+ type: string;
849
1507
  }
850
-
851
- declare class EnvWhatsAppRepository implements IWhatsAppRepository {
852
- private env;
853
- constructor(env: WabotEnv);
854
- findBySlug(slug: string): Promise<WhatsApp | null>;
855
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
856
- private getFromEnvVars;
1508
+ interface IWhatsAppCloudTextMessage extends IWhatsAppCloudBaseMessage {
1509
+ type: 'text';
1510
+ text: {
1511
+ body: string;
1512
+ };
857
1513
  }
858
-
859
- declare function prepareChatContainer(container: DependencyContainer$1, context: IMessageContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer$1>;
860
-
861
- interface IrunChannelProps {
862
- channel: IConstructor<IChatChannel>;
863
- channelConfig?: object;
864
- mindset: IConstructor<IMindset>;
865
- chatRepository: IConstructor<IChatRepository>;
866
- chatBotAdapter: IConstructor<IChatBotAdapter>;
1514
+ interface IWhatsAppCloudAudioMessage extends IWhatsAppCloudBaseMessage {
1515
+ type: 'audio';
1516
+ audio: {
1517
+ mime_type: string;
1518
+ sha256: string;
1519
+ id: string;
1520
+ voice: boolean;
1521
+ };
867
1522
  }
868
- declare function runChannel(props: IrunChannelProps): void;
869
1523
 
870
- interface IServerProvider<T, ST extends T> {
871
- replace: IConstructor<T>;
872
- with: IConstructor<ST>;
873
- singleton?: true;
874
- }
875
- interface IServerConfig {
876
- controllers: IConstructor<any>[];
877
- providers?: IServerProvider<unknown, unknown>[];
1524
+ declare class WhatsAppReceiverByCloudApi extends WhatsAppReceiver {
1525
+ private expressProvider;
1526
+ private whatsAppRepository;
1527
+ private listeners;
1528
+ private expressApp;
1529
+ private logger;
1530
+ private webhookPath;
1531
+ constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
1532
+ connect(): Promise<void>;
1533
+ listenMessage(request: IListenWhatsAppMessageRequest): void;
1534
+ protected handlePayload(payload: IWhatsAppCloudWebhookPayload): Promise<void>;
1535
+ private emmitMessage;
878
1536
  }
879
- declare function runServer(config: IServerConfig): void;
880
1537
 
881
- declare class SendOneTimePasswordRequest {
882
- fromEmail: string;
883
- toEmail: string;
1538
+ declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
1539
+ private logger;
1540
+ constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
1541
+ sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
1542
+ sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
1543
+ protected getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppCloudTemplate | null>;
884
1544
  }
885
1545
 
886
- declare class ValidateOneTimePasswordRequest {
887
- userEmail: string;
888
- otp: string;
1546
+ interface IWhatsAppProxyMessageContent {
1547
+ text: string;
889
1548
  }
890
1549
 
891
- interface ISendEmailRequest {
1550
+ interface IWhatsAppProxyMessage {
892
1551
  from: string;
893
1552
  to: string;
894
- subject: string;
895
- html: string;
896
- }
897
- interface IEmailService {
898
- sendEmail(request: ISendEmailRequest): Promise<void>;
899
- }
900
- declare class EmailService implements IEmailService {
901
- sendEmail(request: ISendEmailRequest): Promise<void>;
902
- }
903
-
904
- interface IOtpService {
905
- generate(): Promise<string>;
906
- }
907
- declare class OtpService implements IOtpService {
908
- generate(): Promise<string>;
909
- }
910
-
911
- declare class AuthenticationModule {
912
- private userRepository;
913
- private emailService;
914
- private otpService;
915
- private context;
916
- constructor(userRepository: UserRepository, emailService: EmailService, otpService: OtpService, context: MessageContext);
917
- sendOneTimePassword(request: SendOneTimePasswordRequest): Promise<string>;
918
- validateOneTimePassword(request: ValidateOneTimePasswordRequest): Promise<string>;
919
- protected generateOtpEmailHtml(otp: string, user: User): Promise<string>;
920
- protected generateOtpEmailSubject(): Promise<string>;
1553
+ senderName?: string;
1554
+ content: IWhatsAppProxyMessageContent;
921
1555
  }
922
1556
 
923
- declare class RegisterUserWithEmailRequest {
924
- email: string;
925
- shortName: string;
1557
+ declare const WHATSAPP_PROXY_SEND_MESSAGE_EVENT: "sendMessage";
1558
+ interface IWhatsAppProxySendMessageEventReq {
1559
+ event: typeof WHATSAPP_PROXY_SEND_MESSAGE_EVENT;
1560
+ data: IWhatsAppProxyMessage;
926
1561
  }
927
-
928
- declare class RegisterUserModule {
929
- private userRepository;
930
- private context;
931
- constructor(userRepository: UserRepository, context: MessageContext);
932
- registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
1562
+ declare const WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT: "listenMessage";
1563
+ interface IWhatsAppProxyListenMessageEventReq {
1564
+ event: typeof WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT;
1565
+ data: IWhatsAppProxyListenMessageEventData;
933
1566
  }
934
-
935
- declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
936
- constructor(pool: Pool);
937
- findByConnection(query: IUserConnection): Promise<User | null>;
1567
+ interface IWhatsAppProxyListenMessageEventData {
1568
+ from?: string[];
1569
+ to: string[];
938
1570
  }
939
-
940
- declare class RamUserRepository implements IUserRepository {
941
- private items;
942
- create(chat: User): Promise<void>;
943
- findByConnection(query: IUserConnection): Promise<User | null>;
944
- update(chat: User): Promise<void>;
1571
+ declare const WHATSAPP_MESSAGE_EVENT: "message";
1572
+ interface IWhatsAppProxyMessageEventReq {
1573
+ event: typeof WHATSAPP_MESSAGE_EVENT;
1574
+ data: IWhatsAppProxyMessage;
945
1575
  }
946
1576
 
947
- declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
948
- constructor(pool: Pool);
949
- findByConnection(query: IChatConnection): Promise<Chat | null>;
950
- findMemory(chatId: string): Promise<IChatMemory | null>;
1577
+ declare class WhatsAppWabotProxyConnection {
1578
+ private baseUrl;
1579
+ private socket;
1580
+ private apiKey;
1581
+ private logger;
1582
+ constructor(env: Env);
1583
+ getSocket(): Promise<Socket$1>;
951
1584
  }
952
1585
 
953
- declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMemory {
954
- private chatId;
955
- constructor(pool: Pool, chatId: string);
956
- findLastItems(count: number): Promise<ChatItem[]>;
1586
+ declare class WhatsAppReceiverByWabotProxy extends WhatsAppReceiver {
1587
+ private connection;
1588
+ private loger;
1589
+ constructor(connection: WhatsAppWabotProxyConnection);
1590
+ connect(): Promise<void>;
1591
+ listenMessage(request: IListenWhatsAppMessageRequest): void;
957
1592
  }
958
1593
 
959
- declare class RamChatMemory implements IChatMemory {
960
- private memory;
961
- findLastItems(count: number): Promise<ChatItem[]>;
962
- create(item: ChatItem): Promise<void>;
963
- clearMemory(): Promise<void>;
1594
+ declare class WhatsAppSenderByWabotProxy extends WhatsAppSender {
1595
+ private wabotDevConnection;
1596
+ private logger;
1597
+ constructor(wabotDevConnection: WhatsAppWabotProxyConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
1598
+ sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
964
1599
  }
965
1600
 
966
- declare class RamChatRepository implements IChatRepository {
967
- private items;
968
- private memories;
969
- create(chat: Chat): Promise<void>;
970
- findByConnection(query: IChatConnection): Promise<Chat | null>;
971
- findMemory(chatId: string): Promise<IChatMemory | null>;
972
- private getMemory;
1601
+ interface IHtmlModuleOptions {
1602
+ url: string;
1603
+ title: string;
973
1604
  }
1605
+ declare function HtmlModule(options: IHtmlModuleOptions): {
1606
+ new (): {};
1607
+ };
974
1608
 
975
- export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, DeepSeekChatBotAdapter, EmailService, EnvWhatsAppRepository, ExpressProvider, HttpServerProvider, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type IEmailService, type IGetWhatsAppTemplateRequest, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IReceivedMessage, type IReceivedMessageItem, type IReversibleMapper, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IWabotEnvType, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, type IrunChannelProps, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, RegisterUserModule, RegisterUserWithEmailRequest, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, WabotEnv, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, container, inject, injectable, isOptional, mindset, mindsetFunction, mindsetModule, param, prepareChatContainer, runChannel, runServer, singleton, socket, telegram, whatsapp };
1609
+ export { AnthropicChatAdapter, ApiKey, ApiKeyConnectionGuardMiddleware, ApiKeyGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionMiddleware, type IConnectionMiddlewareMetadata, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketConnectionConfig, type ISocketConnectionMetadata, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtConnectionGuardMiddleware, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyConnectionGuard, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp };