@wabot-dev/framework 0.1.0-beta.3 → 0.1.0-beta.31

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