@wabot-dev/framework 0.1.0 → 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 +29 -34
  3. package/dist/src/addon/auth/api-key/ApiKeyGuardMiddleware.js +3 -6
  4. package/dist/src/addon/auth/api-key/{ApiKeyConnectionGuardMiddleware.js → ApiKeyHandshakeGuardMiddleware.js} +5 -5
  5. package/dist/src/addon/auth/api-key/ApiKeyRepository.js +7 -17
  6. package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +39 -6
  7. package/dist/src/addon/auth/api-key/RemoteApiKeyRepository.js +22 -14
  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 +131 -129
  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,61 +981,58 @@ 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
 
1004
988
  interface IApiKeyData<A extends IStorableData> extends IEntityData {
1005
- passwordHash?: string;
989
+ secretHash?: string;
990
+ metadata?: Record<string, string>;
1006
991
  authInfo: A;
1007
992
  name: string;
1008
993
  }
1009
994
  declare class ApiKey<A extends IStorableData> extends Entity<IApiKeyData<A>> {
995
+ static PREFIX: string;
996
+ static hashSecret(secret: string): string;
1010
997
  get authInfo(): A;
998
+ get metadata(): Record<string, string>;
999
+ get name(): string;
1011
1000
  setAuthInfo(authInfo: A): void;
1012
- generatePassword(): string;
1013
- isValidPassword(password: string): boolean;
1014
- validatePassword(password: string): void;
1015
- static inflate(secret: string): {
1016
- id: string;
1017
- pass: string;
1018
- };
1019
- static deflate(data: {
1020
- id: string;
1021
- pass: string;
1022
- }): string;
1001
+ generateSecret(): string;
1002
+ isValidSecret(secret: string): boolean;
1003
+ validateSecret(secret: string): void;
1023
1004
  }
1024
1005
 
1025
1006
  interface IApiKeyRepository<A extends IStorableData> {
1026
1007
  find(id: string): Promise<ApiKey<A> | null>;
1027
1008
  findOrThrow(id: string): Promise<ApiKey<A>>;
1009
+ findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1028
1010
  create(item: ApiKey<A>): Promise<void>;
1029
- generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1030
- findAuthInfo(secret: string): Promise<A>;
1011
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1012
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1013
+ findAndValidate(secret: string): Promise<A>;
1031
1014
  }
1032
1015
  interface IGenerateApiKeyReq<A extends IStorableData> extends IStorableData {
1033
1016
  name: string;
1017
+ metadata?: Record<string, string>;
1034
1018
  authInfo: A;
1035
1019
  }
1036
- interface IGenerateApiKeyRes {
1037
- id: string;
1020
+ interface IGenerateApiKeyRes<A extends IStorableData> {
1021
+ apiKey: ApiKey<A>;
1038
1022
  secret: string;
1039
1023
  }
1040
1024
 
1041
1025
  declare class ApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
1042
- findAuthInfo(secret: string): Promise<A>;
1043
1026
  find(id: string): Promise<ApiKey<A> | null>;
1044
1027
  findOrThrow(id: string): Promise<ApiKey<A>>;
1028
+ findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1045
1029
  create(item: ApiKey<A>): Promise<void>;
1046
- generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1047
- static generate(repository: ApiKeyRepository<any>, req: IGenerateApiKeyReq<any>): Promise<{
1048
- id: string;
1049
- secret: string;
1050
- }>;
1051
- static findAuthInfo<A extends IStorableData>(repository: ApiKeyRepository<A>, secret: string): Promise<A>;
1030
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1031
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1032
+ findAndValidate(secret: string): Promise<A>;
1052
1033
  }
1053
1034
 
1054
- declare class ApiKeyConnectionGuardMiddleware implements IConnectionMiddleware {
1035
+ declare class ApiKeyHandshakeGuardMiddleware implements IHandshakeMiddleware {
1055
1036
  private apiKeyRepository;
1056
1037
  private auth;
1057
1038
  constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
@@ -1067,48 +1048,58 @@ declare class ApiKeyGuardMiddleware implements IMiddleware {
1067
1048
 
1068
1049
  declare class PgApiKeyRepository<A extends IStorableData> extends PgCrudRepository<ApiKey<A>> implements IApiKeyRepository<A> {
1069
1050
  constructor(pool: Pool);
1070
- findAuthInfo(secret: string): Promise<A>;
1071
- generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1051
+ findAndValidate(secret: string): Promise<A>;
1052
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1053
+ findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1054
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1072
1055
  }
1073
1056
 
1057
+ interface IRemoteApiKeyFetcher<A extends IStorableData> {
1058
+ fetchAuthInfoBySecret: (secret: string) => Promise<A | null>;
1059
+ }
1074
1060
  declare class RemoteApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
1075
1061
  private fetcher;
1076
1062
  private cacheSeconds;
1077
- private cache;
1078
- constructor(fetcher: (id: string) => Promise<ApiKey<A> | null>, cacheSeconds: number);
1063
+ private cacheBySecret;
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
- findAuthInfo(secret: string): Promise<A>;
1068
+ findBySecret(secret: string): Promise<ApiKey<A> | null>;
1069
+ findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
1082
1070
  create(item: ApiKey<A>): Promise<void>;
1083
- generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes>;
1071
+ generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1084
1072
  }
1085
1073
 
1086
- declare function jwtConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
1074
+ declare function jwtHandshakeGuard(): (target: IConstructor<any>) => void;
1087
1075
 
1088
1076
  declare function jwtGuard(): (target: object, propertyKey: string | symbol) => void;
1089
1077
 
1090
1078
  interface IJwtRefreshTokenData<A extends IStorableData> extends IEntityData {
1079
+ secretHash?: string;
1080
+ metadata?: Record<string, string>;
1091
1081
  authInfo: A;
1092
- passwordHash?: string;
1093
1082
  expirationTime: number;
1083
+ revokedAt?: number;
1094
1084
  }
1095
1085
  declare class JwtRefreshToken<A extends IStorableData> extends Entity<IJwtRefreshTokenData<A>> {
1086
+ static PREFIX: string;
1087
+ static hashSecret(secret: string): string;
1096
1088
  get authInfo(): A;
1089
+ get metadata(): Record<string, string>;
1097
1090
  get expirationTime(): Date;
1098
- generatePassword(): string;
1099
- isValidPassword(password: string): boolean;
1100
- validatePassword(password: string): void;
1101
- static inflate(secret: string): {
1102
- id: string;
1103
- pass: string;
1104
- };
1105
- static deflate(data: {
1106
- id: string;
1107
- pass: string;
1108
- }): 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;
1109
1098
  }
1110
1099
 
1111
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>[]>;
1112
1103
  }
1113
1104
 
1114
1105
  declare class JwtTokenDto {
@@ -1138,6 +1129,8 @@ declare class JwtSigner {
1138
1129
  }
1139
1130
 
1140
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>;
1141
1134
  find(id: string): Promise<JwtRefreshToken<D> | null>;
1142
1135
  findOrThrow(id: string): Promise<JwtRefreshToken<D>>;
1143
1136
  findByIds(ids: string[]): Promise<JwtRefreshToken<D>[]>;
@@ -1153,11 +1146,11 @@ declare class Jwt {
1153
1146
  private jwtRefreshTokenRepository;
1154
1147
  private config;
1155
1148
  constructor(auth: Auth<any>, jwtSigner: JwtSigner, jwtRefreshTokenRepository: JwtRefreshTokenRepository<any>, config: JwtConfig);
1156
- createToken(): Promise<JwtAccessAndRefreshTokenDto>;
1157
- refreshToken(refreshSecret: string): Promise<JwtTokenDto>;
1149
+ createToken(metadata?: Record<string, string>): Promise<JwtAccessAndRefreshTokenDto>;
1150
+ findRefreshTokenAuthInfo(secret: string): Promise<any>;
1158
1151
  }
1159
1152
 
1160
- declare class JwtConnectionGuardMiddleware implements IConnectionMiddleware {
1153
+ declare class JwtHandshakeGuardMiddleware implements IHandshakeMiddleware {
1161
1154
  private config;
1162
1155
  private auth;
1163
1156
  constructor(config: JwtConfig, auth: Auth<any>);
@@ -1173,6 +1166,9 @@ declare class JwtGuardMiddleware implements IMiddleware {
1173
1166
 
1174
1167
  declare class PgJwtRefreshTokenRepository<D extends IStorableData> extends PgCrudRepository<JwtRefreshToken<D>> implements IJwtRefreshTokenRepository<D> {
1175
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>[]>;
1176
1172
  }
1177
1173
 
1178
1174
  declare class AnthropicChatAdapter implements IChatAdapter {
@@ -1278,28 +1274,34 @@ declare function writeJsonToFile<T>(filename: string, data: T): void;
1278
1274
  declare function readJsonFromFile<T>(filename: string): T | null;
1279
1275
 
1280
1276
  interface ISocketChannelConfig {
1281
- channel: string;
1277
+ namespace: string;
1278
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
1282
1279
  }
1283
1280
 
1284
1281
  declare class SocketChannelConfig implements ISocketChannelConfig {
1285
- channel: string;
1286
- constructor(channel: string);
1282
+ namespace: string;
1283
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined;
1284
+ constructor(namespace: string, handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined);
1287
1285
  }
1288
1286
 
1289
1287
  declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
1290
1288
 
1291
1289
  interface ISocketChannelReceivedMessage {
1292
1290
  chatId: string;
1293
- userId: string;
1291
+ senderName: string;
1292
+ text: string;
1293
+ }
1294
+ declare class SocketChannelReceivedMessage implements ISocketChannelReceivedMessage {
1295
+ chatId: string;
1294
1296
  senderName: string;
1295
1297
  text: string;
1296
1298
  }
1297
1299
  declare class SocketChannel implements IChatChannel {
1298
1300
  private config;
1299
- private socketServerProvider;
1300
1301
  private callBack;
1301
- private server;
1302
- constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider);
1302
+ private controller;
1303
+ constructor(config: SocketChannelConfig);
1304
+ private configController;
1303
1305
  listen(callback: (message: IChannelMessage) => void): void;
1304
1306
  connect(): void;
1305
1307
  }
@@ -1621,4 +1623,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
1621
1623
  new (): {};
1622
1624
  };
1623
1625
 
1624
- export { AnthropicChatAdapter, ApiKey, ApiKeyConnectionGuardMiddleware, ApiKeyGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionMiddleware, type IConnectionMiddlewareMetadata, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketConnectionConfig, type ISocketConnectionMetadata, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtConnectionGuardMiddleware, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyConnectionGuard, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, 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.1.0",
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 };