@wabot-dev/framework 0.1.0-beta.2 → 0.1.0-beta.21
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.
- package/dist/src/ai/claude/ClaudeChatBotAdapter.js +113 -0
- package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +12 -13
- package/dist/src/ai/openia/OpenaiChatBotAdapter.js +9 -7
- package/dist/src/channels/cmd/@cmd.js +0 -4
- package/dist/src/channels/cmd/CmdChannel.js +0 -4
- package/dist/src/channels/express/ExpressProvider.js +46 -0
- package/dist/src/channels/http/HttpServerProvider.js +31 -0
- package/dist/src/channels/{socket-io → socket}/@socket.js +0 -4
- package/dist/src/channels/{socket-io → socket}/SocketChannel.js +12 -11
- package/dist/src/channels/socket/SocketServerProvider.js +50 -0
- package/dist/src/channels/telegram/@telegram.js +0 -4
- package/dist/src/channels/telegram/TelegramChannel.js +0 -4
- package/dist/src/channels/wabot/WabotDevConnection.js +57 -0
- package/dist/src/channels/{whatsapp/WhatsAppDevSocketContracts.js → wabot/WabotDevSocketContracts.js} +3 -3
- package/dist/src/channels/whatsapp/@whatsapp.js +0 -4
- package/dist/src/channels/whatsapp/EnvWhatsAppRepository.js +49 -0
- package/dist/src/channels/whatsapp/PgWhatsAppRepository.js +41 -0
- package/dist/src/channels/whatsapp/WhatsApp.js +32 -0
- package/dist/src/channels/whatsapp/WhatsAppChannel.js +33 -32
- package/dist/src/channels/whatsapp/{WhatsAppConnection.js → WhatsAppReceiver.js} +4 -6
- package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +32 -0
- package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +63 -0
- package/dist/src/channels/whatsapp/WhatsAppRepository.js +10 -0
- package/dist/src/channels/whatsapp/WhatsAppSender.js +107 -20
- package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +118 -0
- package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +56 -0
- package/dist/src/chatbot/ChatBotAdapter.js +1 -5
- package/dist/src/chatbot/metadata/@chatBot.js +0 -5
- package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +0 -5
- package/dist/src/controller/metadata/ControllerMetadataStore.js +0 -2
- package/dist/src/controller/metadata/controller/@chatController.js +0 -2
- package/dist/src/core/{Persistent.js → Entity.js} +24 -9
- package/dist/src/core/IMessageContext.js +0 -2
- package/dist/src/core/Storable.js +8 -0
- package/dist/src/core/chat/Chat.js +2 -2
- package/dist/src/core/chat/ChatItem.js +2 -2
- package/dist/src/core/user/User.js +2 -2
- package/dist/src/env/Env.js +39 -0
- package/dist/src/error/CustomError.js +15 -0
- package/dist/src/index.d.ts +539 -240
- package/dist/src/index.js +65 -34
- package/dist/src/mindset/MindsetOperator.js +1 -3
- package/dist/src/mindset/metadata/MindsetMetadataStore.js +0 -2
- package/dist/src/mindset/metadata/mindsets/@mindset.js +0 -2
- package/dist/src/mindset/metadata/modules/@mindsetModule.js +0 -2
- package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -2
- package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -2
- package/dist/src/pre-made/module/html/HtmlModule.js +70 -0
- package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -2
- package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +1 -7
- package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +0 -5
- package/dist/src/pre-made/repository/chat/ram/RamChatRepository.js +1 -1
- package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -5
- package/dist/src/repository/pg/PgCrudRepository.js +13 -3
- package/dist/src/repository/pg/PgRepositoryBase.js +2 -2
- package/dist/src/rest-controller/metadata/@get.js +19 -0
- package/dist/src/rest-controller/metadata/@middleware.js +16 -0
- package/dist/src/rest-controller/metadata/@post.js +19 -0
- package/dist/src/rest-controller/metadata/@restController.js +15 -0
- package/dist/src/rest-controller/metadata/RestControllerMetadataStore.js +50 -0
- package/dist/src/rest-controller/runRestControllers.js +93 -0
- package/dist/src/server/prepareChatContainer.js +6 -6
- package/dist/src/server/runChannel.js +2 -10
- package/dist/src/server/runServer.js +0 -43
- package/dist/src/validation/metadata/@isBoolean.js +17 -0
- package/dist/src/validation/metadata/@isDate.js +17 -0
- package/dist/src/validation/metadata/@isModel.js +18 -0
- package/dist/src/validation/metadata/@isNotEmpty.js +17 -0
- package/dist/src/validation/metadata/@isNumber.js +17 -0
- package/dist/src/validation/metadata/@isOptional.js +17 -0
- package/dist/src/validation/metadata/@isPresent.js +17 -0
- package/dist/src/validation/metadata/@isString.js +17 -0
- package/dist/src/validation/metadata/@max.js +18 -0
- package/dist/src/validation/metadata/@min.js +18 -0
- package/dist/src/validation/metadata/ValidationMetadataStore.js +70 -0
- package/dist/src/validation/validate.js +11 -0
- package/dist/src/validation/validators/validateIsBoolean.js +12 -0
- package/dist/src/validation/validators/validateIsDate.js +16 -0
- package/dist/src/validation/validators/validateIsNotEmpty.js +12 -0
- package/dist/src/validation/validators/validateIsNumber.js +12 -0
- package/dist/src/validation/validators/validateIsOptional.js +5 -0
- package/dist/src/validation/validators/validateIsPresent.js +12 -0
- package/dist/src/validation/validators/validateIsString.js +12 -0
- package/dist/src/validation/validators/validateMax.js +17 -0
- package/dist/src/validation/validators/validateMin.js +17 -0
- package/dist/src/validation/validators/validateModel.js +34 -0
- package/package.json +5 -6
- package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +0 -69
- package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +0 -39
- package/dist/src/controller/express/Express.js +0 -5
- package/dist/src/controller/socket.io/SocketIO.js +0 -5
- package/dist/src/env/WabotEnv.js +0 -21
- package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
- package/dist/src/pre-made/repository/chat/sqlite/SqliteChatMemory.js +0 -23
- package/dist/src/pre-made/repository/chat/sqlite/SqliteChatRepository.js +0 -30
- package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +0 -23
- package/dist/src/repository/sqlite/SqliteCrudRepository.js +0 -85
- package/dist/src/repository/sqlite/SqlitePersistentMapper.js +0 -17
- /package/dist/src/channels/{socket-io → socket}/SocketChannelConfig.js +0 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import InjectionToken from 'tsyringe/dist/typings/providers/injection-token';
|
|
2
2
|
import DependencyContainer, { PreResolutionInterceptorCallback, PostResolutionInterceptorCallback } from 'tsyringe/dist/typings/types/dependency-container';
|
|
3
3
|
import InterceptionOptions from 'tsyringe/dist/typings/types/interceptor-options';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { Server } from 'socket.io';
|
|
7
|
-
|
|
4
|
+
import { Server } from 'http';
|
|
5
|
+
import { Express, Request, Response } from 'express';
|
|
6
|
+
import { Server as Server$1 } from 'socket.io';
|
|
7
|
+
import { Pool } from 'pg';
|
|
8
|
+
import { Socket } from 'socket.io-client';
|
|
8
9
|
import * as tsyringe from 'tsyringe';
|
|
9
10
|
import { DependencyContainer as DependencyContainer$1 } from 'tsyringe';
|
|
10
11
|
export { DependencyContainer } from 'tsyringe';
|
|
11
|
-
import { Pool } from 'pg';
|
|
12
|
-
import { Database } from 'sqlite';
|
|
13
|
-
import sqlite3 from 'sqlite3';
|
|
14
12
|
|
|
15
13
|
interface IMindsetFunctionConfig {
|
|
16
14
|
description: string;
|
|
@@ -28,33 +26,58 @@ interface IMindsetFunctionDecoration {
|
|
|
28
26
|
decorationConfig: any;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
type IPrimitive = null | number | string | boolean | undefined;
|
|
30
|
+
type IStorableData = {
|
|
31
|
+
[key: string]: IPrimitive | IPrimitive[] | IStorableData | IStorableData[];
|
|
32
|
+
};
|
|
33
|
+
declare class Storable<D extends IStorableData> {
|
|
34
|
+
protected data: D;
|
|
35
|
+
constructor(data: D);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface IEntityData extends IStorableData {
|
|
32
39
|
id?: string;
|
|
33
40
|
createdAt?: number | null;
|
|
34
41
|
discardedAt?: number | null;
|
|
35
42
|
}
|
|
36
|
-
declare class
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
declare class Entity<D extends IEntityData> extends Storable<D> {
|
|
44
|
+
get id(): string;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use id
|
|
47
|
+
*/
|
|
39
48
|
getId(): string;
|
|
49
|
+
get createdAt(): Date;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated use createdAt
|
|
52
|
+
*/
|
|
40
53
|
getCreatedAt(): Date;
|
|
41
|
-
update(newData: D): void;
|
|
54
|
+
update(newData: Omit<D, 'id' | 'createdAt' | 'discardedAt'>): void;
|
|
42
55
|
wasCreated(): boolean;
|
|
43
56
|
validate(): void;
|
|
44
57
|
discard(): void;
|
|
45
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Should use IEntityData
|
|
61
|
+
*/
|
|
62
|
+
interface IPersistentData extends IEntityData {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Should use Entity
|
|
66
|
+
*/
|
|
67
|
+
declare class Persistent<D extends IPersistentData> extends Entity<D> {
|
|
68
|
+
}
|
|
46
69
|
|
|
47
70
|
type IChatType = 'PRIVATE' | 'GROUP';
|
|
48
|
-
interface IChatConnection {
|
|
71
|
+
interface IChatConnection extends IStorableData {
|
|
49
72
|
chatType: IChatType;
|
|
50
73
|
channelName: string;
|
|
51
74
|
id: string;
|
|
52
75
|
}
|
|
53
|
-
interface IChatData extends
|
|
76
|
+
interface IChatData extends IEntityData {
|
|
54
77
|
type: IChatType;
|
|
55
78
|
connections: IChatConnection[];
|
|
56
79
|
}
|
|
57
|
-
declare class Chat extends
|
|
80
|
+
declare class Chat extends Entity<IChatData> {
|
|
58
81
|
constructor(data: IChatData);
|
|
59
82
|
isPrivate(): boolean;
|
|
60
83
|
isGroup(): boolean;
|
|
@@ -64,24 +87,24 @@ declare class Chat extends Persistent<IChatData> {
|
|
|
64
87
|
validate(): void;
|
|
65
88
|
}
|
|
66
89
|
|
|
67
|
-
interface IChatDocument {
|
|
90
|
+
interface IChatDocument extends IStorableData {
|
|
68
91
|
}
|
|
69
92
|
|
|
70
|
-
interface IChatImage {
|
|
93
|
+
interface IChatImage extends IStorableData {
|
|
71
94
|
}
|
|
72
95
|
|
|
73
|
-
interface IUserConnection {
|
|
96
|
+
interface IUserConnection extends IStorableData {
|
|
74
97
|
channelName: string;
|
|
75
98
|
id: string;
|
|
76
99
|
}
|
|
77
|
-
interface IUserData extends
|
|
100
|
+
interface IUserData extends IEntityData {
|
|
78
101
|
shortName: string;
|
|
79
102
|
connections: IUserConnection[];
|
|
80
103
|
keyValueData: {
|
|
81
104
|
[key: string]: string;
|
|
82
105
|
};
|
|
83
106
|
}
|
|
84
|
-
declare class User extends
|
|
107
|
+
declare class User extends Entity<IUserData> {
|
|
85
108
|
constructor(data: IUserData);
|
|
86
109
|
hasConnection(connection: IUserConnection): boolean;
|
|
87
110
|
getValue(key: string): string;
|
|
@@ -89,7 +112,7 @@ declare class User extends Persistent<IUserData> {
|
|
|
89
112
|
addConnection(connection: IUserConnection): void;
|
|
90
113
|
}
|
|
91
114
|
|
|
92
|
-
interface IChatMessage {
|
|
115
|
+
interface IChatMessage extends IStorableData {
|
|
93
116
|
text?: string;
|
|
94
117
|
documents?: IChatDocument[];
|
|
95
118
|
images?: IChatImage[];
|
|
@@ -120,12 +143,9 @@ type ISystemFunctionCallItem = {
|
|
|
120
143
|
type: 'FUNCTION_CALL';
|
|
121
144
|
content: IChatFunctionCall;
|
|
122
145
|
};
|
|
123
|
-
type IChatItemData =
|
|
124
|
-
id?: string;
|
|
125
|
-
createdAt?: number;
|
|
126
|
-
} & (ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem);
|
|
146
|
+
type IChatItemData = IEntityData & (ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem);
|
|
127
147
|
type IChatItemType = IChatItemData['type'];
|
|
128
|
-
declare class ChatItem extends
|
|
148
|
+
declare class ChatItem extends Entity<IChatItemData> {
|
|
129
149
|
getType(): "BOT_MESSAGE" | "CONNECTION_MESSAGE" | "FUNCTION_CALL";
|
|
130
150
|
getContent(): IChatMessage | IConnectionChatMessage | IChatFunctionCall;
|
|
131
151
|
getData(): IChatItemData;
|
|
@@ -174,11 +194,6 @@ declare class MessageContext implements IMessageContext {
|
|
|
174
194
|
constructor(message: IConnectionChatMessage, chat: Chat, user: User | null);
|
|
175
195
|
}
|
|
176
196
|
|
|
177
|
-
interface IReversibleMapper<T1, T2> {
|
|
178
|
-
map(input: T1): T2;
|
|
179
|
-
rev(input: T2): T1;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
197
|
type IConstructor<T> = new (...args: any[]) => T;
|
|
183
198
|
|
|
184
199
|
interface IMindsetIdentity {
|
|
@@ -228,8 +243,6 @@ interface IMindsetModuleDecoration {
|
|
|
228
243
|
decorationConfig: any;
|
|
229
244
|
}
|
|
230
245
|
|
|
231
|
-
declare function isOptional(): PropertyDecorator;
|
|
232
|
-
|
|
233
246
|
interface IParamConfig {
|
|
234
247
|
name?: string;
|
|
235
248
|
optional?: boolean;
|
|
@@ -369,19 +382,29 @@ declare class ChatBot implements IChatBot {
|
|
|
369
382
|
protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
|
|
370
383
|
}
|
|
371
384
|
|
|
385
|
+
declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
|
|
386
|
+
private deepSeek;
|
|
387
|
+
private model;
|
|
388
|
+
constructor(mindset: MindsetOperator);
|
|
389
|
+
validateEnvVariables(envVariables: (string | undefined)[]): void;
|
|
390
|
+
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
391
|
+
private mapChatItems;
|
|
392
|
+
}
|
|
393
|
+
|
|
372
394
|
declare class OpenaiChatBotAdapter extends ChatBotAdapter {
|
|
373
395
|
private openai;
|
|
374
396
|
private model;
|
|
397
|
+
private logger;
|
|
375
398
|
constructor(mindset: MindsetOperator);
|
|
376
399
|
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
377
400
|
private mapChatItems;
|
|
378
401
|
}
|
|
379
402
|
|
|
380
|
-
declare class
|
|
381
|
-
private
|
|
403
|
+
declare class ClaudeChatBotAdapter extends ChatBotAdapter {
|
|
404
|
+
private anthropic;
|
|
382
405
|
private model;
|
|
406
|
+
private logger;
|
|
383
407
|
constructor(mindset: MindsetOperator);
|
|
384
|
-
validateEnvVariables(envVariables: (string | undefined)[]): void;
|
|
385
408
|
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
386
409
|
private mapChatItems;
|
|
387
410
|
}
|
|
@@ -437,10 +460,6 @@ declare class ControllerMetadataStore {
|
|
|
437
460
|
} | null;
|
|
438
461
|
}
|
|
439
462
|
|
|
440
|
-
declare const ExpressApp: unique symbol;
|
|
441
|
-
|
|
442
|
-
declare const SocketIoApp: unique symbol;
|
|
443
|
-
|
|
444
463
|
declare class CmdChannel implements IChatChannel {
|
|
445
464
|
private chatResolver;
|
|
446
465
|
private userResolver;
|
|
@@ -451,6 +470,63 @@ declare class CmdChannel implements IChatChannel {
|
|
|
451
470
|
connect(): void;
|
|
452
471
|
}
|
|
453
472
|
|
|
473
|
+
declare class HttpServerProvider {
|
|
474
|
+
server: Server | null;
|
|
475
|
+
private listening;
|
|
476
|
+
private logger;
|
|
477
|
+
getHttpServer(): Server;
|
|
478
|
+
listen(): void;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
declare class ExpressProvider {
|
|
482
|
+
private httpServerProvider;
|
|
483
|
+
private expressApp;
|
|
484
|
+
private logger;
|
|
485
|
+
constructor(httpServerProvider: HttpServerProvider);
|
|
486
|
+
getExpress(): Express;
|
|
487
|
+
listen(): void;
|
|
488
|
+
private createExpress;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
interface ISocketChannelConfig {
|
|
492
|
+
channel: string;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
declare class SocketChannelConfig implements ISocketChannelConfig {
|
|
496
|
+
channel: string;
|
|
497
|
+
constructor(channel: string);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
|
|
501
|
+
|
|
502
|
+
declare class SocketServerProvider {
|
|
503
|
+
private httpServerProvider;
|
|
504
|
+
private socketServer;
|
|
505
|
+
private logger;
|
|
506
|
+
constructor(httpServerProvider: HttpServerProvider);
|
|
507
|
+
getSocketServer(): Server$1;
|
|
508
|
+
listen(): void;
|
|
509
|
+
private createSocketServer;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
interface ISocketChannelReceivedMessage {
|
|
513
|
+
chatId: string;
|
|
514
|
+
userId: string;
|
|
515
|
+
senderName: string;
|
|
516
|
+
text: string;
|
|
517
|
+
}
|
|
518
|
+
declare class SocketChannel implements IChatChannel {
|
|
519
|
+
private config;
|
|
520
|
+
private socketServerProvider;
|
|
521
|
+
private chatResolver;
|
|
522
|
+
private userResolver;
|
|
523
|
+
private callBack;
|
|
524
|
+
private server;
|
|
525
|
+
constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider, chatResolver: ChatResolver, userResolver: UserResolver);
|
|
526
|
+
listen(callback: (message: IReceivedMessage) => void): void;
|
|
527
|
+
connect(): void;
|
|
528
|
+
}
|
|
529
|
+
|
|
454
530
|
interface ITelegramChannelConfig {
|
|
455
531
|
botToken: string;
|
|
456
532
|
}
|
|
@@ -482,9 +558,64 @@ declare class WhatsappChannelConfig implements IWhatsappChannelConfig {
|
|
|
482
558
|
|
|
483
559
|
declare function whatsapp(config: IWhatsappChannelConfig): (target: object, propertyKey: string | symbol) => void;
|
|
484
560
|
|
|
561
|
+
interface IWhatsAppBusinessNumber extends IStorableData {
|
|
562
|
+
id: string;
|
|
563
|
+
number: string;
|
|
564
|
+
}
|
|
565
|
+
interface IWhatsAppBusinessAccount extends IStorableData {
|
|
566
|
+
id: string;
|
|
567
|
+
}
|
|
568
|
+
interface IWhatsAppData extends IEntityData {
|
|
569
|
+
slug: string;
|
|
570
|
+
verifyToken: string;
|
|
571
|
+
appSecret: string;
|
|
572
|
+
accessToken: string;
|
|
573
|
+
businessAccount: IWhatsAppBusinessAccount;
|
|
574
|
+
businessNumbers: IWhatsAppBusinessNumber[];
|
|
575
|
+
}
|
|
576
|
+
declare class WhatsApp extends Entity<IWhatsAppData> {
|
|
577
|
+
getVerifyToken(): string;
|
|
578
|
+
getSlug(): string;
|
|
579
|
+
getBusinessAccount(): IWhatsAppBusinessAccount;
|
|
580
|
+
getAppSecret(): string;
|
|
581
|
+
getBusinessNumbers(): IWhatsAppBusinessNumber[];
|
|
582
|
+
getAccessToken(): string;
|
|
583
|
+
hasBusinessNumber(number: string): boolean;
|
|
584
|
+
getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
interface IWhatsAppRepository {
|
|
588
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
589
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
type IEnvType = 'development' | 'staging' | 'testing' | 'production';
|
|
593
|
+
declare class Env {
|
|
594
|
+
private envType;
|
|
595
|
+
constructor();
|
|
596
|
+
isDevelopment(): boolean;
|
|
597
|
+
isProduction(): boolean;
|
|
598
|
+
isTesting(): boolean;
|
|
599
|
+
requireString(varName: string, options?: {
|
|
600
|
+
default?: string;
|
|
601
|
+
}): string;
|
|
602
|
+
requireNumber(varName: string, options?: {
|
|
603
|
+
default?: number;
|
|
604
|
+
}): number;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
declare class EnvWhatsAppRepository implements IWhatsAppRepository {
|
|
608
|
+
private env;
|
|
609
|
+
constructor(env: Env);
|
|
610
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
611
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
612
|
+
private getFromEnvVars;
|
|
613
|
+
}
|
|
614
|
+
|
|
485
615
|
type IWhatsAppTemplateParameter = {
|
|
486
616
|
type: 'text';
|
|
487
617
|
text: string;
|
|
618
|
+
parameter_name?: string;
|
|
488
619
|
} | {
|
|
489
620
|
type: 'currency';
|
|
490
621
|
currency: {
|
|
@@ -504,12 +635,30 @@ interface IWhatsAppTemplateMessage {
|
|
|
504
635
|
parameters: IWhatsAppTemplateParameter[];
|
|
505
636
|
}
|
|
506
637
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
638
|
+
interface IWhatsAppTemplateResponse {
|
|
639
|
+
data: IWhatsAppTemplate[];
|
|
640
|
+
paging: IWhatsAppApiPaging;
|
|
641
|
+
}
|
|
642
|
+
interface IWhatsAppTemplate {
|
|
643
|
+
name: string;
|
|
644
|
+
parameter_format: 'POSITIONAL' | 'OTHER';
|
|
645
|
+
components: IWhatsAppTemplateComponent[];
|
|
646
|
+
language: string;
|
|
647
|
+
status: string;
|
|
648
|
+
category: string;
|
|
649
|
+
id: string;
|
|
650
|
+
}
|
|
651
|
+
interface IWhatsAppTemplateComponent {
|
|
652
|
+
type: 'HEADER' | 'BODY' | 'FOOTER';
|
|
653
|
+
format?: 'TEXT';
|
|
654
|
+
text?: string;
|
|
655
|
+
}
|
|
656
|
+
interface IWhatsAppApiPaging {
|
|
657
|
+
cursors: IWhatsAppApiCursors;
|
|
658
|
+
}
|
|
659
|
+
interface IWhatsAppApiCursors {
|
|
660
|
+
before: string;
|
|
661
|
+
after: string;
|
|
513
662
|
}
|
|
514
663
|
|
|
515
664
|
interface IWhatsAppWebhookPayload {
|
|
@@ -564,12 +713,70 @@ interface IAudioMessage extends IBaseMessage {
|
|
|
564
713
|
};
|
|
565
714
|
}
|
|
566
715
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
716
|
+
interface ICrudRepository<T> {
|
|
717
|
+
find(id: string): Promise<T | null>;
|
|
718
|
+
findOrThrow(id: string): Promise<T>;
|
|
719
|
+
findAll(id: string): Promise<T[]>;
|
|
720
|
+
create(item: T): Promise<void>;
|
|
721
|
+
update(item: T): Promise<void>;
|
|
722
|
+
discard(item: T): Promise<void>;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
type IPgRepositoryConfig<P extends Entity<IEntityData>> = {
|
|
726
|
+
schema?: string;
|
|
727
|
+
table: string;
|
|
728
|
+
constructor: IConstructor<P>;
|
|
729
|
+
add?: {
|
|
730
|
+
columns: {
|
|
731
|
+
[column: string]: {
|
|
732
|
+
type: string;
|
|
733
|
+
value: (item: P) => boolean | number | string | null | Date;
|
|
734
|
+
};
|
|
735
|
+
};
|
|
736
|
+
};
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
declare class PgRepositoryBase<P extends Entity<IEntityData>> {
|
|
740
|
+
protected pool: Pool;
|
|
741
|
+
protected config: IPgRepositoryConfig<any>;
|
|
742
|
+
private tableIsCreated;
|
|
743
|
+
protected schema: string;
|
|
744
|
+
protected table: string;
|
|
745
|
+
protected columnsList: string[];
|
|
746
|
+
protected columnsAndTypes: string;
|
|
747
|
+
protected columns: string;
|
|
748
|
+
protected vars: string;
|
|
749
|
+
protected updates: string;
|
|
750
|
+
addColumns: {
|
|
751
|
+
[columns: string]: {
|
|
752
|
+
type: string;
|
|
753
|
+
value: (item: P) => number | boolean | string | null | Date;
|
|
754
|
+
};
|
|
755
|
+
};
|
|
756
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<any>);
|
|
757
|
+
protected values(item: P): (string | number | boolean | Date | null)[];
|
|
758
|
+
protected exec(sql: string, values: any[]): Promise<void>;
|
|
759
|
+
protected query(sql: string, values: any[]): Promise<any[]>;
|
|
760
|
+
protected connect(): Promise<Pool>;
|
|
761
|
+
protected ensureTable(): Promise<void>;
|
|
762
|
+
protected ensureColumns(): Promise<void>;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
766
|
+
protected readonly config: IPgRepositoryConfig<P>;
|
|
767
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
768
|
+
find(id: string): Promise<P | null>;
|
|
769
|
+
findOrThrow(id: string): Promise<P>;
|
|
770
|
+
findAll(): Promise<P[]>;
|
|
771
|
+
create(item: P): Promise<void>;
|
|
772
|
+
update(item: P): Promise<void>;
|
|
773
|
+
discard(item: P): Promise<void>;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
|
|
777
|
+
constructor(pool: Pool);
|
|
778
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
779
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
573
780
|
}
|
|
574
781
|
|
|
575
782
|
declare class Logger {
|
|
@@ -584,123 +791,129 @@ declare class Logger {
|
|
|
584
791
|
private log;
|
|
585
792
|
}
|
|
586
793
|
|
|
587
|
-
|
|
794
|
+
type IWhatsAppMessageListener = (message: IConnectionChatMessage) => Promise<void>;
|
|
795
|
+
interface IListenWhatsAppMessageRequest {
|
|
796
|
+
to: string;
|
|
797
|
+
listener: IWhatsAppMessageListener;
|
|
798
|
+
}
|
|
799
|
+
declare abstract class WhatsAppReceiver {
|
|
588
800
|
protected logger: Logger;
|
|
589
801
|
private listeners;
|
|
590
802
|
constructor(logger: Logger);
|
|
591
|
-
abstract
|
|
592
|
-
|
|
593
|
-
abstract sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
594
|
-
listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
|
|
803
|
+
abstract connect(): Promise<void>;
|
|
804
|
+
listenMessage(request: IListenWhatsAppMessageRequest): void;
|
|
595
805
|
protected handlePayload(payload: IWhatsAppWebhookPayload): Promise<void>;
|
|
596
806
|
private emmitMessage;
|
|
597
807
|
}
|
|
598
808
|
|
|
599
|
-
declare class
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
private devToken?;
|
|
603
|
-
private connected;
|
|
604
|
-
constructor();
|
|
605
|
-
sendWhatsApp(businessNumber: string, to: string, chatMessage: IChatMessage): Promise<void>;
|
|
606
|
-
sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
607
|
-
connect(): void;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
declare class WhatsAppProdConnection implements IWhatsAppConnection {
|
|
611
|
-
private express;
|
|
612
|
-
constructor(express: Express);
|
|
613
|
-
listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
|
|
614
|
-
sendWhatsApp(businessNumber: string, to: string, replyMessage: IChatMessage): Promise<void>;
|
|
615
|
-
sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
616
|
-
connect(): void;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
declare class WhatsAppChannel implements IChatChannel {
|
|
620
|
-
private config;
|
|
621
|
-
private chatResolver;
|
|
622
|
-
private userResolver;
|
|
623
|
-
private wabotEnv;
|
|
624
|
-
private logger;
|
|
625
|
-
private whatsAppConection;
|
|
626
|
-
constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, wabotEnv: WabotEnv, devConnection: WhatsAppDevConnection, prodConnection: WhatsAppProdConnection);
|
|
627
|
-
listen(callback: (message: IReceivedMessage) => void): void;
|
|
628
|
-
connect(): void;
|
|
809
|
+
declare class WhatsAppRepository implements IWhatsAppRepository {
|
|
810
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
811
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
629
812
|
}
|
|
630
813
|
|
|
631
|
-
|
|
632
|
-
readonly DEV_WATSAPP_WEBHOOK: "dev-whatsapp-webhook";
|
|
633
|
-
};
|
|
634
|
-
declare const devWhatsappEmitEvent: {
|
|
635
|
-
readonly DEV_CONNECTION: "dev-connection";
|
|
636
|
-
readonly DEV_SEND_WHATSAPP: "dev-send-whatsapp";
|
|
637
|
-
readonly DEV_SEND_WHATSAPP_TEMPLATE: "dev-send-whatsapp-template";
|
|
638
|
-
};
|
|
639
|
-
interface IDevConnectionRequest {
|
|
640
|
-
token: string;
|
|
641
|
-
}
|
|
642
|
-
interface IDevSendWhatsappRequest {
|
|
814
|
+
interface ISendWhatsAppRequest {
|
|
643
815
|
from: string;
|
|
644
816
|
to: string;
|
|
645
817
|
message: IChatMessage;
|
|
646
818
|
}
|
|
647
|
-
interface
|
|
819
|
+
interface ISendWhatsAppTemplateRequest {
|
|
648
820
|
from: string;
|
|
649
821
|
to: string;
|
|
650
|
-
|
|
822
|
+
templateMessage: IWhatsAppTemplateMessage;
|
|
823
|
+
senderName: string;
|
|
651
824
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
constructor(wabotEnv: WabotEnv, devConnection: WhatsAppDevConnection, prodConnection: WhatsAppProdConnection);
|
|
657
|
-
send(businessNumber: string, to: string, message: IChatMessage): Promise<void>;
|
|
658
|
-
sendTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
825
|
+
interface IGetWhatsAppTemplateRequest {
|
|
826
|
+
from: string;
|
|
827
|
+
templateName: string;
|
|
828
|
+
languageCode: string;
|
|
659
829
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
channel: string;
|
|
830
|
+
interface IWhatsAppSenderOptions {
|
|
831
|
+
writeChatMemory?: boolean;
|
|
663
832
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
833
|
+
declare class WhatsAppSender {
|
|
834
|
+
protected logger: Logger;
|
|
835
|
+
protected chatRepository: ChatRepository;
|
|
836
|
+
protected chatResolver: ChatResolver;
|
|
837
|
+
protected whatsAppRepository: WhatsAppRepository;
|
|
838
|
+
constructor(logger: Logger, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
839
|
+
protected handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
840
|
+
protected handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
841
|
+
protected handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
842
|
+
sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
843
|
+
sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
844
|
+
getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
845
|
+
protected resolveTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
|
|
846
|
+
protected writePrivateChatMemory(message: IChatMessage, to: string): Promise<void>;
|
|
847
|
+
private replaceTemplateParameters;
|
|
668
848
|
}
|
|
669
849
|
|
|
670
|
-
declare
|
|
671
|
-
|
|
672
|
-
declare class SocketChannel implements IChatChannel {
|
|
850
|
+
declare class WhatsAppChannel implements IChatChannel {
|
|
673
851
|
private config;
|
|
674
|
-
private server;
|
|
675
852
|
private chatResolver;
|
|
676
853
|
private userResolver;
|
|
677
|
-
private
|
|
678
|
-
|
|
854
|
+
private sender;
|
|
855
|
+
private receiver;
|
|
856
|
+
private logger;
|
|
857
|
+
constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, sender: WhatsAppSender, receiver: WhatsAppReceiver);
|
|
679
858
|
listen(callback: (message: IReceivedMessage) => void): void;
|
|
680
859
|
connect(): void;
|
|
681
860
|
}
|
|
682
861
|
|
|
683
|
-
declare
|
|
862
|
+
declare class WabotDevConnection {
|
|
863
|
+
private devProxy;
|
|
864
|
+
private devProxySocket;
|
|
865
|
+
private devToken;
|
|
866
|
+
private logger;
|
|
867
|
+
static isTokenAvailable(): boolean;
|
|
868
|
+
constructor();
|
|
869
|
+
getSocket(): Promise<Socket>;
|
|
870
|
+
}
|
|
684
871
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
chatRepository: IConstructor<IChatRepository>;
|
|
690
|
-
chatBotAdapter: IConstructor<IChatBotAdapter>;
|
|
872
|
+
declare class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
|
|
873
|
+
private wabotDevConnection;
|
|
874
|
+
constructor(wabotDevConnection: WabotDevConnection);
|
|
875
|
+
connect(): Promise<void>;
|
|
691
876
|
}
|
|
692
|
-
declare function runChannel(props: IrunChannelProps): void;
|
|
693
877
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
878
|
+
declare class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
|
|
879
|
+
private expressProvider;
|
|
880
|
+
private whatsAppRepository;
|
|
881
|
+
private expressApp;
|
|
882
|
+
private webhookPath;
|
|
883
|
+
constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
|
|
884
|
+
connect(): Promise<void>;
|
|
698
885
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
886
|
+
|
|
887
|
+
declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
|
|
888
|
+
constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
889
|
+
handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
890
|
+
handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
891
|
+
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
|
|
895
|
+
private wabotDevConnection;
|
|
896
|
+
constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
897
|
+
handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
898
|
+
handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
899
|
+
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
interface ICustomErrorData {
|
|
903
|
+
message: string;
|
|
904
|
+
humanMessage?: string;
|
|
905
|
+
code?: string;
|
|
906
|
+
httpCode?: number;
|
|
907
|
+
cause?: Error;
|
|
908
|
+
info?: any;
|
|
909
|
+
}
|
|
910
|
+
declare class CustomError extends Error {
|
|
911
|
+
humanMessage?: string;
|
|
912
|
+
code?: string;
|
|
913
|
+
httpCode?: number;
|
|
914
|
+
info?: any;
|
|
915
|
+
constructor(data: ICustomErrorData);
|
|
702
916
|
}
|
|
703
|
-
declare function runServer(config: IServerConfig): void;
|
|
704
917
|
|
|
705
918
|
declare class SendOneTimePasswordRequest {
|
|
706
919
|
fromEmail: string;
|
|
@@ -756,92 +969,14 @@ declare class RegisterUserModule {
|
|
|
756
969
|
registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
|
|
757
970
|
}
|
|
758
971
|
|
|
759
|
-
interface
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
create(item: T): Promise<void>;
|
|
763
|
-
update(item: T): Promise<void>;
|
|
764
|
-
discard(item: T): Promise<void>;
|
|
972
|
+
interface IHtmlModuleOptions {
|
|
973
|
+
url: string;
|
|
974
|
+
title: string;
|
|
765
975
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
schema?: string;
|
|
769
|
-
table: string;
|
|
770
|
-
constructor: IConstructor<P>;
|
|
771
|
-
add?: {
|
|
772
|
-
columns: {
|
|
773
|
-
[column: string]: {
|
|
774
|
-
type: string;
|
|
775
|
-
value: (item: P) => boolean | number | string | null | Date;
|
|
776
|
-
};
|
|
777
|
-
};
|
|
778
|
-
};
|
|
976
|
+
declare function HtmlModule(options: IHtmlModuleOptions): {
|
|
977
|
+
new (): {};
|
|
779
978
|
};
|
|
780
979
|
|
|
781
|
-
declare class PgRepositoryBase<P extends Persistent> {
|
|
782
|
-
protected pool: Pool;
|
|
783
|
-
protected config: IPgRepositoryConfig<any>;
|
|
784
|
-
private tableIsCreated;
|
|
785
|
-
schema: string;
|
|
786
|
-
table: string;
|
|
787
|
-
columnsList: string[];
|
|
788
|
-
columnsAndTypes: string;
|
|
789
|
-
columns: string;
|
|
790
|
-
vars: string;
|
|
791
|
-
updates: string;
|
|
792
|
-
addColumns: {
|
|
793
|
-
[columns: string]: {
|
|
794
|
-
type: string;
|
|
795
|
-
value: (item: P) => number | boolean | string | null | Date;
|
|
796
|
-
};
|
|
797
|
-
};
|
|
798
|
-
constructor(pool: Pool, config: IPgRepositoryConfig<any>);
|
|
799
|
-
values(item: P): (string | number | boolean | Date | null)[];
|
|
800
|
-
protected exec(sql: string, values: any[]): Promise<void>;
|
|
801
|
-
protected query(sql: string, values: any[]): Promise<any[]>;
|
|
802
|
-
protected connect(): Promise<Pool>;
|
|
803
|
-
protected ensureTable(): Promise<void>;
|
|
804
|
-
protected ensureColumns(): Promise<void>;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
808
|
-
protected readonly config: IPgRepositoryConfig<P>;
|
|
809
|
-
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
810
|
-
find(id: string): Promise<P | null>;
|
|
811
|
-
findAll(): Promise<P[]>;
|
|
812
|
-
create(item: P): Promise<void>;
|
|
813
|
-
update(item: P): Promise<void>;
|
|
814
|
-
discard(item: P): Promise<void>;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
interface ISqliteRecord {
|
|
818
|
-
id: string;
|
|
819
|
-
data: string;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
declare class SqliteCrudRepository<P extends Persistent> implements ICrudRepository<P> {
|
|
823
|
-
private table;
|
|
824
|
-
private dbPath;
|
|
825
|
-
private mapper;
|
|
826
|
-
private tableCreated;
|
|
827
|
-
constructor(table: string, dbPath: string, mapper: IReversibleMapper<P, string>);
|
|
828
|
-
find(id: string): Promise<P | null>;
|
|
829
|
-
findAll(): Promise<P[]>;
|
|
830
|
-
create(item: P): Promise<void>;
|
|
831
|
-
update(item: P): Promise<void>;
|
|
832
|
-
discard(item: P): Promise<void>;
|
|
833
|
-
protected getDb(): Promise<Database<sqlite3.Database, sqlite3.Statement>>;
|
|
834
|
-
protected createTable(db: Database<sqlite3.Database, sqlite3.Statement>): Promise<void>;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
declare class SqlitePersistentMapper<P extends Persistent> implements IReversibleMapper<P, string> {
|
|
838
|
-
private ctor;
|
|
839
|
-
constructor(ctor: IConstructor<P>);
|
|
840
|
-
map(input: P): string;
|
|
841
|
-
rev(input: string): P;
|
|
842
|
-
}
|
|
843
|
-
declare function sqliteMapperFor<P extends Persistent>(ctor: IConstructor<P>): SqlitePersistentMapper<P>;
|
|
844
|
-
|
|
845
980
|
declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
|
|
846
981
|
constructor(pool: Pool);
|
|
847
982
|
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
@@ -854,12 +989,6 @@ declare class RamUserRepository implements IUserRepository {
|
|
|
854
989
|
update(chat: User): Promise<void>;
|
|
855
990
|
}
|
|
856
991
|
|
|
857
|
-
declare class SqliteUserRepository extends SqliteCrudRepository<User> implements IUserRepository {
|
|
858
|
-
constructor();
|
|
859
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
860
|
-
static getDbPath(): string;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
992
|
declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
|
|
864
993
|
constructor(pool: Pool);
|
|
865
994
|
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
@@ -872,19 +1001,6 @@ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMe
|
|
|
872
1001
|
findLastItems(count: number): Promise<ChatItem[]>;
|
|
873
1002
|
}
|
|
874
1003
|
|
|
875
|
-
declare class SqliteChatMemory extends SqliteCrudRepository<ChatItem> implements IChatMemory {
|
|
876
|
-
constructor(chatId: string);
|
|
877
|
-
findLastItems(count: number): Promise<ChatItem[]>;
|
|
878
|
-
static getDbPath(chatId: string): string;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
declare class SqliteChatRepository extends SqliteCrudRepository<Chat> implements IChatRepository {
|
|
882
|
-
constructor();
|
|
883
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
884
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
885
|
-
static getDbPath(): string;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
1004
|
declare class RamChatMemory implements IChatMemory {
|
|
889
1005
|
private memory;
|
|
890
1006
|
findLastItems(count: number): Promise<ChatItem[]>;
|
|
@@ -901,4 +1017,187 @@ declare class RamChatRepository implements IChatRepository {
|
|
|
901
1017
|
private getMemory;
|
|
902
1018
|
}
|
|
903
1019
|
|
|
904
|
-
|
|
1020
|
+
interface IGetConfig {
|
|
1021
|
+
path?: string;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
declare function get(config?: IGetConfig): (target: object, propertyKey: string | symbol) => void;
|
|
1025
|
+
|
|
1026
|
+
interface IMiddleware {
|
|
1027
|
+
handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
declare function middleware(middlewareConstructor: IConstructor<IMiddleware>): (target: object, propertyKey: string | symbol) => void;
|
|
1031
|
+
|
|
1032
|
+
interface IPostConfig {
|
|
1033
|
+
path?: string;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
declare function post(config?: string | IPostConfig): (target: object, propertyKey: string | symbol) => void;
|
|
1037
|
+
|
|
1038
|
+
interface IRestControllerConfig {
|
|
1039
|
+
path: string;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
declare function restController(config: string | IRestControllerConfig): (target: IConstructor<any>) => void;
|
|
1043
|
+
|
|
1044
|
+
interface IEndPointMetadata {
|
|
1045
|
+
method: 'get' | 'post';
|
|
1046
|
+
path?: string;
|
|
1047
|
+
controllerConstructor: IConstructor<any>;
|
|
1048
|
+
functionName: string;
|
|
1049
|
+
paramsTypes: any[];
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
interface IMiddlewareMetadata {
|
|
1053
|
+
controllerConstructor: IConstructor<any>;
|
|
1054
|
+
functionName: string;
|
|
1055
|
+
middlewareConstructor: IConstructor<IMiddleware>;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
interface IRestControllerMetadata {
|
|
1059
|
+
controllerConstructor: IConstructor<any>;
|
|
1060
|
+
path: string;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
declare class RestControllerMetadataStore {
|
|
1064
|
+
private endPoints;
|
|
1065
|
+
private middlewares;
|
|
1066
|
+
private restControllers;
|
|
1067
|
+
saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
|
|
1068
|
+
saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
|
|
1069
|
+
saveMiddlewareMetadata(middlewareMetadata: IMiddlewareMetadata): void;
|
|
1070
|
+
getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
|
|
1071
|
+
middlewares: IMiddlewareMetadata[];
|
|
1072
|
+
controller: IRestControllerMetadata;
|
|
1073
|
+
method: "get" | "post";
|
|
1074
|
+
path?: string;
|
|
1075
|
+
controllerConstructor: IConstructor<any>;
|
|
1076
|
+
functionName: string;
|
|
1077
|
+
paramsTypes: any[];
|
|
1078
|
+
}[];
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
declare function runRestControllers(controllers: IConstructor<any>[]): void;
|
|
1082
|
+
|
|
1083
|
+
declare function prepareChatContainer(container: DependencyContainer$1, context: IMessageContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer$1>;
|
|
1084
|
+
|
|
1085
|
+
interface IrunChannelProps {
|
|
1086
|
+
channel: IConstructor<IChatChannel>;
|
|
1087
|
+
channelConfig?: object;
|
|
1088
|
+
mindset: IConstructor<IMindset>;
|
|
1089
|
+
chatRepository: IConstructor<IChatRepository>;
|
|
1090
|
+
chatBotAdapter: IConstructor<IChatBotAdapter>;
|
|
1091
|
+
}
|
|
1092
|
+
declare function runChannel(props: IrunChannelProps): void;
|
|
1093
|
+
|
|
1094
|
+
interface IServerProvider<T, ST extends T> {
|
|
1095
|
+
replace: IConstructor<T>;
|
|
1096
|
+
with: IConstructor<ST>;
|
|
1097
|
+
singleton?: true;
|
|
1098
|
+
}
|
|
1099
|
+
interface IServerConfig {
|
|
1100
|
+
controllers: IConstructor<any>[];
|
|
1101
|
+
providers?: IServerProvider<unknown, unknown>[];
|
|
1102
|
+
}
|
|
1103
|
+
declare function runServer(config: IServerConfig): void;
|
|
1104
|
+
|
|
1105
|
+
declare function isBoolean(): (target: object, propertyKey: string | symbol) => void;
|
|
1106
|
+
|
|
1107
|
+
declare function isDate(): (target: object, propertyKey: string | symbol) => void;
|
|
1108
|
+
|
|
1109
|
+
declare function isModel(model: IConstructor<any>): (target: object, propertyKey: string | symbol) => void;
|
|
1110
|
+
|
|
1111
|
+
declare function isNotEmpty(): (target: object, propertyKey: string | symbol) => void;
|
|
1112
|
+
|
|
1113
|
+
declare function isNumber(): (target: object, propertyKey: string | symbol) => void;
|
|
1114
|
+
|
|
1115
|
+
declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
|
|
1116
|
+
|
|
1117
|
+
declare function isPresent(): (target: object, propertyKey: string | symbol) => void;
|
|
1118
|
+
|
|
1119
|
+
declare function isString(): (target: object, propertyKey: string | symbol) => void;
|
|
1120
|
+
|
|
1121
|
+
declare function max(limit: any): (target: object, propertyKey: string | symbol) => void;
|
|
1122
|
+
|
|
1123
|
+
declare function min(limit: any): (target: object, propertyKey: string | symbol) => void;
|
|
1124
|
+
|
|
1125
|
+
interface IValidationError {
|
|
1126
|
+
description: string;
|
|
1127
|
+
}
|
|
1128
|
+
interface IModelValidationError extends IValidationError {
|
|
1129
|
+
properties: {
|
|
1130
|
+
[key: string]: string[];
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
type IValidationResult<V> = {
|
|
1134
|
+
value: V;
|
|
1135
|
+
error?: undefined;
|
|
1136
|
+
} | {
|
|
1137
|
+
value?: undefined;
|
|
1138
|
+
error: IValidationError;
|
|
1139
|
+
};
|
|
1140
|
+
type IModelValidationResult<V> = {
|
|
1141
|
+
value: V;
|
|
1142
|
+
error?: undefined;
|
|
1143
|
+
} | {
|
|
1144
|
+
value?: undefined;
|
|
1145
|
+
error: IModelValidationError;
|
|
1146
|
+
};
|
|
1147
|
+
type IValidator = (value: any, options: any) => IValidationResult<any>;
|
|
1148
|
+
interface IPropertyValidatorInfo {
|
|
1149
|
+
propertyName: string;
|
|
1150
|
+
validator: IValidator;
|
|
1151
|
+
validatorOptions?: any;
|
|
1152
|
+
}
|
|
1153
|
+
type IModelValidatorsInfo<V> = {
|
|
1154
|
+
modelConstructor: IConstructor<V>;
|
|
1155
|
+
properties: {
|
|
1156
|
+
[prop: string]: {
|
|
1157
|
+
isOptional?: boolean;
|
|
1158
|
+
validators?: IPropertyValidatorInfo[];
|
|
1159
|
+
} | undefined;
|
|
1160
|
+
};
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
interface IValidatorMetadata {
|
|
1164
|
+
modelConstructor: IConstructor<any>;
|
|
1165
|
+
propertyName: string;
|
|
1166
|
+
validator: IValidator;
|
|
1167
|
+
validatorOptions?: any;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
declare class ValidationMetadataStore {
|
|
1171
|
+
private validators;
|
|
1172
|
+
saveValidatorMetadata(validatorMetadata: IValidatorMetadata): void;
|
|
1173
|
+
getModelValidatorsInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
|
|
1174
|
+
private getConstructorPropertiesValidatorsInfo;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
declare function validateIsBoolean(value: any): IValidationResult<boolean>;
|
|
1178
|
+
|
|
1179
|
+
declare function validateIsDate(value: any): IValidationResult<Date>;
|
|
1180
|
+
|
|
1181
|
+
declare function validateIsNotEmpty(value: any): IValidationResult<any>;
|
|
1182
|
+
|
|
1183
|
+
declare function validateIsNumber(value: any): IValidationResult<number>;
|
|
1184
|
+
|
|
1185
|
+
declare function validateIsString(value: any): IValidationResult<string>;
|
|
1186
|
+
|
|
1187
|
+
interface IValidateMaxOptions {
|
|
1188
|
+
limit: any;
|
|
1189
|
+
}
|
|
1190
|
+
declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
|
|
1191
|
+
|
|
1192
|
+
interface IValidateMinOptions {
|
|
1193
|
+
limit: any;
|
|
1194
|
+
}
|
|
1195
|
+
declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
|
|
1196
|
+
|
|
1197
|
+
declare function validateIsPresent(value: any): IValidationResult<any>;
|
|
1198
|
+
|
|
1199
|
+
declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
|
|
1200
|
+
|
|
1201
|
+
declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
|
|
1202
|
+
|
|
1203
|
+
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatBotAdapter, CmdChannel, Container, ControllerMetadataStore, CustomError, DeepSeekChatBotAdapter, EmailService, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEmailService, type IEndPointMetadata, type IEntityData, type IEnvType, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplate, type IWhatsAppTemplateComponent, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppTemplateResponse, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, type IrunChannelProps, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, RegisterUserModule, RegisterUserWithEmailRequest, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, container, get, inject, injectable, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, max, middleware, min, mindset, mindsetFunction, mindsetModule, param, post, prepareChatContainer, restController, runChannel, runRestControllers, runServer, singleton, socket, telegram, validate, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
|