Spaces:
Runtime error
Runtime error
| import { ApiProperty } from '@nestjs/swagger'; | |
| import { BooleanString } from '@waha/nestjs/validation/BooleanString'; | |
| import { IsDynamicObject } from '@waha/nestjs/validation/IsDynamicObject'; | |
| import { Transform, Type } from 'class-transformer'; | |
| import { | |
| IsArray, | |
| IsBoolean, | |
| IsOptional, | |
| IsString, | |
| Matches, | |
| MaxLength, | |
| ValidateNested, | |
| } from 'class-validator'; | |
| import { WAHASessionStatus } from './enums.dto'; | |
| import { ChatIdProperty } from './properties.dto'; | |
| import { WebhookConfig } from './webhooks.config.dto'; | |
| /** | |
| * Queries | |
| */ | |
| export class ListSessionsQuery { | |
| ({ | |
| example: false, | |
| required: false, | |
| description: | |
| 'Return all sessions, including those that are in the STOPPED state.', | |
| }) | |
| (BooleanString) | |
| () | |
| () | |
| all?: boolean; | |
| } | |
| /** | |
| * Requests | |
| */ | |
| export class ProxyConfig { | |
| ({ | |
| example: 'localhost:3128', | |
| }) | |
| () | |
| server: string; | |
| ({ | |
| example: null, | |
| }) | |
| () | |
| () | |
| username?: string; | |
| ({ | |
| example: null, | |
| }) | |
| () | |
| () | |
| password?: string; | |
| } | |
| export class NowebStoreConfig { | |
| ({ | |
| description: | |
| 'Enable or disable the store for contacts, chats, and messages.', | |
| example: true, | |
| }) | |
| () | |
| enabled: boolean = false; | |
| ({ | |
| description: | |
| 'Enable full sync on session initialization (when scanning QR code).\n' + | |
| 'Full sync will download all contacts, chats, and messages from the phone.\n' + | |
| 'If disabled, only messages early than 90 days will be downloaded and some contacts may be missing.', | |
| }) | |
| () | |
| fullSync: boolean = false; | |
| } | |
| export class NowebConfig { | |
| () | |
| (() => NowebStoreConfig) | |
| () | |
| store?: NowebStoreConfig; | |
| ({ | |
| description: 'Mark the session as online when it connects to the server.', | |
| }) | |
| () | |
| markOnline: boolean = true; | |
| } | |
| export class WebjsConfig { | |
| ({ | |
| description: | |
| "Enable emission of special 'tag:*' engine events required for presence.update and message.ack.\n" + | |
| 'WARNING: Enabling this may have performance and stability impact. Disabled by default.', | |
| required: false, | |
| default: false, | |
| }) | |
| () | |
| () | |
| tagsEventsOn?: boolean = false; | |
| } | |
| export class IgnoreConfig { | |
| ({ | |
| description: 'Ignore a status@broadcast (stories) events', | |
| }) | |
| () | |
| () | |
| status?: boolean; | |
| ({ | |
| description: 'Ignore groups events', | |
| }) | |
| () | |
| () | |
| groups?: boolean; | |
| ({ | |
| description: 'Ignore channels events', | |
| }) | |
| () | |
| () | |
| channels?: boolean; | |
| } | |
| export class SessionConfig { | |
| ({ each: true }) | |
| (() => WebhookConfig) | |
| () | |
| () | |
| webhooks?: WebhookConfig[]; | |
| ({ | |
| example: { | |
| 'user.id': '123', | |
| 'user.email': 'email@example.com', | |
| }, | |
| description: | |
| "Metadata for the session. You'll get 'metadata' in all webhooks.", | |
| required: false, | |
| }) | |
| () | |
| () | |
| metadata?: Map<string, string>; | |
| ({ | |
| example: null, | |
| }) | |
| () | |
| (() => ProxyConfig) | |
| () | |
| proxy?: ProxyConfig; | |
| ({ | |
| required: false, | |
| default: false, | |
| }) | |
| () | |
| () | |
| debug?: boolean; | |
| ({ | |
| example: { | |
| status: null, | |
| groups: null, | |
| channels: null, | |
| }, | |
| description: 'Ignore some events related to specific chats', | |
| }) | |
| () | |
| (() => IgnoreConfig) | |
| () | |
| ignore?: IgnoreConfig; | |
| ({ | |
| example: { | |
| store: { | |
| enabled: true, | |
| fullSync: false, | |
| }, | |
| }, | |
| }) | |
| () | |
| (() => NowebConfig) | |
| () | |
| noweb?: NowebConfig; | |
| ({ | |
| description: 'WebJS-specific settings.', | |
| required: false, | |
| }) | |
| () | |
| (() => WebjsConfig) | |
| () | |
| webjs?: WebjsConfig; | |
| } | |
| export class SessionDTO { | |
| ({ | |
| example: 'default', | |
| description: 'Session name (id)', | |
| }) | |
| () | |
| name: string; | |
| status: WAHASessionStatus; | |
| config?: SessionConfig; | |
| } | |
| export class MeInfo { | |
| () | |
| id: string; | |
| ({ | |
| example: '123123@lid', | |
| }) | |
| lid?: string; | |
| pushName: string; | |
| } | |
| export class SessionInfo extends SessionDTO { | |
| me?: MeInfo; | |
| assignedWorker?: string; | |
| } | |
| export class SessionDetailedInfo extends SessionInfo { | |
| engine?: any; | |
| } | |
| // Affect almost all Databases - Sqlite, MongoDB, Postgres. | |
| const DB_NAME_LIMIT = 64; | |
| const DB_NAME_MAX_PREFIX_LEN = 'waha_noweb'.length; | |
| export class SessionCreateRequest { | |
| ({ | |
| example: 'default', | |
| description: 'Session name (id)', | |
| required: false, | |
| }) | |
| () | |
| () | |
| (DB_NAME_LIMIT - DB_NAME_MAX_PREFIX_LEN) | |
| (/^[a-zA-Z0-9_-]*$/, { | |
| message: | |
| 'Session name can only contain alphanumeric characters, hyphens, and underscores (a-z, A-Z, 0-9, -, _) or be empty', | |
| }) | |
| name: string | undefined; | |
| () | |
| (() => SessionConfig) | |
| () | |
| config?: SessionConfig; | |
| ({ | |
| description: 'Start session after creation', | |
| example: true, | |
| default: true, | |
| }) | |
| () | |
| () | |
| start?: boolean; | |
| } | |
| export class SessionUpdateRequest { | |
| () | |
| (() => SessionConfig) | |
| () | |
| config?: SessionConfig; | |
| } | |