@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/templates.d.ts
CHANGED
|
@@ -1,140 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
label: string;
|
|
4
|
-
type: 'text' | 'email' | 'textarea' | 'select' | 'checkbox' | 'rich_text' | 'number' | 'date' | 'multi_select' | 'file';
|
|
5
|
-
value?: any;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
readonly?: boolean;
|
|
9
|
-
helpText?: string;
|
|
10
|
-
options?: Array<{
|
|
11
|
-
value: string;
|
|
12
|
-
label: string;
|
|
13
|
-
selected?: boolean;
|
|
14
|
-
}>;
|
|
15
|
-
rows?: number;
|
|
16
|
-
className?: string;
|
|
17
|
-
validation?: {
|
|
18
|
-
min?: number;
|
|
19
|
-
max?: number;
|
|
20
|
-
pattern?: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
interface FormData {
|
|
24
|
-
id?: string;
|
|
25
|
-
action?: string;
|
|
26
|
-
method?: string;
|
|
27
|
-
hxPost?: string;
|
|
28
|
-
hxPut?: string;
|
|
29
|
-
hxTarget?: string;
|
|
30
|
-
fields: FormField[];
|
|
31
|
-
submitButtons: Array<{
|
|
32
|
-
label: string;
|
|
33
|
-
type?: 'submit' | 'button';
|
|
34
|
-
value?: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
className?: string;
|
|
37
|
-
onclick?: string;
|
|
38
|
-
}>;
|
|
39
|
-
title?: string;
|
|
40
|
-
description?: string;
|
|
41
|
-
className?: string;
|
|
42
|
-
}
|
|
43
|
-
declare function renderForm(data: FormData): string;
|
|
44
|
-
declare function renderFormField(field: FormField): string;
|
|
45
|
-
|
|
46
|
-
interface TableColumn {
|
|
47
|
-
key: string;
|
|
48
|
-
label: string;
|
|
49
|
-
sortable?: boolean;
|
|
50
|
-
className?: string;
|
|
51
|
-
sortType?: 'string' | 'number' | 'date' | 'boolean';
|
|
52
|
-
render?: (value: any, row: any) => string;
|
|
53
|
-
}
|
|
54
|
-
interface TableData<T = any> {
|
|
55
|
-
columns: TableColumn[];
|
|
56
|
-
rows: T[];
|
|
57
|
-
selectable?: boolean;
|
|
58
|
-
className?: string;
|
|
59
|
-
emptyMessage?: string;
|
|
60
|
-
tableId?: string;
|
|
61
|
-
title?: string;
|
|
62
|
-
rowClickable?: boolean;
|
|
63
|
-
rowClickUrl?: (row: T) => string;
|
|
64
|
-
}
|
|
65
|
-
declare function renderTable<T = any>(data: TableData<T>): string;
|
|
66
|
-
|
|
67
|
-
interface PaginationData {
|
|
68
|
-
currentPage: number;
|
|
69
|
-
totalPages: number;
|
|
70
|
-
totalItems: number;
|
|
71
|
-
itemsPerPage: number;
|
|
72
|
-
startItem: number;
|
|
73
|
-
endItem: number;
|
|
74
|
-
baseUrl: string;
|
|
75
|
-
queryParams?: Record<string, string>;
|
|
76
|
-
showPageNumbers?: boolean;
|
|
77
|
-
maxPageNumbers?: number;
|
|
78
|
-
showPageSizeSelector?: boolean;
|
|
79
|
-
pageSizeOptions?: number[];
|
|
80
|
-
}
|
|
81
|
-
declare function renderPagination(data: PaginationData): string;
|
|
82
|
-
|
|
83
|
-
type AlertType = 'success' | 'error' | 'warning' | 'info';
|
|
84
|
-
interface AlertData {
|
|
85
|
-
type: AlertType;
|
|
86
|
-
title?: string;
|
|
87
|
-
message: string;
|
|
88
|
-
dismissible?: boolean;
|
|
89
|
-
className?: string;
|
|
90
|
-
icon?: boolean;
|
|
91
|
-
}
|
|
92
|
-
declare function renderAlert(data: AlertData): string;
|
|
93
|
-
|
|
94
|
-
interface ConfirmationDialogOptions {
|
|
95
|
-
id: string;
|
|
96
|
-
title: string;
|
|
97
|
-
message: string;
|
|
98
|
-
confirmText?: string;
|
|
99
|
-
cancelText?: string;
|
|
100
|
-
confirmClass?: string;
|
|
101
|
-
iconColor?: 'red' | 'yellow' | 'blue';
|
|
102
|
-
onConfirm?: string;
|
|
103
|
-
}
|
|
104
|
-
declare function renderConfirmationDialog(options: ConfirmationDialogOptions): string;
|
|
105
|
-
/**
|
|
106
|
-
* Helper function to show a confirmation dialog programmatically
|
|
107
|
-
* Usage in templates: Add this script and call showConfirmDialog()
|
|
108
|
-
*/
|
|
109
|
-
declare function getConfirmationDialogScript(): string;
|
|
110
|
-
|
|
111
|
-
interface FilterOption {
|
|
112
|
-
value: string;
|
|
113
|
-
label: string;
|
|
114
|
-
selected?: boolean;
|
|
115
|
-
color?: string;
|
|
116
|
-
}
|
|
117
|
-
interface Filter {
|
|
118
|
-
name: string;
|
|
119
|
-
label: string;
|
|
120
|
-
options: FilterOption[];
|
|
121
|
-
}
|
|
122
|
-
interface FilterBarData {
|
|
123
|
-
filters: Filter[];
|
|
124
|
-
actions?: Array<{
|
|
125
|
-
label: string;
|
|
126
|
-
className?: string;
|
|
127
|
-
onclick?: string;
|
|
128
|
-
hxGet?: string;
|
|
129
|
-
hxTarget?: string;
|
|
130
|
-
}>;
|
|
131
|
-
bulkActions?: Array<{
|
|
132
|
-
label: string;
|
|
133
|
-
value: string;
|
|
134
|
-
icon?: string;
|
|
135
|
-
className?: string;
|
|
136
|
-
}>;
|
|
137
|
-
}
|
|
138
|
-
declare function renderFilterBar(data: FilterBarData): string;
|
|
139
|
-
|
|
140
|
-
export { type AlertData, type ConfirmationDialogOptions, type Filter, type FilterBarData, type FilterOption, type FormData, type FormField, type PaginationData, type TableColumn, type TableData, getConfirmationDialogScript, renderAlert, renderConfirmationDialog, renderFilterBar, renderForm, renderFormField, renderPagination, renderTable };
|
|
1
|
+
// Template exports from core package
|
|
2
|
+
export * from '../src/templates/index'
|
package/dist/templates.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { getConfirmationDialogScript, renderAlert, renderConfirmationDialog, renderFilterBar, renderForm, renderFormField, renderPagination, renderTable } from './chunk-
|
|
2
|
-
|
|
1
|
+
export { getConfirmationDialogScript, renderAlert, renderConfirmationDialog, renderFilterBar, renderForm, renderFormField, renderPagination, renderTable } from './chunk-FZYF43TN.js';
|
|
2
|
+
export { renderAdminLayout, renderAdminLayoutCatalyst, renderLogo } from './chunk-G4JGVZAF.js';
|
|
3
|
+
import './chunk-V4OQ3NZ2.js';
|
|
3
4
|
//# sourceMappingURL=templates.js.map
|
|
4
5
|
//# sourceMappingURL=templates.js.map
|
package/dist/types.cjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
import 'hono';
|
|
4
|
-
import 'zod';
|
|
5
|
-
import '@cloudflare/workers-types';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Plugin Manifest Types
|
|
9
|
-
*
|
|
10
|
-
* Defines the structure for plugin manifest.json files
|
|
11
|
-
*/
|
|
12
|
-
interface PluginManifest {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
version: string;
|
|
16
|
-
description: string;
|
|
17
|
-
author: string;
|
|
18
|
-
homepage?: string;
|
|
19
|
-
repository?: string;
|
|
20
|
-
license?: string;
|
|
21
|
-
category: string;
|
|
22
|
-
tags?: string[];
|
|
23
|
-
dependencies?: string[];
|
|
24
|
-
settings?: Record<string, any>;
|
|
25
|
-
hooks?: Record<string, string>;
|
|
26
|
-
routes?: Array<{
|
|
27
|
-
path: string;
|
|
28
|
-
method: string;
|
|
29
|
-
handler: string;
|
|
30
|
-
description?: string;
|
|
31
|
-
}>;
|
|
32
|
-
permissions?: Record<string, string>;
|
|
33
|
-
adminMenu?: {
|
|
34
|
-
label: string;
|
|
35
|
-
icon: string;
|
|
36
|
-
path: string;
|
|
37
|
-
order: number;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type { PluginManifest };
|
|
1
|
+
// Type exports from core package
|
|
2
|
+
export * from '../src/types/index'
|
package/dist/types.js
CHANGED
package/dist/utils.cjs
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,184 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Escapes HTML special characters to prevent XSS attacks
|
|
6
|
-
* @param text - The text to escape
|
|
7
|
-
* @returns The escaped text safe for HTML output
|
|
8
|
-
*/
|
|
9
|
-
declare function escapeHtml(text: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Sanitizes user input by escaping HTML special characters
|
|
12
|
-
* This should be used for all user-provided text fields to prevent XSS
|
|
13
|
-
* @param input - The input string to sanitize
|
|
14
|
-
* @returns The sanitized string
|
|
15
|
-
*/
|
|
16
|
-
declare function sanitizeInput(input: string | null | undefined): string;
|
|
17
|
-
/**
|
|
18
|
-
* Sanitizes an object's string properties
|
|
19
|
-
* @param obj - Object with string properties to sanitize
|
|
20
|
-
* @param fields - Array of field names to sanitize
|
|
21
|
-
* @returns New object with sanitized fields
|
|
22
|
-
*/
|
|
23
|
-
declare function sanitizeObject<T extends Record<string, any>>(obj: T, fields: (keyof T)[]): T;
|
|
24
|
-
|
|
25
|
-
interface TemplateData {
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
}
|
|
28
|
-
declare class TemplateRenderer {
|
|
29
|
-
private templateCache;
|
|
30
|
-
constructor();
|
|
31
|
-
/**
|
|
32
|
-
* Simple Handlebars-like template engine
|
|
33
|
-
*/
|
|
34
|
-
private renderTemplate;
|
|
35
|
-
/**
|
|
36
|
-
* Get nested value from object using dot notation
|
|
37
|
-
*/
|
|
38
|
-
private getNestedValue;
|
|
39
|
-
/**
|
|
40
|
-
* Title case helper function
|
|
41
|
-
*/
|
|
42
|
-
private titleCase;
|
|
43
|
-
/**
|
|
44
|
-
* Render a template string with data
|
|
45
|
-
*/
|
|
46
|
-
render(template: string, data?: TemplateData): string;
|
|
47
|
-
/**
|
|
48
|
-
* Clear template cache (useful for development)
|
|
49
|
-
*/
|
|
50
|
-
clearCache(): void;
|
|
51
|
-
}
|
|
52
|
-
declare const templateRenderer: TemplateRenderer;
|
|
53
|
-
declare function renderTemplate(template: string, data?: TemplateData): string;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Query Filter Builder for SonicJS AI
|
|
57
|
-
* Supports comprehensive filtering with AND/OR logic
|
|
58
|
-
* Compatible with D1 Database (SQLite)
|
|
59
|
-
*/
|
|
60
|
-
type FilterOperator = 'equals' | 'not_equals' | 'greater_than' | 'greater_than_equal' | 'less_than' | 'less_than_equal' | 'like' | 'contains' | 'in' | 'not_in' | 'all' | 'exists' | 'near' | 'within' | 'intersects';
|
|
61
|
-
interface FilterCondition {
|
|
62
|
-
field: string;
|
|
63
|
-
operator: FilterOperator;
|
|
64
|
-
value: any;
|
|
65
|
-
}
|
|
66
|
-
interface FilterGroup {
|
|
67
|
-
and?: FilterCondition[];
|
|
68
|
-
or?: FilterCondition[];
|
|
69
|
-
}
|
|
70
|
-
interface QueryFilter {
|
|
71
|
-
where?: FilterGroup;
|
|
72
|
-
limit?: number;
|
|
73
|
-
offset?: number;
|
|
74
|
-
sort?: {
|
|
75
|
-
field: string;
|
|
76
|
-
order: 'asc' | 'desc';
|
|
77
|
-
}[];
|
|
78
|
-
}
|
|
79
|
-
interface QueryResult {
|
|
80
|
-
sql: string;
|
|
81
|
-
params: any[];
|
|
82
|
-
errors: string[];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Query Filter Builder
|
|
86
|
-
* Converts filter objects into SQL WHERE clauses with parameterized queries
|
|
87
|
-
*/
|
|
88
|
-
declare class QueryFilterBuilder {
|
|
89
|
-
private params;
|
|
90
|
-
private errors;
|
|
91
|
-
/**
|
|
92
|
-
* Build a complete SQL query from filter object
|
|
93
|
-
*/
|
|
94
|
-
build(baseTable: string, filter: QueryFilter): QueryResult;
|
|
95
|
-
/**
|
|
96
|
-
* Build WHERE clause from filter group
|
|
97
|
-
*/
|
|
98
|
-
private buildWhereClause;
|
|
99
|
-
/**
|
|
100
|
-
* Build a single condition
|
|
101
|
-
*/
|
|
102
|
-
private buildCondition;
|
|
103
|
-
/**
|
|
104
|
-
* Build equals condition
|
|
105
|
-
*/
|
|
106
|
-
private buildEquals;
|
|
107
|
-
/**
|
|
108
|
-
* Build not equals condition
|
|
109
|
-
*/
|
|
110
|
-
private buildNotEquals;
|
|
111
|
-
/**
|
|
112
|
-
* Build comparison condition (>, >=, <, <=)
|
|
113
|
-
*/
|
|
114
|
-
private buildComparison;
|
|
115
|
-
/**
|
|
116
|
-
* Build LIKE condition (case-insensitive, all words must be present)
|
|
117
|
-
*/
|
|
118
|
-
private buildLike;
|
|
119
|
-
/**
|
|
120
|
-
* Build CONTAINS condition (case-insensitive substring)
|
|
121
|
-
*/
|
|
122
|
-
private buildContains;
|
|
123
|
-
/**
|
|
124
|
-
* Build IN condition
|
|
125
|
-
*/
|
|
126
|
-
private buildIn;
|
|
127
|
-
/**
|
|
128
|
-
* Build NOT IN condition
|
|
129
|
-
*/
|
|
130
|
-
private buildNotIn;
|
|
131
|
-
/**
|
|
132
|
-
* Build ALL condition (value must contain all items in list)
|
|
133
|
-
* For SQLite, we'll check if a JSON array contains all values
|
|
134
|
-
*/
|
|
135
|
-
private buildAll;
|
|
136
|
-
/**
|
|
137
|
-
* Build EXISTS condition
|
|
138
|
-
*/
|
|
139
|
-
private buildExists;
|
|
140
|
-
/**
|
|
141
|
-
* Sanitize field names to prevent SQL injection
|
|
142
|
-
*/
|
|
143
|
-
private sanitizeFieldName;
|
|
144
|
-
/**
|
|
145
|
-
* Parse filter from query string
|
|
146
|
-
*/
|
|
147
|
-
static parseFromQuery(query: Record<string, any>): QueryFilter;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Helper function to build query from filter
|
|
151
|
-
*/
|
|
152
|
-
declare function buildQuery(table: string, filter: QueryFilter): QueryResult;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Simple in-memory metrics tracker for real-time analytics
|
|
156
|
-
* Tracks requests per second using a sliding window
|
|
157
|
-
*/
|
|
158
|
-
declare class MetricsTracker {
|
|
159
|
-
private requests;
|
|
160
|
-
private readonly windowSize;
|
|
161
|
-
/**
|
|
162
|
-
* Record a new request
|
|
163
|
-
*/
|
|
164
|
-
recordRequest(): void;
|
|
165
|
-
/**
|
|
166
|
-
* Clean up old requests outside the window
|
|
167
|
-
*/
|
|
168
|
-
private cleanup;
|
|
169
|
-
/**
|
|
170
|
-
* Get current requests per second
|
|
171
|
-
*/
|
|
172
|
-
getRequestsPerSecond(): number;
|
|
173
|
-
/**
|
|
174
|
-
* Get total requests in the current window
|
|
175
|
-
*/
|
|
176
|
-
getTotalRequests(): number;
|
|
177
|
-
/**
|
|
178
|
-
* Get average requests per second over the window
|
|
179
|
-
*/
|
|
180
|
-
getAverageRPS(): number;
|
|
181
|
-
}
|
|
182
|
-
declare const metricsTracker: MetricsTracker;
|
|
183
|
-
|
|
184
|
-
export { type FilterCondition, type FilterGroup, type FilterOperator, type QueryFilter, QueryFilterBuilder, type QueryResult, TemplateRenderer, buildQuery, escapeHtml, metricsTracker, renderTemplate, sanitizeInput, sanitizeObject, templateRenderer };
|
|
1
|
+
// Utility exports from core package
|
|
2
|
+
export * from '../src/utils/index'
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { QueryFilterBuilder, TemplateRenderer, buildQuery, escapeHtml, metricsTracker, renderTemplate, sanitizeInput, sanitizeObject, templateRenderer } from './chunk-JIINOD2W.js';
|
|
2
|
-
import './chunk-
|
|
2
|
+
import './chunk-V4OQ3NZ2.js';
|
|
3
3
|
//# sourceMappingURL=utils.js.map
|
|
4
4
|
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
-- Initial schema for SonicJS AI
|
|
2
|
+
-- Create users table for authentication
|
|
3
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
email TEXT NOT NULL UNIQUE,
|
|
6
|
+
username TEXT NOT NULL UNIQUE,
|
|
7
|
+
first_name TEXT NOT NULL,
|
|
8
|
+
last_name TEXT NOT NULL,
|
|
9
|
+
password_hash TEXT,
|
|
10
|
+
role TEXT NOT NULL DEFAULT 'viewer',
|
|
11
|
+
avatar TEXT,
|
|
12
|
+
is_active INTEGER NOT NULL DEFAULT 1,
|
|
13
|
+
last_login_at INTEGER,
|
|
14
|
+
created_at INTEGER NOT NULL,
|
|
15
|
+
updated_at INTEGER NOT NULL
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
-- Create collections table for content schema definitions
|
|
19
|
+
CREATE TABLE IF NOT EXISTS collections (
|
|
20
|
+
id TEXT PRIMARY KEY,
|
|
21
|
+
name TEXT NOT NULL UNIQUE,
|
|
22
|
+
display_name TEXT NOT NULL,
|
|
23
|
+
description TEXT,
|
|
24
|
+
schema TEXT NOT NULL, -- JSON schema definition
|
|
25
|
+
is_active INTEGER NOT NULL DEFAULT 1,
|
|
26
|
+
created_at INTEGER NOT NULL,
|
|
27
|
+
updated_at INTEGER NOT NULL
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
-- Create content table for actual content data
|
|
31
|
+
CREATE TABLE IF NOT EXISTS content (
|
|
32
|
+
id TEXT PRIMARY KEY,
|
|
33
|
+
collection_id TEXT NOT NULL REFERENCES collections(id),
|
|
34
|
+
slug TEXT NOT NULL,
|
|
35
|
+
title TEXT NOT NULL,
|
|
36
|
+
data TEXT NOT NULL, -- JSON content data
|
|
37
|
+
status TEXT NOT NULL DEFAULT 'draft',
|
|
38
|
+
published_at INTEGER,
|
|
39
|
+
author_id TEXT NOT NULL REFERENCES users(id),
|
|
40
|
+
created_at INTEGER NOT NULL,
|
|
41
|
+
updated_at INTEGER NOT NULL
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
-- Create content_versions table for versioning
|
|
45
|
+
CREATE TABLE IF NOT EXISTS content_versions (
|
|
46
|
+
id TEXT PRIMARY KEY,
|
|
47
|
+
content_id TEXT NOT NULL REFERENCES content(id),
|
|
48
|
+
version INTEGER NOT NULL,
|
|
49
|
+
data TEXT NOT NULL, -- JSON data
|
|
50
|
+
author_id TEXT NOT NULL REFERENCES users(id),
|
|
51
|
+
created_at INTEGER NOT NULL
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
-- Create media/files table with comprehensive R2 integration
|
|
55
|
+
CREATE TABLE IF NOT EXISTS media (
|
|
56
|
+
id TEXT PRIMARY KEY,
|
|
57
|
+
filename TEXT NOT NULL,
|
|
58
|
+
original_name TEXT NOT NULL,
|
|
59
|
+
mime_type TEXT NOT NULL,
|
|
60
|
+
size INTEGER NOT NULL,
|
|
61
|
+
width INTEGER,
|
|
62
|
+
height INTEGER,
|
|
63
|
+
folder TEXT NOT NULL DEFAULT 'uploads',
|
|
64
|
+
r2_key TEXT NOT NULL, -- R2 storage key
|
|
65
|
+
public_url TEXT NOT NULL, -- CDN URL
|
|
66
|
+
thumbnail_url TEXT, -- Cloudflare Images URL
|
|
67
|
+
alt TEXT,
|
|
68
|
+
caption TEXT,
|
|
69
|
+
tags TEXT, -- JSON array of tags
|
|
70
|
+
uploaded_by TEXT NOT NULL REFERENCES users(id),
|
|
71
|
+
uploaded_at INTEGER NOT NULL,
|
|
72
|
+
updated_at INTEGER,
|
|
73
|
+
published_at INTEGER,
|
|
74
|
+
scheduled_at INTEGER,
|
|
75
|
+
archived_at INTEGER,
|
|
76
|
+
deleted_at INTEGER
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
-- Create API tokens table for programmatic access
|
|
80
|
+
CREATE TABLE IF NOT EXISTS api_tokens (
|
|
81
|
+
id TEXT PRIMARY KEY,
|
|
82
|
+
name TEXT NOT NULL,
|
|
83
|
+
token TEXT NOT NULL UNIQUE,
|
|
84
|
+
user_id TEXT NOT NULL REFERENCES users(id),
|
|
85
|
+
permissions TEXT NOT NULL, -- JSON array of permissions
|
|
86
|
+
expires_at INTEGER,
|
|
87
|
+
last_used_at INTEGER,
|
|
88
|
+
created_at INTEGER NOT NULL
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
-- Create workflow history table for content workflow tracking
|
|
92
|
+
CREATE TABLE IF NOT EXISTS workflow_history (
|
|
93
|
+
id TEXT PRIMARY KEY,
|
|
94
|
+
content_id TEXT NOT NULL REFERENCES content(id),
|
|
95
|
+
action TEXT NOT NULL,
|
|
96
|
+
from_status TEXT NOT NULL,
|
|
97
|
+
to_status TEXT NOT NULL,
|
|
98
|
+
user_id TEXT NOT NULL REFERENCES users(id),
|
|
99
|
+
comment TEXT,
|
|
100
|
+
created_at INTEGER NOT NULL
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
-- Create indexes for better performance
|
|
104
|
+
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
|
|
105
|
+
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
|
|
106
|
+
CREATE INDEX IF NOT EXISTS idx_users_role ON users(role);
|
|
107
|
+
|
|
108
|
+
CREATE INDEX IF NOT EXISTS idx_collections_name ON collections(name);
|
|
109
|
+
CREATE INDEX IF NOT EXISTS idx_collections_active ON collections(is_active);
|
|
110
|
+
|
|
111
|
+
CREATE INDEX IF NOT EXISTS idx_content_collection ON content(collection_id);
|
|
112
|
+
CREATE INDEX IF NOT EXISTS idx_content_author ON content(author_id);
|
|
113
|
+
CREATE INDEX IF NOT EXISTS idx_content_status ON content(status);
|
|
114
|
+
CREATE INDEX IF NOT EXISTS idx_content_published ON content(published_at);
|
|
115
|
+
CREATE INDEX IF NOT EXISTS idx_content_slug ON content(slug);
|
|
116
|
+
|
|
117
|
+
CREATE INDEX IF NOT EXISTS idx_content_versions_content ON content_versions(content_id);
|
|
118
|
+
CREATE INDEX IF NOT EXISTS idx_content_versions_version ON content_versions(version);
|
|
119
|
+
|
|
120
|
+
CREATE INDEX IF NOT EXISTS idx_media_folder ON media(folder);
|
|
121
|
+
CREATE INDEX IF NOT EXISTS idx_media_type ON media(mime_type);
|
|
122
|
+
CREATE INDEX IF NOT EXISTS idx_media_uploaded_by ON media(uploaded_by);
|
|
123
|
+
CREATE INDEX IF NOT EXISTS idx_media_uploaded_at ON media(uploaded_at);
|
|
124
|
+
CREATE INDEX IF NOT EXISTS idx_media_deleted ON media(deleted_at);
|
|
125
|
+
|
|
126
|
+
CREATE INDEX IF NOT EXISTS idx_api_tokens_user ON api_tokens(user_id);
|
|
127
|
+
CREATE INDEX IF NOT EXISTS idx_api_tokens_token ON api_tokens(token);
|
|
128
|
+
|
|
129
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_history_content ON workflow_history(content_id);
|
|
130
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_history_user ON workflow_history(user_id);
|
|
131
|
+
|
|
132
|
+
-- Insert default admin user (password: admin123)
|
|
133
|
+
INSERT OR IGNORE INTO users (
|
|
134
|
+
id, email, username, first_name, last_name, password_hash,
|
|
135
|
+
role, is_active, created_at, updated_at
|
|
136
|
+
) VALUES (
|
|
137
|
+
'admin-user-id',
|
|
138
|
+
'admin@sonicjs.com',
|
|
139
|
+
'admin',
|
|
140
|
+
'Admin',
|
|
141
|
+
'User',
|
|
142
|
+
'd1c379e871838f44e21d5a55841349e50636f06df139bfef11870eec74c381db', -- SHA-256 hash of 'admin123'
|
|
143
|
+
'admin',
|
|
144
|
+
1,
|
|
145
|
+
strftime('%s', 'now') * 1000,
|
|
146
|
+
strftime('%s', 'now') * 1000
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
-- Insert sample collections
|
|
150
|
+
INSERT OR IGNORE INTO collections (
|
|
151
|
+
id, name, display_name, description, schema,
|
|
152
|
+
is_active, created_at, updated_at
|
|
153
|
+
) VALUES (
|
|
154
|
+
'blog-posts-collection',
|
|
155
|
+
'blog_posts',
|
|
156
|
+
'Blog Posts',
|
|
157
|
+
'Blog post content collection',
|
|
158
|
+
'{"type":"object","properties":{"title":{"type":"string","title":"Title","required":true},"content":{"type":"string","title":"Content","format":"richtext"},"excerpt":{"type":"string","title":"Excerpt"},"featured_image":{"type":"string","title":"Featured Image","format":"media"},"tags":{"type":"array","title":"Tags","items":{"type":"string"}},"status":{"type":"string","title":"Status","enum":["draft","published","archived"],"default":"draft"}},"required":["title"]}',
|
|
159
|
+
1,
|
|
160
|
+
strftime('%s', 'now') * 1000,
|
|
161
|
+
strftime('%s', 'now') * 1000
|
|
162
|
+
),
|
|
163
|
+
(
|
|
164
|
+
'pages-collection',
|
|
165
|
+
'pages',
|
|
166
|
+
'Pages',
|
|
167
|
+
'Static page content collection',
|
|
168
|
+
'{"type":"object","properties":{"title":{"type":"string","title":"Title","required":true},"content":{"type":"string","title":"Content","format":"richtext"},"slug":{"type":"string","title":"Slug"},"meta_description":{"type":"string","title":"Meta Description"},"featured_image":{"type":"string","title":"Featured Image","format":"media"}},"required":["title"]}',
|
|
169
|
+
1,
|
|
170
|
+
strftime('%s', 'now') * 1000,
|
|
171
|
+
strftime('%s', 'now') * 1000
|
|
172
|
+
),
|
|
173
|
+
(
|
|
174
|
+
'news-collection',
|
|
175
|
+
'news',
|
|
176
|
+
'News',
|
|
177
|
+
'News article content collection',
|
|
178
|
+
'{"type":"object","properties":{"title":{"type":"string","title":"Title","required":true},"content":{"type":"string","title":"Content","format":"richtext"},"publish_date":{"type":"string","title":"Publish Date","format":"date"},"author":{"type":"string","title":"Author"},"category":{"type":"string","title":"Category","enum":["technology","business","general"]}},"required":["title"]}',
|
|
179
|
+
1,
|
|
180
|
+
strftime('%s', 'now') * 1000,
|
|
181
|
+
strftime('%s', 'now') * 1000
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
-- Insert sample content
|
|
185
|
+
INSERT OR IGNORE INTO content (
|
|
186
|
+
id, collection_id, slug, title, data, status,
|
|
187
|
+
author_id, created_at, updated_at
|
|
188
|
+
) VALUES (
|
|
189
|
+
'welcome-blog-post',
|
|
190
|
+
'blog-posts-collection',
|
|
191
|
+
'welcome-to-sonicjs-ai',
|
|
192
|
+
'Welcome to SonicJS AI',
|
|
193
|
+
'{"title":"Welcome to SonicJS AI","content":"<h1>Welcome to SonicJS AI</h1><p>This is your first blog post created with SonicJS AI, a modern headless CMS built on Cloudflare Workers.</p><h2>Features</h2><ul><li>Cloudflare-native architecture</li><li>TypeScript-first development</li><li>Hono.js framework</li><li>D1 database</li><li>R2 media storage</li><li>Edge computing</li></ul><p>Get started by exploring the admin interface and creating your own content!</p>","excerpt":"Welcome to SonicJS AI, a modern headless CMS built on Cloudflare Workers with TypeScript and Hono.js.","status":"published","tags":["welcome","cms","cloudflare"]}',
|
|
194
|
+
'published',
|
|
195
|
+
'admin-user-id',
|
|
196
|
+
strftime('%s', 'now') * 1000,
|
|
197
|
+
strftime('%s', 'now') * 1000
|
|
198
|
+
);
|