@wabot-dev/framework 0.1.0-beta.53 → 0.1.0-beta.55

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.
@@ -17,7 +17,7 @@ class JwtRefreshTokenRepository {
17
17
  update(item) {
18
18
  throw new Error('Method not implemented.');
19
19
  }
20
- discard(item) {
20
+ delete(item) {
21
21
  throw new Error('Method not implemented.');
22
22
  }
23
23
  }
@@ -39,9 +39,6 @@ class Entity extends Storable {
39
39
  throw new Error('createdAt is required');
40
40
  }
41
41
  }
42
- discard() {
43
- this.data.discardedAt = new Date().getTime();
44
- }
45
42
  }
46
43
  /**
47
44
  * @deprecated Should use Entity
@@ -20,7 +20,7 @@ let JobRepository = class JobRepository {
20
20
  update(item) {
21
21
  throw new Error('Method not implemented.');
22
22
  }
23
- discard(item) {
23
+ delete(item) {
24
24
  throw new Error('Method not implemented.');
25
25
  }
26
26
  };
@@ -71,14 +71,12 @@ class PgCrudRepository extends PgRepositoryBase {
71
71
  `;
72
72
  await this.exec(sql, [...this.values(item), item.id]);
73
73
  }
74
- async discard(item) {
75
- const _item = await this.find(item.id);
76
- if (!_item) {
77
- throw new Error('Not found');
78
- }
79
- item.discard();
80
- _item.discard();
81
- await this.update(_item);
74
+ async delete(item) {
75
+ const sql = `
76
+ DELETE FROM ${this.table}
77
+ WHERE id = $1
78
+ `;
79
+ await this.exec(sql, [item.id]);
82
80
  }
83
81
  }
84
82
 
@@ -0,0 +1,7 @@
1
+ import { methodDecorator } from './methodDecorator.js';
2
+
3
+ function onDelete(config) {
4
+ return methodDecorator('delete', config);
5
+ }
6
+
7
+ export { onDelete };
@@ -0,0 +1,7 @@
1
+ import { methodDecorator } from './methodDecorator.js';
2
+
3
+ function onGet(config) {
4
+ return methodDecorator('get', config);
5
+ }
6
+
7
+ export { onGet };
@@ -0,0 +1,7 @@
1
+ import { methodDecorator } from './methodDecorator.js';
2
+
3
+ function onPost(config) {
4
+ return methodDecorator('post', config);
5
+ }
6
+
7
+ export { onPost };
@@ -0,0 +1,7 @@
1
+ import { methodDecorator } from './methodDecorator.js';
2
+
3
+ function onPut(config) {
4
+ return methodDecorator('put', config);
5
+ }
6
+
7
+ export { onPut };
@@ -1,14 +1,14 @@
1
1
  import { container } from '../../../core/injection/index.js';
2
2
  import { RestControllerMetadataStore } from './RestControllerMetadataStore.js';
3
3
 
4
- function get(config) {
4
+ function methodDecorator(method, config) {
5
5
  return function (target, propertyKey) {
6
6
  const functionName = propertyKey.toString();
7
7
  const paramsTypes = Reflect.getMetadata('design:paramtypes', target, functionName);
8
8
  const store = container.resolve(RestControllerMetadataStore);
9
9
  store.saveEndPointMetadata({
10
10
  controllerConstructor: target.constructor,
11
- method: 'get',
11
+ method,
12
12
  config: typeof config === 'string' ? { path: config } : config,
13
13
  functionName,
14
14
  paramsTypes,
@@ -16,4 +16,4 @@ function get(config) {
16
16
  };
17
17
  }
18
18
 
19
- export { get };
19
+ export { methodDecorator };
@@ -46,7 +46,6 @@ declare class Entity<D extends IEntityData> extends Storable<D> {
46
46
  update(newData: Omit<D, 'id' | 'createdAt' | 'discardedAt'>): void;
47
47
  wasCreated(): boolean;
48
48
  validate(): void;
49
- discard(): void;
50
49
  }
51
50
  /**
52
51
  * @deprecated Should use IEntityData
@@ -165,7 +164,7 @@ interface ICrudRepository<T> {
165
164
  findAll(id: string): Promise<T[]>;
166
165
  create(item: T): Promise<void>;
167
166
  update(item: T): Promise<void>;
168
- discard(item: T): Promise<void>;
167
+ delete(item: T): Promise<void>;
169
168
  }
170
169
 
171
170
  declare function isModel(model: IConstructor<any>): (target: object, propertyKey: string | symbol) => void;
@@ -352,7 +351,7 @@ declare class JobRepository implements IJobRepository {
352
351
  findAll(id: string): Promise<Job[]>;
353
352
  create(item: Job): Promise<void>;
354
353
  update(item: Job): Promise<void>;
355
- discard(item: Job): Promise<void>;
354
+ delete(item: Job): Promise<void>;
356
355
  }
357
356
 
358
357
  interface IJobEvent extends IStorableData {
@@ -820,7 +819,7 @@ declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgReposito
820
819
  findAll(): Promise<P[]>;
821
820
  create(item: P): Promise<void>;
822
821
  update(item: P): Promise<void>;
823
- discard(item: P): Promise<void>;
822
+ delete(item: P): Promise<void>;
824
823
  }
825
824
 
826
825
  interface IEndPointConfig {
@@ -829,7 +828,7 @@ interface IEndPointConfig {
829
828
  disableUrlEncodedParser?: boolean;
830
829
  }
831
830
 
832
- declare function get(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
831
+ declare function onGet(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
833
832
 
834
833
  interface IMiddleware {
835
834
  handle(req: Request, res: Response, container: DependencyContainer$1): Promise<void>;
@@ -837,7 +836,11 @@ interface IMiddleware {
837
836
 
838
837
  declare function middleware(middlewareConstructor: IConstructor<IMiddleware>): (target: object, propertyKey: string | symbol) => void;
839
838
 
840
- declare function post(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
839
+ declare function onPost(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
840
+
841
+ declare function onPut(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
842
+
843
+ declare function onDelete(config?: string | IEndPointConfig): (target: object, propertyKey: string | symbol) => void;
841
844
 
842
845
  interface IRestControllerConfig {
843
846
  path: string;
@@ -846,7 +849,7 @@ interface IRestControllerConfig {
846
849
  declare function restController(config: string | IRestControllerConfig): (target: IConstructor<any>) => void;
847
850
 
848
851
  interface IEndPointMetadata {
849
- method: 'get' | 'post';
852
+ method: 'get' | 'post' | 'put' | 'delete';
850
853
  config?: IEndPointConfig;
851
854
  controllerConstructor: IConstructor<any>;
852
855
  functionName: string;
@@ -874,7 +877,7 @@ declare class RestControllerMetadataStore {
874
877
  getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
875
878
  middlewares: IMiddlewareMetadata[];
876
879
  controller: IRestControllerMetadata;
877
- method: "get" | "post";
880
+ method: "get" | "post" | "put" | "delete";
878
881
  config?: IEndPointConfig;
879
882
  controllerConstructor: IConstructor<any>;
880
883
  functionName: string;
@@ -1079,7 +1082,7 @@ declare class JwtRefreshTokenRepository<D extends IStorableData> implements IJwt
1079
1082
  findAll(id: string): Promise<JwtRefreshToken<D>[]>;
1080
1083
  create(item: JwtRefreshToken<D>): Promise<void>;
1081
1084
  update(item: JwtRefreshToken<D>): Promise<void>;
1082
- discard(item: JwtRefreshToken<D>): Promise<void>;
1085
+ delete(item: JwtRefreshToken<D>): Promise<void>;
1083
1086
  }
1084
1087
 
1085
1088
  declare class Jwt {
@@ -1552,4 +1555,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
1552
1555
  new (): {};
1553
1556
  };
1554
1557
 
1555
- export { AnthropicChatAdapter, ApiKey, 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 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 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 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, 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, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp };
1558
+ export { AnthropicChatAdapter, ApiKey, 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 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 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 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, 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, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp };
package/dist/src/index.js CHANGED
@@ -72,9 +72,11 @@ export { Money } from './feature/money/Money.js';
72
72
  export { MoneyDto } from './feature/money/MoneyDto.js';
73
73
  export { PgCrudRepository } from './feature/pg/PgCrudRepository.js';
74
74
  export { PgRepositoryBase } from './feature/pg/PgRepositoryBase.js';
75
- export { get } from './feature/rest-controller/metadata/@get.js';
75
+ export { onGet } from './feature/rest-controller/metadata/@onGet.js';
76
76
  export { middleware } from './feature/rest-controller/metadata/@middleware.js';
77
- export { post } from './feature/rest-controller/metadata/@post.js';
77
+ export { onPost } from './feature/rest-controller/metadata/@onPost.js';
78
+ export { onPut } from './feature/rest-controller/metadata/@onPut.js';
79
+ export { onDelete } from './feature/rest-controller/metadata/@onDelete.js';
78
80
  export { restController } from './feature/rest-controller/metadata/@restController.js';
79
81
  export { RestControllerMetadataStore } from './feature/rest-controller/metadata/RestControllerMetadataStore.js';
80
82
  export { runRestControllers } from './feature/rest-controller/runRestControllers.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.1.0-beta.53",
3
+ "version": "0.1.0-beta.55",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -1,19 +0,0 @@
1
- import { container } from '../../../core/injection/index.js';
2
- import { RestControllerMetadataStore } from './RestControllerMetadataStore.js';
3
-
4
- function post(config) {
5
- return function (target, propertyKey) {
6
- const functionName = propertyKey.toString();
7
- const paramsTypes = Reflect.getMetadata('design:paramtypes', target, functionName);
8
- const store = container.resolve(RestControllerMetadataStore);
9
- store.saveEndPointMetadata({
10
- controllerConstructor: target.constructor,
11
- method: 'post',
12
- config: typeof config === 'string' ? { path: config } : config,
13
- functionName,
14
- paramsTypes,
15
- });
16
- };
17
- }
18
-
19
- export { post };