mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
Merge pull request #750 from judsonjuniorr/v2-path-mappings
V2 Path mapping & deps fix & bundler changed to tsup
This commit is contained in:
commit
6800b63945
21
package.json
21
package.json
@ -2,13 +2,14 @@
|
|||||||
"name": "evolution-api",
|
"name": "evolution-api",
|
||||||
"version": "2.0.9-rc",
|
"version": "2.0.9-rc",
|
||||||
"description": "Rest api for communication with WhatsApp",
|
"description": "Rest api for communication with WhatsApp",
|
||||||
"main": "./dist/src/main.js",
|
"main": "./dist/main.js",
|
||||||
|
"type": "commonjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsup",
|
||||||
"start": "ts-node --files --transpile-only ./src/main.ts",
|
"start": "tsnd -r tsconfig-paths/register --files --transpile-only ./src/main.ts",
|
||||||
"start:prod": "node dist/src/main",
|
"start:prod": "node dist/main",
|
||||||
"dev:server": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./src/main.ts",
|
"dev:server": "clear && tsnd -r tsconfig-paths/register --files --transpile-only --respawn --ignore-watch node_modules ./src/main.ts",
|
||||||
"test": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./test/all.test.ts",
|
"test": "clear && tsnd -r tsconfig-paths/register --files --transpile-only --respawn --ignore-watch node_modules ./test/all.test.ts",
|
||||||
"lint": "eslint --fix --ext .ts src",
|
"lint": "eslint --fix --ext .ts src",
|
||||||
|
|
||||||
"db:generate": "node runWithProvider.js \"npx prisma generate --schema ./prisma/DATABASE_PROVIDER-schema.prisma\"",
|
"db:generate": "node runWithProvider.js \"npx prisma generate --schema ./prisma/DATABASE_PROVIDER-schema.prisma\"",
|
||||||
@ -75,11 +76,13 @@
|
|||||||
"jimp": "^0.16.13",
|
"jimp": "^0.16.13",
|
||||||
"join": "^3.0.0",
|
"join": "^3.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
|
"json-schema": "^0.4.0",
|
||||||
"jsonschema": "^1.4.1",
|
"jsonschema": "^1.4.1",
|
||||||
"link-preview-js": "^3.0.4",
|
"link-preview-js": "^3.0.4",
|
||||||
|
"long": "^5.2.3",
|
||||||
|
"mime": "^3.0.0",
|
||||||
"minio": "^8.0.1",
|
"minio": "^8.0.1",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
"node-mime-types": "^1.1.0",
|
|
||||||
"node-windows": "^1.0.0-beta.8",
|
"node-windows": "^1.0.0-beta.8",
|
||||||
"openai": "^4.52.7",
|
"openai": "^4.52.7",
|
||||||
"parse-bmfont-xml": "^1.1.4",
|
"parse-bmfont-xml": "^1.1.4",
|
||||||
@ -92,6 +95,7 @@
|
|||||||
"sharp": "^0.32.2",
|
"sharp": "^0.32.2",
|
||||||
"socket.io": "^4.7.1",
|
"socket.io": "^4.7.1",
|
||||||
"socks-proxy-agent": "^8.0.1",
|
"socks-proxy-agent": "^8.0.1",
|
||||||
|
"tsup": "^8.2.4",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"xml2js": "^0.6.2",
|
"xml2js": "^0.6.2",
|
||||||
"yamljs": "^0.3.0"
|
"yamljs": "^0.3.0"
|
||||||
@ -101,7 +105,7 @@
|
|||||||
"@types/cors": "^2.8.13",
|
"@types/cors": "^2.8.13",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/mime-types": "^2.1.1",
|
"@types/json-schema": "^7.0.15",
|
||||||
"@types/node": "^18.15.11",
|
"@types/node": "^18.15.11",
|
||||||
"@types/node-windows": "^0.1.2",
|
"@types/node-windows": "^0.1.2",
|
||||||
"@types/qrcode": "^1.5.0",
|
"@types/qrcode": "^1.5.0",
|
||||||
@ -116,6 +120,7 @@
|
|||||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
"ts-node-dev": "^2.0.0",
|
"ts-node-dev": "^2.0.0",
|
||||||
|
"tsconfig-paths": "^4.2.0",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
import { ConfigService, Database } from '@config/env.config';
|
||||||
|
import { ROOT_DIR } from '@config/path.config';
|
||||||
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { ConfigService, Database } from '../../config/env.config';
|
|
||||||
import { ROOT_DIR } from '../../config/path.config';
|
|
||||||
|
|
||||||
export type IInsert = { insertCount: number };
|
export type IInsert = { insertCount: number };
|
||||||
|
|
||||||
export interface IRepository {
|
export interface IRepository {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import 'express-async-errors';
|
import 'express-async-errors';
|
||||||
|
|
||||||
|
import { GetParticipant, GroupInvite } from '@api/dto/group.dto';
|
||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { BadRequestException } from '@exceptions';
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { JSONSchema7 } from 'json-schema';
|
import { JSONSchema7 } from 'json-schema';
|
||||||
import { validate } from 'jsonschema';
|
import { validate } from 'jsonschema';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { BadRequestException } from '../../exceptions';
|
|
||||||
import { GetParticipant, GroupInvite } from '../dto/group.dto';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
|
|
||||||
type DataValidate<T> = {
|
type DataValidate<T> = {
|
||||||
request: Request;
|
request: Request;
|
||||||
schema: JSONSchema7;
|
schema: JSONSchema7;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { Contact, Message, MessageUpdate } from '@prisma/client';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ArchiveChatDto,
|
ArchiveChatDto,
|
||||||
BlockUserDto,
|
BlockUserDto,
|
||||||
@ -15,10 +13,11 @@ import {
|
|||||||
SendPresenceDto,
|
SendPresenceDto,
|
||||||
UpdateMessageDto,
|
UpdateMessageDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
} from '../dto/chat.dto';
|
} from '@api/dto/chat.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { Query } from '../repository/repository.service';
|
import { Query } from '@api/repository/repository.service';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
|
import { Contact, Message, MessageUpdate } from '@prisma/client';
|
||||||
|
|
||||||
export class ChatController {
|
export class ChatController {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
@ -11,9 +11,9 @@ import {
|
|||||||
GroupToggleEphemeralDto,
|
GroupToggleEphemeralDto,
|
||||||
GroupUpdateParticipantDto,
|
GroupUpdateParticipantDto,
|
||||||
GroupUpdateSettingDto,
|
GroupUpdateSettingDto,
|
||||||
} from '../dto/group.dto';
|
} from '@api/dto/group.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
|
|
||||||
export class GroupController {
|
export class GroupController {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
|
import { InstanceDto, SetPresenceDto } from '@api/dto/instance.dto';
|
||||||
|
import { ChatwootService } from '@api/integrations/chatwoot/services/chatwoot.service';
|
||||||
|
import { RabbitmqService } from '@api/integrations/rabbitmq/services/rabbitmq.service';
|
||||||
|
import { SqsService } from '@api/integrations/sqs/services/sqs.service';
|
||||||
|
import { WebsocketService } from '@api/integrations/websocket/services/websocket.service';
|
||||||
|
import { ProviderFiles } from '@api/provider/sessions';
|
||||||
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
|
import { AuthService } from '@api/services/auth.service';
|
||||||
|
import { CacheService } from '@api/services/cache.service';
|
||||||
|
import { BaileysStartupService } from '@api/services/channels/whatsapp.baileys.service';
|
||||||
|
import { BusinessStartupService } from '@api/services/channels/whatsapp.business.service';
|
||||||
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
|
import { SettingsService } from '@api/services/settings.service';
|
||||||
|
import { WebhookService } from '@api/services/webhook.service';
|
||||||
|
import { Events, Integration, wa } from '@api/types/wa.types';
|
||||||
|
import { Auth, Chatwoot, ConfigService, HttpServer, WaBusiness } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { BadRequestException, InternalServerErrorException, UnauthorizedException } from '@exceptions';
|
||||||
import { JsonValue } from '@prisma/client/runtime/library';
|
import { JsonValue } from '@prisma/client/runtime/library';
|
||||||
import { delay } from 'baileys';
|
import { delay } from 'baileys';
|
||||||
import { isArray, isURL } from 'class-validator';
|
import { isArray, isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { Auth, Chatwoot, ConfigService, HttpServer, WaBusiness } from '../../config/env.config';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { BadRequestException, InternalServerErrorException, UnauthorizedException } from '../../exceptions';
|
|
||||||
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
|
|
||||||
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
|
||||||
import { RabbitmqService } from '../integrations/rabbitmq/services/rabbitmq.service';
|
|
||||||
import { SqsService } from '../integrations/sqs/services/sqs.service';
|
|
||||||
import { WebsocketService } from '../integrations/websocket/services/websocket.service';
|
|
||||||
import { ProviderFiles } from '../provider/sessions';
|
|
||||||
import { PrismaRepository } from '../repository/repository.service';
|
|
||||||
import { AuthService } from '../services/auth.service';
|
|
||||||
import { CacheService } from '../services/cache.service';
|
|
||||||
import { BaileysStartupService } from '../services/channels/whatsapp.baileys.service';
|
|
||||||
import { BusinessStartupService } from '../services/channels/whatsapp.business.service';
|
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
|
||||||
import { SettingsService } from '../services/settings.service';
|
|
||||||
import { WebhookService } from '../services/webhook.service';
|
|
||||||
import { Events, Integration, wa } from '../types/wa.types';
|
|
||||||
import { ProxyController } from './proxy.controller';
|
import { ProxyController } from './proxy.controller';
|
||||||
|
|
||||||
export class InstanceController {
|
export class InstanceController {
|
||||||
@ -44,7 +44,7 @@ export class InstanceController {
|
|||||||
private readonly providerFiles: ProviderFiles,
|
private readonly providerFiles: ProviderFiles,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(InstanceController.name);
|
private readonly logger = new Logger('InstanceController');
|
||||||
|
|
||||||
public async createInstance({
|
public async createInstance({
|
||||||
instanceName,
|
instanceName,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { HandleLabelDto } from '../dto/label.dto';
|
import { HandleLabelDto } from '@api/dto/label.dto';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
|
|
||||||
export class LabelController {
|
export class LabelController {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { ProxyDto } from '@api/dto/proxy.dto';
|
||||||
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
|
import { ProxyService } from '@api/services/proxy.service';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { BadRequestException, NotFoundException } from '@exceptions';
|
||||||
|
import { makeProxyAgent } from '@utils/makeProxyAgent';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { BadRequestException, NotFoundException } from '../../exceptions';
|
|
||||||
import { makeProxyAgent } from '../../utils/makeProxyAgent';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { ProxyDto } from '../dto/proxy.dto';
|
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
|
||||||
import { ProxyService } from '../services/proxy.service';
|
|
||||||
|
|
||||||
const logger = new Logger('ProxyController');
|
const logger = new Logger('ProxyController');
|
||||||
|
|
||||||
export class ProxyController {
|
export class ProxyController {
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import { isBase64, isURL } from 'class-validator';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
|
||||||
import { BadRequestException } from '../../exceptions';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import {
|
import {
|
||||||
SendAudioDto,
|
SendAudioDto,
|
||||||
SendButtonDto,
|
SendButtonDto,
|
||||||
@ -15,8 +12,10 @@ import {
|
|||||||
SendStickerDto,
|
SendStickerDto,
|
||||||
SendTemplateDto,
|
SendTemplateDto,
|
||||||
SendTextDto,
|
SendTextDto,
|
||||||
} from '../dto/sendMessage.dto';
|
} from '@api/dto/sendMessage.dto';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
|
import { BadRequestException } from '@exceptions';
|
||||||
|
import { isBase64, isURL } from 'class-validator';
|
||||||
|
|
||||||
export class SendMessageController {
|
export class SendMessageController {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { SettingsDto } from '../dto/settings.dto';
|
import { SettingsDto } from '@api/dto/settings.dto';
|
||||||
import { SettingsService } from '../services/settings.service';
|
import { SettingsService } from '@api/services/settings.service';
|
||||||
|
|
||||||
export class SettingsController {
|
export class SettingsController {
|
||||||
constructor(private readonly settingsService: SettingsService) {}
|
constructor(private readonly settingsService: SettingsService) {}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { TemplateDto } from '../dto/template.dto';
|
import { TemplateDto } from '@api/dto/template.dto';
|
||||||
import { TemplateService } from '../services/template.service';
|
import { TemplateService } from '@api/services/template.service';
|
||||||
|
|
||||||
export class TemplateController {
|
export class TemplateController {
|
||||||
constructor(private readonly templateService: TemplateService) {}
|
constructor(private readonly templateService: TemplateService) {}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { WebhookDto } from '@api/dto/webhook.dto';
|
||||||
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
|
import { WebhookService } from '@api/services/webhook.service';
|
||||||
|
import { BadRequestException } from '@exceptions';
|
||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
|
|
||||||
import { BadRequestException } from '../../exceptions';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { WebhookDto } from '../dto/webhook.dto';
|
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
|
||||||
import { WebhookService } from '../services/webhook.service';
|
|
||||||
|
|
||||||
export class WebhookController {
|
export class WebhookController {
|
||||||
constructor(private readonly webhookService: WebhookService, private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly webhookService: WebhookService, private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { prismaRepository } from '@api/server.module';
|
||||||
|
import { Auth, configService, Database } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { ForbiddenException, UnauthorizedException } from '@exceptions';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
|
|
||||||
import { Auth, configService, Database } from '../../config/env.config';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { ForbiddenException, UnauthorizedException } from '../../exceptions';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { prismaRepository } from '../server.module';
|
|
||||||
|
|
||||||
const logger = new Logger('GUARD');
|
const logger = new Logger('GUARD');
|
||||||
|
|
||||||
async function apikey(req: Request, _: Response, next: NextFunction) {
|
async function apikey(req: Request, _: Response, next: NextFunction) {
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { cache, waMonitor } from '@api/server.module';
|
||||||
|
import { CacheConf, configService, Database } from '@config/env.config';
|
||||||
|
import { BadRequestException, ForbiddenException, InternalServerErrorException, NotFoundException } from '@exceptions';
|
||||||
|
import { prismaServer } from '@libs/prisma.connect';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
|
|
||||||
import { CacheConf, configService, Database } from '../../config/env.config';
|
|
||||||
import {
|
|
||||||
BadRequestException,
|
|
||||||
ForbiddenException,
|
|
||||||
InternalServerErrorException,
|
|
||||||
NotFoundException,
|
|
||||||
} from '../../exceptions';
|
|
||||||
import { prismaServer } from '../../libs/prisma.connect';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { cache, waMonitor } from '../server.module';
|
|
||||||
|
|
||||||
async function getInstance(instanceName: string) {
|
async function getInstance(instanceName: string) {
|
||||||
try {
|
try {
|
||||||
const db = configService.get<Database>('DATABASE');
|
const db = configService.get<Database>('DATABASE');
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
|
|
||||||
import { sendTelemetry } from '../../utils/sendTelemetry';
|
|
||||||
|
|
||||||
class Telemetry {
|
class Telemetry {
|
||||||
public collectTelemetry(req: Request, res: Response, next: NextFunction): void {
|
public collectTelemetry(req: Request, res: Response, next: NextFunction): void {
|
||||||
sendTelemetry(req.path);
|
sendTelemetry(req.path);
|
||||||
|
@ -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 { 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 {
|
export class ChatwootController {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly chatwootService: ChatwootService,
|
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 postgresql from 'pg';
|
||||||
|
|
||||||
import { Chatwoot, configService } from '../../../../config/env.config';
|
|
||||||
import { Logger } from '../../../../config/logger.config';
|
|
||||||
|
|
||||||
const { Pool } = postgresql;
|
const { Pool } = postgresql;
|
||||||
|
|
||||||
class Postgres {
|
class Postgres {
|
||||||
private logger = new Logger(Postgres.name);
|
private logger = new Logger('Postgres');
|
||||||
private pool;
|
private pool;
|
||||||
private connected = false;
|
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 { 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 {
|
export class ChatwootRouter extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
constructor(...guards: RequestHandler[]) {
|
||||||
super();
|
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, {
|
import ChatwootClient, {
|
||||||
ChatwootAPIConfig,
|
ChatwootAPIConfig,
|
||||||
contact,
|
contact,
|
||||||
@ -9,29 +20,17 @@ import ChatwootClient, {
|
|||||||
} from '@figuro/chatwoot-sdk';
|
} from '@figuro/chatwoot-sdk';
|
||||||
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
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 { 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 axios from 'axios';
|
||||||
import { proto } from 'baileys';
|
import { proto } from 'baileys';
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
import Jimp from 'jimp';
|
import Jimp from 'jimp';
|
||||||
import Long from 'long';
|
import Long from 'long';
|
||||||
import mimeTypes from 'mime-types';
|
import mime from 'mime';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Readable } from 'stream';
|
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 {
|
interface ChatwootMessage {
|
||||||
messageId?: number;
|
messageId?: number;
|
||||||
inboxId?: number;
|
inboxId?: number;
|
||||||
@ -41,7 +40,7 @@ interface ChatwootMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ChatwootService {
|
export class ChatwootService {
|
||||||
private readonly logger = new Logger(ChatwootService.name);
|
private readonly logger = new Logger('ChatwootService');
|
||||||
|
|
||||||
private provider: any;
|
private provider: any;
|
||||||
|
|
||||||
@ -49,7 +48,7 @@ export class ChatwootService {
|
|||||||
private readonly waMonitor: WAMonitoringService,
|
private readonly waMonitor: WAMonitoringService,
|
||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
private readonly prismaRepository: PrismaRepository,
|
private readonly prismaRepository: PrismaRepository,
|
||||||
private readonly cache: ICache,
|
private readonly cache: CacheService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private pgClient = postgresClient.getChatwootConnection();
|
private pgClient = postgresClient.getChatwootConnection();
|
||||||
@ -997,7 +996,7 @@ export class ChatwootService {
|
|||||||
public async sendAttachment(waInstance: any, number: string, media: any, caption?: string, options?: Options) {
|
public async sendAttachment(waInstance: any, number: string, media: any, caption?: string, options?: Options) {
|
||||||
try {
|
try {
|
||||||
const parsedMedia = path.parse(decodeURIComponent(media));
|
const parsedMedia = path.parse(decodeURIComponent(media));
|
||||||
let mimeType = mimeTypes.lookup(parsedMedia?.ext) || '';
|
let mimeType = mime.getType(parsedMedia?.ext) || '';
|
||||||
let fileName = parsedMedia?.name + parsedMedia?.ext;
|
let fileName = parsedMedia?.name + parsedMedia?.ext;
|
||||||
|
|
||||||
if (!mimeType) {
|
if (!mimeType) {
|
||||||
@ -1837,9 +1836,7 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!nameFile) {
|
if (!nameFile) {
|
||||||
nameFile = `${Math.random().toString(36).substring(7)}.${
|
nameFile = `${Math.random().toString(36).substring(7)}.${mime.getExtension(downloadBase64.mimetype) || ''}`;
|
||||||
mimeTypes.extension(downloadBase64.mimetype) || ''
|
|
||||||
}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileData = Buffer.from(downloadBase64.base64, 'base64');
|
const fileData = Buffer.from(downloadBase64.base64, 'base64');
|
||||||
@ -1927,8 +1924,8 @@ export class ChatwootService {
|
|||||||
if (adsMessage) {
|
if (adsMessage) {
|
||||||
const imgBuffer = await axios.get(adsMessage.thumbnailUrl, { responseType: 'arraybuffer' });
|
const imgBuffer = await axios.get(adsMessage.thumbnailUrl, { responseType: 'arraybuffer' });
|
||||||
|
|
||||||
const extension = mimeTypes.extension(imgBuffer.headers['content-type']);
|
const extension = mime.getExtension(imgBuffer.headers['content-type']);
|
||||||
const mimeType = extension && mimeTypes.lookup(extension);
|
const mimeType = extension && mime.getType(extension);
|
||||||
|
|
||||||
if (!mimeType) {
|
if (!mimeType) {
|
||||||
this.logger.warn('mimetype of Ads message not found');
|
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 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 fileData = Buffer.from(imgBuffer.data, 'binary');
|
||||||
|
|
||||||
const img = await Jimp.read(fileData);
|
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 { inbox } from '@figuro/chatwoot-sdk';
|
||||||
import { Chatwoot as ChatwootModel, Contact, Message } from '@prisma/client';
|
import { Chatwoot as ChatwootModel, Contact, Message } from '@prisma/client';
|
||||||
import { proto } from 'baileys';
|
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 = {
|
type ChatwootUser = {
|
||||||
user_type: string;
|
user_type: string;
|
||||||
user_id: number;
|
user_id: number;
|
||||||
@ -28,7 +27,7 @@ type firstLastTimestamp = {
|
|||||||
type IWebMessageInfo = Omit<proto.IWebMessageInfo, 'key'> & Partial<Pick<proto.IWebMessageInfo, 'key'>>;
|
type IWebMessageInfo = Omit<proto.IWebMessageInfo, 'key'> & Partial<Pick<proto.IWebMessageInfo, 'key'>>;
|
||||||
|
|
||||||
class ChatwootImport {
|
class ChatwootImport {
|
||||||
private logger = new Logger(ChatwootImport.name);
|
private logger = new Logger('ChatwootImport');
|
||||||
private repositoryMessagesCache = new Map<string, Set<string>>();
|
private repositoryMessagesCache = new Map<string, Set<string>>();
|
||||||
private historyMessages = new Map<string, Message[]>();
|
private historyMessages = new Map<string, Message[]>();
|
||||||
private historyContacts = new Map<string, Contact[]>();
|
private historyContacts = new Map<string, Contact[]>();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { configService, Dify } from '../../../../config/env.config';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { BadRequestException } from '../../../../exceptions';
|
import { DifyDto, DifyIgnoreJidDto } from '@api/integrations/dify/dto/dify.dto';
|
||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { DifyService } from '@api/integrations/dify/services/dify.service';
|
||||||
import { DifyDto, DifyIgnoreJidDto } from '../dto/dify.dto';
|
import { configService, Dify } from '@config/env.config';
|
||||||
import { DifyService } from '../services/dify.service';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
|
||||||
export class DifyController {
|
export class DifyController {
|
||||||
constructor(private readonly difyService: DifyService) {}
|
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 {
|
import {
|
||||||
difyIgnoreJidSchema,
|
difyIgnoreJidSchema,
|
||||||
difySchema,
|
difySchema,
|
||||||
difySettingSchema,
|
difySettingSchema,
|
||||||
difyStatusSchema,
|
difyStatusSchema,
|
||||||
instanceSchema,
|
instanceSchema,
|
||||||
} from '../../../../validate/validate.schema';
|
} from '@validate/validate.schema';
|
||||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
import { RequestHandler, Router } from 'express';
|
||||||
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';
|
|
||||||
|
|
||||||
export class DifyRouter extends RouterBroker {
|
export class DifyRouter extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
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 { Dify, DifySession, DifySetting, Message } from '@prisma/client';
|
||||||
|
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Readable } from 'stream';
|
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 {
|
export class DifyService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly waMonitor: WAMonitoringService,
|
private readonly waMonitor: WAMonitoringService,
|
||||||
@ -19,7 +18,7 @@ export class DifyService {
|
|||||||
|
|
||||||
private userMessageDebounce: { [key: string]: { message: string; timeoutId: NodeJS.Timeout } } = {};
|
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) {
|
public async create(instance: InstanceDto, data: DifyDto) {
|
||||||
const instanceId = await this.prismaRepository.instance
|
const instanceId = await this.prismaRepository.instance
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { configService, Openai } from '../../../../config/env.config';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { BadRequestException } from '../../../../exceptions';
|
import { OpenaiCredsDto, OpenaiDto, OpenaiIgnoreJidDto } from '@api/integrations/openai/dto/openai.dto';
|
||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { OpenaiService } from '@api/integrations/openai/services/openai.service';
|
||||||
import { OpenaiCredsDto, OpenaiDto, OpenaiIgnoreJidDto } from '../dto/openai.dto';
|
import { configService, Openai } from '@config/env.config';
|
||||||
import { OpenaiService } from '../services/openai.service';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
|
||||||
export class OpenaiController {
|
export class OpenaiController {
|
||||||
constructor(private readonly openaiService: OpenaiService) {}
|
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 {
|
import {
|
||||||
instanceSchema,
|
instanceSchema,
|
||||||
openaiCredsSchema,
|
openaiCredsSchema,
|
||||||
@ -7,12 +15,8 @@ import {
|
|||||||
openaiSchema,
|
openaiSchema,
|
||||||
openaiSettingSchema,
|
openaiSettingSchema,
|
||||||
openaiStatusSchema,
|
openaiStatusSchema,
|
||||||
} from '../../../../validate/validate.schema';
|
} from '@validate/validate.schema';
|
||||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
import { RequestHandler, Router } from 'express';
|
||||||
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';
|
|
||||||
|
|
||||||
export class OpenaiRouter extends RouterBroker {
|
export class OpenaiRouter extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
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 { Message, OpenaiBot, OpenaiCreds, OpenaiSession, OpenaiSetting } from '@prisma/client';
|
||||||
|
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { downloadMediaMessage } from 'baileys';
|
import { downloadMediaMessage } from 'baileys';
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
import OpenAI from 'openai';
|
import OpenAI from 'openai';
|
||||||
import P from 'pino';
|
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 {
|
export class OpenaiService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly waMonitor: WAMonitoringService,
|
private readonly waMonitor: WAMonitoringService,
|
||||||
@ -24,7 +28,7 @@ export class OpenaiService {
|
|||||||
|
|
||||||
private client: OpenAI;
|
private client: OpenAI;
|
||||||
|
|
||||||
private readonly logger = new Logger(OpenaiService.name);
|
private readonly logger = new Logger('OpenaiService');
|
||||||
|
|
||||||
public async createCreds(instance: InstanceDto, data: OpenaiCredsDto) {
|
public async createCreds(instance: InstanceDto, data: OpenaiCredsDto) {
|
||||||
const instanceId = await this.prismaRepository.instance
|
const instanceId = await this.prismaRepository.instance
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { configService, Rabbitmq } from '../../../../config/env.config';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { BadRequestException } from '../../../../exceptions';
|
import { RabbitmqDto } from '@api/integrations/rabbitmq/dto/rabbitmq.dto';
|
||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { RabbitmqService } from '@api/integrations/rabbitmq/services/rabbitmq.service';
|
||||||
import { RabbitmqDto } from '../dto/rabbitmq.dto';
|
import { configService, Rabbitmq } from '@config/env.config';
|
||||||
import { RabbitmqService } from '../services/rabbitmq.service';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
|
||||||
export class RabbitmqController {
|
export class RabbitmqController {
|
||||||
constructor(private readonly rabbitmqService: RabbitmqService) {}
|
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 { JsonValue } from '@prisma/client/runtime/library';
|
||||||
import * as amqp from 'amqplib/callback_api';
|
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');
|
const logger = new Logger('AMQP');
|
||||||
|
|
||||||
let amqpChannel: amqp.Channel | null = null;
|
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 { 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 {
|
export class RabbitmqRouter extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
constructor(...guards: RequestHandler[]) {
|
||||||
super();
|
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 { 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 {
|
export class RabbitmqService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(RabbitmqService.name);
|
private readonly logger = new Logger('RabbitmqService');
|
||||||
|
|
||||||
public create(instance: InstanceDto, data: RabbitmqDto) {
|
public create(instance: InstanceDto, data: RabbitmqDto) {
|
||||||
this.waMonitor.waInstances[instance.instanceName].setRabbitmq(data);
|
this.waMonitor.waInstances[instance.instanceName].setRabbitmq(data);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { MediaDto } from '../dto/media.dto';
|
import { MediaDto } from '@api/integrations/s3/dto/media.dto';
|
||||||
import { S3Service } from '../services/s3.service';
|
import { S3Service } from '@api/integrations/s3/services/s3.service';
|
||||||
|
|
||||||
export class S3Controller {
|
export class S3Controller {
|
||||||
constructor(private readonly s3Service: S3Service) {}
|
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 * as MinIo from 'minio';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { Readable, Transform } from 'stream';
|
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 logger = new Logger('S3 Service');
|
||||||
|
|
||||||
const BUCKET = new ConfigService().get<S3>('S3');
|
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 { 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 {
|
export class S3Router extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
constructor(...guards: RequestHandler[]) {
|
||||||
super();
|
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 { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { BadRequestException } from '../../../../exceptions';
|
import { MediaDto } from '@api/integrations/s3/dto/media.dto';
|
||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { getObjectUrl } from '@api/integrations/s3/libs/minio.server';
|
||||||
import { PrismaRepository } from '../../../repository/repository.service';
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
import { MediaDto } from '../dto/media.dto';
|
import { Logger } from '@config/logger.config';
|
||||||
import { getObjectUrl } from '../libs/minio.server';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
|
||||||
export class S3Service {
|
export class S3Service {
|
||||||
constructor(private readonly prismaRepository: PrismaRepository) {}
|
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) {
|
public async getMedia(instance: InstanceDto, query?: MediaDto) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { configService, Sqs } from '../../../../config/env.config';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { BadRequestException } from '../../../../exceptions';
|
import { SqsDto } from '@api/integrations/sqs/dto/sqs.dto';
|
||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { SqsService } from '@api/integrations/sqs/services/sqs.service';
|
||||||
import { SqsDto } from '../dto/sqs.dto';
|
import { configService, Sqs } from '@config/env.config';
|
||||||
import { SqsService } from '../services/sqs.service';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
|
||||||
export class SqsController {
|
export class SqsController {
|
||||||
constructor(private readonly sqsService: SqsService) {}
|
constructor(private readonly sqsService: SqsService) {}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { SQS } from '@aws-sdk/client-sqs';
|
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 { JsonValue } from '@prisma/client/runtime/library';
|
||||||
|
|
||||||
import { configService, Sqs } from '../../../../config/env.config';
|
|
||||||
import { Logger } from '../../../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('SQS');
|
const logger = new Logger('SQS');
|
||||||
|
|
||||||
let sqs: 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 { 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 {
|
export class SqsRouter extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
constructor(...guards: RequestHandler[]) {
|
||||||
super();
|
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 { 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 {
|
export class SqsService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(SqsService.name);
|
private readonly logger = new Logger('SqsService');
|
||||||
|
|
||||||
public create(instance: InstanceDto, data: SqsDto) {
|
public create(instance: InstanceDto, data: SqsDto) {
|
||||||
this.waMonitor.waInstances[instance.instanceName].setSqs(data);
|
this.waMonitor.waInstances[instance.instanceName].setSqs(data);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { configService, Typebot } from '../../../../config/env.config';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { BadRequestException } from '../../../../exceptions';
|
import { TypebotDto, TypebotIgnoreJidDto } from '@api/integrations/typebot/dto/typebot.dto';
|
||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { TypebotService } from '@api/integrations/typebot/services/typebot.service';
|
||||||
import { TypebotDto, TypebotIgnoreJidDto } from '../dto/typebot.dto';
|
import { configService, Typebot } from '@config/env.config';
|
||||||
import { TypebotService } from '../services/typebot.service';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
|
||||||
export class TypebotController {
|
export class TypebotController {
|
||||||
constructor(private readonly typebotService: TypebotService) {}
|
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 {
|
import {
|
||||||
instanceSchema,
|
instanceSchema,
|
||||||
typebotIgnoreJidSchema,
|
typebotIgnoreJidSchema,
|
||||||
@ -7,12 +10,8 @@ import {
|
|||||||
typebotSettingSchema,
|
typebotSettingSchema,
|
||||||
typebotStartSchema,
|
typebotStartSchema,
|
||||||
typebotStatusSchema,
|
typebotStatusSchema,
|
||||||
} from '../../../../validate/validate.schema';
|
} from '@validate/validate.schema';
|
||||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
import { RequestHandler, Router } from 'express';
|
||||||
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';
|
|
||||||
|
|
||||||
export class TypebotRouter extends RouterBroker {
|
export class TypebotRouter extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
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 { Instance, Message, Typebot as TypebotModel, TypebotSession } from '@prisma/client';
|
||||||
|
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||||
import axios from 'axios';
|
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 {
|
export class TypebotService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly waMonitor: WAMonitoringService,
|
private readonly waMonitor: WAMonitoringService,
|
||||||
@ -19,7 +18,7 @@ export class TypebotService {
|
|||||||
|
|
||||||
private userMessageDebounce: { [key: string]: { message: string; timeoutId: NodeJS.Timeout } } = {};
|
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) {
|
public async create(instance: InstanceDto, data: TypebotDto) {
|
||||||
const instanceId = await this.prismaRepository.instance
|
const instanceId = await this.prismaRepository.instance
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { WebsocketDto } from '../dto/websocket.dto';
|
import { WebsocketDto } from '@api/integrations/websocket/dto/websocket.dto';
|
||||||
import { WebsocketService } from '../services/websocket.service';
|
import { WebsocketService } from '@api/integrations/websocket/services/websocket.service';
|
||||||
|
|
||||||
export class WebsocketController {
|
export class WebsocketController {
|
||||||
constructor(private readonly websocketService: WebsocketService) {}
|
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 } from 'http';
|
||||||
import { Server as SocketIO } from 'socket.io';
|
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');
|
const logger = new Logger('Socket');
|
||||||
|
|
||||||
let io: SocketIO;
|
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 { 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 {
|
export class WebsocketRouter extends RouterBroker {
|
||||||
constructor(...guards: RequestHandler[]) {
|
constructor(...guards: RequestHandler[]) {
|
||||||
super();
|
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 { 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 {
|
export class WebsocketService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(WebsocketService.name);
|
private readonly logger = new Logger('WebsocketService');
|
||||||
|
|
||||||
public create(instance: InstanceDto, data: WebsocketDto) {
|
public create(instance: InstanceDto, data: WebsocketDto) {
|
||||||
this.waMonitor.waInstances[instance.instanceName].setWebsocket(data);
|
this.waMonitor.waInstances[instance.instanceName].setWebsocket(data);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
import { Auth, ConfigService, ProviderSession } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
import { Auth, ConfigService, ProviderSession } from '../../config/env.config';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
type ResponseSuccess = { status: number; data?: any };
|
type ResponseSuccess = { status: number; data?: any };
|
||||||
type ResponseProvider = Promise<[ResponseSuccess?, Error?]>;
|
type ResponseProvider = Promise<[ResponseSuccess?, Error?]>;
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ export class ProviderFiles {
|
|||||||
this.globalApiToken = this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY;
|
this.globalApiToken = this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly logger = new Logger(ProviderFiles.name);
|
private readonly logger = new Logger('ProviderFiles');
|
||||||
|
|
||||||
private baseUrl: string;
|
private baseUrl: string;
|
||||||
private globalApiToken: string;
|
private globalApiToken: string;
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
import { ConfigService } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
export class Query<T> {
|
export class Query<T> {
|
||||||
where?: T;
|
where?: T;
|
||||||
sort?: 'asc' | 'desc';
|
sort?: 'asc' | 'desc';
|
||||||
@ -15,7 +14,7 @@ export class PrismaRepository extends PrismaClient {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly logger = new Logger(PrismaRepository.name);
|
private readonly logger = new Logger('PrismaRepository');
|
||||||
|
|
||||||
public async onModuleInit() {
|
public async onModuleInit() {
|
||||||
await this.$connect();
|
await this.$connect();
|
||||||
|
@ -1,6 +1,24 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
import {
|
||||||
|
ArchiveChatDto,
|
||||||
|
BlockUserDto,
|
||||||
|
DeleteMessage,
|
||||||
|
getBase64FromMediaMessageDto,
|
||||||
|
MarkChatUnreadDto,
|
||||||
|
NumberDto,
|
||||||
|
PrivacySettingDto,
|
||||||
|
ProfileNameDto,
|
||||||
|
ProfilePictureDto,
|
||||||
|
ProfileStatusDto,
|
||||||
|
ReadMessageDto,
|
||||||
|
SendPresenceDto,
|
||||||
|
UpdateMessageDto,
|
||||||
|
WhatsAppNumberDto,
|
||||||
|
} from '@api/dto/chat.dto';
|
||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { Query } from '@api/repository/repository.service';
|
||||||
|
import { chatController } from '@api/server.module';
|
||||||
import { Contact, Message, MessageUpdate } from '@prisma/client';
|
import { Contact, Message, MessageUpdate } from '@prisma/client';
|
||||||
import { RequestHandler, Router } from 'express';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
archiveChatSchema,
|
archiveChatSchema,
|
||||||
blockUserSchema,
|
blockUserSchema,
|
||||||
@ -18,27 +36,9 @@ import {
|
|||||||
readMessageSchema,
|
readMessageSchema,
|
||||||
updateMessageSchema,
|
updateMessageSchema,
|
||||||
whatsappNumberSchema,
|
whatsappNumberSchema,
|
||||||
} from '../../validate/validate.schema';
|
} from '@validate/validate.schema';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RequestHandler, Router } from 'express';
|
||||||
import {
|
|
||||||
ArchiveChatDto,
|
|
||||||
BlockUserDto,
|
|
||||||
DeleteMessage,
|
|
||||||
getBase64FromMediaMessageDto,
|
|
||||||
MarkChatUnreadDto,
|
|
||||||
NumberDto,
|
|
||||||
PrivacySettingDto,
|
|
||||||
ProfileNameDto,
|
|
||||||
ProfilePictureDto,
|
|
||||||
ProfileStatusDto,
|
|
||||||
ReadMessageDto,
|
|
||||||
SendPresenceDto,
|
|
||||||
UpdateMessageDto,
|
|
||||||
WhatsAppNumberDto,
|
|
||||||
} from '../dto/chat.dto';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { Query } from '../repository/repository.service';
|
|
||||||
import { chatController } from '../server.module';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class ChatRouter extends RouterBroker {
|
export class ChatRouter extends RouterBroker {
|
||||||
@ -270,5 +270,5 @@ export class ChatRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,4 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
|
||||||
import {
|
|
||||||
AcceptGroupInviteSchema,
|
|
||||||
createGroupSchema,
|
|
||||||
getParticipantsSchema,
|
|
||||||
groupInviteSchema,
|
|
||||||
groupJidSchema,
|
|
||||||
groupSendInviteSchema,
|
|
||||||
toggleEphemeralSchema,
|
|
||||||
updateGroupDescriptionSchema,
|
|
||||||
updateGroupPictureSchema,
|
|
||||||
updateGroupSubjectSchema,
|
|
||||||
updateParticipantsSchema,
|
|
||||||
updateSettingsSchema,
|
|
||||||
} from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import {
|
import {
|
||||||
AcceptGroupInvite,
|
AcceptGroupInvite,
|
||||||
CreateGroupDto,
|
CreateGroupDto,
|
||||||
@ -28,8 +12,24 @@ import {
|
|||||||
GroupToggleEphemeralDto,
|
GroupToggleEphemeralDto,
|
||||||
GroupUpdateParticipantDto,
|
GroupUpdateParticipantDto,
|
||||||
GroupUpdateSettingDto,
|
GroupUpdateSettingDto,
|
||||||
} from '../dto/group.dto';
|
} from '@api/dto/group.dto';
|
||||||
import { groupController } from '../server.module';
|
import { groupController } from '@api/server.module';
|
||||||
|
import {
|
||||||
|
AcceptGroupInviteSchema,
|
||||||
|
createGroupSchema,
|
||||||
|
getParticipantsSchema,
|
||||||
|
groupInviteSchema,
|
||||||
|
groupJidSchema,
|
||||||
|
groupSendInviteSchema,
|
||||||
|
toggleEphemeralSchema,
|
||||||
|
updateGroupDescriptionSchema,
|
||||||
|
updateGroupPictureSchema,
|
||||||
|
updateGroupSubjectSchema,
|
||||||
|
updateParticipantsSchema,
|
||||||
|
updateSettingsSchema,
|
||||||
|
} from '@validate/validate.schema';
|
||||||
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class GroupRouter extends RouterBroker {
|
export class GroupRouter extends RouterBroker {
|
||||||
@ -198,5 +198,5 @@ export class GroupRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
|
import { authGuard } from '@api/guards/auth.guard';
|
||||||
|
import { instanceExistsGuard, instanceLoggedGuard } from '@api/guards/instance.guard';
|
||||||
|
import Telemetry from '@api/guards/telemetry.guard';
|
||||||
|
import { ChatwootRouter } from '@api/integrations/chatwoot/routes/chatwoot.router';
|
||||||
|
import { DifyRouter } from '@api/integrations/dify/routes/dify.router';
|
||||||
|
import { OpenaiRouter } from '@api/integrations/openai/routes/openai.router';
|
||||||
|
import { RabbitmqRouter } from '@api/integrations/rabbitmq/routes/rabbitmq.router';
|
||||||
|
import { S3Router } from '@api/integrations/s3/routes/s3.router';
|
||||||
|
import { SqsRouter } from '@api/integrations/sqs/routes/sqs.router';
|
||||||
|
import { TypebotRouter } from '@api/integrations/typebot/routes/typebot.router';
|
||||||
|
import { WebsocketRouter } from '@api/integrations/websocket/routes/websocket.router';
|
||||||
|
import { webhookController } from '@api/server.module';
|
||||||
|
import { configService, WaBusiness } from '@config/env.config';
|
||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import mime from 'mime';
|
import mime from 'mime';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { configService, WaBusiness } from '../../config/env.config';
|
|
||||||
import { authGuard } from '../guards/auth.guard';
|
|
||||||
import { instanceExistsGuard, instanceLoggedGuard } from '../guards/instance.guard';
|
|
||||||
import Telemetry from '../guards/telemetry.guard';
|
|
||||||
import { ChatwootRouter } from '../integrations/chatwoot/routes/chatwoot.router';
|
|
||||||
import { DifyRouter } from '../integrations/dify/routes/dify.router';
|
|
||||||
import { OpenaiRouter } from '../integrations/openai/routes/openai.router';
|
|
||||||
import { RabbitmqRouter } from '../integrations/rabbitmq/routes/rabbitmq.router';
|
|
||||||
import { S3Router } from '../integrations/s3/routes/s3.router';
|
|
||||||
import { SqsRouter } from '../integrations/sqs/routes/sqs.router';
|
|
||||||
import { TypebotRouter } from '../integrations/typebot/routes/typebot.router';
|
|
||||||
import { WebsocketRouter } from '../integrations/websocket/routes/websocket.router';
|
|
||||||
import { webhookController } from '../server.module';
|
|
||||||
import { ChatRouter } from './chat.router';
|
import { ChatRouter } from './chat.router';
|
||||||
import { GroupRouter } from './group.router';
|
import { GroupRouter } from './group.router';
|
||||||
import { InstanceRouter } from './instance.router';
|
import { InstanceRouter } from './instance.router';
|
||||||
@ -37,7 +37,7 @@ enum HttpStatus {
|
|||||||
INTERNAL_SERVER_ERROR = 500,
|
INTERNAL_SERVER_ERROR = 500,
|
||||||
}
|
}
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
const serverConfig = configService.get('SERVER');
|
const serverConfig = configService.get('SERVER');
|
||||||
const guards = [instanceExistsGuard, instanceLoggedGuard, authGuard['apikey']];
|
const guards = [instanceExistsGuard, instanceLoggedGuard, authGuard['apikey']];
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ router.get('/assets/*', (req, res) => {
|
|||||||
const filePath = path.join(basePath, 'assets/', fileName);
|
const filePath = path.join(basePath, 'assets/', fileName);
|
||||||
|
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
res.set('Content-Type', mime.lookup(filePath) || 'text/css');
|
res.set('Content-Type', mime.getType(filePath) || 'text/css');
|
||||||
res.send(fs.readFileSync(filePath));
|
res.send(fs.readFileSync(filePath));
|
||||||
} else {
|
} else {
|
||||||
res.status(404).send('File not found');
|
res.status(404).send('File not found');
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
import { InstanceDto, SetPresenceDto } from '@api/dto/instance.dto';
|
||||||
|
import { instanceController } from '@api/server.module';
|
||||||
|
import { ConfigService } from '@config/env.config';
|
||||||
|
import { instanceSchema, presenceOnlySchema } from '@validate/validate.schema';
|
||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
|
||||||
import { instanceSchema, presenceOnlySchema } from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
|
|
||||||
import { instanceController } from '../server.module';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class InstanceRouter extends RouterBroker {
|
export class InstanceRouter extends RouterBroker {
|
||||||
@ -95,5 +95,5 @@ export class InstanceRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
import { HandleLabelDto, LabelDto } from '@api/dto/label.dto';
|
||||||
|
import { labelController } from '@api/server.module';
|
||||||
|
import { handleLabelSchema } from '@validate/validate.schema';
|
||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { handleLabelSchema } from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { HandleLabelDto, LabelDto } from '../dto/label.dto';
|
|
||||||
import { labelController } from '../server.module';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class LabelRouter extends RouterBroker {
|
export class LabelRouter extends RouterBroker {
|
||||||
@ -32,5 +32,5 @@ export class LabelRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { ProxyDto } from '@api/dto/proxy.dto';
|
||||||
|
import { proxyController } from '@api/server.module';
|
||||||
|
import { instanceSchema, proxySchema } from '@validate/validate.schema';
|
||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { instanceSchema, proxySchema } from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { ProxyDto } from '../dto/proxy.dto';
|
|
||||||
import { proxyController } from '../server.module';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class ProxyRouter extends RouterBroker {
|
export class ProxyRouter extends RouterBroker {
|
||||||
@ -33,5 +33,5 @@ export class ProxyRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,4 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
|
||||||
import {
|
|
||||||
audioMessageSchema,
|
|
||||||
buttonMessageSchema,
|
|
||||||
contactMessageSchema,
|
|
||||||
listMessageSchema,
|
|
||||||
locationMessageSchema,
|
|
||||||
mediaMessageSchema,
|
|
||||||
pollMessageSchema,
|
|
||||||
reactionMessageSchema,
|
|
||||||
statusMessageSchema,
|
|
||||||
stickerMessageSchema,
|
|
||||||
templateMessageSchema,
|
|
||||||
textMessageSchema,
|
|
||||||
} from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import {
|
import {
|
||||||
SendAudioDto,
|
SendAudioDto,
|
||||||
SendButtonDto,
|
SendButtonDto,
|
||||||
@ -28,8 +12,24 @@ import {
|
|||||||
SendStickerDto,
|
SendStickerDto,
|
||||||
SendTemplateDto,
|
SendTemplateDto,
|
||||||
SendTextDto,
|
SendTextDto,
|
||||||
} from '../dto/sendMessage.dto';
|
} from '@api/dto/sendMessage.dto';
|
||||||
import { sendMessageController } from '../server.module';
|
import { sendMessageController } from '@api/server.module';
|
||||||
|
import {
|
||||||
|
audioMessageSchema,
|
||||||
|
buttonMessageSchema,
|
||||||
|
contactMessageSchema,
|
||||||
|
listMessageSchema,
|
||||||
|
locationMessageSchema,
|
||||||
|
mediaMessageSchema,
|
||||||
|
pollMessageSchema,
|
||||||
|
reactionMessageSchema,
|
||||||
|
statusMessageSchema,
|
||||||
|
stickerMessageSchema,
|
||||||
|
templateMessageSchema,
|
||||||
|
textMessageSchema,
|
||||||
|
} from '@validate/validate.schema';
|
||||||
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class MessageRouter extends RouterBroker {
|
export class MessageRouter extends RouterBroker {
|
||||||
@ -159,5 +159,5 @@ export class MessageRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { SettingsDto } from '@api/dto/settings.dto';
|
||||||
|
import { settingsController } from '@api/server.module';
|
||||||
|
import { settingsSchema } from '@validate/validate.schema';
|
||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { settingsSchema } from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { SettingsDto } from '../dto/settings.dto';
|
|
||||||
import { settingsController } from '../server.module';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class SettingsRouter extends RouterBroker {
|
export class SettingsRouter extends RouterBroker {
|
||||||
@ -33,5 +33,5 @@ export class SettingsRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { TemplateDto } from '@api/dto/template.dto';
|
||||||
|
import { templateController } from '@api/server.module';
|
||||||
|
import { ConfigService } from '@config/env.config';
|
||||||
|
import { instanceSchema, templateSchema } from '@validate/validate.schema';
|
||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
|
||||||
import { instanceSchema, templateSchema } from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { TemplateDto } from '../dto/template.dto';
|
|
||||||
import { templateController } from '../server.module';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class TemplateRouter extends RouterBroker {
|
export class TemplateRouter extends RouterBroker {
|
||||||
@ -34,5 +34,5 @@ export class TemplateRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
import express, { Router } from 'express';
|
import express, { Router } from 'express';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
|
|
||||||
export class ViewsRouter extends RouterBroker {
|
export class ViewsRouter extends RouterBroker {
|
||||||
public readonly router: Router;
|
public readonly router: Router;
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { WebhookDto } from '@api/dto/webhook.dto';
|
||||||
|
import { webhookController } from '@api/server.module';
|
||||||
|
import { ConfigService } from '@config/env.config';
|
||||||
|
import { instanceSchema, webhookSchema } from '@validate/validate.schema';
|
||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
|
||||||
import { instanceSchema, webhookSchema } from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { WebhookDto } from '../dto/webhook.dto';
|
|
||||||
import { webhookController } from '../server.module';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class WebhookRouter extends RouterBroker {
|
export class WebhookRouter extends RouterBroker {
|
||||||
@ -34,5 +34,5 @@ export class WebhookRouter extends RouterBroker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly router = Router();
|
public readonly router: Router = Router();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { CacheEngine } from '../cache/cacheengine';
|
import { CacheEngine } from '@cache/cacheengine';
|
||||||
import { Chatwoot, configService, ProviderSession } from '../config/env.config';
|
import { Chatwoot, configService, ProviderSession } from '@config/env.config';
|
||||||
import { eventEmitter } from '../config/event.config';
|
import { eventEmitter } from '@config/event.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '@config/logger.config';
|
||||||
|
|
||||||
import { ChatController } from './controllers/chat.controller';
|
import { ChatController } from './controllers/chat.controller';
|
||||||
import { GroupController } from './controllers/group.controller';
|
import { GroupController } from './controllers/group.controller';
|
||||||
import { InstanceController } from './controllers/instance.controller';
|
import { InstanceController } from './controllers/instance.controller';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { BadRequestException } from '../../exceptions';
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
import { PrismaRepository } from '../repository/repository.service';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
constructor(private readonly prismaRepository: PrismaRepository) {}
|
constructor(private readonly prismaRepository: PrismaRepository) {}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
|
import { ICache } from '@api/abstract/abstract.cache';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { BufferJSON } from 'baileys';
|
import { BufferJSON } from 'baileys';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { ICache } from '../abstract/abstract.cache';
|
|
||||||
|
|
||||||
export class CacheService {
|
export class CacheService {
|
||||||
private readonly logger = new Logger(CacheService.name);
|
private readonly logger = new Logger('CacheService');
|
||||||
|
|
||||||
constructor(private readonly cache: ICache) {
|
constructor(private readonly cache: ICache) {
|
||||||
if (cache) {
|
if (cache) {
|
||||||
|
@ -1,3 +1,25 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { ProxyDto } from '@api/dto/proxy.dto';
|
||||||
|
import { SettingsDto } from '@api/dto/settings.dto';
|
||||||
|
import { WebhookDto } from '@api/dto/webhook.dto';
|
||||||
|
import { ChatwootDto } from '@api/integrations/chatwoot/dto/chatwoot.dto';
|
||||||
|
import { ChatwootService } from '@api/integrations/chatwoot/services/chatwoot.service';
|
||||||
|
import { DifyService } from '@api/integrations/dify/services/dify.service';
|
||||||
|
import { OpenaiService } from '@api/integrations/openai/services/openai.service';
|
||||||
|
import { RabbitmqDto } from '@api/integrations/rabbitmq/dto/rabbitmq.dto';
|
||||||
|
import { getAMQP, removeQueues } from '@api/integrations/rabbitmq/libs/amqp.server';
|
||||||
|
import { SqsDto } from '@api/integrations/sqs/dto/sqs.dto';
|
||||||
|
import { getSQS, removeQueues as removeQueuesSQS } from '@api/integrations/sqs/libs/sqs.server';
|
||||||
|
import { TypebotService } from '@api/integrations/typebot/services/typebot.service';
|
||||||
|
import { WebsocketDto } from '@api/integrations/websocket/dto/websocket.dto';
|
||||||
|
import { getIO } from '@api/integrations/websocket/libs/socket.server';
|
||||||
|
import { PrismaRepository, Query } from '@api/repository/repository.service';
|
||||||
|
import { waMonitor } from '@api/server.module';
|
||||||
|
import { Events, wa } from '@api/types/wa.types';
|
||||||
|
import { Auth, Chatwoot, ConfigService, HttpServer, Log, Rabbitmq, Sqs, Webhook, Websocket } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { ROOT_DIR } from '@config/path.config';
|
||||||
|
import { NotFoundException } from '@exceptions';
|
||||||
import { Contact, Message } from '@prisma/client';
|
import { Contact, Message } from '@prisma/client';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { WASocket } from 'baileys';
|
import { WASocket } from 'baileys';
|
||||||
@ -6,38 +28,6 @@ import EventEmitter2 from 'eventemitter2';
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import {
|
|
||||||
Auth,
|
|
||||||
Chatwoot,
|
|
||||||
ConfigService,
|
|
||||||
HttpServer,
|
|
||||||
Log,
|
|
||||||
Rabbitmq,
|
|
||||||
Sqs,
|
|
||||||
Webhook,
|
|
||||||
Websocket,
|
|
||||||
} from '../../config/env.config';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { ROOT_DIR } from '../../config/path.config';
|
|
||||||
import { NotFoundException } from '../../exceptions';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { ProxyDto } from '../dto/proxy.dto';
|
|
||||||
import { SettingsDto } from '../dto/settings.dto';
|
|
||||||
import { WebhookDto } from '../dto/webhook.dto';
|
|
||||||
import { ChatwootDto } from '../integrations/chatwoot/dto/chatwoot.dto';
|
|
||||||
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
|
||||||
import { DifyService } from '../integrations/dify/services/dify.service';
|
|
||||||
import { OpenaiService } from '../integrations/openai/services/openai.service';
|
|
||||||
import { RabbitmqDto } from '../integrations/rabbitmq/dto/rabbitmq.dto';
|
|
||||||
import { getAMQP, removeQueues } from '../integrations/rabbitmq/libs/amqp.server';
|
|
||||||
import { SqsDto } from '../integrations/sqs/dto/sqs.dto';
|
|
||||||
import { getSQS, removeQueues as removeQueuesSQS } from '../integrations/sqs/libs/sqs.server';
|
|
||||||
import { TypebotService } from '../integrations/typebot/services/typebot.service';
|
|
||||||
import { WebsocketDto } from '../integrations/websocket/dto/websocket.dto';
|
|
||||||
import { getIO } from '../integrations/websocket/libs/socket.server';
|
|
||||||
import { PrismaRepository, Query } from '../repository/repository.service';
|
|
||||||
import { waMonitor } from '../server.module';
|
|
||||||
import { Events, wa } from '../types/wa.types';
|
|
||||||
import { CacheService } from './cache.service';
|
import { CacheService } from './cache.service';
|
||||||
|
|
||||||
export class ChannelStartupService {
|
export class ChannelStartupService {
|
||||||
@ -48,7 +38,7 @@ export class ChannelStartupService {
|
|||||||
public readonly chatwootCache: CacheService,
|
public readonly chatwootCache: CacheService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public readonly logger = new Logger(ChannelStartupService.name);
|
public readonly logger = new Logger('ChannelStartupService');
|
||||||
|
|
||||||
public client: WASocket;
|
public client: WASocket;
|
||||||
public readonly instance: wa.Instance = {};
|
public readonly instance: wa.Instance = {};
|
||||||
|
@ -1,6 +1,83 @@
|
|||||||
|
import {
|
||||||
|
ArchiveChatDto,
|
||||||
|
BlockUserDto,
|
||||||
|
DeleteMessage,
|
||||||
|
getBase64FromMediaMessageDto,
|
||||||
|
LastMessage,
|
||||||
|
MarkChatUnreadDto,
|
||||||
|
NumberBusiness,
|
||||||
|
OnWhatsAppDto,
|
||||||
|
PrivacySettingDto,
|
||||||
|
ReadMessageDto,
|
||||||
|
SendPresenceDto,
|
||||||
|
UpdateMessageDto,
|
||||||
|
WhatsAppNumberDto,
|
||||||
|
} from '@api/dto/chat.dto';
|
||||||
|
import {
|
||||||
|
AcceptGroupInvite,
|
||||||
|
CreateGroupDto,
|
||||||
|
GetParticipant,
|
||||||
|
GroupDescriptionDto,
|
||||||
|
GroupInvite,
|
||||||
|
GroupJid,
|
||||||
|
GroupPictureDto,
|
||||||
|
GroupSendInvite,
|
||||||
|
GroupSubjectDto,
|
||||||
|
GroupToggleEphemeralDto,
|
||||||
|
GroupUpdateParticipantDto,
|
||||||
|
GroupUpdateSettingDto,
|
||||||
|
} from '@api/dto/group.dto';
|
||||||
|
import { InstanceDto, SetPresenceDto } from '@api/dto/instance.dto';
|
||||||
|
import { HandleLabelDto, LabelDto } from '@api/dto/label.dto';
|
||||||
|
import {
|
||||||
|
ContactMessage,
|
||||||
|
MediaMessage,
|
||||||
|
Options,
|
||||||
|
SendAudioDto,
|
||||||
|
SendContactDto,
|
||||||
|
SendListDto,
|
||||||
|
SendLocationDto,
|
||||||
|
SendMediaDto,
|
||||||
|
SendPollDto,
|
||||||
|
SendReactionDto,
|
||||||
|
SendStatusDto,
|
||||||
|
SendStickerDto,
|
||||||
|
SendTextDto,
|
||||||
|
StatusMessage,
|
||||||
|
} from '@api/dto/sendMessage.dto';
|
||||||
|
import { chatwootImport } from '@api/integrations/chatwoot/utils/chatwoot-import-helper';
|
||||||
|
import * as s3Service from '@api/integrations/s3/libs/minio.server';
|
||||||
|
import { ProviderFiles } from '@api/provider/sessions';
|
||||||
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
|
import { waMonitor } from '@api/server.module';
|
||||||
|
import { CacheService } from '@api/services/cache.service';
|
||||||
|
import { ChannelStartupService } from '@api/services/channel.service';
|
||||||
|
import { Events, MessageSubtype, TypeMediaMessage, wa } from '@api/types/wa.types';
|
||||||
|
import { CacheEngine } from '@cache/cacheengine';
|
||||||
|
import {
|
||||||
|
CacheConf,
|
||||||
|
Chatwoot,
|
||||||
|
ConfigService,
|
||||||
|
configService,
|
||||||
|
ConfigSessionPhone,
|
||||||
|
Database,
|
||||||
|
Dify,
|
||||||
|
Log,
|
||||||
|
Openai,
|
||||||
|
ProviderSession,
|
||||||
|
QrCode,
|
||||||
|
S3,
|
||||||
|
Typebot,
|
||||||
|
} from '@config/env.config';
|
||||||
|
import { INSTANCE_DIR } from '@config/path.config';
|
||||||
|
import { BadRequestException, InternalServerErrorException, NotFoundException } from '@exceptions';
|
||||||
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
||||||
import { Boom } from '@hapi/boom';
|
import { Boom } from '@hapi/boom';
|
||||||
import { Instance } from '@prisma/client';
|
import { Instance } from '@prisma/client';
|
||||||
|
import { makeProxyAgent } from '@utils/makeProxyAgent';
|
||||||
|
import useMultiFileAuthStatePrisma from '@utils/use-multi-file-auth-state-prisma';
|
||||||
|
import { AuthStateProvider } from '@utils/use-multi-file-auth-state-provider-files';
|
||||||
|
import { useMultiFileAuthStateRedisDb } from '@utils/use-multi-file-auth-state-redis-db';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import makeWASocket, {
|
import makeWASocket, {
|
||||||
AnyMessageContent,
|
AnyMessageContent,
|
||||||
@ -49,7 +126,6 @@ import { existsSync, readFileSync } from 'fs';
|
|||||||
import Long from 'long';
|
import Long from 'long';
|
||||||
import mime from 'mime';
|
import mime from 'mime';
|
||||||
import NodeCache from 'node-cache';
|
import NodeCache from 'node-cache';
|
||||||
import { getMIMEType } from 'node-mime-types';
|
|
||||||
import { release } from 'os';
|
import { release } from 'os';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import P from 'pino';
|
import P from 'pino';
|
||||||
@ -59,84 +135,6 @@ import sharp from 'sharp';
|
|||||||
import { PassThrough } from 'stream';
|
import { PassThrough } from 'stream';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { CacheEngine } from '../../../cache/cacheengine';
|
|
||||||
import {
|
|
||||||
CacheConf,
|
|
||||||
Chatwoot,
|
|
||||||
ConfigService,
|
|
||||||
configService,
|
|
||||||
ConfigSessionPhone,
|
|
||||||
Database,
|
|
||||||
Dify,
|
|
||||||
Log,
|
|
||||||
Openai,
|
|
||||||
ProviderSession,
|
|
||||||
QrCode,
|
|
||||||
S3,
|
|
||||||
Typebot,
|
|
||||||
} from '../../../config/env.config';
|
|
||||||
import { INSTANCE_DIR } from '../../../config/path.config';
|
|
||||||
import { BadRequestException, InternalServerErrorException, NotFoundException } from '../../../exceptions';
|
|
||||||
import { makeProxyAgent } from '../../../utils/makeProxyAgent';
|
|
||||||
import useMultiFileAuthStatePrisma from '../../../utils/use-multi-file-auth-state-prisma';
|
|
||||||
import { AuthStateProvider } from '../../../utils/use-multi-file-auth-state-provider-files';
|
|
||||||
import { useMultiFileAuthStateRedisDb } from '../../../utils/use-multi-file-auth-state-redis-db';
|
|
||||||
import {
|
|
||||||
ArchiveChatDto,
|
|
||||||
BlockUserDto,
|
|
||||||
DeleteMessage,
|
|
||||||
getBase64FromMediaMessageDto,
|
|
||||||
LastMessage,
|
|
||||||
MarkChatUnreadDto,
|
|
||||||
NumberBusiness,
|
|
||||||
OnWhatsAppDto,
|
|
||||||
PrivacySettingDto,
|
|
||||||
ReadMessageDto,
|
|
||||||
SendPresenceDto,
|
|
||||||
UpdateMessageDto,
|
|
||||||
WhatsAppNumberDto,
|
|
||||||
} from '../../dto/chat.dto';
|
|
||||||
import {
|
|
||||||
AcceptGroupInvite,
|
|
||||||
CreateGroupDto,
|
|
||||||
GetParticipant,
|
|
||||||
GroupDescriptionDto,
|
|
||||||
GroupInvite,
|
|
||||||
GroupJid,
|
|
||||||
GroupPictureDto,
|
|
||||||
GroupSendInvite,
|
|
||||||
GroupSubjectDto,
|
|
||||||
GroupToggleEphemeralDto,
|
|
||||||
GroupUpdateParticipantDto,
|
|
||||||
GroupUpdateSettingDto,
|
|
||||||
} from '../../dto/group.dto';
|
|
||||||
import { InstanceDto, SetPresenceDto } from '../../dto/instance.dto';
|
|
||||||
import { HandleLabelDto, LabelDto } from '../../dto/label.dto';
|
|
||||||
import {
|
|
||||||
ContactMessage,
|
|
||||||
MediaMessage,
|
|
||||||
Options,
|
|
||||||
SendAudioDto,
|
|
||||||
SendContactDto,
|
|
||||||
SendListDto,
|
|
||||||
SendLocationDto,
|
|
||||||
SendMediaDto,
|
|
||||||
SendPollDto,
|
|
||||||
SendReactionDto,
|
|
||||||
SendStatusDto,
|
|
||||||
SendStickerDto,
|
|
||||||
SendTextDto,
|
|
||||||
StatusMessage,
|
|
||||||
} from '../../dto/sendMessage.dto';
|
|
||||||
import { chatwootImport } from '../../integrations/chatwoot/utils/chatwoot-import-helper';
|
|
||||||
import * as s3Service from '../../integrations/s3/libs/minio.server';
|
|
||||||
import { ProviderFiles } from '../../provider/sessions';
|
|
||||||
import { PrismaRepository } from '../../repository/repository.service';
|
|
||||||
import { waMonitor } from '../../server.module';
|
|
||||||
import { Events, MessageSubtype, TypeMediaMessage, wa } from '../../types/wa.types';
|
|
||||||
import { CacheService } from './../cache.service';
|
|
||||||
import { ChannelStartupService } from './../channel.service';
|
|
||||||
|
|
||||||
const groupMetadataCache = new CacheService(new CacheEngine(configService, 'groups').getEngine());
|
const groupMetadataCache = new CacheService(new CacheEngine(configService, 'groups').getEngine());
|
||||||
|
|
||||||
export class BaileysStartupService extends ChannelStartupService {
|
export class BaileysStartupService extends ChannelStartupService {
|
||||||
@ -1015,7 +1013,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
await this.contactHandle['contacts.upsert'](
|
await this.contactHandle['contacts.upsert'](
|
||||||
contacts
|
contacts
|
||||||
.filter((c) => !!c.notify ?? !!c.name)
|
.filter((c) => !!c.notify || !!c.name)
|
||||||
.map((c) => ({
|
.map((c) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name ?? c.notify,
|
name: c.name ?? c.notify,
|
||||||
@ -1156,7 +1154,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
const { buffer, mediaType, fileName, size } = media;
|
const { buffer, mediaType, fileName, size } = media;
|
||||||
|
|
||||||
const mimetype = mime.lookup(fileName).toString();
|
const mimetype = mime.getType(fileName).toString();
|
||||||
|
|
||||||
const fullName = join(`${this.instance.id}`, received.key.remoteJid, mediaType, fileName);
|
const fullName = join(`${this.instance.id}`, received.key.remoteJid, mediaType, fileName);
|
||||||
|
|
||||||
@ -2319,7 +2317,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
if (mediaMessage.mimetype) {
|
if (mediaMessage.mimetype) {
|
||||||
mimetype = mediaMessage.mimetype;
|
mimetype = mediaMessage.mimetype;
|
||||||
} else {
|
} else {
|
||||||
mimetype = getMIMEType(mediaMessage.fileName);
|
mimetype = mime.getType(mediaMessage.fileName);
|
||||||
|
|
||||||
if (!mimetype && isURL(mediaMessage.media)) {
|
if (!mimetype && isURL(mediaMessage.media)) {
|
||||||
let config: any = {
|
let config: any = {
|
||||||
@ -2983,7 +2981,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
);
|
);
|
||||||
const typeMessage = getContentType(msg.message);
|
const typeMessage = getContentType(msg.message);
|
||||||
|
|
||||||
const ext = mime.extension(mediaMessage?.['mimetype']);
|
const ext = mime.getExtension(mediaMessage?.['mimetype']);
|
||||||
|
|
||||||
const fileName = mediaMessage?.['fileName'] || `${msg.key.id}.${ext}` || `${v4()}.${ext}`;
|
const fileName = mediaMessage?.['fileName'] || `${msg.key.id}.${ext}` || `${v4()}.${ext}`;
|
||||||
|
|
||||||
|
@ -1,14 +1,4 @@
|
|||||||
import axios from 'axios';
|
import { NumberBusiness } from '@api/dto/chat.dto';
|
||||||
import { arrayUnique, isURL } from 'class-validator';
|
|
||||||
import EventEmitter2 from 'eventemitter2';
|
|
||||||
import FormData from 'form-data';
|
|
||||||
import { createReadStream } from 'fs';
|
|
||||||
import { getMIMEType } from 'node-mime-types';
|
|
||||||
import { join } from 'path';
|
|
||||||
|
|
||||||
import { Chatwoot, ConfigService, Database, Dify, Openai, S3, Typebot, WaBusiness } from '../../../config/env.config';
|
|
||||||
import { BadRequestException, InternalServerErrorException } from '../../../exceptions';
|
|
||||||
import { NumberBusiness } from '../../dto/chat.dto';
|
|
||||||
import {
|
import {
|
||||||
ContactMessage,
|
ContactMessage,
|
||||||
MediaMessage,
|
MediaMessage,
|
||||||
@ -22,13 +12,22 @@ import {
|
|||||||
SendReactionDto,
|
SendReactionDto,
|
||||||
SendTemplateDto,
|
SendTemplateDto,
|
||||||
SendTextDto,
|
SendTextDto,
|
||||||
} from '../../dto/sendMessage.dto';
|
} from '@api/dto/sendMessage.dto';
|
||||||
import * as s3Service from '../../integrations/s3/libs/minio.server';
|
import * as s3Service from '@api/integrations/s3/libs/minio.server';
|
||||||
import { ProviderFiles } from '../../provider/sessions';
|
import { ProviderFiles } from '@api/provider/sessions';
|
||||||
import { PrismaRepository } from '../../repository/repository.service';
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
import { Events, wa } from '../../types/wa.types';
|
import { CacheService } from '@api/services/cache.service';
|
||||||
import { CacheService } from './../cache.service';
|
import { ChannelStartupService } from '@api/services/channel.service';
|
||||||
import { ChannelStartupService } from './../channel.service';
|
import { Events, wa } from '@api/types/wa.types';
|
||||||
|
import { Chatwoot, ConfigService, Database, Dify, Openai, S3, Typebot, WaBusiness } from '@config/env.config';
|
||||||
|
import { BadRequestException, InternalServerErrorException } from '@exceptions';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { arrayUnique, isURL } from 'class-validator';
|
||||||
|
import EventEmitter2 from 'eventemitter2';
|
||||||
|
import FormData from 'form-data';
|
||||||
|
import { createReadStream } from 'fs';
|
||||||
|
import mime from 'mime';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
export class BusinessStartupService extends ChannelStartupService {
|
export class BusinessStartupService extends ChannelStartupService {
|
||||||
constructor(
|
constructor(
|
||||||
@ -1059,11 +1058,11 @@ export class BusinessStartupService extends ChannelStartupService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (isURL(mediaMessage.media)) {
|
if (isURL(mediaMessage.media)) {
|
||||||
mimetype = getMIMEType(mediaMessage.media);
|
mimetype = mime.getType(mediaMessage.media);
|
||||||
prepareMedia.id = mediaMessage.media;
|
prepareMedia.id = mediaMessage.media;
|
||||||
prepareMedia.type = 'link';
|
prepareMedia.type = 'link';
|
||||||
} else {
|
} else {
|
||||||
mimetype = getMIMEType(mediaMessage.fileName);
|
mimetype = mime.getType(mediaMessage.fileName);
|
||||||
const id = await this.getIdMedia(prepareMedia);
|
const id = await this.getIdMedia(prepareMedia);
|
||||||
prepareMedia.id = id;
|
prepareMedia.id = id;
|
||||||
prepareMedia.type = 'id';
|
prepareMedia.type = 'id';
|
||||||
@ -1109,11 +1108,11 @@ export class BusinessStartupService extends ChannelStartupService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (isURL(audio)) {
|
if (isURL(audio)) {
|
||||||
mimetype = getMIMEType(audio);
|
mimetype = mime.getType(audio);
|
||||||
prepareMedia.id = audio;
|
prepareMedia.id = audio;
|
||||||
prepareMedia.type = 'link';
|
prepareMedia.type = 'link';
|
||||||
} else {
|
} else {
|
||||||
mimetype = getMIMEType(prepareMedia.fileName);
|
mimetype = mime.getType(prepareMedia.fileName);
|
||||||
const id = await this.getIdMedia(prepareMedia);
|
const id = await this.getIdMedia(prepareMedia);
|
||||||
prepareMedia.id = id;
|
prepareMedia.id = id;
|
||||||
prepareMedia.type = 'id';
|
prepareMedia.type = 'id';
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { ProviderFiles } from '@api/provider/sessions';
|
||||||
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
|
import { Integration } from '@api/types/wa.types';
|
||||||
|
import { CacheConf, Chatwoot, ConfigService, Database, DelInstance, ProviderSession } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { INSTANCE_DIR, STORE_DIR } from '@config/path.config';
|
||||||
|
import { NotFoundException } from '@exceptions';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
import { rmSync } from 'fs';
|
import { rmSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { CacheConf, Chatwoot, ConfigService, Database, DelInstance, ProviderSession } from '../../config/env.config';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { INSTANCE_DIR, STORE_DIR } from '../../config/path.config';
|
|
||||||
import { NotFoundException } from '../../exceptions';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { ProviderFiles } from '../provider/sessions';
|
|
||||||
import { PrismaRepository } from '../repository/repository.service';
|
|
||||||
import { Integration } from '../types/wa.types';
|
|
||||||
import { CacheService } from './cache.service';
|
import { CacheService } from './cache.service';
|
||||||
import { BaileysStartupService } from './channels/whatsapp.baileys.service';
|
import { BaileysStartupService } from './channels/whatsapp.baileys.service';
|
||||||
import { BusinessStartupService } from './channels/whatsapp.business.service';
|
import { BusinessStartupService } from './channels/whatsapp.business.service';
|
||||||
@ -35,7 +35,7 @@ export class WAMonitoringService {
|
|||||||
private readonly db: Partial<Database> = {};
|
private readonly db: Partial<Database> = {};
|
||||||
private readonly redis: Partial<CacheConf> = {};
|
private readonly redis: Partial<CacheConf> = {};
|
||||||
|
|
||||||
private readonly logger = new Logger(WAMonitoringService.name);
|
private readonly logger = new Logger('WAMonitoringService');
|
||||||
public readonly waInstances: Record<string, BaileysStartupService | BusinessStartupService> = {};
|
public readonly waInstances: Record<string, BaileysStartupService | BusinessStartupService> = {};
|
||||||
|
|
||||||
private readonly providerSession = Object.freeze(this.configService.get<ProviderSession>('PROVIDER'));
|
private readonly providerSession = Object.freeze(this.configService.get<ProviderSession>('PROVIDER'));
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { ProxyDto } from '@api/dto/proxy.dto';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { Proxy } from '@prisma/client';
|
import { Proxy } from '@prisma/client';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { ProxyDto } from '../dto/proxy.dto';
|
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { WAMonitoringService } from './monitor.service';
|
||||||
|
|
||||||
export class ProxyService {
|
export class ProxyService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(ProxyService.name);
|
private readonly logger = new Logger('ProxyService');
|
||||||
|
|
||||||
public create(instance: InstanceDto, data: ProxyDto) {
|
public create(instance: InstanceDto, data: ProxyDto) {
|
||||||
this.waMonitor.waInstances[instance.instanceName].setProxy(data);
|
this.waMonitor.waInstances[instance.instanceName].setProxy(data);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { Logger } from '../../config/logger.config';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { SettingsDto } from '@api/dto/settings.dto';
|
||||||
import { SettingsDto } from '../dto/settings.dto';
|
import { Logger } from '@config/logger.config';
|
||||||
|
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { WAMonitoringService } from './monitor.service';
|
||||||
|
|
||||||
export class SettingsService {
|
export class SettingsService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(SettingsService.name);
|
private readonly logger = new Logger('SettingsService');
|
||||||
|
|
||||||
public async create(instance: InstanceDto, data: SettingsDto) {
|
public async create(instance: InstanceDto, data: SettingsDto) {
|
||||||
await this.waMonitor.waInstances[instance.instanceName].setSettings(data);
|
await this.waMonitor.waInstances[instance.instanceName].setSettings(data);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { TemplateDto } from '@api/dto/template.dto';
|
||||||
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
|
import { ConfigService, WaBusiness } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { ConfigService, WaBusiness } from '../../config/env.config';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { TemplateDto } from '../dto/template.dto';
|
|
||||||
import { PrismaRepository } from '../repository/repository.service';
|
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { WAMonitoringService } from './monitor.service';
|
||||||
|
|
||||||
export class TemplateService {
|
export class TemplateService {
|
||||||
@ -14,7 +14,7 @@ export class TemplateService {
|
|||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(TemplateService.name);
|
private readonly logger = new Logger('TemplateService');
|
||||||
|
|
||||||
private businessId: string;
|
private businessId: string;
|
||||||
private token: string;
|
private token: string;
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
|
import { WebhookDto } from '@api/dto/webhook.dto';
|
||||||
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { Webhook } from '@prisma/client';
|
import { Webhook } from '@prisma/client';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { WebhookDto } from '../dto/webhook.dto';
|
|
||||||
import { PrismaRepository } from '../repository/repository.service';
|
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { WAMonitoringService } from './monitor.service';
|
||||||
|
|
||||||
export class WebhookService {
|
export class WebhookService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService, public readonly prismaRepository: PrismaRepository) {}
|
constructor(private readonly waMonitor: WAMonitoringService, public readonly prismaRepository: PrismaRepository) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(WebhookService.name);
|
private readonly logger = new Logger('WebhookService');
|
||||||
|
|
||||||
public create(instance: InstanceDto, data: WebhookDto) {
|
public create(instance: InstanceDto, data: WebhookDto) {
|
||||||
this.waMonitor.waInstances[instance.instanceName].setWebhook(data);
|
this.waMonitor.waInstances[instance.instanceName].setWebhook(data);
|
||||||
|
7
src/cache/cacheengine.ts
vendored
7
src/cache/cacheengine.ts
vendored
@ -1,6 +1,7 @@
|
|||||||
import { ICache } from '../api/abstract/abstract.cache';
|
import { ICache } from '@api/abstract/abstract.cache';
|
||||||
import { CacheConf, ConfigService } from '../config/env.config';
|
import { CacheConf, ConfigService } from '@config/env.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '@config/logger.config';
|
||||||
|
|
||||||
import { LocalCache } from './localcache';
|
import { LocalCache } from './localcache';
|
||||||
import { RedisCache } from './rediscache';
|
import { RedisCache } from './rediscache';
|
||||||
|
|
||||||
|
5
src/cache/localcache.ts
vendored
5
src/cache/localcache.ts
vendored
@ -1,8 +1,7 @@
|
|||||||
|
import { ICache } from '@api/abstract/abstract.cache';
|
||||||
|
import { CacheConf, CacheConfLocal, ConfigService } from '@config/env.config';
|
||||||
import NodeCache from 'node-cache';
|
import NodeCache from 'node-cache';
|
||||||
|
|
||||||
import { ICache } from '../api/abstract/abstract.cache';
|
|
||||||
import { CacheConf, CacheConfLocal, ConfigService } from '../config/env.config';
|
|
||||||
|
|
||||||
export class LocalCache implements ICache {
|
export class LocalCache implements ICache {
|
||||||
private conf: CacheConfLocal;
|
private conf: CacheConfLocal;
|
||||||
static localCache = new NodeCache();
|
static localCache = new NodeCache();
|
||||||
|
7
src/cache/rediscache.client.ts
vendored
7
src/cache/rediscache.client.ts
vendored
@ -1,10 +1,9 @@
|
|||||||
|
import { CacheConf, CacheConfRedis, configService } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { createClient, RedisClientType } from 'redis';
|
import { createClient, RedisClientType } from 'redis';
|
||||||
|
|
||||||
import { CacheConf, CacheConfRedis, configService } from '../config/env.config';
|
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
|
|
||||||
class Redis {
|
class Redis {
|
||||||
private logger = new Logger(Redis.name);
|
private logger = new Logger('Redis');
|
||||||
private client: RedisClientType = null;
|
private client: RedisClientType = null;
|
||||||
private conf: CacheConfRedis;
|
private conf: CacheConfRedis;
|
||||||
private connected = false;
|
private connected = false;
|
||||||
|
8
src/cache/rediscache.ts
vendored
8
src/cache/rediscache.ts
vendored
@ -1,13 +1,13 @@
|
|||||||
|
import { ICache } from '@api/abstract/abstract.cache';
|
||||||
|
import { CacheConf, CacheConfRedis, ConfigService } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { BufferJSON } from 'baileys';
|
import { BufferJSON } from 'baileys';
|
||||||
import { RedisClientType } from 'redis';
|
import { RedisClientType } from 'redis';
|
||||||
|
|
||||||
import { ICache } from '../api/abstract/abstract.cache';
|
|
||||||
import { CacheConf, CacheConfRedis, ConfigService } from '../config/env.config';
|
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
import { redisClient } from './rediscache.client';
|
import { redisClient } from './rediscache.client';
|
||||||
|
|
||||||
export class RedisCache implements ICache {
|
export class RedisCache implements ICache {
|
||||||
private readonly logger = new Logger(RedisCache.name);
|
private readonly logger = new Logger('RedisCache');
|
||||||
private client: RedisClientType;
|
private client: RedisClientType;
|
||||||
private conf: CacheConfRedis;
|
private conf: CacheConfRedis;
|
||||||
|
|
||||||
|
@ -58,7 +58,11 @@ enum Background {
|
|||||||
|
|
||||||
export class Logger {
|
export class Logger {
|
||||||
private readonly configService = configService;
|
private readonly configService = configService;
|
||||||
constructor(private context = 'Logger') {}
|
private context: string;
|
||||||
|
|
||||||
|
constructor(context = 'Logger') {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
private instance = null;
|
private instance = null;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HttpStatus } from '../api/routes/index.router';
|
import { HttpStatus } from '@api/routes/index.router';
|
||||||
|
|
||||||
export class BadRequestException {
|
export class BadRequestException {
|
||||||
constructor(...objectError: any[]) {
|
constructor(...objectError: any[]) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HttpStatus } from '../api/routes/index.router';
|
import { HttpStatus } from '@api/routes/index.router';
|
||||||
|
|
||||||
export class UnauthorizedException {
|
export class UnauthorizedException {
|
||||||
constructor(...objectError: any[]) {
|
constructor(...objectError: any[]) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HttpStatus } from '../api/routes/index.router';
|
import { HttpStatus } from '@api/routes/index.router';
|
||||||
|
|
||||||
export class ForbiddenException {
|
export class ForbiddenException {
|
||||||
constructor(...objectError: any[]) {
|
constructor(...objectError: any[]) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HttpStatus } from '../api/routes/index.router';
|
import { HttpStatus } from '@api/routes/index.router';
|
||||||
|
|
||||||
export class NotFoundException {
|
export class NotFoundException {
|
||||||
constructor(...objectError: any[]) {
|
constructor(...objectError: any[]) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HttpStatus } from '../api/routes/index.router';
|
import { HttpStatus } from '@api/routes/index.router';
|
||||||
|
|
||||||
export class InternalServerErrorException {
|
export class InternalServerErrorException {
|
||||||
constructor(...objectError: any[]) {
|
constructor(...objectError: any[]) {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
import { configService, Database } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
import { configService, Database } from '../config/env.config';
|
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('Prisma');
|
const logger = new Logger('Prisma');
|
||||||
|
|
||||||
const db = configService.get<Database>('DATABASE');
|
const db = configService.get<Database>('DATABASE');
|
||||||
|
25
src/main.ts
25
src/main.ts
@ -1,24 +1,23 @@
|
|||||||
import 'express-async-errors';
|
import 'express-async-errors';
|
||||||
|
|
||||||
|
import { initAMQP, initGlobalQueues } from '@api/integrations/rabbitmq/libs/amqp.server';
|
||||||
|
import { initSQS } from '@api/integrations/sqs/libs/sqs.server';
|
||||||
|
import { initIO } from '@api/integrations/websocket/libs/socket.server';
|
||||||
|
import { ProviderFiles } from '@api/provider/sessions';
|
||||||
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
|
import { HttpStatus, router } from '@api/routes/index.router';
|
||||||
|
import { waMonitor } from '@api/server.module';
|
||||||
|
import { Auth, configService, Cors, HttpServer, ProviderSession, Rabbitmq, Sqs, Webhook } from '@config/env.config';
|
||||||
|
import { onUnexpectedError } from '@config/error.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { ROOT_DIR } from '@config/path.config';
|
||||||
|
import { ServerUP } from '@utils/server-up';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import compression from 'compression';
|
import compression from 'compression';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import express, { json, NextFunction, Request, Response, urlencoded } from 'express';
|
import express, { json, NextFunction, Request, Response, urlencoded } from 'express';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { initAMQP, initGlobalQueues } from './api/integrations/rabbitmq/libs/amqp.server';
|
|
||||||
import { initSQS } from './api/integrations/sqs/libs/sqs.server';
|
|
||||||
import { initIO } from './api/integrations/websocket/libs/socket.server';
|
|
||||||
import { ProviderFiles } from './api/provider/sessions';
|
|
||||||
import { PrismaRepository } from './api/repository/repository.service';
|
|
||||||
import { HttpStatus, router } from './api/routes/index.router';
|
|
||||||
import { waMonitor } from './api/server.module';
|
|
||||||
import { Auth, configService, Cors, HttpServer, ProviderSession, Rabbitmq, Sqs, Webhook } from './config/env.config';
|
|
||||||
import { onUnexpectedError } from './config/error.config';
|
|
||||||
import { Logger } from './config/logger.config';
|
|
||||||
import { ROOT_DIR } from './config/path.config';
|
|
||||||
import { ServerUP } from './utils/server-up';
|
|
||||||
|
|
||||||
function initWA() {
|
function initWA() {
|
||||||
waMonitor.loadInstance();
|
waMonitor.loadInstance();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
import { ConfigService, Language } from '@config/env.config';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { ConfigService, Language } from '../config/env.config';
|
|
||||||
|
|
||||||
const languages = ['en', 'pt-BR', 'es'];
|
const languages = ['en', 'pt-BR', 'es'];
|
||||||
const translationsPath = path.join(__dirname, 'translations');
|
const translationsPath = path.join(__dirname, 'translations');
|
||||||
const configService: ConfigService = new ConfigService();
|
const configService: ConfigService = new ConfigService();
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
|
import { configService, SslConf } from '@config/env.config';
|
||||||
import { Express } from 'express';
|
import { Express } from 'express';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
|
|
||||||
import { configService, SslConf } from '../config/env.config';
|
|
||||||
|
|
||||||
export class ServerUP {
|
export class ServerUP {
|
||||||
static #app: Express;
|
static #app: Express;
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
|
import { CacheService } from '@api/services/cache.service';
|
||||||
|
import { INSTANCE_DIR } from '@config/path.config';
|
||||||
|
import { prismaServer } from '@libs/prisma.connect';
|
||||||
import { AuthenticationState, BufferJSON, initAuthCreds, WAProto as proto } from 'baileys';
|
import { AuthenticationState, BufferJSON, initAuthCreds, WAProto as proto } from 'baileys';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { CacheService } from '../api/services/cache.service';
|
|
||||||
import { INSTANCE_DIR } from '../config/path.config';
|
|
||||||
import { prismaServer } from '../libs/prisma.connect';
|
|
||||||
|
|
||||||
const prisma = prismaServer;
|
const prisma = prismaServer;
|
||||||
|
|
||||||
// const fixFileName = (file: string): string | undefined => {
|
// const fixFileName = (file: string): string | undefined => {
|
||||||
|
@ -34,18 +34,17 @@
|
|||||||
* └──────────────────────────────────────────────────────────────────────────────┘
|
* └──────────────────────────────────────────────────────────────────────────────┘
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { ProviderFiles } from '@api/provider/sessions';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { AuthenticationCreds, AuthenticationState, BufferJSON, initAuthCreds, proto, SignalDataTypeMap } from 'baileys';
|
import { AuthenticationCreds, AuthenticationState, BufferJSON, initAuthCreds, proto, SignalDataTypeMap } from 'baileys';
|
||||||
import { isNotEmpty } from 'class-validator';
|
import { isNotEmpty } from 'class-validator';
|
||||||
|
|
||||||
import { ProviderFiles } from '../api/provider/sessions';
|
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
|
|
||||||
export type AuthState = { state: AuthenticationState; saveCreds: () => Promise<void> };
|
export type AuthState = { state: AuthenticationState; saveCreds: () => Promise<void> };
|
||||||
|
|
||||||
export class AuthStateProvider {
|
export class AuthStateProvider {
|
||||||
constructor(private readonly providerFiles: ProviderFiles) {}
|
constructor(private readonly providerFiles: ProviderFiles) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(AuthStateProvider.name);
|
private readonly logger = new Logger('AuthStateProvider');
|
||||||
|
|
||||||
public async authStateProvider(instance: string): Promise<AuthState> {
|
public async authStateProvider(instance: string): Promise<AuthState> {
|
||||||
const [, error] = await this.providerFiles.create(instance);
|
const [, error] = await this.providerFiles.create(instance);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
import { CacheService } from '@api/services/cache.service';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { AuthenticationCreds, AuthenticationState, initAuthCreds, proto, SignalDataTypeMap } from 'baileys';
|
import { AuthenticationCreds, AuthenticationState, initAuthCreds, proto, SignalDataTypeMap } from 'baileys';
|
||||||
|
|
||||||
import { CacheService } from '../api/services/cache.service';
|
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
|
|
||||||
export async function useMultiFileAuthStateRedisDb(
|
export async function useMultiFileAuthStateRedisDb(
|
||||||
instanceName: string,
|
instanceName: string,
|
||||||
cache: CacheService,
|
cache: CacheService,
|
||||||
@ -10,7 +9,7 @@ export async function useMultiFileAuthStateRedisDb(
|
|||||||
state: AuthenticationState;
|
state: AuthenticationState;
|
||||||
saveCreds: () => Promise<void>;
|
saveCreds: () => Promise<void>;
|
||||||
}> {
|
}> {
|
||||||
const logger = new Logger(useMultiFileAuthStateRedisDb.name);
|
const logger = new Logger('useMultiFileAuthStateRedisDb');
|
||||||
|
|
||||||
const writeData = async (data: any, key: string): Promise<any> => {
|
const writeData = async (data: any, key: string): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
import { Integration } from '@api/types/wa.types';
|
||||||
import { JSONSchema7 } from 'json-schema';
|
import { JSONSchema7 } from 'json-schema';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { Integration } from '../api/types/wa.types';
|
|
||||||
|
|
||||||
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
||||||
const properties = {};
|
const properties = {};
|
||||||
propertyNames.forEach(
|
propertyNames.forEach(
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
// Integrations Schema
|
// Integrations Schema
|
||||||
export * from '../api/integrations/chatwoot/validate/chatwoot.schema';
|
|
||||||
export * from '../api/integrations/dify/validate/dify.schema';
|
|
||||||
export * from '../api/integrations/openai/validate/openai.schema';
|
|
||||||
export * from '../api/integrations/rabbitmq/validate/rabbitmq.schema';
|
|
||||||
export * from '../api/integrations/sqs/validate/sqs.schema';
|
|
||||||
export * from '../api/integrations/typebot/validate/typebot.schema';
|
|
||||||
export * from './chat.schema';
|
export * from './chat.schema';
|
||||||
export * from './group.schema';
|
export * from './group.schema';
|
||||||
export * from './instance.schema';
|
export * from './instance.schema';
|
||||||
@ -15,3 +9,9 @@ export * from './settings.schema';
|
|||||||
export * from './template.schema';
|
export * from './template.schema';
|
||||||
export * from './webhook.schema';
|
export * from './webhook.schema';
|
||||||
export * from './websocket.schema';
|
export * from './websocket.schema';
|
||||||
|
export * from '@api/integrations/chatwoot/validate/chatwoot.schema';
|
||||||
|
export * from '@api/integrations/dify/validate/dify.schema';
|
||||||
|
export * from '@api/integrations/openai/validate/openai.schema';
|
||||||
|
export * from '@api/integrations/rabbitmq/validate/rabbitmq.schema';
|
||||||
|
export * from '@api/integrations/sqs/validate/sqs.schema';
|
||||||
|
export * from '@api/integrations/typebot/validate/typebot.schema';
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"target": "ES6",
|
"target": "es2020",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"rootDir": "./",
|
"rootDir": "./",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
@ -16,7 +16,17 @@
|
|||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strictNullChecks": false,
|
"strictNullChecks": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"noImplicitAny": false
|
"noImplicitAny": false,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@api/*": ["./src/api/*"],
|
||||||
|
"@cache/*": ["./src/cache/*"],
|
||||||
|
"@config/*": ["./src/config/*"],
|
||||||
|
"@exceptions": ["./src/exceptions"],
|
||||||
|
"@libs/*": ["./src/libs/*"],
|
||||||
|
"@utils/*": ["./src/utils/*"],
|
||||||
|
"@validate/*": ["./src/validate/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "./test", "./dist", "./prisma"],
|
"exclude": ["node_modules", "./test", "./dist", "./prisma"],
|
||||||
"include": [
|
"include": [
|
||||||
|
11
tsup.config.ts
Normal file
11
tsup.config.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { defineConfig } from 'tsup';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ['src'],
|
||||||
|
outDir: 'dist',
|
||||||
|
splitting: false,
|
||||||
|
sourcemap: true,
|
||||||
|
clean: true,
|
||||||
|
minify: true,
|
||||||
|
format: ['cjs', 'esm'],
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user