@wabot-dev/framework 0.1.0-beta.9 → 0.2.0-beta.1
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/addon/async/pg/PgJobRepository.js +26 -0
- package/dist/src/addon/auth/api-key/@apiKeyConnectionGuard.js +16 -0
- package/dist/src/addon/auth/api-key/@apiKeyGuard.js +17 -0
- package/dist/src/addon/auth/api-key/ApiKey.js +45 -0
- package/dist/src/addon/auth/api-key/ApiKeyConnectionGuardMiddleware.js +57 -0
- package/dist/src/addon/auth/api-key/ApiKeyGuardMiddleware.js +45 -0
- package/dist/src/addon/auth/api-key/ApiKeyRepository.js +22 -0
- package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +53 -0
- package/dist/src/addon/auth/api-key/RemoteApiKeyRepository.js +62 -0
- package/dist/src/addon/auth/jwt/@jwtConnectionGuard.js +16 -0
- package/dist/src/addon/auth/jwt/@jwtGuard.js +17 -0
- package/dist/src/addon/auth/jwt/Jwt.js +53 -0
- package/dist/src/addon/auth/jwt/JwtAccessAndRefreshTokenDto.js +20 -0
- package/dist/src/addon/auth/jwt/JwtConfig.js +28 -0
- package/dist/src/addon/auth/jwt/JwtConnectionGuardMiddleware.js +57 -0
- package/dist/src/addon/auth/jwt/JwtGuardMiddleware.js +45 -0
- package/dist/src/addon/auth/jwt/JwtRefreshToken.js +56 -0
- package/dist/src/addon/auth/jwt/JwtRefreshTokenRepository.js +25 -0
- package/dist/src/addon/auth/jwt/JwtSigner.js +36 -0
- package/dist/src/addon/auth/jwt/JwtTokenDto.js +22 -0
- package/dist/src/addon/auth/jwt/PgJwtRefreshTokenRepository.js +21 -0
- package/dist/src/addon/chat-bot/anthropic/AnthropicChatAdapter.js +135 -0
- package/dist/src/addon/chat-bot/deepseek/DeepSeekChatAdapter.js +137 -0
- package/dist/src/addon/chat-bot/google/GoogleChatAdapter.js +128 -0
- package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +117 -0
- package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatMemory.js +6 -4
- package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatRepository.js +6 -5
- package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatRepository.js +2 -2
- package/dist/src/addon/chat-bot/wabot/WabotChatAdapter.js +41 -0
- package/dist/src/addon/chat-controller/cmd/@cmd.js +24 -0
- package/dist/src/addon/chat-controller/cmd/CmdChannel.js +91 -0
- package/dist/src/{channels → addon/chat-controller}/socket/@socket.js +10 -4
- package/dist/src/{channels → addon/chat-controller}/socket/SocketChannel.js +9 -23
- package/dist/src/{channels → addon/chat-controller}/socket/SocketChannelConfig.js +1 -1
- package/dist/src/{channels → addon/chat-controller}/telegram/@telegram.js +10 -4
- package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannel.js +4 -22
- package/dist/src/addon/chat-controller/whatsapp/@whatsApp.js +26 -0
- package/dist/src/{channels → addon/chat-controller}/whatsapp/EnvWhatsAppRepository.js +3 -3
- package/dist/src/{channels → addon/chat-controller}/whatsapp/PgWhatsAppRepository.js +2 -2
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsApp.js +2 -4
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannel.js +6 -18
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiver.js +10 -0
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSender.js +15 -39
- package/dist/src/addon/chat-controller/whatsapp/cloud-api/WhatsAppReceiverByCloudApi.js +97 -0
- package/dist/src/{channels/whatsapp → addon/chat-controller/whatsapp/cloud-api}/WhatsAppSenderByCloudApi.js +27 -20
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppProxyContracts.js +5 -0
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppReceiverByWabotProxy.js +65 -0
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppSenderByWabotProxy.js +61 -0
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppWabotProxyConnection.js +45 -0
- package/dist/src/{pre-made/module → addon/mindset}/html/HtmlModule.js +7 -7
- package/dist/src/core/auth/Auth.js +33 -0
- package/dist/src/core/{Persistent.js → entity/Entity.js} +24 -12
- package/dist/src/core/env/Env.js +39 -0
- package/dist/src/core/error/CustomError.js +15 -0
- package/dist/src/core/injection/index.js +4 -0
- package/dist/src/core/mapper/Mapper.js +42 -0
- package/dist/src/core/password/Password.js +30 -0
- package/dist/src/core/random/Random.js +65 -0
- package/dist/src/core/storable/Storable.js +8 -0
- package/dist/src/core/validation/core/validateArray.js +51 -0
- package/dist/src/core/validation/core/validateModel.js +36 -0
- package/dist/src/{validation/metadata/@isNumber.js → core/validation/metadata/@isArray.js} +5 -4
- package/dist/src/{validation/metadata/@isDate.js → core/validation/metadata/@isModel.js} +5 -4
- package/dist/src/{validation → core/validation}/metadata/@isOptional.js +1 -1
- package/dist/src/core/validation/metadata/ValidationMetadataStore.js +98 -0
- package/dist/src/core/validation/modelInfo.js +9 -0
- package/dist/src/{validation/validateModel2.js → core/validation/validate.js} +3 -3
- package/dist/src/{validation/metadata → core/validation/validators/is-boolean}/@isBoolean.js +3 -3
- package/dist/src/core/validation/validators/is-date/@isDate.js +17 -0
- package/dist/src/core/validation/validators/is-in/@isIn.js +18 -0
- package/dist/src/core/validation/validators/is-in/validateIsIn.js +12 -0
- package/dist/src/{validation/metadata → core/validation/validators/is-not-empty}/@isNotEmpty.js +3 -3
- package/dist/src/core/validation/validators/is-number/@isNumber.js +17 -0
- package/dist/src/{validation/metadata → core/validation/validators/is-present}/@isPresent.js +3 -3
- package/dist/src/{validation/metadata → core/validation/validators/is-string}/@isString.js +3 -3
- package/dist/src/{validation/metadata → core/validation/validators/max}/@max.js +3 -3
- package/dist/src/{validation/metadata → core/validation/validators/min}/@min.js +3 -3
- package/dist/src/feature/async/@command.js +11 -0
- package/dist/src/feature/async/@commandHandler.js +12 -0
- package/dist/src/feature/async/Async.js +38 -0
- package/dist/src/feature/async/Command.js +9 -0
- package/dist/src/feature/async/CommandMetadataStore.js +38 -0
- package/dist/src/feature/async/Job.js +27 -0
- package/dist/src/feature/async/JobRepository.js +31 -0
- package/dist/src/feature/async/JobRunner.js +48 -0
- package/dist/src/feature/async/JobsEventsHub.js +36 -0
- package/dist/src/feature/async/runCommandHandlers.js +29 -0
- package/dist/src/{core/chat → feature/chat-bot}/Chat.js +2 -2
- package/dist/src/feature/chat-bot/ChatAdapter.js +7 -0
- package/dist/src/feature/chat-bot/ChatBot.js +73 -0
- package/dist/src/feature/chat-bot/ChatItem.js +24 -0
- package/dist/src/feature/chat-bot/ChatMemory.js +10 -0
- package/dist/src/{core/chat/repository/IChatRepository.js → feature/chat-bot/ChatRepository.js} +2 -8
- package/dist/src/feature/chat-bot/IChatItem.js +3 -0
- package/dist/src/{chatbot → feature/chat-bot}/metadata/@chatBot.js +1 -1
- package/dist/src/{chatbot → feature/chat-bot}/metadata/ChatBotMetadataStore.js +1 -1
- package/dist/src/{controller/channel → feature/chat-controller}/ChatResolver.js +6 -4
- package/dist/src/{controller → feature/chat-controller}/metadata/ControllerMetadataStore.js +1 -1
- package/dist/src/{controller → feature/chat-controller}/metadata/controller/@chatController.js +1 -1
- package/dist/src/feature/chat-controller/runChatControllers.js +83 -0
- package/dist/src/{channels → feature}/express/ExpressProvider.js +2 -4
- package/dist/src/{channels → feature}/http/HttpServerProvider.js +2 -2
- package/dist/src/{mindset → feature/mindset}/IMindset.js +6 -0
- package/dist/src/feature/mindset/MindsetOperator.js +180 -0
- package/dist/src/{mindset → feature/mindset}/metadata/MindsetMetadataStore.js +1 -1
- package/dist/src/{mindset → feature/mindset}/metadata/functions/@mindsetFunction.js +1 -1
- package/dist/src/{mindset → feature/mindset}/metadata/mindsets/@mindset.js +1 -1
- package/dist/src/{mindset → feature/mindset}/metadata/modules/@mindsetModule.js +1 -2
- package/dist/src/{mindset → feature/mindset}/metadata/params/@param.js +1 -1
- package/dist/src/feature/money/Money.js +61 -0
- package/dist/src/feature/money/MoneyDto.js +22 -0
- package/dist/src/{repository → feature}/pg/PgCrudRepository.js +24 -10
- package/dist/src/{repository → feature}/pg/PgRepositoryBase.js +2 -2
- package/dist/src/feature/rest-controller/injection-tokens.js +4 -0
- package/dist/src/{rest-controller/metadata/@post.js → feature/rest-controller/metadata/@middleware.js} +5 -8
- package/dist/src/feature/rest-controller/metadata/@onDelete.js +7 -0
- package/dist/src/feature/rest-controller/metadata/@onGet.js +7 -0
- package/dist/src/feature/rest-controller/metadata/@onPost.js +7 -0
- package/dist/src/feature/rest-controller/metadata/@onPut.js +7 -0
- package/dist/src/{rest-controller → feature/rest-controller}/metadata/@restController.js +2 -2
- package/dist/src/{rest-controller → feature/rest-controller}/metadata/RestControllerMetadataStore.js +14 -1
- package/dist/src/{rest-controller/metadata/@get.js → feature/rest-controller/metadata/methodDecorator.js} +5 -5
- package/dist/src/feature/rest-controller/runRestControllers.js +103 -0
- package/dist/src/{channels → feature}/socket/SocketServerProvider.js +2 -2
- package/dist/src/feature/socket-controller/metadata/@connectionMiddleware.js +16 -0
- package/dist/src/feature/socket-controller/metadata/@socketConnection.js +18 -0
- package/dist/src/feature/socket-controller/metadata/@socketController.js +15 -0
- package/dist/src/feature/socket-controller/metadata/@socketEvent.js +18 -0
- package/dist/src/feature/socket-controller/metadata/SocketControllerMetadataStore.js +65 -0
- package/dist/src/feature/socket-controller/runSocketControllers.js +99 -0
- package/dist/src/index.d.ts +1219 -718
- package/dist/src/index.js +147 -102
- package/package.json +8 -2
- package/dist/src/_virtual/_commonjsHelpers.js +0 -5
- package/dist/src/_virtual/cjs.js +0 -7
- package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +0 -107
- package/dist/src/ai/openia/OpenaiChatBotAdapter.js +0 -88
- package/dist/src/channels/cmd/@cmd.js +0 -18
- package/dist/src/channels/cmd/CmdChannel.js +0 -73
- package/dist/src/channels/wabot/WabotDevConnection.js +0 -57
- package/dist/src/channels/wabot/WabotDevSocketContracts.js +0 -10
- package/dist/src/channels/whatsapp/@whatsapp.js +0 -20
- package/dist/src/channels/whatsapp/WhatsAppReceiver.js +0 -59
- package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +0 -32
- package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +0 -63
- package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +0 -61
- package/dist/src/chatbot/ChatBot.js +0 -51
- package/dist/src/chatbot/ChatBotAdapter.js +0 -72
- package/dist/src/controller/channel/UserResolver.js +0 -21
- package/dist/src/core/IMessageContext.js +0 -12
- package/dist/src/core/chat/ChatItem.js +0 -15
- package/dist/src/core/chat/repository/IChatMemory.js +0 -10
- package/dist/src/core/user/IUserRepository.js +0 -19
- package/dist/src/core/user/User.js +0 -26
- package/dist/src/env/WabotEnv.js +0 -27
- package/dist/src/injection/index.js +0 -4
- package/dist/src/mindset/MindsetOperator.js +0 -101
- package/dist/src/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +0 -90
- package/dist/src/node_modules/deepmerge/dist/cjs.js +0 -142
- package/dist/src/node_modules/dom-serializer/lib/esm/foreignNames.js +0 -102
- package/dist/src/node_modules/dom-serializer/lib/esm/index.js +0 -186
- package/dist/src/node_modules/domelementtype/lib/esm/index.js +0 -53
- package/dist/src/node_modules/domhandler/lib/esm/index.js +0 -148
- package/dist/src/node_modules/domhandler/lib/esm/node.js +0 -334
- package/dist/src/node_modules/entities/lib/esm/decode.js +0 -458
- package/dist/src/node_modules/entities/lib/esm/decode_codepoint.js +0 -62
- package/dist/src/node_modules/entities/lib/esm/escape.js +0 -99
- package/dist/src/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -8
- package/dist/src/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -8
- package/dist/src/node_modules/html-to-text/lib/html-to-text.js +0 -2147
- package/dist/src/node_modules/htmlparser2/lib/esm/Parser.js +0 -491
- package/dist/src/node_modules/htmlparser2/lib/esm/Tokenizer.js +0 -928
- package/dist/src/node_modules/htmlparser2/lib/esm/index.js +0 -18
- package/dist/src/node_modules/leac/lib/leac.js +0 -3
- package/dist/src/node_modules/parseley/lib/parseley.js +0 -270
- package/dist/src/node_modules/peberminta/lib/core.js +0 -171
- package/dist/src/node_modules/selderee/lib/selderee.js +0 -380
- package/dist/src/pre-made/module/authentication/AuthenticationModule.js +0 -97
- package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -25
- package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -25
- package/dist/src/pre-made/module/register-user/RegisterUserModule.js +0 -56
- package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -25
- package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -33
- package/dist/src/pre-made/repository/user/ram/RamUserRepository.js +0 -27
- package/dist/src/pre-made/service/EmailService.js +0 -13
- package/dist/src/pre-made/service/OtpService.js +0 -14
- package/dist/src/rest-controller/runRestControllers.js +0 -74
- package/dist/src/server/prepareChatContainer.js +0 -43
- package/dist/src/server/runChannel.js +0 -27
- package/dist/src/server/runServer.js +0 -40
- package/dist/src/validation/metadata/@validable.js +0 -14
- package/dist/src/validation/metadata/ValidationMetadataStore.js +0 -55
- package/dist/src/validation/validators/validateModel.js +0 -47
- /package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatMemory.js +0 -0
- /package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannelConfig.js +0 -0
- /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannelConfig.js +0 -0
- /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppRepository.js +0 -0
- /package/dist/src/{injection → core/injection}/Container.js +0 -0
- /package/dist/src/{logger → core/logger}/Logger.js +0 -0
- /package/dist/src/{validation/validators → core/validation/core}/validateIsOptional.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/is-boolean}/validateIsBoolean.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/is-date}/validateIsDate.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/is-not-empty}/validateIsNotEmpty.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/is-number}/validateIsNumber.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/is-present}/validateIsPresent.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/is-string}/validateIsString.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/max}/validateMax.js +0 -0
- /package/dist/src/{validation/validators → core/validation/validators/min}/validateMin.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/functions/decoratorNames.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/mindsets/decoratorNames.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/modules/decoratorNames.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/params/decoratorNames.js +0 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -1,183 +1,437 @@
|
|
|
1
|
+
import * as tsyringe from 'tsyringe';
|
|
2
|
+
import { DependencyContainer as DependencyContainer$1 } from 'tsyringe';
|
|
3
|
+
export { DependencyContainer } from 'tsyringe';
|
|
1
4
|
import InjectionToken from 'tsyringe/dist/typings/providers/injection-token';
|
|
2
5
|
import DependencyContainer, { PreResolutionInterceptorCallback, PostResolutionInterceptorCallback } from 'tsyringe/dist/typings/types/dependency-container';
|
|
3
6
|
import InterceptionOptions from 'tsyringe/dist/typings/types/interceptor-options';
|
|
4
7
|
import { Server } from 'http';
|
|
5
|
-
import { Express } from 'express';
|
|
6
|
-
import
|
|
7
|
-
import { Socket } from 'socket.io-client';
|
|
8
|
+
import { Express, Request, Response } from 'express';
|
|
9
|
+
import * as big_js from 'big.js';
|
|
8
10
|
import { Pool } from 'pg';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
|
|
11
|
+
import { Server as Server$1, Socket } from 'socket.io';
|
|
12
|
+
import { Algorithm } from 'jsonwebtoken';
|
|
13
|
+
import { Socket as Socket$1 } from 'socket.io-client';
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
type IPrimitive = null | number | string | boolean | undefined;
|
|
16
|
+
type IStorableData = {
|
|
17
|
+
[key: string]: IPrimitive | IPrimitive[] | IStorableData | IStorableData[];
|
|
18
|
+
};
|
|
19
|
+
declare class Storable<D extends IStorableData> {
|
|
20
|
+
protected data: D;
|
|
21
|
+
constructor(data: D);
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
declare
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
constructor: Function;
|
|
25
|
-
paramsTypes: Function[];
|
|
26
|
-
decorationConfig: any;
|
|
24
|
+
declare class Auth<D extends IStorableData> {
|
|
25
|
+
private authInfo;
|
|
26
|
+
require(): D;
|
|
27
|
+
assign(authInfo: D): void;
|
|
28
|
+
override(authInfo: D): void;
|
|
29
|
+
clear(): void;
|
|
30
|
+
isAssigned(): boolean;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
interface
|
|
33
|
+
interface IEntityData extends IStorableData {
|
|
30
34
|
id?: string;
|
|
31
35
|
createdAt?: number | null;
|
|
32
36
|
discardedAt?: number | null;
|
|
33
37
|
}
|
|
34
|
-
declare class
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
declare class Entity<D extends IEntityData> extends Storable<D> {
|
|
39
|
+
get id(): string;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated use id
|
|
42
|
+
*/
|
|
37
43
|
getId(): string;
|
|
44
|
+
get createdAt(): Date;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use createdAt
|
|
47
|
+
*/
|
|
38
48
|
getCreatedAt(): Date;
|
|
39
|
-
update(newData: D): void;
|
|
49
|
+
update(newData: Omit<D, 'id' | 'createdAt' | 'discardedAt'>): void;
|
|
40
50
|
wasCreated(): boolean;
|
|
41
51
|
validate(): void;
|
|
42
|
-
discard(): void;
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
channelName: string;
|
|
49
|
-
id: string;
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Should use IEntityData
|
|
55
|
+
*/
|
|
56
|
+
interface IPersistentData extends IEntityData {
|
|
50
57
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Should use Entity
|
|
60
|
+
*/
|
|
61
|
+
declare class Persistent<D extends IPersistentData> extends Entity<D> {
|
|
54
62
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
|
|
64
|
+
type IEnvType = 'development' | 'staging' | 'testing' | 'production';
|
|
65
|
+
declare class Env {
|
|
66
|
+
private envType;
|
|
67
|
+
constructor();
|
|
68
|
+
isDevelopment(): boolean;
|
|
69
|
+
isProduction(): boolean;
|
|
70
|
+
isTesting(): boolean;
|
|
71
|
+
requireString(varName: string, options?: {
|
|
72
|
+
default?: string;
|
|
73
|
+
}): string;
|
|
74
|
+
requireNumber(varName: string, options?: {
|
|
75
|
+
default?: number;
|
|
76
|
+
}): number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface ICustomErrorData {
|
|
80
|
+
message: string;
|
|
81
|
+
humanMessage?: string;
|
|
82
|
+
code?: string;
|
|
83
|
+
httpCode?: number;
|
|
84
|
+
cause?: Error;
|
|
85
|
+
info?: any;
|
|
86
|
+
}
|
|
87
|
+
declare class CustomError extends Error {
|
|
88
|
+
humanMessage?: string;
|
|
89
|
+
code?: string;
|
|
90
|
+
httpCode?: number;
|
|
91
|
+
info?: any;
|
|
92
|
+
constructor(data: ICustomErrorData);
|
|
63
93
|
}
|
|
64
94
|
|
|
65
|
-
|
|
95
|
+
type IConstructor<T> = new (...args: any[]) => T;
|
|
96
|
+
|
|
97
|
+
declare class Container implements DependencyContainer {
|
|
98
|
+
register(token: unknown, provider: unknown, options?: unknown): DependencyContainer;
|
|
99
|
+
registerSingleton(from: unknown, to?: unknown): DependencyContainer;
|
|
100
|
+
registerType<T>(from: InjectionToken<T>, to: InjectionToken<T>): DependencyContainer;
|
|
101
|
+
registerInstance<T>(token: InjectionToken<T>, instance: T): DependencyContainer;
|
|
102
|
+
resolve<T>(token: InjectionToken<T>): T;
|
|
103
|
+
resolveAll<T>(token: InjectionToken<T>): T[];
|
|
104
|
+
isRegistered<T>(token: InjectionToken<T>, recursive?: boolean): boolean;
|
|
105
|
+
reset(): void;
|
|
106
|
+
clearInstances(): void;
|
|
107
|
+
createChildContainer(): DependencyContainer;
|
|
108
|
+
beforeResolution<T>(token: InjectionToken<T>, callback: PreResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
|
|
109
|
+
afterResolution<T>(token: InjectionToken<T>, callback: PostResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
|
|
110
|
+
dispose(): Promise<void> | void;
|
|
66
111
|
}
|
|
67
112
|
|
|
68
|
-
|
|
113
|
+
declare const injectable: typeof tsyringe.injectable;
|
|
114
|
+
declare const container: tsyringe.DependencyContainer;
|
|
115
|
+
declare const singleton: typeof tsyringe.singleton;
|
|
116
|
+
declare const inject: typeof tsyringe.inject;
|
|
117
|
+
declare const scoped: typeof tsyringe.scoped;
|
|
118
|
+
declare const Lifecycle: typeof tsyringe.Lifecycle;
|
|
119
|
+
|
|
120
|
+
declare class Logger {
|
|
121
|
+
private debuggers;
|
|
122
|
+
constructor(name: string);
|
|
123
|
+
trace(...args: any[]): void;
|
|
124
|
+
debug(...args: any[]): void;
|
|
125
|
+
info(...args: any[]): void;
|
|
126
|
+
warn(...args: any[]): void;
|
|
127
|
+
error(...args: any[]): void;
|
|
128
|
+
fatal(...args: any[]): void;
|
|
129
|
+
private log;
|
|
69
130
|
}
|
|
70
131
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
id: string;
|
|
132
|
+
declare class Mapper {
|
|
133
|
+
map<T>(data: any, ctor: IConstructor<T>): T;
|
|
74
134
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
135
|
+
|
|
136
|
+
interface PasswordHashOptions {
|
|
137
|
+
password: string;
|
|
138
|
+
saltLength?: number;
|
|
139
|
+
keyLength?: number;
|
|
81
140
|
}
|
|
82
|
-
declare class
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
141
|
+
declare class Password {
|
|
142
|
+
static hash(options: PasswordHashOptions): string;
|
|
143
|
+
static isValid(req: {
|
|
144
|
+
password: string;
|
|
145
|
+
hash: string;
|
|
146
|
+
}): boolean;
|
|
147
|
+
static generate(length: number): string;
|
|
88
148
|
}
|
|
89
149
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
150
|
+
declare class Random {
|
|
151
|
+
static integer(options: {
|
|
152
|
+
min: number;
|
|
153
|
+
max: number;
|
|
154
|
+
}): number;
|
|
155
|
+
static slug(name: string, options: {
|
|
156
|
+
randomLength: number;
|
|
157
|
+
}): string;
|
|
158
|
+
static alphaNumeric(length: number): string;
|
|
159
|
+
static alphaNumericLowerCase(length: number): string;
|
|
160
|
+
static numberCode(length: number): string;
|
|
100
161
|
}
|
|
101
162
|
|
|
102
|
-
interface
|
|
103
|
-
id: string
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
163
|
+
interface ICrudRepository<T> {
|
|
164
|
+
find(id: string): Promise<T | null>;
|
|
165
|
+
findOrThrow(id: string): Promise<T>;
|
|
166
|
+
findByIds(ids: string[]): Promise<T[]>;
|
|
167
|
+
findAll(id: string): Promise<T[]>;
|
|
168
|
+
create(item: T): Promise<void>;
|
|
169
|
+
update(item: T): Promise<void>;
|
|
170
|
+
delete(item: T): Promise<void>;
|
|
107
171
|
}
|
|
108
172
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
173
|
+
declare function isModel(model: IConstructor<any>): (target: object, propertyKey: string | symbol) => void;
|
|
174
|
+
|
|
175
|
+
declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
|
|
176
|
+
|
|
177
|
+
interface IValidationError {
|
|
178
|
+
description: string;
|
|
179
|
+
}
|
|
180
|
+
interface IModelValidationError extends IValidationError {
|
|
181
|
+
properties: {
|
|
182
|
+
[key: string]: string[];
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
interface IArrayValidationError extends IValidationError {
|
|
186
|
+
items: (IValidationError[] | null)[];
|
|
187
|
+
}
|
|
188
|
+
type IValidationResult<V> = {
|
|
189
|
+
value: V;
|
|
190
|
+
error?: undefined;
|
|
191
|
+
} | {
|
|
192
|
+
value?: undefined;
|
|
193
|
+
error: IValidationError;
|
|
112
194
|
};
|
|
113
|
-
type
|
|
114
|
-
|
|
115
|
-
|
|
195
|
+
type IModelValidationResult<V> = {
|
|
196
|
+
value: V;
|
|
197
|
+
error?: undefined;
|
|
198
|
+
} | {
|
|
199
|
+
value?: undefined;
|
|
200
|
+
error: IModelValidationError;
|
|
116
201
|
};
|
|
117
|
-
type
|
|
118
|
-
|
|
119
|
-
|
|
202
|
+
type IArrayValidationResult<V> = {
|
|
203
|
+
value: V[];
|
|
204
|
+
error?: undefined;
|
|
205
|
+
} | {
|
|
206
|
+
value?: undefined;
|
|
207
|
+
error: IArrayValidationError;
|
|
120
208
|
};
|
|
121
|
-
type
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
declare class ChatItem extends Persistent<IChatItemData> {
|
|
127
|
-
getType(): "BOT_MESSAGE" | "CONNECTION_MESSAGE" | "FUNCTION_CALL";
|
|
128
|
-
getContent(): IChatMessage | IConnectionChatMessage | IChatFunctionCall;
|
|
129
|
-
getData(): IChatItemData;
|
|
209
|
+
type IValidator<V = any, O = any> = (value: V, options: O) => IValidationResult<V>;
|
|
210
|
+
interface IPropertyValidatorInfo {
|
|
211
|
+
propertyName: string;
|
|
212
|
+
validator: IValidator;
|
|
213
|
+
validatorOptions?: any;
|
|
130
214
|
}
|
|
215
|
+
type IModelValidatorsInfo<V> = {
|
|
216
|
+
modelConstructor: IConstructor<V>;
|
|
217
|
+
properties: {
|
|
218
|
+
[prop: string]: {
|
|
219
|
+
isOptional?: boolean;
|
|
220
|
+
validators?: IPropertyValidatorInfo[];
|
|
221
|
+
} | undefined;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
131
224
|
|
|
132
|
-
interface
|
|
133
|
-
|
|
134
|
-
|
|
225
|
+
interface IValidateArrayOptions {
|
|
226
|
+
minLength?: number;
|
|
227
|
+
maxLength?: number;
|
|
135
228
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
229
|
+
interface IValidateArrayOptionsWithItemsValidators extends IValidateArrayOptions {
|
|
230
|
+
itemsValidator?: {
|
|
231
|
+
validator: IValidator;
|
|
232
|
+
options: any;
|
|
233
|
+
}[];
|
|
139
234
|
}
|
|
235
|
+
declare function validateArray(value: any, options?: IValidateArrayOptionsWithItemsValidators): IArrayValidationResult<any>;
|
|
140
236
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
237
|
+
declare function isArray(options?: IValidateArrayOptions): (target: object, propertyKey: string | symbol) => void;
|
|
238
|
+
|
|
239
|
+
interface IValidatorMetadata {
|
|
240
|
+
modelConstructor: IConstructor<any>;
|
|
241
|
+
propertyName: string;
|
|
242
|
+
validator: IValidator;
|
|
243
|
+
validatorOptions?: any;
|
|
145
244
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
245
|
+
|
|
246
|
+
declare class ValidationMetadataStore {
|
|
247
|
+
private validators;
|
|
248
|
+
saveValidatorMetadata(validatorMetadata: IValidatorMetadata): void;
|
|
249
|
+
getModelValidatorsInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
|
|
250
|
+
private getConstructorPropertiesValidatorsInfo;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
|
|
254
|
+
|
|
255
|
+
declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
|
|
256
|
+
|
|
257
|
+
declare function modelInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
|
|
258
|
+
|
|
259
|
+
declare function isBoolean(): (target: object, propertyKey: string | symbol) => void;
|
|
260
|
+
|
|
261
|
+
declare function validateIsBoolean(value: any): IValidationResult<boolean>;
|
|
262
|
+
|
|
263
|
+
declare function isDate(): (target: object, propertyKey: string | symbol) => void;
|
|
264
|
+
|
|
265
|
+
declare function validateIsDate(value: any): IValidationResult<Date>;
|
|
266
|
+
|
|
267
|
+
interface IValidateIsInOptions {
|
|
268
|
+
values: readonly (number | string | boolean | null)[];
|
|
269
|
+
}
|
|
270
|
+
declare function validateIsIn(value: any, options: IValidateIsInOptions): IValidationResult<any>;
|
|
271
|
+
|
|
272
|
+
declare function isIn(values: IValidateIsInOptions['values']): (target: object, propertyKey: string | symbol) => void;
|
|
273
|
+
|
|
274
|
+
declare function isNotEmpty(): (target: object, propertyKey: string | symbol) => void;
|
|
275
|
+
|
|
276
|
+
declare function validateIsNotEmpty(value: any): IValidationResult<any>;
|
|
277
|
+
|
|
278
|
+
declare function isNumber(): (target: object, propertyKey: string | symbol) => void;
|
|
279
|
+
|
|
280
|
+
declare function validateIsNumber(value: any): IValidationResult<number>;
|
|
281
|
+
|
|
282
|
+
declare function isPresent(): (target: object, propertyKey: string | symbol) => void;
|
|
283
|
+
|
|
284
|
+
declare function validateIsPresent(value: any): IValidationResult<any>;
|
|
285
|
+
|
|
286
|
+
declare function isString(): (target: object, propertyKey: string | symbol) => void;
|
|
287
|
+
|
|
288
|
+
declare function validateIsString(value: any): IValidationResult<string>;
|
|
289
|
+
|
|
290
|
+
declare function max(limit: any): (target: object, propertyKey: string | symbol) => void;
|
|
291
|
+
|
|
292
|
+
interface IValidateMaxOptions {
|
|
293
|
+
limit: any;
|
|
150
294
|
}
|
|
295
|
+
declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
|
|
296
|
+
|
|
297
|
+
declare function min(limit: any): (target: object, propertyKey: string | symbol) => void;
|
|
151
298
|
|
|
152
|
-
interface
|
|
153
|
-
|
|
154
|
-
update(chat: User): Promise<void>;
|
|
155
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
299
|
+
interface IValidateMinOptions {
|
|
300
|
+
limit: any;
|
|
156
301
|
}
|
|
157
|
-
declare
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
302
|
+
declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
|
|
303
|
+
|
|
304
|
+
interface ICommandConfig {
|
|
305
|
+
name?: string;
|
|
161
306
|
}
|
|
307
|
+
declare function command(config?: ICommandConfig): (target: IConstructor<any>) => void;
|
|
162
308
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
chat: Chat;
|
|
166
|
-
user: User | null;
|
|
309
|
+
declare class Command<T extends IStorableData> extends Storable<T> {
|
|
310
|
+
getData(): T;
|
|
167
311
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
user: User | null;
|
|
172
|
-
constructor(message: IConnectionChatMessage, chat: Chat, user: User | null);
|
|
312
|
+
|
|
313
|
+
interface ICommandHandler<C extends Command<any>> {
|
|
314
|
+
handle(command: C): void | Promise<void>;
|
|
173
315
|
}
|
|
174
316
|
|
|
175
|
-
interface
|
|
176
|
-
|
|
177
|
-
rev(input: T2): T1;
|
|
317
|
+
interface ICommandHandlerConfig<C extends Command<any>> {
|
|
318
|
+
command: IConstructor<C>;
|
|
178
319
|
}
|
|
320
|
+
declare function commandHandler<C extends Command<any>>(config: ICommandHandlerConfig<C>): (target: IConstructor<ICommandHandler<C>>) => void;
|
|
179
321
|
|
|
180
|
-
|
|
322
|
+
declare class CommandMetadataStore {
|
|
323
|
+
private handlersMap;
|
|
324
|
+
private handlersInverseMap;
|
|
325
|
+
private commandsMap;
|
|
326
|
+
private commandsInverseMap;
|
|
327
|
+
registerCommand(command: IConstructor<Command<any>>, commandName: string): void;
|
|
328
|
+
registerHandler(command: IConstructor<Command<any>>, handlerConstructor: IConstructor<ICommandHandler<any>>): void;
|
|
329
|
+
getHandlerForCommandName(commandName: string): IConstructor<ICommandHandler<any>> | null;
|
|
330
|
+
getCommandNameForHandler(handlerConstructor: IConstructor<ICommandHandler<any>>): string | null;
|
|
331
|
+
getCommandName(command: IConstructor<Command<any>>): string | null;
|
|
332
|
+
getCommandForCommandName(commandName: string): IConstructor<Command<any>> | null;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
interface IJobData extends IEntityData {
|
|
336
|
+
commandName: string;
|
|
337
|
+
commandData: any;
|
|
338
|
+
startedAt?: number;
|
|
339
|
+
successAt?: number;
|
|
340
|
+
failedAt?: number;
|
|
341
|
+
retryAt?: number;
|
|
342
|
+
error?: {
|
|
343
|
+
message: string;
|
|
344
|
+
stack?: string;
|
|
345
|
+
info?: any;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
declare class Job extends Entity<IJobData> {
|
|
349
|
+
get commandName(): string;
|
|
350
|
+
hasFinished(): boolean;
|
|
351
|
+
setAsStarted(): void;
|
|
352
|
+
setAsSuccess(): void;
|
|
353
|
+
setAsFailed(error: Error): void;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
interface IJobRepository extends ICrudRepository<Job> {
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
declare class JobRepository implements IJobRepository {
|
|
360
|
+
find(id: string): Promise<Job | null>;
|
|
361
|
+
findOrThrow(id: string): Promise<Job>;
|
|
362
|
+
findByIds(ids: string[]): Promise<Job[]>;
|
|
363
|
+
findAll(id: string): Promise<Job[]>;
|
|
364
|
+
create(item: Job): Promise<void>;
|
|
365
|
+
update(item: Job): Promise<void>;
|
|
366
|
+
delete(item: Job): Promise<void>;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
interface IJobEvent extends IStorableData {
|
|
370
|
+
jobId: string;
|
|
371
|
+
type: 'created';
|
|
372
|
+
}
|
|
373
|
+
type IJobEventListener = (event: IJobEvent) => void | Promise<void>;
|
|
374
|
+
declare class JobsEventsHub {
|
|
375
|
+
private logger;
|
|
376
|
+
private jobsEventsListener;
|
|
377
|
+
notifyJobCreated(job: Job): void;
|
|
378
|
+
listenJobsEvents(listener: IJobEventListener): void;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
declare class Async {
|
|
382
|
+
private jobRepository;
|
|
383
|
+
private handlerContainer;
|
|
384
|
+
private jobsEventsHub;
|
|
385
|
+
constructor(jobRepository: JobRepository, handlerContainer: CommandMetadataStore, jobsEventsHub: JobsEventsHub);
|
|
386
|
+
run<T extends IStorableData>(command: Command<T>): Promise<Job>;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
declare class JobRunner {
|
|
390
|
+
private jobRepository;
|
|
391
|
+
private handlerContainer;
|
|
392
|
+
private logger;
|
|
393
|
+
constructor(jobRepository: JobRepository, handlerContainer: CommandMetadataStore);
|
|
394
|
+
run(job: Job): Promise<void>;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
declare function runAsyncCommandHandlers(handlers: IConstructor<ICommandHandler<any>>[]): void;
|
|
398
|
+
|
|
399
|
+
interface IChatConnection extends IStorableData {
|
|
400
|
+
channelName: string;
|
|
401
|
+
id: string;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
type IChatType = 'PRIVATE' | 'GROUP';
|
|
405
|
+
|
|
406
|
+
interface IChatData extends IEntityData {
|
|
407
|
+
type: IChatType;
|
|
408
|
+
connections: IChatConnection[];
|
|
409
|
+
}
|
|
410
|
+
declare class Chat extends Entity<IChatData> {
|
|
411
|
+
constructor(data: IChatData);
|
|
412
|
+
isPrivate(): boolean;
|
|
413
|
+
isGroup(): boolean;
|
|
414
|
+
hasConnection(connection: IChatConnection): boolean;
|
|
415
|
+
private validatePrivateChat;
|
|
416
|
+
private validateGroupChat;
|
|
417
|
+
validate(): void;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
interface IMindsetFunctionConfig {
|
|
421
|
+
description: string;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
declare function mindsetFunction(config: IMindsetFunctionConfig): (target: object, propertyKey: string | symbol) => void;
|
|
425
|
+
|
|
426
|
+
declare const MINDSET_FUNCTION_DECORATION_FUNCTION = "mindsetFunction";
|
|
427
|
+
|
|
428
|
+
interface IMindsetFunctionDecoration {
|
|
429
|
+
decorationName: string;
|
|
430
|
+
functionName: string;
|
|
431
|
+
constructor: Function;
|
|
432
|
+
paramsTypes: Function[];
|
|
433
|
+
decorationConfig: any;
|
|
434
|
+
}
|
|
181
435
|
|
|
182
436
|
interface IMindsetIdentity {
|
|
183
437
|
name: string;
|
|
@@ -186,15 +440,23 @@ interface IMindsetIdentity {
|
|
|
186
440
|
personality?: string;
|
|
187
441
|
emotions?: string;
|
|
188
442
|
}
|
|
443
|
+
interface IMindsetLlm {
|
|
444
|
+
provider?: string;
|
|
445
|
+
model: string;
|
|
446
|
+
}
|
|
189
447
|
interface IMindset {
|
|
190
448
|
identity(): Promise<IMindsetIdentity>;
|
|
191
449
|
skills(): Promise<string>;
|
|
192
450
|
limits(): Promise<string>;
|
|
451
|
+
workflow(): Promise<string>;
|
|
452
|
+
llms(): Promise<IMindsetLlm[]>;
|
|
193
453
|
}
|
|
194
454
|
declare class Mindset implements IMindset {
|
|
195
455
|
identity(): Promise<IMindsetIdentity>;
|
|
196
456
|
skills(): Promise<string>;
|
|
197
457
|
limits(): Promise<string>;
|
|
458
|
+
workflow(): Promise<string>;
|
|
459
|
+
llms(): Promise<IMindsetLlm[]>;
|
|
198
460
|
}
|
|
199
461
|
|
|
200
462
|
interface IMindsetConfig {
|
|
@@ -283,26 +545,17 @@ declare class MindsetMetadataStore {
|
|
|
283
545
|
getMindsetMetadata(ctor: Function): IMindsetMetadata;
|
|
284
546
|
}
|
|
285
547
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
createChildContainer(): DependencyContainer;
|
|
297
|
-
beforeResolution<T>(token: InjectionToken<T>, callback: PreResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
|
|
298
|
-
afterResolution<T>(token: InjectionToken<T>, callback: PostResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
|
|
299
|
-
dispose(): Promise<void> | void;
|
|
548
|
+
interface IMindsetToolParameter {
|
|
549
|
+
type: string;
|
|
550
|
+
name: string;
|
|
551
|
+
description: string;
|
|
552
|
+
}
|
|
553
|
+
interface IMindsetTool {
|
|
554
|
+
language: string;
|
|
555
|
+
name: string;
|
|
556
|
+
description: string;
|
|
557
|
+
parameters: IMindsetToolParameter[];
|
|
300
558
|
}
|
|
301
|
-
|
|
302
|
-
declare const injectable: typeof tsyringe.injectable;
|
|
303
|
-
declare const container: tsyringe.DependencyContainer;
|
|
304
|
-
declare const singleton: typeof tsyringe.singleton;
|
|
305
|
-
declare const inject: typeof tsyringe.inject;
|
|
306
559
|
|
|
307
560
|
declare class MindsetOperator implements IMindset {
|
|
308
561
|
private mindset;
|
|
@@ -312,45 +565,88 @@ declare class MindsetOperator implements IMindset {
|
|
|
312
565
|
identity(): Promise<IMindsetIdentity>;
|
|
313
566
|
skills(): Promise<string>;
|
|
314
567
|
limits(): Promise<string>;
|
|
568
|
+
workflow(): Promise<string>;
|
|
569
|
+
llms(): Promise<IMindsetLlm[]>;
|
|
570
|
+
systemPrompt(): Promise<string>;
|
|
571
|
+
tools(): IMindsetTool[];
|
|
572
|
+
protected tool(fn: IMindsetFunctionMetadata, module: IMindsetModuleMetadata): IMindsetTool;
|
|
573
|
+
protected toolParameter(param: IMindsetFunctionParamMetadata): IMindsetToolParameter;
|
|
315
574
|
callFunction(name: string, params: string): Promise<string>;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
readonly name: string;
|
|
319
|
-
readonly description: string;
|
|
320
|
-
readonly parameters: {
|
|
321
|
-
readonly type: "object";
|
|
322
|
-
readonly properties: {};
|
|
323
|
-
readonly required: string[];
|
|
324
|
-
};
|
|
325
|
-
}[]>;
|
|
326
|
-
private functionDescriptor;
|
|
327
|
-
private toolParam;
|
|
575
|
+
functionResponseToString(response: any): Promise<string>;
|
|
576
|
+
functionErrorToString(error: any): Promise<string>;
|
|
328
577
|
}
|
|
329
578
|
|
|
330
|
-
|
|
579
|
+
interface IChatMessage extends IStorableData {
|
|
580
|
+
senderId?: string;
|
|
581
|
+
senderName?: string;
|
|
582
|
+
text?: string;
|
|
583
|
+
}
|
|
331
584
|
|
|
332
|
-
interface
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
585
|
+
interface IFunctionCall extends IStorableData {
|
|
586
|
+
id: string;
|
|
587
|
+
name: string;
|
|
588
|
+
arguments?: string;
|
|
589
|
+
result?: string;
|
|
336
590
|
}
|
|
337
591
|
|
|
338
|
-
declare
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
592
|
+
declare const chatItemTypeOptions: readonly ["botMessage", "humanMessage", "functionCall"];
|
|
593
|
+
type IBotMessageItem = {
|
|
594
|
+
type: 'botMessage';
|
|
595
|
+
botMessage: IChatMessage;
|
|
596
|
+
};
|
|
597
|
+
type IHumanMessageItem = {
|
|
598
|
+
type: 'humanMessage';
|
|
599
|
+
humanMessage: IChatMessage;
|
|
600
|
+
};
|
|
601
|
+
type IFunctionCallItem = {
|
|
602
|
+
type: 'functionCall';
|
|
603
|
+
functionCall: IFunctionCall;
|
|
604
|
+
};
|
|
605
|
+
type IChatItem = IBotMessageItem | IHumanMessageItem | IFunctionCallItem;
|
|
606
|
+
type IChatItemType = (typeof chatItemTypeOptions)[number];
|
|
607
|
+
|
|
608
|
+
interface ILanguageModelUsage {
|
|
609
|
+
inputTokens: number;
|
|
610
|
+
outputTokens: number;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
interface IChatAdapterNextItemReq {
|
|
614
|
+
model: string;
|
|
615
|
+
systemPrompt: string;
|
|
616
|
+
tools: IMindsetTool[];
|
|
617
|
+
prevItems: IChatItem[];
|
|
618
|
+
}
|
|
619
|
+
interface IChatAdapterNextItemRes {
|
|
620
|
+
chatItem: IChatItem;
|
|
621
|
+
usage: ILanguageModelUsage;
|
|
622
|
+
}
|
|
623
|
+
interface IChatAdapter {
|
|
624
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
declare class ChatAdapter implements IChatAdapter {
|
|
628
|
+
nextItem(req: IChatAdapterNextItemReq & {
|
|
629
|
+
provider?: string;
|
|
630
|
+
}): Promise<IChatAdapterNextItemRes>;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
type IChatItemData = IEntityData & IChatItem;
|
|
634
|
+
declare class ChatItem extends Entity<IChatItemData> {
|
|
635
|
+
get type(): "botMessage" | "humanMessage" | "functionCall";
|
|
636
|
+
get botMessage(): IChatMessage;
|
|
637
|
+
get functionCall(): IFunctionCall;
|
|
638
|
+
setFunctionResult(result: string): void;
|
|
639
|
+
getData(): IChatItemData;
|
|
342
640
|
}
|
|
343
641
|
|
|
344
|
-
interface
|
|
345
|
-
|
|
642
|
+
interface IChatMemory {
|
|
643
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
644
|
+
create(item: ChatItem): Promise<void>;
|
|
346
645
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
protected systemPrompt(): Promise<string>;
|
|
352
|
-
protected buildBotMessageItem(text: string): Promise<ChatItem>;
|
|
353
|
-
protected buildFunctionCallItem(id: string, functionName: string, functionArguments: string): Promise<ChatItem>;
|
|
646
|
+
|
|
647
|
+
declare class ChatMemory implements IChatMemory {
|
|
648
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
649
|
+
create(item: ChatItem): Promise<void>;
|
|
354
650
|
}
|
|
355
651
|
|
|
356
652
|
interface IChatBot {
|
|
@@ -360,51 +656,36 @@ interface IChatBot {
|
|
|
360
656
|
declare class ChatBot implements IChatBot {
|
|
361
657
|
private memory;
|
|
362
658
|
private adapter;
|
|
363
|
-
|
|
364
|
-
|
|
659
|
+
private mindset;
|
|
660
|
+
constructor(memory: ChatMemory, adapter: ChatAdapter, mindset: MindsetOperator);
|
|
661
|
+
sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): Promise<void>;
|
|
365
662
|
protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
|
|
366
663
|
}
|
|
367
664
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
validateEnvVariables(envVariables: (string | undefined)[]): void;
|
|
373
|
-
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
374
|
-
private mapChatItems;
|
|
665
|
+
interface IChatRepository {
|
|
666
|
+
create(chat: Chat): Promise<void>;
|
|
667
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
668
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
375
669
|
}
|
|
376
670
|
|
|
377
|
-
declare class
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
constructor(mindset: MindsetOperator);
|
|
382
|
-
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
383
|
-
private mapChatItems;
|
|
671
|
+
declare class ChatRepository implements IChatRepository {
|
|
672
|
+
create(chat: Chat): Promise<void>;
|
|
673
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
674
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
384
675
|
}
|
|
385
676
|
|
|
386
|
-
declare function
|
|
387
|
-
|
|
388
|
-
declare class ChatResolver {
|
|
389
|
-
private chatRepository;
|
|
390
|
-
constructor(chatRepository: ChatRepository);
|
|
391
|
-
resolve(connection: IChatConnection): Promise<Chat>;
|
|
392
|
-
private resolveGroupChat;
|
|
393
|
-
private resolvePrivateChat;
|
|
394
|
-
}
|
|
677
|
+
declare function chatBot(mindset: IConstructor<IMindset>): (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
395
678
|
|
|
396
|
-
interface
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
listen(callback: (message: IReceivedMessage) => void): void;
|
|
401
|
-
connect(): void;
|
|
679
|
+
interface IChatBotMetadata {
|
|
680
|
+
constructor: IConstructor<any>;
|
|
681
|
+
mindsetConstructor: IConstructor<IMindset>;
|
|
682
|
+
injectionToken: string;
|
|
402
683
|
}
|
|
403
684
|
|
|
404
|
-
declare class
|
|
405
|
-
private
|
|
406
|
-
|
|
407
|
-
|
|
685
|
+
declare class ChatBotMetadataStore {
|
|
686
|
+
private chatBots;
|
|
687
|
+
saveChatBotMetadata(chatBot: IChatBotMetadata): void;
|
|
688
|
+
getChatBotsMetadata(): IChatBotMetadata[];
|
|
408
689
|
}
|
|
409
690
|
|
|
410
691
|
interface IchatControllerConfig {
|
|
@@ -416,6 +697,22 @@ interface IChatControllerMetadata {
|
|
|
416
697
|
controllerConstructor: Function;
|
|
417
698
|
}
|
|
418
699
|
|
|
700
|
+
interface IReceivedMessage {
|
|
701
|
+
message: IChatMessage;
|
|
702
|
+
reply: (message: IChatMessage) => void;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
interface IChannelMessage extends IReceivedMessage {
|
|
706
|
+
chatConnection: IChatConnection;
|
|
707
|
+
authInfo?: IStorableData;
|
|
708
|
+
setAuthInfo?: (authInfo: IStorableData | undefined) => void;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
interface IChatChannel {
|
|
712
|
+
listen(callback: (received: IChannelMessage) => void): void;
|
|
713
|
+
connect(): void;
|
|
714
|
+
}
|
|
715
|
+
|
|
419
716
|
interface IChannelMetadata {
|
|
420
717
|
controllerConstructor: IConstructor<any>;
|
|
421
718
|
functionName: string;
|
|
@@ -434,16 +731,21 @@ declare class ControllerMetadataStore {
|
|
|
434
731
|
} | null;
|
|
435
732
|
}
|
|
436
733
|
|
|
437
|
-
declare class
|
|
438
|
-
private
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
private
|
|
442
|
-
|
|
443
|
-
listen(callback: (message: IReceivedMessage) => void): void;
|
|
444
|
-
connect(): void;
|
|
734
|
+
declare class ChatResolver {
|
|
735
|
+
private chatRepository;
|
|
736
|
+
constructor(chatRepository: ChatRepository);
|
|
737
|
+
resolve(connection: IChatConnection): Promise<Chat>;
|
|
738
|
+
private resolveGroupChat;
|
|
739
|
+
private resolvePrivateChat;
|
|
445
740
|
}
|
|
446
741
|
|
|
742
|
+
interface IMessageContext extends IReceivedMessage {
|
|
743
|
+
chat: Chat;
|
|
744
|
+
authInfo?: IStorableData;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
declare function runChatControllers(controllers: IConstructor<any>[]): void;
|
|
748
|
+
|
|
447
749
|
declare class HttpServerProvider {
|
|
448
750
|
server: Server | null;
|
|
449
751
|
private listening;
|
|
@@ -462,16 +764,152 @@ declare class ExpressProvider {
|
|
|
462
764
|
private createExpress;
|
|
463
765
|
}
|
|
464
766
|
|
|
465
|
-
interface
|
|
466
|
-
|
|
767
|
+
interface IMoneyData extends IStorableData {
|
|
768
|
+
amount: string;
|
|
769
|
+
currency: string;
|
|
770
|
+
}
|
|
771
|
+
declare class Money extends Storable<IMoneyData> {
|
|
772
|
+
getData(): {
|
|
773
|
+
[key: string]: IPrimitive | IStorableData | IPrimitive[] | IStorableData[];
|
|
774
|
+
amount: string;
|
|
775
|
+
currency: string;
|
|
776
|
+
};
|
|
777
|
+
get amount(): big_js.Big;
|
|
778
|
+
get currency(): string;
|
|
779
|
+
plus(money: Money): Money;
|
|
780
|
+
minus(money: Money): Money;
|
|
781
|
+
times(value: bigint | string): Money;
|
|
782
|
+
div(value: bigint | string): Money;
|
|
783
|
+
negative(): Money;
|
|
784
|
+
isGretterThan(money: Money): boolean;
|
|
785
|
+
protected validateEqualCurrencies(left: string, right: string): void;
|
|
786
|
+
static zero(currency: string): Money;
|
|
467
787
|
}
|
|
468
788
|
|
|
469
|
-
declare class
|
|
470
|
-
|
|
471
|
-
|
|
789
|
+
declare class MoneyDto {
|
|
790
|
+
amount: string;
|
|
791
|
+
currency: string;
|
|
472
792
|
}
|
|
473
793
|
|
|
474
|
-
|
|
794
|
+
type IPgRepositoryConfig<P extends Entity<IEntityData>> = {
|
|
795
|
+
schema?: string;
|
|
796
|
+
table: string;
|
|
797
|
+
constructor: IConstructor<P>;
|
|
798
|
+
add?: {
|
|
799
|
+
columns: {
|
|
800
|
+
[column: string]: {
|
|
801
|
+
type: string;
|
|
802
|
+
value: (item: P) => boolean | number | string | null | Date;
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
};
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
declare class PgRepositoryBase<P extends Entity<IEntityData>> {
|
|
809
|
+
protected pool: Pool;
|
|
810
|
+
protected config: IPgRepositoryConfig<any>;
|
|
811
|
+
private tableIsCreated;
|
|
812
|
+
protected schema: string;
|
|
813
|
+
protected table: string;
|
|
814
|
+
protected columnsList: string[];
|
|
815
|
+
protected columnsAndTypes: string;
|
|
816
|
+
protected columns: string;
|
|
817
|
+
protected vars: string;
|
|
818
|
+
protected updates: string;
|
|
819
|
+
addColumns: {
|
|
820
|
+
[columns: string]: {
|
|
821
|
+
type: string;
|
|
822
|
+
value: (item: P) => number | boolean | string | null | Date;
|
|
823
|
+
};
|
|
824
|
+
};
|
|
825
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<any>);
|
|
826
|
+
protected values(item: P): (string | number | boolean | Date | null)[];
|
|
827
|
+
protected exec(sql: string, values: any[]): Promise<void>;
|
|
828
|
+
protected query(sql: string, values: any[]): Promise<P[]>;
|
|
829
|
+
protected connect(): Promise<Pool>;
|
|
830
|
+
protected ensureTable(): Promise<void>;
|
|
831
|
+
protected ensureColumns(): Promise<void>;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
835
|
+
protected readonly config: IPgRepositoryConfig<P>;
|
|
836
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
837
|
+
find(id: string): Promise<P | null>;
|
|
838
|
+
findByIds(ids: string[]): Promise<P[]>;
|
|
839
|
+
findOrThrow(id: string): Promise<P>;
|
|
840
|
+
findAll(): Promise<P[]>;
|
|
841
|
+
create(item: P): Promise<void>;
|
|
842
|
+
update(item: P): Promise<void>;
|
|
843
|
+
delete(item: P): Promise<void>;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
interface IEndPointConfig {
|
|
847
|
+
path?: string;
|
|
848
|
+
disableJsonParser?: boolean;
|
|
849
|
+
disableUrlEncodedParser?: boolean;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
declare function onGet(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
|
|
853
|
+
|
|
854
|
+
interface IMiddleware {
|
|
855
|
+
handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
declare function middleware(middlewareConstructor: IConstructor<IMiddleware>): (target: object, propertyKey: string | symbol) => void;
|
|
859
|
+
|
|
860
|
+
declare function onPost(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
|
|
861
|
+
|
|
862
|
+
declare function onPut(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
|
|
863
|
+
|
|
864
|
+
declare function onDelete(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
|
|
865
|
+
|
|
866
|
+
interface IRestControllerConfig {
|
|
867
|
+
path: string;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
declare function restController(config: string | IRestControllerConfig): (target: IConstructor<any>) => void;
|
|
871
|
+
|
|
872
|
+
interface IEndPointMetadata {
|
|
873
|
+
method: 'get' | 'post' | 'put' | 'delete';
|
|
874
|
+
config?: IEndPointConfig;
|
|
875
|
+
controllerConstructor: IConstructor<any>;
|
|
876
|
+
functionName: string;
|
|
877
|
+
paramsTypes: any[];
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
interface IMiddlewareMetadata {
|
|
881
|
+
controllerConstructor: IConstructor<any>;
|
|
882
|
+
functionName: string;
|
|
883
|
+
middlewareConstructor: IConstructor<IMiddleware>;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
interface IRestControllerMetadata {
|
|
887
|
+
controllerConstructor: IConstructor<any>;
|
|
888
|
+
path: string;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
declare class RestControllerMetadataStore {
|
|
892
|
+
private endPoints;
|
|
893
|
+
private middlewares;
|
|
894
|
+
private restControllers;
|
|
895
|
+
saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
|
|
896
|
+
saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
|
|
897
|
+
saveMiddlewareMetadata(middlewareMetadata: IMiddlewareMetadata): void;
|
|
898
|
+
getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
|
|
899
|
+
middlewares: IMiddlewareMetadata[];
|
|
900
|
+
controller: IRestControllerMetadata;
|
|
901
|
+
method: "get" | "post" | "put" | "delete";
|
|
902
|
+
config?: IEndPointConfig;
|
|
903
|
+
controllerConstructor: IConstructor<any>;
|
|
904
|
+
functionName: string;
|
|
905
|
+
paramsTypes: any[];
|
|
906
|
+
}[];
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
declare function runRestControllers(controllers: IConstructor<any>[]): void;
|
|
910
|
+
|
|
911
|
+
declare const EXPRESS_REQ = "EXPRESS_REQ";
|
|
912
|
+
declare const EXPRESS_RES = "EXPRESS_RES";
|
|
475
913
|
|
|
476
914
|
declare class SocketServerProvider {
|
|
477
915
|
private httpServerProvider;
|
|
@@ -483,138 +921,427 @@ declare class SocketServerProvider {
|
|
|
483
921
|
private createSocketServer;
|
|
484
922
|
}
|
|
485
923
|
|
|
486
|
-
interface
|
|
487
|
-
|
|
488
|
-
userId: string;
|
|
489
|
-
senderName: string;
|
|
490
|
-
text: string;
|
|
924
|
+
interface IConnectionMiddleware {
|
|
925
|
+
handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
|
|
491
926
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
private callBack;
|
|
498
|
-
private server;
|
|
499
|
-
constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider, chatResolver: ChatResolver, userResolver: UserResolver);
|
|
500
|
-
listen(callback: (message: IReceivedMessage) => void): void;
|
|
501
|
-
connect(): void;
|
|
927
|
+
|
|
928
|
+
declare function connectionMiddleware(middlewareConstructor: IConstructor<IConnectionMiddleware>): (target: object, propertyKey: string | symbol) => void;
|
|
929
|
+
|
|
930
|
+
interface ISocketConnectionConfig {
|
|
931
|
+
namespace: string;
|
|
502
932
|
}
|
|
503
933
|
|
|
504
|
-
|
|
505
|
-
|
|
934
|
+
declare function socketConnection(config?: string | ISocketConnectionConfig): (target: object, propertyKey: string | symbol) => void;
|
|
935
|
+
|
|
936
|
+
interface ISocketControllerConfig {
|
|
937
|
+
namespace: string;
|
|
506
938
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
939
|
+
|
|
940
|
+
declare function socketController(config?: string | ISocketControllerConfig): (target: IConstructor<any>) => void;
|
|
941
|
+
|
|
942
|
+
interface ISocketEventConfig {
|
|
943
|
+
namespace?: string;
|
|
944
|
+
event: string;
|
|
510
945
|
}
|
|
511
946
|
|
|
512
|
-
declare function
|
|
947
|
+
declare function socketEvent(config: string | ISocketEventConfig): (target: object, propertyKey: string | symbol) => void;
|
|
513
948
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
private bot;
|
|
519
|
-
constructor(config: TelegramChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver);
|
|
520
|
-
listen(callback: (message: IReceivedMessage) => void): void;
|
|
521
|
-
connect(): void;
|
|
949
|
+
interface IConnectionMiddlewareMetadata {
|
|
950
|
+
controllerConstructor: IConstructor<any>;
|
|
951
|
+
functionName: string;
|
|
952
|
+
middlewareConstructor: IConstructor<IConnectionMiddleware>;
|
|
522
953
|
}
|
|
523
954
|
|
|
524
|
-
interface
|
|
525
|
-
|
|
526
|
-
|
|
955
|
+
interface ISocketConnectionMetadata {
|
|
956
|
+
config?: ISocketConnectionConfig;
|
|
957
|
+
controllerConstructor: IConstructor<any>;
|
|
958
|
+
functionName: string;
|
|
959
|
+
paramsTypes: any[];
|
|
527
960
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
961
|
+
|
|
962
|
+
interface ISocketControllerMetadata {
|
|
963
|
+
controllerConstructor: IConstructor<any>;
|
|
964
|
+
config?: ISocketControllerConfig;
|
|
531
965
|
}
|
|
532
966
|
|
|
533
|
-
|
|
967
|
+
interface ISocketEventMetadata {
|
|
968
|
+
config: ISocketEventConfig;
|
|
969
|
+
controllerConstructor: IConstructor<any>;
|
|
970
|
+
functionName: string;
|
|
971
|
+
paramsTypes: any[];
|
|
972
|
+
}
|
|
534
973
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
templateName: string;
|
|
554
|
-
languageCode: string;
|
|
555
|
-
parameters: IWhatsAppTemplateParameter[];
|
|
974
|
+
declare class SocketControllerMetadataStore {
|
|
975
|
+
private socketControllers;
|
|
976
|
+
private socketConnections;
|
|
977
|
+
private socketEvents;
|
|
978
|
+
private connectionMiddlewares;
|
|
979
|
+
saveControllerMetadata(controllerMetadata: ISocketControllerMetadata): void;
|
|
980
|
+
saveSocketConnectionMetadata(socketConnectionMetadata: ISocketConnectionMetadata): void;
|
|
981
|
+
saveSocketEventMetadata(socketEventMetadata: ISocketEventMetadata): void;
|
|
982
|
+
saveConnectionMiddlewareMetadata(middlewareMetadata: IConnectionMiddlewareMetadata): void;
|
|
983
|
+
getControllerSockerConnectionsInfo(controllerConstructor: IConstructor<any>): {
|
|
984
|
+
events: ISocketEventMetadata[];
|
|
985
|
+
connectionMiddlewares: IConnectionMiddlewareMetadata[];
|
|
986
|
+
controller: ISocketControllerMetadata;
|
|
987
|
+
config?: ISocketConnectionConfig;
|
|
988
|
+
controllerConstructor: IConstructor<any>;
|
|
989
|
+
functionName: string;
|
|
990
|
+
paramsTypes: any[];
|
|
991
|
+
}[];
|
|
556
992
|
}
|
|
557
993
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
interface IEntry {
|
|
563
|
-
id: string;
|
|
564
|
-
changes: IChange[];
|
|
994
|
+
declare function runSocketControllers(controllers: IConstructor<any>[]): void;
|
|
995
|
+
|
|
996
|
+
declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepository {
|
|
997
|
+
constructor(pool: Pool);
|
|
565
998
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
999
|
+
|
|
1000
|
+
declare function apiKeyConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
|
|
1001
|
+
|
|
1002
|
+
declare function apiKeyGuard(): (target: object, propertyKey: string | symbol) => void;
|
|
1003
|
+
|
|
1004
|
+
interface IApiKeyData<A extends IStorableData> extends IEntityData {
|
|
1005
|
+
secretHash?: string;
|
|
1006
|
+
metadata?: Record<string, string>;
|
|
1007
|
+
authInfo: A;
|
|
1008
|
+
name: string;
|
|
570
1009
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
1010
|
+
declare class ApiKey<A extends IStorableData> extends Entity<IApiKeyData<A>> {
|
|
1011
|
+
static PREFIX: string;
|
|
1012
|
+
static hashSecret(secret: string): string;
|
|
1013
|
+
get authInfo(): A;
|
|
1014
|
+
get metadata(): Record<string, string>;
|
|
1015
|
+
setAuthInfo(authInfo: A): void;
|
|
1016
|
+
generateSecret(): string;
|
|
1017
|
+
isValidSecret(secret: string): boolean;
|
|
1018
|
+
validateSecret(secret: string): void;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
interface IApiKeyRepository<A extends IStorableData> {
|
|
1022
|
+
find(id: string): Promise<ApiKey<A> | null>;
|
|
1023
|
+
findOrThrow(id: string): Promise<ApiKey<A>>;
|
|
1024
|
+
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1025
|
+
create(item: ApiKey<A>): Promise<void>;
|
|
1026
|
+
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
1027
|
+
findAuthInfoBySecret(secret: string): Promise<A | null>;
|
|
1028
|
+
}
|
|
1029
|
+
interface IGenerateApiKeyReq<A extends IStorableData> extends IStorableData {
|
|
1030
|
+
name: string;
|
|
1031
|
+
metadata?: Record<string, string>;
|
|
1032
|
+
authInfo: A;
|
|
576
1033
|
}
|
|
577
|
-
interface
|
|
578
|
-
|
|
579
|
-
|
|
1034
|
+
interface IGenerateApiKeyRes<A extends IStorableData> {
|
|
1035
|
+
apiKey: ApiKey<A>;
|
|
1036
|
+
secret: string;
|
|
580
1037
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
1038
|
+
|
|
1039
|
+
declare class ApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
|
|
1040
|
+
findAuthInfoBySecret(secret: string): Promise<A>;
|
|
1041
|
+
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1042
|
+
find(id: string): Promise<ApiKey<A> | null>;
|
|
1043
|
+
findOrThrow(id: string): Promise<ApiKey<A>>;
|
|
1044
|
+
create(item: ApiKey<A>): Promise<void>;
|
|
1045
|
+
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
586
1046
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
1047
|
+
|
|
1048
|
+
declare class ApiKeyConnectionGuardMiddleware implements IConnectionMiddleware {
|
|
1049
|
+
private apiKeyRepository;
|
|
1050
|
+
private auth;
|
|
1051
|
+
constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
|
|
1052
|
+
handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
|
|
593
1053
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
1054
|
+
|
|
1055
|
+
declare class ApiKeyGuardMiddleware implements IMiddleware {
|
|
1056
|
+
private apiKeyRepository;
|
|
1057
|
+
private auth;
|
|
1058
|
+
constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
|
|
1059
|
+
handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
|
|
599
1060
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
1061
|
+
|
|
1062
|
+
declare class PgApiKeyRepository<A extends IStorableData> extends PgCrudRepository<ApiKey<A>> implements IApiKeyRepository<A> {
|
|
1063
|
+
constructor(pool: Pool);
|
|
1064
|
+
findAuthInfoBySecret(secret: string): Promise<A | null>;
|
|
1065
|
+
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1066
|
+
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
interface IRemoteApiKeyFetcher<A extends IStorableData> {
|
|
1070
|
+
fetchById: (id: string) => Promise<ApiKey<A> | null>;
|
|
1071
|
+
fetchBySecret: (secret: string) => Promise<ApiKey<A> | null>;
|
|
1072
|
+
}
|
|
1073
|
+
declare class RemoteApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
|
|
1074
|
+
private fetcher;
|
|
1075
|
+
private cacheSeconds;
|
|
1076
|
+
private cacheById;
|
|
1077
|
+
private cacheBySecret;
|
|
1078
|
+
constructor(fetcher: IRemoteApiKeyFetcher<A>, cacheSeconds: number);
|
|
1079
|
+
find(id: string): Promise<ApiKey<A> | null>;
|
|
1080
|
+
findOrThrow(id: string): Promise<ApiKey<A>>;
|
|
1081
|
+
findAuthInfoBySecret(secret: string): Promise<A>;
|
|
1082
|
+
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1083
|
+
create(item: ApiKey<A>): Promise<void>;
|
|
1084
|
+
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
declare function jwtConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
|
|
1088
|
+
|
|
1089
|
+
declare function jwtGuard(): (target: object, propertyKey: string | symbol) => void;
|
|
1090
|
+
|
|
1091
|
+
interface IJwtRefreshTokenData<A extends IStorableData> extends IEntityData {
|
|
1092
|
+
authInfo: A;
|
|
1093
|
+
passwordHash?: string;
|
|
1094
|
+
expirationTime: number;
|
|
1095
|
+
}
|
|
1096
|
+
declare class JwtRefreshToken<A extends IStorableData> extends Entity<IJwtRefreshTokenData<A>> {
|
|
1097
|
+
get authInfo(): A;
|
|
1098
|
+
get expirationTime(): Date;
|
|
1099
|
+
generatePassword(): string;
|
|
1100
|
+
isValidPassword(password: string): boolean;
|
|
1101
|
+
validatePassword(password: string): void;
|
|
1102
|
+
static inflate(secret: string): {
|
|
605
1103
|
id: string;
|
|
606
|
-
|
|
1104
|
+
pass: string;
|
|
607
1105
|
};
|
|
1106
|
+
static deflate(data: {
|
|
1107
|
+
id: string;
|
|
1108
|
+
pass: string;
|
|
1109
|
+
}): string;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
interface IJwtRefreshTokenRepository<D extends IStorableData> extends ICrudRepository<JwtRefreshToken<D>> {
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
declare class JwtTokenDto {
|
|
1116
|
+
token?: string;
|
|
1117
|
+
expiration?: Date;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
declare class JwtAccessAndRefreshTokenDto {
|
|
1121
|
+
access?: JwtTokenDto;
|
|
1122
|
+
refresh?: JwtTokenDto;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
declare class JwtConfig {
|
|
1126
|
+
secretOrPublicKey: string;
|
|
1127
|
+
secretOrPrivateKey: string;
|
|
1128
|
+
algorithm: Algorithm;
|
|
1129
|
+
accessExpirationSeconds: number;
|
|
1130
|
+
refreshExpirationSeconds: number;
|
|
1131
|
+
constructor(env: Env);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
declare class JwtSigner {
|
|
1135
|
+
private config;
|
|
1136
|
+
private mapper;
|
|
1137
|
+
constructor(config: JwtConfig, mapper: Mapper);
|
|
1138
|
+
signAccessToken<D extends IStorableData>(info: D | JwtRefreshToken<any>): Promise<JwtTokenDto>;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
declare class JwtRefreshTokenRepository<D extends IStorableData> implements IJwtRefreshTokenRepository<D> {
|
|
1142
|
+
find(id: string): Promise<JwtRefreshToken<D> | null>;
|
|
1143
|
+
findOrThrow(id: string): Promise<JwtRefreshToken<D>>;
|
|
1144
|
+
findByIds(ids: string[]): Promise<JwtRefreshToken<D>[]>;
|
|
1145
|
+
findAll(id: string): Promise<JwtRefreshToken<D>[]>;
|
|
1146
|
+
create(item: JwtRefreshToken<D>): Promise<void>;
|
|
1147
|
+
update(item: JwtRefreshToken<D>): Promise<void>;
|
|
1148
|
+
delete(item: JwtRefreshToken<D>): Promise<void>;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
declare class Jwt {
|
|
1152
|
+
private auth;
|
|
1153
|
+
private jwtSigner;
|
|
1154
|
+
private jwtRefreshTokenRepository;
|
|
1155
|
+
private config;
|
|
1156
|
+
constructor(auth: Auth<any>, jwtSigner: JwtSigner, jwtRefreshTokenRepository: JwtRefreshTokenRepository<any>, config: JwtConfig);
|
|
1157
|
+
createToken(): Promise<JwtAccessAndRefreshTokenDto>;
|
|
1158
|
+
refreshToken(refreshSecret: string): Promise<JwtTokenDto>;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
declare class JwtConnectionGuardMiddleware implements IConnectionMiddleware {
|
|
1162
|
+
private config;
|
|
1163
|
+
private auth;
|
|
1164
|
+
constructor(config: JwtConfig, auth: Auth<any>);
|
|
1165
|
+
handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
declare class JwtGuardMiddleware implements IMiddleware {
|
|
1169
|
+
private config;
|
|
1170
|
+
private auth;
|
|
1171
|
+
constructor(config: JwtConfig, auth: Auth<any>);
|
|
1172
|
+
handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
declare class PgJwtRefreshTokenRepository<D extends IStorableData> extends PgCrudRepository<JwtRefreshToken<D>> implements IJwtRefreshTokenRepository<D> {
|
|
1176
|
+
constructor(pool: Pool);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
declare class AnthropicChatAdapter implements IChatAdapter {
|
|
1180
|
+
private env;
|
|
1181
|
+
private anthropic;
|
|
1182
|
+
private logger;
|
|
1183
|
+
constructor(env: Env);
|
|
1184
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
1185
|
+
private mapChatItems;
|
|
1186
|
+
private mapHumanMessage;
|
|
1187
|
+
private mapBotMessage;
|
|
1188
|
+
private mapFunctionCall;
|
|
1189
|
+
private mapTool;
|
|
1190
|
+
private mapResponse;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
declare class DeepSeekChatAdapter implements IChatAdapter {
|
|
1194
|
+
private deepSeek;
|
|
1195
|
+
private logger;
|
|
1196
|
+
constructor();
|
|
1197
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
1198
|
+
private mapChatItems;
|
|
1199
|
+
private mapHumanMessage;
|
|
1200
|
+
private mapBotMessage;
|
|
1201
|
+
private mapFunctionCall;
|
|
1202
|
+
private mapTool;
|
|
1203
|
+
private mapResponse;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
declare class GoogleChatAdapter implements IChatAdapter {
|
|
1207
|
+
private env;
|
|
1208
|
+
private openai;
|
|
1209
|
+
private logger;
|
|
1210
|
+
constructor(env: Env);
|
|
1211
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
1212
|
+
private mapChatItems;
|
|
1213
|
+
private mapHumanMessage;
|
|
1214
|
+
private mapBotMessage;
|
|
1215
|
+
private mapFunctionCall;
|
|
1216
|
+
private mapTool;
|
|
1217
|
+
private mapResponse;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
declare class OpenaiChatAdapter implements IChatAdapter {
|
|
1221
|
+
private openai;
|
|
1222
|
+
private logger;
|
|
1223
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
1224
|
+
private mapChatItems;
|
|
1225
|
+
private mapConectionMessage;
|
|
1226
|
+
private mapBotMessage;
|
|
1227
|
+
private mapFunctionCall;
|
|
1228
|
+
private mapTool;
|
|
1229
|
+
private mapResponse;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
|
|
1233
|
+
constructor(pool: Pool);
|
|
1234
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
1235
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMemory {
|
|
1239
|
+
private chatId;
|
|
1240
|
+
constructor(pool: Pool, chatId: string);
|
|
1241
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
declare class RamChatMemory implements IChatMemory {
|
|
1245
|
+
private memory;
|
|
1246
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
1247
|
+
create(item: ChatItem): Promise<void>;
|
|
1248
|
+
clearMemory(): Promise<void>;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
declare class RamChatRepository implements IChatRepository {
|
|
1252
|
+
private items;
|
|
1253
|
+
private memories;
|
|
1254
|
+
create(chat: Chat): Promise<void>;
|
|
1255
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
1256
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
1257
|
+
private getMemory;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
declare class WabotChatAdapter implements IChatAdapter {
|
|
1261
|
+
private apiKey;
|
|
1262
|
+
private baseUrl;
|
|
1263
|
+
private logger;
|
|
1264
|
+
constructor(env: Env);
|
|
1265
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
declare function cmd(): (target: object, propertyKey: string | symbol) => void;
|
|
1269
|
+
|
|
1270
|
+
declare class CmdChannel implements IChatChannel {
|
|
1271
|
+
private authInfo;
|
|
1272
|
+
private chatId;
|
|
1273
|
+
private rl;
|
|
1274
|
+
private callBack;
|
|
1275
|
+
listen(callback: (message: IChannelMessage) => void): void;
|
|
1276
|
+
connect(): void;
|
|
1277
|
+
}
|
|
1278
|
+
declare function writeJsonToFile<T>(filename: string, data: T): void;
|
|
1279
|
+
declare function readJsonFromFile<T>(filename: string): T | null;
|
|
1280
|
+
|
|
1281
|
+
interface ISocketChannelConfig {
|
|
1282
|
+
channel: string;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
declare class SocketChannelConfig implements ISocketChannelConfig {
|
|
1286
|
+
channel: string;
|
|
1287
|
+
constructor(channel: string);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
|
|
1291
|
+
|
|
1292
|
+
interface ISocketChannelReceivedMessage {
|
|
1293
|
+
chatId: string;
|
|
1294
|
+
userId: string;
|
|
1295
|
+
senderName: string;
|
|
1296
|
+
text: string;
|
|
1297
|
+
}
|
|
1298
|
+
declare class SocketChannel implements IChatChannel {
|
|
1299
|
+
private config;
|
|
1300
|
+
private socketServerProvider;
|
|
1301
|
+
private callBack;
|
|
1302
|
+
private server;
|
|
1303
|
+
constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider);
|
|
1304
|
+
listen(callback: (message: IChannelMessage) => void): void;
|
|
1305
|
+
connect(): void;
|
|
608
1306
|
}
|
|
609
1307
|
|
|
610
|
-
interface
|
|
1308
|
+
interface ITelegramChannelConfig {
|
|
1309
|
+
botToken: string;
|
|
1310
|
+
}
|
|
1311
|
+
declare class TelegramChannelConfig implements ITelegramChannelConfig {
|
|
1312
|
+
botToken: string;
|
|
1313
|
+
constructor(botToken: string);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
declare function telegram(config: ITelegramChannelConfig): (target: object, propertyKey: string | symbol) => void;
|
|
1317
|
+
|
|
1318
|
+
declare class TelegramChannel implements IChatChannel {
|
|
1319
|
+
private config;
|
|
1320
|
+
private bot;
|
|
1321
|
+
constructor(config: TelegramChannelConfig);
|
|
1322
|
+
listen(callback: (message: IChannelMessage) => void): void;
|
|
1323
|
+
connect(): void;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
interface IWhatsappChannelConfig {
|
|
1327
|
+
number: string;
|
|
1328
|
+
proxy?: string;
|
|
1329
|
+
}
|
|
1330
|
+
declare class WhatsappChannelConfig implements IWhatsappChannelConfig {
|
|
1331
|
+
number: string;
|
|
1332
|
+
constructor(number: string);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
declare function whatsApp(config: string | IWhatsappChannelConfig): (target: object, propertyKey: string | symbol) => void;
|
|
1336
|
+
|
|
1337
|
+
interface IWhatsAppBusinessNumber extends IStorableData {
|
|
611
1338
|
id: string;
|
|
612
1339
|
number: string;
|
|
613
1340
|
}
|
|
614
|
-
interface IWhatsAppBusinessAccount {
|
|
1341
|
+
interface IWhatsAppBusinessAccount extends IStorableData {
|
|
615
1342
|
id: string;
|
|
616
1343
|
}
|
|
617
|
-
interface IWhatsAppData extends
|
|
1344
|
+
interface IWhatsAppData extends IEntityData {
|
|
618
1345
|
slug: string;
|
|
619
1346
|
verifyToken: string;
|
|
620
1347
|
appSecret: string;
|
|
@@ -622,7 +1349,7 @@ interface IWhatsAppData extends IPersistentData {
|
|
|
622
1349
|
businessAccount: IWhatsAppBusinessAccount;
|
|
623
1350
|
businessNumbers: IWhatsAppBusinessNumber[];
|
|
624
1351
|
}
|
|
625
|
-
declare class WhatsApp extends
|
|
1352
|
+
declare class WhatsApp extends Entity<IWhatsAppData> {
|
|
626
1353
|
getVerifyToken(): string;
|
|
627
1354
|
getSlug(): string;
|
|
628
1355
|
getBusinessAccount(): IWhatsAppBusinessAccount;
|
|
@@ -633,57 +1360,88 @@ declare class WhatsApp extends Persistent<IWhatsAppData> {
|
|
|
633
1360
|
getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
|
|
634
1361
|
}
|
|
635
1362
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
1363
|
+
interface IWhatsAppRepository {
|
|
1364
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
1365
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
declare class EnvWhatsAppRepository implements IWhatsAppRepository {
|
|
1369
|
+
private env;
|
|
1370
|
+
constructor(env: Env);
|
|
1371
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
1372
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
1373
|
+
private getFromEnvVars;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
|
|
1377
|
+
constructor(pool: Pool);
|
|
1378
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
1379
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
646
1380
|
}
|
|
647
1381
|
|
|
648
|
-
type IWhatsAppMessageListener = (message:
|
|
1382
|
+
type IWhatsAppMessageListener = (message: Omit<IChannelMessage, 'reply'>) => Promise<void>;
|
|
649
1383
|
interface IListenWhatsAppMessageRequest {
|
|
650
1384
|
to: string;
|
|
651
1385
|
listener: IWhatsAppMessageListener;
|
|
652
1386
|
}
|
|
653
|
-
declare
|
|
654
|
-
|
|
655
|
-
private listeners;
|
|
656
|
-
constructor(logger: Logger);
|
|
657
|
-
abstract connect(): Promise<void>;
|
|
1387
|
+
declare class WhatsAppReceiver {
|
|
1388
|
+
connect(): Promise<void>;
|
|
658
1389
|
listenMessage(request: IListenWhatsAppMessageRequest): void;
|
|
659
|
-
protected handlePayload(payload: IWhatsAppWebhookPayload): Promise<void>;
|
|
660
|
-
private emmitMessage;
|
|
661
1390
|
}
|
|
662
1391
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
1392
|
+
type IWhatsAppCloudTemplateParameter = {
|
|
1393
|
+
type: 'text';
|
|
1394
|
+
text: string;
|
|
1395
|
+
parameter_name?: string;
|
|
1396
|
+
} | {
|
|
1397
|
+
type: 'currency';
|
|
1398
|
+
currency: {
|
|
1399
|
+
fallback_value: string;
|
|
1400
|
+
code: string;
|
|
1401
|
+
amount_1000: number;
|
|
1402
|
+
};
|
|
1403
|
+
} | {
|
|
1404
|
+
type: 'date_time';
|
|
1405
|
+
date_time: {
|
|
1406
|
+
fallback_value: string;
|
|
1407
|
+
};
|
|
1408
|
+
};
|
|
1409
|
+
interface IWhatsAppCloudTemplateMessage {
|
|
1410
|
+
templateName: string;
|
|
1411
|
+
languageCode: string;
|
|
1412
|
+
parameters: IWhatsAppCloudTemplateParameter[];
|
|
666
1413
|
}
|
|
667
1414
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
1415
|
+
interface IWhatsAppCloudTemplateResponse {
|
|
1416
|
+
data: IWhatsAppCloudTemplate[];
|
|
1417
|
+
paging: IWhatsAppCloudApiPaging;
|
|
671
1418
|
}
|
|
672
|
-
|
|
673
|
-
interface IWhatsAppTemplate {
|
|
1419
|
+
interface IWhatsAppCloudTemplate {
|
|
674
1420
|
name: string;
|
|
675
1421
|
parameter_format: 'POSITIONAL' | 'OTHER';
|
|
676
|
-
components:
|
|
1422
|
+
components: IWhatsAppCloudTemplateComponent[];
|
|
677
1423
|
language: string;
|
|
678
1424
|
status: string;
|
|
679
1425
|
category: string;
|
|
680
1426
|
id: string;
|
|
681
1427
|
}
|
|
682
|
-
interface
|
|
1428
|
+
interface IWhatsAppCloudTemplateComponent {
|
|
683
1429
|
type: 'HEADER' | 'BODY' | 'FOOTER';
|
|
684
1430
|
format?: 'TEXT';
|
|
685
1431
|
text?: string;
|
|
686
1432
|
}
|
|
1433
|
+
interface IWhatsAppCloudApiPaging {
|
|
1434
|
+
cursors: IWhatsAppCloudApiCursors;
|
|
1435
|
+
}
|
|
1436
|
+
interface IWhatsAppCloudApiCursors {
|
|
1437
|
+
before: string;
|
|
1438
|
+
after: string;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
declare class WhatsAppRepository implements IWhatsAppRepository {
|
|
1442
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
1443
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
1444
|
+
}
|
|
687
1445
|
|
|
688
1446
|
interface ISendWhatsAppRequest {
|
|
689
1447
|
from: string;
|
|
@@ -693,7 +1451,7 @@ interface ISendWhatsAppRequest {
|
|
|
693
1451
|
interface ISendWhatsAppTemplateRequest {
|
|
694
1452
|
from: string;
|
|
695
1453
|
to: string;
|
|
696
|
-
templateMessage:
|
|
1454
|
+
templateMessage: IWhatsAppCloudTemplateMessage;
|
|
697
1455
|
senderName: string;
|
|
698
1456
|
}
|
|
699
1457
|
interface IGetWhatsAppTemplateRequest {
|
|
@@ -704,232 +1462,156 @@ interface IGetWhatsAppTemplateRequest {
|
|
|
704
1462
|
interface IWhatsAppSenderOptions {
|
|
705
1463
|
writeChatMemory?: boolean;
|
|
706
1464
|
}
|
|
707
|
-
declare
|
|
708
|
-
protected logger: Logger;
|
|
1465
|
+
declare class WhatsAppSender {
|
|
709
1466
|
protected chatRepository: ChatRepository;
|
|
710
1467
|
protected chatResolver: ChatResolver;
|
|
711
1468
|
protected whatsAppRepository: WhatsAppRepository;
|
|
712
|
-
constructor(
|
|
713
|
-
protected abstract handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
714
|
-
protected abstract handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
715
|
-
protected abstract handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
1469
|
+
constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
716
1470
|
sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
717
1471
|
sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
718
|
-
getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<
|
|
719
|
-
protected
|
|
1472
|
+
protected getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppCloudTemplate | null>;
|
|
1473
|
+
protected mapTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
|
|
720
1474
|
protected writePrivateChatMemory(message: IChatMessage, to: string): Promise<void>;
|
|
721
|
-
|
|
1475
|
+
protected replaceTemplateParameters(template: string, data: IWhatsAppCloudTemplateParameter[]): string;
|
|
722
1476
|
}
|
|
723
1477
|
|
|
724
1478
|
declare class WhatsAppChannel implements IChatChannel {
|
|
725
1479
|
private config;
|
|
726
|
-
private chatResolver;
|
|
727
|
-
private userResolver;
|
|
728
1480
|
private sender;
|
|
729
1481
|
private receiver;
|
|
730
1482
|
private logger;
|
|
731
|
-
constructor(config: WhatsappChannelConfig,
|
|
732
|
-
listen(callback: (message:
|
|
1483
|
+
constructor(config: WhatsappChannelConfig, sender: WhatsAppSender, receiver: WhatsAppReceiver);
|
|
1484
|
+
listen(callback: (message: IChannelMessage) => void): void;
|
|
733
1485
|
connect(): void;
|
|
734
1486
|
}
|
|
735
1487
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
private devToken;
|
|
740
|
-
private logger;
|
|
741
|
-
static isTokenAvailable(): boolean;
|
|
742
|
-
constructor();
|
|
743
|
-
getSocket(): Promise<Socket>;
|
|
1488
|
+
interface IWhatsAppCloudWebhookPayload {
|
|
1489
|
+
object: 'whatsapp_business_account';
|
|
1490
|
+
entry: IWhatsAppCloudEntry[];
|
|
744
1491
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
constructor(wabotDevConnection: WabotDevConnection);
|
|
749
|
-
connect(): Promise<void>;
|
|
1492
|
+
interface IWhatsAppCloudEntry {
|
|
1493
|
+
id: string;
|
|
1494
|
+
changes: IWhatsAppCloudChange[];
|
|
750
1495
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
private expressApp;
|
|
756
|
-
private webhookPath;
|
|
757
|
-
constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
|
|
758
|
-
connect(): Promise<void>;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
|
|
762
|
-
private wabotDevConnection;
|
|
763
|
-
constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
764
|
-
handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
765
|
-
handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
766
|
-
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
1496
|
+
type IWhatsAppCloudChange = IWhatsAppCloudMessagesChange;
|
|
1497
|
+
interface IWhatsAppCloudMessagesChange {
|
|
1498
|
+
value: IWhatsAppCloudMessagesChangeValue;
|
|
1499
|
+
field: 'messages';
|
|
767
1500
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
1501
|
+
interface IWhatsAppCloudMessagesChangeValue {
|
|
1502
|
+
messaging_product: 'whatsapp';
|
|
1503
|
+
metadata: IWhatsAppCloudMessageMetadata;
|
|
1504
|
+
contacts?: IWhatsAppCloudContact[];
|
|
1505
|
+
messages?: IWhatsAppCloudMessage[];
|
|
774
1506
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
findOrThrow(id: string): Promise<T>;
|
|
779
|
-
findAll(id: string): Promise<T[]>;
|
|
780
|
-
create(item: T): Promise<void>;
|
|
781
|
-
update(item: T): Promise<void>;
|
|
782
|
-
discard(item: T): Promise<void>;
|
|
1507
|
+
interface IWhatsAppCloudMessageMetadata {
|
|
1508
|
+
display_phone_number: string;
|
|
1509
|
+
phone_number_id: string;
|
|
783
1510
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
table: string;
|
|
788
|
-
constructor: IConstructor<P>;
|
|
789
|
-
add?: {
|
|
790
|
-
columns: {
|
|
791
|
-
[column: string]: {
|
|
792
|
-
type: string;
|
|
793
|
-
value: (item: P) => boolean | number | string | null | Date;
|
|
794
|
-
};
|
|
795
|
-
};
|
|
796
|
-
};
|
|
797
|
-
};
|
|
798
|
-
|
|
799
|
-
declare class PgRepositoryBase<P extends Persistent> {
|
|
800
|
-
protected pool: Pool;
|
|
801
|
-
protected config: IPgRepositoryConfig<any>;
|
|
802
|
-
private tableIsCreated;
|
|
803
|
-
schema: string;
|
|
804
|
-
table: string;
|
|
805
|
-
columnsList: string[];
|
|
806
|
-
columnsAndTypes: string;
|
|
807
|
-
columns: string;
|
|
808
|
-
vars: string;
|
|
809
|
-
updates: string;
|
|
810
|
-
addColumns: {
|
|
811
|
-
[columns: string]: {
|
|
812
|
-
type: string;
|
|
813
|
-
value: (item: P) => number | boolean | string | null | Date;
|
|
814
|
-
};
|
|
1511
|
+
interface IWhatsAppCloudContact {
|
|
1512
|
+
profile: {
|
|
1513
|
+
name: string;
|
|
815
1514
|
};
|
|
816
|
-
|
|
817
|
-
values(item: P): (string | number | boolean | Date | null)[];
|
|
818
|
-
protected exec(sql: string, values: any[]): Promise<void>;
|
|
819
|
-
protected query(sql: string, values: any[]): Promise<any[]>;
|
|
820
|
-
protected connect(): Promise<Pool>;
|
|
821
|
-
protected ensureTable(): Promise<void>;
|
|
822
|
-
protected ensureColumns(): Promise<void>;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
826
|
-
protected readonly config: IPgRepositoryConfig<P>;
|
|
827
|
-
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
828
|
-
find(id: string): Promise<P | null>;
|
|
829
|
-
findOrThrow(id: string): Promise<P>;
|
|
830
|
-
findAll(): Promise<P[]>;
|
|
831
|
-
create(item: P): Promise<void>;
|
|
832
|
-
update(item: P): Promise<void>;
|
|
833
|
-
discard(item: P): Promise<void>;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
|
|
837
|
-
constructor(pool: Pool);
|
|
838
|
-
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
839
|
-
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
1515
|
+
wa_id: string;
|
|
840
1516
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
isProduction(): boolean;
|
|
848
|
-
requireString(varName: string): string;
|
|
1517
|
+
type IWhatsAppCloudMessage = IWhatsAppCloudTextMessage | IWhatsAppCloudAudioMessage;
|
|
1518
|
+
interface IWhatsAppCloudBaseMessage {
|
|
1519
|
+
from: string;
|
|
1520
|
+
id: string;
|
|
1521
|
+
timestamp: string;
|
|
1522
|
+
type: string;
|
|
849
1523
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
856
|
-
private getFromEnvVars;
|
|
1524
|
+
interface IWhatsAppCloudTextMessage extends IWhatsAppCloudBaseMessage {
|
|
1525
|
+
type: 'text';
|
|
1526
|
+
text: {
|
|
1527
|
+
body: string;
|
|
1528
|
+
};
|
|
857
1529
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
chatBotAdapter: IConstructor<IChatBotAdapter>;
|
|
1530
|
+
interface IWhatsAppCloudAudioMessage extends IWhatsAppCloudBaseMessage {
|
|
1531
|
+
type: 'audio';
|
|
1532
|
+
audio: {
|
|
1533
|
+
mime_type: string;
|
|
1534
|
+
sha256: string;
|
|
1535
|
+
id: string;
|
|
1536
|
+
voice: boolean;
|
|
1537
|
+
};
|
|
867
1538
|
}
|
|
868
|
-
declare function runChannel(props: IrunChannelProps): void;
|
|
869
1539
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1540
|
+
declare class WhatsAppReceiverByCloudApi extends WhatsAppReceiver {
|
|
1541
|
+
private expressProvider;
|
|
1542
|
+
private whatsAppRepository;
|
|
1543
|
+
private listeners;
|
|
1544
|
+
private expressApp;
|
|
1545
|
+
private logger;
|
|
1546
|
+
private webhookPath;
|
|
1547
|
+
constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
|
|
1548
|
+
connect(): Promise<void>;
|
|
1549
|
+
listenMessage(request: IListenWhatsAppMessageRequest): void;
|
|
1550
|
+
protected handlePayload(payload: IWhatsAppCloudWebhookPayload): Promise<void>;
|
|
1551
|
+
private emmitMessage;
|
|
878
1552
|
}
|
|
879
|
-
declare function runServer(config: IServerConfig): void;
|
|
880
1553
|
|
|
881
|
-
declare class
|
|
882
|
-
|
|
883
|
-
|
|
1554
|
+
declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
|
|
1555
|
+
private logger;
|
|
1556
|
+
constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
1557
|
+
sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
1558
|
+
sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
1559
|
+
protected getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppCloudTemplate | null>;
|
|
884
1560
|
}
|
|
885
1561
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
otp: string;
|
|
1562
|
+
interface IWhatsAppProxyMessageContent {
|
|
1563
|
+
text: string;
|
|
889
1564
|
}
|
|
890
1565
|
|
|
891
|
-
interface
|
|
1566
|
+
interface IWhatsAppProxyMessage {
|
|
892
1567
|
from: string;
|
|
893
1568
|
to: string;
|
|
894
|
-
|
|
895
|
-
|
|
1569
|
+
senderName?: string;
|
|
1570
|
+
content: IWhatsAppProxyMessageContent;
|
|
896
1571
|
}
|
|
897
|
-
|
|
898
|
-
|
|
1572
|
+
|
|
1573
|
+
declare const WHATSAPP_PROXY_SEND_MESSAGE_EVENT: "sendMessage";
|
|
1574
|
+
interface IWhatsAppProxySendMessageEventReq {
|
|
1575
|
+
event: typeof WHATSAPP_PROXY_SEND_MESSAGE_EVENT;
|
|
1576
|
+
data: IWhatsAppProxyMessage;
|
|
899
1577
|
}
|
|
900
|
-
declare
|
|
901
|
-
|
|
1578
|
+
declare const WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT: "listenMessage";
|
|
1579
|
+
interface IWhatsAppProxyListenMessageEventReq {
|
|
1580
|
+
event: typeof WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT;
|
|
1581
|
+
data: IWhatsAppProxyListenMessageEventData;
|
|
902
1582
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1583
|
+
interface IWhatsAppProxyListenMessageEventData {
|
|
1584
|
+
from?: string[];
|
|
1585
|
+
to: string[];
|
|
906
1586
|
}
|
|
907
|
-
declare
|
|
908
|
-
|
|
1587
|
+
declare const WHATSAPP_MESSAGE_EVENT: "message";
|
|
1588
|
+
interface IWhatsAppProxyMessageEventReq {
|
|
1589
|
+
event: typeof WHATSAPP_MESSAGE_EVENT;
|
|
1590
|
+
data: IWhatsAppProxyMessage;
|
|
909
1591
|
}
|
|
910
1592
|
|
|
911
|
-
declare class
|
|
912
|
-
private
|
|
913
|
-
private
|
|
914
|
-
private
|
|
915
|
-
private
|
|
916
|
-
constructor(
|
|
917
|
-
|
|
918
|
-
validateOneTimePassword(request: ValidateOneTimePasswordRequest): Promise<string>;
|
|
919
|
-
protected generateOtpEmailHtml(otp: string, user: User): Promise<string>;
|
|
920
|
-
protected generateOtpEmailSubject(): Promise<string>;
|
|
1593
|
+
declare class WhatsAppWabotProxyConnection {
|
|
1594
|
+
private baseUrl;
|
|
1595
|
+
private socket;
|
|
1596
|
+
private apiKey;
|
|
1597
|
+
private logger;
|
|
1598
|
+
constructor(env: Env);
|
|
1599
|
+
getSocket(): Promise<Socket$1>;
|
|
921
1600
|
}
|
|
922
1601
|
|
|
923
|
-
declare class
|
|
924
|
-
|
|
925
|
-
|
|
1602
|
+
declare class WhatsAppReceiverByWabotProxy extends WhatsAppReceiver {
|
|
1603
|
+
private connection;
|
|
1604
|
+
private loger;
|
|
1605
|
+
constructor(connection: WhatsAppWabotProxyConnection);
|
|
1606
|
+
connect(): Promise<void>;
|
|
1607
|
+
listenMessage(request: IListenWhatsAppMessageRequest): void;
|
|
926
1608
|
}
|
|
927
1609
|
|
|
928
|
-
declare class
|
|
929
|
-
private
|
|
930
|
-
private
|
|
931
|
-
constructor(
|
|
932
|
-
|
|
1610
|
+
declare class WhatsAppSenderByWabotProxy extends WhatsAppSender {
|
|
1611
|
+
private wabotDevConnection;
|
|
1612
|
+
private logger;
|
|
1613
|
+
constructor(wabotDevConnection: WhatsAppWabotProxyConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
1614
|
+
sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
933
1615
|
}
|
|
934
1616
|
|
|
935
1617
|
interface IHtmlModuleOptions {
|
|
@@ -940,185 +1622,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
|
|
|
940
1622
|
new (): {};
|
|
941
1623
|
};
|
|
942
1624
|
|
|
943
|
-
|
|
944
|
-
constructor(pool: Pool);
|
|
945
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
declare class RamUserRepository implements IUserRepository {
|
|
949
|
-
private items;
|
|
950
|
-
create(chat: User): Promise<void>;
|
|
951
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
952
|
-
update(chat: User): Promise<void>;
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
|
|
956
|
-
constructor(pool: Pool);
|
|
957
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
958
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMemory {
|
|
962
|
-
private chatId;
|
|
963
|
-
constructor(pool: Pool, chatId: string);
|
|
964
|
-
findLastItems(count: number): Promise<ChatItem[]>;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
declare class RamChatMemory implements IChatMemory {
|
|
968
|
-
private memory;
|
|
969
|
-
findLastItems(count: number): Promise<ChatItem[]>;
|
|
970
|
-
create(item: ChatItem): Promise<void>;
|
|
971
|
-
clearMemory(): Promise<void>;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
declare class RamChatRepository implements IChatRepository {
|
|
975
|
-
private items;
|
|
976
|
-
private memories;
|
|
977
|
-
create(chat: Chat): Promise<void>;
|
|
978
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
979
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
980
|
-
private getMemory;
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
interface IGetConfig {
|
|
984
|
-
path?: string;
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
declare function get(config?: IGetConfig): (target: object, propertyKey: string | symbol) => void;
|
|
988
|
-
|
|
989
|
-
interface IPostConfig {
|
|
990
|
-
path?: string;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
declare function post(config?: IPostConfig): (target: object, propertyKey: string | symbol) => void;
|
|
994
|
-
|
|
995
|
-
interface IRestControllerConfig {
|
|
996
|
-
path: string;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
declare function restController(config: IRestControllerConfig): (target: IConstructor<any>) => void;
|
|
1000
|
-
|
|
1001
|
-
interface IEndPointMetadata {
|
|
1002
|
-
method: 'get' | 'post';
|
|
1003
|
-
path?: string;
|
|
1004
|
-
controllerConstructor: IConstructor<any>;
|
|
1005
|
-
functionName: string;
|
|
1006
|
-
paramsTypes: any[];
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
interface IRestControllerMetadata {
|
|
1010
|
-
controllerConstructor: IConstructor<any>;
|
|
1011
|
-
path: string;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
declare class RestControllerMetadataStore {
|
|
1015
|
-
private endPoints;
|
|
1016
|
-
private restControllers;
|
|
1017
|
-
saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
|
|
1018
|
-
saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
|
|
1019
|
-
getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
|
|
1020
|
-
controller: IRestControllerMetadata;
|
|
1021
|
-
method: "get" | "post";
|
|
1022
|
-
path?: string;
|
|
1023
|
-
controllerConstructor: IConstructor<any>;
|
|
1024
|
-
functionName: string;
|
|
1025
|
-
paramsTypes: any[];
|
|
1026
|
-
}[];
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
declare function runRestControllers(controllers: IConstructor<any>[], container: DependencyContainer$1): void;
|
|
1030
|
-
|
|
1031
|
-
declare function isBoolean(): (target: object, propertyKey: string | symbol) => void;
|
|
1032
|
-
|
|
1033
|
-
declare function isDate(): (target: object, propertyKey: string | symbol) => void;
|
|
1034
|
-
|
|
1035
|
-
declare function isNotEmpty(): (target: object, propertyKey: string | symbol) => void;
|
|
1036
|
-
|
|
1037
|
-
declare function isNumber(): (target: object, propertyKey: string | symbol) => void;
|
|
1038
|
-
|
|
1039
|
-
declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
|
|
1040
|
-
|
|
1041
|
-
declare function isPresent(): (target: object, propertyKey: string | symbol) => void;
|
|
1042
|
-
|
|
1043
|
-
declare function isString(): (target: object, propertyKey: string | symbol) => void;
|
|
1044
|
-
|
|
1045
|
-
declare function max(limit: any): (target: object, propertyKey: string | symbol) => void;
|
|
1046
|
-
|
|
1047
|
-
declare function min(limit: any): (target: object, propertyKey: string | symbol) => void;
|
|
1048
|
-
|
|
1049
|
-
declare function validable<A>(): (target: IConstructor<A>) => void;
|
|
1050
|
-
|
|
1051
|
-
interface IValidationError {
|
|
1052
|
-
description: string;
|
|
1053
|
-
}
|
|
1054
|
-
interface IModelValidationError {
|
|
1055
|
-
model: IValidationError[];
|
|
1056
|
-
properties: {
|
|
1057
|
-
name: string;
|
|
1058
|
-
errors: IValidationError[];
|
|
1059
|
-
}[];
|
|
1060
|
-
}
|
|
1061
|
-
interface IValidationResult<V> {
|
|
1062
|
-
value?: V;
|
|
1063
|
-
error?: IValidationError;
|
|
1064
|
-
}
|
|
1065
|
-
interface IModelValidationResult<V> {
|
|
1066
|
-
value?: V;
|
|
1067
|
-
error?: IModelValidationError;
|
|
1068
|
-
}
|
|
1069
|
-
type IValidator = (value: any, options: any) => IValidationResult<any>;
|
|
1070
|
-
interface IPropertyValidatorInfo {
|
|
1071
|
-
propertyName: string;
|
|
1072
|
-
validator: IValidator;
|
|
1073
|
-
validatorOptions?: any;
|
|
1074
|
-
}
|
|
1075
|
-
type IModelValidatorsInfo<V> = {
|
|
1076
|
-
modelConstructor: IConstructor<V>;
|
|
1077
|
-
properties: {
|
|
1078
|
-
[prop: string]: {
|
|
1079
|
-
isOptional?: boolean;
|
|
1080
|
-
validators?: IPropertyValidatorInfo[];
|
|
1081
|
-
} | undefined;
|
|
1082
|
-
};
|
|
1083
|
-
};
|
|
1084
|
-
|
|
1085
|
-
interface IValidatorMetadata {
|
|
1086
|
-
modelConstructor: IConstructor<any>;
|
|
1087
|
-
propertyName: string;
|
|
1088
|
-
validator: IValidator;
|
|
1089
|
-
validatorOptions?: any;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
declare class ValidationMetadataStore {
|
|
1093
|
-
private validators;
|
|
1094
|
-
saveValidatorMetadata(validatorMetadata: IValidatorMetadata): void;
|
|
1095
|
-
getModelValidatorsInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
declare function validateIsBoolean(value: any): IValidationResult<boolean>;
|
|
1099
|
-
|
|
1100
|
-
declare function validateIsDate(value: any): IValidationResult<Date>;
|
|
1101
|
-
|
|
1102
|
-
declare function validateIsNotEmpty(value: any): IValidationResult<any>;
|
|
1103
|
-
|
|
1104
|
-
declare function validateIsNumber(value: any): IValidationResult<number>;
|
|
1105
|
-
|
|
1106
|
-
declare function validateIsString(value: any): IValidationResult<string>;
|
|
1107
|
-
|
|
1108
|
-
interface IValidateMaxOptions {
|
|
1109
|
-
limit: any;
|
|
1110
|
-
}
|
|
1111
|
-
declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
|
|
1112
|
-
|
|
1113
|
-
interface IValidateMinOptions {
|
|
1114
|
-
limit: any;
|
|
1115
|
-
}
|
|
1116
|
-
declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
|
|
1117
|
-
|
|
1118
|
-
declare function validateIsPresent(value: any): IValidationResult<any>;
|
|
1119
|
-
|
|
1120
|
-
declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
|
|
1121
|
-
|
|
1122
|
-
declare function validateModel2<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
|
|
1123
|
-
|
|
1124
|
-
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, DeepSeekChatBotAdapter, EmailService, 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 IEmailService, type IEndPointMetadata, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, type IReversibleMapper, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWabotEnvType, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, type IrunChannelProps, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, RegisterUserModule, RegisterUserWithEmailRequest, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WabotEnv, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, container, get, inject, injectable, isBoolean, isDate, isNotEmpty, isNumber, isOptional, isPresent, isString, max, min, mindset, mindsetFunction, mindsetModule, param, post, prepareChatContainer, restController, runChannel, runRestControllers, runServer, singleton, socket, telegram, validable, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, validateModel2, whatsapp };
|
|
1625
|
+
export { AnthropicChatAdapter, ApiKey, ApiKeyConnectionGuardMiddleware, ApiKeyGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionMiddleware, type IConnectionMiddlewareMetadata, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketConnectionConfig, type ISocketConnectionMetadata, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtConnectionGuardMiddleware, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyConnectionGuard, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, readJsonFromFile, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp, writeJsonToFile };
|