@sonicjs-cms/core 2.0.0-alpha.2 → 2.0.0-alpha.4
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-5XKH6PBR.js +7026 -0
- package/dist/chunk-5XKH6PBR.js.map +1 -0
- package/dist/chunk-AGOE25LF.cjs +137 -0
- package/dist/chunk-AGOE25LF.cjs.map +1 -0
- package/dist/chunk-B5DU2UAN.cjs +7035 -0
- package/dist/chunk-B5DU2UAN.cjs.map +1 -0
- package/dist/index.cjs +13 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/routes.cjs +34 -2
- package/dist/routes.js +5 -1
- package/dist/services.cjs +13 -1
- package/dist/services.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 +1 -1
- 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-ALTMI5Y2.cjs.map +0 -1
- package/dist/chunk-BOLQHE4J.cjs +0 -11
- package/dist/chunk-BOLQHE4J.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/index.d.ts +0 -136
- package/dist/middleware.d.cts +0 -206
- package/dist/middleware.d.ts +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/plugins.d.ts +0 -330
- package/dist/routes.d.cts +0 -17
- package/dist/routes.d.ts +0 -17
- package/dist/services.d.cts +0 -5
- package/dist/services.d.ts +0 -5
- package/dist/templates.d.cts +0 -140
- package/dist/templates.d.ts +0 -140
- package/dist/types.d.cts +0 -41
- package/dist/types.d.ts +0 -41
- package/dist/utils.d.cts +0 -184
- package/dist/utils.d.ts +0 -184
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
-- Plugin System Tables
|
|
2
|
+
-- Migration: 006_plugin_system
|
|
3
|
+
-- Description: Add plugin management system tables
|
|
4
|
+
|
|
5
|
+
-- Plugins table
|
|
6
|
+
CREATE TABLE IF NOT EXISTS plugins (
|
|
7
|
+
id TEXT PRIMARY KEY,
|
|
8
|
+
name TEXT NOT NULL UNIQUE,
|
|
9
|
+
display_name TEXT NOT NULL,
|
|
10
|
+
description TEXT,
|
|
11
|
+
version TEXT NOT NULL,
|
|
12
|
+
author TEXT NOT NULL,
|
|
13
|
+
category TEXT NOT NULL,
|
|
14
|
+
icon TEXT,
|
|
15
|
+
status TEXT DEFAULT 'inactive' CHECK (status IN ('active', 'inactive', 'error')),
|
|
16
|
+
is_core BOOLEAN DEFAULT FALSE,
|
|
17
|
+
settings JSON,
|
|
18
|
+
permissions JSON,
|
|
19
|
+
dependencies JSON,
|
|
20
|
+
download_count INTEGER DEFAULT 0,
|
|
21
|
+
rating REAL DEFAULT 0,
|
|
22
|
+
installed_at INTEGER NOT NULL,
|
|
23
|
+
activated_at INTEGER,
|
|
24
|
+
last_updated INTEGER NOT NULL,
|
|
25
|
+
error_message TEXT,
|
|
26
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
27
|
+
updated_at INTEGER DEFAULT (unixepoch())
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
-- Plugin hooks table (registered hooks by plugins)
|
|
31
|
+
CREATE TABLE IF NOT EXISTS plugin_hooks (
|
|
32
|
+
id TEXT PRIMARY KEY,
|
|
33
|
+
plugin_id TEXT NOT NULL,
|
|
34
|
+
hook_name TEXT NOT NULL,
|
|
35
|
+
handler_name TEXT NOT NULL,
|
|
36
|
+
priority INTEGER DEFAULT 10,
|
|
37
|
+
is_active BOOLEAN DEFAULT TRUE,
|
|
38
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
39
|
+
FOREIGN KEY (plugin_id) REFERENCES plugins(id) ON DELETE CASCADE,
|
|
40
|
+
UNIQUE(plugin_id, hook_name, handler_name)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
-- Plugin routes table
|
|
44
|
+
CREATE TABLE IF NOT EXISTS plugin_routes (
|
|
45
|
+
id TEXT PRIMARY KEY,
|
|
46
|
+
plugin_id TEXT NOT NULL,
|
|
47
|
+
path TEXT NOT NULL,
|
|
48
|
+
method TEXT NOT NULL,
|
|
49
|
+
handler_name TEXT NOT NULL,
|
|
50
|
+
middleware JSON,
|
|
51
|
+
is_active BOOLEAN DEFAULT TRUE,
|
|
52
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
53
|
+
FOREIGN KEY (plugin_id) REFERENCES plugins(id) ON DELETE CASCADE,
|
|
54
|
+
UNIQUE(plugin_id, path, method)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
-- Plugin assets table (CSS, JS files provided by plugins)
|
|
58
|
+
CREATE TABLE IF NOT EXISTS plugin_assets (
|
|
59
|
+
id TEXT PRIMARY KEY,
|
|
60
|
+
plugin_id TEXT NOT NULL,
|
|
61
|
+
asset_type TEXT NOT NULL CHECK (asset_type IN ('css', 'js', 'image', 'font')),
|
|
62
|
+
asset_path TEXT NOT NULL,
|
|
63
|
+
load_order INTEGER DEFAULT 100,
|
|
64
|
+
load_location TEXT DEFAULT 'footer' CHECK (load_location IN ('header', 'footer')),
|
|
65
|
+
is_active BOOLEAN DEFAULT TRUE,
|
|
66
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
67
|
+
FOREIGN KEY (plugin_id) REFERENCES plugins(id) ON DELETE CASCADE
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
-- Plugin activity log
|
|
71
|
+
CREATE TABLE IF NOT EXISTS plugin_activity_log (
|
|
72
|
+
id TEXT PRIMARY KEY,
|
|
73
|
+
plugin_id TEXT NOT NULL,
|
|
74
|
+
action TEXT NOT NULL,
|
|
75
|
+
user_id TEXT,
|
|
76
|
+
details JSON,
|
|
77
|
+
timestamp INTEGER DEFAULT (unixepoch()),
|
|
78
|
+
FOREIGN KEY (plugin_id) REFERENCES plugins(id) ON DELETE CASCADE
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
-- Create indexes
|
|
82
|
+
CREATE INDEX IF NOT EXISTS idx_plugins_status ON plugins(status);
|
|
83
|
+
CREATE INDEX IF NOT EXISTS idx_plugins_category ON plugins(category);
|
|
84
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_hooks_plugin ON plugin_hooks(plugin_id);
|
|
85
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_routes_plugin ON plugin_routes(plugin_id);
|
|
86
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_assets_plugin ON plugin_assets(plugin_id);
|
|
87
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_activity_plugin ON plugin_activity_log(plugin_id);
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_activity_timestamp ON plugin_activity_log(timestamp);
|
|
89
|
+
|
|
90
|
+
-- Insert core plugins
|
|
91
|
+
INSERT INTO plugins (
|
|
92
|
+
id, name, display_name, description, version, author, category, icon,
|
|
93
|
+
status, is_core, permissions, installed_at, last_updated
|
|
94
|
+
) VALUES
|
|
95
|
+
(
|
|
96
|
+
'core-auth',
|
|
97
|
+
'core-auth',
|
|
98
|
+
'Authentication System',
|
|
99
|
+
'Core authentication and user management system',
|
|
100
|
+
'1.0.0',
|
|
101
|
+
'SonicJS Team',
|
|
102
|
+
'security',
|
|
103
|
+
'🔐',
|
|
104
|
+
'active',
|
|
105
|
+
TRUE,
|
|
106
|
+
'["manage:users", "manage:roles", "manage:permissions"]',
|
|
107
|
+
unixepoch(),
|
|
108
|
+
unixepoch()
|
|
109
|
+
),
|
|
110
|
+
(
|
|
111
|
+
'core-media',
|
|
112
|
+
'core-media',
|
|
113
|
+
'Media Manager',
|
|
114
|
+
'Core media upload and management system',
|
|
115
|
+
'1.0.0',
|
|
116
|
+
'SonicJS Team',
|
|
117
|
+
'media',
|
|
118
|
+
'📸',
|
|
119
|
+
'active',
|
|
120
|
+
TRUE,
|
|
121
|
+
'["manage:media", "upload:files"]',
|
|
122
|
+
unixepoch(),
|
|
123
|
+
unixepoch()
|
|
124
|
+
),
|
|
125
|
+
(
|
|
126
|
+
'core-workflow',
|
|
127
|
+
'core-workflow',
|
|
128
|
+
'Workflow Engine',
|
|
129
|
+
'Content workflow and approval system',
|
|
130
|
+
'1.0.0',
|
|
131
|
+
'SonicJS Team',
|
|
132
|
+
'content',
|
|
133
|
+
'🔄',
|
|
134
|
+
'active',
|
|
135
|
+
TRUE,
|
|
136
|
+
'["manage:workflows", "approve:content"]',
|
|
137
|
+
unixepoch(),
|
|
138
|
+
unixepoch()
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
-- FAQ Plugin will be added as a third-party plugin through the admin interface
|
|
142
|
+
|
|
143
|
+
-- Add plugin management permission
|
|
144
|
+
INSERT OR IGNORE INTO permissions (id, name, description, category, created_at)
|
|
145
|
+
VALUES (
|
|
146
|
+
'manage:plugins',
|
|
147
|
+
'Manage Plugins',
|
|
148
|
+
'Install, uninstall, activate, and configure plugins',
|
|
149
|
+
'system',
|
|
150
|
+
unixepoch()
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
-- Grant plugin management permission to admin role
|
|
154
|
+
INSERT OR IGNORE INTO role_permissions (id, role, permission_id, created_at)
|
|
155
|
+
VALUES ('role-perm-manage-plugins', 'admin', 'manage:plugins', unixepoch());
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- Demo Login Plugin Migration
|
|
2
|
+
-- Migration: 007_demo_login_plugin
|
|
3
|
+
-- Description: Add demo login prefill plugin to the plugin registry
|
|
4
|
+
|
|
5
|
+
-- Insert demo login plugin
|
|
6
|
+
INSERT INTO plugins (
|
|
7
|
+
id, name, display_name, description, version, author, category, icon,
|
|
8
|
+
status, is_core, permissions, installed_at, last_updated
|
|
9
|
+
) VALUES (
|
|
10
|
+
'demo-login-prefill',
|
|
11
|
+
'demo-login-plugin',
|
|
12
|
+
'Demo Login Prefill',
|
|
13
|
+
'Prefills login form with demo credentials (admin@sonicjs.com/admin123) for easy site demonstration',
|
|
14
|
+
'1.0.0',
|
|
15
|
+
'SonicJS',
|
|
16
|
+
'demo',
|
|
17
|
+
'🎯',
|
|
18
|
+
'inactive',
|
|
19
|
+
TRUE,
|
|
20
|
+
'[]',
|
|
21
|
+
unixepoch(),
|
|
22
|
+
unixepoch()
|
|
23
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- Migration: Fix overly restrictive slug validation patterns
|
|
2
|
+
-- This migration relaxes the slug field validation to be more user-friendly
|
|
3
|
+
|
|
4
|
+
-- Update the pages collection slug field to allow underscores and be less restrictive
|
|
5
|
+
UPDATE content_fields
|
|
6
|
+
SET field_options = '{"pattern": "^[a-zA-Z0-9_-]+$", "placeholder": "url-friendly-slug", "help": "Use letters, numbers, underscores, and hyphens only"}'
|
|
7
|
+
WHERE field_name = 'slug' AND collection_id = 'pages-collection';
|
|
8
|
+
|
|
9
|
+
-- Update blog posts slug field if it exists
|
|
10
|
+
UPDATE content_fields
|
|
11
|
+
SET field_options = '{"pattern": "^[a-zA-Z0-9_-]+$", "placeholder": "url-friendly-slug", "help": "Use letters, numbers, underscores, and hyphens only"}'
|
|
12
|
+
WHERE field_name = 'slug' AND collection_id = 'blog-posts-collection';
|
|
13
|
+
|
|
14
|
+
-- Update news slug field if it exists
|
|
15
|
+
UPDATE content_fields
|
|
16
|
+
SET field_options = '{"pattern": "^[a-zA-Z0-9_-]+$", "placeholder": "url-friendly-slug", "help": "Use letters, numbers, underscores, and hyphens only"}'
|
|
17
|
+
WHERE field_name = 'slug' AND collection_id = 'news-collection';
|
|
18
|
+
|
|
19
|
+
-- Update any other slug fields with the restrictive pattern
|
|
20
|
+
UPDATE content_fields
|
|
21
|
+
SET field_options = REPLACE(field_options, '"pattern": "^[a-z0-9-]+$"', '"pattern": "^[a-zA-Z0-9_-]+$"')
|
|
22
|
+
WHERE field_options LIKE '%"pattern": "^[a-z0-9-]+$"%';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
-- System Logging Tables
|
|
2
|
+
-- Migration: 009_system_logging
|
|
3
|
+
-- Description: Add system logging and configuration tables
|
|
4
|
+
|
|
5
|
+
-- System logs table for tracking application events
|
|
6
|
+
CREATE TABLE IF NOT EXISTS system_logs (
|
|
7
|
+
id TEXT PRIMARY KEY,
|
|
8
|
+
level TEXT NOT NULL CHECK (level IN ('debug', 'info', 'warn', 'error', 'fatal')),
|
|
9
|
+
category TEXT NOT NULL CHECK (category IN ('auth', 'api', 'workflow', 'plugin', 'media', 'system', 'security', 'error')),
|
|
10
|
+
message TEXT NOT NULL,
|
|
11
|
+
data TEXT, -- JSON data
|
|
12
|
+
user_id TEXT,
|
|
13
|
+
session_id TEXT,
|
|
14
|
+
request_id TEXT,
|
|
15
|
+
ip_address TEXT,
|
|
16
|
+
user_agent TEXT,
|
|
17
|
+
method TEXT,
|
|
18
|
+
url TEXT,
|
|
19
|
+
status_code INTEGER,
|
|
20
|
+
duration INTEGER, -- milliseconds
|
|
21
|
+
stack_trace TEXT,
|
|
22
|
+
tags TEXT, -- JSON array
|
|
23
|
+
source TEXT, -- source of the log entry
|
|
24
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
25
|
+
FOREIGN KEY (user_id) REFERENCES users(id)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
-- Log configuration table for managing log settings per category
|
|
29
|
+
CREATE TABLE IF NOT EXISTS log_config (
|
|
30
|
+
id TEXT PRIMARY KEY,
|
|
31
|
+
category TEXT NOT NULL UNIQUE CHECK (category IN ('auth', 'api', 'workflow', 'plugin', 'media', 'system', 'security', 'error')),
|
|
32
|
+
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
|
33
|
+
level TEXT NOT NULL DEFAULT 'info' CHECK (level IN ('debug', 'info', 'warn', 'error', 'fatal')),
|
|
34
|
+
retention_days INTEGER NOT NULL DEFAULT 30,
|
|
35
|
+
max_size_mb INTEGER NOT NULL DEFAULT 100,
|
|
36
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
37
|
+
updated_at INTEGER NOT NULL DEFAULT (unixepoch())
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
-- Create indexes for better performance
|
|
41
|
+
CREATE INDEX IF NOT EXISTS idx_system_logs_level ON system_logs(level);
|
|
42
|
+
CREATE INDEX IF NOT EXISTS idx_system_logs_category ON system_logs(category);
|
|
43
|
+
CREATE INDEX IF NOT EXISTS idx_system_logs_created_at ON system_logs(created_at);
|
|
44
|
+
CREATE INDEX IF NOT EXISTS idx_system_logs_user_id ON system_logs(user_id);
|
|
45
|
+
CREATE INDEX IF NOT EXISTS idx_system_logs_status_code ON system_logs(status_code);
|
|
46
|
+
CREATE INDEX IF NOT EXISTS idx_system_logs_source ON system_logs(source);
|
|
47
|
+
|
|
48
|
+
-- Insert default log configurations
|
|
49
|
+
INSERT OR IGNORE INTO log_config (id, category, enabled, level, retention_days, max_size_mb) VALUES
|
|
50
|
+
('log-config-auth', 'auth', TRUE, 'info', 90, 50),
|
|
51
|
+
('log-config-api', 'api', TRUE, 'info', 30, 100),
|
|
52
|
+
('log-config-workflow', 'workflow', TRUE, 'info', 60, 50),
|
|
53
|
+
('log-config-plugin', 'plugin', TRUE, 'warn', 30, 25),
|
|
54
|
+
('log-config-media', 'media', TRUE, 'info', 30, 50),
|
|
55
|
+
('log-config-system', 'system', TRUE, 'info', 90, 100),
|
|
56
|
+
('log-config-security', 'security', TRUE, 'warn', 180, 100),
|
|
57
|
+
('log-config-error', 'error', TRUE, 'error', 90, 200);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Migration: Add Config-Managed Collections Support
|
|
2
|
+
-- Description: Add 'managed' column to collections table to support config-based collection definitions
|
|
3
|
+
-- Created: 2025-10-03
|
|
4
|
+
|
|
5
|
+
-- Add 'managed' column to collections table
|
|
6
|
+
-- This column indicates whether a collection is managed by configuration files (true) or user-created (false)
|
|
7
|
+
-- Managed collections cannot be edited through the admin UI
|
|
8
|
+
ALTER TABLE collections ADD COLUMN managed INTEGER DEFAULT 0 NOT NULL;
|
|
9
|
+
|
|
10
|
+
-- Create an index on the managed column for faster queries
|
|
11
|
+
CREATE INDEX IF NOT EXISTS idx_collections_managed ON collections(managed);
|
|
12
|
+
|
|
13
|
+
-- Create an index on managed + is_active for efficient filtering
|
|
14
|
+
CREATE INDEX IF NOT EXISTS idx_collections_managed_active ON collections(managed, is_active);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
-- Testimonials Plugin Migration
|
|
2
|
+
-- Creates testimonials table for the testimonials plugin
|
|
3
|
+
-- This demonstrates a code-based collection defined in src/plugins/core-plugins/testimonials-plugin.ts
|
|
4
|
+
|
|
5
|
+
CREATE TABLE IF NOT EXISTS testimonials (
|
|
6
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
7
|
+
author_name TEXT NOT NULL,
|
|
8
|
+
author_title TEXT,
|
|
9
|
+
author_company TEXT,
|
|
10
|
+
testimonial_text TEXT NOT NULL,
|
|
11
|
+
rating INTEGER CHECK(rating >= 1 AND rating <= 5),
|
|
12
|
+
isPublished INTEGER NOT NULL DEFAULT 1,
|
|
13
|
+
sortOrder INTEGER NOT NULL DEFAULT 0,
|
|
14
|
+
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
|
|
15
|
+
updated_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
-- Create indexes for better performance
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_testimonials_published ON testimonials(isPublished);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_testimonials_sort_order ON testimonials(sortOrder);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS idx_testimonials_rating ON testimonials(rating);
|
|
22
|
+
|
|
23
|
+
-- Create trigger to update updated_at timestamp
|
|
24
|
+
CREATE TRIGGER IF NOT EXISTS testimonials_updated_at
|
|
25
|
+
AFTER UPDATE ON testimonials
|
|
26
|
+
BEGIN
|
|
27
|
+
UPDATE testimonials SET updated_at = strftime('%s', 'now') WHERE id = NEW.id;
|
|
28
|
+
END;
|
|
29
|
+
|
|
30
|
+
-- Insert plugin record
|
|
31
|
+
INSERT OR IGNORE INTO plugins (name, display_name, description, version, status, category, settings) VALUES
|
|
32
|
+
('testimonials',
|
|
33
|
+
'Customer Testimonials',
|
|
34
|
+
'Manage customer testimonials and reviews with rating support. This is a code-based collection example.',
|
|
35
|
+
'1.0.0',
|
|
36
|
+
'active',
|
|
37
|
+
'content',
|
|
38
|
+
'{"defaultPublished": true, "requireRating": false}');
|
|
39
|
+
|
|
40
|
+
-- Insert sample testimonial data
|
|
41
|
+
INSERT OR IGNORE INTO testimonials (author_name, author_title, author_company, testimonial_text, rating, isPublished, sortOrder) VALUES
|
|
42
|
+
('Jane Smith',
|
|
43
|
+
'CTO',
|
|
44
|
+
'TechStartup Inc',
|
|
45
|
+
'SonicJS AI has transformed how we manage our content. The plugin architecture is brilliant and the edge deployment is blazing fast.',
|
|
46
|
+
5,
|
|
47
|
+
1,
|
|
48
|
+
1),
|
|
49
|
+
|
|
50
|
+
('Michael Chen',
|
|
51
|
+
'Lead Developer',
|
|
52
|
+
'Digital Agency Co',
|
|
53
|
+
'We migrated from WordPress to SonicJS AI and couldn''t be happier. The TypeScript-first approach and modern tooling make development a joy.',
|
|
54
|
+
5,
|
|
55
|
+
1,
|
|
56
|
+
2),
|
|
57
|
+
|
|
58
|
+
('Sarah Johnson',
|
|
59
|
+
'Product Manager',
|
|
60
|
+
'E-commerce Solutions',
|
|
61
|
+
'The headless CMS approach combined with Cloudflare Workers gives us unmatched performance. Our content is served globally with minimal latency.',
|
|
62
|
+
4,
|
|
63
|
+
1,
|
|
64
|
+
3),
|
|
65
|
+
|
|
66
|
+
('David Rodriguez',
|
|
67
|
+
'Full Stack Developer',
|
|
68
|
+
'Creative Studio',
|
|
69
|
+
'Great CMS for modern web applications. The admin interface is clean and the API is well-designed. Plugin system is very flexible.',
|
|
70
|
+
5,
|
|
71
|
+
1,
|
|
72
|
+
4),
|
|
73
|
+
|
|
74
|
+
('Emily Watson',
|
|
75
|
+
'Technical Director',
|
|
76
|
+
'Media Company',
|
|
77
|
+
'SonicJS AI solved our content distribution challenges. The R2 integration for media storage works flawlessly and scales effortlessly.',
|
|
78
|
+
4,
|
|
79
|
+
1,
|
|
80
|
+
5);
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
-- Code Examples Plugin Migration
|
|
2
|
+
-- Creates code_examples table for the code examples plugin
|
|
3
|
+
-- This demonstrates a code-based collection for storing and managing code snippets
|
|
4
|
+
|
|
5
|
+
CREATE TABLE IF NOT EXISTS code_examples (
|
|
6
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
7
|
+
title TEXT NOT NULL,
|
|
8
|
+
description TEXT,
|
|
9
|
+
code TEXT NOT NULL,
|
|
10
|
+
language TEXT NOT NULL,
|
|
11
|
+
category TEXT,
|
|
12
|
+
tags TEXT,
|
|
13
|
+
isPublished INTEGER NOT NULL DEFAULT 1,
|
|
14
|
+
sortOrder INTEGER NOT NULL DEFAULT 0,
|
|
15
|
+
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
|
|
16
|
+
updated_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
-- Create indexes for better performance
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_code_examples_published ON code_examples(isPublished);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS idx_code_examples_sort_order ON code_examples(sortOrder);
|
|
22
|
+
CREATE INDEX IF NOT EXISTS idx_code_examples_language ON code_examples(language);
|
|
23
|
+
CREATE INDEX IF NOT EXISTS idx_code_examples_category ON code_examples(category);
|
|
24
|
+
|
|
25
|
+
-- Create trigger to update updated_at timestamp
|
|
26
|
+
CREATE TRIGGER IF NOT EXISTS code_examples_updated_at
|
|
27
|
+
AFTER UPDATE ON code_examples
|
|
28
|
+
BEGIN
|
|
29
|
+
UPDATE code_examples SET updated_at = strftime('%s', 'now') WHERE id = NEW.id;
|
|
30
|
+
END;
|
|
31
|
+
|
|
32
|
+
-- Insert plugin record
|
|
33
|
+
INSERT OR IGNORE INTO plugins (name, display_name, description, version, status, category, settings) VALUES
|
|
34
|
+
('code-examples',
|
|
35
|
+
'Code Examples',
|
|
36
|
+
'Manage code snippets and examples with syntax highlighting support. Perfect for documentation and tutorials.',
|
|
37
|
+
'1.0.0',
|
|
38
|
+
'active',
|
|
39
|
+
'content',
|
|
40
|
+
'{"defaultPublished": true, "supportedLanguages": ["javascript", "typescript", "python", "go", "rust", "java", "php", "ruby", "sql"]}');
|
|
41
|
+
|
|
42
|
+
-- Insert sample code examples
|
|
43
|
+
INSERT OR IGNORE INTO code_examples (title, description, code, language, category, tags, isPublished, sortOrder) VALUES
|
|
44
|
+
('React useState Hook',
|
|
45
|
+
'Basic example of using the useState hook in React for managing component state.',
|
|
46
|
+
'import { useState } from ''react'';
|
|
47
|
+
|
|
48
|
+
function Counter() {
|
|
49
|
+
const [count, setCount] = useState(0);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div>
|
|
53
|
+
<p>Count: {count}</p>
|
|
54
|
+
<button onClick={() => setCount(count + 1)}>
|
|
55
|
+
Increment
|
|
56
|
+
</button>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default Counter;',
|
|
62
|
+
'javascript',
|
|
63
|
+
'frontend',
|
|
64
|
+
'react,hooks,state',
|
|
65
|
+
1,
|
|
66
|
+
1),
|
|
67
|
+
|
|
68
|
+
('TypeScript Interface Example',
|
|
69
|
+
'Defining a TypeScript interface for type-safe objects.',
|
|
70
|
+
'interface User {
|
|
71
|
+
id: string;
|
|
72
|
+
email: string;
|
|
73
|
+
name: string;
|
|
74
|
+
role: ''admin'' | ''editor'' | ''viewer'';
|
|
75
|
+
createdAt: Date;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function greetUser(user: User): string {
|
|
79
|
+
return `Hello, ${user.name}!`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const user: User = {
|
|
83
|
+
id: ''123'',
|
|
84
|
+
email: ''user@example.com'',
|
|
85
|
+
name: ''John Doe'',
|
|
86
|
+
role: ''admin'',
|
|
87
|
+
createdAt: new Date()
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
console.log(greetUser(user));',
|
|
91
|
+
'typescript',
|
|
92
|
+
'backend',
|
|
93
|
+
'typescript,types,interface',
|
|
94
|
+
1,
|
|
95
|
+
2),
|
|
96
|
+
|
|
97
|
+
('Python List Comprehension',
|
|
98
|
+
'Elegant way to create lists in Python using list comprehensions.',
|
|
99
|
+
'# Basic list comprehension
|
|
100
|
+
squares = [x**2 for x in range(10)]
|
|
101
|
+
print(squares) # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
|
102
|
+
|
|
103
|
+
# With condition
|
|
104
|
+
even_squares = [x**2 for x in range(10) if x % 2 == 0]
|
|
105
|
+
print(even_squares) # [0, 4, 16, 36, 64]
|
|
106
|
+
|
|
107
|
+
# Nested list comprehension
|
|
108
|
+
matrix = [[i+j for j in range(3)] for i in range(3)]
|
|
109
|
+
print(matrix) # [[0, 1, 2], [1, 2, 3], [2, 3, 4]]',
|
|
110
|
+
'python',
|
|
111
|
+
'general',
|
|
112
|
+
'python,lists,comprehension',
|
|
113
|
+
1,
|
|
114
|
+
3),
|
|
115
|
+
|
|
116
|
+
('SQL Join Example',
|
|
117
|
+
'Common SQL JOIN patterns for combining data from multiple tables.',
|
|
118
|
+
'-- INNER JOIN: Returns only matching rows
|
|
119
|
+
SELECT users.name, orders.total
|
|
120
|
+
FROM users
|
|
121
|
+
INNER JOIN orders ON users.id = orders.user_id;
|
|
122
|
+
|
|
123
|
+
-- LEFT JOIN: Returns all users, even without orders
|
|
124
|
+
SELECT users.name, orders.total
|
|
125
|
+
FROM users
|
|
126
|
+
LEFT JOIN orders ON users.id = orders.user_id;
|
|
127
|
+
|
|
128
|
+
-- Multiple JOINs
|
|
129
|
+
SELECT
|
|
130
|
+
users.name,
|
|
131
|
+
orders.order_date,
|
|
132
|
+
products.name AS product_name
|
|
133
|
+
FROM users
|
|
134
|
+
INNER JOIN orders ON users.id = orders.user_id
|
|
135
|
+
INNER JOIN order_items ON orders.id = order_items.order_id
|
|
136
|
+
INNER JOIN products ON order_items.product_id = products.id;',
|
|
137
|
+
'sql',
|
|
138
|
+
'database',
|
|
139
|
+
'sql,joins,queries',
|
|
140
|
+
1,
|
|
141
|
+
4),
|
|
142
|
+
|
|
143
|
+
('Go Error Handling',
|
|
144
|
+
'Idiomatic error handling pattern in Go.',
|
|
145
|
+
'package main
|
|
146
|
+
|
|
147
|
+
import (
|
|
148
|
+
"errors"
|
|
149
|
+
"fmt"
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
func divide(a, b float64) (float64, error) {
|
|
153
|
+
if b == 0 {
|
|
154
|
+
return 0, errors.New("division by zero")
|
|
155
|
+
}
|
|
156
|
+
return a / b, nil
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
func main() {
|
|
160
|
+
result, err := divide(10, 2)
|
|
161
|
+
if err != nil {
|
|
162
|
+
fmt.Println("Error:", err)
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
fmt.Printf("Result: %.2f\n", result)
|
|
166
|
+
|
|
167
|
+
// This will error
|
|
168
|
+
_, err = divide(10, 0)
|
|
169
|
+
if err != nil {
|
|
170
|
+
fmt.Println("Error:", err)
|
|
171
|
+
}
|
|
172
|
+
}',
|
|
173
|
+
'go',
|
|
174
|
+
'backend',
|
|
175
|
+
'go,error-handling,functions',
|
|
176
|
+
1,
|
|
177
|
+
5);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
-- Fix Plugin Registry
|
|
2
|
+
-- Migration: 014_fix_plugin_registry
|
|
3
|
+
-- Description: Add missing plugins and fix plugin name mismatches
|
|
4
|
+
|
|
5
|
+
-- Note: Cannot easily update plugin names as they may be referenced elsewhere
|
|
6
|
+
-- Instead we'll add the missing plugins with correct names
|
|
7
|
+
|
|
8
|
+
-- Insert missing plugins
|
|
9
|
+
|
|
10
|
+
-- Core Analytics Plugin
|
|
11
|
+
INSERT OR IGNORE INTO plugins (
|
|
12
|
+
id, name, display_name, description, version, author, category, icon,
|
|
13
|
+
status, is_core, permissions, installed_at, last_updated
|
|
14
|
+
) VALUES (
|
|
15
|
+
'core-analytics',
|
|
16
|
+
'core-analytics',
|
|
17
|
+
'Analytics & Tracking',
|
|
18
|
+
'Core analytics tracking and reporting plugin with page views and event tracking',
|
|
19
|
+
'1.0.0',
|
|
20
|
+
'SonicJS Team',
|
|
21
|
+
'analytics',
|
|
22
|
+
'📊',
|
|
23
|
+
'active',
|
|
24
|
+
TRUE,
|
|
25
|
+
'["view:analytics", "manage:tracking"]',
|
|
26
|
+
unixepoch(),
|
|
27
|
+
unixepoch()
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
-- FAQ Plugin
|
|
31
|
+
INSERT OR IGNORE INTO plugins (
|
|
32
|
+
id, name, display_name, description, version, author, category, icon,
|
|
33
|
+
status, is_core, permissions, installed_at, last_updated
|
|
34
|
+
) VALUES (
|
|
35
|
+
'faq-plugin',
|
|
36
|
+
'faq-plugin',
|
|
37
|
+
'FAQ Management',
|
|
38
|
+
'Frequently Asked Questions management plugin with categories, search, and custom styling',
|
|
39
|
+
'1.0.0',
|
|
40
|
+
'SonicJS',
|
|
41
|
+
'content',
|
|
42
|
+
'❓',
|
|
43
|
+
'active',
|
|
44
|
+
FALSE,
|
|
45
|
+
'["manage:faqs"]',
|
|
46
|
+
unixepoch(),
|
|
47
|
+
unixepoch()
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
-- Seed Data Plugin
|
|
51
|
+
INSERT OR IGNORE INTO plugins (
|
|
52
|
+
id, name, display_name, description, version, author, category, icon,
|
|
53
|
+
status, is_core, permissions, installed_at, last_updated
|
|
54
|
+
) VALUES (
|
|
55
|
+
'seed-data',
|
|
56
|
+
'seed-data',
|
|
57
|
+
'Seed Data Generator',
|
|
58
|
+
'Generate realistic example users and content for testing and development',
|
|
59
|
+
'1.0.0',
|
|
60
|
+
'SonicJS Team',
|
|
61
|
+
'development',
|
|
62
|
+
'🌱',
|
|
63
|
+
'inactive',
|
|
64
|
+
FALSE,
|
|
65
|
+
'["admin"]',
|
|
66
|
+
unixepoch(),
|
|
67
|
+
unixepoch()
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
-- Database Tools Plugin
|
|
71
|
+
INSERT OR IGNORE INTO plugins (
|
|
72
|
+
id, name, display_name, description, version, author, category, icon,
|
|
73
|
+
status, is_core, permissions, installed_at, last_updated
|
|
74
|
+
) VALUES (
|
|
75
|
+
'database-tools',
|
|
76
|
+
'database-tools',
|
|
77
|
+
'Database Tools',
|
|
78
|
+
'Database management tools including truncate, backup, and validation',
|
|
79
|
+
'1.0.0',
|
|
80
|
+
'SonicJS Team',
|
|
81
|
+
'system',
|
|
82
|
+
'🗄️',
|
|
83
|
+
'active',
|
|
84
|
+
FALSE,
|
|
85
|
+
'["manage:database", "admin"]',
|
|
86
|
+
unixepoch(),
|
|
87
|
+
unixepoch()
|
|
88
|
+
);
|