@sonicjs-cms/core 2.0.0-alpha.1 → 2.0.0-alpha.11
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-3MNMOLSA.js +133 -0
- package/dist/chunk-3MNMOLSA.js.map +1 -0
- package/dist/{chunk-BRC3F4CG.cjs → chunk-6BHDKYLU.cjs} +8 -2
- package/dist/{chunk-KRJMGD4E.js.map → chunk-6BHDKYLU.cjs.map} +1 -1
- package/dist/{chunk-CXZDAR6S.js → chunk-7N3HK7ZK.js} +3 -3
- package/dist/{chunk-CXZDAR6S.js.map → chunk-7N3HK7ZK.js.map} +1 -1
- package/dist/chunk-AGOE25LF.cjs +137 -0
- package/dist/chunk-AGOE25LF.cjs.map +1 -0
- package/dist/{chunk-NRSL6BQI.js → chunk-BITQ4MFX.js} +3 -3
- package/dist/{chunk-NRSL6BQI.js.map → chunk-BITQ4MFX.js.map} +1 -1
- package/dist/{chunk-24PWAFUT.cjs → chunk-BUKT6HP5.cjs} +13 -13
- package/dist/{chunk-24PWAFUT.cjs.map → chunk-BUKT6HP5.cjs.map} +1 -1
- package/dist/chunk-DG4INX36.cjs +14246 -0
- package/dist/chunk-DG4INX36.cjs.map +1 -0
- package/dist/chunk-FDUDHGI6.js +14233 -0
- package/dist/chunk-FDUDHGI6.js.map +1 -0
- package/dist/{chunk-L3NXO7Y4.cjs → chunk-FVMV5DKA.cjs} +49 -49
- package/dist/{chunk-L3NXO7Y4.cjs.map → chunk-FVMV5DKA.cjs.map} +1 -1
- package/dist/{chunk-KRJMGD4E.js → chunk-FZYF43TN.js} +8 -2
- package/dist/chunk-FZYF43TN.js.map +1 -0
- package/dist/chunk-G4JGVZAF.js +1337 -0
- package/dist/chunk-G4JGVZAF.js.map +1 -0
- package/dist/{chunk-EMMSS5I5.cjs → chunk-IGJUBJBW.cjs} +8 -2
- package/dist/{chunk-ALTMI5Y2.cjs.map → chunk-IGJUBJBW.cjs.map} +1 -1
- package/dist/chunk-LEGKJ5DI.cjs +1344 -0
- package/dist/chunk-LEGKJ5DI.cjs.map +1 -0
- package/dist/{chunk-WJ7QYVR2.cjs → chunk-RNR4HA23.cjs} +4 -4
- package/dist/{chunk-WJ7QYVR2.cjs.map → chunk-RNR4HA23.cjs.map} +1 -1
- package/dist/{chunk-G3PMV62Z.js → chunk-V4OQ3NZ2.js} +7 -3
- package/dist/{chunk-G3PMV62Z.js.map → chunk-V4OQ3NZ2.js.map} +1 -1
- package/dist/{chunk-PTQZ5FEI.js → chunk-WESS2U3K.js} +3 -3
- package/dist/{chunk-PTQZ5FEI.js.map → chunk-WESS2U3K.js.map} +1 -1
- package/dist/index.cjs +147 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -135
- package/dist/index.js +24 -9
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +23 -23
- package/dist/middleware.d.ts +2 -206
- package/dist/middleware.js +3 -3
- package/dist/plugins.cjs +8 -8
- package/dist/plugins.d.ts +2 -330
- package/dist/plugins.js +2 -2
- package/dist/routes.cjs +52 -3
- package/dist/routes.d.ts +2 -17
- package/dist/routes.js +7 -2
- package/dist/services.cjs +31 -19
- package/dist/services.d.ts +2 -5
- package/dist/services.js +3 -3
- package/dist/templates.cjs +23 -10
- package/dist/templates.d.ts +2 -140
- package/dist/templates.js +3 -2
- package/dist/types.cjs +1 -1
- package/dist/types.d.ts +2 -41
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +2 -184
- package/dist/utils.js +1 -1
- package/migrations/001_initial_schema.sql +198 -0
- package/migrations/002_faq_plugin.sql +86 -0
- package/migrations/003_stage5_enhancements.sql +121 -0
- package/migrations/004_stage6_user_management.sql +183 -0
- package/migrations/005_stage7_workflow_automation.sql +294 -0
- package/migrations/006_plugin_system.sql +155 -0
- package/migrations/007_demo_login_plugin.sql +23 -0
- package/migrations/008_fix_slug_validation.sql +22 -0
- package/migrations/009_system_logging.sql +57 -0
- package/migrations/011_config_managed_collections.sql +14 -0
- package/migrations/012_testimonials_plugin.sql +80 -0
- package/migrations/013_code_examples_plugin.sql +177 -0
- package/migrations/014_fix_plugin_registry.sql +88 -0
- package/migrations/015_add_remaining_plugins.sql +89 -0
- package/migrations/016_remove_duplicate_cache_plugin.sql +17 -0
- package/migrations/017_auth_configurable_fields.sql +49 -0
- package/package.json +2 -2
- package/dist/chunk-4URGXJP7.js +0 -3
- package/dist/chunk-4URGXJP7.js.map +0 -1
- package/dist/chunk-ALTMI5Y2.cjs +0 -4
- package/dist/chunk-BOLQHE4J.cjs +0 -11
- package/dist/chunk-BOLQHE4J.cjs.map +0 -1
- package/dist/chunk-BRC3F4CG.cjs.map +0 -1
- package/dist/chunk-EMMSS5I5.cjs.map +0 -1
- package/dist/chunk-HD7R6T6I.js +0 -9
- package/dist/chunk-HD7R6T6I.js.map +0 -1
- package/dist/collection-config-FLlGtsh9.d.cts +0 -107
- package/dist/collection-config-FLlGtsh9.d.ts +0 -107
- package/dist/index-BlsY5XNH.d.ts +0 -8333
- package/dist/index-D45jaIlr.d.cts +0 -8333
- package/dist/index.d.cts +0 -136
- package/dist/middleware.d.cts +0 -206
- package/dist/plugin-UzmDImQc.d.cts +0 -357
- package/dist/plugin-UzmDImQc.d.ts +0 -357
- package/dist/plugins.d.cts +0 -330
- package/dist/routes.d.cts +0 -17
- package/dist/services.d.cts +0 -5
- package/dist/templates.d.cts +0 -140
- package/dist/types.d.cts +0 -41
- package/dist/utils.d.cts +0 -184
package/dist/index.d.ts
CHANGED
|
@@ -1,136 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { s as schema } from './index-BlsY5XNH.js';
|
|
4
|
-
export { aa as Collection, ac as Content, C as CorePlugin, ai as DbPlugin, ak as DbPluginHook, p as LogCategory, au as LogConfig, q as LogEntry, r as LogFilter, o as LogLevel, L as Logger, ae as Media, m as Migration, M as MigrationService, n as MigrationStatus, ab as NewCollection, ad as NewContent, av as NewLogConfig, af as NewMedia, aj as NewPlugin, ar as NewPluginActivityLog, ap as NewPluginAsset, al as NewPluginHook, an as NewPluginRoute, at as NewSystemLog, a9 as NewUser, ah as NewWorkflowHistory, aq as PluginActivityLog, ao as PluginAsset, k as PluginBootstrapService, am as PluginRoute, P as PluginServiceClass, as as SystemLog, a8 as User, ag as WorkflowHistory, z as apiTokens, e as cleanupRemovedCollections, t as collections, w as content, x as contentVersions, f as fullCollectionSync, g as getAvailableCollectionNames, h as getLogger, d as getManagedCollections, j as initLogger, N as insertCollectionSchema, Q as insertContentSchema, a6 as insertLogConfigSchema, S as insertMediaSchema, a2 as insertPluginActivityLogSchema, a0 as insertPluginAssetSchema, Y as insertPluginHookSchema, _ as insertPluginRouteSchema, W as insertPluginSchema, a4 as insertSystemLogSchema, J as insertUserSchema, U as insertWorkflowHistorySchema, i as isCollectionManaged, a as loadCollectionConfig, l as loadCollectionConfigs, I as logConfig, y as media, G as pluginActivityLog, F as pluginAssets, D as pluginHooks, E as pluginRoutes, B as plugins, O as selectCollectionSchema, R as selectContentSchema, a7 as selectLogConfigSchema, T as selectMediaSchema, a3 as selectPluginActivityLogSchema, a1 as selectPluginAssetSchema, Z as selectPluginHookSchema, $ as selectPluginRouteSchema, X as selectPluginSchema, a5 as selectSystemLogSchema, K as selectUserSchema, V as selectWorkflowHistorySchema, c as syncCollection, b as syncCollections, H as systemLogs, u as users, v as validateCollectionConfig, A as workflowHistory } from './index-BlsY5XNH.js';
|
|
5
|
-
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.js';
|
|
6
|
-
export { HookSystemImpl, HookUtils, PluginManager as PluginManagerClass, PluginRegistryImpl, PluginValidator as PluginValidatorClass, ScopedHookSystem as ScopedHookSystemClass } from './plugins.js';
|
|
7
|
-
export { ROUTES_INFO } from './routes.js';
|
|
8
|
-
export { AlertData, ConfirmationDialogOptions, Filter, FilterBarData, FilterOption, FormData, FormField, PaginationData, TableColumn, TableData, getConfirmationDialogScript, renderAlert, renderConfirmationDialog, renderFilterBar, renderForm, renderFormField, renderPagination, renderTable } from './templates.js';
|
|
9
|
-
export { b as CollectionConfig, c as CollectionConfigModule, C as CollectionSchema, d as CollectionSyncResult, a as FieldConfig, F as FieldType } from './collection-config-FLlGtsh9.js';
|
|
10
|
-
export { A as AuthService, C as ContentService, u as HOOKS, k as HookContext, H as HookHandler, t as HookName, l as HookSystem, M as MediaService, P as Plugin, g as PluginAdminPage, q as PluginBuilderOptions, h as PluginComponent, b as PluginConfig, a as PluginContext, j as PluginHook, p 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, s as PluginValidationResult, r as PluginValidator, S as ScopedHookSystem } from './plugin-UzmDImQc.js';
|
|
11
|
-
export { PluginManifest } from './types.js';
|
|
12
|
-
export { FilterCondition, FilterGroup, FilterOperator, QueryFilter, QueryFilterBuilder, QueryResult, TemplateRenderer, buildQuery, escapeHtml, metricsTracker, renderTemplate, sanitizeInput, sanitizeObject, templateRenderer } from './utils.js';
|
|
13
|
-
import * as drizzle_orm_d1 from 'drizzle-orm/d1';
|
|
14
|
-
import 'drizzle-zod';
|
|
15
|
-
import 'drizzle-orm/sqlite-core';
|
|
16
|
-
import 'zod';
|
|
1
|
+
// Main exports from @sonicjs-cms/core package
|
|
2
|
+
export * from '../src/index'
|
|
17
3
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* Creates a configured SonicJS application with all core functionality
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
interface Bindings {
|
|
25
|
-
DB: D1Database$1;
|
|
26
|
-
CACHE_KV: KVNamespace;
|
|
27
|
-
MEDIA_BUCKET: R2Bucket;
|
|
28
|
-
ASSETS: Fetcher;
|
|
29
|
-
EMAIL_QUEUE?: Queue;
|
|
30
|
-
SENDGRID_API_KEY?: string;
|
|
31
|
-
DEFAULT_FROM_EMAIL?: string;
|
|
32
|
-
IMAGES_ACCOUNT_ID?: string;
|
|
33
|
-
IMAGES_API_TOKEN?: string;
|
|
34
|
-
ENVIRONMENT?: string;
|
|
35
|
-
}
|
|
36
|
-
interface Variables {
|
|
37
|
-
user?: {
|
|
38
|
-
userId: string;
|
|
39
|
-
email: string;
|
|
40
|
-
role: string;
|
|
41
|
-
exp: number;
|
|
42
|
-
iat: number;
|
|
43
|
-
};
|
|
44
|
-
requestId?: string;
|
|
45
|
-
startTime?: number;
|
|
46
|
-
appVersion?: string;
|
|
47
|
-
}
|
|
48
|
-
interface SonicJSConfig {
|
|
49
|
-
collections?: {
|
|
50
|
-
directory?: string;
|
|
51
|
-
autoSync?: boolean;
|
|
52
|
-
};
|
|
53
|
-
plugins?: {
|
|
54
|
-
directory?: string;
|
|
55
|
-
autoLoad?: boolean;
|
|
56
|
-
};
|
|
57
|
-
routes?: Array<{
|
|
58
|
-
path: string;
|
|
59
|
-
handler: Hono;
|
|
60
|
-
}>;
|
|
61
|
-
middleware?: {
|
|
62
|
-
beforeAuth?: Array<(c: Context, next: () => Promise<void>) => Promise<void>>;
|
|
63
|
-
afterAuth?: Array<(c: Context, next: () => Promise<void>) => Promise<void>>;
|
|
64
|
-
};
|
|
65
|
-
version?: string;
|
|
66
|
-
name?: string;
|
|
67
|
-
}
|
|
68
|
-
type SonicJSApp = Hono<{
|
|
69
|
-
Bindings: Bindings;
|
|
70
|
-
Variables: Variables;
|
|
71
|
-
}>;
|
|
72
|
-
/**
|
|
73
|
-
* Create a SonicJS application with core functionality
|
|
74
|
-
*
|
|
75
|
-
* @param config - Application configuration
|
|
76
|
-
* @returns Configured Hono application
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* import { createSonicJSApp } from '@sonicjs/core'
|
|
81
|
-
*
|
|
82
|
-
* const app = createSonicJSApp({
|
|
83
|
-
* collections: {
|
|
84
|
-
* directory: './src/collections',
|
|
85
|
-
* autoSync: true
|
|
86
|
-
* },
|
|
87
|
-
* plugins: {
|
|
88
|
-
* directory: './src/plugins',
|
|
89
|
-
* autoLoad: true
|
|
90
|
-
* }
|
|
91
|
-
* })
|
|
92
|
-
*
|
|
93
|
-
* export default app
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
declare function createSonicJSApp(config?: SonicJSConfig): SonicJSApp;
|
|
97
|
-
/**
|
|
98
|
-
* Setup core middleware (backward compatibility)
|
|
99
|
-
*
|
|
100
|
-
* @param _app - Hono application
|
|
101
|
-
* @deprecated Use createSonicJSApp() instead
|
|
102
|
-
*/
|
|
103
|
-
declare function setupCoreMiddleware(_app: SonicJSApp): void;
|
|
104
|
-
/**
|
|
105
|
-
* Setup core routes (backward compatibility)
|
|
106
|
-
*
|
|
107
|
-
* @param _app - Hono application
|
|
108
|
-
* @deprecated Use createSonicJSApp() instead
|
|
109
|
-
*/
|
|
110
|
-
declare function setupCoreRoutes(_app: SonicJSApp): void;
|
|
111
|
-
|
|
112
|
-
declare function createDb(d1: D1Database): drizzle_orm_d1.DrizzleD1Database<typeof schema> & {
|
|
113
|
-
$client: D1Database;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @sonicjs/core - Main Entry Point
|
|
118
|
-
*
|
|
119
|
-
* Core framework for SonicJS headless CMS
|
|
120
|
-
* Built for Cloudflare's edge platform with TypeScript
|
|
121
|
-
*
|
|
122
|
-
* Phase 2 Migration Status:
|
|
123
|
-
* - Week 1: Types, Utils, Database (COMPLETED ✓)
|
|
124
|
-
* - Week 2: Services, Middleware, Plugins (COMPLETED ✓)
|
|
125
|
-
* - Week 3: Routes, Templates (COMPLETED ✓)
|
|
126
|
-
* - Week 4: Integration & Testing (COMPLETED ✓)
|
|
127
|
-
*
|
|
128
|
-
* Test Coverage:
|
|
129
|
-
* - Utilities: 48 tests (sanitize, query-filter, metrics)
|
|
130
|
-
* - Middleware: 51 tests (auth, logging, security, performance)
|
|
131
|
-
* - Total: 99 tests passing
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
declare const VERSION = "2.0.0-alpha.1";
|
|
135
|
-
|
|
136
|
-
export { type Bindings, type SonicJSApp, type SonicJSConfig, VERSION, type Variables, createDb, createSonicJSApp, setupCoreMiddleware, setupCoreRoutes };
|
|
4
|
+
// Explicitly re-export key types and classes
|
|
5
|
+
export type { Plugin, PluginContext } from '../src/types/index'
|
|
6
|
+
export { TemplateRenderer, templateRenderer, renderTemplate } from '../src/utils/template-renderer'
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import './chunk-
|
|
2
|
-
export {
|
|
3
|
-
import
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
1
|
+
import { api_default, api_media_default, api_system_default, admin_api_default, admin_content_default, adminMediaRoutes, adminPluginRoutes, adminLogsRoutes, userRoutes, auth_default } from './chunk-FDUDHGI6.js';
|
|
2
|
+
export { ROUTES_INFO, admin_content_default as adminContentRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, userRoutes as adminUsersRoutes, api_media_default as apiMediaRoutes, api_default as apiRoutes, auth_default as authRoutes } from './chunk-FDUDHGI6.js';
|
|
3
|
+
import './chunk-3MNMOLSA.js';
|
|
4
|
+
export { AuthManager, PermissionManager, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './chunk-WESS2U3K.js';
|
|
5
|
+
import { schema_exports } from './chunk-7N3HK7ZK.js';
|
|
6
|
+
export { Logger, MigrationService, PluginBootstrapService, PluginService as PluginServiceClass, apiTokens, cleanupRemovedCollections, collections, content, contentVersions, fullCollectionSync, getAvailableCollectionNames, getLogger, getManagedCollections, initLogger, insertCollectionSchema, insertContentSchema, insertLogConfigSchema, insertMediaSchema, insertPluginActivityLogSchema, insertPluginAssetSchema, insertPluginHookSchema, insertPluginRouteSchema, insertPluginSchema, insertSystemLogSchema, insertUserSchema, insertWorkflowHistorySchema, isCollectionManaged, loadCollectionConfig, loadCollectionConfigs, logConfig, media, pluginActivityLog, pluginAssets, pluginHooks, pluginRoutes, plugins, selectCollectionSchema, selectContentSchema, selectLogConfigSchema, selectMediaSchema, selectPluginActivityLogSchema, selectPluginAssetSchema, selectPluginHookSchema, selectPluginRouteSchema, selectPluginSchema, selectSystemLogSchema, selectUserSchema, selectWorkflowHistorySchema, syncCollection, syncCollections, systemLogs, users, validateCollectionConfig, workflowHistory } from './chunk-7N3HK7ZK.js';
|
|
7
|
+
export { getConfirmationDialogScript, renderAlert, renderConfirmationDialog, renderFilterBar, renderForm, renderFormField, renderPagination, renderTable } from './chunk-FZYF43TN.js';
|
|
8
|
+
import './chunk-G4JGVZAF.js';
|
|
9
|
+
export { HookSystemImpl, HookUtils, PluginManager as PluginManagerClass, PluginRegistryImpl, PluginValidator as PluginValidatorClass, ScopedHookSystem as ScopedHookSystemClass } from './chunk-BITQ4MFX.js';
|
|
8
10
|
export { QueryFilterBuilder, TemplateRenderer, buildQuery, escapeHtml, metricsTracker, renderTemplate, sanitizeInput, sanitizeObject, templateRenderer } from './chunk-JIINOD2W.js';
|
|
9
11
|
export { HOOKS } from './chunk-LOUJRBXV.js';
|
|
10
|
-
import './chunk-
|
|
12
|
+
import './chunk-V4OQ3NZ2.js';
|
|
11
13
|
import { Hono } from 'hono';
|
|
12
14
|
import { drizzle } from 'drizzle-orm/d1';
|
|
13
15
|
|
|
@@ -38,11 +40,24 @@ function createSonicJSApp(config = {}) {
|
|
|
38
40
|
app.use("*", middleware);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
43
|
+
app.route("/api", api_default);
|
|
44
|
+
app.route("/api/media", api_media_default);
|
|
45
|
+
app.route("/api/system", api_system_default);
|
|
46
|
+
app.route("/admin/api", admin_api_default);
|
|
47
|
+
app.route("/admin/content", admin_content_default);
|
|
48
|
+
app.route("/admin/media", adminMediaRoutes);
|
|
49
|
+
app.route("/admin/plugins", adminPluginRoutes);
|
|
50
|
+
app.route("/admin/logs", adminLogsRoutes);
|
|
51
|
+
app.route("/admin", userRoutes);
|
|
52
|
+
app.route("/auth", auth_default);
|
|
41
53
|
if (config.routes) {
|
|
42
54
|
for (const route of config.routes) {
|
|
43
55
|
app.route(route.path, route.handler);
|
|
44
56
|
}
|
|
45
57
|
}
|
|
58
|
+
app.get("/", (c) => {
|
|
59
|
+
return c.redirect("/auth/login");
|
|
60
|
+
});
|
|
46
61
|
app.get("/health", (c) => {
|
|
47
62
|
return c.json({
|
|
48
63
|
name: appName,
|
|
@@ -71,7 +86,7 @@ function createDb(d1) {
|
|
|
71
86
|
}
|
|
72
87
|
|
|
73
88
|
// src/index.ts
|
|
74
|
-
var VERSION = "2.0.0-alpha.
|
|
89
|
+
var VERSION = "2.0.0-alpha.3";
|
|
75
90
|
|
|
76
91
|
export { VERSION, createDb, createSonicJSApp, setupCoreMiddleware, setupCoreRoutes };
|
|
77
92
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/app.ts","../src/db/index.ts","../src/index.ts"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["/**\n * Main Application Factory\n *\n * Creates a configured SonicJS application with all core functionality\n */\n\nimport { Hono } from 'hono'\nimport type { Context } from 'hono'\nimport type { D1Database, KVNamespace, R2Bucket } from '@cloudflare/workers-types'\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\nexport interface Bindings {\n DB: D1Database\n CACHE_KV: KVNamespace\n MEDIA_BUCKET: R2Bucket\n ASSETS: Fetcher\n EMAIL_QUEUE?: Queue\n SENDGRID_API_KEY?: string\n DEFAULT_FROM_EMAIL?: string\n IMAGES_ACCOUNT_ID?: string\n IMAGES_API_TOKEN?: string\n ENVIRONMENT?: string\n}\n\nexport interface Variables {\n user?: {\n userId: string\n email: string\n role: string\n exp: number\n iat: number\n }\n requestId?: string\n startTime?: number\n appVersion?: string\n}\n\nexport interface SonicJSConfig {\n // Collections configuration\n collections?: {\n directory?: string\n autoSync?: boolean\n }\n\n // Plugins configuration\n plugins?: {\n directory?: string\n autoLoad?: boolean\n }\n\n // Custom routes\n routes?: Array<{\n path: string\n handler: Hono\n }>\n\n // Custom middleware\n middleware?: {\n beforeAuth?: Array<(c: Context, next: () => Promise<void>) => Promise<void>>\n afterAuth?: Array<(c: Context, next: () => Promise<void>) => Promise<void>>\n }\n\n // App metadata\n version?: string\n name?: string\n}\n\nexport type SonicJSApp = Hono<{ Bindings: Bindings; Variables: Variables }>\n\n// ============================================================================\n// Application Factory\n// ============================================================================\n\n/**\n * Create a SonicJS application with core functionality\n *\n * @param config - Application configuration\n * @returns Configured Hono application\n *\n * @example\n * ```typescript\n * import { createSonicJSApp } from '@sonicjs/core'\n *\n * const app = createSonicJSApp({\n * collections: {\n * directory: './src/collections',\n * autoSync: true\n * },\n * plugins: {\n * directory: './src/plugins',\n * autoLoad: true\n * }\n * })\n *\n * export default app\n * ```\n */\nexport function createSonicJSApp(config: SonicJSConfig = {}): SonicJSApp {\n const app = new Hono<{ Bindings: Bindings; Variables: Variables }>()\n\n // Set app metadata\n const appVersion = config.version || '1.0.0'\n const appName = config.name || 'SonicJS'\n\n // App version middleware\n app.use('*', async (c, next) => {\n c.set('appVersion', appVersion)\n await next()\n })\n\n // Bootstrap middleware\n // Note: Implementation will be imported from middleware/bootstrap\n // This is a placeholder for the factory pattern\n app.use('*', async (_c, next) => {\n // Bootstrap logic here (migrations, collections, plugins)\n await next()\n })\n\n // Custom middleware - before auth\n if (config.middleware?.beforeAuth) {\n for (const middleware of config.middleware.beforeAuth) {\n app.use('*', middleware)\n }\n }\n\n // Logging middleware\n app.use('*', async (_c, next) => {\n // Logging logic here\n await next()\n })\n\n // Security middleware\n app.use('*', async (_c, next) => {\n // Security headers, CORS, etc.\n await next()\n })\n\n // Custom middleware - after auth\n if (config.middleware?.afterAuth) {\n for (const middleware of config.middleware.afterAuth) {\n app.use('*', middleware)\n }\n }\n\n // Core routes\n // Note: Routes will be imported from routes/*\n // This is a placeholder for the factory pattern\n\n // Custom routes\n if (config.routes) {\n for (const route of config.routes) {\n app.route(route.path, route.handler)\n }\n }\n\n // Health check\n app.get('/health', (c) => {\n return c.json({\n name: appName,\n version: appVersion,\n status: 'running',\n timestamp: new Date().toISOString()\n })\n })\n\n // 404 handler\n app.notFound((c) => {\n return c.json({ error: 'Not Found', status: 404 }, 404)\n })\n\n // Error handler\n app.onError((err, c) => {\n console.error(err)\n return c.json({ error: 'Internal Server Error', status: 500 }, 500)\n })\n\n return app\n}\n\n/**\n * Setup core middleware (backward compatibility)\n *\n * @param _app - Hono application\n * @deprecated Use createSonicJSApp() instead\n */\nexport function setupCoreMiddleware(_app: SonicJSApp): void {\n console.warn('setupCoreMiddleware is deprecated. Use createSonicJSApp() instead.')\n // Backward compatibility implementation\n}\n\n/**\n * Setup core routes (backward compatibility)\n *\n * @param _app - Hono application\n * @deprecated Use createSonicJSApp() instead\n */\nexport function setupCoreRoutes(_app: SonicJSApp): void {\n console.warn('setupCoreRoutes is deprecated. Use createSonicJSApp() instead.')\n // Backward compatibility implementation\n}\n","import { drizzle } from 'drizzle-orm/d1';\nimport * as schema from './schema';\n\nexport function createDb(d1: D1Database) {\n return drizzle(d1, { schema });\n}\n\nexport * from './schema';","/**\n * @sonicjs/core - Main Entry Point\n *\n * Core framework for SonicJS headless CMS\n * Built for Cloudflare's edge platform with TypeScript\n *\n * Phase 2 Migration Status:\n * - Week 1: Types, Utils, Database (COMPLETED ✓)\n * - Week 2: Services, Middleware, Plugins (COMPLETED ✓)\n * - Week 3: Routes, Templates (COMPLETED ✓)\n * - Week 4: Integration & Testing (COMPLETED ✓)\n *\n * Test Coverage:\n * - Utilities: 48 tests (sanitize, query-filter, metrics)\n * - Middleware: 51 tests (auth, logging, security, performance)\n * - Total: 99 tests passing\n */\n\n// ============================================================================\n// Main Application API (Phase 2 Week 1)\n// ============================================================================\n\nexport { createSonicJSApp, setupCoreMiddleware, setupCoreRoutes } from './app'\nexport type { SonicJSConfig, SonicJSApp, Bindings, Variables } from './app'\n\n// ============================================================================\n// Placeholders - To be populated in Phase 2\n// ============================================================================\n\n// Services - Week 2 (COMPLETED)\nexport {\n // Collection Management\n loadCollectionConfigs,\n loadCollectionConfig,\n getAvailableCollectionNames,\n validateCollectionConfig,\n syncCollections,\n syncCollection,\n isCollectionManaged,\n getManagedCollections,\n cleanupRemovedCollections,\n fullCollectionSync,\n // Database Migrations\n MigrationService,\n // Logging\n Logger,\n getLogger,\n initLogger,\n // Plugin Services - Class implementations\n PluginService as PluginServiceClass,\n PluginBootstrapService,\n} from './services'\n\nexport type { Migration, MigrationStatus, LogLevel, LogCategory, LogEntry, LogFilter, CorePlugin } from './services'\n\n// Middleware - Week 2 (COMPLETED)\nexport {\n // Authentication\n AuthManager,\n requireAuth,\n requireRole,\n optionalAuth,\n // Logging\n loggingMiddleware,\n detailedLoggingMiddleware,\n securityLoggingMiddleware,\n performanceLoggingMiddleware,\n // Performance\n cacheHeaders,\n compressionMiddleware,\n securityHeaders,\n // Permissions\n PermissionManager,\n requirePermission,\n requireAnyPermission,\n logActivity,\n // Plugin middleware\n requireActivePlugin,\n requireActivePlugins,\n getActivePlugins,\n isPluginActive,\n // Bootstrap\n bootstrapMiddleware,\n} from './middleware'\n\nexport type { Permission, UserPermissions } from './middleware'\n\n// Plugins - Week 2 (COMPLETED)\nexport {\n // Hook System - Class implementations\n HookSystemImpl,\n ScopedHookSystem as ScopedHookSystemClass,\n HookUtils,\n // Plugin Registry\n PluginRegistryImpl,\n // Plugin Manager - Class implementation\n PluginManager as PluginManagerClass,\n // Plugin Validator - Class implementation\n PluginValidator as PluginValidatorClass,\n} from './plugins'\n\n// Routes - Week 3 (COMPLETED)\nexport { ROUTES_INFO } from './routes'\n\n// Templates - Week 3 (COMPLETED)\nexport {\n // Form templates\n renderForm,\n renderFormField,\n // Table templates\n renderTable,\n // Pagination templates\n renderPagination,\n // Alert templates\n renderAlert,\n // Confirmation dialog templates\n renderConfirmationDialog,\n getConfirmationDialogScript,\n // Filter bar templates\n renderFilterBar,\n} from './templates'\n\nexport type {\n FormField,\n FormData,\n TableColumn,\n TableData,\n PaginationData,\n AlertData,\n ConfirmationDialogOptions,\n FilterBarData,\n Filter,\n FilterOption,\n} from './templates'\n\n// Types - Week 1 (COMPLETED)\nexport type {\n // Collection types\n FieldType,\n FieldConfig,\n CollectionSchema,\n CollectionConfig,\n CollectionConfigModule,\n CollectionSyncResult,\n // Plugin types\n Plugin,\n PluginContext,\n PluginConfig,\n PluginRoutes,\n PluginMiddleware,\n PluginModel,\n PluginService,\n PluginAdminPage,\n PluginComponent,\n PluginMenuItem,\n PluginHook,\n HookHandler,\n HookContext,\n HookSystem,\n ScopedHookSystem,\n PluginRegistry,\n PluginManager,\n PluginStatus,\n AuthService,\n ContentService,\n MediaService,\n PluginLogger,\n PluginBuilderOptions,\n PluginValidator,\n PluginValidationResult,\n HookName,\n // Plugin manifest\n PluginManifest,\n} from './types'\n\nexport { HOOKS } from './types'\n\n// Utils - Week 1 (COMPLETED)\nexport {\n // Sanitization\n escapeHtml,\n sanitizeInput,\n sanitizeObject,\n // Template rendering\n TemplateRenderer,\n templateRenderer,\n renderTemplate,\n // Query filtering\n QueryFilterBuilder,\n buildQuery,\n // Metrics\n metricsTracker,\n} from './utils'\n\nexport type {\n FilterOperator,\n FilterCondition,\n FilterGroup,\n QueryFilter,\n QueryResult,\n} from './utils'\n\n// Database - Week 1 (COMPLETED)\nexport {\n createDb,\n // Schema exports\n users,\n collections,\n content,\n contentVersions,\n media,\n apiTokens,\n workflowHistory,\n plugins,\n pluginHooks,\n pluginRoutes,\n pluginAssets,\n pluginActivityLog,\n systemLogs,\n logConfig,\n // Zod validation schemas\n insertUserSchema,\n selectUserSchema,\n insertCollectionSchema,\n selectCollectionSchema,\n insertContentSchema,\n selectContentSchema,\n insertMediaSchema,\n selectMediaSchema,\n insertWorkflowHistorySchema,\n selectWorkflowHistorySchema,\n insertPluginSchema,\n selectPluginSchema,\n insertPluginHookSchema,\n selectPluginHookSchema,\n insertPluginRouteSchema,\n selectPluginRouteSchema,\n insertPluginAssetSchema,\n selectPluginAssetSchema,\n insertPluginActivityLogSchema,\n selectPluginActivityLogSchema,\n insertSystemLogSchema,\n selectSystemLogSchema,\n insertLogConfigSchema,\n selectLogConfigSchema,\n} from './db'\n\nexport type {\n User,\n NewUser,\n Collection,\n NewCollection,\n Content,\n NewContent,\n Media,\n NewMedia,\n WorkflowHistory,\n NewWorkflowHistory,\n Plugin as DbPlugin,\n NewPlugin,\n PluginHook as DbPluginHook,\n NewPluginHook,\n PluginRoute,\n NewPluginRoute,\n PluginAsset,\n NewPluginAsset,\n PluginActivityLog,\n NewPluginActivityLog,\n SystemLog,\n NewSystemLog,\n LogConfig,\n NewLogConfig,\n} from './db'\n\n// Plugins - Week 2\n// export { PluginBuilder, HookSystem } from './plugins/sdk'\n\n// ============================================================================\n// Version\n// ============================================================================\n\nexport const VERSION = '2.0.0-alpha.1'\n\n// ============================================================================\n// Phase 2 Migration Notes\n// ============================================================================\n\n/**\n * This is a work-in-progress package being extracted from the main SonicJS codebase.\n *\n * Current Phase: 2 (Core Module Migration)\n * Current Week: 1 (Types, Utils, Database)\n *\n * Expected completion: 4 weeks from 2025-01-17\n *\n * DO NOT USE IN PRODUCTION - Alpha release for development only\n */\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/app.ts","../src/db/index.ts","../src/index.ts"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["/**\n * Main Application Factory\n *\n * Creates a configured SonicJS application with all core functionality\n */\n\nimport { Hono } from 'hono'\nimport type { Context } from 'hono'\nimport type { D1Database, KVNamespace, R2Bucket } from '@cloudflare/workers-types'\nimport { apiRoutes, apiMediaRoutes, apiSystemRoutes, adminApiRoutes, authRoutes, adminContentRoutes, adminUsersRoutes, adminMediaRoutes, adminPluginRoutes, adminLogsRoutes } from './routes'\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\nexport interface Bindings {\n DB: D1Database\n CACHE_KV: KVNamespace\n MEDIA_BUCKET: R2Bucket\n ASSETS: Fetcher\n EMAIL_QUEUE?: Queue\n SENDGRID_API_KEY?: string\n DEFAULT_FROM_EMAIL?: string\n IMAGES_ACCOUNT_ID?: string\n IMAGES_API_TOKEN?: string\n ENVIRONMENT?: string\n BUCKET_NAME?: string\n}\n\nexport interface Variables {\n user?: {\n userId: string\n email: string\n role: string\n exp: number\n iat: number\n }\n requestId?: string\n startTime?: number\n appVersion?: string\n}\n\nexport interface SonicJSConfig {\n // Collections configuration\n collections?: {\n directory?: string\n autoSync?: boolean\n }\n\n // Plugins configuration\n plugins?: {\n directory?: string\n autoLoad?: boolean\n }\n\n // Custom routes\n routes?: Array<{\n path: string\n handler: Hono\n }>\n\n // Custom middleware\n middleware?: {\n beforeAuth?: Array<(c: Context, next: () => Promise<void>) => Promise<void>>\n afterAuth?: Array<(c: Context, next: () => Promise<void>) => Promise<void>>\n }\n\n // App metadata\n version?: string\n name?: string\n}\n\nexport type SonicJSApp = Hono<{ Bindings: Bindings; Variables: Variables }>\n\n// ============================================================================\n// Application Factory\n// ============================================================================\n\n/**\n * Create a SonicJS application with core functionality\n *\n * @param config - Application configuration\n * @returns Configured Hono application\n *\n * @example\n * ```typescript\n * import { createSonicJSApp } from '@sonicjs/core'\n *\n * const app = createSonicJSApp({\n * collections: {\n * directory: './src/collections',\n * autoSync: true\n * },\n * plugins: {\n * directory: './src/plugins',\n * autoLoad: true\n * }\n * })\n *\n * export default app\n * ```\n */\nexport function createSonicJSApp(config: SonicJSConfig = {}): SonicJSApp {\n const app = new Hono<{ Bindings: Bindings; Variables: Variables }>()\n\n // Set app metadata\n const appVersion = config.version || '1.0.0'\n const appName = config.name || 'SonicJS'\n\n // App version middleware\n app.use('*', async (c, next) => {\n c.set('appVersion', appVersion)\n await next()\n })\n\n // Bootstrap middleware\n // Note: Implementation will be imported from middleware/bootstrap\n // This is a placeholder for the factory pattern\n app.use('*', async (_c, next) => {\n // Bootstrap logic here (migrations, collections, plugins)\n await next()\n })\n\n // Custom middleware - before auth\n if (config.middleware?.beforeAuth) {\n for (const middleware of config.middleware.beforeAuth) {\n app.use('*', middleware)\n }\n }\n\n // Logging middleware\n app.use('*', async (_c, next) => {\n // Logging logic here\n await next()\n })\n\n // Security middleware\n app.use('*', async (_c, next) => {\n // Security headers, CORS, etc.\n await next()\n })\n\n // Custom middleware - after auth\n if (config.middleware?.afterAuth) {\n for (const middleware of config.middleware.afterAuth) {\n app.use('*', middleware)\n }\n }\n\n // Core routes\n // Routes are being imported incrementally from routes/*\n // Each route is tested and migrated one-by-one\n app.route('/api', apiRoutes)\n app.route('/api/media', apiMediaRoutes)\n app.route('/api/system', apiSystemRoutes)\n app.route('/admin/api', adminApiRoutes)\n app.route('/admin/content', adminContentRoutes)\n app.route('/admin/media', adminMediaRoutes)\n app.route('/admin/plugins', adminPluginRoutes)\n app.route('/admin/logs', adminLogsRoutes)\n app.route('/admin', adminUsersRoutes)\n app.route('/auth', authRoutes)\n\n // Custom routes - User-defined routes\n if (config.routes) {\n for (const route of config.routes) {\n app.route(route.path, route.handler)\n }\n }\n\n // Root redirect to login\n app.get('/', (c) => {\n return c.redirect('/auth/login')\n })\n\n // Health check\n app.get('/health', (c) => {\n return c.json({\n name: appName,\n version: appVersion,\n status: 'running',\n timestamp: new Date().toISOString()\n })\n })\n\n // 404 handler\n app.notFound((c) => {\n return c.json({ error: 'Not Found', status: 404 }, 404)\n })\n\n // Error handler\n app.onError((err, c) => {\n console.error(err)\n return c.json({ error: 'Internal Server Error', status: 500 }, 500)\n })\n\n return app\n}\n\n/**\n * Setup core middleware (backward compatibility)\n *\n * @param _app - Hono application\n * @deprecated Use createSonicJSApp() instead\n */\nexport function setupCoreMiddleware(_app: SonicJSApp): void {\n console.warn('setupCoreMiddleware is deprecated. Use createSonicJSApp() instead.')\n // Backward compatibility implementation\n}\n\n/**\n * Setup core routes (backward compatibility)\n *\n * @param _app - Hono application\n * @deprecated Use createSonicJSApp() instead\n */\nexport function setupCoreRoutes(_app: SonicJSApp): void {\n console.warn('setupCoreRoutes is deprecated. Use createSonicJSApp() instead.')\n // Backward compatibility implementation\n}\n","import { drizzle } from 'drizzle-orm/d1';\nimport * as schema from './schema';\n\nexport function createDb(d1: D1Database) {\n return drizzle(d1, { schema });\n}\n\nexport * from './schema';","/**\n * @sonicjs/core - Main Entry Point\n *\n * Core framework for SonicJS headless CMS\n * Built for Cloudflare's edge platform with TypeScript\n *\n * Phase 2 Migration Status:\n * - Week 1: Types, Utils, Database (COMPLETED ✓)\n * - Week 2: Services, Middleware, Plugins (COMPLETED ✓)\n * - Week 3: Routes, Templates (COMPLETED ✓)\n * - Week 4: Integration & Testing (COMPLETED ✓)\n *\n * Test Coverage:\n * - Utilities: 48 tests (sanitize, query-filter, metrics)\n * - Middleware: 51 tests (auth, logging, security, performance)\n * - Total: 99 tests passing\n */\n\n// ============================================================================\n// Main Application API (Phase 2 Week 1)\n// ============================================================================\n\nexport { createSonicJSApp, setupCoreMiddleware, setupCoreRoutes } from './app'\nexport type { SonicJSConfig, SonicJSApp, Bindings, Variables } from './app'\n\n// ============================================================================\n// Placeholders - To be populated in Phase 2\n// ============================================================================\n\n// Services - Week 2 (COMPLETED)\nexport {\n // Collection Management\n loadCollectionConfigs,\n loadCollectionConfig,\n getAvailableCollectionNames,\n validateCollectionConfig,\n syncCollections,\n syncCollection,\n isCollectionManaged,\n getManagedCollections,\n cleanupRemovedCollections,\n fullCollectionSync,\n // Database Migrations\n MigrationService,\n // Logging\n Logger,\n getLogger,\n initLogger,\n // Plugin Services - Class implementations\n PluginService as PluginServiceClass,\n PluginBootstrapService,\n} from './services'\n\nexport type { Migration, MigrationStatus, LogLevel, LogCategory, LogEntry, LogFilter, CorePlugin } from './services'\n\n// Middleware - Week 2 (COMPLETED)\nexport {\n // Authentication\n AuthManager,\n requireAuth,\n requireRole,\n optionalAuth,\n // Logging\n loggingMiddleware,\n detailedLoggingMiddleware,\n securityLoggingMiddleware,\n performanceLoggingMiddleware,\n // Performance\n cacheHeaders,\n compressionMiddleware,\n securityHeaders,\n // Permissions\n PermissionManager,\n requirePermission,\n requireAnyPermission,\n logActivity,\n // Plugin middleware\n requireActivePlugin,\n requireActivePlugins,\n getActivePlugins,\n isPluginActive,\n // Bootstrap\n bootstrapMiddleware,\n} from './middleware'\n\nexport type { Permission, UserPermissions } from './middleware'\n\n// Plugins - Week 2 (COMPLETED)\nexport {\n // Hook System - Class implementations\n HookSystemImpl,\n ScopedHookSystem as ScopedHookSystemClass,\n HookUtils,\n // Plugin Registry\n PluginRegistryImpl,\n // Plugin Manager - Class implementation\n PluginManager as PluginManagerClass,\n // Plugin Validator - Class implementation\n PluginValidator as PluginValidatorClass,\n} from './plugins'\n\n// Routes - Week 3 (COMPLETED)\nexport {\n ROUTES_INFO,\n apiRoutes,\n apiMediaRoutes,\n authRoutes,\n adminContentRoutes,\n adminUsersRoutes,\n adminMediaRoutes,\n adminLogsRoutes,\n adminPluginRoutes,\n} from './routes'\n\n// Templates - Week 3 (COMPLETED)\nexport {\n // Form templates\n renderForm,\n renderFormField,\n // Table templates\n renderTable,\n // Pagination templates\n renderPagination,\n // Alert templates\n renderAlert,\n // Confirmation dialog templates\n renderConfirmationDialog,\n getConfirmationDialogScript,\n // Filter bar templates\n renderFilterBar,\n} from './templates'\n\nexport type {\n FormField,\n FormData,\n TableColumn,\n TableData,\n PaginationData,\n AlertData,\n ConfirmationDialogOptions,\n FilterBarData,\n Filter,\n FilterOption,\n} from './templates'\n\n// Types - Week 1 (COMPLETED)\nexport type {\n // Collection types\n FieldType,\n FieldConfig,\n CollectionSchema,\n CollectionConfig,\n CollectionConfigModule,\n CollectionSyncResult,\n // Plugin types\n Plugin,\n PluginContext,\n PluginConfig,\n PluginRoutes,\n PluginMiddleware,\n PluginModel,\n PluginService,\n PluginAdminPage,\n PluginComponent,\n PluginMenuItem,\n PluginHook,\n HookHandler,\n HookContext,\n HookSystem,\n ScopedHookSystem,\n PluginRegistry,\n PluginManager,\n PluginStatus,\n AuthService,\n ContentService,\n MediaService,\n PluginLogger,\n PluginBuilderOptions,\n PluginValidator,\n PluginValidationResult,\n HookName,\n // Plugin manifest\n PluginManifest,\n} from './types'\n\nexport { HOOKS } from './types'\n\n// Utils - Week 1 (COMPLETED)\nexport {\n // Sanitization\n escapeHtml,\n sanitizeInput,\n sanitizeObject,\n // Template rendering\n TemplateRenderer,\n templateRenderer,\n renderTemplate,\n // Query filtering\n QueryFilterBuilder,\n buildQuery,\n // Metrics\n metricsTracker,\n} from './utils'\n\nexport type {\n FilterOperator,\n FilterCondition,\n FilterGroup,\n QueryFilter,\n QueryResult,\n} from './utils'\n\n// Database - Week 1 (COMPLETED)\nexport {\n createDb,\n // Schema exports\n users,\n collections,\n content,\n contentVersions,\n media,\n apiTokens,\n workflowHistory,\n plugins,\n pluginHooks,\n pluginRoutes,\n pluginAssets,\n pluginActivityLog,\n systemLogs,\n logConfig,\n // Zod validation schemas\n insertUserSchema,\n selectUserSchema,\n insertCollectionSchema,\n selectCollectionSchema,\n insertContentSchema,\n selectContentSchema,\n insertMediaSchema,\n selectMediaSchema,\n insertWorkflowHistorySchema,\n selectWorkflowHistorySchema,\n insertPluginSchema,\n selectPluginSchema,\n insertPluginHookSchema,\n selectPluginHookSchema,\n insertPluginRouteSchema,\n selectPluginRouteSchema,\n insertPluginAssetSchema,\n selectPluginAssetSchema,\n insertPluginActivityLogSchema,\n selectPluginActivityLogSchema,\n insertSystemLogSchema,\n selectSystemLogSchema,\n insertLogConfigSchema,\n selectLogConfigSchema,\n} from './db'\n\nexport type {\n User,\n NewUser,\n Collection,\n NewCollection,\n Content,\n NewContent,\n Media,\n NewMedia,\n WorkflowHistory,\n NewWorkflowHistory,\n Plugin as DbPlugin,\n NewPlugin,\n PluginHook as DbPluginHook,\n NewPluginHook,\n PluginRoute,\n NewPluginRoute,\n PluginAsset,\n NewPluginAsset,\n PluginActivityLog,\n NewPluginActivityLog,\n SystemLog,\n NewSystemLog,\n LogConfig,\n NewLogConfig,\n} from './db'\n\n// Plugins - Week 2\n// export { PluginBuilder, HookSystem } from './plugins/sdk'\n\n// ============================================================================\n// Version\n// ============================================================================\n\nexport const VERSION = '2.0.0-alpha.3'\n\n// ============================================================================\n// Phase 2 Migration Notes\n// ============================================================================\n\n/**\n * This is a work-in-progress package being extracted from the main SonicJS codebase.\n *\n * Current Phase: 2 (Core Module Migration)\n * Current Week: 1 (Types, Utils, Database)\n *\n * Expected completion: 4 weeks from 2025-01-17\n *\n * DO NOT USE IN PRODUCTION - Alpha release for development only\n */\n"]}
|
package/dist/middleware.cjs
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkBUKT6HP5_cjs = require('./chunk-BUKT6HP5.cjs');
|
|
4
|
+
require('./chunk-RNR4HA23.cjs');
|
|
5
|
+
require('./chunk-IGJUBJBW.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "AuthManager", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkBUKT6HP5_cjs.AuthManager; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "PermissionManager", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkBUKT6HP5_cjs.PermissionManager; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "bootstrapMiddleware", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkBUKT6HP5_cjs.bootstrapMiddleware; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "cacheHeaders", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkBUKT6HP5_cjs.cacheHeaders; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "compressionMiddleware", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkBUKT6HP5_cjs.compressionMiddleware; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "detailedLoggingMiddleware", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkBUKT6HP5_cjs.detailedLoggingMiddleware; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "getActivePlugins", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkBUKT6HP5_cjs.getActivePlugins; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "isPluginActive", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkBUKT6HP5_cjs.isPluginActive; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "logActivity", {
|
|
42
42
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunkBUKT6HP5_cjs.logActivity; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "loggingMiddleware", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkBUKT6HP5_cjs.loggingMiddleware; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, "optionalAuth", {
|
|
50
50
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunkBUKT6HP5_cjs.optionalAuth; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, "performanceLoggingMiddleware", {
|
|
54
54
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunkBUKT6HP5_cjs.performanceLoggingMiddleware; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "requireActivePlugin", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunkBUKT6HP5_cjs.requireActivePlugin; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, "requireActivePlugins", {
|
|
62
62
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
63
|
+
get: function () { return chunkBUKT6HP5_cjs.requireActivePlugins; }
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(exports, "requireAnyPermission", {
|
|
66
66
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
67
|
+
get: function () { return chunkBUKT6HP5_cjs.requireAnyPermission; }
|
|
68
68
|
});
|
|
69
69
|
Object.defineProperty(exports, "requireAuth", {
|
|
70
70
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
71
|
+
get: function () { return chunkBUKT6HP5_cjs.requireAuth; }
|
|
72
72
|
});
|
|
73
73
|
Object.defineProperty(exports, "requirePermission", {
|
|
74
74
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
75
|
+
get: function () { return chunkBUKT6HP5_cjs.requirePermission; }
|
|
76
76
|
});
|
|
77
77
|
Object.defineProperty(exports, "requireRole", {
|
|
78
78
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
79
|
+
get: function () { return chunkBUKT6HP5_cjs.requireRole; }
|
|
80
80
|
});
|
|
81
81
|
Object.defineProperty(exports, "securityHeaders", {
|
|
82
82
|
enumerable: true,
|
|
83
|
-
get: function () { return
|
|
83
|
+
get: function () { return chunkBUKT6HP5_cjs.securityHeaders; }
|
|
84
84
|
});
|
|
85
85
|
Object.defineProperty(exports, "securityLoggingMiddleware", {
|
|
86
86
|
enumerable: true,
|
|
87
|
-
get: function () { return
|
|
87
|
+
get: function () { return chunkBUKT6HP5_cjs.securityLoggingMiddleware; }
|
|
88
88
|
});
|
|
89
89
|
//# sourceMappingURL=middleware.cjs.map
|
|
90
90
|
//# sourceMappingURL=middleware.cjs.map
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,206 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Bootstrap middleware that ensures system initialization
|
|
200
|
-
* Runs once per worker instance
|
|
201
|
-
*/
|
|
202
|
-
declare function bootstrapMiddleware(): (c: Context<{
|
|
203
|
-
Bindings: Bindings;
|
|
204
|
-
}>, next: Next) => Promise<void>;
|
|
205
|
-
|
|
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 };
|
|
1
|
+
// Middleware exports from core package
|
|
2
|
+
export * from '../src/middleware/index'
|
package/dist/middleware.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AuthManager, PermissionManager, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { AuthManager, PermissionManager, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './chunk-WESS2U3K.js';
|
|
2
|
+
import './chunk-7N3HK7ZK.js';
|
|
3
|
+
import './chunk-V4OQ3NZ2.js';
|
|
4
4
|
//# sourceMappingURL=middleware.js.map
|
|
5
5
|
//# sourceMappingURL=middleware.js.map
|