Spaces:
Sleeping
Sleeping
Download src/modules/webhook/dto/webhook.dto.ts from jinksQspider/openWa: direct link, hf CLI and curl.
- Browser
- Download file 2.63 kB
-
https://huggingface.co/spaces/jinksQspider/openWa/resolve/main/src/modules/webhook/dto/webhook.dto.ts
- Command line
-
hf download hf://spaces/jinksQspider/openWa/src/modules/webhook/dto/webhook.dto.ts
-
curl -L -o webhook.dto.ts https://huggingface.co/spaces/jinksQspider/openWa/resolve/main/src/modules/webhook/dto/webhook.dto.ts
2.63 kB
| import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | |
| import { IsString, IsUrl, IsArray, IsOptional, IsBoolean, IsInt, Min, Max, ArrayMinSize } from 'class-validator'; | |
| export const WEBHOOK_EVENTS = [ | |
| 'message.received', | |
| 'message.sent', | |
| 'message.ack', | |
| 'message.failed', | |
| 'message.revoked', | |
| 'session.status', | |
| 'session.qr', | |
| 'session.authenticated', | |
| 'session.disconnected', | |
| 'group.join', | |
| 'group.leave', | |
| 'group.update', | |
| ] as const; | |
| export type WebhookEventType = (typeof WEBHOOK_EVENTS)[number]; | |
| export class CreateWebhookDto { | |
| ({ | |
| description: 'Webhook URL to receive events', | |
| example: 'https://your-server.com/webhook', | |
| }) | |
| () | |
| url: string; | |
| ({ | |
| description: 'Event types to subscribe to', | |
| example: ['message.received', 'session.status'], | |
| enum: WEBHOOK_EVENTS, | |
| }) | |
| () | |
| () | |
| (1) | |
| events?: string[]; | |
| ({ | |
| description: 'Secret key for HMAC signature verification', | |
| example: 'your-secret-key', | |
| }) | |
| () | |
| () | |
| secret?: string; | |
| ({ | |
| description: 'Custom headers to include in webhook requests', | |
| example: { 'X-Custom-Header': 'value' }, | |
| }) | |
| () | |
| headers?: Record<string, string>; | |
| ({ | |
| description: 'Number of retry attempts on failure', | |
| example: 3, | |
| minimum: 0, | |
| maximum: 5, | |
| }) | |
| () | |
| () | |
| (0) | |
| (5) | |
| retryCount?: number; | |
| } | |
| export class UpdateWebhookDto { | |
| ({ description: 'Webhook URL' }) | |
| () | |
| () | |
| url?: string; | |
| ({ description: 'Event types to subscribe to' }) | |
| () | |
| () | |
| events?: string[]; | |
| ({ description: 'Secret key for HMAC signature' }) | |
| () | |
| () | |
| secret?: string; | |
| ({ description: 'Custom headers' }) | |
| () | |
| headers?: Record<string, string>; | |
| ({ description: 'Enable/disable webhook' }) | |
| () | |
| () | |
| active?: boolean; | |
| ({ description: 'Retry count' }) | |
| () | |
| () | |
| (0) | |
| (5) | |
| retryCount?: number; | |
| } | |
| export class WebhookResponseDto { | |
| () | |
| id: string; | |
| () | |
| sessionId: string; | |
| () | |
| url: string; | |
| () | |
| events: string[]; | |
| () | |
| active: boolean; | |
| () | |
| retryCount: number; | |
| () | |
| lastTriggeredAt?: Date | null; | |
| () | |
| createdAt: Date; | |
| () | |
| updatedAt: Date; | |
| } | |