@wabot-dev/framework 0.1.0-beta.38 → 0.1.0-beta.39

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.
@@ -0,0 +1,22 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import '../../core/injection/index.js';
3
+ import '../../core/validation/metadata/ValidationMetadataStore.js';
4
+ import { isNotEmpty } from '../validation/is-not-empty/@isNotEmpty.js';
5
+ import { isString } from '../validation/is-string/@isString.js';
6
+
7
+ class MoneyDto {
8
+ amount = '';
9
+ currency = '';
10
+ }
11
+ __decorate([
12
+ isString(),
13
+ isNotEmpty(),
14
+ __metadata("design:type", String)
15
+ ], MoneyDto.prototype, "amount", void 0);
16
+ __decorate([
17
+ isString(),
18
+ isNotEmpty(),
19
+ __metadata("design:type", String)
20
+ ], MoneyDto.prototype, "currency", void 0);
21
+
22
+ export { MoneyDto };
@@ -6,7 +6,6 @@ import '../../../core/validation/metadata/ValidationMetadataStore.js';
6
6
  import '../../../feature/express/ExpressProvider.js';
7
7
  import 'express';
8
8
  import 'path';
9
- import '../../../feature/rest-controller/auth/Auth.js';
10
9
  import { JwtGuardMiddleware } from './JwtGuardMiddleware.js';
11
10
 
12
11
  function jwtGuard() {
@@ -3,13 +3,7 @@ import { JwtSigner } from './JwtSigner.js';
3
3
  import { JwtRefreshTokenRepository } from './JwtRefreshTokenRepository.js';
4
4
  import { JwtRefreshToken } from './JwtRefreshToken.js';
5
5
  import { injectable } from '../../../core/injection/index.js';
6
- import '../../../feature/rest-controller/metadata/RestControllerMetadataStore.js';
7
- import 'debug';
8
- import '../../../core/validation/metadata/ValidationMetadataStore.js';
9
- import '../../../feature/express/ExpressProvider.js';
10
- import 'express';
11
- import 'path';
12
- import { Auth } from '../../../feature/rest-controller/auth/Auth.js';
6
+ import { Auth } from '../../../core/auth/Auth.js';
13
7
 
14
8
  let Jwt = class Jwt {
15
9
  auth;
@@ -1,15 +1,9 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import { CustomError } from '../../../core/error/CustomError.js';
3
3
  import { injectable } from '../../../core/injection/index.js';
4
- import '../../../feature/rest-controller/metadata/RestControllerMetadataStore.js';
5
- import 'debug';
6
- import '../../../core/validation/metadata/ValidationMetadataStore.js';
7
- import '../../../feature/express/ExpressProvider.js';
8
- import 'express';
9
- import 'path';
10
- import { Auth } from '../../../feature/rest-controller/auth/Auth.js';
11
4
  import jwt from 'jsonwebtoken';
12
5
  import { JwtConfig } from './JwtConfig.js';
6
+ import { Auth } from '../../../core/auth/Auth.js';
13
7
 
14
8
  let JwtGuardMiddleware = class JwtGuardMiddleware {
15
9
  config;
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from 'tslib';
2
- import { CustomError } from '../../../core/error/CustomError.js';
3
- import { scoped, Lifecycle } from '../../../core/injection/index.js';
2
+ import { CustomError } from '../error/CustomError.js';
3
+ import { scoped, Lifecycle } from '../injection/index.js';
4
4
 
5
5
  let Auth = class Auth {
6
6
  authInfo = null;
@@ -0,0 +1,61 @@
1
+ import { Storable } from '../../core/storable/Storable.js';
2
+ import { Big } from 'big.js';
3
+
4
+ Big.strict = true;
5
+ class Money extends Storable {
6
+ getData() {
7
+ return { ...this.data };
8
+ }
9
+ get amount() {
10
+ return Big(this.data.amount);
11
+ }
12
+ get currency() {
13
+ return this.data.currency;
14
+ }
15
+ plus(money) {
16
+ this.validateEqualCurrencies(this.data.currency, money.data.currency);
17
+ return new Money({
18
+ amount: this.amount.plus(money.amount).toFixed(6),
19
+ currency: this.currency,
20
+ });
21
+ }
22
+ minus(money) {
23
+ this.validateEqualCurrencies(this.data.currency, money.data.currency);
24
+ return new Money({
25
+ amount: this.amount.minus(money.amount).toFixed(6),
26
+ currency: this.currency,
27
+ });
28
+ }
29
+ times(value) {
30
+ return new Money({
31
+ amount: this.amount.times(new Big(String(value))).toFixed(6),
32
+ currency: this.currency,
33
+ });
34
+ }
35
+ div(value) {
36
+ return new Money({
37
+ amount: this.amount.div(new Big(String(value))).toFixed(6),
38
+ currency: this.currency,
39
+ });
40
+ }
41
+ negative() {
42
+ return new Money({
43
+ amount: new Big('0').minus(this.amount).toFixed(6),
44
+ currency: this.currency,
45
+ });
46
+ }
47
+ isGretterThan(money) {
48
+ this.validateEqualCurrencies(this.data.currency, money.data.currency);
49
+ return this.amount.gt(money.amount);
50
+ }
51
+ validateEqualCurrencies(left, right) {
52
+ if (left !== right) {
53
+ throw new Error(`Is not posible operate with diferent currencies: '${left}' and '${right}'`);
54
+ }
55
+ }
56
+ static zero(currency) {
57
+ return new Money({ currency, amount: '0' });
58
+ }
59
+ }
60
+
61
+ export { Money };
@@ -7,6 +7,7 @@ import InterceptionOptions from 'tsyringe/dist/typings/types/interceptor-options
7
7
  import { Server } from 'http';
8
8
  import { Express, Request, Response } from 'express';
9
9
  import { Server as Server$1 } from 'socket.io';
10
+ import * as big_js from 'big.js';
10
11
  import { Pool } from 'pg';
11
12
  import { Socket } from 'socket.io-client';
12
13
  import { Algorithm } from 'jsonwebtoken';
@@ -20,6 +21,12 @@ declare class Storable<D extends IStorableData> {
20
21
  constructor(data: D);
21
22
  }
22
23
 
24
+ declare class Auth<D extends IStorableData> {
25
+ private authInfo;
26
+ require(): D;
27
+ assign(authInfo: D): void;
28
+ }
29
+
23
30
  interface IEntityData extends IStorableData {
24
31
  id?: string;
25
32
  createdAt?: number | null;
@@ -731,12 +738,6 @@ declare class RestControllerMetadataStore {
731
738
 
732
739
  declare function runRestControllers(controllers: IConstructor<any>[]): void;
733
740
 
734
- declare class Auth<D extends IStorableData> {
735
- private authInfo;
736
- require(): D;
737
- assign(authInfo: D): void;
738
- }
739
-
740
741
  declare const EXPRESS_REQ = "EXPRESS_REQ";
741
742
  declare const EXPRESS_RES = "EXPRESS_RES";
742
743
 
@@ -750,6 +751,28 @@ declare class SocketServerProvider {
750
751
  private createSocketServer;
751
752
  }
752
753
 
754
+ interface IMoneyData extends IStorableData {
755
+ amount: string;
756
+ currency: string;
757
+ }
758
+ declare class Money extends Storable<IMoneyData> {
759
+ getData(): {
760
+ [key: string]: IPrimitive | IStorableData | IPrimitive[] | IStorableData[];
761
+ amount: string;
762
+ currency: string;
763
+ };
764
+ get amount(): big_js.Big;
765
+ get currency(): string;
766
+ plus(money: Money): Money;
767
+ minus(money: Money): Money;
768
+ times(value: bigint | string): Money;
769
+ div(value: bigint | string): Money;
770
+ negative(): Money;
771
+ isGretterThan(money: Money): boolean;
772
+ protected validateEqualCurrencies(left: string, right: string): void;
773
+ static zero(currency: string): Money;
774
+ }
775
+
753
776
  type IPgRepositoryConfig<P extends Entity<IEntityData>> = {
754
777
  schema?: string;
755
778
  table: string;
@@ -1306,4 +1329,9 @@ interface IValidateMaxOptions {
1306
1329
  }
1307
1330
  declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
1308
1331
 
1309
- export { Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GeminiChatAdapter, HtmlModule, HttpServerProvider, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type ILanguageModelUsage, 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 IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, 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, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, scoped, singleton, socket, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
1332
+ declare class MoneyDto {
1333
+ amount: string;
1334
+ currency: string;
1335
+ }
1336
+
1337
+ export { Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GeminiChatAdapter, HtmlModule, HttpServerProvider, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type ILanguageModelUsage, 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 IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, 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, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, 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, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, scoped, singleton, socket, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
package/dist/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { Auth } from './core/auth/Auth.js';
1
2
  export { Entity, Persistent } from './core/entity/Entity.js';
2
3
  export { Env } from './core/env/Env.js';
3
4
  export { CustomError } from './core/error/CustomError.js';
@@ -56,9 +57,9 @@ export { post } from './feature/rest-controller/metadata/@post.js';
56
57
  export { restController } from './feature/rest-controller/metadata/@restController.js';
57
58
  export { RestControllerMetadataStore } from './feature/rest-controller/metadata/RestControllerMetadataStore.js';
58
59
  export { runRestControllers } from './feature/rest-controller/runRestControllers.js';
59
- export { Auth } from './feature/rest-controller/auth/Auth.js';
60
60
  export { EXPRESS_REQ, EXPRESS_RES } from './feature/rest-controller/injection-tokens.js';
61
61
  export { SocketServerProvider } from './feature/socket/SocketServerProvider.js';
62
+ export { Money } from './feature/money/Money.js';
62
63
  export { PgJobRepository } from './addon/async/pg/PgJobRepository.js';
63
64
  export { ClaudeChatAdapter } from './addon/chat-bot/claude/ClaudeChatAdapter.js';
64
65
  export { DeepSeekChatAdapter } from './addon/chat-bot/deepseek/DeepSeekChatAdapter.js';
@@ -117,4 +118,5 @@ export { min } from './addon/validation/min/@min.js';
117
118
  export { validateMin } from './addon/validation/min/validateMin.js';
118
119
  export { max } from './addon/validation/max/@max.js';
119
120
  export { validateMax } from './addon/validation/max/validateMax.js';
121
+ export { MoneyDto } from './addon/money/MoneyDto.js';
120
122
  export { Container } from './core/injection/Container.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.1.0-beta.38",
3
+ "version": "0.1.0-beta.39",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -24,6 +24,7 @@
24
24
  "@rollup/plugin-json": "6.1.0",
25
25
  "@rollup/plugin-node-resolve": "16.0.1",
26
26
  "@rollup/plugin-typescript": "12.1.2",
27
+ "@types/big.js": "^6.2.2",
27
28
  "@types/html-to-text": "^9.0.4",
28
29
  "@types/node": "22.14.1",
29
30
  "@types/react": "^19.1.2",
@@ -42,6 +43,7 @@
42
43
  "@types/jsonwebtoken": "^9.0.10",
43
44
  "@types/pg": "^8.11.14",
44
45
  "@yucacodes/ts": "^0.0.4",
46
+ "big.js": "^7.0.1",
45
47
  "body-parser": "^2.2.0",
46
48
  "debug": "^4.4.0",
47
49
  "dotenv": "^16.5.0",