@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.
Files changed (105) hide show
  1. package/README.md +75 -1
  2. package/dist/app-Db0AfT5F.d.cts +100 -0
  3. package/dist/app-Db0AfT5F.d.ts +100 -0
  4. package/dist/chunk-23VPL6VI.cjs +1828 -0
  5. package/dist/chunk-23VPL6VI.cjs.map +1 -0
  6. package/dist/chunk-3MPQII4R.js +1826 -0
  7. package/dist/chunk-3MPQII4R.js.map +1 -0
  8. package/dist/{chunk-YTMFJLJZ.cjs → chunk-44LBCF3B.cjs} +5 -3
  9. package/dist/chunk-44LBCF3B.cjs.map +1 -0
  10. package/dist/{chunk-2DIWLDCA.cjs → chunk-5QJX2VMP.cjs} +541 -533
  11. package/dist/chunk-5QJX2VMP.cjs.map +1 -0
  12. package/dist/{chunk-UEYMFNBN.cjs → chunk-5UUYHAZT.cjs} +7 -36
  13. package/dist/chunk-5UUYHAZT.cjs.map +1 -0
  14. package/dist/{chunk-ZUK55KZB.js → chunk-6RJU7HL5.js} +5 -3
  15. package/dist/chunk-6RJU7HL5.js.map +1 -0
  16. package/dist/{chunk-K4Z3IHOK.js → chunk-7CXL5K7N.js} +5 -248
  17. package/dist/chunk-7CXL5K7N.js.map +1 -0
  18. package/dist/{chunk-WBX5YMTB.cjs → chunk-7KCDFDRI.cjs} +27 -15
  19. package/dist/chunk-7KCDFDRI.cjs.map +1 -0
  20. package/dist/{chunk-HKEK7UNV.js → chunk-CPXAVWCU.js} +3 -3
  21. package/dist/{chunk-HKEK7UNV.js.map → chunk-CPXAVWCU.js.map} +1 -1
  22. package/dist/{chunk-F5ESJXI2.cjs → chunk-DTLB6UIH.cjs} +3 -3
  23. package/dist/{chunk-F5ESJXI2.cjs.map → chunk-DTLB6UIH.cjs.map} +1 -1
  24. package/dist/{chunk-AINTFRTC.cjs → chunk-ES3BRZQJ.cjs} +252 -2
  25. package/dist/chunk-ES3BRZQJ.cjs.map +1 -0
  26. package/dist/{chunk-HV2I6API.cjs → chunk-NAYD76QF.cjs} +4 -251
  27. package/dist/chunk-NAYD76QF.cjs.map +1 -0
  28. package/dist/{chunk-L232U757.js → chunk-Q52ZQFMB.js} +249 -3
  29. package/dist/chunk-Q52ZQFMB.js.map +1 -0
  30. package/dist/{chunk-NMVOTNSL.js → chunk-RRKXFGIO.js} +28 -16
  31. package/dist/chunk-RRKXFGIO.js.map +1 -0
  32. package/dist/{chunk-OORGXYDA.js → chunk-WK5EUGBO.js} +5 -32
  33. package/dist/chunk-WK5EUGBO.js.map +1 -0
  34. package/dist/{chunk-R57VFNP3.js → chunk-ZPERJATF.js} +441 -433
  35. package/dist/chunk-ZPERJATF.js.map +1 -0
  36. package/dist/collection-config-FLlGtsh9.d.cts +107 -0
  37. package/dist/collection-config-FLlGtsh9.d.ts +107 -0
  38. package/dist/filter-bar.template-By4jeiw_.d.cts +140 -0
  39. package/dist/filter-bar.template-By4jeiw_.d.ts +140 -0
  40. package/dist/index.cjs +146 -165
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +44 -0
  43. package/dist/index.d.ts +43 -5
  44. package/dist/index.js +19 -14
  45. package/dist/index.js.map +1 -1
  46. package/dist/middleware.cjs +24 -33
  47. package/dist/middleware.d.cts +89 -0
  48. package/dist/middleware.d.ts +89 -2
  49. package/dist/middleware.js +3 -4
  50. package/dist/migrations-CCLAGJGP.js +4 -0
  51. package/dist/{migrations-IHERIQVD.js.map → migrations-CCLAGJGP.js.map} +1 -1
  52. package/dist/migrations-O6INOHRD.cjs +13 -0
  53. package/dist/{migrations-POFD5KNG.cjs.map → migrations-O6INOHRD.cjs.map} +1 -1
  54. package/dist/plugin-bootstrap-C0E3jdz-.d.cts +8339 -0
  55. package/dist/plugin-bootstrap-CDh0JHtW.d.ts +8339 -0
  56. package/dist/plugin-manifest-BCMx9CAq.d.cts +35 -0
  57. package/dist/plugin-manifest-BCMx9CAq.d.ts +35 -0
  58. package/dist/plugin-zvZpaiP5.d.cts +357 -0
  59. package/dist/plugin-zvZpaiP5.d.ts +357 -0
  60. package/dist/plugins.cjs +7 -7
  61. package/dist/plugins.d.cts +330 -0
  62. package/dist/plugins.d.ts +330 -2
  63. package/dist/plugins.js +1 -1
  64. package/dist/routes.cjs +27 -27
  65. package/dist/routes.d.cts +224 -0
  66. package/dist/routes.d.ts +224 -2
  67. package/dist/routes.js +7 -7
  68. package/dist/services.cjs +41 -41
  69. package/dist/services.d.cts +236 -0
  70. package/dist/services.d.ts +236 -2
  71. package/dist/services.js +4 -4
  72. package/dist/telemetry-BFBIjBxK.d.cts +36 -0
  73. package/dist/telemetry-BFBIjBxK.d.ts +36 -0
  74. package/dist/templates.d.cts +133 -0
  75. package/dist/templates.d.ts +133 -2
  76. package/dist/types.d.cts +7 -0
  77. package/dist/types.d.ts +7 -2
  78. package/dist/utils.cjs +27 -27
  79. package/dist/utils.d.cts +53 -0
  80. package/dist/utils.d.ts +53 -2
  81. package/dist/utils.js +2 -2
  82. package/dist/version-vktVAxhe.d.cts +195 -0
  83. package/dist/version-vktVAxhe.d.ts +195 -0
  84. package/migrations/001_initial_schema.sql +1 -1
  85. package/migrations/002_faq_plugin.sql +86 -0
  86. package/package.json +3 -1
  87. package/dist/chunk-2DIWLDCA.cjs.map +0 -1
  88. package/dist/chunk-AINTFRTC.cjs.map +0 -1
  89. package/dist/chunk-HV2I6API.cjs.map +0 -1
  90. package/dist/chunk-K4Z3IHOK.js.map +0 -1
  91. package/dist/chunk-L232U757.js.map +0 -1
  92. package/dist/chunk-NMVOTNSL.js.map +0 -1
  93. package/dist/chunk-OORGXYDA.js.map +0 -1
  94. package/dist/chunk-R57VFNP3.js.map +0 -1
  95. package/dist/chunk-T7IYBGGO.cjs +0 -746
  96. package/dist/chunk-T7IYBGGO.cjs.map +0 -1
  97. package/dist/chunk-UEYMFNBN.cjs.map +0 -1
  98. package/dist/chunk-WBX5YMTB.cjs.map +0 -1
  99. package/dist/chunk-YTMFJLJZ.cjs.map +0 -1
  100. package/dist/chunk-ZPMFT2JW.js +0 -744
  101. package/dist/chunk-ZPMFT2JW.js.map +0 -1
  102. package/dist/chunk-ZUK55KZB.js.map +0 -1
  103. package/dist/migrations-IHERIQVD.js +0 -4
  104. package/dist/migrations-POFD5KNG.cjs +0 -13
  105. /package/migrations/{021_add_otp_login.sql → 026_add_otp_login.sql} +0 -0
package/dist/services.cjs CHANGED
@@ -1,112 +1,112 @@
1
1
  'use strict';
2
2
 
3
- var chunkAINTFRTC_cjs = require('./chunk-AINTFRTC.cjs');
4
- var chunkHV2I6API_cjs = require('./chunk-HV2I6API.cjs');
5
- var chunkT7IYBGGO_cjs = require('./chunk-T7IYBGGO.cjs');
6
- require('./chunk-WBX5YMTB.cjs');
3
+ var chunkES3BRZQJ_cjs = require('./chunk-ES3BRZQJ.cjs');
4
+ var chunkNAYD76QF_cjs = require('./chunk-NAYD76QF.cjs');
5
+ var chunk23VPL6VI_cjs = require('./chunk-23VPL6VI.cjs');
6
+ require('./chunk-7KCDFDRI.cjs');
7
7
  require('./chunk-IGJUBJBW.cjs');
8
8
 
9
9
 
10
10
 
11
11
  Object.defineProperty(exports, "CACHE_CONFIGS", {
12
12
  enumerable: true,
13
- get: function () { return chunkAINTFRTC_cjs.CACHE_CONFIGS; }
13
+ get: function () { return chunkES3BRZQJ_cjs.CACHE_CONFIGS; }
14
14
  });
15
15
  Object.defineProperty(exports, "CacheService", {
16
16
  enumerable: true,
17
- get: function () { return chunkAINTFRTC_cjs.CacheService; }
17
+ get: function () { return chunkES3BRZQJ_cjs.CacheService; }
18
18
  });
19
19
  Object.defineProperty(exports, "Logger", {
20
20
  enumerable: true,
21
- get: function () { return chunkAINTFRTC_cjs.Logger; }
21
+ get: function () { return chunkES3BRZQJ_cjs.Logger; }
22
22
  });
23
23
  Object.defineProperty(exports, "SettingsService", {
24
24
  enumerable: true,
25
- get: function () { return chunkAINTFRTC_cjs.SettingsService; }
25
+ get: function () { return chunkES3BRZQJ_cjs.SettingsService; }
26
+ });
27
+ Object.defineProperty(exports, "TelemetryService", {
28
+ enumerable: true,
29
+ get: function () { return chunkES3BRZQJ_cjs.TelemetryService; }
30
+ });
31
+ Object.defineProperty(exports, "createInstallationIdentity", {
32
+ enumerable: true,
33
+ get: function () { return chunkES3BRZQJ_cjs.createInstallationIdentity; }
26
34
  });
27
35
  Object.defineProperty(exports, "getCacheService", {
28
36
  enumerable: true,
29
- get: function () { return chunkAINTFRTC_cjs.getCacheService; }
37
+ get: function () { return chunkES3BRZQJ_cjs.getCacheService; }
30
38
  });
31
39
  Object.defineProperty(exports, "getLogger", {
32
40
  enumerable: true,
33
- get: function () { return chunkAINTFRTC_cjs.getLogger; }
41
+ get: function () { return chunkES3BRZQJ_cjs.getLogger; }
34
42
  });
35
- Object.defineProperty(exports, "initLogger", {
43
+ Object.defineProperty(exports, "getTelemetryService", {
36
44
  enumerable: true,
37
- get: function () { return chunkAINTFRTC_cjs.initLogger; }
45
+ get: function () { return chunkES3BRZQJ_cjs.getTelemetryService; }
38
46
  });
39
- Object.defineProperty(exports, "PluginBootstrapService", {
47
+ Object.defineProperty(exports, "initLogger", {
40
48
  enumerable: true,
41
- get: function () { return chunkHV2I6API_cjs.PluginBootstrapService; }
49
+ get: function () { return chunkES3BRZQJ_cjs.initLogger; }
42
50
  });
43
- Object.defineProperty(exports, "PluginService", {
51
+ Object.defineProperty(exports, "initTelemetry", {
44
52
  enumerable: true,
45
- get: function () { return chunkHV2I6API_cjs.PluginService; }
53
+ get: function () { return chunkES3BRZQJ_cjs.initTelemetry; }
46
54
  });
47
- Object.defineProperty(exports, "TelemetryService", {
55
+ Object.defineProperty(exports, "PluginBootstrapService", {
48
56
  enumerable: true,
49
- get: function () { return chunkHV2I6API_cjs.TelemetryService; }
57
+ get: function () { return chunkNAYD76QF_cjs.PluginBootstrapService; }
50
58
  });
51
- Object.defineProperty(exports, "cleanupRemovedCollections", {
59
+ Object.defineProperty(exports, "PluginService", {
52
60
  enumerable: true,
53
- get: function () { return chunkHV2I6API_cjs.cleanupRemovedCollections; }
61
+ get: function () { return chunkNAYD76QF_cjs.PluginService; }
54
62
  });
55
- Object.defineProperty(exports, "createInstallationIdentity", {
63
+ Object.defineProperty(exports, "cleanupRemovedCollections", {
56
64
  enumerable: true,
57
- get: function () { return chunkHV2I6API_cjs.createInstallationIdentity; }
65
+ get: function () { return chunkNAYD76QF_cjs.cleanupRemovedCollections; }
58
66
  });
59
67
  Object.defineProperty(exports, "fullCollectionSync", {
60
68
  enumerable: true,
61
- get: function () { return chunkHV2I6API_cjs.fullCollectionSync; }
69
+ get: function () { return chunkNAYD76QF_cjs.fullCollectionSync; }
62
70
  });
63
71
  Object.defineProperty(exports, "getAvailableCollectionNames", {
64
72
  enumerable: true,
65
- get: function () { return chunkHV2I6API_cjs.getAvailableCollectionNames; }
73
+ get: function () { return chunkNAYD76QF_cjs.getAvailableCollectionNames; }
66
74
  });
67
75
  Object.defineProperty(exports, "getManagedCollections", {
68
76
  enumerable: true,
69
- get: function () { return chunkHV2I6API_cjs.getManagedCollections; }
70
- });
71
- Object.defineProperty(exports, "getTelemetryService", {
72
- enumerable: true,
73
- get: function () { return chunkHV2I6API_cjs.getTelemetryService; }
74
- });
75
- Object.defineProperty(exports, "initTelemetry", {
76
- enumerable: true,
77
- get: function () { return chunkHV2I6API_cjs.initTelemetry; }
77
+ get: function () { return chunkNAYD76QF_cjs.getManagedCollections; }
78
78
  });
79
79
  Object.defineProperty(exports, "isCollectionManaged", {
80
80
  enumerable: true,
81
- get: function () { return chunkHV2I6API_cjs.isCollectionManaged; }
81
+ get: function () { return chunkNAYD76QF_cjs.isCollectionManaged; }
82
82
  });
83
83
  Object.defineProperty(exports, "loadCollectionConfig", {
84
84
  enumerable: true,
85
- get: function () { return chunkHV2I6API_cjs.loadCollectionConfig; }
85
+ get: function () { return chunkNAYD76QF_cjs.loadCollectionConfig; }
86
86
  });
87
87
  Object.defineProperty(exports, "loadCollectionConfigs", {
88
88
  enumerable: true,
89
- get: function () { return chunkHV2I6API_cjs.loadCollectionConfigs; }
89
+ get: function () { return chunkNAYD76QF_cjs.loadCollectionConfigs; }
90
90
  });
91
91
  Object.defineProperty(exports, "registerCollections", {
92
92
  enumerable: true,
93
- get: function () { return chunkHV2I6API_cjs.registerCollections; }
93
+ get: function () { return chunkNAYD76QF_cjs.registerCollections; }
94
94
  });
95
95
  Object.defineProperty(exports, "syncCollection", {
96
96
  enumerable: true,
97
- get: function () { return chunkHV2I6API_cjs.syncCollection; }
97
+ get: function () { return chunkNAYD76QF_cjs.syncCollection; }
98
98
  });
99
99
  Object.defineProperty(exports, "syncCollections", {
100
100
  enumerable: true,
101
- get: function () { return chunkHV2I6API_cjs.syncCollections; }
101
+ get: function () { return chunkNAYD76QF_cjs.syncCollections; }
102
102
  });
103
103
  Object.defineProperty(exports, "validateCollectionConfig", {
104
104
  enumerable: true,
105
- get: function () { return chunkHV2I6API_cjs.validateCollectionConfig; }
105
+ get: function () { return chunkNAYD76QF_cjs.validateCollectionConfig; }
106
106
  });
107
107
  Object.defineProperty(exports, "MigrationService", {
108
108
  enumerable: true,
109
- get: function () { return chunkT7IYBGGO_cjs.MigrationService; }
109
+ get: function () { return chunk23VPL6VI_cjs.MigrationService; }
110
110
  });
111
111
  //# sourceMappingURL=services.cjs.map
112
112
  //# sourceMappingURL=services.cjs.map
@@ -0,0 +1,236 @@
1
+ export { C as CorePlugin, p as LogCategory, q as LogEntry, t as LogFilter, o as LogLevel, L as Logger, m as Migration, M as MigrationService, n as MigrationStatus, k as PluginBootstrapService, P as PluginService, e as cleanupRemovedCollections, f as fullCollectionSync, g as getAvailableCollectionNames, h as getLogger, d as getManagedCollections, j as initLogger, i as isCollectionManaged, a as loadCollectionConfig, l as loadCollectionConfigs, r as registerCollections, c as syncCollection, b as syncCollections, v as validateCollectionConfig } from './plugin-bootstrap-C0E3jdz-.cjs';
2
+ import { b as TelemetryConfig, c as TelemetryIdentity, T as TelemetryEvent, a as TelemetryProperties } from './telemetry-BFBIjBxK.cjs';
3
+ import './collection-config-FLlGtsh9.cjs';
4
+ import '@cloudflare/workers-types';
5
+ import 'drizzle-zod';
6
+ import 'drizzle-orm/sqlite-core';
7
+
8
+ /**
9
+ * Simple Cache Service
10
+ *
11
+ * Provides basic caching functionality for the core package
12
+ * Can be extended with KV or other storage backends
13
+ */
14
+ interface CacheConfig {
15
+ ttl: number;
16
+ keyPrefix: string;
17
+ }
18
+ declare class CacheService {
19
+ private config;
20
+ private memoryCache;
21
+ constructor(config: CacheConfig);
22
+ /**
23
+ * Generate cache key with prefix
24
+ */
25
+ generateKey(type: string, identifier?: string): string;
26
+ /**
27
+ * Get value from cache
28
+ */
29
+ get<T>(key: string): Promise<T | null>;
30
+ /**
31
+ * Get value from cache with source information
32
+ */
33
+ getWithSource<T>(key: string): Promise<{
34
+ hit: boolean;
35
+ data: T | null;
36
+ source: string;
37
+ ttl?: number;
38
+ }>;
39
+ /**
40
+ * Set value in cache
41
+ */
42
+ set(key: string, value: any, ttl?: number): Promise<void>;
43
+ /**
44
+ * Delete specific key from cache
45
+ */
46
+ delete(key: string): Promise<void>;
47
+ /**
48
+ * Invalidate cache keys matching a pattern
49
+ * For memory cache, we do simple string matching
50
+ */
51
+ invalidate(pattern: string): Promise<void>;
52
+ /**
53
+ * Clear all cache
54
+ */
55
+ clear(): Promise<void>;
56
+ /**
57
+ * Get value from cache or set it using a callback
58
+ */
59
+ getOrSet<T>(key: string, callback: () => Promise<T>, ttl?: number): Promise<T>;
60
+ }
61
+ /**
62
+ * Cache configurations for different data types
63
+ */
64
+ declare const CACHE_CONFIGS: {
65
+ api: {
66
+ ttl: number;
67
+ keyPrefix: string;
68
+ };
69
+ user: {
70
+ ttl: number;
71
+ keyPrefix: string;
72
+ };
73
+ content: {
74
+ ttl: number;
75
+ keyPrefix: string;
76
+ };
77
+ collection: {
78
+ ttl: number;
79
+ keyPrefix: string;
80
+ };
81
+ };
82
+ /**
83
+ * Get cache service instance for a config
84
+ */
85
+ declare function getCacheService(config: CacheConfig): CacheService;
86
+
87
+ interface Setting {
88
+ id: string;
89
+ category: string;
90
+ key: string;
91
+ value: string;
92
+ created_at: number;
93
+ updated_at: number;
94
+ }
95
+ interface GeneralSettings {
96
+ siteName: string;
97
+ siteDescription: string;
98
+ adminEmail: string;
99
+ timezone: string;
100
+ language: string;
101
+ maintenanceMode: boolean;
102
+ }
103
+ declare class SettingsService {
104
+ private db;
105
+ constructor(db: D1Database);
106
+ /**
107
+ * Get a setting value by category and key
108
+ */
109
+ getSetting(category: string, key: string): Promise<any | null>;
110
+ /**
111
+ * Get all settings for a category
112
+ */
113
+ getCategorySettings(category: string): Promise<Record<string, any>>;
114
+ /**
115
+ * Set a setting value
116
+ */
117
+ setSetting(category: string, key: string, value: any): Promise<boolean>;
118
+ /**
119
+ * Set multiple settings at once
120
+ */
121
+ setMultipleSettings(category: string, settings: Record<string, any>): Promise<boolean>;
122
+ /**
123
+ * Get general settings with defaults
124
+ */
125
+ getGeneralSettings(userEmail?: string): Promise<GeneralSettings>;
126
+ /**
127
+ * Save general settings
128
+ */
129
+ saveGeneralSettings(settings: Partial<GeneralSettings>): Promise<boolean>;
130
+ }
131
+
132
+ /**
133
+ * Telemetry Service
134
+ *
135
+ * Privacy-first telemetry service using PostHog
136
+ * - No PII collection
137
+ * - Opt-out by default
138
+ * - Silent failures (never blocks app)
139
+ */
140
+
141
+ /**
142
+ * TelemetryService class
143
+ *
144
+ * Handles all telemetry tracking in a privacy-conscious way
145
+ */
146
+ declare class TelemetryService {
147
+ private config;
148
+ private identity;
149
+ private client;
150
+ private enabled;
151
+ private eventQueue;
152
+ private isInitialized;
153
+ constructor(config?: Partial<TelemetryConfig>);
154
+ /**
155
+ * Initialize the telemetry service
156
+ */
157
+ initialize(identity: TelemetryIdentity): Promise<void>;
158
+ /**
159
+ * Track a telemetry event
160
+ */
161
+ track(event: TelemetryEvent, properties?: TelemetryProperties): Promise<void>;
162
+ /**
163
+ * Track installation started
164
+ */
165
+ trackInstallationStarted(properties?: TelemetryProperties): Promise<void>;
166
+ /**
167
+ * Track installation completed
168
+ */
169
+ trackInstallationCompleted(properties?: TelemetryProperties): Promise<void>;
170
+ /**
171
+ * Track installation failed
172
+ */
173
+ trackInstallationFailed(error: Error | string, properties?: TelemetryProperties): Promise<void>;
174
+ /**
175
+ * Track dev server started
176
+ */
177
+ trackDevServerStarted(properties?: TelemetryProperties): Promise<void>;
178
+ /**
179
+ * Track page view in admin UI
180
+ */
181
+ trackPageView(route: string, properties?: TelemetryProperties): Promise<void>;
182
+ /**
183
+ * Track error (sanitized)
184
+ */
185
+ trackError(error: Error | string, properties?: TelemetryProperties): Promise<void>;
186
+ /**
187
+ * Track plugin activation
188
+ */
189
+ trackPluginActivated(properties?: TelemetryProperties): Promise<void>;
190
+ /**
191
+ * Track migration run
192
+ */
193
+ trackMigrationRun(properties?: TelemetryProperties): Promise<void>;
194
+ /**
195
+ * Flush queued events
196
+ */
197
+ private flushQueue;
198
+ /**
199
+ * Sanitize properties to ensure no PII
200
+ */
201
+ private sanitizeProperties;
202
+ /**
203
+ * Get SonicJS version
204
+ */
205
+ private getVersion;
206
+ /**
207
+ * Shutdown the telemetry service
208
+ */
209
+ shutdown(): Promise<void>;
210
+ /**
211
+ * Enable telemetry
212
+ */
213
+ enable(): void;
214
+ /**
215
+ * Disable telemetry
216
+ */
217
+ disable(): void;
218
+ /**
219
+ * Check if telemetry is enabled
220
+ */
221
+ isEnabled(): boolean;
222
+ }
223
+ /**
224
+ * Get the telemetry service instance
225
+ */
226
+ declare function getTelemetryService(config?: Partial<TelemetryConfig>): TelemetryService;
227
+ /**
228
+ * Initialize telemetry service
229
+ */
230
+ declare function initTelemetry(identity: TelemetryIdentity, config?: Partial<TelemetryConfig>): Promise<TelemetryService>;
231
+ /**
232
+ * Create a new installation identity
233
+ */
234
+ declare function createInstallationIdentity(projectName?: string): TelemetryIdentity;
235
+
236
+ export { CACHE_CONFIGS, type CacheConfig, CacheService, type GeneralSettings, type Setting, SettingsService, TelemetryService, createInstallationIdentity, getCacheService, getTelemetryService, initTelemetry };
@@ -1,2 +1,236 @@
1
- // Service exports from core package
2
- export * from '../src/services/index'
1
+ export { C as CorePlugin, p as LogCategory, q as LogEntry, t as LogFilter, o as LogLevel, L as Logger, m as Migration, M as MigrationService, n as MigrationStatus, k as PluginBootstrapService, P as PluginService, e as cleanupRemovedCollections, f as fullCollectionSync, g as getAvailableCollectionNames, h as getLogger, d as getManagedCollections, j as initLogger, i as isCollectionManaged, a as loadCollectionConfig, l as loadCollectionConfigs, r as registerCollections, c as syncCollection, b as syncCollections, v as validateCollectionConfig } from './plugin-bootstrap-CDh0JHtW.js';
2
+ import { b as TelemetryConfig, c as TelemetryIdentity, T as TelemetryEvent, a as TelemetryProperties } from './telemetry-BFBIjBxK.js';
3
+ import './collection-config-FLlGtsh9.js';
4
+ import '@cloudflare/workers-types';
5
+ import 'drizzle-zod';
6
+ import 'drizzle-orm/sqlite-core';
7
+
8
+ /**
9
+ * Simple Cache Service
10
+ *
11
+ * Provides basic caching functionality for the core package
12
+ * Can be extended with KV or other storage backends
13
+ */
14
+ interface CacheConfig {
15
+ ttl: number;
16
+ keyPrefix: string;
17
+ }
18
+ declare class CacheService {
19
+ private config;
20
+ private memoryCache;
21
+ constructor(config: CacheConfig);
22
+ /**
23
+ * Generate cache key with prefix
24
+ */
25
+ generateKey(type: string, identifier?: string): string;
26
+ /**
27
+ * Get value from cache
28
+ */
29
+ get<T>(key: string): Promise<T | null>;
30
+ /**
31
+ * Get value from cache with source information
32
+ */
33
+ getWithSource<T>(key: string): Promise<{
34
+ hit: boolean;
35
+ data: T | null;
36
+ source: string;
37
+ ttl?: number;
38
+ }>;
39
+ /**
40
+ * Set value in cache
41
+ */
42
+ set(key: string, value: any, ttl?: number): Promise<void>;
43
+ /**
44
+ * Delete specific key from cache
45
+ */
46
+ delete(key: string): Promise<void>;
47
+ /**
48
+ * Invalidate cache keys matching a pattern
49
+ * For memory cache, we do simple string matching
50
+ */
51
+ invalidate(pattern: string): Promise<void>;
52
+ /**
53
+ * Clear all cache
54
+ */
55
+ clear(): Promise<void>;
56
+ /**
57
+ * Get value from cache or set it using a callback
58
+ */
59
+ getOrSet<T>(key: string, callback: () => Promise<T>, ttl?: number): Promise<T>;
60
+ }
61
+ /**
62
+ * Cache configurations for different data types
63
+ */
64
+ declare const CACHE_CONFIGS: {
65
+ api: {
66
+ ttl: number;
67
+ keyPrefix: string;
68
+ };
69
+ user: {
70
+ ttl: number;
71
+ keyPrefix: string;
72
+ };
73
+ content: {
74
+ ttl: number;
75
+ keyPrefix: string;
76
+ };
77
+ collection: {
78
+ ttl: number;
79
+ keyPrefix: string;
80
+ };
81
+ };
82
+ /**
83
+ * Get cache service instance for a config
84
+ */
85
+ declare function getCacheService(config: CacheConfig): CacheService;
86
+
87
+ interface Setting {
88
+ id: string;
89
+ category: string;
90
+ key: string;
91
+ value: string;
92
+ created_at: number;
93
+ updated_at: number;
94
+ }
95
+ interface GeneralSettings {
96
+ siteName: string;
97
+ siteDescription: string;
98
+ adminEmail: string;
99
+ timezone: string;
100
+ language: string;
101
+ maintenanceMode: boolean;
102
+ }
103
+ declare class SettingsService {
104
+ private db;
105
+ constructor(db: D1Database);
106
+ /**
107
+ * Get a setting value by category and key
108
+ */
109
+ getSetting(category: string, key: string): Promise<any | null>;
110
+ /**
111
+ * Get all settings for a category
112
+ */
113
+ getCategorySettings(category: string): Promise<Record<string, any>>;
114
+ /**
115
+ * Set a setting value
116
+ */
117
+ setSetting(category: string, key: string, value: any): Promise<boolean>;
118
+ /**
119
+ * Set multiple settings at once
120
+ */
121
+ setMultipleSettings(category: string, settings: Record<string, any>): Promise<boolean>;
122
+ /**
123
+ * Get general settings with defaults
124
+ */
125
+ getGeneralSettings(userEmail?: string): Promise<GeneralSettings>;
126
+ /**
127
+ * Save general settings
128
+ */
129
+ saveGeneralSettings(settings: Partial<GeneralSettings>): Promise<boolean>;
130
+ }
131
+
132
+ /**
133
+ * Telemetry Service
134
+ *
135
+ * Privacy-first telemetry service using PostHog
136
+ * - No PII collection
137
+ * - Opt-out by default
138
+ * - Silent failures (never blocks app)
139
+ */
140
+
141
+ /**
142
+ * TelemetryService class
143
+ *
144
+ * Handles all telemetry tracking in a privacy-conscious way
145
+ */
146
+ declare class TelemetryService {
147
+ private config;
148
+ private identity;
149
+ private client;
150
+ private enabled;
151
+ private eventQueue;
152
+ private isInitialized;
153
+ constructor(config?: Partial<TelemetryConfig>);
154
+ /**
155
+ * Initialize the telemetry service
156
+ */
157
+ initialize(identity: TelemetryIdentity): Promise<void>;
158
+ /**
159
+ * Track a telemetry event
160
+ */
161
+ track(event: TelemetryEvent, properties?: TelemetryProperties): Promise<void>;
162
+ /**
163
+ * Track installation started
164
+ */
165
+ trackInstallationStarted(properties?: TelemetryProperties): Promise<void>;
166
+ /**
167
+ * Track installation completed
168
+ */
169
+ trackInstallationCompleted(properties?: TelemetryProperties): Promise<void>;
170
+ /**
171
+ * Track installation failed
172
+ */
173
+ trackInstallationFailed(error: Error | string, properties?: TelemetryProperties): Promise<void>;
174
+ /**
175
+ * Track dev server started
176
+ */
177
+ trackDevServerStarted(properties?: TelemetryProperties): Promise<void>;
178
+ /**
179
+ * Track page view in admin UI
180
+ */
181
+ trackPageView(route: string, properties?: TelemetryProperties): Promise<void>;
182
+ /**
183
+ * Track error (sanitized)
184
+ */
185
+ trackError(error: Error | string, properties?: TelemetryProperties): Promise<void>;
186
+ /**
187
+ * Track plugin activation
188
+ */
189
+ trackPluginActivated(properties?: TelemetryProperties): Promise<void>;
190
+ /**
191
+ * Track migration run
192
+ */
193
+ trackMigrationRun(properties?: TelemetryProperties): Promise<void>;
194
+ /**
195
+ * Flush queued events
196
+ */
197
+ private flushQueue;
198
+ /**
199
+ * Sanitize properties to ensure no PII
200
+ */
201
+ private sanitizeProperties;
202
+ /**
203
+ * Get SonicJS version
204
+ */
205
+ private getVersion;
206
+ /**
207
+ * Shutdown the telemetry service
208
+ */
209
+ shutdown(): Promise<void>;
210
+ /**
211
+ * Enable telemetry
212
+ */
213
+ enable(): void;
214
+ /**
215
+ * Disable telemetry
216
+ */
217
+ disable(): void;
218
+ /**
219
+ * Check if telemetry is enabled
220
+ */
221
+ isEnabled(): boolean;
222
+ }
223
+ /**
224
+ * Get the telemetry service instance
225
+ */
226
+ declare function getTelemetryService(config?: Partial<TelemetryConfig>): TelemetryService;
227
+ /**
228
+ * Initialize telemetry service
229
+ */
230
+ declare function initTelemetry(identity: TelemetryIdentity, config?: Partial<TelemetryConfig>): Promise<TelemetryService>;
231
+ /**
232
+ * Create a new installation identity
233
+ */
234
+ declare function createInstallationIdentity(projectName?: string): TelemetryIdentity;
235
+
236
+ export { CACHE_CONFIGS, type CacheConfig, CacheService, type GeneralSettings, type Setting, SettingsService, TelemetryService, createInstallationIdentity, getCacheService, getTelemetryService, initTelemetry };
package/dist/services.js CHANGED
@@ -1,7 +1,7 @@
1
- export { CACHE_CONFIGS, CacheService, Logger, SettingsService, getCacheService, getLogger, initLogger } from './chunk-L232U757.js';
2
- export { PluginBootstrapService, PluginService, TelemetryService, cleanupRemovedCollections, createInstallationIdentity, fullCollectionSync, getAvailableCollectionNames, getManagedCollections, getTelemetryService, initTelemetry, isCollectionManaged, loadCollectionConfig, loadCollectionConfigs, registerCollections, syncCollection, syncCollections, validateCollectionConfig } from './chunk-K4Z3IHOK.js';
3
- export { MigrationService } from './chunk-ZPMFT2JW.js';
4
- import './chunk-NMVOTNSL.js';
1
+ export { CACHE_CONFIGS, CacheService, Logger, SettingsService, TelemetryService, createInstallationIdentity, getCacheService, getLogger, getTelemetryService, initLogger, initTelemetry } from './chunk-Q52ZQFMB.js';
2
+ export { PluginBootstrapService, PluginService, cleanupRemovedCollections, fullCollectionSync, getAvailableCollectionNames, getManagedCollections, isCollectionManaged, loadCollectionConfig, loadCollectionConfigs, registerCollections, syncCollection, syncCollections, validateCollectionConfig } from './chunk-7CXL5K7N.js';
3
+ export { MigrationService } from './chunk-3MPQII4R.js';
4
+ import './chunk-RRKXFGIO.js';
5
5
  import './chunk-V4OQ3NZ2.js';
6
6
  //# sourceMappingURL=services.js.map
7
7
  //# sourceMappingURL=services.js.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Telemetry Types
3
+ *
4
+ * Privacy-first telemetry types for SonicJS
5
+ * No PII (Personally Identifiable Information) is collected
6
+ */
7
+ type TelemetryEvent = 'installation_started' | 'installation_completed' | 'installation_failed' | 'setup_wizard_started' | 'setup_wizard_completed' | 'first_dev_server_start' | 'dev_server_started' | 'dev_server_stopped' | 'admin_login' | 'plugin_activated' | 'plugin_deactivated' | 'collection_created' | 'content_created' | 'page_viewed' | 'feature_used' | 'error_occurred' | 'migration_run' | 'deployment_triggered';
8
+ interface TelemetryProperties {
9
+ os?: 'darwin' | 'linux' | 'win32' | string;
10
+ nodeVersion?: string;
11
+ packageManager?: 'npm' | 'yarn' | 'pnpm' | 'bun';
12
+ installationDuration?: number;
13
+ success?: boolean;
14
+ errorType?: string;
15
+ sessionDuration?: number;
16
+ pluginsCount?: number;
17
+ collectionsCount?: number;
18
+ contentItemsCount?: number;
19
+ route?: string;
20
+ feature?: string;
21
+ migrationType?: 'initial' | 'update' | 'rollback';
22
+ migrationSuccess?: boolean;
23
+ [key: string]: string | number | boolean | undefined;
24
+ }
25
+ interface TelemetryConfig {
26
+ enabled: boolean;
27
+ apiKey?: string;
28
+ host?: string;
29
+ debug?: boolean;
30
+ }
31
+ interface TelemetryIdentity {
32
+ installationId: string;
33
+ projectId?: string;
34
+ }
35
+
36
+ export type { TelemetryEvent as T, TelemetryProperties as a, TelemetryConfig as b, TelemetryIdentity as c };