@groundbrick/sveltekit-adapter 0.1.0

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 (96) hide show
  1. package/README.md +554 -0
  2. package/dist/analytics/components/GoogleAnalytics.svelte +96 -0
  3. package/dist/analytics/config/analytics.config.d.ts +6 -0
  4. package/dist/analytics/config/analytics.config.d.ts.map +1 -0
  5. package/dist/analytics/config/analytics.config.js +27 -0
  6. package/dist/analytics/config/analytics.config.js.map +1 -0
  7. package/dist/analytics/index.d.ts +7 -0
  8. package/dist/analytics/index.d.ts.map +1 -0
  9. package/dist/analytics/index.js +9 -0
  10. package/dist/analytics/index.js.map +1 -0
  11. package/dist/analytics/interfaces/IAnalyticsService.d.ts +40 -0
  12. package/dist/analytics/interfaces/IAnalyticsService.d.ts.map +1 -0
  13. package/dist/analytics/interfaces/IAnalyticsService.js +2 -0
  14. package/dist/analytics/interfaces/IAnalyticsService.js.map +1 -0
  15. package/dist/analytics/services/AnalyticsService.d.ts +37 -0
  16. package/dist/analytics/services/AnalyticsService.d.ts.map +1 -0
  17. package/dist/analytics/services/AnalyticsService.js +261 -0
  18. package/dist/analytics/services/AnalyticsService.js.map +1 -0
  19. package/dist/analytics/utils/consent.d.ts +52 -0
  20. package/dist/analytics/utils/consent.d.ts.map +1 -0
  21. package/dist/analytics/utils/consent.js +138 -0
  22. package/dist/analytics/utils/consent.js.map +1 -0
  23. package/dist/auth/index.d.ts +10 -0
  24. package/dist/auth/index.d.ts.map +1 -0
  25. package/dist/auth/index.js +49 -0
  26. package/dist/auth/index.js.map +1 -0
  27. package/dist/client/ApiClient.d.ts +17 -0
  28. package/dist/client/ApiClient.d.ts.map +1 -0
  29. package/dist/client/ApiClient.js +184 -0
  30. package/dist/client/ApiClient.js.map +1 -0
  31. package/dist/client/NotificationComponent.d.ts +7 -0
  32. package/dist/client/NotificationComponent.d.ts.map +1 -0
  33. package/dist/client/NotificationComponent.js +131 -0
  34. package/dist/client/NotificationComponent.js.map +1 -0
  35. package/dist/client/apiWrapper.d.ts +324 -0
  36. package/dist/client/apiWrapper.d.ts.map +1 -0
  37. package/dist/client/apiWrapper.js +257 -0
  38. package/dist/client/apiWrapper.js.map +1 -0
  39. package/dist/client/authErrorHandler.d.ts +19 -0
  40. package/dist/client/authErrorHandler.d.ts.map +1 -0
  41. package/dist/client/authErrorHandler.js +40 -0
  42. package/dist/client/authErrorHandler.js.map +1 -0
  43. package/dist/client/hooks.d.ts +11 -0
  44. package/dist/client/hooks.d.ts.map +1 -0
  45. package/dist/client/hooks.js +28 -0
  46. package/dist/client/hooks.js.map +1 -0
  47. package/dist/client/index.d.ts +8 -0
  48. package/dist/client/index.d.ts.map +1 -0
  49. package/dist/client/index.js +13 -0
  50. package/dist/client/index.js.map +1 -0
  51. package/dist/client/jwtDecoder.d.ts +56 -0
  52. package/dist/client/jwtDecoder.d.ts.map +1 -0
  53. package/dist/client/jwtDecoder.js +114 -0
  54. package/dist/client/jwtDecoder.js.map +1 -0
  55. package/dist/client/notifications.d.ts +55 -0
  56. package/dist/client/notifications.d.ts.map +1 -0
  57. package/dist/client/notifications.js +160 -0
  58. package/dist/client/notifications.js.map +1 -0
  59. package/dist/client/stores.d.ts +26 -0
  60. package/dist/client/stores.d.ts.map +1 -0
  61. package/dist/client/stores.js +196 -0
  62. package/dist/client/stores.js.map +1 -0
  63. package/dist/consent/components/CookieConsent.svelte +580 -0
  64. package/dist/consent/config/consent.config.d.ts +7 -0
  65. package/dist/consent/config/consent.config.d.ts.map +1 -0
  66. package/dist/consent/config/consent.config.js +194 -0
  67. package/dist/consent/config/consent.config.js.map +1 -0
  68. package/dist/consent/index.d.ts +5 -0
  69. package/dist/consent/index.d.ts.map +1 -0
  70. package/dist/consent/index.js +7 -0
  71. package/dist/consent/index.js.map +1 -0
  72. package/dist/consent/interfaces/IConsentService.d.ts +121 -0
  73. package/dist/consent/interfaces/IConsentService.d.ts.map +1 -0
  74. package/dist/consent/interfaces/IConsentService.js +2 -0
  75. package/dist/consent/interfaces/IConsentService.js.map +1 -0
  76. package/dist/consent/services/ConsentService.d.ts +39 -0
  77. package/dist/consent/services/ConsentService.d.ts.map +1 -0
  78. package/dist/consent/services/ConsentService.js +302 -0
  79. package/dist/consent/services/ConsentService.js.map +1 -0
  80. package/dist/consent/utils/analytics.d.ts +52 -0
  81. package/dist/consent/utils/analytics.d.ts.map +1 -0
  82. package/dist/consent/utils/analytics.js +181 -0
  83. package/dist/consent/utils/analytics.js.map +1 -0
  84. package/dist/hooks/index.d.ts +14 -0
  85. package/dist/hooks/index.d.ts.map +1 -0
  86. package/dist/hooks/index.js +218 -0
  87. package/dist/hooks/index.js.map +1 -0
  88. package/dist/index.d.ts +5 -0
  89. package/dist/index.d.ts.map +1 -0
  90. package/dist/index.js +10 -0
  91. package/dist/index.js.map +1 -0
  92. package/dist/types/index.d.ts +88 -0
  93. package/dist/types/index.d.ts.map +1 -0
  94. package/dist/types/index.js +2 -0
  95. package/dist/types/index.js.map +1 -0
  96. package/package.json +87 -0
@@ -0,0 +1,28 @@
1
+ import { navigating } from '$app/stores';
2
+ import { browser } from '$app/environment';
3
+ import { clearNonPersistentNotifications } from './notifications.js';
4
+ /**
5
+ * Hook that automatically clears non-persistent notifications when navigating.
6
+ * Call this function in your app's root layout to enable auto-clearing.
7
+ */
8
+ export function useNavigationNotificationClear() {
9
+ if (!browser)
10
+ return;
11
+ // Subscribe to navigation changes
12
+ navigating.subscribe((navigation) => {
13
+ // Clear non-persistent notifications when starting navigation
14
+ if (navigation && navigation.from) {
15
+ clearNonPersistentNotifications();
16
+ }
17
+ });
18
+ }
19
+ /**
20
+ * Alternative hook that can be used in specific pages/components
21
+ * to clear notifications when the component is mounted
22
+ */
23
+ export function useClearNotificationsOnMount() {
24
+ if (browser) {
25
+ clearNonPersistentNotifications();
26
+ }
27
+ }
28
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/client/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;GAGG;AACH,MAAM,UAAU,8BAA8B;IAC1C,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,kCAAkC;IAClC,UAAU,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EAAE;QAChC,8DAA8D;QAC9D,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;YAChC,+BAA+B,EAAE,CAAC;QACtC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B;IACxC,IAAI,OAAO,EAAE,CAAC;QACV,+BAA+B,EAAE,CAAC;IACtC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { ApiClient, createApiClient } from './ApiClient.js';
2
+ export { authStore, apiStore, currentUser, isLoading, currentError, initializeStores, initializeAuth, initializeFromJwt, initializeFromToken, clearErrors, } from './stores.js';
3
+ export { decodeJwtToken, safeDecodeJwt, hasPermission, hasAnyPermission, hasAllPermissions, getUserDisplayName, getAdditionalFields, type JwtPayload, type DecodedJwt } from './jwtDecoder.js';
4
+ export { notificationStore, notifications, errorNotifications, successNotifications, warningNotifications, infoNotifications, latestError, latestSuccess, hasNotifications, hasErrors, hasSuccess, showSuccess, showError, showWarning, showInfo, clearAllNotifications, clearNotificationsByType, clearNonPersistentNotifications, removeNotification } from './notifications.js';
5
+ export { useNavigationNotificationClear, useClearNotificationsOnMount } from './hooks.js';
6
+ export { authErrorHandler, handleAuthError, } from './authErrorHandler.js';
7
+ export { ApiWrapper, createApiWrapper, type ApiWrapperOptions } from './apiWrapper.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,QAAQ,EACR,qBAAqB,EACrB,wBAAwB,EACxB,+BAA+B,EAC/B,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { ApiClient, createApiClient } from './ApiClient.js';
2
+ export { authStore, apiStore, currentUser, isLoading, currentError, initializeStores, initializeAuth, initializeFromJwt, initializeFromToken, clearErrors, } from './stores.js';
3
+ // Export JWT decoder utilities
4
+ export { decodeJwtToken, safeDecodeJwt, hasPermission, hasAnyPermission, hasAllPermissions, getUserDisplayName, getAdditionalFields } from './jwtDecoder.js';
5
+ // Export new notification system
6
+ export { notificationStore, notifications, errorNotifications, successNotifications, warningNotifications, infoNotifications, latestError, latestSuccess, hasNotifications, hasErrors, hasSuccess, showSuccess, showError, showWarning, showInfo, clearAllNotifications, clearNotificationsByType, clearNonPersistentNotifications, removeNotification } from './notifications.js';
7
+ // Export navigation hooks
8
+ export { useNavigationNotificationClear, useClearNotificationsOnMount } from './hooks.js';
9
+ // Export API error handling
10
+ export { authErrorHandler, handleAuthError, } from './authErrorHandler.js';
11
+ // Export API wrapper utility
12
+ export { ApiWrapper, createApiWrapper } from './apiWrapper.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,+BAA+B;AAC/B,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EAGpB,MAAM,iBAAiB,CAAC;AAEzB,iCAAiC;AACjC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,QAAQ,EACR,qBAAqB,EACrB,wBAAwB,EACxB,+BAA+B,EAC/B,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,0BAA0B;AAC1B,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAEpB,4BAA4B;AAC5B,OAAO,EACL,gBAAgB,EAChB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,6BAA6B;AAC7B,OAAO,EACL,UAAU,EACV,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,56 @@
1
+ export interface JwtPayload {
2
+ userId: number;
3
+ email: string;
4
+ role: string;
5
+ permissions: string[];
6
+ name?: string;
7
+ iat?: number;
8
+ exp?: number;
9
+ [key: string]: any;
10
+ }
11
+ export interface DecodedJwt {
12
+ payload: JwtPayload;
13
+ isValid: boolean;
14
+ isExpired: boolean;
15
+ expiresAt?: Date;
16
+ }
17
+ /**
18
+ * Safely decode JWT token client-side without verification
19
+ * This only decodes the payload - server-side verification is still required for security
20
+ */
21
+ export declare function decodeJwtToken(token: string): DecodedJwt | null;
22
+ /**
23
+ * Get JWT token from HTTP-only cookie (server-side only) or return null
24
+ * In browser, this will return null as HTTP-only cookies are not accessible
25
+ */
26
+ export declare function getAuthTokenFromCookie(): string | null;
27
+ /**
28
+ * Check if user has specific permission based on role hierarchy
29
+ * - staff: check permissions array
30
+ * - admin: has all permissions for their petshop
31
+ * - super_admin: has all permissions everywhere
32
+ * - customer: has no admin permissions
33
+ TODO: REMOVE ANY REFERENCE TO FIXED ROLES - MAKE IT GENERIC
34
+ */
35
+ export declare function hasPermission(payload: JwtPayload, permission: string): boolean;
36
+ /**
37
+ * Check if user has any of the specified permissions
38
+ */
39
+ export declare function hasAnyPermission(payload: JwtPayload, permissions: string[]): boolean;
40
+ /**
41
+ * Check if user has all of the specified permissions
42
+ */
43
+ export declare function hasAllPermissions(payload: JwtPayload, permissions: string[]): boolean;
44
+ /**
45
+ * Extract user display name from JWT payload
46
+ */
47
+ export declare function getUserDisplayName(payload: JwtPayload): string;
48
+ /**
49
+ * Get additional fields from JWT payload (application-specific data)
50
+ */
51
+ export declare function getAdditionalFields(payload: JwtPayload): Record<string, any>;
52
+ /**
53
+ * Utility to safely decode and validate JWT token with error handling
54
+ */
55
+ export declare function safeDecodeJwt(token: string | null | undefined): DecodedJwt | null;
56
+ //# sourceMappingURL=jwtDecoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwtDecoder.d.ts","sourceRoot":"","sources":["../../src/client/jwtDecoder.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAkC/D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAStD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAiB9E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAEpF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAErF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAE9D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAG5E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAiBjF"}
@@ -0,0 +1,114 @@
1
+ import { browser } from '$app/environment';
2
+ /**
3
+ * Safely decode JWT token client-side without verification
4
+ * This only decodes the payload - server-side verification is still required for security
5
+ */
6
+ export function decodeJwtToken(token) {
7
+ try {
8
+ // JWT has 3 parts separated by dots: header.payload.signature
9
+ const parts = token.split('.');
10
+ if (parts.length !== 3) {
11
+ return null;
12
+ }
13
+ // Decode the payload (middle part)
14
+ const payload = parts[1];
15
+ // Add padding if needed for base64 decoding
16
+ const paddedPayload = payload + '='.repeat((4 - payload.length % 4) % 4);
17
+ // Decode base64
18
+ const decoded = atob(paddedPayload);
19
+ const parsedPayload = JSON.parse(decoded);
20
+ // Check if token is expired
21
+ const now = Math.floor(Date.now() / 1000);
22
+ const isExpired = parsedPayload.exp ? parsedPayload.exp < now : false;
23
+ const expiresAt = parsedPayload.exp ? new Date(parsedPayload.exp * 1000) : undefined;
24
+ return {
25
+ payload: parsedPayload,
26
+ isValid: true,
27
+ isExpired,
28
+ expiresAt
29
+ };
30
+ }
31
+ catch (error) {
32
+ console.warn('Failed to decode JWT token:', error);
33
+ return null;
34
+ }
35
+ }
36
+ /**
37
+ * Get JWT token from HTTP-only cookie (server-side only) or return null
38
+ * In browser, this will return null as HTTP-only cookies are not accessible
39
+ */
40
+ export function getAuthTokenFromCookie() {
41
+ if (!browser) {
42
+ // Server-side: would need to pass from server context
43
+ return null;
44
+ }
45
+ // Client-side: HTTP-only cookies are not accessible via document.cookie
46
+ // Token should be available through server-side rendering or API calls
47
+ return null;
48
+ }
49
+ /**
50
+ * Check if user has specific permission based on role hierarchy
51
+ * - staff: check permissions array
52
+ * - admin: has all permissions for their petshop
53
+ * - super_admin: has all permissions everywhere
54
+ * - customer: has no admin permissions
55
+ TODO: REMOVE ANY REFERENCE TO FIXED ROLES - MAKE IT GENERIC
56
+ */
57
+ export function hasPermission(payload, permission) {
58
+ if (!payload)
59
+ return false;
60
+ switch (payload.role) {
61
+ case 'super_admin':
62
+ return true; // Super admin has all permissions
63
+ case 'admin':
64
+ return true; // Admin has all permissions in their petshop
65
+ case 'staff':
66
+ return payload.permissions?.includes(permission) || false;
67
+ case 'customer':
68
+ default:
69
+ return false; // Customers have no admin permissions
70
+ }
71
+ }
72
+ /**
73
+ * Check if user has any of the specified permissions
74
+ */
75
+ export function hasAnyPermission(payload, permissions) {
76
+ return permissions.some(permission => hasPermission(payload, permission));
77
+ }
78
+ /**
79
+ * Check if user has all of the specified permissions
80
+ */
81
+ export function hasAllPermissions(payload, permissions) {
82
+ return permissions.every(permission => hasPermission(payload, permission));
83
+ }
84
+ /**
85
+ * Extract user display name from JWT payload
86
+ */
87
+ export function getUserDisplayName(payload) {
88
+ return payload.name || payload.email || 'User';
89
+ }
90
+ /**
91
+ * Get additional fields from JWT payload (application-specific data)
92
+ */
93
+ export function getAdditionalFields(payload) {
94
+ const { userId, email, role, permissions, name, iat, exp, ...additionalFields } = payload;
95
+ return additionalFields;
96
+ }
97
+ /**
98
+ * Utility to safely decode and validate JWT token with error handling
99
+ */
100
+ export function safeDecodeJwt(token) {
101
+ if (!token || typeof token !== 'string') {
102
+ return null;
103
+ }
104
+ const decoded = decodeJwtToken(token);
105
+ if (!decoded || !decoded.isValid) {
106
+ return null;
107
+ }
108
+ if (decoded.isExpired) {
109
+ console.debug('JWT token is expired');
110
+ return decoded; // Return expired token info for proper handling
111
+ }
112
+ return decoded;
113
+ }
114
+ //# sourceMappingURL=jwtDecoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwtDecoder.js","sourceRoot":"","sources":["../../src/client/jwtDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAqB3C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IACxC,IAAI,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,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAC1F,OAAO,gBAAgB,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAgC;IAC1D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC,CAAC,gDAAgD;IACpE,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { type Writable, type Readable } from 'svelte/store';
2
+ import type { Notification, NotificationStore, NotificationType, NotificationOptions } from '../types/index.js';
3
+ export declare const notificationStore: Writable<NotificationStore> & {
4
+ add: (type: NotificationType, message: string, options?: NotificationOptions) => string;
5
+ remove: (id: string) => void;
6
+ clear: (type?: NotificationType) => void;
7
+ clearNonPersistent: () => void;
8
+ success: (message: string, options?: NotificationOptions) => string;
9
+ error: (message: string, options?: NotificationOptions) => string;
10
+ warning: (message: string, options?: NotificationOptions) => string;
11
+ info: (message: string, options?: NotificationOptions) => string;
12
+ };
13
+ export declare const notifications: Readable<Notification[]>;
14
+ export declare const errorNotifications: Readable<Notification[]>;
15
+ export declare const successNotifications: Readable<Notification[]>;
16
+ export declare const warningNotifications: Readable<Notification[]>;
17
+ export declare const infoNotifications: Readable<Notification[]>;
18
+ export declare const latestError: Readable<Notification | null>;
19
+ export declare const latestSuccess: Readable<Notification | null>;
20
+ export declare const hasNotifications: Readable<boolean>;
21
+ export declare const hasErrors: Readable<boolean>;
22
+ export declare const hasSuccess: Readable<boolean>;
23
+ /**
24
+ * Show a success notification
25
+ */
26
+ export declare function showSuccess(message: string, options?: NotificationOptions): string;
27
+ /**
28
+ * Show an error notification
29
+ */
30
+ export declare function showError(message: string, options?: NotificationOptions): string;
31
+ /**
32
+ * Show a warning notification
33
+ */
34
+ export declare function showWarning(message: string, options?: NotificationOptions): string;
35
+ /**
36
+ * Show an info notification
37
+ */
38
+ export declare function showInfo(message: string, options?: NotificationOptions): string;
39
+ /**
40
+ * Clear all notifications
41
+ */
42
+ export declare function clearAllNotifications(): void;
43
+ /**
44
+ * Clear notifications by type
45
+ */
46
+ export declare function clearNotificationsByType(type: NotificationType): void;
47
+ /**
48
+ * Clear non-persistent notifications (called on navigation)
49
+ */
50
+ export declare function clearNonPersistentNotifications(): void;
51
+ /**
52
+ * Remove specific notification by ID
53
+ */
54
+ export declare function removeNotification(id: string): void;
55
+ //# sourceMappingURL=notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/client/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAsHhH,eAAO,MAAM,iBAAiB;SA/GrB,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM;YAC/E,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI;WACrB,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,IAAI;wBACpB,MAAM,IAAI;aACrB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM;WAC5D,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,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,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAE/E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEnD"}
@@ -0,0 +1,160 @@
1
+ import { writable, derived } from 'svelte/store';
2
+ // ============================================================================
3
+ // NOTIFICATION STORE
4
+ // ============================================================================
5
+ function createNotificationStore() {
6
+ const { subscribe, set, update } = writable({
7
+ notifications: []
8
+ });
9
+ // Auto-dismiss timer map
10
+ const timers = new Map();
11
+ function generateId() {
12
+ return `notification-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
13
+ }
14
+ function scheduleAutoDismiss(id, duration) {
15
+ if (duration > 0) {
16
+ const timer = window.setTimeout(() => {
17
+ remove(id);
18
+ }, duration);
19
+ timers.set(id, timer);
20
+ }
21
+ }
22
+ function clearTimer(id) {
23
+ const timer = timers.get(id);
24
+ if (timer) {
25
+ clearTimeout(timer);
26
+ timers.delete(id);
27
+ }
28
+ }
29
+ function add(type, message, options = {}) {
30
+ const id = generateId();
31
+ const duration = options.duration ?? (type === 'error' ? 8000 : 5000); // Errors show longer
32
+ const notification = {
33
+ id,
34
+ type,
35
+ message,
36
+ title: options.title,
37
+ duration,
38
+ persistent: options.persistent ?? false,
39
+ timestamp: Date.now()
40
+ };
41
+ update(state => ({
42
+ notifications: [...state.notifications, notification]
43
+ }));
44
+ scheduleAutoDismiss(id, duration);
45
+ return id;
46
+ }
47
+ function remove(id) {
48
+ clearTimer(id);
49
+ update(state => ({
50
+ notifications: state.notifications.filter(n => n.id !== id)
51
+ }));
52
+ }
53
+ function clear(type) {
54
+ update(state => {
55
+ // Clear timers for notifications being removed
56
+ const toRemove = type
57
+ ? state.notifications.filter(n => n.type === type)
58
+ : state.notifications;
59
+ toRemove.forEach(n => clearTimer(n.id));
60
+ return {
61
+ notifications: type
62
+ ? state.notifications.filter(n => n.type !== type)
63
+ : []
64
+ };
65
+ });
66
+ }
67
+ function clearNonPersistent() {
68
+ update(state => {
69
+ // Clear timers for non-persistent notifications
70
+ const toRemove = state.notifications.filter(n => !n.persistent);
71
+ toRemove.forEach(n => clearTimer(n.id));
72
+ return {
73
+ notifications: state.notifications.filter(n => n.persistent)
74
+ };
75
+ });
76
+ }
77
+ return {
78
+ subscribe,
79
+ set,
80
+ update,
81
+ add,
82
+ remove,
83
+ clear,
84
+ clearNonPersistent,
85
+ success: (message, options) => add('success', message, options),
86
+ error: (message, options) => add('error', message, options),
87
+ warning: (message, options) => add('warning', message, options),
88
+ info: (message, options) => add('info', message, options)
89
+ };
90
+ }
91
+ export const notificationStore = createNotificationStore();
92
+ // ============================================================================
93
+ // DERIVED STORES
94
+ // ============================================================================
95
+ // Get all notifications
96
+ export const notifications = derived(notificationStore, $store => $store.notifications);
97
+ // Get notifications by type
98
+ export const errorNotifications = derived(notifications, $notifications => $notifications.filter(n => n.type === 'error'));
99
+ export const successNotifications = derived(notifications, $notifications => $notifications.filter(n => n.type === 'success'));
100
+ export const warningNotifications = derived(notifications, $notifications => $notifications.filter(n => n.type === 'warning'));
101
+ export const infoNotifications = derived(notifications, $notifications => $notifications.filter(n => n.type === 'info'));
102
+ // Get latest notification by type
103
+ export const latestError = derived(errorNotifications, $errors => $errors.length > 0 ? $errors[$errors.length - 1] : null);
104
+ export const latestSuccess = derived(successNotifications, $success => $success.length > 0 ? $success[$success.length - 1] : null);
105
+ // Check if there are any notifications
106
+ export const hasNotifications = derived(notifications, $notifications => $notifications.length > 0);
107
+ export const hasErrors = derived(errorNotifications, $errors => $errors.length > 0);
108
+ export const hasSuccess = derived(successNotifications, $success => $success.length > 0);
109
+ // ============================================================================
110
+ // UTILITY FUNCTIONS
111
+ // ============================================================================
112
+ /**
113
+ * Show a success notification
114
+ */
115
+ export function showSuccess(message, options) {
116
+ return notificationStore.success(message, options);
117
+ }
118
+ /**
119
+ * Show an error notification
120
+ */
121
+ export function showError(message, options) {
122
+ return notificationStore.error(message, options);
123
+ }
124
+ /**
125
+ * Show a warning notification
126
+ */
127
+ export function showWarning(message, options) {
128
+ return notificationStore.warning(message, options);
129
+ }
130
+ /**
131
+ * Show an info notification
132
+ */
133
+ export function showInfo(message, options) {
134
+ return notificationStore.info(message, options);
135
+ }
136
+ /**
137
+ * Clear all notifications
138
+ */
139
+ export function clearAllNotifications() {
140
+ notificationStore.clear();
141
+ }
142
+ /**
143
+ * Clear notifications by type
144
+ */
145
+ export function clearNotificationsByType(type) {
146
+ notificationStore.clear(type);
147
+ }
148
+ /**
149
+ * Clear non-persistent notifications (called on navigation)
150
+ */
151
+ export function clearNonPersistentNotifications() {
152
+ notificationStore.clearNonPersistent();
153
+ }
154
+ /**
155
+ * Remove specific notification by ID
156
+ */
157
+ export function removeNotification(id) {
158
+ notificationStore.remove(id);
159
+ }
160
+ //# sourceMappingURL=notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/client/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAgC,MAAM,cAAc,CAAC;AAG/E,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,SAAS,uBAAuB;IAU5B,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAoB;QAC3D,aAAa,EAAE,EAAE;KACpB,CAAC,CAAC;IAEH,yBAAyB;IACzB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,SAAS,UAAU;QACf,OAAO,gBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,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AAoB,EACpB,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAClC,CAAC;AAEF,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,OAA6B;IACtE,OAAO,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,OAA6B;IACpE,OAAO,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,OAA6B;IACtE,OAAO,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,OAA6B;IACnE,OAAO,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACjC,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAsB;IAC3D,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B;IAC3C,iBAAiB,CAAC,kBAAkB,EAAE,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU;IACzC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type Writable, type Readable } from 'svelte/store';
2
+ import type { AuthStore, ApiStore } from '../types/index.js';
3
+ import { type JwtPayload } from './jwtDecoder.js';
4
+ export declare const authStore: Writable<AuthStore> & {
5
+ login: (user: Record<string, unknown>) => void;
6
+ logout: () => void;
7
+ setLoading: (loading: boolean) => void;
8
+ setError: (error: string | null) => void;
9
+ initialize: () => void;
10
+ initializeFromJwt: (jwtPayload: JwtPayload) => void;
11
+ initializeFromToken: (token: string) => boolean;
12
+ };
13
+ export declare const apiStore: Writable<ApiStore> & {
14
+ setLoading: (loading: boolean) => void;
15
+ setError: (error: string | null) => void;
16
+ setLastRequest: (request: string | null) => void;
17
+ };
18
+ export declare const currentUser: Readable<Record<string, unknown> | null>;
19
+ export declare const isLoading: Readable<boolean>;
20
+ export declare const currentError: Readable<string | null>;
21
+ export declare function initializeStores(): void;
22
+ export declare function clearErrors(): void;
23
+ export declare function initializeAuth(apiClient: any): Promise<void>;
24
+ export declare function initializeFromJwt(jwtPayload: JwtPayload): void;
25
+ export declare function initializeFromToken(token: string): boolean;
26
+ //# sourceMappingURL=stores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../../src/client/stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEpF,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA6IjE,eAAO,MAAM,SAAS;WAtIX,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI;YACtC,MAAM,IAAI;gBACN,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI;cAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI;gBAC5B,MAAM,IAAI;uBACH,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI;yBAC9B,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO;CAgIT,CAAC;AAoC3C,eAAO,MAAM,QA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