@wabot-dev/framework 0.9.1 → 0.9.5

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 (84) hide show
  1. package/dist/src/addon/async/in-memory/InMemoryCronJobRepository.js +45 -0
  2. package/dist/src/addon/async/in-memory/InMemoryJobRepository.js +75 -0
  3. package/dist/src/addon/async/in-memory/index.js +2 -0
  4. package/dist/src/addon/async/pg/PgCronJobRepository.js +7 -5
  5. package/dist/src/addon/async/pg/PgJobRepository.js +8 -5
  6. package/dist/src/addon/async/pg/PgTransactionAdapter.js +25 -0
  7. package/dist/src/addon/async/pg/index.js +3 -0
  8. package/dist/src/addon/auth/api-key/ApiKey.js +4 -4
  9. package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +9 -8
  10. package/dist/src/addon/auth/jwt/JwtRefreshToken.js +4 -4
  11. package/dist/src/addon/auth/jwt/PgJwtRefreshTokenRepository.js +6 -5
  12. package/dist/src/addon/chat-bot/{ram/RamChatMemory.js → in-memory/InMemoryChatMemory.js} +2 -2
  13. package/dist/src/addon/chat-bot/{ram/RamChatRepository.js → in-memory/InMemoryChatRepository.js} +6 -6
  14. package/dist/src/addon/chat-bot/in-memory/index.js +2 -0
  15. package/dist/src/addon/chat-bot/pg/PgChatMemory.js +8 -7
  16. package/dist/src/addon/chat-bot/pg/PgChatRepository.js +7 -6
  17. package/dist/src/addon/chat-bot/pg/index.js +2 -0
  18. package/dist/src/addon/chat-controller/cmd/@cmd.js +7 -2
  19. package/dist/src/addon/chat-controller/cmd/CmdChannel.js +85 -61
  20. package/dist/src/addon/chat-controller/cmd/CmdChannelConfig.js +8 -0
  21. package/dist/src/addon/chat-controller/cmd/CmdChannelServer.js +169 -0
  22. package/dist/src/addon/chat-controller/cmd/cmdChannelSocketPath.js +16 -0
  23. package/dist/src/addon/chat-controller/cmd/runCmdClient.js +226 -0
  24. package/dist/src/addon/chat-controller/socket/@socket.js +3 -1
  25. package/dist/src/addon/chat-controller/socket/SocketChannelConfig.js +4 -4
  26. package/dist/src/addon/chat-controller/whatsapp/WhatsAppSender.js +2 -72
  27. package/dist/src/addon/chat-controller/whatsapp/{WhatsAppReceiver.js → cloud-api/WhatsAppApiReceiver.js} +2 -2
  28. package/dist/src/addon/chat-controller/whatsapp/cloud-api/WhatsAppApiSender.js +67 -0
  29. package/dist/src/addon/chat-controller/whatsapp/cloud-api/WhatsAppReceiverByCloudApi.js +5 -7
  30. package/dist/src/addon/chat-controller/whatsapp/wasender/@wasender.js +23 -0
  31. package/dist/src/addon/chat-controller/{wasender/WhatsAppByWasenderChannel.js → whatsapp/wasender/WasenderChannel.js} +20 -20
  32. package/dist/src/addon/chat-controller/{wasender/WhatsAppByWasenderChannelConfig.js → whatsapp/wasender/WasenderChannelConfig.js} +3 -3
  33. package/dist/src/addon/chat-controller/whatsapp/wasender/WasenderChannelName.js +3 -0
  34. package/dist/src/addon/chat-controller/{wasender/WhatsAppReceiverByWasender.js → whatsapp/wasender/WasenderReceiver.js} +7 -7
  35. package/dist/src/addon/chat-controller/{wasender/WhatsAppSenderByWasender.js → whatsapp/wasender/WasenderSender.js} +8 -5
  36. package/dist/src/addon/chat-controller/{wasender → whatsapp/wasender}/WasenderWebhookController.js +4 -4
  37. package/dist/src/addon/lock/InMemoryLockKey.js +45 -0
  38. package/dist/src/addon/lock/InMemoryLocker.js +15 -0
  39. package/dist/src/addon/lock/index.js +2 -0
  40. package/dist/src/core/repository/CrudRepository.js +25 -0
  41. package/dist/src/feature/async/{@cron.js → @cronHandler.js} +2 -2
  42. package/dist/src/feature/async/@transaction.js +22 -0
  43. package/dist/src/feature/async/AsyncMetadataStore.js +6 -0
  44. package/dist/src/feature/async/TransactionMetadataStore.js +28 -0
  45. package/dist/src/feature/chat-controller/metadata/ControllerMetadataStore.js +3 -0
  46. package/dist/src/feature/pg/@pgExtension.js +33 -0
  47. package/dist/src/feature/pg/PgJsonRepositoryAdapter.js +50 -0
  48. package/dist/src/feature/pg/index.js +10 -0
  49. package/dist/src/feature/project-runner/ProjectRunner.js +276 -0
  50. package/dist/src/feature/repository/@memoryExtension.js +29 -0
  51. package/dist/src/feature/repository/@query.js +22 -0
  52. package/dist/src/feature/repository/@queryExtension.js +21 -0
  53. package/dist/src/feature/repository/@repository.js +170 -0
  54. package/dist/src/feature/repository/MemoryRepositoryAdapter.js +110 -0
  55. package/dist/src/feature/repository/RepositoryAdapterRegistry.js +27 -0
  56. package/dist/src/feature/repository/RepositoryMetadataStore.js +102 -0
  57. package/dist/src/feature/repository/evaluateQueryAst.js +134 -0
  58. package/dist/src/feature/rest-controller/metadata/RestControllerMetadataStore.js +3 -0
  59. package/dist/src/feature/socket-controller/metadata/SocketControllerMetadataStore.js +3 -0
  60. package/dist/src/index.d.ts +377 -298
  61. package/dist/src/index.js +40 -34
  62. package/package.json +9 -7
  63. package/dist/src/addon/chat-controller/wasender/@whatsAppByWasender.js +0 -20
  64. package/dist/src/addon/chat-controller/wasender/whatsAppByWasenderChannelName.js +0 -3
  65. package/dist/src/addon/chat-controller/whatsapp/@whatsApp.js +0 -20
  66. package/dist/src/addon/chat-controller/whatsapp/EnvWhatsAppRepository.js +0 -49
  67. package/dist/src/addon/chat-controller/whatsapp/PgWhatsAppRepository.js +0 -48
  68. package/dist/src/addon/chat-controller/whatsapp/WhatsApp.js +0 -30
  69. package/dist/src/addon/chat-controller/whatsapp/WhatsAppChannel.js +0 -58
  70. package/dist/src/addon/chat-controller/whatsapp/WhatsAppChannelConfig.js +0 -8
  71. package/dist/src/addon/chat-controller/whatsapp/WhatsAppRepository.js +0 -10
  72. package/dist/src/addon/chat-controller/whatsapp/cloud-api/WhatsAppSenderByCloudApi.js +0 -133
  73. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppProxyContracts.js +0 -5
  74. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppReceiverByWabotProxy.js +0 -67
  75. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppSenderByWabotProxy.js +0 -63
  76. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppWabotProxyConnection.js +0 -45
  77. package/dist/src/feature/pg/query/@pgJsonRepository.js +0 -73
  78. package/dist/src/feature/pg/query/@query.js +0 -14
  79. package/dist/src/feature/pg/query/PgJsonRepository.js +0 -23
  80. package/dist/src/feature/pg/query/PgRepositoryMetadataStore.js +0 -44
  81. /package/dist/src/addon/chat-controller/whatsapp/{whatsAppChannelName.js → cloud-api/whatsAppChannelName.js} +0 -0
  82. /package/dist/src/addon/chat-controller/{wasender → whatsapp/wasender}/extractNumberFromWasenderKey.js +0 -0
  83. /package/dist/src/feature/pg/{query/buildQuerySql.js → buildQuerySql.js} +0 -0
  84. /package/dist/src/feature/{pg/query → repository}/parseQueryMethodName.js +0 -0
@@ -11,7 +11,6 @@ import { Pool, PoolClient } from 'pg';
11
11
  import { AsyncLocalStorage } from 'node:async_hooks';
12
12
  import { Server as Server$1, Socket } from 'socket.io';
13
13
  import { Algorithm } from 'jsonwebtoken';
14
- import { Socket as Socket$1 } from 'socket.io-client';
15
14
  import { Wasender } from 'wasenderapi';
16
15
 
17
16
  type IStorablePrimitive = null | number | string | boolean | undefined;
@@ -48,8 +47,9 @@ declare function strArr(strings: TemplateStringsArray): ConfigReference<string[]
48
47
  declare function numArr(strings: TemplateStringsArray): ConfigReference<number[]>;
49
48
  declare function boolArr(strings: TemplateStringsArray): ConfigReference<boolean[]>;
50
49
 
50
+ type ResolveConfigValue<V> = V extends ConfigReference<infer R> ? R : V;
51
51
  type ResolvedConfig<T> = {
52
- [K in keyof T]: T[K] extends ConfigReference<infer R> ? R : T[K];
52
+ [K in keyof T]: ResolveConfigValue<T[K]>;
53
53
  };
54
54
  declare function resolveConfigReferences<T extends Record<string, any>>(config: T): ResolvedConfig<T>;
55
55
  declare class ConfigResolver {
@@ -417,7 +417,18 @@ declare class Random {
417
417
  static numberCode(length: number): string;
418
418
  }
419
419
 
420
- interface ICrudRepository<T> {
420
+ interface ICrudRepository<T extends Entity<IEntityData>> {
421
+ find(id: string): Promise<T | null>;
422
+ findOrThrow(id: string): Promise<T>;
423
+ findByIds(ids: string[]): Promise<T[]>;
424
+ findAll(id: string): Promise<T[]>;
425
+ create(item: T): Promise<void>;
426
+ update(item: T): Promise<void>;
427
+ delete(item: T): Promise<void>;
428
+ }
429
+
430
+ declare class CrudRepository<T extends Entity<IEntityData>, Ext = never> implements ICrudRepository<T> {
431
+ protected readonly extension: Ext;
421
432
  find(id: string): Promise<T | null>;
422
433
  findOrThrow(id: string): Promise<T>;
423
434
  findByIds(ids: string[]): Promise<T[]>;
@@ -468,7 +479,9 @@ interface ICronConfig {
468
479
  cron: string;
469
480
  disabled?: boolean;
470
481
  }
471
- declare function cron(config: ICronConfig): (target: IConstructor<ICronHandler>) => void;
482
+ declare function cronHandler(config: ICronConfig): (target: IConstructor<ICronHandler>) => void;
483
+
484
+ declare function transaction(dbNames?: readonly string[]): <This, A extends unknown[], R>(_target: object, _propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<(this: This, ...args: A) => Promise<R>>) => TypedPropertyDescriptor<(this: This, ...args: A) => Promise<R>>;
472
485
 
473
486
  interface ICronJobScheduleConfig {
474
487
  name: string;
@@ -497,6 +510,8 @@ declare class AsyncMetadataStore {
497
510
  requireCommandNameForHandler(handlerConstructor: IConstructor<ICommandHandler<any>>): string;
498
511
  getCommandName(command: IConstructor<any>): string | null;
499
512
  getCommandForCommandName(commandName: string): IConstructor<any> | null;
513
+ getAllCommandHandlers(): IConstructor<ICommandHandler<any>>[];
514
+ getAllCronHandlers(): IConstructor<ICronHandler>[];
500
515
  }
501
516
 
502
517
  interface IJobData extends IEntityData {
@@ -664,12 +679,24 @@ declare class CronJobRepository implements ICronJobRepository {
664
679
  findOrThrow(id: string): Promise<CronJob>;
665
680
  }
666
681
 
682
+ interface ITransactionAdapter {
683
+ run<T>(fn: () => Promise<T>): Promise<T>;
684
+ }
685
+
667
686
  declare function runCommandHandlers(handlers: IConstructor<ICommandHandler<any>>[]): void;
668
687
  declare function stopCommandHandlers(handlers: IConstructor<ICommandHandler<any>>[]): void;
669
688
 
670
689
  declare function runCronHandlers(handlers: IConstructor<ICronHandler>[]): void;
671
690
  declare function stopCronHandlers(handlers: IConstructor<ICronHandler>[]): void;
672
691
 
692
+ declare class TransactionMetadataStore {
693
+ private adapters;
694
+ registerAdapter(dbName: string, adapter: ITransactionAdapter): void;
695
+ requireAdapter(dbName: string): ITransactionAdapter;
696
+ requireAdapters(dbNames: readonly string[]): ITransactionAdapter[];
697
+ getAllAdapters(): ITransactionAdapter[];
698
+ }
699
+
673
700
  interface IChatConnection {
674
701
  chatType: 'GROUP' | 'PRIVATE';
675
702
  channelName: string;
@@ -1096,6 +1123,32 @@ declare function runChatAdapters(adapters: IConstructor<IChatAdapter>[]): void;
1096
1123
 
1097
1124
  declare function safeJsonParse<T = unknown>(json: string | undefined | null, context?: string): T;
1098
1125
 
1126
+ interface IProjectRunnerConfig {
1127
+ directories?: string[];
1128
+ connectionString?: string;
1129
+ chatAdapters?: IConstructor<IChatAdapter>[];
1130
+ }
1131
+ declare class ProjectRunner {
1132
+ private directories;
1133
+ private chatAdapters;
1134
+ private connectionString;
1135
+ private isPg;
1136
+ private pool;
1137
+ constructor(config?: IProjectRunnerConfig);
1138
+ run(): Promise<void>;
1139
+ private resolveConnectionString;
1140
+ private initPool;
1141
+ private scanDirectories;
1142
+ private importFiles;
1143
+ private discoverComponents;
1144
+ private registerAdapters;
1145
+ private registerMemoryAdapters;
1146
+ private registerPostgresAdapters;
1147
+ private startComponents;
1148
+ private resolveDefaultChatAdapters;
1149
+ }
1150
+ declare function run(config?: IProjectRunnerConfig): Promise<void>;
1151
+
1099
1152
  interface IchatControllerConfig {
1100
1153
  }
1101
1154
 
@@ -1133,6 +1186,7 @@ declare class ControllerMetadataStore {
1133
1186
  private chatControllers;
1134
1187
  saveChannelMetadata(channelMetadata: IChannelMetadata): void;
1135
1188
  saveChatControllerMetadata(controllerMetadata: IChatControllerMetadata): void;
1189
+ getAllChatControllerConstructors(): Function[];
1136
1190
  getChatControllerMetadata(controllerConstructor: Function): {
1137
1191
  config: IChatControllerMetadata;
1138
1192
  channels: IChannelMetadata[];
@@ -1240,6 +1294,10 @@ declare class PgRepositoryBase<P extends Entity<IEntityData>> {
1240
1294
  protected ensureColumns(client: PoolClient): Promise<void>;
1241
1295
  }
1242
1296
 
1297
+ declare const PG_ADAPTER_ID: unique symbol;
1298
+ type ExtensionOf$1<R> = R extends CrudRepository<any, infer Ext> ? Ext : never;
1299
+ declare function pgExtension<R extends CrudRepository<any, any>>(repositoryClass: IConstructor<R>): <E extends PgRepositoryBase<any> & ExtensionOf$1<R>>(target: IConstructor<E>) => void;
1300
+
1243
1301
  declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgRepositoryBase<P> implements ICrudRepository<P> {
1244
1302
  protected readonly config: IPgRepositoryConfig<P>;
1245
1303
  constructor(pool: Pool, config: IPgRepositoryConfig<P>);
@@ -1252,6 +1310,116 @@ declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgReposito
1252
1310
  delete(item: P): Promise<void>;
1253
1311
  }
1254
1312
 
1313
+ interface IRepositoryConfig<P extends Entity<IEntityData>> {
1314
+ table: string;
1315
+ constructor: IConstructor<P>;
1316
+ schema?: string;
1317
+ }
1318
+
1319
+ type QueryPrefix = 'find' | 'findOne' | 'count' | 'exists' | 'delete';
1320
+ type QueryOperator = 'Equals' | 'Not' | 'Like' | 'NotLike' | 'In' | 'NotIn' | 'Gt' | 'Gte' | 'Lt' | 'Lte' | 'IsNull' | 'IsNotNull';
1321
+ type QueryConnector = 'And' | 'Or';
1322
+ interface IQueryCondition {
1323
+ field: string;
1324
+ operator: QueryOperator;
1325
+ connector?: QueryConnector;
1326
+ }
1327
+ interface IQueryOrderBy {
1328
+ field: string;
1329
+ direction: 'ASC' | 'DESC';
1330
+ }
1331
+ interface IQueryAst {
1332
+ prefix: QueryPrefix;
1333
+ conditions: IQueryCondition[];
1334
+ orderBy: IQueryOrderBy[];
1335
+ limit?: number;
1336
+ }
1337
+
1338
+ interface IRepositoryRuntime<P extends Entity<IEntityData>> {
1339
+ find(id: string): Promise<P | null>;
1340
+ findOrThrow(id: string): Promise<P>;
1341
+ findByIds(ids: string[]): Promise<P[]>;
1342
+ findAll(): Promise<P[]>;
1343
+ create(item: P): Promise<void>;
1344
+ update(item: P): Promise<void>;
1345
+ delete(item: P): Promise<void>;
1346
+ runQuery(ast: IQueryAst, args: unknown[]): Promise<P[]>;
1347
+ runCount(ast: IQueryAst, args: unknown[]): Promise<number>;
1348
+ runExists(ast: IQueryAst, args: unknown[]): Promise<boolean>;
1349
+ runDelete(ast: IQueryAst, args: unknown[]): Promise<void>;
1350
+ }
1351
+
1352
+ interface IRepositoryAdapter {
1353
+ readonly id: symbol;
1354
+ build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
1355
+ buildExtension?<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
1356
+ }
1357
+
1358
+ declare class MemoryRepositoryExtension<P extends Entity<IEntityData>> {
1359
+ protected readonly items: Map<string, P>;
1360
+ protected readonly config: IRepositoryConfig<P>;
1361
+ constructor(items: Map<string, P>, config: IRepositoryConfig<P>);
1362
+ protected clone(item: P): P;
1363
+ }
1364
+ declare const MEMORY_ADAPTER_ID: unique symbol;
1365
+ declare class MemoryRepositoryAdapter implements IRepositoryAdapter {
1366
+ readonly id: symbol;
1367
+ private stores;
1368
+ private getStore;
1369
+ build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
1370
+ buildExtension<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
1371
+ }
1372
+
1373
+ type ExtensionOf<R> = R extends CrudRepository<any, infer Ext> ? Ext : never;
1374
+ declare function memoryExtension<R extends CrudRepository<any, any>>(repositoryClass: IConstructor<R>): <E extends MemoryRepositoryExtension<any> & ExtensionOf<R>>(target: IConstructor<E>) => void;
1375
+
1376
+ declare function query(): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
1377
+
1378
+ declare function queryExtension(): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
1379
+
1380
+ declare function repository<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): (target: IConstructor<any>) => void;
1381
+
1382
+ declare function evaluateQueryAst<P extends Entity<IEntityData>>(items: Iterable<P>, ast: IQueryAst, args: unknown[]): P[];
1383
+
1384
+ declare function parseQueryMethodName(name: string): IQueryAst;
1385
+
1386
+ declare class RepositoryAdapterRegistry {
1387
+ private adapter;
1388
+ setDefault(adapter: IRepositoryAdapter): void;
1389
+ getDefault(): IRepositoryAdapter;
1390
+ hasDefault(): boolean;
1391
+ clear(): void;
1392
+ }
1393
+
1394
+ interface IQueryMethodMetadata {
1395
+ repositoryConstructor: IConstructor<any>;
1396
+ functionName: string;
1397
+ }
1398
+ declare class RepositoryMetadataStore {
1399
+ private queryMethods;
1400
+ private extensionMethods;
1401
+ private repositoryConfigs;
1402
+ private extensions;
1403
+ saveQueryMethodMetadata(metadata: IQueryMethodMetadata): void;
1404
+ saveExtensionMethodMetadata(metadata: IQueryMethodMetadata): void;
1405
+ saveRepositoryConfig<P extends Entity<IEntityData>>(ctor: IConstructor<any>, config: IRepositoryConfig<P>): void;
1406
+ getRepositoryConfig(ctor: IConstructor<any>): IRepositoryConfig<any> | undefined;
1407
+ getQueryMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
1408
+ getExtensionMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
1409
+ private collectMethodsFromHierarchy;
1410
+ saveExtension(repositoryConstructor: IConstructor<any>, adapterId: symbol, extensionConstructor: IConstructor<any>): void;
1411
+ getExtension(ctor: IConstructor<any>, adapterId: symbol): IConstructor<any> | undefined;
1412
+ validateExtensionsRegistered(adapterId: symbol): void;
1413
+ }
1414
+
1415
+ declare class PgJsonRepositoryAdapter implements IRepositoryAdapter {
1416
+ private readonly pool;
1417
+ readonly id: symbol;
1418
+ constructor(pool: Pool);
1419
+ build<P extends Entity<IEntityData>>(config: IRepositoryConfig<P>): IRepositoryRuntime<P>;
1420
+ buildExtension<E>(config: IRepositoryConfig<any>, ExtensionCtor: IConstructor<E>): E;
1421
+ }
1422
+
1255
1423
  declare class PgLocker implements ILocker {
1256
1424
  private readonly pool;
1257
1425
  constructor(pool: Pool);
@@ -1277,46 +1445,6 @@ declare const pgStorage: AsyncLocalStorage<ClientMap>;
1277
1445
  */
1278
1446
  declare function getClientMap(): ClientMap;
1279
1447
 
1280
- declare function pgJsonRepository<P extends Entity<IEntityData>>(config: IPgRepositoryConfig<P>): (target: IConstructor<any>) => void;
1281
-
1282
- declare function query(): (target: object, propertyKey: string | symbol) => void;
1283
-
1284
- declare class PgJsonRepository<P extends Entity<IEntityData>> extends PgCrudRepository<P> {
1285
- constructor(pool: Pool);
1286
- }
1287
-
1288
- interface IQueryMethodMetadata {
1289
- repositoryConstructor: IConstructor<any>;
1290
- functionName: string;
1291
- }
1292
- declare class PgRepositoryMetadataStore {
1293
- private queryMethods;
1294
- private repositoryConfigs;
1295
- saveQueryMethodMetadata(metadata: IQueryMethodMetadata): void;
1296
- saveRepositoryConfig<P extends Entity<IEntityData>>(ctor: IConstructor<any>, config: IPgRepositoryConfig<P>): void;
1297
- getRepositoryConfig(ctor: IConstructor<any>): IPgRepositoryConfig<any> | undefined;
1298
- getQueryMethods(ctor: IConstructor<any>): IQueryMethodMetadata[];
1299
- }
1300
-
1301
- type QueryPrefix = 'find' | 'findOne' | 'count' | 'exists' | 'delete';
1302
- type QueryOperator = 'Equals' | 'Not' | 'Like' | 'NotLike' | 'In' | 'NotIn' | 'Gt' | 'Gte' | 'Lt' | 'Lte' | 'IsNull' | 'IsNotNull';
1303
- type QueryConnector = 'And' | 'Or';
1304
- interface IQueryCondition {
1305
- field: string;
1306
- operator: QueryOperator;
1307
- connector?: QueryConnector;
1308
- }
1309
- interface IQueryOrderBy {
1310
- field: string;
1311
- direction: 'ASC' | 'DESC';
1312
- }
1313
- interface IQueryAst {
1314
- prefix: QueryPrefix;
1315
- conditions: IQueryCondition[];
1316
- orderBy: IQueryOrderBy[];
1317
- limit?: number;
1318
- }
1319
-
1320
1448
  interface IBuiltQuery {
1321
1449
  sql: string;
1322
1450
  argCount: number;
@@ -1324,8 +1452,6 @@ interface IBuiltQuery {
1324
1452
  }
1325
1453
  declare function buildQuerySql(ast: IQueryAst, table: string, columns: string): IBuiltQuery;
1326
1454
 
1327
- declare function parseQueryMethodName(name: string): IQueryAst;
1328
-
1329
1455
  /**
1330
1456
  * Runs a function with a shared Postgres client for the given pool.
1331
1457
  * Reuses the client if already present in the async context.
@@ -1391,6 +1517,7 @@ declare class RestControllerMetadataStore {
1391
1517
  saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
1392
1518
  saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
1393
1519
  saveMiddlewareMetadata(middlewareMetadata: IMiddlewareMetadata): void;
1520
+ getAllRestControllerConstructors(): IConstructor<any>[];
1394
1521
  getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
1395
1522
  controllerConstructor: IConstructor<any>;
1396
1523
  middlewares: IMiddlewareMetadata[];
@@ -1469,6 +1596,7 @@ declare class SocketControllerMetadataStore {
1469
1596
  saveControllerMetadata(controllerMetadata: ISocketControllerMetadata): void;
1470
1597
  saveSocketEventMetadata(socketEventMetadata: ISocketEventMetadata): void;
1471
1598
  saveHandshakeMiddlewareMetadata(handshakeMetadata: IHandshakeMiddlewareMetadata): void;
1599
+ getAllSocketControllerConstructors(): IConstructor<any>[];
1472
1600
  getSocketControllerInfo(controllerConstructor: IConstructor<any>): {
1473
1601
  controller: ISocketControllerMetadata;
1474
1602
  events: Map<string, ISocketEventMetadata>;
@@ -1478,6 +1606,12 @@ declare class SocketControllerMetadataStore {
1478
1606
 
1479
1607
  declare function runSocketControllers(controllers: IConstructor<any>[]): void;
1480
1608
 
1609
+ declare class PgCronJobRepository extends PgCrudRepository<CronJob> implements ICronJobRepository {
1610
+ constructor(pool: Pool);
1611
+ findDue(date?: Date): Promise<CronJob[]>;
1612
+ findByName(name: string): Promise<CronJob | null>;
1613
+ }
1614
+
1481
1615
  declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepository {
1482
1616
  constructor(pool: Pool);
1483
1617
  findPendingForRunFrom(date: Date, limit: number): Promise<Job[]>;
@@ -1485,9 +1619,32 @@ declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepos
1485
1619
  countRunningByCommand(commandName: string): Promise<number>;
1486
1620
  }
1487
1621
 
1488
- declare class PgCronJobRepository extends PgCrudRepository<CronJob> implements ICronJobRepository {
1622
+ declare class PgTransactionAdapter implements ITransactionAdapter {
1623
+ private pool;
1489
1624
  constructor(pool: Pool);
1625
+ run<T>(fn: () => Promise<T>): Promise<T>;
1626
+ }
1627
+
1628
+ declare class InMemoryJobRepository implements IJobRepository {
1629
+ private items;
1630
+ find(id: string): Promise<Job | null>;
1631
+ findOrThrow(id: string): Promise<Job>;
1632
+ findByIds(ids: string[]): Promise<Job[]>;
1633
+ findAll(): Promise<Job[]>;
1634
+ create(item: Job): Promise<void>;
1635
+ update(item: Job): Promise<void>;
1636
+ delete(item: Job): Promise<void>;
1637
+ findPendingForRunFrom(date: Date, limit: number): Promise<Job[]>;
1638
+ findRunningJobs(): Promise<Job[]>;
1639
+ countRunningByCommand(commandName: string): Promise<number>;
1640
+ }
1641
+
1642
+ declare class InMemoryCronJobRepository implements ICronJobRepository {
1643
+ private items;
1644
+ create(cronJob: CronJob): Promise<void>;
1490
1645
  findDue(date?: Date): Promise<CronJob[]>;
1646
+ findOrThrow(id: string): Promise<CronJob>;
1647
+ update(cronJob: CronJob): Promise<void>;
1491
1648
  findByName(name: string): Promise<CronJob | null>;
1492
1649
  }
1493
1650
 
@@ -1770,14 +1927,14 @@ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMe
1770
1927
  findLastItems(count: number): Promise<ChatItem[]>;
1771
1928
  }
1772
1929
 
1773
- declare class RamChatMemory implements IChatMemory {
1930
+ declare class InMemoryChatMemory implements IChatMemory {
1774
1931
  private memory;
1775
1932
  findLastItems(count: number): Promise<ChatItem[]>;
1776
1933
  create(item: ChatItem): Promise<void>;
1777
1934
  clearMemory(): Promise<void>;
1778
1935
  }
1779
1936
 
1780
- declare class RamChatRepository implements IChatRepository {
1937
+ declare class InMemoryChatRepository implements IChatRepository {
1781
1938
  private items;
1782
1939
  private memories;
1783
1940
  update(chat: Chat): Promise<void>;
@@ -1798,6 +1955,34 @@ declare class WabotChatAdapter implements IChatAdapter {
1798
1955
 
1799
1956
  declare function cmd(): (target: object, propertyKey: string | symbol) => void;
1800
1957
 
1958
+ declare class CmdChannelConfig {
1959
+ readonly route: string;
1960
+ constructor(route: string);
1961
+ }
1962
+
1963
+ interface ICmdChannelHandlers {
1964
+ onMessage: (text: string, reply: (response: {
1965
+ senderName?: string;
1966
+ text: string;
1967
+ }) => void) => Promise<void> | void;
1968
+ }
1969
+ declare class CmdChannelServer {
1970
+ private server;
1971
+ private channels;
1972
+ private client;
1973
+ private buffer;
1974
+ private activeRoute;
1975
+ register(route: string, handlers: ICmdChannelHandlers): void;
1976
+ unregister(route: string): void;
1977
+ private ensureStarted;
1978
+ private shutdown;
1979
+ private handleConnection;
1980
+ private handleData;
1981
+ private handleMessage;
1982
+ private sendToClient;
1983
+ private send;
1984
+ }
1985
+
1801
1986
  declare const cmdChannelName: "CmdChannel";
1802
1987
 
1803
1988
  interface ICmdReceivedMessage extends IReceivedMessage {
@@ -1811,30 +1996,61 @@ interface ICmdChannelMessage extends ICmdReceivedMessage {
1811
1996
 
1812
1997
  declare class CmdChannel implements IChatChannel {
1813
1998
  private auth;
1814
- private chatId;
1815
- private rl;
1999
+ private server;
2000
+ private config;
1816
2001
  static channelName: "CmdChannel";
2002
+ private chatId;
1817
2003
  private callBack;
1818
- constructor(auth: Auth<any>);
2004
+ constructor(auth: Auth<any>, server: CmdChannelServer, config: CmdChannelConfig);
1819
2005
  listen(callback: (message: ICmdChannelMessage) => Promise<void>): void;
1820
2006
  disconnect(): void;
1821
2007
  connect(): void;
2008
+ private routeSlug;
2009
+ private chatIdPath;
2010
+ private authInfoPath;
2011
+ private ensureChatId;
2012
+ private ensureAuthLoaded;
1822
2013
  }
1823
2014
  declare function writeJsonToFile<T>(filename: string, data: T): void;
1824
2015
  declare function readJsonFromFile<T>(filename: string): T | null;
1825
2016
 
1826
- interface ISocketChannelConfig {
1827
- namespace: string;
1828
- handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
2017
+ declare function cmdChannelSocketPath(): string;
2018
+
2019
+ interface ICmdChannelEntry {
2020
+ route: string;
1829
2021
  }
2022
+ type CmdClientMessage = {
2023
+ type: 'hello';
2024
+ } | {
2025
+ type: 'select';
2026
+ route: string;
2027
+ } | {
2028
+ type: 'message';
2029
+ text: string;
2030
+ };
2031
+ type CmdServerMessage = {
2032
+ type: 'channels';
2033
+ list: ICmdChannelEntry[];
2034
+ } | {
2035
+ type: 'selected';
2036
+ route: string;
2037
+ } | {
2038
+ type: 'reply';
2039
+ senderName?: string;
2040
+ text: string;
2041
+ } | {
2042
+ type: 'error';
2043
+ message: string;
2044
+ };
1830
2045
 
1831
- declare class SocketChannelConfig implements ISocketChannelConfig {
1832
- namespace: string;
1833
- handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined;
1834
- constructor(namespace: string, handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined);
2046
+ declare function runCmdClient(): void;
2047
+
2048
+ interface ISocketChannelConfig {
2049
+ namespace: string | ConfigReference<string>;
2050
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
1835
2051
  }
1836
2052
 
1837
- declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
2053
+ declare function socket(config: ISocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
1838
2054
 
1839
2055
  declare const socketChannelName: "SocketChannel";
1840
2056
 
@@ -1847,6 +2063,15 @@ interface ISocketChannelMessage extends ISocketReceivedMessage {
1847
2063
  injectInstances?: [any, any][];
1848
2064
  }
1849
2065
 
2066
+ declare class SocketChannelConfig {
2067
+ namespace: string;
2068
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
2069
+ constructor(config: {
2070
+ namespace: string;
2071
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
2072
+ });
2073
+ }
2074
+
1850
2075
  declare class SocketChannelMessageFile {
1851
2076
  id: string;
1852
2077
  mimeType: string;
@@ -1913,99 +2138,6 @@ declare class TelegramChannel implements IChatChannel {
1913
2138
  disconnect(): void;
1914
2139
  }
1915
2140
 
1916
- interface IWhatsappChannelConfig {
1917
- number: string;
1918
- proxy?: string;
1919
- }
1920
- declare class WhatsappChannelConfig implements IWhatsappChannelConfig {
1921
- number: string;
1922
- constructor(number: string);
1923
- }
1924
-
1925
- declare function whatsApp(config: string | IWhatsappChannelConfig): (target: object, propertyKey: string | symbol) => void;
1926
-
1927
- interface IWhatsAppBusinessNumber {
1928
- id: string;
1929
- number: string;
1930
- }
1931
- interface IWhatsAppBusinessAccount {
1932
- id: string;
1933
- }
1934
- interface IWhatsAppData extends IEntityData {
1935
- slug: string;
1936
- verifyToken: string;
1937
- appSecret: string;
1938
- accessToken: string;
1939
- businessAccount: IWhatsAppBusinessAccount;
1940
- businessNumbers: IWhatsAppBusinessNumber[];
1941
- }
1942
- declare class WhatsApp extends Entity<IWhatsAppData> {
1943
- getVerifyToken(): string;
1944
- getSlug(): string;
1945
- getBusinessAccount(): IWhatsAppBusinessAccount;
1946
- getAppSecret(): string;
1947
- getBusinessNumbers(): {
1948
- id: string;
1949
- number: string;
1950
- }[];
1951
- getAccessToken(): string;
1952
- hasBusinessNumber(number: string): boolean;
1953
- getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
1954
- }
1955
-
1956
- interface IWhatsAppRepository {
1957
- findBySlug(slug: string): Promise<WhatsApp | null>;
1958
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1959
- }
1960
-
1961
- declare class EnvWhatsAppRepository implements IWhatsAppRepository {
1962
- private env;
1963
- constructor(env: Env);
1964
- findBySlug(slug: string): Promise<WhatsApp | null>;
1965
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1966
- private getFromEnvVars;
1967
- }
1968
-
1969
- declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
1970
- constructor(pool: Pool);
1971
- findBySlug(slug: string): Promise<WhatsApp | null>;
1972
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
1973
- }
1974
-
1975
- type IWhatsAppMessageListener = (message: Omit<IChannelMessage, 'reply'>) => Promise<void>;
1976
- interface IListenWhatsAppMessageRequest {
1977
- to: string;
1978
- listener: IWhatsAppMessageListener;
1979
- }
1980
- declare class WhatsAppReceiver {
1981
- connect(): Promise<void>;
1982
- disconnect(): void;
1983
- listenMessage(request: IListenWhatsAppMessageRequest): void;
1984
- }
1985
-
1986
- type IWhatsAppCloudTemplateParameter = {
1987
- type: 'text';
1988
- text: string;
1989
- parameter_name?: string;
1990
- } | {
1991
- type: 'currency';
1992
- currency: {
1993
- fallback_value: string;
1994
- code: string;
1995
- amount_1000: number;
1996
- };
1997
- } | {
1998
- type: 'date_time';
1999
- date_time: {
2000
- fallback_value: string;
2001
- };
2002
- };
2003
- interface IWhatsAppCloudTemplateMessage {
2004
- templateName: string;
2005
- languageCode: string;
2006
- parameters: IWhatsAppCloudTemplateParameter[];
2007
- }
2008
-
2009
2141
  interface IWhatsAppCloudTemplateResponse {
2010
2142
  data: IWhatsAppCloudTemplate[];
2011
2143
  paging: IWhatsAppCloudApiPaging;
@@ -2032,66 +2164,6 @@ interface IWhatsAppCloudApiCursors {
2032
2164
  after: string;
2033
2165
  }
2034
2166
 
2035
- declare class WhatsAppRepository implements IWhatsAppRepository {
2036
- findBySlug(slug: string): Promise<WhatsApp | null>;
2037
- findByBusinessNumber(number: string): Promise<WhatsApp | null>;
2038
- }
2039
-
2040
- interface ISendWhatsAppRequest {
2041
- from: string;
2042
- to: string;
2043
- message: IChatMessage;
2044
- }
2045
- interface ISendWhatsAppTemplateRequest {
2046
- from: string;
2047
- to: string;
2048
- templateMessage: IWhatsAppCloudTemplateMessage;
2049
- senderName: string;
2050
- }
2051
- interface IGetWhatsAppTemplateRequest {
2052
- from: string;
2053
- templateName: string;
2054
- languageCode: string;
2055
- }
2056
- interface IWhatsAppSenderOptions {
2057
- writeChatMemory?: boolean;
2058
- }
2059
- declare class WhatsAppSender {
2060
- protected chatRepository: ChatRepository;
2061
- protected chatResolver: ChatResolver;
2062
- protected whatsAppRepository: WhatsAppRepository;
2063
- constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
2064
- sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
2065
- sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
2066
- protected getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppCloudTemplate | null>;
2067
- protected mapTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
2068
- protected writePrivateChatMemory(message: IChatMessage, to: string): Promise<void>;
2069
- protected replaceTemplateParameters(template: string, data: IWhatsAppCloudTemplateParameter[]): string;
2070
- }
2071
-
2072
- declare const whatsAppChannelName: "WhatsAppChannel";
2073
-
2074
- interface IWhatsAppReceivedMessage extends IReceivedMessage {
2075
- channel: typeof whatsAppChannelName;
2076
- }
2077
-
2078
- interface IWhatsAppChannelMessage extends IWhatsAppReceivedMessage {
2079
- chatConnection: IChatConnection;
2080
- injectInstances?: [any, any][];
2081
- }
2082
-
2083
- declare class WhatsAppChannel implements IChatChannel {
2084
- private config;
2085
- private sender;
2086
- private receiver;
2087
- static channelName: "WhatsAppChannel";
2088
- private logger;
2089
- constructor(config: WhatsappChannelConfig, sender: WhatsAppSender, receiver: WhatsAppReceiver);
2090
- listen(callback: (message: IWhatsAppChannelMessage) => Promise<void>): void;
2091
- connect(): void;
2092
- disconnect(): void;
2093
- }
2094
-
2095
2167
  interface IWhatsAppCloudWebhookPayload {
2096
2168
  object: 'whatsapp_business_account';
2097
2169
  entry: IWhatsAppCloudEntry[];
@@ -2144,95 +2216,84 @@ interface IWhatsAppCloudAudioMessage extends IWhatsAppCloudBaseMessage {
2144
2216
  };
2145
2217
  }
2146
2218
 
2147
- declare class WhatsAppReceiverByCloudApi extends WhatsAppReceiver {
2219
+ type IWhatsAppMessageListener = (message: Omit<IChannelMessage, 'reply'>) => Promise<void>;
2220
+ interface IListenWhatsAppMessageRequest {
2221
+ to: string;
2222
+ listener: IWhatsAppMessageListener;
2223
+ }
2224
+ declare class WhatsAppApiReceiver {
2225
+ connect(): Promise<void>;
2226
+ disconnect(): void;
2227
+ listenMessage(request: IListenWhatsAppMessageRequest): void;
2228
+ }
2229
+
2230
+ declare class WhatsAppReceiverByCloudApi extends WhatsAppApiReceiver {
2148
2231
  private expressProvider;
2149
- private whatsAppRepository;
2150
2232
  private listeners;
2151
2233
  private expressApp;
2152
2234
  private logger;
2153
2235
  private webhookPath;
2154
- constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
2236
+ constructor(expressProvider: ExpressProvider);
2155
2237
  connect(): Promise<void>;
2156
2238
  listenMessage(request: IListenWhatsAppMessageRequest): void;
2157
2239
  protected handlePayload(payload: IWhatsAppCloudWebhookPayload): Promise<void>;
2158
2240
  private emmitMessage;
2159
2241
  }
2160
2242
 
2161
- declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
2162
- private logger;
2163
- constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
2164
- sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
2165
- sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
2166
- protected getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppCloudTemplate | null>;
2167
- }
2168
-
2169
- interface IWhatsAppProxyMessageContent {
2243
+ type IWhatsAppTemplateParameter = {
2244
+ type: 'text';
2170
2245
  text: string;
2246
+ parameter_name?: string;
2247
+ } | {
2248
+ type: 'currency';
2249
+ currency: {
2250
+ fallback_value: string;
2251
+ code: string;
2252
+ amount_1000: number;
2253
+ };
2254
+ } | {
2255
+ type: 'date_time';
2256
+ date_time: {
2257
+ fallback_value: string;
2258
+ };
2259
+ };
2260
+ interface IWhatsAppTemplateData {
2261
+ templateName: string;
2262
+ languageCode: string;
2263
+ parameters: IWhatsAppTemplateParameter[];
2171
2264
  }
2172
-
2173
- interface IWhatsAppProxyMessage {
2265
+ interface ISendWhatsAppMessageReq {
2174
2266
  from: string;
2175
2267
  to: string;
2176
- senderName?: string;
2177
- content: IWhatsAppProxyMessageContent;
2178
- }
2179
-
2180
- declare const WHATSAPP_PROXY_SEND_MESSAGE_EVENT: "sendMessage";
2181
- interface IWhatsAppProxySendMessageEventReq {
2182
- event: typeof WHATSAPP_PROXY_SEND_MESSAGE_EVENT;
2183
- data: IWhatsAppProxyMessage;
2184
- }
2185
- declare const WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT: "listenMessage";
2186
- interface IWhatsAppProxyListenMessageEventReq {
2187
- event: typeof WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT;
2188
- data: IWhatsAppProxyListenMessageEventData;
2268
+ message: IChatMessage;
2189
2269
  }
2190
- interface IWhatsAppProxyListenMessageEventData {
2191
- from?: string[];
2270
+ interface ISendWhatsAppTemplateReq {
2271
+ from: string;
2192
2272
  to: string;
2273
+ templateData: IWhatsAppTemplateData;
2274
+ senderName: string;
2193
2275
  }
2194
- declare const WHATSAPP_MESSAGE_EVENT: "message";
2195
- interface IWhatsAppProxyMessageEventReq {
2196
- event: typeof WHATSAPP_MESSAGE_EVENT;
2197
- data: IWhatsAppProxyMessage;
2198
- }
2199
-
2200
- declare class WhatsAppWabotProxyConnection {
2201
- private baseUrl;
2202
- private socket;
2203
- private apiKey;
2204
- private logger;
2205
- constructor(env: Env);
2206
- getSocket(): Promise<Socket$1>;
2207
- }
2208
-
2209
- declare class WhatsAppReceiverByWabotProxy extends WhatsAppReceiver {
2210
- private connection;
2211
- private loger;
2212
- constructor(connection: WhatsAppWabotProxyConnection);
2213
- connect(): Promise<void>;
2214
- listenMessage(request: IListenWhatsAppMessageRequest): void;
2276
+ interface IWhatsAppSender {
2277
+ sendMessage(request: ISendWhatsAppMessageReq): Promise<void>;
2278
+ sendTemplate(request: ISendWhatsAppTemplateReq): Promise<void>;
2215
2279
  }
2216
2280
 
2217
- declare class WhatsAppSenderByWabotProxy extends WhatsAppSender {
2218
- private wabotDevConnection;
2219
- private logger;
2220
- constructor(wabotDevConnection: WhatsAppWabotProxyConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
2221
- sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
2281
+ declare class WhatsAppApiSender implements IWhatsAppSender {
2282
+ private accessToken;
2283
+ private businessNumberId;
2284
+ constructor(accessToken: string, businessNumberId: string);
2285
+ sendMessage(request: ISendWhatsAppMessageReq): Promise<void>;
2286
+ sendTemplate(request: ISendWhatsAppTemplateReq): Promise<void>;
2222
2287
  }
2223
2288
 
2224
- interface IWhatsAppByWasenderChannelConfig {
2225
- apiKey?: string;
2226
- webhookSecret?: string;
2227
- phoneNumber?: string;
2289
+ interface IWasenderChannelConfig {
2290
+ apiKey?: string | ConfigReference<string>;
2291
+ webhookSecret?: string | ConfigReference<string>;
2292
+ phoneNumber?: string | ConfigReference<string>;
2228
2293
  webhookPath?: string;
2229
- retryOptions?: {
2230
- enabled: boolean;
2231
- maxRetries: number;
2232
- };
2233
2294
  }
2234
2295
 
2235
- declare function whatsAppByWasender(config?: IWhatsAppByWasenderChannelConfig): (target: object, propertyKey: string | symbol) => void;
2296
+ declare function wasender(config?: IWasenderChannelConfig): (target: object, propertyKey: string | symbol) => void;
2236
2297
 
2237
2298
  type IWasenderEvent = IWasenderMessageReceivedEvent | IWasenderQrUpdatedEvent;
2238
2299
  interface IWasenderQrUpdatedEvent {
@@ -2279,7 +2340,7 @@ interface IWasenderDeviceListMetadata {
2279
2340
  recipientTimestamp: string;
2280
2341
  }
2281
2342
 
2282
- declare class WhatsAppByWasenderChannelConfig implements IWhatsAppByWasenderChannelConfig {
2343
+ declare class WasenderChannelConfig {
2283
2344
  readonly apiKey?: string;
2284
2345
  readonly webhookSecret?: string;
2285
2346
  readonly phoneNumber?: string;
@@ -2288,40 +2349,45 @@ declare class WhatsAppByWasenderChannelConfig implements IWhatsAppByWasenderChan
2288
2349
  enabled: boolean;
2289
2350
  maxRetries: number;
2290
2351
  };
2291
- constructor(config: IWhatsAppByWasenderChannelConfig);
2352
+ constructor(config: {
2353
+ apiKey?: string;
2354
+ webhookSecret?: string;
2355
+ phoneNumber?: string;
2356
+ webhookPath?: string;
2357
+ });
2292
2358
  }
2293
2359
 
2294
- interface IWhatsAppByWasenderChatMessage extends IChatMessage {
2360
+ interface IWasenderChatMessage extends IChatMessage {
2295
2361
  metadata: {
2296
2362
  whatsAppNumber: string;
2297
2363
  };
2298
2364
  }
2299
2365
 
2300
- declare const whatsAppByWasenderChannelName: "WhatsAppByWasenderChannel";
2366
+ declare const wasenderChannelName: "WhatsAppByWasenderChannel";
2301
2367
 
2302
- interface IWhatsAppByWasenderReceivedMessage extends IReceivedMessage {
2303
- channel: typeof whatsAppByWasenderChannelName;
2304
- message: IWhatsAppByWasenderChatMessage;
2368
+ interface IWasenderReceivedMessage extends IReceivedMessage {
2369
+ channel: typeof wasenderChannelName;
2370
+ message: IWasenderChatMessage;
2305
2371
  }
2306
2372
 
2307
- interface IWhatsAppByWasenderChannelMessage extends IWhatsAppByWasenderReceivedMessage {
2373
+ interface IWasenderChannelMessage extends IWasenderReceivedMessage {
2308
2374
  chatConnection: IChatConnection;
2309
2375
  injectInstances?: [any, any][];
2310
2376
  }
2311
2377
 
2312
- declare class WhatsAppByWasenderChannel implements IChatChannel {
2378
+ declare class WasenderChannel implements IChatChannel {
2313
2379
  private logger;
2314
2380
  private sender;
2315
2381
  private receiver;
2316
2382
  private phoneNumber;
2317
2383
  static channelName: "WhatsAppByWasenderChannel";
2318
- constructor(config: WhatsAppByWasenderChannelConfig, env: Env);
2319
- listen(callback: (message: IWhatsAppByWasenderChannelMessage) => Promise<void>): void;
2384
+ constructor(config: WasenderChannelConfig, env: Env);
2385
+ listen(callback: (message: IWasenderChannelMessage) => Promise<void>): void;
2320
2386
  connect(): void;
2321
2387
  disconnect(): void;
2322
2388
  }
2323
2389
 
2324
- type IWasenderChannelMessageListener = (message: IWhatsAppByWasenderChatMessage, from: string) => Promise<void>;
2390
+ type IWasenderChannelMessageListener = (message: IWasenderChatMessage, from: string) => Promise<void>;
2325
2391
  declare class WasenderWebhookController {
2326
2392
  private wasender;
2327
2393
  private listener;
@@ -2333,7 +2399,7 @@ declare class WasenderWebhookController {
2333
2399
  private getRawBody;
2334
2400
  }
2335
2401
 
2336
- declare class WhatsAppReceiverByWasender {
2402
+ declare class WasenderReceiver {
2337
2403
  private config;
2338
2404
  private wasender;
2339
2405
  private listener;
@@ -2351,23 +2417,36 @@ declare class WhatsAppReceiverByWasender {
2351
2417
  disconnect(): void;
2352
2418
  }
2353
2419
 
2354
- interface ISendByWasenderRequest {
2355
- from: string;
2356
- to: string;
2357
- message: IChatMessage;
2358
- }
2359
- declare class WhatsAppSenderByWasender {
2420
+ declare class WasenderSender implements IWhatsAppSender {
2360
2421
  private wasender;
2361
2422
  private logger;
2362
2423
  constructor(apiKey: string, retryOptions?: {
2363
2424
  enabled: boolean;
2364
2425
  maxRetries: number;
2365
2426
  });
2366
- send(request: ISendByWasenderRequest): Promise<void>;
2427
+ sendMessage(request: ISendWhatsAppMessageReq): Promise<void>;
2428
+ sendTemplate(request: ISendWhatsAppTemplateReq): Promise<void>;
2367
2429
  }
2368
2430
 
2369
2431
  declare function extractNumberFromWasenderMessageKey(key: IWasenderMessageKey): string;
2370
2432
 
2433
+ declare class WhatsAppSender implements IWhatsAppSender {
2434
+ sendMessage(request: ISendWhatsAppMessageReq): Promise<void>;
2435
+ sendTemplate(request: ISendWhatsAppTemplateReq): Promise<void>;
2436
+ }
2437
+
2438
+ declare class InMemoryLockKey implements ILockKey {
2439
+ private readonly key;
2440
+ private static locks;
2441
+ constructor(key: string | number);
2442
+ run<T>(fn: () => Promise<T>): Promise<T>;
2443
+ tryRun<T>(fn: () => Promise<T>): Promise<T | undefined>;
2444
+ }
2445
+
2446
+ declare class InMemoryLocker implements ILocker {
2447
+ withKey(key: string | number | ILockerKey): ILockKey;
2448
+ }
2449
+
2371
2450
  interface IHtmlModuleOptions {
2372
2451
  url: string;
2373
2452
  title: string;
@@ -2376,4 +2455,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
2376
2455
  new (): {};
2377
2456
  };
2378
2457
 
2379
- export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatAdapterMetadataStore, ChatAdapterRegistry, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatOperator, ChatRepository, ChatResolver, type ClientMap, CmdChannel, type ConfigReference, type ConfigReferenceType, ConfigResolver, Container, ControllerMetadataStore, CronJob, CronJobRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, type ErrorSeverity, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IBuiltQuery, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterDecoratorConfig, type IChatAdapterMetadata, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, type IChatAssociation, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatMessageDocument, type IChatMessageFile, type IChatMessageImage, type IChatMessagesPrivateFile, type IChatMessagesPublicFile, type IChatRepository, type IChatType, type ICmdChannelMessage, type ICmdReceivedMessage, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICronConfig, type ICronJobData, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IErrorHandlersConfig, type IErrorMonitor, type IErrorMonitorContext, type IExtractChatMessageTextOptions, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type ILockKey, type ILocker, type ILockerKey, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModelKind, type IMindsetModelRef, type IMindsetModels, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IPropertyValidatorInfo, type IQueryAst, type IQueryCondition, type IQueryMethodMetadata, type IQueryOrderBy, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type IScheduleAt, type IScheduleDelay, type ISendByWasenderRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelMessage, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type ISocketReceivedMessage, type IStorableData, type ITelegramChannelConfig, type ITelegramChannelMessage, type ITelegramReceivedMessage, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWasenderChannelMessageListener, type IWasenderDeviceListMetadata, type IWasenderEvent, type IWasenderMessageContent, type IWasenderMessageContextInfo, type IWasenderMessageKey, type IWasenderMessageReceivedData, type IWasenderMessageReceivedEvent, type IWasenderQrUpdatedEvent, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppByWasenderChannelConfig, type IWhatsAppByWasenderReceivedMessage, type IWhatsAppChannelMessage, 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 IWhatsAppReceivedMessage, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenRouterChatAdapter, OpenaiChatAdapter, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository, PgJsonRepository, PgJwtRefreshTokenRepository, PgLockKey, PgLocker, PgRepositoryBase, PgRepositoryMetadataStore, PgWhatsAppRepository, type QueryConnector, type QueryOperator, type QueryPrefix, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, type ResolvedConfig, RestControllerMetadataStore, RestRequest, SocketChannel, SocketChannelConfig, SocketChannelMessageFile, SocketChannelReceivedMessage, SocketControllerMetadataStore, SocketServerConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, UnionChatAdapter, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WasenderWebhookController, WhatsApp, WhatsAppByWasenderChannel, WhatsAppByWasenderChannelConfig, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppReceiverByWasender, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppSenderByWasender, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyGuard, apiKeyHandshakeGuard, bool, boolArr, buildQuerySql, chatAdapter, chatBot, chatController, chatItemTypeOptions, cmd, cmdChannelName, command, commandHandler, container, cron, description, errorToPlainObject, extractChatMessageText, extractNumberFromWasenderMessageKey, getClientMap, getPgClient, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isChatMessageEmpty, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isRecord, isRetryableError, isString, jwtGuard, jwtHandshakeGuard, max, middleware, min, mindset, mindsetModule, modelInfo, num, numArr, obj, onDelete, onGet, onPost, onPut, onSocketEvent, parseQueryMethodName, pgJsonRepository, pgStorage, query, readJsonFromFile, resolveConfigReferences, restController, runChatAdapters, runChatControllers, runCommandHandlers, runCronHandlers, runRestControllers, runSocketControllers, safeJsonParse, scoped, setupErrorHandlers, singleton, socket, socketChannelName, socketController, stopCommandHandlers, stopCronHandlers, str, strArr, telegram, telegramChannelName, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsRecord, validateIsString, validateMax, validateMin, validateModel, whatsApp, whatsAppByWasender, whatsAppByWasenderChannelName, whatsAppChannelName, withPgClient, withPgTransaction, writeJsonToFile };
2458
+ export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatAdapterMetadataStore, ChatAdapterRegistry, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatOperator, ChatRepository, ChatResolver, type ClientMap, CmdChannel, CmdChannelConfig, CmdChannelServer, type CmdClientMessage, type CmdServerMessage, type ConfigReference, type ConfigReferenceType, ConfigResolver, Container, ControllerMetadataStore, CronJob, CronJobRepository, CrudRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, type ErrorSeverity, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IBuiltQuery, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterDecoratorConfig, type IChatAdapterMetadata, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, type IChatAssociation, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatMessageDocument, type IChatMessageFile, type IChatMessageImage, type IChatMessagesPrivateFile, type IChatMessagesPublicFile, type IChatRepository, type IChatType, type ICmdChannelEntry, type ICmdChannelHandlers, type ICmdChannelMessage, type ICmdReceivedMessage, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICronConfig, type ICronHandler, type ICronJobData, type ICronJobRepository, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IErrorHandlersConfig, type IErrorMonitor, type IErrorMonitorContext, type IExtractChatMessageTextOptions, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type ILockKey, type ILocker, type ILockerKey, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModelKind, type IMindsetModelRef, type IMindsetModels, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IProjectRunnerConfig, type IPropertyValidatorInfo, type IQueryAst, type IQueryCondition, type IQueryMethodMetadata, type IQueryOrderBy, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRepositoryAdapter, type IRepositoryConfig, type IRepositoryRuntime, type IRestControllerConfig, type IRestControllerMetadata, type IScheduleAt, type IScheduleDelay, type ISendWhatsAppMessageReq, type ISendWhatsAppTemplateReq, type ISocketChannelConfig, type ISocketChannelMessage, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type ISocketReceivedMessage, type IStorableData, type ITelegramChannelConfig, type ITelegramChannelMessage, type ITelegramReceivedMessage, type ITransactionAdapter, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWasenderChannelConfig, type IWasenderChannelMessageListener, type IWasenderDeviceListMetadata, type IWasenderEvent, type IWasenderMessageContent, type IWasenderMessageContextInfo, type IWasenderMessageKey, type IWasenderMessageReceivedData, type IWasenderMessageReceivedEvent, type IWasenderQrUpdatedEvent, type IWasenderReceivedMessage, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppSender, type IWhatsAppTemplateData, type IWhatsAppTemplateParameter, type IchatControllerConfig, InMemoryChatMemory, InMemoryChatRepository, InMemoryCronJobRepository, InMemoryJobRepository, InMemoryLockKey, InMemoryLocker, Job, JobRepository, JobRunner, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, MEMORY_ADAPTER_ID, Mapper, MemoryRepositoryAdapter, MemoryRepositoryExtension, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenRouterChatAdapter, OpenaiChatAdapter, PG_ADAPTER_ID, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository, PgJsonRepositoryAdapter, PgJwtRefreshTokenRepository, PgLockKey, PgLocker, PgRepositoryBase, PgRepositoryBase as PgRepositoryExtension, PgTransactionAdapter, ProjectRunner, type QueryConnector, type QueryOperator, type QueryPrefix, Random, RemoteApiKeyRepository, RepositoryAdapterRegistry, RepositoryMetadataStore, type ResolvedConfig, RestControllerMetadataStore, RestRequest, SocketChannel, SocketChannelConfig, SocketChannelMessageFile, SocketChannelReceivedMessage, SocketControllerMetadataStore, SocketServerConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, TransactionMetadataStore, UnionChatAdapter, ValidationMetadataStore, WabotChatAdapter, WasenderChannel, WasenderChannelConfig, WasenderReceiver, WasenderSender, WasenderWebhookController, WhatsAppApiSender, WhatsAppReceiverByCloudApi, WhatsAppSender, apiKeyGuard, apiKeyHandshakeGuard, bool, boolArr, buildQuerySql, chatAdapter, chatBot, chatController, chatItemTypeOptions, cmd, cmdChannelName, cmdChannelSocketPath, command, commandHandler, container, cronHandler, description, errorToPlainObject, evaluateQueryAst, extractChatMessageText, extractNumberFromWasenderMessageKey, getClientMap, getPgClient, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isChatMessageEmpty, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isRecord, isRetryableError, isString, jwtGuard, jwtHandshakeGuard, max, memoryExtension, middleware, min, mindset, mindsetModule, modelInfo, num, numArr, obj, onDelete, onGet, onPost, onPut, onSocketEvent, parseQueryMethodName, pgExtension, pgStorage, query, queryExtension, readJsonFromFile, repository, resolveConfigReferences, restController, run, runChatAdapters, runChatControllers, runCmdClient, runCommandHandlers, runCronHandlers, runRestControllers, runSocketControllers, safeJsonParse, scoped, setupErrorHandlers, singleton, socket, socketChannelName, socketController, stopCommandHandlers, stopCronHandlers, str, strArr, telegram, telegramChannelName, transaction, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsRecord, validateIsString, validateMax, validateMin, validateModel, wasender, wasenderChannelName, withPgClient, withPgTransaction, writeJsonToFile };