@sonicjs-cms/core 2.2.0 → 2.3.1
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/README.md +75 -1
- package/dist/app-Db0AfT5F.d.cts +100 -0
- package/dist/app-Db0AfT5F.d.ts +100 -0
- package/dist/chunk-23VPL6VI.cjs +1828 -0
- package/dist/chunk-23VPL6VI.cjs.map +1 -0
- package/dist/chunk-3MPQII4R.js +1826 -0
- package/dist/chunk-3MPQII4R.js.map +1 -0
- package/dist/{chunk-YTMFJLJZ.cjs → chunk-44LBCF3B.cjs} +5 -3
- package/dist/chunk-44LBCF3B.cjs.map +1 -0
- package/dist/{chunk-2DIWLDCA.cjs → chunk-5QJX2VMP.cjs} +541 -533
- package/dist/chunk-5QJX2VMP.cjs.map +1 -0
- package/dist/{chunk-UEYMFNBN.cjs → chunk-5UUYHAZT.cjs} +7 -36
- package/dist/chunk-5UUYHAZT.cjs.map +1 -0
- package/dist/{chunk-ZUK55KZB.js → chunk-6RJU7HL5.js} +5 -3
- package/dist/chunk-6RJU7HL5.js.map +1 -0
- package/dist/{chunk-K4Z3IHOK.js → chunk-7CXL5K7N.js} +5 -248
- package/dist/chunk-7CXL5K7N.js.map +1 -0
- package/dist/{chunk-WBX5YMTB.cjs → chunk-7KCDFDRI.cjs} +27 -15
- package/dist/chunk-7KCDFDRI.cjs.map +1 -0
- package/dist/{chunk-HKEK7UNV.js → chunk-CPXAVWCU.js} +3 -3
- package/dist/{chunk-HKEK7UNV.js.map → chunk-CPXAVWCU.js.map} +1 -1
- package/dist/{chunk-F5ESJXI2.cjs → chunk-DTLB6UIH.cjs} +3 -3
- package/dist/{chunk-F5ESJXI2.cjs.map → chunk-DTLB6UIH.cjs.map} +1 -1
- package/dist/{chunk-AINTFRTC.cjs → chunk-ES3BRZQJ.cjs} +252 -2
- package/dist/chunk-ES3BRZQJ.cjs.map +1 -0
- package/dist/{chunk-HV2I6API.cjs → chunk-NAYD76QF.cjs} +4 -251
- package/dist/chunk-NAYD76QF.cjs.map +1 -0
- package/dist/{chunk-L232U757.js → chunk-Q52ZQFMB.js} +249 -3
- package/dist/chunk-Q52ZQFMB.js.map +1 -0
- package/dist/{chunk-NMVOTNSL.js → chunk-RRKXFGIO.js} +28 -16
- package/dist/chunk-RRKXFGIO.js.map +1 -0
- package/dist/{chunk-OORGXYDA.js → chunk-WK5EUGBO.js} +5 -32
- package/dist/chunk-WK5EUGBO.js.map +1 -0
- package/dist/{chunk-R57VFNP3.js → chunk-ZPERJATF.js} +441 -433
- package/dist/chunk-ZPERJATF.js.map +1 -0
- package/dist/collection-config-FLlGtsh9.d.cts +107 -0
- package/dist/collection-config-FLlGtsh9.d.ts +107 -0
- package/dist/filter-bar.template-By4jeiw_.d.cts +140 -0
- package/dist/filter-bar.template-By4jeiw_.d.ts +140 -0
- package/dist/index.cjs +146 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +43 -5
- package/dist/index.js +19 -14
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +24 -33
- package/dist/middleware.d.cts +89 -0
- package/dist/middleware.d.ts +89 -2
- package/dist/middleware.js +3 -4
- package/dist/migrations-CCLAGJGP.js +4 -0
- package/dist/{migrations-IHERIQVD.js.map → migrations-CCLAGJGP.js.map} +1 -1
- package/dist/migrations-O6INOHRD.cjs +13 -0
- package/dist/{migrations-POFD5KNG.cjs.map → migrations-O6INOHRD.cjs.map} +1 -1
- package/dist/plugin-bootstrap-C0E3jdz-.d.cts +8339 -0
- package/dist/plugin-bootstrap-CDh0JHtW.d.ts +8339 -0
- package/dist/plugin-manifest-BCMx9CAq.d.cts +35 -0
- package/dist/plugin-manifest-BCMx9CAq.d.ts +35 -0
- package/dist/plugin-zvZpaiP5.d.cts +357 -0
- package/dist/plugin-zvZpaiP5.d.ts +357 -0
- package/dist/plugins.cjs +7 -7
- package/dist/plugins.d.cts +330 -0
- package/dist/plugins.d.ts +330 -2
- package/dist/plugins.js +1 -1
- package/dist/routes.cjs +27 -27
- package/dist/routes.d.cts +224 -0
- package/dist/routes.d.ts +224 -2
- package/dist/routes.js +7 -7
- package/dist/services.cjs +41 -41
- package/dist/services.d.cts +236 -0
- package/dist/services.d.ts +236 -2
- package/dist/services.js +4 -4
- package/dist/telemetry-BFBIjBxK.d.cts +36 -0
- package/dist/telemetry-BFBIjBxK.d.ts +36 -0
- package/dist/templates.d.cts +133 -0
- package/dist/templates.d.ts +133 -2
- package/dist/types.d.cts +7 -0
- package/dist/types.d.ts +7 -2
- package/dist/utils.cjs +27 -27
- package/dist/utils.d.cts +53 -0
- package/dist/utils.d.ts +53 -2
- package/dist/utils.js +2 -2
- package/dist/version-vktVAxhe.d.cts +195 -0
- package/dist/version-vktVAxhe.d.ts +195 -0
- package/migrations/001_initial_schema.sql +1 -1
- package/migrations/002_faq_plugin.sql +86 -0
- package/package.json +3 -1
- package/dist/chunk-2DIWLDCA.cjs.map +0 -1
- package/dist/chunk-AINTFRTC.cjs.map +0 -1
- package/dist/chunk-HV2I6API.cjs.map +0 -1
- package/dist/chunk-K4Z3IHOK.js.map +0 -1
- package/dist/chunk-L232U757.js.map +0 -1
- package/dist/chunk-NMVOTNSL.js.map +0 -1
- package/dist/chunk-OORGXYDA.js.map +0 -1
- package/dist/chunk-R57VFNP3.js.map +0 -1
- package/dist/chunk-T7IYBGGO.cjs +0 -746
- package/dist/chunk-T7IYBGGO.cjs.map +0 -1
- package/dist/chunk-UEYMFNBN.cjs.map +0 -1
- package/dist/chunk-WBX5YMTB.cjs.map +0 -1
- package/dist/chunk-YTMFJLJZ.cjs.map +0 -1
- package/dist/chunk-ZPMFT2JW.js +0 -744
- package/dist/chunk-ZPMFT2JW.js.map +0 -1
- package/dist/chunk-ZUK55KZB.js.map +0 -1
- package/dist/migrations-IHERIQVD.js +0 -4
- package/dist/migrations-POFD5KNG.cjs +0 -13
- /package/migrations/{021_add_otp_login.sql → 026_add_otp_login.sql} +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML sanitization utilities for preventing XSS attacks
|
|
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
|
+
/**
|
|
185
|
+
* Version utility
|
|
186
|
+
*
|
|
187
|
+
* Provides the current version of @sonicjs-cms/core package
|
|
188
|
+
*/
|
|
189
|
+
declare const SONICJS_VERSION: string;
|
|
190
|
+
/**
|
|
191
|
+
* Get the current SonicJS core version
|
|
192
|
+
*/
|
|
193
|
+
declare function getCoreVersion(): string;
|
|
194
|
+
|
|
195
|
+
export { type FilterOperator as F, QueryFilterBuilder as Q, SONICJS_VERSION as S, TemplateRenderer as T, sanitizeObject as a, buildQuery as b, type FilterCondition as c, type FilterGroup as d, escapeHtml as e, type QueryFilter as f, getCoreVersion as g, type QueryResult as h, metricsTracker as m, renderTemplate as r, sanitizeInput as s, templateRenderer as t };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML sanitization utilities for preventing XSS attacks
|
|
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
|
+
/**
|
|
185
|
+
* Version utility
|
|
186
|
+
*
|
|
187
|
+
* Provides the current version of @sonicjs-cms/core package
|
|
188
|
+
*/
|
|
189
|
+
declare const SONICJS_VERSION: string;
|
|
190
|
+
/**
|
|
191
|
+
* Get the current SonicJS core version
|
|
192
|
+
*/
|
|
193
|
+
declare function getCoreVersion(): string;
|
|
194
|
+
|
|
195
|
+
export { type FilterOperator as F, QueryFilterBuilder as Q, SONICJS_VERSION as S, TemplateRenderer as T, sanitizeObject as a, buildQuery as b, type FilterCondition as c, type FilterGroup as d, escapeHtml as e, type QueryFilter as f, getCoreVersion as g, type QueryResult as h, metricsTracker as m, renderTemplate as r, sanitizeInput as s, templateRenderer as t };
|
|
@@ -139,7 +139,7 @@ INSERT OR IGNORE INTO users (
|
|
|
139
139
|
'admin',
|
|
140
140
|
'Admin',
|
|
141
141
|
'User',
|
|
142
|
-
'
|
|
142
|
+
'9c9ec10df964f588e51acc794a63f18d5582e9b91c8366ba292ebde84d3834fd', -- SHA-256 hash of 'sonicjs!' with salt
|
|
143
143
|
'admin',
|
|
144
144
|
1,
|
|
145
145
|
strftime('%s', 'now') * 1000,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
-- FAQ Plugin Migration (DEPRECATED - Now managed by third-party plugin)
|
|
2
|
+
-- Creates FAQ table for the FAQ plugin
|
|
3
|
+
-- NOTE: This migration is kept for historical purposes.
|
|
4
|
+
-- The FAQ functionality is now provided by the faq-plugin third-party plugin.
|
|
5
|
+
|
|
6
|
+
CREATE TABLE IF NOT EXISTS faqs (
|
|
7
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
8
|
+
question TEXT NOT NULL,
|
|
9
|
+
answer TEXT NOT NULL,
|
|
10
|
+
category TEXT,
|
|
11
|
+
tags TEXT,
|
|
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_faqs_category ON faqs(category);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_faqs_published ON faqs(isPublished);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS idx_faqs_sort_order ON faqs(sortOrder);
|
|
22
|
+
|
|
23
|
+
-- Create trigger to update updated_at timestamp
|
|
24
|
+
CREATE TRIGGER IF NOT EXISTS faqs_updated_at
|
|
25
|
+
AFTER UPDATE ON faqs
|
|
26
|
+
BEGIN
|
|
27
|
+
UPDATE faqs SET updated_at = strftime('%s', 'now') WHERE id = NEW.id;
|
|
28
|
+
END;
|
|
29
|
+
|
|
30
|
+
-- Insert sample FAQ data
|
|
31
|
+
INSERT OR IGNORE INTO faqs (question, answer, category, tags, isPublished, sortOrder) VALUES
|
|
32
|
+
('What is SonicJS AI?',
|
|
33
|
+
'SonicJS AI is a modern, TypeScript-first headless CMS built for Cloudflare''s edge platform. It provides a complete content management system with admin interface, API endpoints, and plugin architecture.',
|
|
34
|
+
'general',
|
|
35
|
+
'sonicjs, cms, cloudflare',
|
|
36
|
+
1,
|
|
37
|
+
1),
|
|
38
|
+
|
|
39
|
+
('How do I get started with SonicJS AI?',
|
|
40
|
+
'To get started: 1) Clone the repository, 2) Install dependencies with npm install, 3) Set up your Cloudflare account and services, 4) Run the development server with npm run dev, 5) Access the admin interface at /admin.',
|
|
41
|
+
'general',
|
|
42
|
+
'getting-started, setup',
|
|
43
|
+
1,
|
|
44
|
+
2),
|
|
45
|
+
|
|
46
|
+
('What technologies does SonicJS AI use?',
|
|
47
|
+
'SonicJS AI is built with: TypeScript for type safety, Hono.js as the web framework, Cloudflare D1 for the database, Cloudflare R2 for media storage, Cloudflare Workers for serverless execution, and Tailwind CSS for styling.',
|
|
48
|
+
'technical',
|
|
49
|
+
'technology-stack, typescript, cloudflare',
|
|
50
|
+
1,
|
|
51
|
+
3),
|
|
52
|
+
|
|
53
|
+
('How do I create content in SonicJS AI?',
|
|
54
|
+
'Content creation is done through the admin interface. Navigate to /admin, log in with your credentials, go to Content section, select a collection, and click "New Content" to create articles, pages, or other content types.',
|
|
55
|
+
'general',
|
|
56
|
+
'content-creation, admin',
|
|
57
|
+
1,
|
|
58
|
+
4),
|
|
59
|
+
|
|
60
|
+
('Is SonicJS AI free to use?',
|
|
61
|
+
'SonicJS AI is open source and free to use. You only pay for the Cloudflare services you consume (D1 database, R2 storage, Workers execution time). Cloudflare offers generous free tiers for development and small projects.',
|
|
62
|
+
'billing',
|
|
63
|
+
'pricing, open-source, cloudflare',
|
|
64
|
+
1,
|
|
65
|
+
5),
|
|
66
|
+
|
|
67
|
+
('How do I add custom functionality?',
|
|
68
|
+
'SonicJS AI features a plugin system that allows you to extend functionality. You can create plugins using the PluginBuilder API, add custom routes, models, admin pages, and integrate with external services.',
|
|
69
|
+
'technical',
|
|
70
|
+
'plugins, customization, development',
|
|
71
|
+
1,
|
|
72
|
+
6),
|
|
73
|
+
|
|
74
|
+
('Can I customize the admin interface?',
|
|
75
|
+
'Yes! The admin interface is built with TypeScript templates and can be customized. You can modify existing templates, create new components, add custom pages, and integrate your own styling while maintaining the dark theme.',
|
|
76
|
+
'technical',
|
|
77
|
+
'admin-interface, customization, templates',
|
|
78
|
+
1,
|
|
79
|
+
7),
|
|
80
|
+
|
|
81
|
+
('How does authentication work?',
|
|
82
|
+
'SonicJS AI includes a built-in authentication system with JWT tokens, role-based access control (admin, editor, viewer), secure password hashing, and session management. Users can be managed through the admin interface.',
|
|
83
|
+
'technical',
|
|
84
|
+
'authentication, security, users',
|
|
85
|
+
1,
|
|
86
|
+
8);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonicjs-cms/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Core framework for SonicJS headless CMS - Edge-first, TypeScript-native CMS built for Cloudflare Workers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
"LICENSE"
|
|
57
57
|
],
|
|
58
58
|
"scripts": {
|
|
59
|
+
"generate:migrations": "npx tsx scripts/generate-migrations.ts",
|
|
60
|
+
"prebuild": "npm run generate:migrations",
|
|
59
61
|
"build": "tsup",
|
|
60
62
|
"dev": "tsup --watch",
|
|
61
63
|
"type-check": "tsc --noEmit",
|