File size: 2,981 Bytes
46252cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsArray, IsObject, IsString, IsUrl } from 'class-validator';
import type { PluginConfigSchema, PluginI18n } from '../../../core/plugins';
import { PluginType, PluginStatus } from '../../../core/plugins';

export class PluginDto {
  @ApiProperty({ description: 'Plugin ID' })
  id!: string;

  @ApiProperty({ description: 'Plugin name' })
  name!: string;

  @ApiProperty({ description: 'Plugin version' })
  version!: string;

  @ApiProperty({ enum: PluginType, description: 'Plugin type' })
  type!: PluginType;

  @ApiPropertyOptional({ description: 'Plugin description' })
  description?: string;

  @ApiPropertyOptional({ description: 'Plugin author' })
  author?: string;

  @ApiProperty({ enum: PluginStatus, description: 'Plugin status' })
  status!: PluginStatus;

  @ApiProperty({ description: 'Plugin configuration' })
  config!: Record<string, unknown>;

  @ApiProperty({ description: 'Whether this is a built-in plugin' })
  builtIn!: boolean;

  @ApiProperty({ description: 'Features provided by this plugin' })
  provides!: string[];

  @ApiProperty({ description: 'Whether this plugin can host provisioned ingress instances' })
  ingressCapable!: boolean;

  @ApiProperty({ description: 'Whether the plugin is scoped to specific sessions (false = global)' })
  sessionScoped!: boolean;

  @ApiProperty({ description: "Sessions this plugin is activated for; ['*'] = all numbers" })
  activeSessions!: string[];

  @ApiPropertyOptional({ description: 'Configuration schema' })
  configSchema?: PluginConfigSchema;

  @ApiPropertyOptional({ description: 'Sandboxed-iframe config editor (entry HTML + optional height)' })
  configUi?: { entry: string; height?: number };

  @ApiPropertyOptional({ description: 'Localized dashboard text (name/description/config titles) per locale code' })
  i18n?: PluginI18n;

  @ApiPropertyOptional({ description: 'Per-session config overrides, keyed by sessionId (secrets redacted)' })
  sessionConfig?: Record<string, Record<string, unknown>>;

  @ApiPropertyOptional({ description: 'When the plugin was loaded' })
  loadedAt?: string;

  @ApiPropertyOptional({ description: 'When the plugin was enabled' })
  enabledAt?: string;

  @ApiPropertyOptional({ description: 'Error message if plugin is in error state' })
  error?: string;
}

export class PluginConfigDto {
  @ApiProperty({ description: 'Plugin configuration object' })
  @IsObject()
  config!: Record<string, unknown>;
}

export class PluginSessionsDto {
  @ApiProperty({
    description: "Sessions to activate the plugin for; ['*'] = all numbers, [] = none",
    example: ['*'],
    type: [String],
  })
  @IsArray()
  @IsString({ each: true })
  sessions!: string[];
}

export class InstallFromUrlDto {
  @ApiProperty({ description: 'HTTP(S) URL of the plugin .zip to download and install' })
  @IsString()
  @IsUrl({ protocols: ['http', 'https'], require_protocol: true })
  url!: string;
}