@wabot-dev/framework 0.5.12 → 0.5.14

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.
@@ -2,12 +2,12 @@ import { __decorate, __metadata } from 'tslib';
2
2
  import { PgCrudRepository } from '../../../feature/pg/PgCrudRepository.js';
3
3
  import '../../../feature/pg/PgLocker.js';
4
4
  import 'debug';
5
+ import { CustomError } from '../../../core/error/CustomError.js';
5
6
  import 'node:crypto';
6
7
  import '../../../feature/pg/withPgClient.js';
7
8
  import '../../../feature/pg/pgStorage.js';
8
9
  import { Pool } from 'pg';
9
10
  import { ApiKey } from './ApiKey.js';
10
- import { CustomError } from '../../../core/error/CustomError.js';
11
11
  import '../../../core/error/setupErrorHandlers.js';
12
12
  import { singleton } from '../../../core/injection/index.js';
13
13
 
@@ -11,5 +11,15 @@ class CustomError extends Error {
11
11
  this.info = data.info;
12
12
  }
13
13
  }
14
+ function errorToPlainObject(error) {
15
+ const { name, message, stack } = error;
16
+ const extra = {};
17
+ for (const key of Object.keys(error)) {
18
+ if (key === 'message' || key === 'stack')
19
+ continue;
20
+ extra[key] = error[key];
21
+ }
22
+ return { name, message, stack, ...extra };
23
+ }
14
24
 
15
- export { CustomError };
25
+ export { CustomError, errorToPlainObject };
@@ -1,4 +1,5 @@
1
1
  import debug from 'debug';
2
+ import { errorToPlainObject } from '../error/CustomError.js';
2
3
 
3
4
  const levelColors = {
4
5
  trace: 0,
@@ -127,11 +128,7 @@ class Logger {
127
128
  formatArgs(args) {
128
129
  return args.map((arg) => {
129
130
  if (arg instanceof Error) {
130
- return JSON.stringify({
131
- name: arg.name,
132
- message: arg.message,
133
- stack: arg.stack,
134
- });
131
+ return JSON.stringify(errorToPlainObject(arg));
135
132
  }
136
133
  if (arg === null) {
137
134
  return 'null';
@@ -1,5 +1,7 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import { singleton } from '../../core/injection/index.js';
3
+ import { CustomError } from '../../core/error/CustomError.js';
4
+ import '../../core/error/setupErrorHandlers.js';
3
5
  import { AsyncMetadataStore } from './AsyncMetadataStore.js';
4
6
  import { Job } from './Job.js';
5
7
  import { JobRepository } from './JobRepository.js';
@@ -28,7 +30,10 @@ let Async = class Async {
28
30
  }
29
31
  const { error, value: commandData } = validateAndTransform(data, ctor);
30
32
  if (error) {
31
- throw new Error(`Validation failed: ${error.description}`);
33
+ throw new CustomError({
34
+ message: `Validation failed: ${error.description}`,
35
+ info: error,
36
+ });
32
37
  }
33
38
  const scheduledDate = this.resolveScheduledDate(scheduledAt);
34
39
  const job = new Job({
@@ -9,6 +9,9 @@ class CronJob extends Entity {
9
9
  this.computeNextRun(new Date());
10
10
  }
11
11
  }
12
+ get schedule() {
13
+ return this.data.cron;
14
+ }
12
15
  get nextRunAt() {
13
16
  return this.data.nextRunAt ? new Date(this.data.nextRunAt) : null;
14
17
  }
@@ -60,7 +60,9 @@ let CronScheduler = class CronScheduler {
60
60
  this.logger.debug(`start reconciliation of crons ${configToReconciliate.map((x) => x.name).join(', ')}`);
61
61
  try {
62
62
  const cronJobs = await Promise.all(configToReconciliate.map((x) => this.reconciliateConfig(x)));
63
- this.logger.info(`Cron reconciliation succeeded for ${configToReconciliate.map((x) => x.name).join(', ')}`);
63
+ for (const cronJob of cronJobs) {
64
+ this.logger.info(`config CRON ${cronJob.name} ${cronJob.schedule}`);
65
+ }
64
66
  this.jobScheduler.start(cronJobs.map((x) => x.commandName));
65
67
  this.jobWatchdog.start(cronJobs.map((x) => x.commandName));
66
68
  }
@@ -126,7 +128,7 @@ let CronScheduler = class CronScheduler {
126
128
  }
127
129
  }
128
130
  await this.cronRepo.update(fresh);
129
- this.logger.info(`Cron ${fresh.id} spawned ${executions} job(s), next at ${fresh.nextRunAt.toISOString()}`);
131
+ this.logger.info(`Cron ${fresh.name} spawned ${executions} job(s), next at ${fresh.nextRunAt.toISOString()}`);
130
132
  });
131
133
  }
132
134
  async reconciliateConfig(config) {
@@ -1,5 +1,5 @@
1
1
  import { Entity } from '../../core/entity/Entity.js';
2
- import { CustomError } from '../../core/error/CustomError.js';
2
+ import { errorToPlainObject } from '../../core/error/CustomError.js';
3
3
  import '../../core/error/setupErrorHandlers.js';
4
4
 
5
5
  class Job extends Entity {
@@ -78,22 +78,21 @@ class Job extends Entity {
78
78
  setAsFailed(error) {
79
79
  if (this.hasFinished())
80
80
  throw new Error(`job ${this.id} Can't be set as failed because has be finished previously`);
81
- if (!this.isRunning())
82
- throw new Error(`job ${this.id} can't be set as failed because is no running`);
83
81
  const now = new Date().getTime();
82
+ const { name: _name, message, stack, ...extra } = errorToPlainObject(error);
84
83
  this.data.error = {
85
84
  time: now,
86
- message: error.message,
87
- stack: error.stack,
88
- info: error instanceof CustomError ? error.info : undefined,
85
+ message,
86
+ stack,
87
+ info: Object.keys(extra).length > 0 ? extra : undefined,
89
88
  };
90
- if (this.data.intentNumber == null)
91
- throw new Error('Invalid intent number');
92
- const currentReintentDelay = (this.data.reintentsDelaysInSeconds ?? []).at(this.data.intentNumber);
89
+ const intentNumber = this.data.intentNumber ?? 0;
90
+ const currentReintentDelay = (this.data.reintentsDelaysInSeconds ?? []).at(intentNumber);
93
91
  if (currentReintentDelay == null) {
94
92
  this.data.failedAt = now;
95
93
  }
96
94
  else {
95
+ this.data.intentNumber = intentNumber + 1;
97
96
  this.data.scheduledAt = now + currentReintentDelay * 1000;
98
97
  this.data.startedAt = undefined;
99
98
  }
@@ -37,8 +37,11 @@ let JobExecutor = class JobExecutor {
37
37
  catch (e) {
38
38
  this.logger.error(`Job ${job.id} execution error:`, e);
39
39
  try {
40
- job.setAsFailed(e instanceof Error ? e : new Error('Job execution error'));
41
- await this.repo.update(job);
40
+ const fresh = await this.repo.findOrThrow(job.id);
41
+ if (!fresh.hasFinished()) {
42
+ fresh.setAsFailed(e instanceof Error ? e : new Error('Job execution error'));
43
+ await this.repo.update(fresh);
44
+ }
42
45
  }
43
46
  catch (updateError) {
44
47
  this.logger.error(`Failed to update job ${job.id} status:`, updateError);
@@ -3,6 +3,8 @@ import { AsyncMetadataStore } from './AsyncMetadataStore.js';
3
3
  import { JobRepository } from './JobRepository.js';
4
4
  import { Job } from './Job.js';
5
5
  import { singleton, container } from '../../core/injection/index.js';
6
+ import { CustomError } from '../../core/error/CustomError.js';
7
+ import '../../core/error/setupErrorHandlers.js';
6
8
  import { Logger } from '../../core/logger/Logger.js';
7
9
  import '../../core/validation/metadata/ValidationMetadataStore.js';
8
10
  import { validateAndTransform } from '../../core/validation/validateAndTransform.js';
@@ -34,8 +36,11 @@ let JobRunner = class JobRunner {
34
36
  let command = undefined;
35
37
  if (commandConstructor) {
36
38
  const validationResult = validateAndTransform(commandData, commandConstructor);
37
- if (!validationResult.value) {
38
- throw new Error('Invalid command data');
39
+ if (validationResult.error) {
40
+ throw new CustomError({
41
+ message: `Invalid command data: ${validationResult.error.description}`,
42
+ info: validationResult.error,
43
+ });
39
44
  }
40
45
  command = validationResult.value;
41
46
  }
@@ -23,7 +23,9 @@ let JobScheduler = class JobScheduler {
23
23
  }
24
24
  start(commands) {
25
25
  commands.forEach((x) => this.commands.add(x));
26
- this.logger.info(`Starting job handlers for commands ${commands.join(', ')}`);
26
+ for (const command of commands) {
27
+ this.logger.info(`config COMMAND ${command}`);
28
+ }
27
29
  if (this.commands.size > 0 && !this.running) {
28
30
  this.running = true;
29
31
  this.tick();
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../../core/error/CustomError.js';
1
+ import { CustomError, errorToPlainObject } from '../../core/error/CustomError.js';
2
2
  import '../../core/error/setupErrorHandlers.js';
3
3
  import { container } from '../../core/injection/index.js';
4
4
  import { Logger } from '../../core/logger/Logger.js';
@@ -76,14 +76,10 @@ function runRestControllers(controllers) {
76
76
  catch (err) {
77
77
  logger.error(`${method.toUpperCase()} ${route} failed`, err);
78
78
  if (err instanceof Error) {
79
- const keys = Object.keys(err).filter((key) => !['message', 'stack'].includes(key));
80
- const { httpCode, ...info } = keys.reduce((acc, key) => {
81
- acc[key] = err[key];
82
- return acc;
83
- }, {});
79
+ const { name: _name, stack, httpCode, ...info } = errorToPlainObject(err);
84
80
  res
85
81
  .status(httpCode ?? 500)
86
- .json(removeCircular({ error: { message: err.message, stack: err.stack, ...info } }));
82
+ .json(removeCircular({ error: { message: err.message, stack, ...info } }));
87
83
  }
88
84
  else {
89
85
  res.status(500).json({ error: { message: 'Unknown error' } });
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../../core/error/CustomError.js';
1
+ import { CustomError, errorToPlainObject } from '../../core/error/CustomError.js';
2
2
  import '../../core/error/setupErrorHandlers.js';
3
3
  import { container } from '../../core/injection/index.js';
4
4
  import { Logger } from '../../core/logger/Logger.js';
@@ -72,13 +72,9 @@ function runSocketControllers(controllers) {
72
72
  catch (err) {
73
73
  logger.error(`Event '${event.config.event}' on '${namespace}' failed`, err);
74
74
  if (err instanceof Error) {
75
- const keys = Object.keys(err).filter((key) => !['message', 'stack'].includes(key));
76
- const { httpCode, ...info } = keys.reduce((acc, key) => {
77
- acc[key] = err[key];
78
- return acc;
79
- }, {});
75
+ const { name: _name, httpCode: _httpCode, ...info } = errorToPlainObject(err);
80
76
  if (typeof callback === 'function') {
81
- callback({ error: { ...info, message: err.message, stack: err.stack } });
77
+ callback({ error: info });
82
78
  }
83
79
  }
84
80
  else {
@@ -117,6 +117,7 @@ declare class CustomError extends Error {
117
117
  info?: any;
118
118
  constructor(data: ICustomErrorData);
119
119
  }
120
+ declare function errorToPlainObject(error: Error): Record<string, any>;
120
121
 
121
122
  type ErrorSeverity = 'warning' | 'error' | 'fatal';
122
123
  interface IErrorMonitorContext {
@@ -604,6 +605,7 @@ interface ICronJobData extends IEntityData {
604
605
  }
605
606
  declare class CronJob extends Entity<ICronJobData> {
606
607
  constructor(data: ICronJobData);
608
+ get schedule(): string;
607
609
  get nextRunAt(): Date | null;
608
610
  get lastRunAt(): Date | null;
609
611
  get maxConcurrency(): number;
@@ -2162,4 +2164,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
2162
2164
  new (): {};
2163
2165
  };
2164
2166
 
2165
- export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, type ClientMap, CmdChannel, Container, ControllerMetadataStore, CronJob, CronJobRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, type ErrorSeverity, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, type IChatAssociation, 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 ICmdChannelMessage, type ICmdReceivedMessage, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICronConfig, type ICronJobData, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IErrorHandlersConfig, type IErrorMonitor, type IErrorMonitorContext, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type ILockKey, type ILocker, type ILockerKey, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type IScheduleAt, type IScheduleDelay, type ISendByWasenderRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelMessage, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type ISocketReceivedMessage, type IStorableData, type ITelegramChannelConfig, type ITelegramChannelMessage, type ITelegramReceivedMessage, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWasenderChannelMessageListener, type IWasenderDeviceListMetadata, type IWasenderEvent, type IWasenderMessageContent, type IWasenderMessageContextInfo, type IWasenderMessageKey, type IWasenderMessageReceivedData, type IWasenderMessageReceivedEvent, type IWasenderQrUpdatedEvent, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppByWasenderChannelConfig, type IWhatsAppByWasenderReceivedMessage, type IWhatsAppChannelMessage, 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 IWhatsAppReceivedMessage, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgLockKey, PgLocker, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, RestRequest, SocketChannel, SocketChannelConfig, SocketChannelReceivedMessage, SocketControllerMetadataStore, SocketServerConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WasenderWebhookController, WhatsApp, WhatsAppByWasenderChannel, WhatsAppByWasenderChannelConfig, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppReceiverByWasender, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppSenderByWasender, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyGuard, apiKeyHandshakeGuard, chatBot, chatController, chatItemTypeOptions, cmd, cmdChannelName, command, commandHandler, container, cron, description, extractChatMessageText, extractNumberFromWasenderMessageKey, getClientMap, getPgClient, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isRecord, isString, jwtGuard, jwtHandshakeGuard, max, middleware, min, mindset, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, onSocketEvent, pgStorage, readJsonFromFile, restController, runChatControllers, runCommandHandlers, runCronHandlers, runRestControllers, runSocketControllers, safeJsonParse, scoped, setupErrorHandlers, singleton, socket, socketChannelName, socketController, stopCommandHandlers, stopCronHandlers, telegram, telegramChannelName, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsRecord, validateIsString, validateMax, validateMin, validateModel, whatsApp, whatsAppByWasender, whatsAppByWasenderChannelName, whatsAppChannelName, withPgClient, withPgTransaction, writeJsonToFile };
2167
+ export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, type ClientMap, CmdChannel, Container, ControllerMetadataStore, CronJob, CronJobRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, type ErrorSeverity, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, type IChatAssociation, 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 ICmdChannelMessage, type ICmdReceivedMessage, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICronConfig, type ICronJobData, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IErrorHandlersConfig, type IErrorMonitor, type IErrorMonitorContext, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type ILockKey, type ILocker, type ILockerKey, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type IScheduleAt, type IScheduleDelay, type ISendByWasenderRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelMessage, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type ISocketReceivedMessage, type IStorableData, type ITelegramChannelConfig, type ITelegramChannelMessage, type ITelegramReceivedMessage, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWasenderChannelMessageListener, type IWasenderDeviceListMetadata, type IWasenderEvent, type IWasenderMessageContent, type IWasenderMessageContextInfo, type IWasenderMessageKey, type IWasenderMessageReceivedData, type IWasenderMessageReceivedEvent, type IWasenderQrUpdatedEvent, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppByWasenderChannelConfig, type IWhatsAppByWasenderReceivedMessage, type IWhatsAppChannelMessage, 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 IWhatsAppReceivedMessage, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgLockKey, PgLocker, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, RestRequest, SocketChannel, SocketChannelConfig, SocketChannelReceivedMessage, SocketControllerMetadataStore, SocketServerConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WasenderWebhookController, WhatsApp, WhatsAppByWasenderChannel, WhatsAppByWasenderChannelConfig, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppReceiverByWasender, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppSenderByWasender, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyGuard, apiKeyHandshakeGuard, chatBot, chatController, chatItemTypeOptions, cmd, cmdChannelName, command, commandHandler, container, cron, description, errorToPlainObject, extractChatMessageText, extractNumberFromWasenderMessageKey, getClientMap, getPgClient, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isRecord, isString, jwtGuard, jwtHandshakeGuard, max, middleware, min, mindset, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, onSocketEvent, pgStorage, readJsonFromFile, restController, runChatControllers, runCommandHandlers, runCronHandlers, runRestControllers, runSocketControllers, safeJsonParse, scoped, setupErrorHandlers, singleton, socket, socketChannelName, socketController, stopCommandHandlers, stopCronHandlers, telegram, telegramChannelName, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsRecord, validateIsString, validateMax, validateMin, validateModel, whatsApp, whatsAppByWasender, whatsAppByWasenderChannelName, whatsAppChannelName, withPgClient, withPgTransaction, writeJsonToFile };
package/dist/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { Auth } from './core/auth/Auth.js';
2
2
  export { Entity, Persistent } from './core/entity/Entity.js';
3
3
  export { Env } from './core/env/Env.js';
4
- export { CustomError } from './core/error/CustomError.js';
4
+ export { CustomError, errorToPlainObject } from './core/error/CustomError.js';
5
5
  export { setupErrorHandlers } from './core/error/setupErrorHandlers.js';
6
6
  export { Lifecycle, container, inject, injectable, scoped, singleton } from './core/injection/index.js';
7
7
  export { Logger } from './core/logger/Logger.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",