@wabot-dev/framework 0.1.0-beta.4 → 0.1.0-beta.41

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 (154) hide show
  1. package/dist/src/addon/async/pg/PgJobRepository.js +26 -0
  2. package/dist/src/addon/chat-bot/anthropic/AnthropicChatAdapter.js +135 -0
  3. package/dist/src/addon/chat-bot/deepseek/DeepSeekChatAdapter.js +137 -0
  4. package/dist/src/addon/chat-bot/google/GoogleChatAdapter.js +127 -0
  5. package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +116 -0
  6. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatMemory.js +5 -4
  7. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatRepository.js +5 -5
  8. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatRepository.js +2 -2
  9. package/dist/src/addon/chat-controller/cmd/@cmd.js +22 -0
  10. package/dist/src/{channels → addon/chat-controller}/cmd/CmdChannel.js +4 -26
  11. package/dist/src/{channels → addon/chat-controller}/socket/@socket.js +8 -4
  12. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannel.js +5 -23
  13. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannelConfig.js +1 -1
  14. package/dist/src/{channels → addon/chat-controller}/telegram/@telegram.js +8 -4
  15. package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannel.js +4 -22
  16. package/dist/src/{channels → addon/chat-controller}/whatsapp/@whatsapp.js +8 -4
  17. package/dist/src/{channels → addon/chat-controller}/whatsapp/EnvWhatsAppRepository.js +3 -3
  18. package/dist/src/{channels → addon/chat-controller}/whatsapp/PgWhatsAppRepository.js +1 -1
  19. package/dist/src/{channels/wabot → addon/chat-controller/whatsapp}/WabotDevConnection.js +2 -2
  20. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsApp.js +2 -4
  21. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannel.js +6 -18
  22. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiver.js +4 -7
  23. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByDevConnection.js +4 -10
  24. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByWebHook.js +6 -12
  25. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSender.js +39 -10
  26. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByCloudApi.js +10 -13
  27. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByDevConnection.js +13 -15
  28. package/dist/src/addon/mindset/html/HtmlModule.js +70 -0
  29. package/dist/src/addon/money/MoneyDto.js +22 -0
  30. package/dist/src/{repository → addon/repository}/pg/PgCrudRepository.js +23 -2
  31. package/dist/src/{repository → addon/repository}/pg/PgRepositoryBase.js +2 -2
  32. package/dist/src/addon/rest-controller/jwt/@jwtGuard.js +17 -0
  33. package/dist/src/addon/rest-controller/jwt/Jwt.js +31 -0
  34. package/dist/src/addon/rest-controller/jwt/JwtAccessAndRefreshTokenDto.js +20 -0
  35. package/dist/src/addon/rest-controller/jwt/JwtConfig.js +28 -0
  36. package/dist/src/addon/rest-controller/jwt/JwtGuardMiddleware.js +45 -0
  37. package/dist/src/addon/rest-controller/jwt/JwtRefreshToken.js +9 -0
  38. package/dist/src/addon/rest-controller/jwt/JwtRefreshTokenRepository.js +21 -0
  39. package/dist/src/addon/rest-controller/jwt/JwtSigner.js +48 -0
  40. package/dist/src/addon/rest-controller/jwt/JwtTokenDto.js +22 -0
  41. package/dist/src/addon/validation/is-boolean/@isBoolean.js +17 -0
  42. package/dist/src/addon/validation/is-boolean/validateIsBoolean.js +12 -0
  43. package/dist/src/addon/validation/is-date/@isDate.js +17 -0
  44. package/dist/src/addon/validation/is-date/validateIsDate.js +16 -0
  45. package/dist/src/addon/validation/is-not-empty/@isNotEmpty.js +17 -0
  46. package/dist/src/addon/validation/is-not-empty/validateIsNotEmpty.js +12 -0
  47. package/dist/src/addon/validation/is-number/@isNumber.js +17 -0
  48. package/dist/src/addon/validation/is-number/validateIsNumber.js +12 -0
  49. package/dist/src/addon/validation/is-present/@isPresent.js +17 -0
  50. package/dist/src/addon/validation/is-present/validateIsPresent.js +12 -0
  51. package/dist/src/addon/validation/is-string/@isString.js +17 -0
  52. package/dist/src/addon/validation/is-string/validateIsString.js +12 -0
  53. package/dist/src/addon/validation/max/@max.js +18 -0
  54. package/dist/src/addon/validation/max/validateMax.js +17 -0
  55. package/dist/src/addon/validation/min/@min.js +18 -0
  56. package/dist/src/addon/validation/min/validateMin.js +17 -0
  57. package/dist/src/core/auth/Auth.js +24 -0
  58. package/dist/src/core/{Persistent.js → entity/Entity.js} +24 -9
  59. package/dist/src/core/env/Env.js +39 -0
  60. package/dist/src/core/error/CustomError.js +15 -0
  61. package/dist/src/core/injection/index.js +4 -0
  62. package/dist/src/core/mapper/Mapper.js +42 -0
  63. package/dist/src/core/random/Random.js +37 -0
  64. package/dist/src/core/storable/Storable.js +8 -0
  65. package/dist/src/core/validation/metadata/@isArray.js +18 -0
  66. package/dist/src/core/validation/metadata/@isModel.js +18 -0
  67. package/dist/src/core/validation/metadata/@isOptional.js +17 -0
  68. package/dist/src/core/validation/metadata/ValidationMetadataStore.js +98 -0
  69. package/dist/src/core/validation/modelInfo.js +9 -0
  70. package/dist/src/core/validation/validate.js +11 -0
  71. package/dist/src/core/validation/validators/validateArray.js +51 -0
  72. package/dist/src/core/validation/validators/validateIsOptional.js +5 -0
  73. package/dist/src/core/validation/validators/validateModel.js +36 -0
  74. package/dist/src/feature/async/@command.js +11 -0
  75. package/dist/src/feature/async/@commandHandler.js +12 -0
  76. package/dist/src/feature/async/Async.js +38 -0
  77. package/dist/src/feature/async/Command.js +9 -0
  78. package/dist/src/feature/async/CommandMetadataStore.js +38 -0
  79. package/dist/src/feature/async/Job.js +24 -0
  80. package/dist/src/feature/async/JobRepository.js +31 -0
  81. package/dist/src/feature/async/JobRunner.js +45 -0
  82. package/dist/src/feature/async/JobsEventsHub.js +24 -0
  83. package/dist/src/feature/async/runCommandHandlers.js +29 -0
  84. package/dist/src/{core/chat → feature/chat-bot}/Chat.js +2 -2
  85. package/dist/src/feature/chat-bot/ChatAdapter.js +7 -0
  86. package/dist/src/feature/chat-bot/ChatBot.js +50 -0
  87. package/dist/src/feature/chat-bot/ChatItem.js +24 -0
  88. package/dist/src/feature/chat-bot/ChatMemory.js +10 -0
  89. package/dist/src/{core/chat/repository/IChatRepository.js → feature/chat-bot/ChatRepository.js} +2 -8
  90. package/dist/src/feature/chat-bot/IChatItem.js +3 -0
  91. package/dist/src/{chatbot → feature/chat-bot}/metadata/@chatBot.js +1 -1
  92. package/dist/src/{chatbot → feature/chat-bot}/metadata/ChatBotMetadataStore.js +1 -1
  93. package/dist/src/{controller/channel → feature/chat-controller}/ChatResolver.js +5 -4
  94. package/dist/src/{controller → feature/chat-controller}/metadata/ControllerMetadataStore.js +1 -1
  95. package/dist/src/{controller → feature/chat-controller}/metadata/controller/@chatController.js +1 -1
  96. package/dist/src/feature/chat-controller/runChatControllers.js +69 -0
  97. package/dist/src/{channels → feature}/express/ExpressProvider.js +2 -4
  98. package/dist/src/{channels → feature}/http/HttpServerProvider.js +2 -2
  99. package/dist/src/{mindset → feature/mindset}/MindsetOperator.js +66 -42
  100. package/dist/src/{mindset → feature/mindset}/metadata/MindsetMetadataStore.js +1 -1
  101. package/dist/src/{mindset → feature/mindset}/metadata/functions/@mindsetFunction.js +1 -1
  102. package/dist/src/{mindset → feature/mindset}/metadata/mindsets/@mindset.js +1 -1
  103. package/dist/src/{mindset → feature/mindset}/metadata/modules/@mindsetModule.js +1 -2
  104. package/dist/src/{mindset → feature/mindset}/metadata/params/@param.js +1 -1
  105. package/dist/src/feature/money/Money.js +61 -0
  106. package/dist/src/feature/rest-controller/injection-tokens.js +4 -0
  107. package/dist/src/feature/rest-controller/metadata/@get.js +19 -0
  108. package/dist/src/feature/rest-controller/metadata/@middleware.js +16 -0
  109. package/dist/src/feature/rest-controller/metadata/@post.js +19 -0
  110. package/dist/src/feature/rest-controller/metadata/@restController.js +15 -0
  111. package/dist/src/feature/rest-controller/metadata/RestControllerMetadataStore.js +50 -0
  112. package/dist/src/feature/rest-controller/runRestControllers.js +88 -0
  113. package/dist/src/{channels → feature}/socket/SocketServerProvider.js +2 -2
  114. package/dist/src/index.d.ts +848 -483
  115. package/dist/src/index.js +122 -76
  116. package/package.json +9 -3
  117. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +0 -106
  118. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +0 -84
  119. package/dist/src/channels/cmd/@cmd.js +0 -18
  120. package/dist/src/chatbot/ChatBot.js +0 -51
  121. package/dist/src/chatbot/ChatBotAdapter.js +0 -72
  122. package/dist/src/controller/channel/UserResolver.js +0 -21
  123. package/dist/src/core/IMessageContext.js +0 -12
  124. package/dist/src/core/chat/ChatItem.js +0 -15
  125. package/dist/src/core/chat/repository/IChatMemory.js +0 -10
  126. package/dist/src/core/user/IUserRepository.js +0 -19
  127. package/dist/src/core/user/User.js +0 -26
  128. package/dist/src/env/WabotEnv.js +0 -27
  129. package/dist/src/injection/index.js +0 -4
  130. package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
  131. package/dist/src/pre-made/module/authentication/AuthenticationModule.js +0 -97
  132. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -25
  133. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -25
  134. package/dist/src/pre-made/module/register-user/RegisterUserModule.js +0 -56
  135. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -25
  136. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -33
  137. package/dist/src/pre-made/repository/user/ram/RamUserRepository.js +0 -27
  138. package/dist/src/pre-made/service/EmailService.js +0 -13
  139. package/dist/src/pre-made/service/OtpService.js +0 -14
  140. package/dist/src/server/prepareChatContainer.js +0 -43
  141. package/dist/src/server/runChannel.js +0 -27
  142. package/dist/src/server/runServer.js +0 -40
  143. /package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatMemory.js +0 -0
  144. /package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannelConfig.js +0 -0
  145. /package/dist/src/{channels/wabot → addon/chat-controller/whatsapp}/WabotDevSocketContracts.js +0 -0
  146. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannelConfig.js +0 -0
  147. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppRepository.js +0 -0
  148. /package/dist/src/{injection → core/injection}/Container.js +0 -0
  149. /package/dist/src/{logger → core/logger}/Logger.js +0 -0
  150. /package/dist/src/{mindset → feature/mindset}/IMindset.js +0 -0
  151. /package/dist/src/{mindset → feature/mindset}/metadata/functions/decoratorNames.js +0 -0
  152. /package/dist/src/{mindset → feature/mindset}/metadata/mindsets/decoratorNames.js +0 -0
  153. /package/dist/src/{mindset → feature/mindset}/metadata/modules/decoratorNames.js +0 -0
  154. /package/dist/src/{mindset → feature/mindset}/metadata/params/decoratorNames.js +0 -0
@@ -1,183 +1,367 @@
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';
8
+ import { Express, Request, Response } from 'express';
6
9
  import { Server as Server$1 } from 'socket.io';
7
- import { Socket } from 'socket.io-client';
10
+ import * as big_js from 'big.js';
8
11
  import { Pool } from 'pg';
9
- import * as tsyringe from 'tsyringe';
10
- import { DependencyContainer as DependencyContainer$1 } from 'tsyringe';
11
- export { DependencyContainer } from 'tsyringe';
12
+ import { Socket } from 'socket.io-client';
13
+ import { Algorithm } from 'jsonwebtoken';
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
49
  discard(): void;
43
50
  }
51
+ /**
52
+ * @deprecated Should use IEntityData
53
+ */
54
+ interface IPersistentData extends IEntityData {
55
+ }
56
+ /**
57
+ * @deprecated Should use Entity
58
+ */
59
+ declare class Persistent<D extends IPersistentData> extends Entity<D> {
60
+ }
44
61
 
45
- type IChatType = 'PRIVATE' | 'GROUP';
46
- interface IChatConnection {
47
- chatType: IChatType;
48
- channelName: string;
49
- id: string;
62
+ type IEnvType = 'development' | 'staging' | 'testing' | 'production';
63
+ declare class Env {
64
+ private envType;
65
+ constructor();
66
+ isDevelopment(): boolean;
67
+ isProduction(): boolean;
68
+ isTesting(): boolean;
69
+ requireString(varName: string, options?: {
70
+ default?: string;
71
+ }): string;
72
+ requireNumber(varName: string, options?: {
73
+ default?: number;
74
+ }): number;
75
+ }
76
+
77
+ interface ICustomErrorData {
78
+ message: string;
79
+ humanMessage?: string;
80
+ code?: string;
81
+ httpCode?: number;
82
+ cause?: Error;
83
+ info?: any;
84
+ }
85
+ declare class CustomError extends Error {
86
+ humanMessage?: string;
87
+ code?: string;
88
+ httpCode?: number;
89
+ info?: any;
90
+ constructor(data: ICustomErrorData);
50
91
  }
51
- interface IChatData extends IPersistentData {
52
- type: IChatType;
53
- connections: IChatConnection[];
92
+
93
+ type IConstructor<T> = new (...args: any[]) => T;
94
+
95
+ declare class Container implements DependencyContainer {
96
+ register(token: unknown, provider: unknown, options?: unknown): DependencyContainer;
97
+ registerSingleton(from: unknown, to?: unknown): DependencyContainer;
98
+ registerType<T>(from: InjectionToken<T>, to: InjectionToken<T>): DependencyContainer;
99
+ registerInstance<T>(token: InjectionToken<T>, instance: T): DependencyContainer;
100
+ resolve<T>(token: InjectionToken<T>): T;
101
+ resolveAll<T>(token: InjectionToken<T>): T[];
102
+ isRegistered<T>(token: InjectionToken<T>, recursive?: boolean): boolean;
103
+ reset(): void;
104
+ clearInstances(): void;
105
+ createChildContainer(): DependencyContainer;
106
+ beforeResolution<T>(token: InjectionToken<T>, callback: PreResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
107
+ afterResolution<T>(token: InjectionToken<T>, callback: PostResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
108
+ dispose(): Promise<void> | void;
54
109
  }
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;
110
+
111
+ declare const injectable: typeof tsyringe.injectable;
112
+ declare const container: tsyringe.DependencyContainer;
113
+ declare const singleton: typeof tsyringe.singleton;
114
+ declare const inject: typeof tsyringe.inject;
115
+ declare const scoped: typeof tsyringe.scoped;
116
+ declare const Lifecycle: typeof tsyringe.Lifecycle;
117
+
118
+ declare class Logger {
119
+ private debuggers;
120
+ constructor(name: string);
121
+ trace(...args: any[]): void;
122
+ debug(...args: any[]): void;
123
+ info(...args: any[]): void;
124
+ warn(...args: any[]): void;
125
+ error(...args: any[]): void;
126
+ fatal(...args: any[]): void;
127
+ private log;
63
128
  }
64
129
 
65
- interface IChatDocument {
130
+ declare class Mapper {
131
+ map<T>(data: any, ctor: IConstructor<T>): T;
66
132
  }
67
133
 
68
- interface IChatImage {
134
+ declare class Random {
135
+ static slug(name: string, options: {
136
+ randomLength: number;
137
+ }): string;
138
+ static string(length: number): string;
139
+ static numberCode(length: number): string;
69
140
  }
70
141
 
71
- interface IUserConnection {
72
- channelName: string;
73
- id: string;
142
+ interface ICrudRepository<T> {
143
+ find(id: string): Promise<T | null>;
144
+ findOrThrow(id: string): Promise<T>;
145
+ findByIds(ids: string[]): Promise<T[]>;
146
+ findAll(id: string): Promise<T[]>;
147
+ create(item: T): Promise<void>;
148
+ update(item: T): Promise<void>;
149
+ discard(item: T): Promise<void>;
150
+ }
151
+
152
+ declare function isModel(model: IConstructor<any>): (target: object, propertyKey: string | symbol) => void;
153
+
154
+ declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
155
+
156
+ interface IValidationError {
157
+ description: string;
74
158
  }
75
- interface IUserData extends IPersistentData {
76
- shortName: string;
77
- connections: IUserConnection[];
78
- keyValueData: {
79
- [key: string]: string;
159
+ interface IModelValidationError extends IValidationError {
160
+ properties: {
161
+ [key: string]: string[];
80
162
  };
81
163
  }
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;
164
+ interface IArrayValidationError extends IValidationError {
165
+ items: (IValidationError[] | null)[];
88
166
  }
167
+ type IValidationResult<V> = {
168
+ value: V;
169
+ error?: undefined;
170
+ } | {
171
+ value?: undefined;
172
+ error: IValidationError;
173
+ };
174
+ type IModelValidationResult<V> = {
175
+ value: V;
176
+ error?: undefined;
177
+ } | {
178
+ value?: undefined;
179
+ error: IModelValidationError;
180
+ };
181
+ type IArrayValidationResult<V> = {
182
+ value: V[];
183
+ error?: undefined;
184
+ } | {
185
+ value?: undefined;
186
+ error: IArrayValidationError;
187
+ };
188
+ type IValidator<V = any, O = any> = (value: V, options: O) => IValidationResult<V>;
189
+ interface IPropertyValidatorInfo {
190
+ propertyName: string;
191
+ validator: IValidator;
192
+ validatorOptions?: any;
193
+ }
194
+ type IModelValidatorsInfo<V> = {
195
+ modelConstructor: IConstructor<V>;
196
+ properties: {
197
+ [prop: string]: {
198
+ isOptional?: boolean;
199
+ validators?: IPropertyValidatorInfo[];
200
+ } | undefined;
201
+ };
202
+ };
89
203
 
90
- interface IChatMessage {
91
- text?: string;
92
- documents?: IChatDocument[];
93
- images?: IChatImage[];
94
- senderName: string;
204
+ interface IValidateArrayOptions {
205
+ minLength?: number;
206
+ maxLength?: number;
95
207
  }
96
- interface IConnectionChatMessage extends IChatMessage {
97
- chatConnection: IChatConnection;
98
- userConnection: IUserConnection;
99
- userId?: string;
208
+ interface IValidateArrayOptionsWithItemsValidators extends IValidateArrayOptions {
209
+ itemsValidator?: {
210
+ validator: IValidator;
211
+ options: any;
212
+ }[];
100
213
  }
214
+ declare function validateArray(value: any, options?: IValidateArrayOptionsWithItemsValidators): IArrayValidationResult<any>;
101
215
 
102
- interface IChatFunctionCall {
103
- id: string;
104
- name: string;
105
- arguments?: string;
106
- result: string;
216
+ declare function isArray(options?: IValidateArrayOptions): (target: object, propertyKey: string | symbol) => void;
217
+
218
+ interface IValidatorMetadata {
219
+ modelConstructor: IConstructor<any>;
220
+ propertyName: string;
221
+ validator: IValidator;
222
+ validatorOptions?: any;
107
223
  }
108
224
 
109
- type ISystemMessageItem = {
110
- type: 'BOT_MESSAGE';
111
- content: IChatMessage;
112
- };
113
- type IReceivedMessageItem = {
114
- type: 'CONNECTION_MESSAGE';
115
- content: IConnectionChatMessage;
116
- };
117
- type ISystemFunctionCallItem = {
118
- type: 'FUNCTION_CALL';
119
- content: IChatFunctionCall;
120
- };
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;
225
+ declare class ValidationMetadataStore {
226
+ private validators;
227
+ saveValidatorMetadata(validatorMetadata: IValidatorMetadata): void;
228
+ getModelValidatorsInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
229
+ private getConstructorPropertiesValidatorsInfo;
130
230
  }
131
231
 
132
- interface IChatMemory {
133
- findLastItems(count: number): Promise<ChatItem[]>;
134
- create(item: ChatItem): Promise<void>;
232
+ declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
233
+
234
+ declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
235
+
236
+ declare function modelInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
237
+
238
+ interface ICommandConfig {
239
+ name?: string;
135
240
  }
136
- declare class ChatMemory implements IChatMemory {
137
- findLastItems(count: number): Promise<ChatItem[]>;
138
- create(item: ChatItem): Promise<void>;
241
+ declare function command(config?: ICommandConfig): (target: IConstructor<any>) => void;
242
+
243
+ declare class Command<T extends IStorableData> extends Storable<T> {
244
+ getData(): T;
139
245
  }
140
246
 
141
- interface IChatRepository {
142
- create(chat: Chat): Promise<void>;
143
- findByConnection(query: IChatConnection): Promise<Chat | null>;
144
- findMemory(chatId: string): Promise<IChatMemory | null>;
247
+ interface ICommandHandler<C extends Command<any>> {
248
+ handle(command: C): void | Promise<void>;
145
249
  }
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>;
250
+
251
+ interface ICommandHandlerConfig<C extends Command<any>> {
252
+ command: IConstructor<C>;
253
+ }
254
+ declare function commandHandler<C extends Command<any>>(config: ICommandHandlerConfig<C>): (target: IConstructor<ICommandHandler<C>>) => void;
255
+
256
+ declare class CommandMetadataStore {
257
+ private handlersMap;
258
+ private handlersInverseMap;
259
+ private commandsMap;
260
+ private commandsInverseMap;
261
+ registerCommand(command: IConstructor<Command<any>>, commandName: string): void;
262
+ registerHandler(command: IConstructor<Command<any>>, handlerConstructor: IConstructor<ICommandHandler<any>>): void;
263
+ getHandlerForCommandName(commandName: string): IConstructor<ICommandHandler<any>> | null;
264
+ getCommandNameForHandler(handlerConstructor: IConstructor<ICommandHandler<any>>): string | null;
265
+ getCommandName(command: IConstructor<Command<any>>): string | null;
266
+ getCommandForCommandName(commandName: string): IConstructor<Command<any>> | null;
150
267
  }
151
268
 
152
- interface IUserRepository {
153
- create(chat: User): Promise<void>;
154
- update(chat: User): Promise<void>;
155
- findByConnection(query: IUserConnection): Promise<User | null>;
269
+ interface IJobData extends IEntityData {
270
+ commandName: string;
271
+ commandData: any;
272
+ startedAt?: number;
273
+ successAt?: number;
274
+ failedAt?: number;
275
+ error?: {
276
+ message: string;
277
+ stack?: string;
278
+ info?: any;
279
+ };
156
280
  }
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>;
281
+ declare class Job extends Entity<IJobData> {
282
+ get commandName(): string;
283
+ setAsStarted(): void;
284
+ setAsSuccess(): void;
285
+ setAsFailed(error: Error): void;
161
286
  }
162
287
 
163
- interface IMessageContext {
164
- message: IConnectionChatMessage;
165
- chat: Chat;
166
- user: User | null;
288
+ interface IJobRepository extends ICrudRepository<Job> {
167
289
  }
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);
290
+
291
+ declare class JobRepository implements IJobRepository {
292
+ find(id: string): Promise<Job | null>;
293
+ findOrThrow(id: string): Promise<Job>;
294
+ findByIds(ids: string[]): Promise<Job[]>;
295
+ findAll(id: string): Promise<Job[]>;
296
+ create(item: Job): Promise<void>;
297
+ update(item: Job): Promise<void>;
298
+ discard(item: Job): Promise<void>;
173
299
  }
174
300
 
175
- interface IReversibleMapper<T1, T2> {
176
- map(input: T1): T2;
177
- rev(input: T2): T1;
301
+ interface IJobEvent extends IStorableData {
302
+ jobId: string;
303
+ type: 'created';
304
+ }
305
+ type IJobEventListener = (event: IJobEvent) => void | Promise<void>;
306
+ declare class JobsEventsHub {
307
+ private jobsEventsListener;
308
+ notifyJobCreated(job: Job): void;
309
+ listenJobsEvents(listener: IJobEventListener): void;
178
310
  }
179
311
 
180
- type IConstructor<T> = new (...args: any[]) => T;
312
+ declare class Async {
313
+ private jobRepository;
314
+ private handlerContainer;
315
+ private jobsEventsHub;
316
+ constructor(jobRepository: JobRepository, handlerContainer: CommandMetadataStore, jobsEventsHub: JobsEventsHub);
317
+ run<T extends IStorableData>(command: Command<T>): Promise<Job>;
318
+ }
319
+
320
+ declare class JobRunner {
321
+ private jobRepository;
322
+ private handlerContainer;
323
+ constructor(jobRepository: JobRepository, handlerContainer: CommandMetadataStore);
324
+ run(job: Job): Promise<void>;
325
+ }
326
+
327
+ declare function runAsyncCommandHandlers(handlers: IConstructor<ICommandHandler<any>>[]): void;
328
+
329
+ interface IChatConnection extends IStorableData {
330
+ channelName: string;
331
+ id: string;
332
+ }
333
+
334
+ type IChatType = 'PRIVATE' | 'GROUP';
335
+
336
+ interface IChatData extends IEntityData {
337
+ type: IChatType;
338
+ connections: IChatConnection[];
339
+ }
340
+ declare class Chat extends Entity<IChatData> {
341
+ constructor(data: IChatData);
342
+ isPrivate(): boolean;
343
+ isGroup(): boolean;
344
+ hasConnection(connection: IChatConnection): boolean;
345
+ private validatePrivateChat;
346
+ private validateGroupChat;
347
+ validate(): void;
348
+ }
349
+
350
+ interface IMindsetFunctionConfig {
351
+ description: string;
352
+ }
353
+
354
+ declare function mindsetFunction(config: IMindsetFunctionConfig): (target: object, propertyKey: string | symbol) => void;
355
+
356
+ declare const MINDSET_FUNCTION_DECORATION_FUNCTION = "mindsetFunction";
357
+
358
+ interface IMindsetFunctionDecoration {
359
+ decorationName: string;
360
+ functionName: string;
361
+ constructor: Function;
362
+ paramsTypes: Function[];
363
+ decorationConfig: any;
364
+ }
181
365
 
182
366
  interface IMindsetIdentity {
183
367
  name: string;
@@ -226,8 +410,6 @@ interface IMindsetModuleDecoration {
226
410
  decorationConfig: any;
227
411
  }
228
412
 
229
- declare function isOptional(): PropertyDecorator;
230
-
231
413
  interface IParamConfig {
232
414
  name?: string;
233
415
  optional?: boolean;
@@ -285,26 +467,17 @@ declare class MindsetMetadataStore {
285
467
  getMindsetMetadata(ctor: Function): IMindsetMetadata;
286
468
  }
287
469
 
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;
470
+ interface IMindsetToolParameter {
471
+ type: string;
472
+ name: string;
473
+ description: string;
474
+ }
475
+ interface IMindsetTool {
476
+ language: string;
477
+ name: string;
478
+ description: string;
479
+ parameters: IMindsetToolParameter[];
302
480
  }
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
481
 
309
482
  declare class MindsetOperator implements IMindset {
310
483
  private mindset;
@@ -314,45 +487,82 @@ declare class MindsetOperator implements IMindset {
314
487
  identity(): Promise<IMindsetIdentity>;
315
488
  skills(): Promise<string>;
316
489
  limits(): Promise<string>;
490
+ systemPrompt(): Promise<string>;
491
+ tools(): IMindsetTool[];
492
+ protected tool(fn: IMindsetFunctionMetadata, module: IMindsetModuleMetadata): IMindsetTool;
493
+ protected toolParameter(param: IMindsetFunctionParamMetadata): IMindsetToolParameter;
317
494
  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
495
  }
331
496
 
332
- declare function chatBot(mindset: IConstructor<IMindset>): (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
497
+ interface IChatMessage extends IStorableData {
498
+ senderId?: string;
499
+ senderName?: string;
500
+ text?: string;
501
+ }
333
502
 
334
- interface IChatBotMetadata {
335
- constructor: IConstructor<any>;
336
- mindsetConstructor: IConstructor<IMindset>;
337
- injectionToken: string;
503
+ interface IFunctionCall extends IStorableData {
504
+ id: string;
505
+ name: string;
506
+ arguments?: string;
507
+ result?: string;
338
508
  }
339
509
 
340
- declare class ChatBotMetadataStore {
341
- private chatBots;
342
- saveChatBotMetadata(chatBot: IChatBotMetadata): void;
343
- getChatBotsMetadata(): IChatBotMetadata[];
510
+ declare const chatItemTypeOptions: readonly ["botMessage", "humanMessage", "functionCall"];
511
+ type IBotMessageItem = {
512
+ type: 'botMessage';
513
+ botMessage: IChatMessage;
514
+ };
515
+ type IHumanMessageItem = {
516
+ type: 'humanMessage';
517
+ humanMessage: IChatMessage;
518
+ };
519
+ type IFunctionCallItem = {
520
+ type: 'functionCall';
521
+ functionCall: IFunctionCall;
522
+ };
523
+ type IChatItem = IBotMessageItem | IHumanMessageItem | IFunctionCallItem;
524
+ type IChatItemType = (typeof chatItemTypeOptions)[number];
525
+
526
+ interface ILanguageModelUsage {
527
+ inputTokens: number;
528
+ outputTokens: number;
529
+ }
530
+
531
+ interface IChatAdapterNextItemReq {
532
+ model: string;
533
+ systemPrompt: string;
534
+ tools: IMindsetTool[];
535
+ prevItems: IChatItem[];
536
+ }
537
+ interface IChatAdapterNextItemRes {
538
+ chatItem: IChatItem;
539
+ usage: ILanguageModelUsage;
540
+ }
541
+ interface IChatAdapter {
542
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
344
543
  }
345
544
 
346
- interface IChatBotAdapter {
347
- generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
545
+ declare class ChatAdapter implements IChatAdapter {
546
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
547
+ }
548
+
549
+ type IChatItemData = IEntityData & IChatItem;
550
+ declare class ChatItem extends Entity<IChatItemData> {
551
+ get type(): "botMessage" | "humanMessage" | "functionCall";
552
+ get botMessage(): IChatMessage;
553
+ get functionCall(): IFunctionCall;
554
+ setFunctionResult(result: string): void;
555
+ getData(): IChatItemData;
556
+ }
557
+
558
+ interface IChatMemory {
559
+ findLastItems(count: number): Promise<ChatItem[]>;
560
+ create(item: ChatItem): Promise<void>;
348
561
  }
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>;
562
+
563
+ declare class ChatMemory implements IChatMemory {
564
+ findLastItems(count: number): Promise<ChatItem[]>;
565
+ create(item: ChatItem): Promise<void>;
356
566
  }
357
567
 
358
568
  interface IChatBot {
@@ -362,50 +572,36 @@ interface IChatBot {
362
572
  declare class ChatBot implements IChatBot {
363
573
  private memory;
364
574
  private adapter;
365
- constructor(memory: ChatMemory, adapter: ChatBotAdapter);
366
- sendMessage(message: IConnectionChatMessage, callback: (message: IChatMessage) => void): Promise<void>;
575
+ private mindset;
576
+ constructor(memory: ChatMemory, adapter: ChatAdapter, mindset: MindsetOperator);
577
+ sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): Promise<void>;
367
578
  protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
368
579
  }
369
580
 
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;
581
+ interface IChatRepository {
582
+ create(chat: Chat): Promise<void>;
583
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
584
+ findMemory(chatId: string): Promise<IChatMemory | null>;
377
585
  }
378
586
 
379
- declare class OpenaiChatBotAdapter extends ChatBotAdapter {
380
- private openai;
381
- private model;
382
- constructor(mindset: MindsetOperator);
383
- generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
384
- private mapChatItems;
587
+ declare class ChatRepository implements IChatRepository {
588
+ create(chat: Chat): Promise<void>;
589
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
590
+ findMemory(chatId: string): Promise<IChatMemory | null>;
385
591
  }
386
592
 
387
- declare function cmd(): (target: object, propertyKey: string | symbol) => void;
388
-
389
- declare class ChatResolver {
390
- private chatRepository;
391
- constructor(chatRepository: ChatRepository);
392
- resolve(connection: IChatConnection): Promise<Chat>;
393
- private resolveGroupChat;
394
- private resolvePrivateChat;
395
- }
593
+ declare function chatBot(mindset: IConstructor<IMindset>): (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
396
594
 
397
- interface IReceivedMessage extends IMessageContext {
398
- reply: (message: IChatMessage) => void;
399
- }
400
- interface IChatChannel {
401
- listen(callback: (message: IReceivedMessage) => void): void;
402
- connect(): void;
595
+ interface IChatBotMetadata {
596
+ constructor: IConstructor<any>;
597
+ mindsetConstructor: IConstructor<IMindset>;
598
+ injectionToken: string;
403
599
  }
404
600
 
405
- declare class UserResolver {
406
- private userRepository;
407
- constructor(userRepository: UserRepository);
408
- resolve(connection: IUserConnection): Promise<User | null>;
601
+ declare class ChatBotMetadataStore {
602
+ private chatBots;
603
+ saveChatBotMetadata(chatBot: IChatBotMetadata): void;
604
+ getChatBotsMetadata(): IChatBotMetadata[];
409
605
  }
410
606
 
411
607
  interface IchatControllerConfig {
@@ -417,6 +613,20 @@ interface IChatControllerMetadata {
417
613
  controllerConstructor: Function;
418
614
  }
419
615
 
616
+ interface IReceivedMessage {
617
+ message: IChatMessage;
618
+ reply: (message: IChatMessage) => void;
619
+ }
620
+
621
+ interface IChannelMessage extends IReceivedMessage {
622
+ chatConnection: IChatConnection;
623
+ }
624
+
625
+ interface IChatChannel {
626
+ listen(callback: (received: IChannelMessage) => void): void;
627
+ connect(): void;
628
+ }
629
+
420
630
  interface IChannelMetadata {
421
631
  controllerConstructor: IConstructor<any>;
422
632
  functionName: string;
@@ -435,34 +645,280 @@ declare class ControllerMetadataStore {
435
645
  } | null;
436
646
  }
437
647
 
648
+ declare class ChatResolver {
649
+ private chatRepository;
650
+ constructor(chatRepository: ChatRepository);
651
+ resolve(connection: IChatConnection): Promise<Chat>;
652
+ private resolveGroupChat;
653
+ private resolvePrivateChat;
654
+ }
655
+
656
+ interface IMessageContext extends IReceivedMessage {
657
+ chat: Chat;
658
+ }
659
+
660
+ declare function runChatControllers(controllers: IConstructor<any>[]): void;
661
+
662
+ declare class HttpServerProvider {
663
+ server: Server | null;
664
+ private listening;
665
+ private logger;
666
+ getHttpServer(): Server;
667
+ listen(): void;
668
+ }
669
+
670
+ declare class ExpressProvider {
671
+ private httpServerProvider;
672
+ private expressApp;
673
+ private logger;
674
+ constructor(httpServerProvider: HttpServerProvider);
675
+ getExpress(): Express;
676
+ listen(): void;
677
+ private createExpress;
678
+ }
679
+
680
+ interface IEndPointConfig {
681
+ path?: string;
682
+ disableJsonParser?: boolean;
683
+ disableUrlEncodedParser?: boolean;
684
+ }
685
+
686
+ declare function get(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
687
+
688
+ interface IMiddleware {
689
+ handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
690
+ }
691
+
692
+ declare function middleware(middlewareConstructor: IConstructor<IMiddleware>): (target: object, propertyKey: string | symbol) => void;
693
+
694
+ declare function post(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
695
+
696
+ interface IRestControllerConfig {
697
+ path: string;
698
+ }
699
+
700
+ declare function restController(config: string | IRestControllerConfig): (target: IConstructor<any>) => void;
701
+
702
+ interface IEndPointMetadata {
703
+ method: 'get' | 'post';
704
+ config?: IEndPointConfig;
705
+ controllerConstructor: IConstructor<any>;
706
+ functionName: string;
707
+ paramsTypes: any[];
708
+ }
709
+
710
+ interface IMiddlewareMetadata {
711
+ controllerConstructor: IConstructor<any>;
712
+ functionName: string;
713
+ middlewareConstructor: IConstructor<IMiddleware>;
714
+ }
715
+
716
+ interface IRestControllerMetadata {
717
+ controllerConstructor: IConstructor<any>;
718
+ path: string;
719
+ }
720
+
721
+ declare class RestControllerMetadataStore {
722
+ private endPoints;
723
+ private middlewares;
724
+ private restControllers;
725
+ saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
726
+ saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
727
+ saveMiddlewareMetadata(middlewareMetadata: IMiddlewareMetadata): void;
728
+ getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
729
+ middlewares: IMiddlewareMetadata[];
730
+ controller: IRestControllerMetadata;
731
+ method: "get" | "post";
732
+ config?: IEndPointConfig;
733
+ controllerConstructor: IConstructor<any>;
734
+ functionName: string;
735
+ paramsTypes: any[];
736
+ }[];
737
+ }
738
+
739
+ declare function runRestControllers(controllers: IConstructor<any>[]): void;
740
+
741
+ declare const EXPRESS_REQ = "EXPRESS_REQ";
742
+ declare const EXPRESS_RES = "EXPRESS_RES";
743
+
744
+ declare class SocketServerProvider {
745
+ private httpServerProvider;
746
+ private socketServer;
747
+ private logger;
748
+ constructor(httpServerProvider: HttpServerProvider);
749
+ getSocketServer(): Server$1;
750
+ listen(): void;
751
+ private createSocketServer;
752
+ }
753
+
754
+ interface IMoneyData extends IStorableData {
755
+ amount: string;
756
+ currency: string;
757
+ }
758
+ declare class Money extends Storable<IMoneyData> {
759
+ getData(): {
760
+ [key: string]: IPrimitive | IStorableData | IPrimitive[] | IStorableData[];
761
+ amount: string;
762
+ currency: string;
763
+ };
764
+ get amount(): big_js.Big;
765
+ get currency(): string;
766
+ plus(money: Money): Money;
767
+ minus(money: Money): Money;
768
+ times(value: bigint | string): Money;
769
+ div(value: bigint | string): Money;
770
+ negative(): Money;
771
+ isGretterThan(money: Money): boolean;
772
+ protected validateEqualCurrencies(left: string, right: string): void;
773
+ static zero(currency: string): Money;
774
+ }
775
+
776
+ type IPgRepositoryConfig<P extends Entity<IEntityData>> = {
777
+ schema?: string;
778
+ table: string;
779
+ constructor: IConstructor<P>;
780
+ add?: {
781
+ columns: {
782
+ [column: string]: {
783
+ type: string;
784
+ value: (item: P) => boolean | number | string | null | Date;
785
+ };
786
+ };
787
+ };
788
+ };
789
+
790
+ declare class PgRepositoryBase<P extends Entity<IEntityData>> {
791
+ protected pool: Pool;
792
+ protected config: IPgRepositoryConfig<any>;
793
+ private tableIsCreated;
794
+ protected schema: string;
795
+ protected table: string;
796
+ protected columnsList: string[];
797
+ protected columnsAndTypes: string;
798
+ protected columns: string;
799
+ protected vars: string;
800
+ protected updates: string;
801
+ addColumns: {
802
+ [columns: string]: {
803
+ type: string;
804
+ value: (item: P) => number | boolean | string | null | Date;
805
+ };
806
+ };
807
+ constructor(pool: Pool, config: IPgRepositoryConfig<any>);
808
+ protected values(item: P): (string | number | boolean | Date | null)[];
809
+ protected exec(sql: string, values: any[]): Promise<void>;
810
+ protected query(sql: string, values: any[]): Promise<any[]>;
811
+ protected connect(): Promise<Pool>;
812
+ protected ensureTable(): Promise<void>;
813
+ protected ensureColumns(): Promise<void>;
814
+ }
815
+
816
+ declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgRepositoryBase<P> implements ICrudRepository<P> {
817
+ protected readonly config: IPgRepositoryConfig<P>;
818
+ constructor(pool: Pool, config: IPgRepositoryConfig<P>);
819
+ find(id: string): Promise<P | null>;
820
+ findByIds(ids: string[]): Promise<P[]>;
821
+ findOrThrow(id: string): Promise<P>;
822
+ findAll(): Promise<P[]>;
823
+ create(item: P): Promise<void>;
824
+ update(item: P): Promise<void>;
825
+ discard(item: P): Promise<void>;
826
+ }
827
+
828
+ declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepository {
829
+ constructor(pool: Pool);
830
+ }
831
+
832
+ declare class AnthropicChatAdapter implements IChatAdapter {
833
+ private env;
834
+ private anthropic;
835
+ private logger;
836
+ constructor(env: Env);
837
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
838
+ private mapChatItems;
839
+ private mapHumanMessage;
840
+ private mapBotMessage;
841
+ private mapFunctionCall;
842
+ private mapTool;
843
+ private mapResponse;
844
+ }
845
+
846
+ declare class DeepSeekChatAdapter implements IChatAdapter {
847
+ private deepSeek;
848
+ private logger;
849
+ constructor();
850
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
851
+ private mapChatItems;
852
+ private mapHumanMessage;
853
+ private mapBotMessage;
854
+ private mapFunctionCall;
855
+ private mapTool;
856
+ private mapResponse;
857
+ }
858
+
859
+ declare class GoogleChatAdapter implements IChatAdapter {
860
+ private env;
861
+ private genai;
862
+ private logger;
863
+ constructor(env: Env);
864
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
865
+ private buildContents;
866
+ private validateMessageContent;
867
+ private mapFunctionCall;
868
+ private mapTool;
869
+ private mapResponse;
870
+ private validateResponse;
871
+ }
872
+
873
+ declare class OpenaiChatAdapter implements IChatAdapter {
874
+ private openai;
875
+ private logger;
876
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
877
+ private mapChatItems;
878
+ private mapConectionMessage;
879
+ private mapBotMessage;
880
+ private mapFunctionCall;
881
+ private mapTool;
882
+ private mapResponse;
883
+ }
884
+
885
+ declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
886
+ constructor(pool: Pool);
887
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
888
+ findMemory(chatId: string): Promise<IChatMemory | null>;
889
+ }
890
+
891
+ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMemory {
892
+ private chatId;
893
+ constructor(pool: Pool, chatId: string);
894
+ findLastItems(count: number): Promise<ChatItem[]>;
895
+ }
896
+
897
+ declare class RamChatMemory implements IChatMemory {
898
+ private memory;
899
+ findLastItems(count: number): Promise<ChatItem[]>;
900
+ create(item: ChatItem): Promise<void>;
901
+ clearMemory(): Promise<void>;
902
+ }
903
+
904
+ declare class RamChatRepository implements IChatRepository {
905
+ private items;
906
+ private memories;
907
+ create(chat: Chat): Promise<void>;
908
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
909
+ findMemory(chatId: string): Promise<IChatMemory | null>;
910
+ private getMemory;
911
+ }
912
+
913
+ declare function cmd(): (target: object, propertyKey: string | symbol) => void;
914
+
438
915
  declare class CmdChannel implements IChatChannel {
439
- private chatResolver;
440
- private userResolver;
441
916
  private rl;
442
917
  private callBack;
443
- constructor(chatResolver: ChatResolver, userResolver: UserResolver);
444
- listen(callback: (message: IReceivedMessage) => void): void;
918
+ listen(callback: (message: IChannelMessage) => void): void;
445
919
  connect(): void;
446
920
  }
447
921
 
448
- declare class HttpServerProvider {
449
- server: Server | null;
450
- private listening;
451
- private logger;
452
- getHttpServer(): Server;
453
- listen(): void;
454
- }
455
-
456
- declare class ExpressProvider {
457
- private httpServerProvider;
458
- private expressApp;
459
- private logger;
460
- constructor(httpServerProvider: HttpServerProvider);
461
- getExpress(): Express;
462
- listen(): void;
463
- private createExpress;
464
- }
465
-
466
922
  interface ISocketChannelConfig {
467
923
  channel: string;
468
924
  }
@@ -474,16 +930,6 @@ declare class SocketChannelConfig implements ISocketChannelConfig {
474
930
 
475
931
  declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
476
932
 
477
- declare class SocketServerProvider {
478
- private httpServerProvider;
479
- private socketServer;
480
- private logger;
481
- constructor(httpServerProvider: HttpServerProvider);
482
- getSocketServer(): Server$1;
483
- listen(): void;
484
- private createSocketServer;
485
- }
486
-
487
933
  interface ISocketChannelReceivedMessage {
488
934
  chatId: string;
489
935
  userId: string;
@@ -493,12 +939,10 @@ interface ISocketChannelReceivedMessage {
493
939
  declare class SocketChannel implements IChatChannel {
494
940
  private config;
495
941
  private socketServerProvider;
496
- private chatResolver;
497
- private userResolver;
498
942
  private callBack;
499
943
  private server;
500
- constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider, chatResolver: ChatResolver, userResolver: UserResolver);
501
- listen(callback: (message: IReceivedMessage) => void): void;
944
+ constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider);
945
+ listen(callback: (message: IChannelMessage) => void): void;
502
946
  connect(): void;
503
947
  }
504
948
 
@@ -514,11 +958,9 @@ declare function telegram(config: ITelegramChannelConfig): (target: object, prop
514
958
 
515
959
  declare class TelegramChannel implements IChatChannel {
516
960
  private config;
517
- private chatResolver;
518
- private userResolver;
519
961
  private bot;
520
- constructor(config: TelegramChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver);
521
- listen(callback: (message: IReceivedMessage) => void): void;
962
+ constructor(config: TelegramChannelConfig);
963
+ listen(callback: (message: IChannelMessage) => void): void;
522
964
  connect(): void;
523
965
  }
524
966
 
@@ -533,9 +975,49 @@ declare class WhatsappChannelConfig implements IWhatsappChannelConfig {
533
975
 
534
976
  declare function whatsapp(config: IWhatsappChannelConfig): (target: object, propertyKey: string | symbol) => void;
535
977
 
978
+ interface IWhatsAppBusinessNumber extends IStorableData {
979
+ id: string;
980
+ number: string;
981
+ }
982
+ interface IWhatsAppBusinessAccount extends IStorableData {
983
+ id: string;
984
+ }
985
+ interface IWhatsAppData extends IEntityData {
986
+ slug: string;
987
+ verifyToken: string;
988
+ appSecret: string;
989
+ accessToken: string;
990
+ businessAccount: IWhatsAppBusinessAccount;
991
+ businessNumbers: IWhatsAppBusinessNumber[];
992
+ }
993
+ declare class WhatsApp extends Entity<IWhatsAppData> {
994
+ getVerifyToken(): string;
995
+ getSlug(): string;
996
+ getBusinessAccount(): IWhatsAppBusinessAccount;
997
+ getAppSecret(): string;
998
+ getBusinessNumbers(): IWhatsAppBusinessNumber[];
999
+ getAccessToken(): string;
1000
+ hasBusinessNumber(number: string): boolean;
1001
+ getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
1002
+ }
1003
+
1004
+ interface IWhatsAppRepository {
1005
+ findBySlug(slug: string): Promise<WhatsApp | null>;
1006
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1007
+ }
1008
+
1009
+ declare class EnvWhatsAppRepository implements IWhatsAppRepository {
1010
+ private env;
1011
+ constructor(env: Env);
1012
+ findBySlug(slug: string): Promise<WhatsApp | null>;
1013
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1014
+ private getFromEnvVars;
1015
+ }
1016
+
536
1017
  type IWhatsAppTemplateParameter = {
537
1018
  type: 'text';
538
1019
  text: string;
1020
+ parameter_name?: string;
539
1021
  } | {
540
1022
  type: 'currency';
541
1023
  currency: {
@@ -555,6 +1037,32 @@ interface IWhatsAppTemplateMessage {
555
1037
  parameters: IWhatsAppTemplateParameter[];
556
1038
  }
557
1039
 
1040
+ interface IWhatsAppTemplateResponse {
1041
+ data: IWhatsAppTemplate[];
1042
+ paging: IWhatsAppApiPaging;
1043
+ }
1044
+ interface IWhatsAppTemplate {
1045
+ name: string;
1046
+ parameter_format: 'POSITIONAL' | 'OTHER';
1047
+ components: IWhatsAppTemplateComponent[];
1048
+ language: string;
1049
+ status: string;
1050
+ category: string;
1051
+ id: string;
1052
+ }
1053
+ interface IWhatsAppTemplateComponent {
1054
+ type: 'HEADER' | 'BODY' | 'FOOTER';
1055
+ format?: 'TEXT';
1056
+ text?: string;
1057
+ }
1058
+ interface IWhatsAppApiPaging {
1059
+ cursors: IWhatsAppApiCursors;
1060
+ }
1061
+ interface IWhatsAppApiCursors {
1062
+ before: string;
1063
+ after: string;
1064
+ }
1065
+
558
1066
  interface IWhatsAppWebhookPayload {
559
1067
  object: 'whatsapp_business_account';
560
1068
  entry: IEntry[];
@@ -607,45 +1115,13 @@ interface IAudioMessage extends IBaseMessage {
607
1115
  };
608
1116
  }
609
1117
 
610
- interface IWhatsAppBusinessNumber {
611
- id: string;
612
- number: string;
613
- }
614
- interface IWhatsAppBusinessAccount {
615
- id: string;
616
- }
617
- interface IWhatsAppData extends IPersistentData {
618
- slug: string;
619
- verifyToken: string;
620
- appSecret: string;
621
- accessToken: string;
622
- businessAccount: IWhatsAppBusinessAccount;
623
- businessNumbers: IWhatsAppBusinessNumber[];
624
- }
625
- declare class WhatsApp extends Persistent<IWhatsAppData> {
626
- getVerifyToken(): string;
627
- getSlug(): string;
628
- getBusinessAccount(): IWhatsAppBusinessAccount;
629
- getAppSecret(): string;
630
- getBusinessNumbers(): IWhatsAppBusinessNumber[];
631
- getAccessToken(): string;
632
- hasBusinessNumber(number: string): boolean;
633
- getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
634
- }
635
-
636
- declare class Logger {
637
- private debuggers;
638
- constructor(name: string);
639
- trace(...args: any[]): void;
640
- debug(...args: any[]): void;
641
- info(...args: any[]): void;
642
- warn(...args: any[]): void;
643
- error(...args: any[]): void;
644
- fatal(...args: any[]): void;
645
- private log;
1118
+ declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
1119
+ constructor(pool: Pool);
1120
+ findBySlug(slug: string): Promise<WhatsApp | null>;
1121
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
646
1122
  }
647
1123
 
648
- type IWhatsAppMessageListener = (message: IConnectionChatMessage) => Promise<void>;
1124
+ type IWhatsAppMessageListener = (message: Omit<IChannelMessage, 'reply'>) => Promise<void>;
649
1125
  interface IListenWhatsAppMessageRequest {
650
1126
  to: string;
651
1127
  listener: IWhatsAppMessageListener;
@@ -660,31 +1136,11 @@ declare abstract class WhatsAppReceiver {
660
1136
  private emmitMessage;
661
1137
  }
662
1138
 
663
- interface IWhatsAppRepository {
664
- findBySlug(slug: string): Promise<WhatsApp | null>;
665
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
666
- }
667
-
668
1139
  declare class WhatsAppRepository implements IWhatsAppRepository {
669
1140
  findBySlug(slug: string): Promise<WhatsApp | null>;
670
1141
  findByBusinessNumber(number: string): Promise<WhatsApp | null>;
671
1142
  }
672
1143
 
673
- interface IWhatsAppTemplate {
674
- name: string;
675
- parameter_format: 'POSITIONAL' | 'OTHER';
676
- components: IWhatsAppTemplateComponent[];
677
- language: string;
678
- status: string;
679
- category: string;
680
- id: string;
681
- }
682
- interface IWhatsAppTemplateComponent {
683
- type: 'HEADER' | 'BODY' | 'FOOTER';
684
- format?: 'TEXT';
685
- text?: string;
686
- }
687
-
688
1144
  interface ISendWhatsAppRequest {
689
1145
  from: string;
690
1146
  to: string;
@@ -704,31 +1160,30 @@ interface IGetWhatsAppTemplateRequest {
704
1160
  interface IWhatsAppSenderOptions {
705
1161
  writeChatMemory?: boolean;
706
1162
  }
707
- declare abstract class WhatsAppSender {
1163
+ declare class WhatsAppSender {
708
1164
  protected logger: Logger;
709
1165
  protected chatRepository: ChatRepository;
710
1166
  protected chatResolver: ChatResolver;
711
1167
  protected whatsAppRepository: WhatsAppRepository;
712
1168
  constructor(logger: Logger, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
713
- protected abstract handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
714
- protected abstract handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
715
- protected abstract handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
1169
+ protected handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
1170
+ protected handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
1171
+ protected handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
716
1172
  sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
717
1173
  sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
718
1174
  getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
719
1175
  protected resolveTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
720
1176
  protected writePrivateChatMemory(message: IChatMessage, to: string): Promise<void>;
1177
+ private replaceTemplateParameters;
721
1178
  }
722
1179
 
723
1180
  declare class WhatsAppChannel implements IChatChannel {
724
1181
  private config;
725
- private chatResolver;
726
- private userResolver;
727
1182
  private sender;
728
1183
  private receiver;
729
1184
  private logger;
730
- constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, sender: WhatsAppSender, receiver: WhatsAppReceiver);
731
- listen(callback: (message: IReceivedMessage) => void): void;
1185
+ constructor(config: WhatsappChannelConfig, sender: WhatsAppSender, receiver: WhatsAppReceiver);
1186
+ listen(callback: (message: IChannelMessage) => void): void;
732
1187
  connect(): void;
733
1188
  }
734
1189
 
@@ -757,216 +1212,126 @@ declare class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
757
1212
  connect(): Promise<void>;
758
1213
  }
759
1214
 
760
- declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
761
- private wabotDevConnection;
762
- constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
1215
+ declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
1216
+ constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
763
1217
  handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
764
1218
  handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
765
1219
  handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
766
1220
  }
767
1221
 
768
- declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
769
- constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
1222
+ declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
1223
+ private wabotDevConnection;
1224
+ constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
770
1225
  handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
771
1226
  handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
772
1227
  handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
773
1228
  }
774
1229
 
775
- interface ICrudRepository<T> {
776
- find(id: string): Promise<T | null>;
777
- findAll(id: string): Promise<T[]>;
778
- create(item: T): Promise<void>;
779
- update(item: T): Promise<void>;
780
- discard(item: T): Promise<void>;
1230
+ interface IHtmlModuleOptions {
1231
+ url: string;
1232
+ title: string;
781
1233
  }
782
-
783
- type IPgRepositoryConfig<P extends Persistent> = {
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
- };
1234
+ declare function HtmlModule(options: IHtmlModuleOptions): {
1235
+ new (): {};
795
1236
  };
796
1237
 
797
- declare class PgRepositoryBase<P extends Persistent> {
798
- protected pool: Pool;
799
- protected config: IPgRepositoryConfig<any>;
800
- private tableIsCreated;
801
- schema: string;
802
- table: string;
803
- columnsList: string[];
804
- columnsAndTypes: string;
805
- columns: string;
806
- vars: string;
807
- 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
- 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<any[]>;
818
- protected connect(): Promise<Pool>;
819
- protected ensureTable(): Promise<void>;
820
- protected ensureColumns(): Promise<void>;
821
- }
1238
+ declare function jwtGuard(): (target: object, propertyKey: string | symbol) => void;
822
1239
 
823
- declare class PgCrudRepository<P extends Persistent> 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
- findAll(): Promise<P[]>;
828
- create(item: P): Promise<void>;
829
- update(item: P): Promise<void>;
830
- discard(item: P): Promise<void>;
1240
+ declare class JwtTokenDto {
1241
+ token?: string;
1242
+ expiration?: Date;
831
1243
  }
832
1244
 
833
- declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
834
- constructor(pool: Pool);
835
- findBySlug(slug: string): Promise<WhatsApp | null>;
836
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1245
+ declare class JwtAccessAndRefreshTokenDto {
1246
+ access?: JwtTokenDto;
1247
+ refresh?: JwtTokenDto;
837
1248
  }
838
1249
 
839
- type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
840
- declare class WabotEnv {
841
- private envType;
842
- constructor();
843
- isDevelopment(): boolean;
844
- isProduction(): boolean;
845
- requireString(varName: string): string;
1250
+ declare class JwtConfig {
1251
+ secretOrPublicKey: string;
1252
+ secretOrPrivateKey: string;
1253
+ algorithm: Algorithm;
1254
+ accessExpirationSeconds: number;
1255
+ refreshExpirationSeconds: number;
1256
+ constructor(env: Env);
846
1257
  }
847
1258
 
848
- declare class EnvWhatsAppRepository implements IWhatsAppRepository {
849
- private env;
850
- constructor(env: WabotEnv);
851
- findBySlug(slug: string): Promise<WhatsApp | null>;
852
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
853
- private getFromEnvVars;
1259
+ interface IJwtRefreshTokenData<A extends IStorableData> extends IEntityData {
1260
+ authInfo: A;
854
1261
  }
855
-
856
- declare function prepareChatContainer(container: DependencyContainer$1, context: IMessageContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer$1>;
857
-
858
- interface IrunChannelProps {
859
- channel: IConstructor<IChatChannel>;
860
- channelConfig?: object;
861
- mindset: IConstructor<IMindset>;
862
- chatRepository: IConstructor<IChatRepository>;
863
- chatBotAdapter: IConstructor<IChatBotAdapter>;
1262
+ declare class JwtRefreshToken<A extends IStorableData> extends Entity<IJwtRefreshTokenData<A>> {
1263
+ get authInfo(): A;
864
1264
  }
865
- declare function runChannel(props: IrunChannelProps): void;
866
1265
 
867
- interface IServerProvider<T, ST extends T> {
868
- replace: IConstructor<T>;
869
- with: IConstructor<ST>;
870
- singleton?: true;
871
- }
872
- interface IServerConfig {
873
- controllers: IConstructor<any>[];
874
- providers?: IServerProvider<unknown, unknown>[];
1266
+ declare class JwtSigner {
1267
+ private config;
1268
+ private mapper;
1269
+ constructor(config: JwtConfig, mapper: Mapper);
1270
+ signAccessToken<D extends IStorableData>(info: D | JwtRefreshToken<any>): Promise<JwtTokenDto>;
1271
+ signRefreshToken(refreshToken: JwtRefreshToken<any>): Promise<JwtTokenDto>;
1272
+ signAccessAndRefreshToken(refreshToken: JwtRefreshToken<any>): Promise<JwtAccessAndRefreshTokenDto>;
875
1273
  }
876
- declare function runServer(config: IServerConfig): void;
877
1274
 
878
- declare class SendOneTimePasswordRequest {
879
- fromEmail: string;
880
- toEmail: string;
1275
+ declare class JwtRefreshTokenRepository<D extends IStorableData> extends PgCrudRepository<JwtRefreshToken<D>> {
1276
+ constructor(pool: Pool);
881
1277
  }
882
1278
 
883
- declare class ValidateOneTimePasswordRequest {
884
- userEmail: string;
885
- otp: string;
1279
+ declare class Jwt {
1280
+ private auth;
1281
+ private jwtSigner;
1282
+ private jwtRefreshTokenRepository;
1283
+ constructor(auth: Auth<any>, jwtSigner: JwtSigner, jwtRefreshTokenRepository: JwtRefreshTokenRepository<any>);
1284
+ createToken(): Promise<JwtAccessAndRefreshTokenDto>;
886
1285
  }
887
1286
 
888
- interface ISendEmailRequest {
889
- from: string;
890
- to: string;
891
- subject: string;
892
- html: string;
893
- }
894
- interface IEmailService {
895
- sendEmail(request: ISendEmailRequest): Promise<void>;
896
- }
897
- declare class EmailService implements IEmailService {
898
- sendEmail(request: ISendEmailRequest): Promise<void>;
1287
+ declare class JwtGuardMiddleware implements IMiddleware {
1288
+ private config;
1289
+ private auth;
1290
+ constructor(config: JwtConfig, auth: Auth<any>);
1291
+ handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
899
1292
  }
900
1293
 
901
- interface IOtpService {
902
- generate(): Promise<string>;
903
- }
904
- declare class OtpService implements IOtpService {
905
- generate(): Promise<string>;
906
- }
1294
+ declare function isBoolean(): (target: object, propertyKey: string | symbol) => void;
907
1295
 
908
- declare class AuthenticationModule {
909
- private userRepository;
910
- private emailService;
911
- private otpService;
912
- private context;
913
- constructor(userRepository: UserRepository, emailService: EmailService, otpService: OtpService, context: MessageContext);
914
- sendOneTimePassword(request: SendOneTimePasswordRequest): Promise<string>;
915
- validateOneTimePassword(request: ValidateOneTimePasswordRequest): Promise<string>;
916
- protected generateOtpEmailHtml(otp: string, user: User): Promise<string>;
917
- protected generateOtpEmailSubject(): Promise<string>;
918
- }
1296
+ declare function validateIsBoolean(value: any): IValidationResult<boolean>;
919
1297
 
920
- declare class RegisterUserWithEmailRequest {
921
- email: string;
922
- shortName: string;
923
- }
1298
+ declare function isDate(): (target: object, propertyKey: string | symbol) => void;
924
1299
 
925
- declare class RegisterUserModule {
926
- private userRepository;
927
- private context;
928
- constructor(userRepository: UserRepository, context: MessageContext);
929
- registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
930
- }
1300
+ declare function validateIsDate(value: any): IValidationResult<Date>;
931
1301
 
932
- declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
933
- constructor(pool: Pool);
934
- findByConnection(query: IUserConnection): Promise<User | null>;
935
- }
1302
+ declare function isNotEmpty(): (target: object, propertyKey: string | symbol) => void;
936
1303
 
937
- declare class RamUserRepository implements IUserRepository {
938
- private items;
939
- create(chat: User): Promise<void>;
940
- findByConnection(query: IUserConnection): Promise<User | null>;
941
- update(chat: User): Promise<void>;
942
- }
1304
+ declare function validateIsNotEmpty(value: any): IValidationResult<any>;
943
1305
 
944
- declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
945
- constructor(pool: Pool);
946
- findByConnection(query: IChatConnection): Promise<Chat | null>;
947
- findMemory(chatId: string): Promise<IChatMemory | null>;
948
- }
1306
+ declare function isNumber(): (target: object, propertyKey: string | symbol) => void;
949
1307
 
950
- declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMemory {
951
- private chatId;
952
- constructor(pool: Pool, chatId: string);
953
- findLastItems(count: number): Promise<ChatItem[]>;
1308
+ declare function validateIsNumber(value: any): IValidationResult<number>;
1309
+
1310
+ declare function isPresent(): (target: object, propertyKey: string | symbol) => void;
1311
+
1312
+ declare function validateIsPresent(value: any): IValidationResult<any>;
1313
+
1314
+ declare function isString(): (target: object, propertyKey: string | symbol) => void;
1315
+
1316
+ declare function validateIsString(value: any): IValidationResult<string>;
1317
+
1318
+ declare function min(limit: any): (target: object, propertyKey: string | symbol) => void;
1319
+
1320
+ interface IValidateMinOptions {
1321
+ limit: any;
954
1322
  }
1323
+ declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
955
1324
 
956
- declare class RamChatMemory implements IChatMemory {
957
- private memory;
958
- findLastItems(count: number): Promise<ChatItem[]>;
959
- create(item: ChatItem): Promise<void>;
960
- clearMemory(): Promise<void>;
1325
+ declare function max(limit: any): (target: object, propertyKey: string | symbol) => void;
1326
+
1327
+ interface IValidateMaxOptions {
1328
+ limit: any;
961
1329
  }
1330
+ declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
962
1331
 
963
- declare class RamChatRepository implements IChatRepository {
964
- private items;
965
- private memories;
966
- create(chat: Chat): Promise<void>;
967
- findByConnection(query: IChatConnection): Promise<Chat | null>;
968
- findMemory(chatId: string): Promise<IChatMemory | null>;
969
- private getMemory;
1332
+ declare class MoneyDto {
1333
+ amount: string;
1334
+ currency: string;
970
1335
  }
971
1336
 
972
- 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 };
1337
+ export { AnthropicChatAdapter, 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 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 IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, 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 IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplate, type IWhatsAppTemplateComponent, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppTemplateResponse, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, 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, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, scoped, singleton, socket, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };