@revealui/core 0.3.0 → 0.5.2

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 (155) hide show
  1. package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -1
  2. package/dist/client/admin/components/AdminDashboard.js +20 -3
  3. package/dist/client/richtext/index.d.ts.map +1 -1
  4. package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
  5. package/dist/collections/operations/create.d.ts +2 -1
  6. package/dist/collections/operations/create.d.ts.map +1 -1
  7. package/dist/collections/operations/create.js +28 -1
  8. package/dist/database/type-adapter.d.ts.map +1 -1
  9. package/dist/features.d.ts +13 -3
  10. package/dist/features.d.ts.map +1 -1
  11. package/dist/features.js +17 -0
  12. package/dist/globals/GlobalOperations.d.ts.map +1 -1
  13. package/dist/globals/GlobalOperations.js +12 -2
  14. package/dist/index.d.ts +11 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +11 -1
  17. package/dist/license.d.ts +6 -0
  18. package/dist/license.d.ts.map +1 -1
  19. package/dist/license.js +14 -1
  20. package/dist/monitoring/alerts.d.ts +4 -4
  21. package/dist/monitoring/alerts.d.ts.map +1 -1
  22. package/dist/plugins/nested-docs.d.ts.map +1 -1
  23. package/dist/plugins/nested-docs.js +0 -1
  24. package/dist/queries/queryBuilder.d.ts.map +1 -1
  25. package/dist/queries/queryBuilder.js +4 -3
  26. package/dist/richtext/index.d.ts.map +1 -1
  27. package/dist/storage/vercel-blob.d.ts.map +1 -1
  28. package/dist/storage/vercel-blob.js +3 -0
  29. package/dist/types/api.d.ts.map +1 -1
  30. package/dist/types/config.d.ts.map +1 -1
  31. package/dist/types/core.d.ts +1 -1
  32. package/dist/types/core.d.ts.map +1 -1
  33. package/dist/types/extensions.d.ts.map +1 -1
  34. package/dist/types/frontend.d.ts.map +1 -1
  35. package/dist/types/legacy.d.ts.map +1 -1
  36. package/dist/types/query.d.ts.map +1 -1
  37. package/dist/types/runtime.d.ts +1 -0
  38. package/dist/types/runtime.d.ts.map +1 -1
  39. package/dist/utils/error-responses.d.ts.map +1 -1
  40. package/dist/utils/error-responses.js +2 -3
  41. package/package.json +24 -24
  42. package/dist/caching/app-cache.d.ts +0 -242
  43. package/dist/caching/app-cache.d.ts.map +0 -1
  44. package/dist/caching/app-cache.js +0 -438
  45. package/dist/caching/cdn-config.d.ts +0 -155
  46. package/dist/caching/cdn-config.d.ts.map +0 -1
  47. package/dist/caching/cdn-config.js +0 -415
  48. package/dist/caching/edge-cache.d.ts +0 -177
  49. package/dist/caching/edge-cache.d.ts.map +0 -1
  50. package/dist/caching/edge-cache.js +0 -414
  51. package/dist/caching/service-worker.d.ts +0 -157
  52. package/dist/caching/service-worker.d.ts.map +0 -1
  53. package/dist/caching/service-worker.js +0 -438
  54. package/dist/client/admin/utils/auth.d.ts +0 -23
  55. package/dist/client/admin/utils/auth.d.ts.map +0 -1
  56. package/dist/client/admin/utils/auth.js +0 -52
  57. package/dist/client/http/client.d.ts +0 -15
  58. package/dist/client/http/client.d.ts.map +0 -1
  59. package/dist/client/http/client.js +0 -49
  60. package/dist/client/http/fetchBanner.d.ts +0 -18
  61. package/dist/client/http/fetchBanner.d.ts.map +0 -1
  62. package/dist/client/http/fetchBanner.js +0 -44
  63. package/dist/client/http/fetchCard.d.ts +0 -18
  64. package/dist/client/http/fetchCard.d.ts.map +0 -1
  65. package/dist/client/http/fetchCard.js +0 -46
  66. package/dist/client/http/fetchEvents.d.ts +0 -18
  67. package/dist/client/http/fetchEvents.d.ts.map +0 -1
  68. package/dist/client/http/fetchEvents.js +0 -44
  69. package/dist/client/http/fetchHero.d.ts +0 -17
  70. package/dist/client/http/fetchHero.d.ts.map +0 -1
  71. package/dist/client/http/fetchHero.js +0 -55
  72. package/dist/client/http/fetchMainInfos.d.ts +0 -17
  73. package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
  74. package/dist/client/http/fetchMainInfos.js +0 -44
  75. package/dist/client/http/fetchVideos.d.ts +0 -13
  76. package/dist/client/http/fetchVideos.d.ts.map +0 -1
  77. package/dist/client/http/fetchVideos.js +0 -36
  78. package/dist/client/http/index.d.ts +0 -19
  79. package/dist/client/http/index.d.ts.map +0 -1
  80. package/dist/client/http/index.js +0 -11
  81. package/dist/error-handling/circuit-breaker.d.ts +0 -262
  82. package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
  83. package/dist/error-handling/circuit-breaker.js +0 -550
  84. package/dist/error-handling/retry.d.ts +0 -194
  85. package/dist/error-handling/retry.d.ts.map +0 -1
  86. package/dist/error-handling/retry.js +0 -455
  87. package/dist/errors/index.d.ts +0 -23
  88. package/dist/errors/index.d.ts.map +0 -1
  89. package/dist/errors/index.js +0 -40
  90. package/dist/generated/agents/index.d.ts +0 -8
  91. package/dist/generated/agents/index.d.ts.map +0 -1
  92. package/dist/generated/agents/index.js +0 -7
  93. package/dist/generated/components/index.d.ts +0 -8
  94. package/dist/generated/components/index.d.ts.map +0 -1
  95. package/dist/generated/components/index.js +0 -7
  96. package/dist/generated/functions/index.d.ts +0 -8
  97. package/dist/generated/functions/index.d.ts.map +0 -1
  98. package/dist/generated/functions/index.js +0 -7
  99. package/dist/generated/hooks/index.d.ts +0 -8
  100. package/dist/generated/hooks/index.d.ts.map +0 -1
  101. package/dist/generated/hooks/index.js +0 -7
  102. package/dist/generated/plans/index.d.ts +0 -8
  103. package/dist/generated/plans/index.d.ts.map +0 -1
  104. package/dist/generated/plans/index.js +0 -7
  105. package/dist/generated/prompts/index.d.ts +0 -8
  106. package/dist/generated/prompts/index.d.ts.map +0 -1
  107. package/dist/generated/prompts/index.js +0 -7
  108. package/dist/generated/tools/index.d.ts +0 -8
  109. package/dist/generated/tools/index.d.ts.map +0 -1
  110. package/dist/generated/tools/index.js +0 -7
  111. package/dist/generated/types/supabase.d.ts +0 -193
  112. package/dist/generated/types/supabase.d.ts.map +0 -1
  113. package/dist/generated/types/supabase.js +0 -5
  114. package/dist/optimization/asset-optimizer.d.ts +0 -206
  115. package/dist/optimization/asset-optimizer.d.ts.map +0 -1
  116. package/dist/optimization/asset-optimizer.js +0 -336
  117. package/dist/optimization/build-optimizer.d.ts +0 -202
  118. package/dist/optimization/build-optimizer.d.ts.map +0 -1
  119. package/dist/optimization/build-optimizer.js +0 -271
  120. package/dist/optimization/bundle-analyzer.d.ts +0 -98
  121. package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
  122. package/dist/optimization/bundle-analyzer.js +0 -346
  123. package/dist/optimization/code-splitting.d.ts +0 -121
  124. package/dist/optimization/code-splitting.d.ts.map +0 -1
  125. package/dist/optimization/code-splitting.js +0 -261
  126. package/dist/plugin/index.d.ts +0 -12
  127. package/dist/plugin/index.d.ts.map +0 -1
  128. package/dist/plugin/index.js +0 -4
  129. package/dist/security/audit.d.ts +0 -188
  130. package/dist/security/audit.d.ts.map +0 -1
  131. package/dist/security/audit.js +0 -433
  132. package/dist/security/auth.d.ts +0 -110
  133. package/dist/security/auth.d.ts.map +0 -1
  134. package/dist/security/auth.js +0 -257
  135. package/dist/security/authorization.d.ts +0 -211
  136. package/dist/security/authorization.d.ts.map +0 -1
  137. package/dist/security/authorization.js +0 -492
  138. package/dist/security/encryption.d.ts +0 -226
  139. package/dist/security/encryption.d.ts.map +0 -1
  140. package/dist/security/encryption.js +0 -534
  141. package/dist/security/gdpr-storage.d.ts +0 -102
  142. package/dist/security/gdpr-storage.d.ts.map +0 -1
  143. package/dist/security/gdpr-storage.js +0 -65
  144. package/dist/security/gdpr.d.ts +0 -320
  145. package/dist/security/gdpr.d.ts.map +0 -1
  146. package/dist/security/gdpr.js +0 -531
  147. package/dist/security/headers.d.ts +0 -184
  148. package/dist/security/headers.d.ts.map +0 -1
  149. package/dist/security/headers.js +0 -420
  150. package/dist/utils/jwt-validation.d.ts +0 -14
  151. package/dist/utils/jwt-validation.d.ts.map +0 -1
  152. package/dist/utils/jwt-validation.js +0 -36
  153. package/dist/utils/request-headers.d.ts +0 -15
  154. package/dist/utils/request-headers.d.ts.map +0 -1
  155. package/dist/utils/request-headers.js +0 -31
@@ -1,438 +0,0 @@
1
- /**
2
- * Service Worker Utilities
3
- *
4
- * Utilities for service worker registration, caching strategies, and offline support
5
- */
6
- import { logger } from '../observability/logger.js';
7
- export const DEFAULT_SW_CONFIG = {
8
- scope: '/',
9
- updateViaCache: 'none',
10
- scriptURL: '/sw.js',
11
- };
12
- /**
13
- * Register service worker
14
- */
15
- export async function registerServiceWorker(config = DEFAULT_SW_CONFIG) {
16
- if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
17
- logger.warn('Service workers are not supported');
18
- return null;
19
- }
20
- try {
21
- const { scriptURL = '/sw.js', scope, updateViaCache } = config;
22
- const registration = await navigator.serviceWorker.register(scriptURL, {
23
- scope,
24
- updateViaCache,
25
- });
26
- logger.info('Service worker registered', { scope: registration.scope });
27
- // Check for updates
28
- registration.addEventListener('updatefound', () => {
29
- const newWorker = registration.installing;
30
- if (newWorker) {
31
- newWorker.addEventListener('statechange', () => {
32
- if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
33
- // New service worker available
34
- logger.info('New service worker available');
35
- // Trigger update notification
36
- window.dispatchEvent(new CustomEvent('sw-update-available', {
37
- detail: { registration },
38
- }));
39
- }
40
- });
41
- }
42
- });
43
- return registration;
44
- }
45
- catch (error) {
46
- logger.error('Service worker registration failed', error instanceof Error ? error : new Error(String(error)));
47
- return null;
48
- }
49
- }
50
- /**
51
- * Unregister service worker
52
- */
53
- export async function unregisterServiceWorker() {
54
- if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
55
- return false;
56
- }
57
- try {
58
- const registration = await navigator.serviceWorker.ready;
59
- return registration.unregister();
60
- }
61
- catch (error) {
62
- logger.error('Service worker unregistration failed', error instanceof Error ? error : new Error(String(error)));
63
- return false;
64
- }
65
- }
66
- /**
67
- * Update service worker
68
- */
69
- export async function updateServiceWorker() {
70
- if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
71
- return;
72
- }
73
- try {
74
- const registration = await navigator.serviceWorker.ready;
75
- await registration.update();
76
- }
77
- catch (error) {
78
- logger.error('Service worker update failed', error instanceof Error ? error : new Error(String(error)));
79
- }
80
- }
81
- /**
82
- * Skip waiting and activate new service worker
83
- */
84
- export async function skipWaitingAndActivate() {
85
- if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
86
- return;
87
- }
88
- const registration = await navigator.serviceWorker.ready;
89
- const waiting = registration.waiting;
90
- if (waiting) {
91
- // Tell service worker to skip waiting
92
- waiting.postMessage({ type: 'SKIP_WAITING' });
93
- // Reload when new service worker takes control
94
- navigator.serviceWorker.addEventListener('controllerchange', () => {
95
- window.location.reload();
96
- });
97
- }
98
- }
99
- /**
100
- * Cache Strategies
101
- */
102
- export const CACHE_STRATEGIES = {
103
- // Network first, fallback to cache
104
- networkFirst: 'network-first',
105
- // Cache first, fallback to network
106
- cacheFirst: 'cache-first',
107
- // Network only
108
- networkOnly: 'network-only',
109
- // Cache only
110
- cacheOnly: 'cache-only',
111
- // Stale while revalidate
112
- staleWhileRevalidate: 'stale-while-revalidate',
113
- };
114
- /**
115
- * Default cache configurations
116
- */
117
- export const DEFAULT_CACHES = {
118
- static: {
119
- name: 'static-assets',
120
- version: 1,
121
- maxAge: 31536000, // 1 year
122
- maxEntries: 100,
123
- strategy: CACHE_STRATEGIES.cacheFirst,
124
- },
125
- images: {
126
- name: 'images',
127
- version: 1,
128
- maxAge: 2592000, // 30 days
129
- maxEntries: 50,
130
- strategy: CACHE_STRATEGIES.cacheFirst,
131
- },
132
- api: {
133
- name: 'api',
134
- version: 1,
135
- maxAge: 300, // 5 minutes
136
- maxEntries: 50,
137
- strategy: CACHE_STRATEGIES.networkFirst,
138
- },
139
- pages: {
140
- name: 'pages',
141
- version: 1,
142
- maxAge: 3600, // 1 hour
143
- maxEntries: 20,
144
- strategy: CACHE_STRATEGIES.staleWhileRevalidate,
145
- },
146
- };
147
- /**
148
- * Generate cache name
149
- */
150
- export function generateCacheName(config) {
151
- return `${config.name}-v${config.version}`;
152
- }
153
- /**
154
- * Service worker message types
155
- */
156
- export const SW_MESSAGES = {
157
- SKIP_WAITING: 'SKIP_WAITING',
158
- CLAIM_CLIENTS: 'CLAIM_CLIENTS',
159
- CLEAR_CACHE: 'CLEAR_CACHE',
160
- CACHE_URLS: 'CACHE_URLS',
161
- DELETE_CACHE: 'DELETE_CACHE',
162
- GET_CACHE_SIZE: 'GET_CACHE_SIZE',
163
- };
164
- /**
165
- * Post message to service worker
166
- */
167
- export async function postMessageToSW(type, payload) {
168
- if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
169
- throw new Error('Service workers not supported');
170
- }
171
- const registration = await navigator.serviceWorker.ready;
172
- const sw = registration.active;
173
- if (!sw) {
174
- throw new Error('No active service worker');
175
- }
176
- return new Promise((resolve, reject) => {
177
- const messageChannel = new MessageChannel();
178
- messageChannel.port1.onmessage = (event) => {
179
- if (event.data.error) {
180
- reject(new Error(event.data.error));
181
- }
182
- else {
183
- resolve(event.data);
184
- }
185
- };
186
- sw.postMessage({ type, payload }, [messageChannel.port2]);
187
- });
188
- }
189
- /**
190
- * Clear all caches
191
- */
192
- export async function clearAllCaches() {
193
- try {
194
- await postMessageToSW(SW_MESSAGES.CLEAR_CACHE);
195
- }
196
- catch (error) {
197
- logger.error('Failed to clear caches', error instanceof Error ? error : new Error(String(error)));
198
- }
199
- }
200
- /**
201
- * Clear specific cache
202
- */
203
- export async function clearCache(cacheName) {
204
- try {
205
- await postMessageToSW(SW_MESSAGES.DELETE_CACHE, { cacheName });
206
- }
207
- catch (error) {
208
- logger.error('Failed to clear cache', error instanceof Error ? error : new Error(String(error)), { cacheName });
209
- }
210
- }
211
- /**
212
- * Precache URLs
213
- */
214
- export async function precacheURLs(urls) {
215
- try {
216
- await postMessageToSW(SW_MESSAGES.CACHE_URLS, { urls });
217
- }
218
- catch (error) {
219
- logger.error('Failed to precache URLs', error instanceof Error ? error : new Error(String(error)));
220
- }
221
- }
222
- /**
223
- * Get cache size
224
- */
225
- export async function getCacheSize() {
226
- if (typeof navigator === 'undefined' || !navigator.storage?.estimate) {
227
- return { quota: 0, usage: 0, available: 0 };
228
- }
229
- try {
230
- const estimate = await navigator.storage.estimate();
231
- const quota = estimate.quota || 0;
232
- const usage = estimate.usage || 0;
233
- const available = quota - usage;
234
- return { quota, usage, available };
235
- }
236
- catch (error) {
237
- logger.error('Failed to get cache size', error instanceof Error ? error : new Error(String(error)));
238
- return { quota: 0, usage: 0, available: 0 };
239
- }
240
- }
241
- /**
242
- * Check if service worker is supported
243
- */
244
- export function isServiceWorkerSupported() {
245
- return typeof window !== 'undefined' && 'serviceWorker' in navigator;
246
- }
247
- /**
248
- * Check if service worker is registered
249
- */
250
- export async function isServiceWorkerRegistered() {
251
- if (!isServiceWorkerSupported()) {
252
- return false;
253
- }
254
- try {
255
- const registration = await navigator.serviceWorker.getRegistration();
256
- return registration !== undefined;
257
- }
258
- catch {
259
- return false;
260
- }
261
- }
262
- /**
263
- * Get service worker state
264
- */
265
- export async function getServiceWorkerState() {
266
- if (!isServiceWorkerSupported()) {
267
- return {
268
- registered: false,
269
- installing: false,
270
- waiting: false,
271
- active: false,
272
- controller: false,
273
- };
274
- }
275
- try {
276
- const registration = await navigator.serviceWorker.getRegistration();
277
- if (!registration) {
278
- return {
279
- registered: false,
280
- installing: false,
281
- waiting: false,
282
- active: false,
283
- controller: false,
284
- };
285
- }
286
- return {
287
- registered: true,
288
- installing: registration.installing !== null,
289
- waiting: registration.waiting !== null,
290
- active: registration.active !== null,
291
- controller: navigator.serviceWorker.controller !== null,
292
- };
293
- }
294
- catch {
295
- return {
296
- registered: false,
297
- installing: false,
298
- waiting: false,
299
- active: false,
300
- controller: false,
301
- };
302
- }
303
- }
304
- /**
305
- * Create service worker helper with registration, update, and state methods.
306
- * Not a React hook — safe to call conditionally or outside components.
307
- */
308
- export function createServiceWorkerHelper(config) {
309
- if (typeof window === 'undefined') {
310
- return {
311
- register: async () => null,
312
- unregister: async () => false,
313
- update: async () => { },
314
- skipWaitingAndActivate: async () => { },
315
- state: Promise.resolve({
316
- registered: false,
317
- installing: false,
318
- waiting: false,
319
- active: false,
320
- controller: false,
321
- }),
322
- };
323
- }
324
- return {
325
- register: () => registerServiceWorker(config),
326
- unregister: unregisterServiceWorker,
327
- update: updateServiceWorker,
328
- skipWaitingAndActivate,
329
- state: getServiceWorkerState(),
330
- };
331
- }
332
- /**
333
- * Offline detection
334
- */
335
- export function isOffline() {
336
- return typeof navigator !== 'undefined' && !navigator.onLine;
337
- }
338
- /**
339
- * Listen for online/offline events
340
- */
341
- export function onNetworkChange(callback) {
342
- if (typeof window === 'undefined') {
343
- return () => { };
344
- }
345
- const handleOnline = () => callback(true);
346
- const handleOffline = () => callback(false);
347
- window.addEventListener('online', handleOnline);
348
- window.addEventListener('offline', handleOffline);
349
- return () => {
350
- window.removeEventListener('online', handleOnline);
351
- window.removeEventListener('offline', handleOffline);
352
- };
353
- }
354
- /**
355
- * Background sync registration
356
- */
357
- export async function registerBackgroundSync(tag) {
358
- if (!isServiceWorkerSupported()) {
359
- throw new Error('Service workers not supported');
360
- }
361
- const registration = await navigator.serviceWorker.ready;
362
- if (!('sync' in registration)) {
363
- throw new Error('Background sync not supported');
364
- }
365
- try {
366
- // @ts-expect-error - sync API not in types yet
367
- await registration.sync.register(tag);
368
- }
369
- catch (error) {
370
- logger.error('Background sync registration failed', error instanceof Error ? error : new Error(String(error)));
371
- throw error;
372
- }
373
- }
374
- /**
375
- * Push notification permission
376
- */
377
- export async function requestNotificationPermission() {
378
- if (typeof window === 'undefined' || !('Notification' in window)) {
379
- throw new Error('Notifications not supported');
380
- }
381
- return Notification.requestPermission();
382
- }
383
- /**
384
- * Subscribe to push notifications
385
- */
386
- export async function subscribeToPush(vapidPublicKey) {
387
- if (!isServiceWorkerSupported()) {
388
- throw new Error('Service workers not supported');
389
- }
390
- const registration = await navigator.serviceWorker.ready;
391
- if (!('pushManager' in registration)) {
392
- throw new Error('Push notifications not supported');
393
- }
394
- try {
395
- const subscription = await registration.pushManager.subscribe({
396
- userVisibleOnly: true,
397
- applicationServerKey: urlBase64ToUint8Array(vapidPublicKey),
398
- });
399
- return subscription;
400
- }
401
- catch (error) {
402
- logger.error('Push subscription failed', error instanceof Error ? error : new Error(String(error)));
403
- return null;
404
- }
405
- }
406
- /**
407
- * Unsubscribe from push notifications
408
- */
409
- export async function unsubscribeFromPush() {
410
- if (!isServiceWorkerSupported()) {
411
- return false;
412
- }
413
- try {
414
- const registration = await navigator.serviceWorker.ready;
415
- const subscription = await registration.pushManager.getSubscription();
416
- if (subscription) {
417
- return subscription.unsubscribe();
418
- }
419
- return false;
420
- }
421
- catch (error) {
422
- logger.error('Push unsubscription failed', error instanceof Error ? error : new Error(String(error)));
423
- return false;
424
- }
425
- }
426
- /**
427
- * Convert VAPID key
428
- */
429
- function urlBase64ToUint8Array(base64String) {
430
- const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
431
- const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');
432
- const rawData = window.atob(base64);
433
- const outputArray = new Uint8Array(rawData.length);
434
- for (let i = 0; i < rawData.length; ++i) {
435
- outputArray[i] = rawData.charCodeAt(i);
436
- }
437
- return outputArray;
438
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Authentication utilities for admin dashboard
3
- * Handles JWT token retrieval and management
4
- */
5
- /**
6
- * Get JWT token from cookies or localStorage
7
- * Priority: cookies > localStorage
8
- */
9
- export declare function getAuthToken(): string | null;
10
- /**
11
- * Set JWT token in localStorage
12
- * Note: Cookies are set server-side, this is for client-side fallback
13
- */
14
- export declare function setAuthToken(token: string): void;
15
- /**
16
- * Remove JWT token from storage
17
- */
18
- export declare function clearAuthToken(): void;
19
- /**
20
- * Get Authorization header value
21
- */
22
- export declare function getAuthHeader(): string | null;
23
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/client/admin/utils/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAoB5C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIhD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAG7C"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Authentication utilities for admin dashboard
3
- * Handles JWT token retrieval and management
4
- */
5
- /**
6
- * Get JWT token from cookies or localStorage
7
- * Priority: cookies > localStorage
8
- */
9
- export function getAuthToken() {
10
- // Try to get from cookies first (server-side compatible)
11
- if (typeof document !== 'undefined') {
12
- const cookies = document.cookie.split(';');
13
- const tokenCookie = cookies.find((cookie) => {
14
- // Defensive check: cookie might be undefined or empty
15
- if (!cookie || typeof cookie !== 'string') {
16
- return false;
17
- }
18
- return cookie.trim().startsWith('revealui-token=');
19
- });
20
- if (tokenCookie) {
21
- return tokenCookie.split('=')[1]?.trim() || null;
22
- }
23
- // Fallback to localStorage
24
- return localStorage.getItem('revealui-token');
25
- }
26
- return null;
27
- }
28
- /**
29
- * Set JWT token in localStorage
30
- * Note: Cookies are set server-side, this is for client-side fallback
31
- */
32
- export function setAuthToken(token) {
33
- if (typeof localStorage !== 'undefined') {
34
- localStorage.setItem('revealui-token', token);
35
- }
36
- }
37
- /**
38
- * Remove JWT token from storage
39
- */
40
- export function clearAuthToken() {
41
- if (typeof localStorage !== 'undefined') {
42
- localStorage.removeItem('revealui-token');
43
- }
44
- // Note: Cookie clearing should be done server-side
45
- }
46
- /**
47
- * Get Authorization header value
48
- */
49
- export function getAuthHeader() {
50
- const token = getAuthToken();
51
- return token ? `JWT ${token}` : null;
52
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Base API client for fetching data from RevealUI CMS
3
- * Uses environment variables to determine CMS URL
4
- */
5
- export interface FetchOptions extends RequestInit {
6
- params?: Record<string, string | number | boolean>;
7
- }
8
- /**
9
- * Base function to fetch data from CMS API
10
- * @param endpoint - API endpoint path (e.g., '/api/collections/pages')
11
- * @param options - Fetch options including query parameters
12
- * @returns Promise with parsed JSON response
13
- */
14
- export declare function fetchFromCMS<T>(endpoint: string, options?: FetchOptions): Promise<T>;
15
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/http/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;CACnD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAyB1F"}
@@ -1,49 +0,0 @@
1
- /**
2
- * Base API client for fetching data from RevealUI CMS
3
- * Uses environment variables to determine CMS URL
4
- */
5
- // Client-side (browser) - Vite exposes VITE_* prefixed env vars
6
- const getClientCMSURL = () => {
7
- if (typeof window === 'undefined')
8
- return 'http://localhost:4000';
9
- // Vite only exposes VITE_* prefixed variables to client
10
- // Use type assertion for import.meta.env which is available in Vite environments
11
- const env = import.meta.env;
12
- return env?.VITE_CMS_URL || env?.VITE_REVEALUI_PUBLIC_SERVER_URL || 'http://localhost:4000';
13
- };
14
- // Server-side (Node.js) - Can access all process.env variables
15
- const getServerCMSURL = () => {
16
- return (process.env.NEXT_PUBLIC_CMS_URL ||
17
- process.env.REVEALUI_PUBLIC_SERVER_URL ||
18
- process.env.VITE_CMS_URL || // Fallback for SSR
19
- 'http://localhost:4000');
20
- };
21
- const CMS_URL = typeof window !== 'undefined' ? getClientCMSURL() : getServerCMSURL();
22
- /**
23
- * Base function to fetch data from CMS API
24
- * @param endpoint - API endpoint path (e.g., '/api/collections/pages')
25
- * @param options - Fetch options including query parameters
26
- * @returns Promise with parsed JSON response
27
- */
28
- export async function fetchFromCMS(endpoint, options) {
29
- const { params, ...fetchOptions } = options || {};
30
- // Build URL with query parameters
31
- const url = new URL(endpoint, CMS_URL);
32
- if (params) {
33
- Object.entries(params).forEach(([key, value]) => {
34
- url.searchParams.append(key, String(value));
35
- });
36
- }
37
- const response = await fetch(url.toString(), {
38
- ...fetchOptions,
39
- headers: {
40
- 'Content-Type': 'application/json',
41
- ...fetchOptions.headers,
42
- },
43
- });
44
- if (!response.ok) {
45
- const errorText = await response.text().catch(() => 'Unknown error');
46
- throw new Error(`CMS API error: ${response.status} ${response.statusText} - ${errorText}`);
47
- }
48
- return (await response.json());
49
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Fetch banners from CMS
3
- * Returns banners from the 'banners' collection
4
- */
5
- export interface BannerData {
6
- id: number;
7
- title?: string;
8
- description?: string;
9
- image?: string;
10
- link?: string;
11
- alt?: string;
12
- }
13
- /**
14
- * Fetches banners from CMS
15
- * Maps Banner collection data to BannerData format
16
- */
17
- export default function fetchBanner(): Promise<BannerData[]>;
18
- //# sourceMappingURL=fetchBanner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchBanner.d.ts","sourceRoot":"","sources":["../../../src/client/http/fetchBanner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,wBAA8B,WAAW,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAgDjE"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Fetch banners from CMS
3
- * Returns banners from the 'banners' collection
4
- */
5
- import { logger } from '@revealui/core/utils/logger';
6
- import { fetchFromCMS } from './client.js';
7
- /**
8
- * Fetches banners from CMS
9
- * Maps Banner collection data to BannerData format
10
- */
11
- export default async function fetchBanner() {
12
- try {
13
- const response = await fetchFromCMS('/api/collections/banners', {
14
- params: {
15
- depth: 1,
16
- limit: 10,
17
- },
18
- });
19
- return (response.docs || []).map((doc) => {
20
- // Extract image URL
21
- let imageUrl = '';
22
- if (doc.image) {
23
- if (typeof doc.image === 'object' && 'url' in doc.image) {
24
- imageUrl = doc.image.url || '';
25
- }
26
- else if (typeof doc.image === 'string') {
27
- imageUrl = doc.image;
28
- }
29
- }
30
- return {
31
- id: doc.id,
32
- title: doc.title || undefined,
33
- description: doc.description || undefined,
34
- image: imageUrl || undefined,
35
- link: doc.link || undefined,
36
- alt: doc.alt || undefined,
37
- };
38
- });
39
- }
40
- catch (error) {
41
- logger.error('Error fetching banners', { error });
42
- return [];
43
- }
44
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Fetch cards from CMS
3
- * Returns cards from the 'cards' collection
4
- */
5
- export interface CardData {
6
- name: string;
7
- image: string;
8
- label: string;
9
- cta: string;
10
- href: string;
11
- loading?: 'eager' | 'lazy';
12
- }
13
- /**
14
- * Fetches cards from CMS
15
- * Maps Card collection data to CardData format
16
- */
17
- export default function fetchCard(): Promise<CardData[]>;
18
- //# sourceMappingURL=fetchCard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchCard.d.ts","sourceRoot":"","sources":["../../../src/client/http/fetchCard.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAC3B;AAED;;;GAGG;AACH,wBAA8B,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAmD7D"}