-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathplugin-validator.ts
More file actions
123 lines (106 loc) · 2.82 KB
/
Copy pathplugin-validator.ts
File metadata and controls
123 lines (106 loc) · 2.82 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
/**
* IPluginValidator - Plugin Validator Interface
*
* Abstract interface for validating plugins before registration and startup.
* Extracted from PluginLoader to follow Single Responsibility Principle.
*/
/**
* Validation result for a plugin
*/
export interface ValidationResult {
/**
* Whether the plugin passed validation
*/
valid: boolean;
/**
* Validation errors (if any)
*/
errors?: Array<{
field: string;
message: string;
code?: string;
}>;
/**
* Validation warnings (non-fatal issues)
*/
warnings?: Array<{
field: string;
message: string;
code?: string;
}>;
}
/**
* Plugin metadata for validation
*/
export interface Plugin {
/**
* Unique plugin identifier
*/
name: string;
/**
* Plugin version (semver)
*/
version?: string;
/**
* Plugin dependencies
*/
dependencies?: string[];
/**
* Plugin initialization function
*/
init?: (context: any) => void | Promise<void>;
/**
* Plugin startup function
*/
start?: (context: any) => void | Promise<void>;
/**
* Plugin destruction function
*/
destroy?: (context: any) => void | Promise<void>;
/**
* Plugin signature for verification (optional)
*/
signature?: string;
/**
* Additional plugin metadata
*/
[key: string]: any;
}
/**
* IPluginValidator - Plugin validation interface
*/
export interface IPluginValidator {
/**
* Validate a plugin object structure
* @param plugin - Plugin to validate
* @returns Validation result
*/
validate(plugin: unknown): ValidationResult;
/**
* Validate plugin version format (semver)
* @param version - Version string to validate
* @returns True if version is valid, false otherwise
*/
validateVersion(version: string): boolean;
/**
* Validate plugin cryptographic signature (optional)
* Used for plugin security verification
* @param plugin - Plugin to validate
* @returns Promise resolving to true if signature is valid
*/
validateSignature?(plugin: Plugin): Promise<boolean>;
/**
* Validate plugin dependencies are satisfied
* @param plugin - Plugin to validate
* @param registry - Map of already registered plugins
* @throws Error if dependencies are not satisfied
*/
validateDependencies(plugin: Plugin, registry: Map<string, Plugin>): void;
/**
* Validate plugin has required lifecycle methods
* @param plugin - Plugin to validate
* @returns True if plugin has valid lifecycle methods
*/
validateLifecycle?(plugin: Plugin): boolean;
}