@sonicjs-cms/core 1.0.0-alpha.1 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-24PWAFUT.cjs +776 -0
- package/dist/chunk-24PWAFUT.cjs.map +1 -0
- package/dist/chunk-4URGXJP7.js +3 -0
- package/dist/{chunk-PZ5AY32C.js.map → chunk-4URGXJP7.js.map} +1 -1
- package/dist/chunk-ALTMI5Y2.cjs +4 -0
- package/dist/{chunk-Q7SFCCGT.cjs.map → chunk-ALTMI5Y2.cjs.map} +1 -1
- package/dist/chunk-CXZDAR6S.js +2360 -0
- package/dist/chunk-CXZDAR6S.js.map +1 -0
- package/dist/chunk-EMMSS5I5.cjs +37 -0
- package/dist/chunk-EMMSS5I5.cjs.map +1 -0
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-L3NXO7Y4.cjs +3093 -0
- package/dist/chunk-L3NXO7Y4.cjs.map +1 -0
- package/dist/chunk-NRSL6BQI.js +3086 -0
- package/dist/chunk-NRSL6BQI.js.map +1 -0
- package/dist/chunk-PTQZ5FEI.js +755 -0
- package/dist/chunk-PTQZ5FEI.js.map +1 -0
- package/dist/chunk-WJ7QYVR2.cjs +2416 -0
- package/dist/chunk-WJ7QYVR2.cjs.map +1 -0
- package/dist/collection-config-FLlGtsh9.d.cts +107 -0
- package/dist/collection-config-FLlGtsh9.d.ts +107 -0
- package/dist/index-BlsY5XNH.d.ts +8333 -0
- package/dist/index-D45jaIlr.d.cts +8333 -0
- package/dist/index.cjs +327 -630
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7961
- package/dist/index.d.ts +13 -7961
- package/dist/index.js +8 -592
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +84 -4
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.cts +203 -5
- package/dist/middleware.d.ts +203 -5
- package/dist/middleware.js +3 -6
- package/dist/middleware.js.map +1 -1
- package/dist/plugin-UzmDImQc.d.cts +357 -0
- package/dist/plugin-UzmDImQc.d.ts +357 -0
- package/dist/plugins.cjs +28 -4
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +326 -4
- package/dist/plugins.d.ts +326 -4
- package/dist/plugins.js +3 -6
- package/dist/plugins.js.map +1 -1
- package/dist/routes.cjs +1 -1
- package/dist/routes.js +1 -1
- package/dist/services.cjs +68 -4
- package/dist/services.cjs.map +1 -1
- package/dist/services.d.cts +5 -8
- package/dist/services.d.ts +5 -8
- package/dist/services.js +3 -6
- package/dist/services.js.map +1 -1
- package/dist/templates.cjs +1 -1
- package/dist/templates.js +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +6 -462
- package/dist/types.d.ts +6 -462
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-Q7SFCCGT.cjs +0 -11
package/dist/middleware.d.ts
CHANGED
|
@@ -1,8 +1,206 @@
|
|
|
1
|
+
import * as hono from 'hono';
|
|
2
|
+
import { Context, Next } from 'hono';
|
|
3
|
+
import { D1Database as D1Database$1 } from '@cloudflare/workers-types';
|
|
4
|
+
|
|
5
|
+
type JWTPayload = {
|
|
6
|
+
userId: string;
|
|
7
|
+
email: string;
|
|
8
|
+
role: string;
|
|
9
|
+
exp: number;
|
|
10
|
+
iat: number;
|
|
11
|
+
};
|
|
12
|
+
declare class AuthManager {
|
|
13
|
+
static generateToken(userId: string, email: string, role: string): Promise<string>;
|
|
14
|
+
static verifyToken(token: string): Promise<JWTPayload | null>;
|
|
15
|
+
static hashPassword(password: string): Promise<string>;
|
|
16
|
+
static verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
17
|
+
}
|
|
18
|
+
declare const requireAuth: () => (c: Context, next: Next) => Promise<void | (Response & hono.TypedResponse<undefined, 302, "redirect">) | (Response & hono.TypedResponse<{
|
|
19
|
+
error: string;
|
|
20
|
+
}, 401, "json">)>;
|
|
21
|
+
declare const requireRole: (requiredRole: string | string[]) => (c: Context, next: Next) => Promise<void | (Response & hono.TypedResponse<undefined, 302, "redirect">) | (Response & hono.TypedResponse<{
|
|
22
|
+
error: string;
|
|
23
|
+
}, 401, "json">) | (Response & hono.TypedResponse<{
|
|
24
|
+
error: string;
|
|
25
|
+
}, 403, "json">)>;
|
|
26
|
+
declare const optionalAuth: () => (c: Context, next: Next) => Promise<void>;
|
|
27
|
+
|
|
28
|
+
type Bindings$2 = {
|
|
29
|
+
DB: D1Database;
|
|
30
|
+
};
|
|
31
|
+
type Variables = {
|
|
32
|
+
user?: {
|
|
33
|
+
userId: string;
|
|
34
|
+
email: string;
|
|
35
|
+
role: string;
|
|
36
|
+
exp: number;
|
|
37
|
+
iat: number;
|
|
38
|
+
};
|
|
39
|
+
requestId?: string;
|
|
40
|
+
startTime?: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Logging middleware that captures HTTP requests and responses
|
|
44
|
+
*/
|
|
45
|
+
declare function loggingMiddleware(): (c: Context<{
|
|
46
|
+
Bindings: Bindings$2;
|
|
47
|
+
Variables: Variables;
|
|
48
|
+
}>, next: Next) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Enhanced logging middleware with more detailed request/response logging
|
|
51
|
+
*/
|
|
52
|
+
declare function detailedLoggingMiddleware(): (c: Context<{
|
|
53
|
+
Bindings: Bindings$2;
|
|
54
|
+
Variables: Variables;
|
|
55
|
+
}>, next: Next) => Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Security logging middleware for sensitive operations
|
|
58
|
+
*/
|
|
59
|
+
declare function securityLoggingMiddleware(): (c: Context<{
|
|
60
|
+
Bindings: Bindings$2;
|
|
61
|
+
Variables: Variables;
|
|
62
|
+
}>, next: Next) => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Performance logging middleware for slow requests
|
|
65
|
+
*/
|
|
66
|
+
declare function performanceLoggingMiddleware(slowThreshold?: number): (c: Context<{
|
|
67
|
+
Bindings: Bindings$2;
|
|
68
|
+
Variables: Variables;
|
|
69
|
+
}>, next: Next) => Promise<void>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Add cache headers for static admin pages
|
|
73
|
+
* Only caches authenticated pages with short TTL
|
|
74
|
+
*/
|
|
75
|
+
declare const cacheHeaders: (maxAge?: number) => (c: Context, next: Next) => Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Compression middleware - only compress if client supports it
|
|
78
|
+
*/
|
|
79
|
+
declare const compressionMiddleware: hono.MiddlewareHandler;
|
|
80
|
+
/**
|
|
81
|
+
* Set security headers
|
|
82
|
+
*/
|
|
83
|
+
declare const securityHeaders: () => (c: Context, next: Next) => Promise<void>;
|
|
84
|
+
|
|
85
|
+
interface Permission {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
description: string;
|
|
89
|
+
category: string;
|
|
90
|
+
}
|
|
91
|
+
interface UserPermissions {
|
|
92
|
+
userId: string;
|
|
93
|
+
role: string;
|
|
94
|
+
permissions: string[];
|
|
95
|
+
teamPermissions?: Record<string, string[]>;
|
|
96
|
+
}
|
|
97
|
+
declare class PermissionManager {
|
|
98
|
+
private static permissionCache;
|
|
99
|
+
private static cacheExpiry;
|
|
100
|
+
private static CACHE_TTL;
|
|
101
|
+
/**
|
|
102
|
+
* Get user permissions from database with caching
|
|
103
|
+
*/
|
|
104
|
+
static getUserPermissions(db: D1Database, userId: string): Promise<UserPermissions>;
|
|
105
|
+
/**
|
|
106
|
+
* Check if user has a specific permission
|
|
107
|
+
*/
|
|
108
|
+
static hasPermission(db: D1Database, userId: string, permission: string, teamId?: string): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Clear permission cache for a user
|
|
111
|
+
*/
|
|
112
|
+
static clearUserCache(userId: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Clear all permission cache
|
|
115
|
+
*/
|
|
116
|
+
static clearAllCache(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Clear all permission cache (alias for clearAllCache)
|
|
119
|
+
*/
|
|
120
|
+
static clearCache(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Check multiple permissions at once
|
|
123
|
+
*/
|
|
124
|
+
static checkMultiplePermissions(db: D1Database, userId: string, permissions: string[], teamId?: string): Promise<Record<string, boolean>>;
|
|
125
|
+
/**
|
|
126
|
+
* Middleware factory to require specific permissions
|
|
127
|
+
*/
|
|
128
|
+
static requirePermissions(permissions: string[], teamIdParam?: string): (c: Context, next: Next) => Promise<void | (Response & hono.TypedResponse<{
|
|
129
|
+
error: string;
|
|
130
|
+
}, 401, "json">) | (Response & hono.TypedResponse<{
|
|
131
|
+
error: string;
|
|
132
|
+
}, 403, "json">) | (Response & hono.TypedResponse<{
|
|
133
|
+
error: string;
|
|
134
|
+
}, 500, "json">)>;
|
|
135
|
+
/**
|
|
136
|
+
* Get all available permissions from database
|
|
137
|
+
*/
|
|
138
|
+
static getAllPermissions(db: D1Database): Promise<Permission[]>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Middleware to require specific permission
|
|
142
|
+
*/
|
|
143
|
+
declare function requirePermission(permission: string, teamIdParam?: string): (c: Context, next: Next) => Promise<void | (Response & hono.TypedResponse<{
|
|
144
|
+
error: string;
|
|
145
|
+
}, 401, "json">) | (Response & hono.TypedResponse<{
|
|
146
|
+
error: string;
|
|
147
|
+
}, 403, "json">) | (Response & hono.TypedResponse<{
|
|
148
|
+
error: string;
|
|
149
|
+
}, 500, "json">)>;
|
|
150
|
+
/**
|
|
151
|
+
* Middleware to require any of the specified permissions
|
|
152
|
+
*/
|
|
153
|
+
declare function requireAnyPermission(permissions: string[], teamIdParam?: string): (c: Context, next: Next) => Promise<(Response & hono.TypedResponse<{
|
|
154
|
+
error: string;
|
|
155
|
+
}, 401, "json">) | (Response & hono.TypedResponse<{
|
|
156
|
+
error: string;
|
|
157
|
+
}, 403, "json">) | (Response & hono.TypedResponse<{
|
|
158
|
+
error: string;
|
|
159
|
+
}, 500, "json">) | undefined>;
|
|
160
|
+
/**
|
|
161
|
+
* Helper to log user activity
|
|
162
|
+
*/
|
|
163
|
+
declare function logActivity(db: D1Database, userId: string, action: string, resourceType?: string, resourceId?: string, details?: any, ipAddress?: string, userAgent?: string): Promise<void>;
|
|
164
|
+
|
|
165
|
+
type Bindings$1 = {
|
|
166
|
+
DB: D1Database$1;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Middleware to check if a plugin is active before allowing access to its routes
|
|
170
|
+
*/
|
|
171
|
+
declare function requireActivePlugin(pluginName: string): (c: Context<{
|
|
172
|
+
Bindings: Bindings$1;
|
|
173
|
+
}>, next: Next) => Promise<void | Response>;
|
|
174
|
+
/**
|
|
175
|
+
* Check if multiple plugins are active
|
|
176
|
+
*/
|
|
177
|
+
declare function requireActivePlugins(pluginNames: string[]): (c: Context<{
|
|
178
|
+
Bindings: Bindings$1;
|
|
179
|
+
}>, next: Next) => Promise<void | Response>;
|
|
180
|
+
/**
|
|
181
|
+
* Get list of active plugins for menu generation
|
|
182
|
+
*/
|
|
183
|
+
declare function getActivePlugins(db: D1Database$1): Promise<Array<{
|
|
184
|
+
name: string;
|
|
185
|
+
display_name: string;
|
|
186
|
+
icon?: string;
|
|
187
|
+
settings?: any;
|
|
188
|
+
}>>;
|
|
189
|
+
/**
|
|
190
|
+
* Check if a specific plugin is active
|
|
191
|
+
*/
|
|
192
|
+
declare function isPluginActive(db: D1Database$1, pluginName: string): Promise<boolean>;
|
|
193
|
+
|
|
194
|
+
type Bindings = {
|
|
195
|
+
DB: D1Database;
|
|
196
|
+
KV: KVNamespace;
|
|
197
|
+
};
|
|
1
198
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Request processing middleware for SonicJS
|
|
199
|
+
* Bootstrap middleware that ensures system initialization
|
|
200
|
+
* Runs once per worker instance
|
|
5
201
|
*/
|
|
6
|
-
declare
|
|
202
|
+
declare function bootstrapMiddleware(): (c: Context<{
|
|
203
|
+
Bindings: Bindings;
|
|
204
|
+
}>, next: Next) => Promise<void>;
|
|
7
205
|
|
|
8
|
-
export {
|
|
206
|
+
export { AuthManager, type Permission, PermissionManager, type UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware };
|
package/dist/middleware.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var placeholder = "middleware";
|
|
5
|
-
|
|
6
|
-
export { placeholder };
|
|
1
|
+
export { AuthManager, PermissionManager, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './chunk-PTQZ5FEI.js';
|
|
2
|
+
import './chunk-CXZDAR6S.js';
|
|
3
|
+
import './chunk-G3PMV62Z.js';
|
|
7
4
|
//# sourceMappingURL=middleware.js.map
|
|
8
5
|
//# sourceMappingURL=middleware.js.map
|
package/dist/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"middleware.js"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { Context, MiddlewareHandler, Hono } from 'hono';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { D1Database, KVNamespace, R2Bucket } from '@cloudflare/workers-types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SonicJS Plugin System Types
|
|
7
|
+
*
|
|
8
|
+
* Defines the core interfaces and types for the plugin system
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface Plugin {
|
|
12
|
+
/** Unique plugin identifier */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Plugin version (semantic versioning) */
|
|
15
|
+
version: string;
|
|
16
|
+
/** Human-readable description */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Plugin author information */
|
|
19
|
+
author?: {
|
|
20
|
+
name: string;
|
|
21
|
+
email?: string;
|
|
22
|
+
url?: string;
|
|
23
|
+
};
|
|
24
|
+
/** Plugin dependencies (other plugins required) */
|
|
25
|
+
dependencies?: string[];
|
|
26
|
+
/** SonicJS version compatibility */
|
|
27
|
+
compatibility?: string;
|
|
28
|
+
/** Plugin license */
|
|
29
|
+
license?: string;
|
|
30
|
+
routes?: PluginRoutes[];
|
|
31
|
+
middleware?: PluginMiddleware[];
|
|
32
|
+
models?: PluginModel[];
|
|
33
|
+
services?: PluginService[];
|
|
34
|
+
adminPages?: PluginAdminPage[];
|
|
35
|
+
adminComponents?: PluginComponent[];
|
|
36
|
+
menuItems?: PluginMenuItem[];
|
|
37
|
+
hooks?: PluginHook[];
|
|
38
|
+
install?: (context: PluginContext) => Promise<void>;
|
|
39
|
+
uninstall?: (context: PluginContext) => Promise<void>;
|
|
40
|
+
activate?: (context: PluginContext) => Promise<void>;
|
|
41
|
+
deactivate?: (context: PluginContext) => Promise<void>;
|
|
42
|
+
configure?: (config: PluginConfig) => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
interface PluginContext {
|
|
45
|
+
/** Database instance */
|
|
46
|
+
db: D1Database;
|
|
47
|
+
/** Key-value storage */
|
|
48
|
+
kv: KVNamespace;
|
|
49
|
+
/** R2 storage bucket */
|
|
50
|
+
r2?: R2Bucket;
|
|
51
|
+
/** Plugin configuration */
|
|
52
|
+
config: PluginConfig;
|
|
53
|
+
/** Core SonicJS services */
|
|
54
|
+
services: {
|
|
55
|
+
auth: AuthService;
|
|
56
|
+
content: ContentService;
|
|
57
|
+
media: MediaService;
|
|
58
|
+
};
|
|
59
|
+
/** Hook system for inter-plugin communication */
|
|
60
|
+
hooks: HookSystem | ScopedHookSystem;
|
|
61
|
+
/** Logging utilities */
|
|
62
|
+
logger: PluginLogger;
|
|
63
|
+
}
|
|
64
|
+
interface PluginConfig {
|
|
65
|
+
/** Plugin-specific configuration */
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
/** Whether plugin is enabled */
|
|
68
|
+
enabled: boolean;
|
|
69
|
+
/** Plugin installation timestamp */
|
|
70
|
+
installedAt?: number;
|
|
71
|
+
/** Plugin last update timestamp */
|
|
72
|
+
updatedAt?: number;
|
|
73
|
+
}
|
|
74
|
+
interface PluginRoutes {
|
|
75
|
+
/** Route path prefix */
|
|
76
|
+
path: string;
|
|
77
|
+
/** Hono route handler */
|
|
78
|
+
handler: Hono;
|
|
79
|
+
/** Route description */
|
|
80
|
+
description?: string;
|
|
81
|
+
/** Whether route requires authentication */
|
|
82
|
+
requiresAuth?: boolean;
|
|
83
|
+
/** Required roles for access */
|
|
84
|
+
roles?: string[];
|
|
85
|
+
/** Route priority (for ordering) */
|
|
86
|
+
priority?: number;
|
|
87
|
+
}
|
|
88
|
+
interface PluginMiddleware {
|
|
89
|
+
/** Middleware name */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Middleware handler function */
|
|
92
|
+
handler: MiddlewareHandler;
|
|
93
|
+
/** Middleware description */
|
|
94
|
+
description?: string;
|
|
95
|
+
/** Middleware priority (lower = earlier) */
|
|
96
|
+
priority?: number;
|
|
97
|
+
/** Routes to apply middleware to */
|
|
98
|
+
routes?: string[];
|
|
99
|
+
/** Whether to apply globally */
|
|
100
|
+
global?: boolean;
|
|
101
|
+
}
|
|
102
|
+
interface PluginModel {
|
|
103
|
+
/** Model name */
|
|
104
|
+
name: string;
|
|
105
|
+
/** Database table name */
|
|
106
|
+
tableName: string;
|
|
107
|
+
/** Zod schema for validation */
|
|
108
|
+
schema: z.ZodSchema;
|
|
109
|
+
/** Database migrations */
|
|
110
|
+
migrations: string[];
|
|
111
|
+
/** Model relationships */
|
|
112
|
+
relationships?: ModelRelationship[];
|
|
113
|
+
/** Whether model extends core content */
|
|
114
|
+
extendsContent?: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface ModelRelationship {
|
|
117
|
+
type: 'oneToOne' | 'oneToMany' | 'manyToMany';
|
|
118
|
+
target: string;
|
|
119
|
+
foreignKey?: string;
|
|
120
|
+
joinTable?: string;
|
|
121
|
+
}
|
|
122
|
+
interface PluginService {
|
|
123
|
+
/** Service name */
|
|
124
|
+
name: string;
|
|
125
|
+
/** Service implementation */
|
|
126
|
+
implementation: any;
|
|
127
|
+
/** Service description */
|
|
128
|
+
description?: string;
|
|
129
|
+
/** Service dependencies */
|
|
130
|
+
dependencies?: string[];
|
|
131
|
+
/** Whether service is singleton */
|
|
132
|
+
singleton?: boolean;
|
|
133
|
+
}
|
|
134
|
+
interface PluginAdminPage {
|
|
135
|
+
/** Page path (relative to /admin) */
|
|
136
|
+
path: string;
|
|
137
|
+
/** Page title */
|
|
138
|
+
title: string;
|
|
139
|
+
/** Page component/template */
|
|
140
|
+
component: string;
|
|
141
|
+
/** Page description */
|
|
142
|
+
description?: string;
|
|
143
|
+
/** Required permissions */
|
|
144
|
+
permissions?: string[];
|
|
145
|
+
/** Menu item configuration */
|
|
146
|
+
menuItem?: PluginMenuItem;
|
|
147
|
+
/** Page icon */
|
|
148
|
+
icon?: string;
|
|
149
|
+
}
|
|
150
|
+
interface PluginComponent {
|
|
151
|
+
/** Component name */
|
|
152
|
+
name: string;
|
|
153
|
+
/** Component template function */
|
|
154
|
+
template: (props: any) => string;
|
|
155
|
+
/** Component description */
|
|
156
|
+
description?: string;
|
|
157
|
+
/** Component props schema */
|
|
158
|
+
propsSchema?: z.ZodSchema;
|
|
159
|
+
}
|
|
160
|
+
interface PluginMenuItem {
|
|
161
|
+
/** Menu item label */
|
|
162
|
+
label: string;
|
|
163
|
+
/** Menu item path */
|
|
164
|
+
path: string;
|
|
165
|
+
/** Menu item icon */
|
|
166
|
+
icon?: string;
|
|
167
|
+
/** Menu item order */
|
|
168
|
+
order?: number;
|
|
169
|
+
/** Parent menu item */
|
|
170
|
+
parent?: string;
|
|
171
|
+
/** Required permissions */
|
|
172
|
+
permissions?: string[];
|
|
173
|
+
/** Whether item is active */
|
|
174
|
+
active?: boolean;
|
|
175
|
+
}
|
|
176
|
+
interface PluginHook {
|
|
177
|
+
/** Hook name */
|
|
178
|
+
name: string;
|
|
179
|
+
/** Hook handler function */
|
|
180
|
+
handler: HookHandler;
|
|
181
|
+
/** Hook priority */
|
|
182
|
+
priority?: number;
|
|
183
|
+
/** Hook description */
|
|
184
|
+
description?: string;
|
|
185
|
+
}
|
|
186
|
+
type HookHandler = (data: any, context: HookContext) => Promise<any>;
|
|
187
|
+
interface HookContext {
|
|
188
|
+
/** Plugin that registered the hook */
|
|
189
|
+
plugin: string;
|
|
190
|
+
/** Hook execution context */
|
|
191
|
+
context: PluginContext;
|
|
192
|
+
/** Cancel hook execution */
|
|
193
|
+
cancel?: () => void;
|
|
194
|
+
}
|
|
195
|
+
interface HookSystem {
|
|
196
|
+
/** Register a hook handler */
|
|
197
|
+
register(hookName: string, handler: HookHandler, priority?: number): void;
|
|
198
|
+
/** Execute all handlers for a hook */
|
|
199
|
+
execute(hookName: string, data: any, context?: any): Promise<any>;
|
|
200
|
+
/** Remove a hook handler */
|
|
201
|
+
unregister(hookName: string, handler: HookHandler): void;
|
|
202
|
+
/** Get all registered hooks */
|
|
203
|
+
getHooks(hookName: string): PluginHook[];
|
|
204
|
+
/** Create a scoped hook system (optional) */
|
|
205
|
+
createScope?(pluginName: string): ScopedHookSystem;
|
|
206
|
+
}
|
|
207
|
+
interface ScopedHookSystem {
|
|
208
|
+
/** Register a hook handler */
|
|
209
|
+
register(hookName: string, handler: HookHandler, priority?: number): void;
|
|
210
|
+
/** Execute all handlers for a hook */
|
|
211
|
+
execute(hookName: string, data: any, context?: any): Promise<any>;
|
|
212
|
+
/** Remove a hook handler */
|
|
213
|
+
unregister(hookName: string, handler: HookHandler): void;
|
|
214
|
+
/** Remove all hooks for this scope */
|
|
215
|
+
unregisterAll(): void;
|
|
216
|
+
}
|
|
217
|
+
interface PluginRegistry {
|
|
218
|
+
/** Get plugin by name */
|
|
219
|
+
get(name: string): Plugin | undefined;
|
|
220
|
+
/** Get all registered plugins */
|
|
221
|
+
getAll(): Plugin[];
|
|
222
|
+
/** Get active plugins */
|
|
223
|
+
getActive(): Plugin[];
|
|
224
|
+
/** Register a plugin */
|
|
225
|
+
register(plugin: Plugin): Promise<void>;
|
|
226
|
+
/** Unregister a plugin */
|
|
227
|
+
unregister(name: string): Promise<void>;
|
|
228
|
+
/** Check if plugin is registered */
|
|
229
|
+
has(name: string): boolean;
|
|
230
|
+
/** Activate a plugin */
|
|
231
|
+
activate(name: string): Promise<void>;
|
|
232
|
+
/** Deactivate a plugin */
|
|
233
|
+
deactivate(name: string): Promise<void>;
|
|
234
|
+
/** Get plugin configuration */
|
|
235
|
+
getConfig(name: string): PluginConfig | undefined;
|
|
236
|
+
/** Set plugin configuration */
|
|
237
|
+
setConfig(name: string, config: PluginConfig): void;
|
|
238
|
+
/** Get plugin status */
|
|
239
|
+
getStatus(name: string): PluginStatus | undefined;
|
|
240
|
+
/** Get all plugin statuses */
|
|
241
|
+
getAllStatuses(): Map<string, PluginStatus>;
|
|
242
|
+
/** Resolve plugin load order based on dependencies */
|
|
243
|
+
resolveLoadOrder(): string[];
|
|
244
|
+
}
|
|
245
|
+
interface PluginManager {
|
|
246
|
+
/** Plugin registry */
|
|
247
|
+
registry: PluginRegistry;
|
|
248
|
+
/** Hook system */
|
|
249
|
+
hooks: HookSystem;
|
|
250
|
+
/** Initialize plugin system */
|
|
251
|
+
initialize(context: PluginContext): Promise<void>;
|
|
252
|
+
/** Load plugins from configuration */
|
|
253
|
+
loadPlugins(config: PluginConfig[]): Promise<void>;
|
|
254
|
+
/** Install a plugin */
|
|
255
|
+
install(plugin: Plugin, config?: PluginConfig): Promise<void>;
|
|
256
|
+
/** Uninstall a plugin */
|
|
257
|
+
uninstall(name: string): Promise<void>;
|
|
258
|
+
/** Get plugin status */
|
|
259
|
+
getStatus(name: string): PluginStatus;
|
|
260
|
+
}
|
|
261
|
+
interface PluginStatus {
|
|
262
|
+
name: string;
|
|
263
|
+
version: string;
|
|
264
|
+
active: boolean;
|
|
265
|
+
installed: boolean;
|
|
266
|
+
hasErrors: boolean;
|
|
267
|
+
errors?: string[];
|
|
268
|
+
lastError?: string;
|
|
269
|
+
}
|
|
270
|
+
interface AuthService {
|
|
271
|
+
/** Verify user permissions */
|
|
272
|
+
hasPermission(userId: string, permission: string): Promise<boolean>;
|
|
273
|
+
/** Get current user */
|
|
274
|
+
getCurrentUser(context: Context): Promise<any>;
|
|
275
|
+
/** Create authentication middleware */
|
|
276
|
+
createMiddleware(options?: any): MiddlewareHandler;
|
|
277
|
+
}
|
|
278
|
+
interface ContentService {
|
|
279
|
+
/** Get content by ID */
|
|
280
|
+
getById(id: string): Promise<any>;
|
|
281
|
+
/** Create new content */
|
|
282
|
+
create(data: any): Promise<any>;
|
|
283
|
+
/** Update content */
|
|
284
|
+
update(id: string, data: any): Promise<any>;
|
|
285
|
+
/** Delete content */
|
|
286
|
+
delete(id: string): Promise<void>;
|
|
287
|
+
/** Search content */
|
|
288
|
+
search(query: string, options?: any): Promise<any[]>;
|
|
289
|
+
}
|
|
290
|
+
interface MediaService {
|
|
291
|
+
/** Upload file */
|
|
292
|
+
upload(file: File, options?: any): Promise<any>;
|
|
293
|
+
/** Get media by ID */
|
|
294
|
+
getById(id: string): Promise<any>;
|
|
295
|
+
/** Delete media */
|
|
296
|
+
delete(id: string): Promise<void>;
|
|
297
|
+
/** Transform image */
|
|
298
|
+
transform(id: string, options: any): Promise<string>;
|
|
299
|
+
}
|
|
300
|
+
interface PluginLogger {
|
|
301
|
+
debug(message: string, data?: any): void;
|
|
302
|
+
info(message: string, data?: any): void;
|
|
303
|
+
warn(message: string, data?: any): void;
|
|
304
|
+
error(message: string, error?: Error, data?: any): void;
|
|
305
|
+
}
|
|
306
|
+
interface PluginBuilderOptions {
|
|
307
|
+
name: string;
|
|
308
|
+
version: string;
|
|
309
|
+
description?: string;
|
|
310
|
+
author?: Plugin['author'];
|
|
311
|
+
dependencies?: string[];
|
|
312
|
+
}
|
|
313
|
+
interface PluginValidator {
|
|
314
|
+
/** Validate plugin definition */
|
|
315
|
+
validate(plugin: Plugin): PluginValidationResult;
|
|
316
|
+
/** Validate plugin dependencies */
|
|
317
|
+
validateDependencies(plugin: Plugin, registry: PluginRegistry): PluginValidationResult;
|
|
318
|
+
/** Validate plugin compatibility */
|
|
319
|
+
validateCompatibility(plugin: Plugin, version: string): PluginValidationResult;
|
|
320
|
+
}
|
|
321
|
+
interface PluginValidationResult {
|
|
322
|
+
valid: boolean;
|
|
323
|
+
errors: string[];
|
|
324
|
+
warnings: string[];
|
|
325
|
+
}
|
|
326
|
+
declare const HOOKS: {
|
|
327
|
+
readonly APP_INIT: "app:init";
|
|
328
|
+
readonly APP_READY: "app:ready";
|
|
329
|
+
readonly APP_SHUTDOWN: "app:shutdown";
|
|
330
|
+
readonly REQUEST_START: "request:start";
|
|
331
|
+
readonly REQUEST_END: "request:end";
|
|
332
|
+
readonly REQUEST_ERROR: "request:error";
|
|
333
|
+
readonly AUTH_LOGIN: "auth:login";
|
|
334
|
+
readonly AUTH_LOGOUT: "auth:logout";
|
|
335
|
+
readonly AUTH_REGISTER: "auth:register";
|
|
336
|
+
readonly USER_LOGIN: "user:login";
|
|
337
|
+
readonly USER_LOGOUT: "user:logout";
|
|
338
|
+
readonly CONTENT_CREATE: "content:create";
|
|
339
|
+
readonly CONTENT_UPDATE: "content:update";
|
|
340
|
+
readonly CONTENT_DELETE: "content:delete";
|
|
341
|
+
readonly CONTENT_PUBLISH: "content:publish";
|
|
342
|
+
readonly CONTENT_SAVE: "content:save";
|
|
343
|
+
readonly MEDIA_UPLOAD: "media:upload";
|
|
344
|
+
readonly MEDIA_DELETE: "media:delete";
|
|
345
|
+
readonly MEDIA_TRANSFORM: "media:transform";
|
|
346
|
+
readonly PLUGIN_INSTALL: "plugin:install";
|
|
347
|
+
readonly PLUGIN_UNINSTALL: "plugin:uninstall";
|
|
348
|
+
readonly PLUGIN_ACTIVATE: "plugin:activate";
|
|
349
|
+
readonly PLUGIN_DEACTIVATE: "plugin:deactivate";
|
|
350
|
+
readonly ADMIN_MENU_RENDER: "admin:menu:render";
|
|
351
|
+
readonly ADMIN_PAGE_RENDER: "admin:page:render";
|
|
352
|
+
readonly DB_MIGRATE: "db:migrate";
|
|
353
|
+
readonly DB_SEED: "db:seed";
|
|
354
|
+
};
|
|
355
|
+
type HookName = typeof HOOKS[keyof typeof HOOKS];
|
|
356
|
+
|
|
357
|
+
export { type AuthService as A, type ContentService as C, type HookHandler as H, type MediaService as M, type Plugin as P, type ScopedHookSystem as S, type PluginContext as a, type PluginConfig as b, type PluginRoutes as c, type PluginMiddleware as d, type PluginModel as e, type PluginService as f, type PluginAdminPage as g, type PluginComponent as h, type PluginMenuItem as i, type PluginHook as j, type HookContext as k, type HookSystem as l, type PluginRegistry as m, type PluginManager as n, type PluginStatus as o, type PluginLogger as p, type PluginBuilderOptions as q, type PluginValidator as r, type PluginValidationResult as s, type HookName as t, HOOKS as u, type ModelRelationship as v };
|