@wabot-dev/framework 0.2.0-beta.1 → 0.2.0-beta.10

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 (34) hide show
  1. package/dist/src/addon/auth/api-key/@apiKeyHandshakeGuard.js +16 -0
  2. package/dist/src/addon/auth/api-key/ApiKey.js +3 -0
  3. package/dist/src/addon/auth/api-key/ApiKeyGuardMiddleware.js +1 -4
  4. package/dist/src/addon/auth/api-key/{ApiKeyConnectionGuardMiddleware.js → ApiKeyHandshakeGuardMiddleware.js} +5 -8
  5. package/dist/src/addon/auth/api-key/ApiKeyRepository.js +8 -5
  6. package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +10 -2
  7. package/dist/src/addon/auth/api-key/RemoteApiKeyRepository.js +13 -25
  8. package/dist/src/addon/auth/jwt/@jwtHandshakeGuard.js +16 -0
  9. package/dist/src/addon/auth/jwt/Jwt.js +7 -9
  10. package/dist/src/addon/auth/jwt/{JwtConnectionGuardMiddleware.js → JwtHandshakeGuardMiddleware.js} +4 -4
  11. package/dist/src/addon/auth/jwt/JwtRefreshToken.js +40 -35
  12. package/dist/src/addon/auth/jwt/JwtRefreshTokenRepository.js +6 -0
  13. package/dist/src/addon/auth/jwt/JwtSigner.js +1 -1
  14. package/dist/src/addon/auth/jwt/PgJwtRefreshTokenRepository.js +27 -0
  15. package/dist/src/addon/chat-controller/socket/@socket.js +1 -1
  16. package/dist/src/addon/chat-controller/socket/SocketChannel.js +64 -29
  17. package/dist/src/addon/chat-controller/socket/SocketChannelConfig.js +6 -4
  18. package/dist/src/core/auth/Auth.js +6 -0
  19. package/dist/src/core/mapper/Mapper.js +22 -6
  20. package/dist/src/core/validation/core/validateModel.js +37 -4
  21. package/dist/src/core/validation/{validate.js → validateAndTransform.js} +2 -2
  22. package/dist/src/feature/chat-controller/runChatControllers.js +3 -1
  23. package/dist/src/feature/rest-controller/runRestControllers.js +2 -2
  24. package/dist/src/feature/socket-controller/metadata/@handshakeMiddlewares.js +16 -0
  25. package/dist/src/feature/socket-controller/metadata/{@socketEvent.js → @onSocketEvent.js} +2 -2
  26. package/dist/src/feature/socket-controller/metadata/SocketControllerMetadataStore.js +12 -34
  27. package/dist/src/feature/socket-controller/runSocketControllers.js +96 -78
  28. package/dist/src/index.d.ts +109 -108
  29. package/dist/src/index.js +8 -9
  30. package/package.json +4 -5
  31. package/dist/src/addon/auth/api-key/@apiKeyConnectionGuard.js +0 -16
  32. package/dist/src/addon/auth/jwt/@jwtConnectionGuard.js +0 -16
  33. package/dist/src/feature/socket-controller/metadata/@connectionMiddleware.js +0 -16
  34. package/dist/src/feature/socket-controller/metadata/@socketConnection.js +0 -18
@@ -23,11 +23,13 @@ declare class Storable<D extends IStorableData> {
23
23
 
24
24
  declare class Auth<D extends IStorableData> {
25
25
  private authInfo;
26
+ private overrided;
26
27
  require(): D;
27
28
  assign(authInfo: D): void;
28
29
  override(authInfo: D): void;
29
30
  clear(): void;
30
31
  isAssigned(): boolean;
32
+ wasOverrided(): boolean;
31
33
  }
32
34
 
33
35
  interface IEntityData extends IStorableData {
@@ -129,47 +131,6 @@ declare class Logger {
129
131
  private log;
130
132
  }
131
133
 
132
- declare class Mapper {
133
- map<T>(data: any, ctor: IConstructor<T>): T;
134
- }
135
-
136
- interface PasswordHashOptions {
137
- password: string;
138
- saltLength?: number;
139
- keyLength?: number;
140
- }
141
- declare class Password {
142
- static hash(options: PasswordHashOptions): string;
143
- static isValid(req: {
144
- password: string;
145
- hash: string;
146
- }): boolean;
147
- static generate(length: number): string;
148
- }
149
-
150
- declare class Random {
151
- static integer(options: {
152
- min: number;
153
- max: number;
154
- }): number;
155
- static slug(name: string, options: {
156
- randomLength: number;
157
- }): string;
158
- static alphaNumeric(length: number): string;
159
- static alphaNumericLowerCase(length: number): string;
160
- static numberCode(length: number): string;
161
- }
162
-
163
- interface ICrudRepository<T> {
164
- find(id: string): Promise<T | null>;
165
- findOrThrow(id: string): Promise<T>;
166
- findByIds(ids: string[]): Promise<T[]>;
167
- findAll(id: string): Promise<T[]>;
168
- create(item: T): Promise<void>;
169
- update(item: T): Promise<void>;
170
- delete(item: T): Promise<void>;
171
- }
172
-
173
134
  declare function isModel(model: IConstructor<any>): (target: object, propertyKey: string | symbol) => void;
174
135
 
175
136
  declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
@@ -252,7 +213,10 @@ declare class ValidationMetadataStore {
252
213
 
253
214
  declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
254
215
 
255
- declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
216
+ type IValidateInputShape<T> = T extends Date ? Date : T extends Array<infer U> ? Array<IValidateInputShape<U>> : T extends object ? {
217
+ [K in keyof T]: IValidateInputShape<T[K]>;
218
+ } : T;
219
+ declare function validateAndTransform<V>(value: IValidateInputShape<V>, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
256
220
 
257
221
  declare function modelInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
258
222
 
@@ -301,6 +265,47 @@ interface IValidateMinOptions {
301
265
  }
302
266
  declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
303
267
 
268
+ declare class Mapper {
269
+ map<T>(data: IValidateInputShape<T>, ctor: IConstructor<T>): T;
270
+ }
271
+
272
+ interface PasswordHashOptions {
273
+ password: string;
274
+ saltLength?: number;
275
+ keyLength?: number;
276
+ }
277
+ declare class Password {
278
+ static hash(options: PasswordHashOptions): string;
279
+ static isValid(req: {
280
+ password: string;
281
+ hash: string;
282
+ }): boolean;
283
+ static generate(length: number): string;
284
+ }
285
+
286
+ declare class Random {
287
+ static integer(options: {
288
+ min: number;
289
+ max: number;
290
+ }): number;
291
+ static slug(name: string, options: {
292
+ randomLength: number;
293
+ }): string;
294
+ static alphaNumeric(length: number): string;
295
+ static alphaNumericLowerCase(length: number): string;
296
+ static numberCode(length: number): string;
297
+ }
298
+
299
+ interface ICrudRepository<T> {
300
+ find(id: string): Promise<T | null>;
301
+ findOrThrow(id: string): Promise<T>;
302
+ findByIds(ids: string[]): Promise<T[]>;
303
+ findAll(id: string): Promise<T[]>;
304
+ create(item: T): Promise<void>;
305
+ update(item: T): Promise<void>;
306
+ delete(item: T): Promise<void>;
307
+ }
308
+
304
309
  interface ICommandConfig {
305
310
  name?: string;
306
311
  }
@@ -921,17 +926,11 @@ declare class SocketServerProvider {
921
926
  private createSocketServer;
922
927
  }
923
928
 
924
- interface IConnectionMiddleware {
929
+ interface IHandshakeMiddleware {
925
930
  handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
926
931
  }
927
932
 
928
- declare function connectionMiddleware(middlewareConstructor: IConstructor<IConnectionMiddleware>): (target: object, propertyKey: string | symbol) => void;
929
-
930
- interface ISocketConnectionConfig {
931
- namespace: string;
932
- }
933
-
934
- declare function socketConnection(config?: string | ISocketConnectionConfig): (target: object, propertyKey: string | symbol) => void;
933
+ declare function handshakeMiddlewares(middlewares: IConstructor<IHandshakeMiddleware>[]): (target: IConstructor<any>) => void;
935
934
 
936
935
  interface ISocketControllerConfig {
937
936
  namespace: string;
@@ -940,23 +939,14 @@ interface ISocketControllerConfig {
940
939
  declare function socketController(config?: string | ISocketControllerConfig): (target: IConstructor<any>) => void;
941
940
 
942
941
  interface ISocketEventConfig {
943
- namespace?: string;
944
942
  event: string;
945
943
  }
946
944
 
947
- declare function socketEvent(config: string | ISocketEventConfig): (target: object, propertyKey: string | symbol) => void;
945
+ declare function onSocketEvent(config: string | ISocketEventConfig): (target: object, propertyKey: string | symbol) => void;
948
946
 
949
- interface IConnectionMiddlewareMetadata {
947
+ interface IHandshakeMiddlewareMetadata {
950
948
  controllerConstructor: IConstructor<any>;
951
- functionName: string;
952
- middlewareConstructor: IConstructor<IConnectionMiddleware>;
953
- }
954
-
955
- interface ISocketConnectionMetadata {
956
- config?: ISocketConnectionConfig;
957
- controllerConstructor: IConstructor<any>;
958
- functionName: string;
959
- paramsTypes: any[];
949
+ middlewareConstructor: IConstructor<IHandshakeMiddleware>;
960
950
  }
961
951
 
962
952
  interface ISocketControllerMetadata {
@@ -973,22 +963,16 @@ interface ISocketEventMetadata {
973
963
 
974
964
  declare class SocketControllerMetadataStore {
975
965
  private socketControllers;
976
- private socketConnections;
977
966
  private socketEvents;
978
- private connectionMiddlewares;
967
+ private handshakeMiddlewares;
979
968
  saveControllerMetadata(controllerMetadata: ISocketControllerMetadata): void;
980
- saveSocketConnectionMetadata(socketConnectionMetadata: ISocketConnectionMetadata): void;
981
969
  saveSocketEventMetadata(socketEventMetadata: ISocketEventMetadata): void;
982
- saveConnectionMiddlewareMetadata(middlewareMetadata: IConnectionMiddlewareMetadata): void;
983
- getControllerSockerConnectionsInfo(controllerConstructor: IConstructor<any>): {
984
- events: ISocketEventMetadata[];
985
- connectionMiddlewares: IConnectionMiddlewareMetadata[];
970
+ saveHandshakeMiddlewareMetadata(handshakeMetadata: IHandshakeMiddlewareMetadata): void;
971
+ getSocketControllerInfo(controllerConstructor: IConstructor<any>): {
986
972
  controller: ISocketControllerMetadata;
987
- config?: ISocketConnectionConfig;
988
- controllerConstructor: IConstructor<any>;
989
- functionName: string;
990
- paramsTypes: any[];
991
- }[];
973
+ events: Map<string, ISocketEventMetadata>;
974
+ handShakeMiddlewares: IHandshakeMiddlewareMetadata[] | undefined;
975
+ };
992
976
  }
993
977
 
994
978
  declare function runSocketControllers(controllers: IConstructor<any>[]): void;
@@ -997,7 +981,7 @@ declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepos
997
981
  constructor(pool: Pool);
998
982
  }
999
983
 
1000
- declare function apiKeyConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
984
+ declare function apiKeyHandshakeGuard(): (target: IConstructor<any>) => void;
1001
985
 
1002
986
  declare function apiKeyGuard(): (target: object, propertyKey: string | symbol) => void;
1003
987
 
@@ -1012,6 +996,7 @@ declare class ApiKey<A extends IStorableData> extends Entity<IApiKeyData<A>> {
1012
996
  static hashSecret(secret: string): string;
1013
997
  get authInfo(): A;
1014
998
  get metadata(): Record<string, string>;
999
+ get name(): string;
1015
1000
  setAuthInfo(authInfo: A): void;
1016
1001
  generateSecret(): string;
1017
1002
  isValidSecret(secret: string): boolean;
@@ -1024,7 +1009,8 @@ interface IApiKeyRepository<A extends IStorableData> {
1024
1009
  findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1025
1010
  create(item: ApiKey<A>): Promise<void>;
1026
1011
  generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1027
- findAuthInfoBySecret(secret: string): Promise<A | null>;
1012
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1013
+ findAndValidate(secret: string): Promise<A>;
1028
1014
  }
1029
1015
  interface IGenerateApiKeyReq<A extends IStorableData> extends IStorableData {
1030
1016
  name: string;
@@ -1037,15 +1023,16 @@ interface IGenerateApiKeyRes<A extends IStorableData> {
1037
1023
  }
1038
1024
 
1039
1025
  declare class ApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
1040
- findAuthInfoBySecret(secret: string): Promise<A>;
1041
- findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1042
1026
  find(id: string): Promise<ApiKey<A> | null>;
1043
1027
  findOrThrow(id: string): Promise<ApiKey<A>>;
1028
+ findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1044
1029
  create(item: ApiKey<A>): Promise<void>;
1045
1030
  generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1031
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1032
+ findAndValidate(secret: string): Promise<A>;
1046
1033
  }
1047
1034
 
1048
- declare class ApiKeyConnectionGuardMiddleware implements IConnectionMiddleware {
1035
+ declare class ApiKeyHandshakeGuardMiddleware implements IHandshakeMiddleware {
1049
1036
  private apiKeyRepository;
1050
1037
  private auth;
1051
1038
  constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
@@ -1061,55 +1048,58 @@ declare class ApiKeyGuardMiddleware implements IMiddleware {
1061
1048
 
1062
1049
  declare class PgApiKeyRepository<A extends IStorableData> extends PgCrudRepository<ApiKey<A>> implements IApiKeyRepository<A> {
1063
1050
  constructor(pool: Pool);
1064
- findAuthInfoBySecret(secret: string): Promise<A | null>;
1051
+ findAndValidate(secret: string): Promise<A>;
1052
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1065
1053
  findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1066
1054
  generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1067
1055
  }
1068
1056
 
1069
1057
  interface IRemoteApiKeyFetcher<A extends IStorableData> {
1070
- fetchById: (id: string) => Promise<ApiKey<A> | null>;
1071
- fetchBySecret: (secret: string) => Promise<ApiKey<A> | null>;
1058
+ fetchAuthInfoBySecret: (secret: string) => Promise<A | null>;
1072
1059
  }
1073
1060
  declare class RemoteApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
1074
1061
  private fetcher;
1075
1062
  private cacheSeconds;
1076
- private cacheById;
1077
1063
  private cacheBySecret;
1078
1064
  constructor(fetcher: IRemoteApiKeyFetcher<A>, cacheSeconds: number);
1065
+ findAndValidate(secret: string): Promise<A>;
1079
1066
  find(id: string): Promise<ApiKey<A> | null>;
1080
1067
  findOrThrow(id: string): Promise<ApiKey<A>>;
1081
- findAuthInfoBySecret(secret: string): Promise<A>;
1068
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1082
1069
  findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1083
1070
  create(item: ApiKey<A>): Promise<void>;
1084
1071
  generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1085
1072
  }
1086
1073
 
1087
- declare function jwtConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
1074
+ declare function jwtHandshakeGuard(): (target: IConstructor<any>) => void;
1088
1075
 
1089
1076
  declare function jwtGuard(): (target: object, propertyKey: string | symbol) => void;
1090
1077
 
1091
1078
  interface IJwtRefreshTokenData<A extends IStorableData> extends IEntityData {
1079
+ secretHash?: string;
1080
+ metadata?: Record<string, string>;
1092
1081
  authInfo: A;
1093
- passwordHash?: string;
1094
1082
  expirationTime: number;
1083
+ revokedAt?: number;
1095
1084
  }
1096
1085
  declare class JwtRefreshToken<A extends IStorableData> extends Entity<IJwtRefreshTokenData<A>> {
1086
+ static PREFIX: string;
1087
+ static hashSecret(secret: string): string;
1097
1088
  get authInfo(): A;
1089
+ get metadata(): Record<string, string>;
1098
1090
  get expirationTime(): Date;
1099
- generatePassword(): string;
1100
- isValidPassword(password: string): boolean;
1101
- validatePassword(password: string): void;
1102
- static inflate(secret: string): {
1103
- id: string;
1104
- pass: string;
1105
- };
1106
- static deflate(data: {
1107
- id: string;
1108
- pass: string;
1109
- }): string;
1091
+ isExpired(): boolean;
1092
+ revoke(): void;
1093
+ isRevoked(): boolean;
1094
+ generateSecret(): string;
1095
+ isValidSecret(secret: string): boolean;
1096
+ isValidToken(secret: string): boolean;
1097
+ validateToken(secret: string): void;
1110
1098
  }
1111
1099
 
1112
1100
  interface IJwtRefreshTokenRepository<D extends IStorableData> extends ICrudRepository<JwtRefreshToken<D>> {
1101
+ findAndValidate(secret: string): Promise<D>;
1102
+ findByMetadata(metadata: Record<string, string>): Promise<JwtRefreshToken<D>[]>;
1113
1103
  }
1114
1104
 
1115
1105
  declare class JwtTokenDto {
@@ -1139,6 +1129,8 @@ declare class JwtSigner {
1139
1129
  }
1140
1130
 
1141
1131
  declare class JwtRefreshTokenRepository<D extends IStorableData> implements IJwtRefreshTokenRepository<D> {
1132
+ findByMetadata(metadata: Record<string, string>): Promise<JwtRefreshToken<D>[]>;
1133
+ findAndValidate(secret: string): Promise<D>;
1142
1134
  find(id: string): Promise<JwtRefreshToken<D> | null>;
1143
1135
  findOrThrow(id: string): Promise<JwtRefreshToken<D>>;
1144
1136
  findByIds(ids: string[]): Promise<JwtRefreshToken<D>[]>;
@@ -1154,11 +1146,11 @@ declare class Jwt {
1154
1146
  private jwtRefreshTokenRepository;
1155
1147
  private config;
1156
1148
  constructor(auth: Auth<any>, jwtSigner: JwtSigner, jwtRefreshTokenRepository: JwtRefreshTokenRepository<any>, config: JwtConfig);
1157
- createToken(): Promise<JwtAccessAndRefreshTokenDto>;
1158
- refreshToken(refreshSecret: string): Promise<JwtTokenDto>;
1149
+ createToken(metadata?: Record<string, string>): Promise<JwtAccessAndRefreshTokenDto>;
1150
+ findRefreshTokenAuthInfo(secret: string): Promise<any>;
1159
1151
  }
1160
1152
 
1161
- declare class JwtConnectionGuardMiddleware implements IConnectionMiddleware {
1153
+ declare class JwtHandshakeGuardMiddleware implements IHandshakeMiddleware {
1162
1154
  private config;
1163
1155
  private auth;
1164
1156
  constructor(config: JwtConfig, auth: Auth<any>);
@@ -1174,6 +1166,9 @@ declare class JwtGuardMiddleware implements IMiddleware {
1174
1166
 
1175
1167
  declare class PgJwtRefreshTokenRepository<D extends IStorableData> extends PgCrudRepository<JwtRefreshToken<D>> implements IJwtRefreshTokenRepository<D> {
1176
1168
  constructor(pool: Pool);
1169
+ findAndValidate(secret: string): Promise<D>;
1170
+ findBySecret(secret: string): Promise<JwtRefreshToken<D> | null>;
1171
+ findByMetadata(metadata: Record<string, string>): Promise<JwtRefreshToken<D>[]>;
1177
1172
  }
1178
1173
 
1179
1174
  declare class AnthropicChatAdapter implements IChatAdapter {
@@ -1279,28 +1274,34 @@ declare function writeJsonToFile<T>(filename: string, data: T): void;
1279
1274
  declare function readJsonFromFile<T>(filename: string): T | null;
1280
1275
 
1281
1276
  interface ISocketChannelConfig {
1282
- channel: string;
1277
+ namespace: string;
1278
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
1283
1279
  }
1284
1280
 
1285
1281
  declare class SocketChannelConfig implements ISocketChannelConfig {
1286
- channel: string;
1287
- constructor(channel: string);
1282
+ namespace: string;
1283
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined;
1284
+ constructor(namespace: string, handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined);
1288
1285
  }
1289
1286
 
1290
1287
  declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
1291
1288
 
1292
1289
  interface ISocketChannelReceivedMessage {
1293
1290
  chatId: string;
1294
- userId: string;
1291
+ senderName: string;
1292
+ text: string;
1293
+ }
1294
+ declare class SocketChannelReceivedMessage implements ISocketChannelReceivedMessage {
1295
+ chatId: string;
1295
1296
  senderName: string;
1296
1297
  text: string;
1297
1298
  }
1298
1299
  declare class SocketChannel implements IChatChannel {
1299
1300
  private config;
1300
- private socketServerProvider;
1301
1301
  private callBack;
1302
- private server;
1303
- constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider);
1302
+ private controller;
1303
+ constructor(config: SocketChannelConfig);
1304
+ private configController;
1304
1305
  listen(callback: (message: IChannelMessage) => void): void;
1305
1306
  connect(): void;
1306
1307
  }
@@ -1622,4 +1623,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
1622
1623
  new (): {};
1623
1624
  };
1624
1625
 
1625
- export { AnthropicChatAdapter, ApiKey, ApiKeyConnectionGuardMiddleware, ApiKeyGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionMiddleware, type IConnectionMiddlewareMetadata, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketConnectionConfig, type ISocketConnectionMetadata, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtConnectionGuardMiddleware, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyConnectionGuard, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, readJsonFromFile, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp, writeJsonToFile };
1626
+ export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketChannelReceivedMessage, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyGuard, apiKeyHandshakeGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, jwtHandshakeGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, onSocketEvent, param, readJsonFromFile, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketController, telegram, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp, writeJsonToFile };
package/dist/src/index.js CHANGED
@@ -14,7 +14,7 @@ export { isArray } from './core/validation/metadata/@isArray.js';
14
14
  export { ValidationMetadataStore } from './core/validation/metadata/ValidationMetadataStore.js';
15
15
  export { validateModel } from './core/validation/core/validateModel.js';
16
16
  export { validateArray } from './core/validation/core/validateArray.js';
17
- export { validate } from './core/validation/validate.js';
17
+ export { validateAndTransform } from './core/validation/validateAndTransform.js';
18
18
  export { modelInfo } from './core/validation/modelInfo.js';
19
19
  export { isBoolean } from './core/validation/validators/is-boolean/@isBoolean.js';
20
20
  export { validateIsBoolean } from './core/validation/validators/is-boolean/validateIsBoolean.js';
@@ -84,27 +84,26 @@ export { RestControllerMetadataStore } from './feature/rest-controller/metadata/
84
84
  export { runRestControllers } from './feature/rest-controller/runRestControllers.js';
85
85
  export { EXPRESS_REQ, EXPRESS_RES } from './feature/rest-controller/injection-tokens.js';
86
86
  export { SocketServerProvider } from './feature/socket/SocketServerProvider.js';
87
- export { connectionMiddleware } from './feature/socket-controller/metadata/@connectionMiddleware.js';
88
- export { socketConnection } from './feature/socket-controller/metadata/@socketConnection.js';
87
+ export { handshakeMiddlewares } from './feature/socket-controller/metadata/@handshakeMiddlewares.js';
89
88
  export { socketController } from './feature/socket-controller/metadata/@socketController.js';
90
- export { socketEvent } from './feature/socket-controller/metadata/@socketEvent.js';
89
+ export { onSocketEvent } from './feature/socket-controller/metadata/@onSocketEvent.js';
91
90
  export { SocketControllerMetadataStore } from './feature/socket-controller/metadata/SocketControllerMetadataStore.js';
92
91
  export { runSocketControllers } from './feature/socket-controller/runSocketControllers.js';
93
92
  export { PgJobRepository } from './addon/async/pg/PgJobRepository.js';
94
- export { apiKeyConnectionGuard } from './addon/auth/api-key/@apiKeyConnectionGuard.js';
93
+ export { apiKeyHandshakeGuard } from './addon/auth/api-key/@apiKeyHandshakeGuard.js';
95
94
  export { apiKeyGuard } from './addon/auth/api-key/@apiKeyGuard.js';
96
95
  export { ApiKey } from './addon/auth/api-key/ApiKey.js';
97
- export { ApiKeyConnectionGuardMiddleware } from './addon/auth/api-key/ApiKeyConnectionGuardMiddleware.js';
96
+ export { ApiKeyHandshakeGuardMiddleware } from './addon/auth/api-key/ApiKeyHandshakeGuardMiddleware.js';
98
97
  export { ApiKeyGuardMiddleware } from './addon/auth/api-key/ApiKeyGuardMiddleware.js';
99
98
  export { ApiKeyRepository } from './addon/auth/api-key/ApiKeyRepository.js';
100
99
  export { PgApiKeyRepository } from './addon/auth/api-key/PgApiKeyRepository.js';
101
100
  export { RemoteApiKeyRepository } from './addon/auth/api-key/RemoteApiKeyRepository.js';
102
- export { jwtConnectionGuard } from './addon/auth/jwt/@jwtConnectionGuard.js';
101
+ export { jwtHandshakeGuard } from './addon/auth/jwt/@jwtHandshakeGuard.js';
103
102
  export { jwtGuard } from './addon/auth/jwt/@jwtGuard.js';
104
103
  export { Jwt } from './addon/auth/jwt/Jwt.js';
105
104
  export { JwtAccessAndRefreshTokenDto } from './addon/auth/jwt/JwtAccessAndRefreshTokenDto.js';
106
105
  export { JwtConfig } from './addon/auth/jwt/JwtConfig.js';
107
- export { JwtConnectionGuardMiddleware } from './addon/auth/jwt/JwtConnectionGuardMiddleware.js';
106
+ export { JwtHandshakeGuardMiddleware } from './addon/auth/jwt/JwtHandshakeGuardMiddleware.js';
108
107
  export { JwtGuardMiddleware } from './addon/auth/jwt/JwtGuardMiddleware.js';
109
108
  export { JwtRefreshToken } from './addon/auth/jwt/JwtRefreshToken.js';
110
109
  export { JwtRefreshTokenRepository } from './addon/auth/jwt/JwtRefreshTokenRepository.js';
@@ -123,7 +122,7 @@ export { WabotChatAdapter } from './addon/chat-bot/wabot/WabotChatAdapter.js';
123
122
  export { cmd } from './addon/chat-controller/cmd/@cmd.js';
124
123
  export { CmdChannel, readJsonFromFile, writeJsonToFile } from './addon/chat-controller/cmd/CmdChannel.js';
125
124
  export { socket } from './addon/chat-controller/socket/@socket.js';
126
- export { SocketChannel } from './addon/chat-controller/socket/SocketChannel.js';
125
+ export { SocketChannel, SocketChannelReceivedMessage } from './addon/chat-controller/socket/SocketChannel.js';
127
126
  export { SocketChannelConfig } from './addon/chat-controller/socket/SocketChannelConfig.js';
128
127
  export { telegram } from './addon/chat-controller/telegram/@telegram.js';
129
128
  export { TelegramChannelConfig } from './addon/chat-controller/telegram/TelegramChannelConfig.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.10",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -24,10 +24,6 @@
24
24
  "@rollup/plugin-json": "6.1.0",
25
25
  "@rollup/plugin-node-resolve": "16.0.1",
26
26
  "@rollup/plugin-typescript": "12.1.2",
27
- "@types/big.js": "^6.2.2",
28
- "@types/html-to-text": "^9.0.4",
29
- "@types/node": "22.14.1",
30
- "@types/react": "^19.1.2",
31
27
  "@yucacodes/ts": "^0.0.4",
32
28
  "prettier": "^3.5.3",
33
29
  "resend": "^4.4.1",
@@ -38,10 +34,13 @@
38
34
  "peerDependencies": {
39
35
  "@anthropic-ai/sdk": "^0.60.0",
40
36
  "@google/genai": "^1.16.0",
37
+ "@types/big.js": "^6.2.2",
41
38
  "@types/debug": "^4.1.12",
42
39
  "@types/express": "^5.0.1",
43
40
  "@types/jsonwebtoken": "^9.0.10",
44
41
  "@types/pg": "^8.11.14",
42
+ "@types/html-to-text": "^9.0.4",
43
+ "@types/node": "22.14.1",
45
44
  "@yucacodes/ts": "^0.0.4",
46
45
  "big.js": "^7.0.1",
47
46
  "body-parser": "^2.2.0",
@@ -1,16 +0,0 @@
1
- import { connectionMiddleware } from '../../../feature/socket-controller/metadata/@connectionMiddleware.js';
2
- import '../../../core/injection/index.js';
3
- import '../../../feature/socket-controller/metadata/SocketControllerMetadataStore.js';
4
- import 'path';
5
- import 'debug';
6
- import '../../../feature/socket/SocketServerProvider.js';
7
- import '../../../core/validation/metadata/ValidationMetadataStore.js';
8
- import { ApiKeyConnectionGuardMiddleware } from './ApiKeyConnectionGuardMiddleware.js';
9
-
10
- function apiKeyConnectionGuard() {
11
- return function (target, propertyKey) {
12
- connectionMiddleware(ApiKeyConnectionGuardMiddleware)(target, propertyKey);
13
- };
14
- }
15
-
16
- export { apiKeyConnectionGuard };
@@ -1,16 +0,0 @@
1
- import { connectionMiddleware } from '../../../feature/socket-controller/metadata/@connectionMiddleware.js';
2
- import '../../../core/injection/index.js';
3
- import '../../../feature/socket-controller/metadata/SocketControllerMetadataStore.js';
4
- import 'path';
5
- import 'debug';
6
- import '../../../feature/socket/SocketServerProvider.js';
7
- import '../../../core/validation/metadata/ValidationMetadataStore.js';
8
- import { JwtConnectionGuardMiddleware } from './JwtConnectionGuardMiddleware.js';
9
-
10
- function jwtConnectionGuard() {
11
- return function (target, propertyKey) {
12
- connectionMiddleware(JwtConnectionGuardMiddleware)(target, propertyKey);
13
- };
14
- }
15
-
16
- export { jwtConnectionGuard };
@@ -1,16 +0,0 @@
1
- import { SocketControllerMetadataStore } from './SocketControllerMetadataStore.js';
2
- import { container } from '../../../core/injection/index.js';
3
-
4
- function connectionMiddleware(middlewareConstructor) {
5
- return function (target, propertyKey) {
6
- const functionName = propertyKey.toString();
7
- const store = container.resolve(SocketControllerMetadataStore);
8
- store.saveConnectionMiddlewareMetadata({
9
- controllerConstructor: target.constructor,
10
- functionName,
11
- middlewareConstructor: middlewareConstructor,
12
- });
13
- };
14
- }
15
-
16
- export { connectionMiddleware };
@@ -1,18 +0,0 @@
1
- import { container } from '../../../core/injection/index.js';
2
- import { SocketControllerMetadataStore } from './SocketControllerMetadataStore.js';
3
-
4
- function socketConnection(config) {
5
- return function (target, propertyKey) {
6
- const functionName = propertyKey.toString();
7
- const paramsTypes = Reflect.getMetadata('design:paramtypes', target, functionName);
8
- const store = container.resolve(SocketControllerMetadataStore);
9
- store.saveSocketConnectionMetadata({
10
- controllerConstructor: target.constructor,
11
- config: typeof config === 'string' ? { namespace: config } : config,
12
- functionName,
13
- paramsTypes,
14
- });
15
- };
16
- }
17
-
18
- export { socketConnection };