@wabot-dev/framework 0.1.0-beta.17 → 0.1.0-beta.19
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { singleton } from '../../injection/index.js';
|
|
3
3
|
import { WhatsApp } from './WhatsApp.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Env } from '../../env/Env.js';
|
|
5
5
|
|
|
6
6
|
let EnvWhatsAppRepository = class EnvWhatsAppRepository {
|
|
7
7
|
env;
|
|
@@ -43,7 +43,7 @@ let EnvWhatsAppRepository = class EnvWhatsAppRepository {
|
|
|
43
43
|
};
|
|
44
44
|
EnvWhatsAppRepository = __decorate([
|
|
45
45
|
singleton(),
|
|
46
|
-
__metadata("design:paramtypes", [
|
|
46
|
+
__metadata("design:paramtypes", [Env])
|
|
47
47
|
], EnvWhatsAppRepository);
|
|
48
48
|
|
|
49
49
|
export { EnvWhatsAppRepository };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { singleton } from 'tsyringe';
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let Env = class Env {
|
|
5
5
|
envType;
|
|
6
6
|
constructor() {
|
|
7
7
|
this.envType = process.env.WABOT_ENV ?? 'development';
|
|
@@ -12,16 +12,28 @@ let WabotEnv = class WabotEnv {
|
|
|
12
12
|
isProduction() {
|
|
13
13
|
return this.envType === 'production';
|
|
14
14
|
}
|
|
15
|
+
isTesting() {
|
|
16
|
+
return this.envType === 'testing';
|
|
17
|
+
}
|
|
15
18
|
requireString(varName) {
|
|
16
19
|
const value = process.env[varName];
|
|
17
20
|
if (!value)
|
|
18
21
|
throw new Error(`Env Variable ${varName} is required`);
|
|
19
22
|
return value;
|
|
20
23
|
}
|
|
24
|
+
requireNumber(varName) {
|
|
25
|
+
const strValue = process.env[varName];
|
|
26
|
+
if (!strValue)
|
|
27
|
+
throw new Error(`Env Variable ${varName} is required`);
|
|
28
|
+
const value = Number(strValue);
|
|
29
|
+
if (isNaN(value))
|
|
30
|
+
throw new Error(`Env Variable ${varName} should have number format`);
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
21
33
|
};
|
|
22
|
-
|
|
34
|
+
Env = __decorate([
|
|
23
35
|
singleton(),
|
|
24
36
|
__metadata("design:paramtypes", [])
|
|
25
|
-
],
|
|
37
|
+
], Env);
|
|
26
38
|
|
|
27
|
-
export {
|
|
39
|
+
export { Env };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -589,18 +589,20 @@ interface IWhatsAppRepository {
|
|
|
589
589
|
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
590
590
|
}
|
|
591
591
|
|
|
592
|
-
type
|
|
593
|
-
declare class
|
|
592
|
+
type IEnvType = 'development' | 'staging' | 'testing' | 'production';
|
|
593
|
+
declare class Env {
|
|
594
594
|
private envType;
|
|
595
595
|
constructor();
|
|
596
596
|
isDevelopment(): boolean;
|
|
597
597
|
isProduction(): boolean;
|
|
598
|
+
isTesting(): boolean;
|
|
598
599
|
requireString(varName: string): string;
|
|
600
|
+
requireNumber(varName: string): number;
|
|
599
601
|
}
|
|
600
602
|
|
|
601
603
|
declare class EnvWhatsAppRepository implements IWhatsAppRepository {
|
|
602
604
|
private env;
|
|
603
|
-
constructor(env:
|
|
605
|
+
constructor(env: Env);
|
|
604
606
|
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
605
607
|
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
606
608
|
private getFromEnvVars;
|
|
@@ -1194,4 +1196,4 @@ declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IM
|
|
|
1194
1196
|
|
|
1195
1197
|
declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
|
|
1196
1198
|
|
|
1197
|
-
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatBotAdapter, CmdChannel, Container, ControllerMetadataStore, CustomError, DeepSeekChatBotAdapter, EmailService, Entity, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEmailService, type IEndPointMetadata, type IEntityData, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type
|
|
1199
|
+
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatBotAdapter, CmdChannel, Container, ControllerMetadataStore, CustomError, DeepSeekChatBotAdapter, EmailService, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEmailService, type IEndPointMetadata, type IEntityData, type IEnvType, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplate, type IWhatsAppTemplateComponent, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppTemplateResponse, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, type IrunChannelProps, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, RegisterUserModule, RegisterUserWithEmailRequest, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, container, get, inject, injectable, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, max, middleware, min, mindset, mindsetFunction, mindsetModule, param, post, prepareChatContainer, restController, runChannel, runRestControllers, runServer, singleton, socket, telegram, validate, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
|
package/dist/src/index.js
CHANGED
|
@@ -42,7 +42,7 @@ export { UserRepository } from './core/user/IUserRepository.js';
|
|
|
42
42
|
export { MessageContext } from './core/IMessageContext.js';
|
|
43
43
|
export { Entity, Persistent } from './core/Entity.js';
|
|
44
44
|
export { Storable } from './core/Storable.js';
|
|
45
|
-
export {
|
|
45
|
+
export { Env } from './env/Env.js';
|
|
46
46
|
export { CustomError } from './error/CustomError.js';
|
|
47
47
|
export { container, inject, injectable, singleton } from './injection/index.js';
|
|
48
48
|
export { Logger } from './logger/Logger.js';
|
|
@@ -9,11 +9,12 @@ function validateModel(value, info) {
|
|
|
9
9
|
const propertyValidators = propertyInfo.validators ?? [];
|
|
10
10
|
resultValue[propertyName] = value[propertyName] ?? resultValue[propertyName];
|
|
11
11
|
if (resultValue[propertyName] == null && propertyInfo.isOptional) {
|
|
12
|
-
resultValue[propertyName] =
|
|
12
|
+
resultValue[propertyName] = undefined;
|
|
13
13
|
continue;
|
|
14
14
|
}
|
|
15
15
|
for (let propertyValidatorInfo of propertyValidators) {
|
|
16
16
|
const propertyValidatorResult = propertyValidatorInfo.validator(resultValue[propertyName], propertyValidatorInfo.validatorOptions);
|
|
17
|
+
resultValue[propertyName] = propertyValidatorResult.value;
|
|
17
18
|
if (propertyValidatorResult.error) {
|
|
18
19
|
let propertyErrors = propertiesErrors[propertyName];
|
|
19
20
|
if (!propertyErrors) {
|
|
@@ -22,9 +23,6 @@ function validateModel(value, info) {
|
|
|
22
23
|
}
|
|
23
24
|
propertyErrors.push(propertyValidatorResult.error.description);
|
|
24
25
|
}
|
|
25
|
-
else {
|
|
26
|
-
resultValue[propertyName] = propertyValidatorResult.value;
|
|
27
|
-
}
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
if (Object.keys(propertiesErrors).length > 0) {
|