mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 04:12:23 -06:00
Path mapping & deps fix & bundler changed to tsup
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { ChatwootDto } from '@api/integrations/chatwoot/dto/chatwoot.dto';
|
||||
import { ChatwootService } from '@api/integrations/chatwoot/services/chatwoot.service';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { waMonitor } from '@api/server.module';
|
||||
import { CacheService } from '@api/services/cache.service';
|
||||
import { CacheEngine } from '@cache/cacheengine';
|
||||
import { Chatwoot, ConfigService, HttpServer } from '@config/env.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
import { isURL } from 'class-validator';
|
||||
|
||||
import { CacheEngine } from '../../../../cache/cacheengine';
|
||||
import { Chatwoot, ConfigService, HttpServer } from '../../../../config/env.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { PrismaRepository } from '../../../repository/repository.service';
|
||||
import { waMonitor } from '../../../server.module';
|
||||
import { CacheService } from '../../../services/cache.service';
|
||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
import { ChatwootService } from '../services/chatwoot.service';
|
||||
|
||||
export class ChatwootController {
|
||||
constructor(
|
||||
private readonly chatwootService: ChatwootService,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Chatwoot, configService } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import postgresql from 'pg';
|
||||
|
||||
import { Chatwoot, configService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const { Pool } = postgresql;
|
||||
|
||||
class Postgres {
|
||||
private logger = new Logger(Postgres.name);
|
||||
private logger = new Logger('Postgres');
|
||||
private pool;
|
||||
private connected = false;
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { ChatwootDto } from '@api/integrations/chatwoot/dto/chatwoot.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { chatwootController } from '@api/server.module';
|
||||
import { chatwootSchema, instanceSchema } from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { chatwootSchema, instanceSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { chatwootController } from '../../../server.module';
|
||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
|
||||
export class ChatwootRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
super();
|
||||
@@ -43,5 +42,5 @@ export class ChatwootRouter extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { Options, Quoted, SendAudioDto, SendMediaDto, SendTextDto } from '@api/dto/sendMessage.dto';
|
||||
import { ChatwootDto } from '@api/integrations/chatwoot/dto/chatwoot.dto';
|
||||
import { postgresClient } from '@api/integrations/chatwoot/libs/postgres.client';
|
||||
import { chatwootImport } from '@api/integrations/chatwoot/utils/chatwoot-import-helper';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { CacheService } from '@api/services/cache.service';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { Events } from '@api/types/wa.types';
|
||||
import { Chatwoot, ConfigService, HttpServer } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import ChatwootClient, {
|
||||
ChatwootAPIConfig,
|
||||
contact,
|
||||
@@ -9,29 +20,17 @@ import ChatwootClient, {
|
||||
} from '@figuro/chatwoot-sdk';
|
||||
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
||||
import { Chatwoot as ChatwootModel, Contact as ContactModel, Message as MessageModel } from '@prisma/client';
|
||||
import i18next from '@utils/i18n';
|
||||
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||
import axios from 'axios';
|
||||
import { proto } from 'baileys';
|
||||
import FormData from 'form-data';
|
||||
import Jimp from 'jimp';
|
||||
import Long from 'long';
|
||||
import mimeTypes from 'mime-types';
|
||||
import mime from 'mime';
|
||||
import path from 'path';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
import { Chatwoot, ConfigService, HttpServer } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import i18next from '../../../../utils/i18n';
|
||||
import { sendTelemetry } from '../../../../utils/sendTelemetry';
|
||||
import { ICache } from '../../../abstract/abstract.cache';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { Options, Quoted, SendAudioDto, SendMediaDto, SendTextDto } from '../../../dto/sendMessage.dto';
|
||||
import { PrismaRepository } from '../../../repository/repository.service';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { Events } from '../../../types/wa.types';
|
||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
import { postgresClient } from '../libs/postgres.client';
|
||||
import { chatwootImport } from '../utils/chatwoot-import-helper';
|
||||
|
||||
interface ChatwootMessage {
|
||||
messageId?: number;
|
||||
inboxId?: number;
|
||||
@@ -41,7 +40,7 @@ interface ChatwootMessage {
|
||||
}
|
||||
|
||||
export class ChatwootService {
|
||||
private readonly logger = new Logger(ChatwootService.name);
|
||||
private readonly logger = new Logger('ChatwootService');
|
||||
|
||||
private provider: any;
|
||||
|
||||
@@ -49,7 +48,7 @@ export class ChatwootService {
|
||||
private readonly waMonitor: WAMonitoringService,
|
||||
private readonly configService: ConfigService,
|
||||
private readonly prismaRepository: PrismaRepository,
|
||||
private readonly cache: ICache,
|
||||
private readonly cache: CacheService,
|
||||
) {}
|
||||
|
||||
private pgClient = postgresClient.getChatwootConnection();
|
||||
@@ -997,7 +996,7 @@ export class ChatwootService {
|
||||
public async sendAttachment(waInstance: any, number: string, media: any, caption?: string, options?: Options) {
|
||||
try {
|
||||
const parsedMedia = path.parse(decodeURIComponent(media));
|
||||
let mimeType = mimeTypes.lookup(parsedMedia?.ext) || '';
|
||||
let mimeType = mime.getType(parsedMedia?.ext) || '';
|
||||
let fileName = parsedMedia?.name + parsedMedia?.ext;
|
||||
|
||||
if (!mimeType) {
|
||||
@@ -1837,9 +1836,7 @@ export class ChatwootService {
|
||||
}
|
||||
|
||||
if (!nameFile) {
|
||||
nameFile = `${Math.random().toString(36).substring(7)}.${
|
||||
mimeTypes.extension(downloadBase64.mimetype) || ''
|
||||
}`;
|
||||
nameFile = `${Math.random().toString(36).substring(7)}.${mime.getExtension(downloadBase64.mimetype) || ''}`;
|
||||
}
|
||||
|
||||
const fileData = Buffer.from(downloadBase64.base64, 'base64');
|
||||
@@ -1927,8 +1924,8 @@ export class ChatwootService {
|
||||
if (adsMessage) {
|
||||
const imgBuffer = await axios.get(adsMessage.thumbnailUrl, { responseType: 'arraybuffer' });
|
||||
|
||||
const extension = mimeTypes.extension(imgBuffer.headers['content-type']);
|
||||
const mimeType = extension && mimeTypes.lookup(extension);
|
||||
const extension = mime.getExtension(imgBuffer.headers['content-type']);
|
||||
const mimeType = extension && mime.getType(extension);
|
||||
|
||||
if (!mimeType) {
|
||||
this.logger.warn('mimetype of Ads message not found');
|
||||
@@ -1936,7 +1933,7 @@ export class ChatwootService {
|
||||
}
|
||||
|
||||
const random = Math.random().toString(36).substring(7);
|
||||
const nameFile = `${random}.${mimeTypes.extension(mimeType)}`;
|
||||
const nameFile = `${random}.${mime.getExtension(mimeType)}`;
|
||||
const fileData = Buffer.from(imgBuffer.data, 'binary');
|
||||
|
||||
const img = await Jimp.read(fileData);
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { ChatwootDto } from '@api/integrations/chatwoot/dto/chatwoot.dto';
|
||||
import { postgresClient } from '@api/integrations/chatwoot/libs/postgres.client';
|
||||
import { ChatwootService } from '@api/integrations/chatwoot/services/chatwoot.service';
|
||||
import { Chatwoot, configService } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { inbox } from '@figuro/chatwoot-sdk';
|
||||
import { Chatwoot as ChatwootModel, Contact, Message } from '@prisma/client';
|
||||
import { proto } from 'baileys';
|
||||
|
||||
import { InstanceDto } from '../../../../api/dto/instance.dto';
|
||||
import { Chatwoot, configService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
import { postgresClient } from '../libs/postgres.client';
|
||||
import { ChatwootService } from '../services/chatwoot.service';
|
||||
|
||||
type ChatwootUser = {
|
||||
user_type: string;
|
||||
user_id: number;
|
||||
@@ -28,7 +27,7 @@ type firstLastTimestamp = {
|
||||
type IWebMessageInfo = Omit<proto.IWebMessageInfo, 'key'> & Partial<Pick<proto.IWebMessageInfo, 'key'>>;
|
||||
|
||||
class ChatwootImport {
|
||||
private logger = new Logger(ChatwootImport.name);
|
||||
private logger = new Logger('ChatwootImport');
|
||||
private repositoryMessagesCache = new Map<string, Set<string>>();
|
||||
private historyMessages = new Map<string, Message[]>();
|
||||
private historyContacts = new Map<string, Contact[]>();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { configService, Dify } from '../../../../config/env.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { DifyDto, DifyIgnoreJidDto } from '../dto/dify.dto';
|
||||
import { DifyService } from '../services/dify.service';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { DifyDto, DifyIgnoreJidDto } from '@api/integrations/dify/dto/dify.dto';
|
||||
import { DifyService } from '@api/integrations/dify/services/dify.service';
|
||||
import { configService, Dify } from '@config/env.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
|
||||
export class DifyController {
|
||||
constructor(private readonly difyService: DifyService) {}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { DifyDto, DifyIgnoreJidDto, DifySettingDto } from '@api/integrations/dify/dto/dify.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { difyController } from '@api/server.module';
|
||||
import {
|
||||
difyIgnoreJidSchema,
|
||||
difySchema,
|
||||
difySettingSchema,
|
||||
difyStatusSchema,
|
||||
instanceSchema,
|
||||
} from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { difyController } from '../../../server.module';
|
||||
import { DifyDto, DifyIgnoreJidDto, DifySettingDto } from '../dto/dify.dto';
|
||||
} from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
export class DifyRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
@@ -119,5 +118,5 @@ export class DifyRouter extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { DifyDto, DifyIgnoreJidDto, DifySettingDto } from '@api/integrations/dify/dto/dify.dto';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { Auth, ConfigService, HttpServer, S3 } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { Dify, DifySession, DifySetting, Message } from '@prisma/client';
|
||||
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||
import axios from 'axios';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
import { Auth, ConfigService, HttpServer, S3 } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { sendTelemetry } from '../../../../utils/sendTelemetry';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { PrismaRepository } from '../../../repository/repository.service';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { DifyDto, DifyIgnoreJidDto, DifySettingDto } from '../dto/dify.dto';
|
||||
|
||||
export class DifyService {
|
||||
constructor(
|
||||
private readonly waMonitor: WAMonitoringService,
|
||||
@@ -19,7 +18,7 @@ export class DifyService {
|
||||
|
||||
private userMessageDebounce: { [key: string]: { message: string; timeoutId: NodeJS.Timeout } } = {};
|
||||
|
||||
private readonly logger = new Logger(DifyService.name);
|
||||
private readonly logger = new Logger('DifyService');
|
||||
|
||||
public async create(instance: InstanceDto, data: DifyDto) {
|
||||
const instanceId = await this.prismaRepository.instance
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { configService, Openai } from '../../../../config/env.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { OpenaiCredsDto, OpenaiDto, OpenaiIgnoreJidDto } from '../dto/openai.dto';
|
||||
import { OpenaiService } from '../services/openai.service';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { OpenaiCredsDto, OpenaiDto, OpenaiIgnoreJidDto } from '@api/integrations/openai/dto/openai.dto';
|
||||
import { OpenaiService } from '@api/integrations/openai/services/openai.service';
|
||||
import { configService, Openai } from '@config/env.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
|
||||
export class OpenaiController {
|
||||
constructor(private readonly openaiService: OpenaiService) {}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import {
|
||||
OpenaiCredsDto,
|
||||
OpenaiDto,
|
||||
OpenaiIgnoreJidDto,
|
||||
OpenaiSettingDto,
|
||||
} from '@api/integrations/openai/dto/openai.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { openaiController } from '@api/server.module';
|
||||
import {
|
||||
instanceSchema,
|
||||
openaiCredsSchema,
|
||||
@@ -7,12 +15,8 @@ import {
|
||||
openaiSchema,
|
||||
openaiSettingSchema,
|
||||
openaiStatusSchema,
|
||||
} from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { openaiController } from '../../../server.module';
|
||||
import { OpenaiCredsDto, OpenaiDto, OpenaiIgnoreJidDto, OpenaiSettingDto } from '../dto/openai.dto';
|
||||
} from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
export class OpenaiRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
@@ -160,5 +164,5 @@ export class OpenaiRouter extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import {
|
||||
OpenaiCredsDto,
|
||||
OpenaiDto,
|
||||
OpenaiIgnoreJidDto,
|
||||
OpenaiSettingDto,
|
||||
} from '@api/integrations/openai/dto/openai.dto';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { ConfigService, Language, S3 } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { Message, OpenaiBot, OpenaiCreds, OpenaiSession, OpenaiSetting } from '@prisma/client';
|
||||
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||
import axios from 'axios';
|
||||
import { downloadMediaMessage } from 'baileys';
|
||||
import FormData from 'form-data';
|
||||
import OpenAI from 'openai';
|
||||
import P from 'pino';
|
||||
|
||||
import { ConfigService, Language, S3 } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { sendTelemetry } from '../../../../utils/sendTelemetry';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { PrismaRepository } from '../../../repository/repository.service';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { OpenaiCredsDto, OpenaiDto, OpenaiIgnoreJidDto, OpenaiSettingDto } from '../dto/openai.dto';
|
||||
|
||||
export class OpenaiService {
|
||||
constructor(
|
||||
private readonly waMonitor: WAMonitoringService,
|
||||
@@ -24,7 +28,7 @@ export class OpenaiService {
|
||||
|
||||
private client: OpenAI;
|
||||
|
||||
private readonly logger = new Logger(OpenaiService.name);
|
||||
private readonly logger = new Logger('OpenaiService');
|
||||
|
||||
public async createCreds(instance: InstanceDto, data: OpenaiCredsDto) {
|
||||
const instanceId = await this.prismaRepository.instance
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { configService, Rabbitmq } from '../../../../config/env.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { RabbitmqDto } from '../dto/rabbitmq.dto';
|
||||
import { RabbitmqService } from '../services/rabbitmq.service';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { RabbitmqDto } from '@api/integrations/rabbitmq/dto/rabbitmq.dto';
|
||||
import { RabbitmqService } from '@api/integrations/rabbitmq/services/rabbitmq.service';
|
||||
import { configService, Rabbitmq } from '@config/env.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
|
||||
export class RabbitmqController {
|
||||
constructor(private readonly rabbitmqService: RabbitmqService) {}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { configService, Rabbitmq } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { JsonValue } from '@prisma/client/runtime/library';
|
||||
import * as amqp from 'amqplib/callback_api';
|
||||
|
||||
import { configService, Rabbitmq } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const logger = new Logger('AMQP');
|
||||
|
||||
let amqpChannel: amqp.Channel | null = null;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { RabbitmqDto } from '@api/integrations/rabbitmq/dto/rabbitmq.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { rabbitmqController } from '@api/server.module';
|
||||
import { instanceSchema, rabbitmqSchema } from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { instanceSchema, rabbitmqSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { rabbitmqController } from '../../../server.module';
|
||||
import { RabbitmqDto } from '../dto/rabbitmq.dto';
|
||||
|
||||
export class RabbitmqRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
super();
|
||||
@@ -33,5 +32,5 @@ export class RabbitmqRouter extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { RabbitmqDto } from '@api/integrations/rabbitmq/dto/rabbitmq.dto';
|
||||
import { initQueues } from '@api/integrations/rabbitmq/libs/amqp.server';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { Rabbitmq } from '@prisma/client';
|
||||
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { RabbitmqDto } from '../dto/rabbitmq.dto';
|
||||
import { initQueues } from '../libs/amqp.server';
|
||||
|
||||
export class RabbitmqService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||
|
||||
private readonly logger = new Logger(RabbitmqService.name);
|
||||
private readonly logger = new Logger('RabbitmqService');
|
||||
|
||||
public create(instance: InstanceDto, data: RabbitmqDto) {
|
||||
this.waMonitor.waInstances[instance.instanceName].setRabbitmq(data);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { MediaDto } from '../dto/media.dto';
|
||||
import { S3Service } from '../services/s3.service';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { MediaDto } from '@api/integrations/s3/dto/media.dto';
|
||||
import { S3Service } from '@api/integrations/s3/services/s3.service';
|
||||
|
||||
export class S3Controller {
|
||||
constructor(private readonly s3Service: S3Service) {}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { ConfigService, S3 } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
import * as MinIo from 'minio';
|
||||
import { join } from 'path';
|
||||
import { Readable, Transform } from 'stream';
|
||||
|
||||
import { ConfigService, S3 } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
|
||||
const logger = new Logger('S3 Service');
|
||||
|
||||
const BUCKET = new ConfigService().get<S3>('S3');
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { MediaDto } from '@api/integrations/s3/dto/media.dto';
|
||||
import { s3Schema, s3UrlSchema } from '@api/integrations/s3/validate/s3.schema';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { s3Controller } from '@api/server.module';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { s3Controller } from '../../../server.module';
|
||||
import { MediaDto } from '../dto/media.dto';
|
||||
import { s3Schema, s3UrlSchema } from '../validate/s3.schema';
|
||||
|
||||
export class S3Router extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
super();
|
||||
@@ -32,5 +31,5 @@ export class S3Router extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { PrismaRepository } from '../../../repository/repository.service';
|
||||
import { MediaDto } from '../dto/media.dto';
|
||||
import { getObjectUrl } from '../libs/minio.server';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { MediaDto } from '@api/integrations/s3/dto/media.dto';
|
||||
import { getObjectUrl } from '@api/integrations/s3/libs/minio.server';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
|
||||
export class S3Service {
|
||||
constructor(private readonly prismaRepository: PrismaRepository) {}
|
||||
|
||||
private readonly logger = new Logger(S3Service.name);
|
||||
private readonly logger = new Logger('S3Service');
|
||||
|
||||
public async getMedia(instance: InstanceDto, query?: MediaDto) {
|
||||
try {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { configService, Sqs } from '../../../../config/env.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { SqsDto } from '../dto/sqs.dto';
|
||||
import { SqsService } from '../services/sqs.service';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { SqsDto } from '@api/integrations/sqs/dto/sqs.dto';
|
||||
import { SqsService } from '@api/integrations/sqs/services/sqs.service';
|
||||
import { configService, Sqs } from '@config/env.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
|
||||
export class SqsController {
|
||||
constructor(private readonly sqsService: SqsService) {}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { SQS } from '@aws-sdk/client-sqs';
|
||||
import { configService, Sqs } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { JsonValue } from '@prisma/client/runtime/library';
|
||||
|
||||
import { configService, Sqs } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const logger = new Logger('SQS');
|
||||
|
||||
let sqs: SQS;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { SqsDto } from '@api/integrations/sqs/dto/sqs.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { sqsController } from '@api/server.module';
|
||||
import { instanceSchema, sqsSchema } from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { instanceSchema, sqsSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { sqsController } from '../../../server.module';
|
||||
import { SqsDto } from '../dto/sqs.dto';
|
||||
|
||||
export class SqsRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
super();
|
||||
@@ -33,5 +32,5 @@ export class SqsRouter extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { SqsDto } from '@api/integrations/sqs/dto/sqs.dto';
|
||||
import { initQueues } from '@api/integrations/sqs/libs/sqs.server';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { Sqs } from '@prisma/client';
|
||||
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { SqsDto } from '../dto/sqs.dto';
|
||||
import { initQueues } from '../libs/sqs.server';
|
||||
|
||||
export class SqsService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||
|
||||
private readonly logger = new Logger(SqsService.name);
|
||||
private readonly logger = new Logger('SqsService');
|
||||
|
||||
public create(instance: InstanceDto, data: SqsDto) {
|
||||
this.waMonitor.waInstances[instance.instanceName].setSqs(data);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { configService, Typebot } from '../../../../config/env.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { TypebotDto, TypebotIgnoreJidDto } from '../dto/typebot.dto';
|
||||
import { TypebotService } from '../services/typebot.service';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { TypebotDto, TypebotIgnoreJidDto } from '@api/integrations/typebot/dto/typebot.dto';
|
||||
import { TypebotService } from '@api/integrations/typebot/services/typebot.service';
|
||||
import { configService, Typebot } from '@config/env.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
|
||||
export class TypebotController {
|
||||
constructor(private readonly typebotService: TypebotService) {}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { TypebotDto, TypebotIgnoreJidDto, TypebotSettingDto } from '@api/integrations/typebot/dto/typebot.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { typebotController } from '@api/server.module';
|
||||
import {
|
||||
instanceSchema,
|
||||
typebotIgnoreJidSchema,
|
||||
@@ -7,12 +10,8 @@ import {
|
||||
typebotSettingSchema,
|
||||
typebotStartSchema,
|
||||
typebotStatusSchema,
|
||||
} from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { typebotController } from '../../../server.module';
|
||||
import { TypebotDto, TypebotIgnoreJidDto, TypebotSettingDto } from '../dto/typebot.dto';
|
||||
} from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
export class TypebotRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
@@ -130,5 +129,5 @@ export class TypebotRouter extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { TypebotDto, TypebotIgnoreJidDto } from '@api/integrations/typebot/dto/typebot.dto';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { Events } from '@api/types/wa.types';
|
||||
import { Auth, ConfigService, HttpServer, S3, Typebot } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { Instance, Message, Typebot as TypebotModel, TypebotSession } from '@prisma/client';
|
||||
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||
import axios from 'axios';
|
||||
|
||||
import { Auth, ConfigService, HttpServer, S3, Typebot } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { sendTelemetry } from '../../../../utils/sendTelemetry';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { PrismaRepository } from '../../../repository/repository.service';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { Events } from '../../../types/wa.types';
|
||||
import { TypebotDto, TypebotIgnoreJidDto } from '../dto/typebot.dto';
|
||||
|
||||
export class TypebotService {
|
||||
constructor(
|
||||
private readonly waMonitor: WAMonitoringService,
|
||||
@@ -19,7 +18,7 @@ export class TypebotService {
|
||||
|
||||
private userMessageDebounce: { [key: string]: { message: string; timeoutId: NodeJS.Timeout } } = {};
|
||||
|
||||
private readonly logger = new Logger(TypebotService.name);
|
||||
private readonly logger = new Logger('TypebotService');
|
||||
|
||||
public async create(instance: InstanceDto, data: TypebotDto) {
|
||||
const instanceId = await this.prismaRepository.instance
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { WebsocketDto } from '../dto/websocket.dto';
|
||||
import { WebsocketService } from '../services/websocket.service';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { WebsocketDto } from '@api/integrations/websocket/dto/websocket.dto';
|
||||
import { WebsocketService } from '@api/integrations/websocket/services/websocket.service';
|
||||
|
||||
export class WebsocketController {
|
||||
constructor(private readonly websocketService: WebsocketService) {}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { configService, Cors, Websocket } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { Server } from 'http';
|
||||
import { Server as SocketIO } from 'socket.io';
|
||||
|
||||
import { configService, Cors, Websocket } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const logger = new Logger('Socket');
|
||||
|
||||
let io: SocketIO;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { WebsocketDto } from '@api/integrations/websocket/dto/websocket.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { websocketController } from '@api/server.module';
|
||||
import { instanceSchema, websocketSchema } from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { instanceSchema, websocketSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { websocketController } from '../../../server.module';
|
||||
import { WebsocketDto } from '../dto/websocket.dto';
|
||||
|
||||
export class WebsocketRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
super();
|
||||
@@ -33,5 +32,5 @@ export class WebsocketRouter extends RouterBroker {
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
public readonly router: Router = Router();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { WebsocketDto } from '@api/integrations/websocket/dto/websocket.dto';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { Websocket } from '@prisma/client';
|
||||
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { WebsocketDto } from '../dto/websocket.dto';
|
||||
|
||||
export class WebsocketService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||
|
||||
private readonly logger = new Logger(WebsocketService.name);
|
||||
private readonly logger = new Logger('WebsocketService');
|
||||
|
||||
public create(instance: InstanceDto, data: WebsocketDto) {
|
||||
this.waMonitor.waInstances[instance.instanceName].setWebsocket(data);
|
||||
|
||||
Reference in New Issue
Block a user