@sonicjs-cms/core 2.5.0 → 2.7.0

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.
Files changed (92) hide show
  1. package/dist/{app-Db0AfT5F.d.cts → app-DV27cjPy.d.cts} +1 -1
  2. package/dist/{app-Db0AfT5F.d.ts → app-DV27cjPy.d.ts} +1 -1
  3. package/dist/{chunk-YIXSSJWD.cjs → chunk-AYPF6C4D.cjs} +5 -5
  4. package/dist/{chunk-YIXSSJWD.cjs.map → chunk-AYPF6C4D.cjs.map} +1 -1
  5. package/dist/chunk-CLIH2T74.js +403 -0
  6. package/dist/chunk-CLIH2T74.js.map +1 -0
  7. package/dist/{chunk-BHNDALCA.js → chunk-DNHJS6RN.js} +6 -4
  8. package/dist/chunk-DNHJS6RN.js.map +1 -0
  9. package/dist/{chunk-YYV3XQOQ.cjs → chunk-E2BXLXPW.cjs} +7 -7
  10. package/dist/{chunk-YYV3XQOQ.cjs.map → chunk-E2BXLXPW.cjs.map} +1 -1
  11. package/dist/{chunk-AZLU3ROK.cjs → chunk-EHSZ6TAN.cjs} +11 -4
  12. package/dist/chunk-EHSZ6TAN.cjs.map +1 -0
  13. package/dist/{chunk-3YUHXWSG.js → chunk-F332TENF.js} +3 -3
  14. package/dist/{chunk-3YUHXWSG.js.map → chunk-F332TENF.js.map} +1 -1
  15. package/dist/{chunk-V5LBQN3I.js → chunk-GRN3GHUG.js} +11 -4
  16. package/dist/chunk-GRN3GHUG.js.map +1 -0
  17. package/dist/{chunk-UAQL2VWX.cjs → chunk-J7F3NPAP.cjs} +2436 -707
  18. package/dist/chunk-J7F3NPAP.cjs.map +1 -0
  19. package/dist/{chunk-VEL7QRYI.js → chunk-L2IDZI7F.js} +9 -2
  20. package/dist/chunk-L2IDZI7F.js.map +1 -0
  21. package/dist/{chunk-ILZ3DP4I.cjs → chunk-MPT5PA6U.cjs} +24 -2
  22. package/dist/chunk-MPT5PA6U.cjs.map +1 -0
  23. package/dist/{chunk-ZWV3EBZ7.cjs → chunk-MYB5RY7H.cjs} +6 -4
  24. package/dist/chunk-MYB5RY7H.cjs.map +1 -0
  25. package/dist/{chunk-OJZ45OJD.js → chunk-UISZ2MBW.js} +2272 -544
  26. package/dist/chunk-UISZ2MBW.js.map +1 -0
  27. package/dist/{chunk-AVPUX57O.js → chunk-V3KVSEG6.js} +3 -3
  28. package/dist/{chunk-AVPUX57O.js.map → chunk-V3KVSEG6.js.map} +1 -1
  29. package/dist/{chunk-TJTWRO4G.js → chunk-Y3EWJQ4D.js} +4 -4
  30. package/dist/{chunk-TJTWRO4G.js.map → chunk-Y3EWJQ4D.js.map} +1 -1
  31. package/dist/{chunk-LWG2MWDA.cjs → chunk-Y72M3MVX.cjs} +4 -4
  32. package/dist/{chunk-LWG2MWDA.cjs.map → chunk-Y72M3MVX.cjs.map} +1 -1
  33. package/dist/{chunk-SGAG6FD3.js → chunk-YFJJU26H.js} +24 -2
  34. package/dist/chunk-YFJJU26H.js.map +1 -0
  35. package/dist/chunk-YHW27CBV.cjs +406 -0
  36. package/dist/chunk-YHW27CBV.cjs.map +1 -0
  37. package/dist/{chunk-I4V3VZWF.cjs → chunk-YRFAQ6MI.cjs} +9 -2
  38. package/dist/chunk-YRFAQ6MI.cjs.map +1 -0
  39. package/dist/{collection-config-B6gMPunn.d.cts → collection-config-BF95LgQb.d.cts} +1 -1
  40. package/dist/{collection-config-B6gMPunn.d.ts → collection-config-BF95LgQb.d.ts} +1 -1
  41. package/dist/index.cjs +4098 -424
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +503 -8
  44. package/dist/index.d.ts +503 -8
  45. package/dist/index.js +4008 -341
  46. package/dist/index.js.map +1 -1
  47. package/dist/middleware.cjs +24 -24
  48. package/dist/middleware.d.cts +1 -1
  49. package/dist/middleware.d.ts +1 -1
  50. package/dist/middleware.js +3 -3
  51. package/dist/migrations-LEMFV2ND.cjs +13 -0
  52. package/dist/{migrations-NIEUFG44.cjs.map → migrations-LEMFV2ND.cjs.map} +1 -1
  53. package/dist/migrations-RKQES6XY.js +4 -0
  54. package/dist/{migrations-TGZKJKV4.js.map → migrations-RKQES6XY.js.map} +1 -1
  55. package/dist/{plugin-bootstrap-dYhD9fQR.d.ts → plugin-bootstrap-CB-xaBfK.d.ts} +2 -2
  56. package/dist/{plugin-bootstrap-SHsdjE6X.d.cts → plugin-bootstrap-U-cw9jn3.d.cts} +2 -2
  57. package/dist/plugins.cjs +11 -11
  58. package/dist/plugins.js +2 -2
  59. package/dist/routes.cjs +27 -27
  60. package/dist/routes.d.cts +1 -1
  61. package/dist/routes.d.ts +1 -1
  62. package/dist/routes.js +7 -7
  63. package/dist/services.cjs +16 -16
  64. package/dist/services.d.cts +2 -2
  65. package/dist/services.d.ts +2 -2
  66. package/dist/services.js +2 -2
  67. package/dist/templates.cjs +17 -17
  68. package/dist/templates.js +2 -2
  69. package/dist/types.d.cts +1 -1
  70. package/dist/types.d.ts +1 -1
  71. package/dist/utils.cjs +14 -14
  72. package/dist/utils.d.cts +1 -1
  73. package/dist/utils.d.ts +1 -1
  74. package/dist/utils.js +1 -1
  75. package/migrations/029_ai_search_plugin.sql +45 -0
  76. package/package.json +4 -2
  77. package/dist/chunk-AI2JJIJX.cjs +0 -211
  78. package/dist/chunk-AI2JJIJX.cjs.map +0 -1
  79. package/dist/chunk-AZLU3ROK.cjs.map +0 -1
  80. package/dist/chunk-BHNDALCA.js.map +0 -1
  81. package/dist/chunk-I4V3VZWF.cjs.map +0 -1
  82. package/dist/chunk-ILZ3DP4I.cjs.map +0 -1
  83. package/dist/chunk-OJZ45OJD.js.map +0 -1
  84. package/dist/chunk-QDBNW7KQ.js +0 -209
  85. package/dist/chunk-QDBNW7KQ.js.map +0 -1
  86. package/dist/chunk-SGAG6FD3.js.map +0 -1
  87. package/dist/chunk-UAQL2VWX.cjs.map +0 -1
  88. package/dist/chunk-V5LBQN3I.js.map +0 -1
  89. package/dist/chunk-VEL7QRYI.js.map +0 -1
  90. package/dist/chunk-ZWV3EBZ7.cjs.map +0 -1
  91. package/dist/migrations-NIEUFG44.cjs +0 -13
  92. package/dist/migrations-TGZKJKV4.js +0 -4
package/dist/index.d.cts CHANGED
@@ -1,26 +1,521 @@
1
- export { B as Bindings, b as SonicJSApp, S as SonicJSConfig, V as Variables, c as createSonicJSApp, s as setupCoreMiddleware, a as setupCoreRoutes } from './app-Db0AfT5F.cjs';
2
- import { s as schema } from './plugin-bootstrap-SHsdjE6X.cjs';
3
- export { ab as Collection, ad as Content, C as CorePlugin, aj as DbPlugin, al as DbPluginHook, p as LogCategory, av as LogConfig, q as LogEntry, t as LogFilter, o as LogLevel, L as Logger, af as Media, m as Migration, M as MigrationService, n as MigrationStatus, ac as NewCollection, ae as NewContent, aw as NewLogConfig, ag as NewMedia, ak as NewPlugin, as as NewPluginActivityLog, aq as NewPluginAsset, am as NewPluginHook, ao as NewPluginRoute, au as NewSystemLog, aa as NewUser, ai as NewWorkflowHistory, ar as PluginActivityLog, ap as PluginAsset, k as PluginBootstrapService, an as PluginRoute, P as PluginServiceClass, at as SystemLog, a9 as User, ah as WorkflowHistory, A as apiTokens, e as cleanupRemovedCollections, w as collections, x as content, y as contentVersions, f as fullCollectionSync, g as getAvailableCollectionNames, h as getLogger, d as getManagedCollections, j as initLogger, O as insertCollectionSchema, R as insertContentSchema, a7 as insertLogConfigSchema, T as insertMediaSchema, a3 as insertPluginActivityLogSchema, a1 as insertPluginAssetSchema, Z as insertPluginHookSchema, $ as insertPluginRouteSchema, X as insertPluginSchema, a5 as insertSystemLogSchema, K as insertUserSchema, V as insertWorkflowHistorySchema, i as isCollectionManaged, a as loadCollectionConfig, l as loadCollectionConfigs, J as logConfig, z as media, H as pluginActivityLog, G as pluginAssets, E as pluginHooks, F as pluginRoutes, D as plugins, r as registerCollections, Q as selectCollectionSchema, S as selectContentSchema, a8 as selectLogConfigSchema, U as selectMediaSchema, a4 as selectPluginActivityLogSchema, a2 as selectPluginAssetSchema, _ as selectPluginHookSchema, a0 as selectPluginRouteSchema, Y as selectPluginSchema, a6 as selectSystemLogSchema, N as selectUserSchema, W as selectWorkflowHistorySchema, c as syncCollection, b as syncCollections, I as systemLogs, u as users, v as validateCollectionConfig, B as workflowHistory } from './plugin-bootstrap-SHsdjE6X.cjs';
1
+ export { B as Bindings, b as SonicJSApp, S as SonicJSConfig, V as Variables, c as createSonicJSApp, s as setupCoreMiddleware, a as setupCoreRoutes } from './app-DV27cjPy.cjs';
2
+ import { t as schema } from './plugin-bootstrap-U-cw9jn3.cjs';
3
+ export { ab as Collection, ad as Content, C as CorePlugin, aj as DbPlugin, al as DbPluginHook, n as LogCategory, av as LogConfig, o as LogEntry, p as LogFilter, m as LogLevel, L as Logger, af as Media, e as Migration, M as MigrationService, h as MigrationStatus, ac as NewCollection, ae as NewContent, aw as NewLogConfig, ag as NewMedia, ak as NewPlugin, as as NewPluginActivityLog, aq as NewPluginAsset, am as NewPluginHook, ao as NewPluginRoute, au as NewSystemLog, aa as NewUser, ai as NewWorkflowHistory, ar as PluginActivityLog, ap as PluginAsset, q as PluginBootstrapService, an as PluginRoute, P as PluginServiceClass, at as SystemLog, a9 as User, ah as WorkflowHistory, A as apiTokens, d as cleanupRemovedCollections, w as collections, x as content, y as contentVersions, f as fullCollectionSync, g as getAvailableCollectionNames, j as getLogger, c as getManagedCollections, k as initLogger, O as insertCollectionSchema, R as insertContentSchema, a7 as insertLogConfigSchema, T as insertMediaSchema, a3 as insertPluginActivityLogSchema, a1 as insertPluginAssetSchema, Z as insertPluginHookSchema, $ as insertPluginRouteSchema, X as insertPluginSchema, a5 as insertSystemLogSchema, K as insertUserSchema, V as insertWorkflowHistorySchema, i as isCollectionManaged, a as loadCollectionConfig, l as loadCollectionConfigs, J as logConfig, z as media, H as pluginActivityLog, G as pluginAssets, E as pluginHooks, F as pluginRoutes, D as plugins, r as registerCollections, Q as selectCollectionSchema, S as selectContentSchema, a8 as selectLogConfigSchema, U as selectMediaSchema, a4 as selectPluginActivityLogSchema, a2 as selectPluginAssetSchema, _ as selectPluginHookSchema, a0 as selectPluginRouteSchema, Y as selectPluginSchema, a6 as selectSystemLogSchema, N as selectUserSchema, W as selectWorkflowHistorySchema, b as syncCollection, s as syncCollections, I as systemLogs, u as users, v as validateCollectionConfig, B as workflowHistory } from './plugin-bootstrap-U-cw9jn3.cjs';
4
4
  export { AuthManager, Permission, PermissionManager, UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './middleware.cjs';
5
5
  export { H as HookSystemImpl, a as HookUtils, b as PluginManagerClass, P as PluginRegistryImpl, c as PluginValidatorClass, S as ScopedHookSystemClass } from './plugin-manager-vBal9Zip.cjs';
6
6
  export { ROUTES_INFO, adminApiRoutes, adminCheckboxRoutes, adminCodeExamplesRoutes, adminCollectionsRoutes, adminContentRoutes, adminDashboardRoutes, adminDesignRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, adminSettingsRoutes, adminTestimonialsRoutes, adminUsersRoutes, apiContentCrudRoutes, apiMediaRoutes, apiRoutes, apiSystemRoutes, authRoutes } from './routes.cjs';
7
7
  export { A as AlertData, C as ConfirmationDialogOptions, k as Filter, j as FilterBarData, l as FilterOption, h as FormData, F as FormField, P as PaginationData, T as TableColumn, i as TableData, g as getConfirmationDialogScript, d as renderAlert, e as renderConfirmationDialog, f as renderFilterBar, r as renderForm, a as renderFormField, c as renderPagination, b as renderTable } from './filter-bar.template-By4jeiw_.cjs';
8
- export { c as CollectionConfig, d as CollectionConfigModule, C as CollectionSchema, e as CollectionSyncResult, a as FieldConfig, F as FieldType } from './collection-config-B6gMPunn.cjs';
8
+ export { c as CollectionConfig, d as CollectionConfigModule, C as CollectionSchema, e as CollectionSyncResult, a as FieldConfig, F as FieldType } from './collection-config-BF95LgQb.cjs';
9
9
  export { A as AuthService, C as ContentService, v as HOOKS, k as HookContext, H as HookHandler, u as HookName, l as HookSystem, p as MediaService, P as Plugin, g as PluginAdminPage, r as PluginBuilderOptions, h as PluginComponent, b as PluginConfig, a as PluginContext, j as PluginHook, q as PluginLogger, n as PluginManager, i as PluginMenuItem, d as PluginMiddleware, e as PluginModel, m as PluginRegistry, c as PluginRoutes, f as PluginService, o as PluginStatus, t as PluginValidationResult, s as PluginValidator, S as ScopedHookSystem } from './plugin-zvZpaiP5.cjs';
10
10
  export { P as PluginManifest } from './plugin-manifest-Dpy8wxIB.cjs';
11
11
  export { c as FilterCondition, d as FilterGroup, F as FilterOperator, f as QueryFilter, Q as QueryFilterBuilder, h as QueryResult, S as SONICJS_VERSION, T as TemplateRenderer, b as buildQuery, e as escapeHtml, g as getCoreVersion, m as metricsTracker, r as renderTemplate, s as sanitizeInput, a as sanitizeObject, t as templateRenderer } from './version-vktVAxhe.cjs';
12
12
  import * as drizzle_orm_d1 from 'drizzle-orm/d1';
13
- import 'hono';
14
- import '@cloudflare/workers-types';
13
+ import { Hono, MiddlewareHandler, Context } from 'hono';
14
+ import { z } from 'zod';
15
+ import { D1Database as D1Database$1, KVNamespace, R2Bucket } from '@cloudflare/workers-types';
15
16
  import 'drizzle-zod';
16
17
  import 'drizzle-orm/sqlite-core';
17
18
  import 'hono/types';
18
- import 'zod';
19
+
20
+ /**
21
+ * SonicJS Plugin System Types
22
+ *
23
+ * Defines the core interfaces and types for the plugin system
24
+ */
25
+
26
+ interface Plugin {
27
+ /** Unique plugin identifier */
28
+ name: string;
29
+ /** Plugin version (semantic versioning) */
30
+ version: string;
31
+ /** Human-readable description */
32
+ description?: string;
33
+ /** Plugin author information */
34
+ author?: {
35
+ name: string;
36
+ email?: string;
37
+ url?: string;
38
+ };
39
+ /** Plugin dependencies (other plugins required) */
40
+ dependencies?: string[];
41
+ /** SonicJS version compatibility */
42
+ compatibility?: string;
43
+ /** Plugin license */
44
+ license?: string;
45
+ routes?: PluginRoutes[];
46
+ middleware?: PluginMiddleware[];
47
+ models?: PluginModel[];
48
+ services?: PluginService[];
49
+ adminPages?: PluginAdminPage[];
50
+ adminComponents?: PluginComponent[];
51
+ menuItems?: PluginMenuItem[];
52
+ hooks?: PluginHook[];
53
+ install?: (context: PluginContext) => Promise<void>;
54
+ uninstall?: (context: PluginContext) => Promise<void>;
55
+ activate?: (context: PluginContext) => Promise<void>;
56
+ deactivate?: (context: PluginContext) => Promise<void>;
57
+ configure?: (config: PluginConfig) => Promise<void>;
58
+ }
59
+ interface PluginContext {
60
+ /** Database instance */
61
+ db: D1Database$1;
62
+ /** Key-value storage */
63
+ kv: KVNamespace;
64
+ /** R2 storage bucket */
65
+ r2?: R2Bucket;
66
+ /** Plugin configuration */
67
+ config: PluginConfig;
68
+ /** Core SonicJS services */
69
+ services: {
70
+ auth: AuthService;
71
+ content: ContentService;
72
+ media: MediaService;
73
+ };
74
+ /** Hook system for inter-plugin communication */
75
+ hooks: HookSystem | ScopedHookSystem;
76
+ /** Logging utilities */
77
+ logger: PluginLogger;
78
+ }
79
+ interface PluginConfig {
80
+ /** Plugin-specific configuration */
81
+ [key: string]: any;
82
+ /** Whether plugin is enabled */
83
+ enabled: boolean;
84
+ /** Plugin installation timestamp */
85
+ installedAt?: number;
86
+ /** Plugin last update timestamp */
87
+ updatedAt?: number;
88
+ }
89
+ interface PluginRoutes {
90
+ /** Route path prefix */
91
+ path: string;
92
+ /** Hono route handler */
93
+ handler: Hono;
94
+ /** Route description */
95
+ description?: string;
96
+ /** Whether route requires authentication */
97
+ requiresAuth?: boolean;
98
+ /** Required roles for access */
99
+ roles?: string[];
100
+ /** Route priority (for ordering) */
101
+ priority?: number;
102
+ }
103
+ interface PluginMiddleware {
104
+ /** Middleware name */
105
+ name: string;
106
+ /** Middleware handler function */
107
+ handler: MiddlewareHandler;
108
+ /** Middleware description */
109
+ description?: string;
110
+ /** Middleware priority (lower = earlier) */
111
+ priority?: number;
112
+ /** Routes to apply middleware to */
113
+ routes?: string[];
114
+ /** Whether to apply globally */
115
+ global?: boolean;
116
+ }
117
+ interface PluginModel {
118
+ /** Model name */
119
+ name: string;
120
+ /** Database table name */
121
+ tableName: string;
122
+ /** Zod schema for validation */
123
+ schema: z.ZodSchema;
124
+ /** Database migrations */
125
+ migrations: string[];
126
+ /** Model relationships */
127
+ relationships?: ModelRelationship[];
128
+ /** Whether model extends core content */
129
+ extendsContent?: boolean;
130
+ }
131
+ interface ModelRelationship {
132
+ type: 'oneToOne' | 'oneToMany' | 'manyToMany';
133
+ target: string;
134
+ foreignKey?: string;
135
+ joinTable?: string;
136
+ }
137
+ interface PluginService {
138
+ /** Service name */
139
+ name: string;
140
+ /** Service implementation */
141
+ implementation: any;
142
+ /** Service description */
143
+ description?: string;
144
+ /** Service dependencies */
145
+ dependencies?: string[];
146
+ /** Whether service is singleton */
147
+ singleton?: boolean;
148
+ }
149
+ interface PluginAdminPage {
150
+ /** Page path (relative to /admin) */
151
+ path: string;
152
+ /** Page title */
153
+ title: string;
154
+ /** Page component/template */
155
+ component: string;
156
+ /** Page description */
157
+ description?: string;
158
+ /** Required permissions */
159
+ permissions?: string[];
160
+ /** Menu item configuration */
161
+ menuItem?: PluginMenuItem;
162
+ /** Page icon */
163
+ icon?: string;
164
+ }
165
+ interface PluginComponent {
166
+ /** Component name */
167
+ name: string;
168
+ /** Component template function */
169
+ template: (props: any) => string;
170
+ /** Component description */
171
+ description?: string;
172
+ /** Component props schema */
173
+ propsSchema?: z.ZodSchema;
174
+ }
175
+ interface PluginMenuItem {
176
+ /** Menu item label */
177
+ label: string;
178
+ /** Menu item path */
179
+ path: string;
180
+ /** Menu item icon */
181
+ icon?: string;
182
+ /** Menu item order */
183
+ order?: number;
184
+ /** Parent menu item */
185
+ parent?: string;
186
+ /** Required permissions */
187
+ permissions?: string[];
188
+ /** Whether item is active */
189
+ active?: boolean;
190
+ }
191
+ interface PluginHook {
192
+ /** Hook name */
193
+ name: string;
194
+ /** Hook handler function */
195
+ handler: HookHandler;
196
+ /** Hook priority */
197
+ priority?: number;
198
+ /** Hook description */
199
+ description?: string;
200
+ }
201
+ type HookHandler = (data: any, context: HookContext) => Promise<any>;
202
+ interface HookContext {
203
+ /** Plugin that registered the hook */
204
+ plugin: string;
205
+ /** Hook execution context */
206
+ context: PluginContext;
207
+ /** Cancel hook execution */
208
+ cancel?: () => void;
209
+ }
210
+ interface HookSystem {
211
+ /** Register a hook handler */
212
+ register(hookName: string, handler: HookHandler, priority?: number): void;
213
+ /** Execute all handlers for a hook */
214
+ execute(hookName: string, data: any, context?: any): Promise<any>;
215
+ /** Remove a hook handler */
216
+ unregister(hookName: string, handler: HookHandler): void;
217
+ /** Get all registered hooks */
218
+ getHooks(hookName: string): PluginHook[];
219
+ /** Create a scoped hook system (optional) */
220
+ createScope?(pluginName: string): ScopedHookSystem;
221
+ }
222
+ interface ScopedHookSystem {
223
+ /** Register a hook handler */
224
+ register(hookName: string, handler: HookHandler, priority?: number): void;
225
+ /** Execute all handlers for a hook */
226
+ execute(hookName: string, data: any, context?: any): Promise<any>;
227
+ /** Remove a hook handler */
228
+ unregister(hookName: string, handler: HookHandler): void;
229
+ /** Remove all hooks for this scope */
230
+ unregisterAll(): void;
231
+ }
232
+ interface AuthService {
233
+ /** Generate JWT token for a user */
234
+ generateToken(userId: string, email: string, role: string): Promise<string>;
235
+ /** Verify and decode JWT token */
236
+ verifyToken(token: string): Promise<any>;
237
+ /** Set authentication cookie (useful for alternative auth methods) */
238
+ setAuthCookie(context: Context, token: string, options?: {
239
+ maxAge?: number;
240
+ secure?: boolean;
241
+ httpOnly?: boolean;
242
+ sameSite?: 'Strict' | 'Lax' | 'None';
243
+ }): void;
244
+ /** Hash password */
245
+ hashPassword(password: string): Promise<string>;
246
+ /** Verify password against hash */
247
+ verifyPassword(password: string, hash: string): Promise<boolean>;
248
+ }
249
+ interface AuthService {
250
+ /** Verify user permissions */
251
+ hasPermission(userId: string, permission: string): Promise<boolean>;
252
+ /** Get current user */
253
+ getCurrentUser(context: Context): Promise<any>;
254
+ /** Create authentication middleware */
255
+ createMiddleware(options?: any): MiddlewareHandler;
256
+ }
257
+ interface ContentService {
258
+ /** Get content by ID */
259
+ getById(id: string): Promise<any>;
260
+ /** Create new content */
261
+ create(data: any): Promise<any>;
262
+ /** Update content */
263
+ update(id: string, data: any): Promise<any>;
264
+ /** Delete content */
265
+ delete(id: string): Promise<void>;
266
+ /** Search content */
267
+ search(query: string, options?: any): Promise<any[]>;
268
+ }
269
+ interface MediaService {
270
+ /** Upload file */
271
+ upload(file: File, options?: any): Promise<any>;
272
+ /** Get media by ID */
273
+ getById(id: string): Promise<any>;
274
+ /** Delete media */
275
+ delete(id: string): Promise<void>;
276
+ /** Transform image */
277
+ transform(id: string, options: any): Promise<string>;
278
+ }
279
+ interface PluginLogger {
280
+ debug(message: string, data?: any): void;
281
+ info(message: string, data?: any): void;
282
+ warn(message: string, data?: any): void;
283
+ error(message: string, error?: Error, data?: any): void;
284
+ }
285
+ interface PluginBuilderOptions {
286
+ name: string;
287
+ version: string;
288
+ description?: string;
289
+ author?: Plugin['author'];
290
+ dependencies?: string[];
291
+ }
19
292
 
20
293
  declare function createDb(d1: D1Database): drizzle_orm_d1.DrizzleD1Database<typeof schema> & {
21
294
  $client: D1Database;
22
295
  };
23
296
 
297
+ /**
298
+ * Plugin Builder SDK
299
+ *
300
+ * Provides a fluent API for building SonicJS plugins
301
+ *
302
+ * @packageDocumentation
303
+ */
304
+
305
+ /**
306
+ * Fluent builder for creating SonicJS plugins.
307
+ *
308
+ * @beta This API is in beta and may change in future releases.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * import { PluginBuilder } from '@sonicjs-cms/core'
313
+ *
314
+ * const plugin = PluginBuilder.create({
315
+ * name: 'my-plugin',
316
+ * version: '1.0.0',
317
+ * description: 'My custom plugin'
318
+ * })
319
+ * .addRoute('/api/my-plugin', routes)
320
+ * .addHook('content:save', handler)
321
+ * .lifecycle({ activate: async () => console.log('Activated!') })
322
+ * .build()
323
+ * ```
324
+ */
325
+ declare class PluginBuilder {
326
+ private plugin;
327
+ constructor(options: PluginBuilderOptions);
328
+ /**
329
+ * Create a new plugin builder
330
+ */
331
+ static create(options: PluginBuilderOptions): PluginBuilder;
332
+ /**
333
+ * Add metadata to the plugin
334
+ */
335
+ metadata(metadata: {
336
+ description?: string;
337
+ author?: Plugin['author'];
338
+ license?: string;
339
+ compatibility?: string;
340
+ dependencies?: string[];
341
+ }): PluginBuilder;
342
+ /**
343
+ * Add routes to plugin
344
+ */
345
+ addRoutes(routes: PluginRoutes[]): PluginBuilder;
346
+ /**
347
+ * Add a single route to plugin
348
+ */
349
+ addRoute(path: string, handler: Hono, options?: {
350
+ description?: string;
351
+ requiresAuth?: boolean;
352
+ roles?: string[];
353
+ priority?: number;
354
+ }): PluginBuilder;
355
+ /**
356
+ * Add middleware to plugin
357
+ */
358
+ addMiddleware(middleware: PluginMiddleware[]): PluginBuilder;
359
+ /**
360
+ * Add a single middleware to plugin
361
+ */
362
+ addSingleMiddleware(name: string, handler: any, options?: {
363
+ description?: string;
364
+ priority?: number;
365
+ routes?: string[];
366
+ global?: boolean;
367
+ }): PluginBuilder;
368
+ /**
369
+ * Add models to plugin
370
+ */
371
+ addModels(models: PluginModel[]): PluginBuilder;
372
+ /**
373
+ * Add a single model to plugin
374
+ */
375
+ addModel(name: string, options: {
376
+ tableName: string;
377
+ schema: z.ZodSchema;
378
+ migrations: string[];
379
+ relationships?: PluginModel['relationships'];
380
+ extendsContent?: boolean;
381
+ }): PluginBuilder;
382
+ /**
383
+ * Add services to plugin
384
+ */
385
+ addServices(services: PluginService[]): PluginBuilder;
386
+ /**
387
+ * Add a single service to plugin
388
+ */
389
+ addService(name: string, implementation: any, options?: {
390
+ description?: string;
391
+ dependencies?: string[];
392
+ singleton?: boolean;
393
+ }): PluginBuilder;
394
+ /**
395
+ * Add admin pages to plugin
396
+ */
397
+ addAdminPages(pages: PluginAdminPage[]): PluginBuilder;
398
+ /**
399
+ * Add a single admin page to plugin
400
+ */
401
+ addAdminPage(path: string, title: string, component: string, options?: {
402
+ description?: string;
403
+ permissions?: string[];
404
+ icon?: string;
405
+ menuItem?: PluginMenuItem;
406
+ }): PluginBuilder;
407
+ /**
408
+ * Add admin components to plugin
409
+ */
410
+ addComponents(components: PluginComponent[]): PluginBuilder;
411
+ /**
412
+ * Add a single admin component to plugin
413
+ */
414
+ addComponent(name: string, template: (props: any) => string, options?: {
415
+ description?: string;
416
+ propsSchema?: z.ZodSchema;
417
+ }): PluginBuilder;
418
+ /**
419
+ * Add menu items to plugin
420
+ */
421
+ addMenuItems(items: PluginMenuItem[]): PluginBuilder;
422
+ /**
423
+ * Add a single menu item to plugin
424
+ */
425
+ addMenuItem(label: string, path: string, options?: {
426
+ icon?: string;
427
+ order?: number;
428
+ parent?: string;
429
+ permissions?: string[];
430
+ }): PluginBuilder;
431
+ /**
432
+ * Add hooks to plugin
433
+ */
434
+ addHooks(hooks: PluginHook[]): PluginBuilder;
435
+ /**
436
+ * Add a single hook to plugin
437
+ */
438
+ addHook(name: string, handler: any, options?: {
439
+ priority?: number;
440
+ description?: string;
441
+ }): PluginBuilder;
442
+ /**
443
+ * Add lifecycle hooks
444
+ */
445
+ lifecycle(hooks: {
446
+ install?: Plugin['install'];
447
+ uninstall?: Plugin['uninstall'];
448
+ activate?: Plugin['activate'];
449
+ deactivate?: Plugin['deactivate'];
450
+ configure?: Plugin['configure'];
451
+ }): PluginBuilder;
452
+ /**
453
+ * Build the plugin
454
+ */
455
+ build(): Plugin;
456
+ }
457
+ /**
458
+ * Helper functions for common plugin patterns.
459
+ *
460
+ * @beta This API is in beta and may change in future releases.
461
+ */
462
+ declare class PluginHelpers {
463
+ /**
464
+ * Create a REST API route for a model.
465
+ *
466
+ * @experimental This method returns placeholder routes. Full implementation coming soon.
467
+ */
468
+ static createModelAPI(modelName: string, options?: {
469
+ basePath?: string;
470
+ permissions?: {
471
+ read?: string[];
472
+ write?: string[];
473
+ delete?: string[];
474
+ };
475
+ }): Hono;
476
+ /**
477
+ * Create an admin CRUD interface for a model.
478
+ *
479
+ * @experimental This method generates basic admin page structures. Full implementation coming soon.
480
+ */
481
+ static createAdminInterface(modelName: string, options?: {
482
+ icon?: string;
483
+ permissions?: string[];
484
+ fields?: Array<{
485
+ name: string;
486
+ type: string;
487
+ label: string;
488
+ required?: boolean;
489
+ }>;
490
+ }): {
491
+ pages: PluginAdminPage[];
492
+ menuItems: PluginMenuItem[];
493
+ };
494
+ /**
495
+ * Create a database migration for a model
496
+ */
497
+ static createMigration(tableName: string, fields: Array<{
498
+ name: string;
499
+ type: 'TEXT' | 'INTEGER' | 'REAL' | 'BLOB';
500
+ nullable?: boolean;
501
+ primaryKey?: boolean;
502
+ unique?: boolean;
503
+ defaultValue?: string;
504
+ }>): string;
505
+ /**
506
+ * Create a Zod schema for a model
507
+ */
508
+ static createSchema(fields: Array<{
509
+ name: string;
510
+ type: 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object';
511
+ optional?: boolean;
512
+ required?: boolean;
513
+ validation?: any;
514
+ items?: any;
515
+ properties?: Record<string, any>;
516
+ }>): z.ZodSchema;
517
+ }
518
+
24
519
  /**
25
520
  * @sonicjs/core - Main Entry Point
26
521
  *
@@ -41,4 +536,4 @@ declare function createDb(d1: D1Database): drizzle_orm_d1.DrizzleD1Database<type
41
536
 
42
537
  declare const VERSION: string;
43
538
 
44
- export { VERSION, createDb };
539
+ export { PluginBuilder, PluginHelpers, VERSION, createDb };