@noatgnu/cupcake-core 1.0.0 → 1.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.
package/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { InjectionToken, OnInit, ModuleWithProviders } from '@angular/core';
3
3
  import * as rxjs from 'rxjs';
4
- import { Observable } from 'rxjs';
4
+ import { Observable, Subject, BehaviorSubject } from 'rxjs';
5
5
  import * as i3 from '@angular/common/http';
6
6
  import { HttpClient, HttpParams, HttpInterceptorFn } from '@angular/common/http';
7
+ import * as _noatgnu_cupcake_core from '@noatgnu/cupcake-core';
7
8
  import * as i4 from '@angular/router';
8
9
  import { CanActivateFn } from '@angular/router';
9
- import * as _noatgnu_cupcake_core from '@noatgnu/cupcake-core';
10
10
  import * as i2 from '@angular/forms';
11
11
  import { FormGroup } from '@angular/forms';
12
12
  import * as i1 from '@angular/common';
@@ -667,25 +667,6 @@ declare class BaseApiService {
667
667
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<BaseApiService>;
668
668
  }
669
669
 
670
- declare class SiteConfigService extends BaseApiService {
671
- private readonly defaultConfig;
672
- private configSubject;
673
- config$: Observable<SiteConfig>;
674
- constructor();
675
- private loadConfig;
676
- private fetchConfigFromBackend;
677
- getCurrentConfig(): Observable<SiteConfig>;
678
- updateConfig(config: Partial<SiteConfig>): Observable<SiteConfig>;
679
- getSiteName(): string;
680
- shouldShowPoweredBy(): boolean;
681
- getLogoUrl(): string | null;
682
- getPrimaryColor(): string;
683
- isRegistrationEnabled(): boolean;
684
- isOrcidLoginEnabled(): boolean;
685
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiteConfigService, never>;
686
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<SiteConfigService>;
687
- }
688
-
689
670
  interface ToastMessage {
690
671
  id: string;
691
672
  message: string;
@@ -708,6 +689,81 @@ declare class ToastService {
708
689
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<ToastService>;
709
690
  }
710
691
 
692
+ interface NotificationItem {
693
+ id: string;
694
+ type: string;
695
+ title: string;
696
+ message: string;
697
+ timestamp: Date;
698
+ read: boolean;
699
+ level?: 'info' | 'success' | 'warning' | 'error';
700
+ actions?: NotificationAction[];
701
+ autoClose?: boolean;
702
+ data?: any;
703
+ }
704
+ interface NotificationAction {
705
+ label: string;
706
+ action: string;
707
+ style?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger';
708
+ }
709
+ declare class NotificationService {
710
+ protected toastService: ToastService;
711
+ private notifications;
712
+ private notificationSubject;
713
+ readonly allNotifications: _angular_core.Signal<NotificationItem[]>;
714
+ readonly unreadNotifications: _angular_core.Signal<NotificationItem[]>;
715
+ readonly unreadCount: _angular_core.Signal<number>;
716
+ readonly notification$: rxjs.Observable<NotificationItem>;
717
+ constructor(toastService: ToastService);
718
+ protected addNotification(notification: NotificationItem): void;
719
+ protected generateNotificationId(): string;
720
+ markAsRead(notificationId: string): void;
721
+ markAllAsRead(): void;
722
+ removeNotification(notificationId: string): void;
723
+ clearAll(): void;
724
+ clearRead(): void;
725
+ createLocalNotification(type: string, title: string, message: string, level?: 'info' | 'success' | 'warning' | 'error', autoClose?: boolean): void;
726
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NotificationService, never>;
727
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<NotificationService>;
728
+ }
729
+
730
+ declare class SiteConfigService extends BaseApiService {
731
+ private readonly defaultConfig;
732
+ private configSubject;
733
+ config$: Observable<SiteConfig>;
734
+ constructor();
735
+ private loadConfig;
736
+ private fetchConfigFromBackend;
737
+ getCurrentConfig(): Observable<SiteConfig>;
738
+ updateConfig(config: Partial<SiteConfig>): Observable<SiteConfig>;
739
+ getSiteName(): string;
740
+ shouldShowPoweredBy(): boolean;
741
+ getLogoUrl(): string | null;
742
+ getPrimaryColor(): string;
743
+ isRegistrationEnabled(): boolean;
744
+ isOrcidLoginEnabled(): boolean;
745
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiteConfigService, never>;
746
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<SiteConfigService>;
747
+ }
748
+
749
+ type Theme = 'light' | 'dark' | 'auto';
750
+ declare class ThemeService {
751
+ private readonly THEME_KEY;
752
+ private readonly mediaQuery;
753
+ private _theme;
754
+ readonly theme: _angular_core.Signal<Theme>;
755
+ readonly isDark: _angular_core.Signal<boolean>;
756
+ constructor();
757
+ setTheme(theme: Theme): void;
758
+ toggleTheme(): void;
759
+ private loadStoredTheme;
760
+ private updateDocumentTheme;
761
+ getThemeIcon(): string;
762
+ getThemeLabel(): string;
763
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ThemeService, never>;
764
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ThemeService>;
765
+ }
766
+
711
767
  declare class UserManagementService {
712
768
  private apiService;
713
769
  private authService;
@@ -772,6 +828,93 @@ declare class ResourceService {
772
828
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<ResourceService>;
773
829
  }
774
830
 
831
+ declare const WEBSOCKET_ENDPOINT: InjectionToken<string>;
832
+ interface WebSocketMessage {
833
+ type: string;
834
+ message?: string;
835
+ timestamp?: string;
836
+ [key: string]: any;
837
+ }
838
+ interface WebSocketConfig {
839
+ url: string;
840
+ endpoint?: string;
841
+ protocols?: string[];
842
+ reconnectInterval?: number;
843
+ maxReconnectAttempts?: number;
844
+ pingInterval?: number;
845
+ }
846
+ declare class WebSocketService {
847
+ protected authService: AuthService;
848
+ protected ws: WebSocket | null;
849
+ protected config: WebSocketConfig;
850
+ protected destroy$: Subject<void>;
851
+ protected reconnectAttempts: number;
852
+ protected isConnecting: boolean;
853
+ protected connectionState: _angular_core.WritableSignal<"error" | "disconnected" | "connecting" | "connected">;
854
+ protected lastError: _angular_core.WritableSignal<string | null>;
855
+ protected messageSubject: Subject<WebSocketMessage>;
856
+ protected connectionSubject: BehaviorSubject<boolean>;
857
+ readonly messages$: Observable<WebSocketMessage>;
858
+ readonly isConnected$: Observable<boolean>;
859
+ readonly connectionState$: _angular_core.Signal<"error" | "disconnected" | "connecting" | "connected">;
860
+ readonly lastError$: _angular_core.Signal<string | null>;
861
+ protected config_token: _noatgnu_cupcake_core.CupcakeCoreConfig;
862
+ protected endpoint: string;
863
+ constructor(authService: AuthService);
864
+ protected getWebSocketUrl(): string;
865
+ connect(): void;
866
+ disconnect(): void;
867
+ send(message: any): void;
868
+ subscribe(subscriptionType: string, options?: any): void;
869
+ protected onOpen(event: Event): void;
870
+ protected onMessage(event: MessageEvent): void;
871
+ protected onError(event: Event): void;
872
+ protected onClose(event: CloseEvent): void;
873
+ protected attemptReconnection(): void;
874
+ filterMessages<T extends WebSocketMessage>(type: string): Observable<T>;
875
+ getNotifications(): Observable<WebSocketMessage>;
876
+ getSystemNotifications(): Observable<WebSocketMessage>;
877
+ reconnectWithNewToken(): void;
878
+ shouldConnect(): boolean;
879
+ updateConfig(): void;
880
+ ngOnDestroy(): void;
881
+ protected getAdaptiveReconnectInterval(): number;
882
+ protected estimateTabCount(): number;
883
+ protected canConnectSafely(): boolean;
884
+ protected setupBrowserResourceHandling(): void;
885
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<WebSocketService, never>;
886
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<WebSocketService>;
887
+ }
888
+
889
+ interface WebSocketEndpointConfig {
890
+ app: string;
891
+ endpoint: string;
892
+ description?: string;
893
+ }
894
+ declare const WEBSOCKET_ENDPOINTS: InjectionToken<WebSocketEndpointConfig[]>;
895
+ declare class WebSocketEndpoints {
896
+ static readonly CORE_NOTIFICATIONS = "notifications";
897
+ static readonly CORE_ADMIN = "admin";
898
+ static readonly CCV_NOTIFICATIONS = "ccv/notifications";
899
+ static readonly CCV_ADMIN = "ccv/admin";
900
+ static readonly CCM_NOTIFICATIONS = "ccm/notifications";
901
+ static readonly CCRV_NOTIFICATIONS = "ccrv/notifications";
902
+ static readonly CCSC_NOTIFICATIONS = "ccsc/notifications";
903
+ }
904
+ declare class WebSocketConfigService {
905
+ private readonly endpoints;
906
+ constructor();
907
+ private registerDefaultEndpoints;
908
+ registerEndpoint(config: WebSocketEndpointConfig): void;
909
+ getEndpoint(endpoint: string): WebSocketEndpointConfig | undefined;
910
+ getEndpointsForApp(app: string): WebSocketEndpointConfig[];
911
+ getAllEndpoints(): WebSocketEndpointConfig[];
912
+ validateEndpoint(endpoint: string): boolean;
913
+ getDefaultEndpointForApp(app: string): string;
914
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<WebSocketConfigService, never>;
915
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<WebSocketConfigService>;
916
+ }
917
+
775
918
  interface LabGroupQueryParams {
776
919
  search?: string;
777
920
  limit?: number;
@@ -837,6 +980,10 @@ declare class LoginComponent implements OnInit {
837
980
  constructor();
838
981
  private returnUrl;
839
982
  ngOnInit(): void;
983
+ /**
984
+ * Clean return URL to prevent accumulating login URLs
985
+ */
986
+ private cleanReturnUrl;
840
987
  /**
841
988
  * Load authentication configuration to determine available login options
842
989
  */
@@ -873,7 +1020,7 @@ declare class LoginComponent implements OnInit {
873
1020
  */
874
1021
  goToRegister(): void;
875
1022
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<LoginComponent, never>;
876
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<LoginComponent, "app-login", never, {}, {}, never, never, true, never>;
1023
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<LoginComponent, "ccc-login", never, {}, {}, never, never, true, never>;
877
1024
  }
878
1025
 
879
1026
  declare class RegisterComponent implements OnInit {
@@ -934,7 +1081,7 @@ declare class RegisterComponent implements OnInit {
934
1081
  isRegistrationDisabled: _angular_core.Signal<boolean>;
935
1082
  canSubmitForm: _angular_core.Signal<boolean>;
936
1083
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<RegisterComponent, never>;
937
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<RegisterComponent, "app-register", never, {}, {}, never, never, true, never>;
1084
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<RegisterComponent, "ccc-register", never, {}, {}, never, never, true, never>;
938
1085
  }
939
1086
 
940
1087
  declare class UserManagementComponent implements OnInit {
@@ -989,7 +1136,7 @@ declare class UserManagementComponent implements OnInit {
989
1136
  formatDate(dateString?: string): string;
990
1137
  getUserDisplayName(user: User): string;
991
1138
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserManagementComponent, never>;
992
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserManagementComponent, "app-user-management", never, {}, {}, never, never, true, never>;
1139
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserManagementComponent, "ccc-user-management", never, {}, {}, never, never, true, never>;
993
1140
  }
994
1141
 
995
1142
  declare class LabGroupsComponent implements OnInit {
@@ -1045,7 +1192,7 @@ declare class LabGroupsComponent implements OnInit {
1045
1192
  private refreshLabGroups;
1046
1193
  closeGroupDetails(): void;
1047
1194
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<LabGroupsComponent, never>;
1048
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<LabGroupsComponent, "app-lab-groups", never, {}, {}, never, never, true, never>;
1195
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<LabGroupsComponent, "ccc-lab-groups", never, {}, {}, never, never, true, never>;
1049
1196
  }
1050
1197
 
1051
1198
  declare class UserProfileComponent implements OnInit {
@@ -1078,7 +1225,7 @@ declare class UserProfileComponent implements OnInit {
1078
1225
  setActiveTab(tab: 'profile' | 'password' | 'email' | 'account'): void;
1079
1226
  private passwordMatchValidator;
1080
1227
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserProfileComponent, never>;
1081
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserProfileComponent, "app-user-profile", never, {}, {}, never, never, true, never>;
1228
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserProfileComponent, "ccc-user-profile", never, {}, {}, never, never, true, never>;
1082
1229
  }
1083
1230
 
1084
1231
  declare class SiteConfigComponent implements OnInit {
@@ -1131,37 +1278,26 @@ declare class SiteConfigComponent implements OnInit {
1131
1278
  */
1132
1279
  clearLogoFile(): void;
1133
1280
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiteConfigComponent, never>;
1134
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiteConfigComponent, "app-site-config", never, {}, {}, never, never, true, never>;
1281
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiteConfigComponent, "ccc-site-config", never, {}, {}, never, never, true, never>;
1135
1282
  }
1136
1283
 
1137
1284
  declare class ToastContainerComponent {
1138
1285
  private toastService;
1139
- /**
1140
- * Signal containing all active toast messages
1141
- */
1286
+ private cdr;
1142
1287
  toasts: _angular_core.Signal<ToastMessage[]>;
1143
- /**
1144
- * Computed signal that maps toast types to their CSS classes
1145
- */
1146
- private toastClassMap;
1147
- /**
1148
- * Computed signal that maps toast types to their Bootstrap icons
1149
- */
1150
- private toastIconMap;
1151
- /**
1152
- * Removes a toast message from the service
1153
- */
1288
+ constructor();
1154
1289
  remove(toast: ToastMessage): void;
1155
- /**
1156
- * Gets the CSS class for a toast based on its type
1157
- */
1158
1290
  getToastClass(type: string): string;
1159
- /**
1160
- * Gets the Bootstrap icon class for a toast based on its type
1161
- */
1162
1291
  getToastIcon(type: string): string;
1163
1292
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<ToastContainerComponent, never>;
1164
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<ToastContainerComponent, "app-toast-container", never, {}, {}, never, never, true, never>;
1293
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ToastContainerComponent, "ccc-toast-container", never, {}, {}, never, never, true, never>;
1294
+ }
1295
+
1296
+ declare class PoweredByFooterComponent {
1297
+ private siteConfigService;
1298
+ siteConfig$: rxjs.Observable<_noatgnu_cupcake_core.SiteConfig>;
1299
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<PoweredByFooterComponent, never>;
1300
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<PoweredByFooterComponent, "ccc-powered-by-footer", never, {}, {}, never, never, true, never>;
1165
1301
  }
1166
1302
 
1167
1303
  declare class CupcakeCoreModule {
@@ -1171,5 +1307,5 @@ declare class CupcakeCoreModule {
1171
1307
  static ɵinj: _angular_core.ɵɵInjectorDeclaration<CupcakeCoreModule>;
1172
1308
  }
1173
1309
 
1174
- export { ApiService, AuthService, BaseApiService, CUPCAKE_CORE_CONFIG, CupcakeCoreModule, InvitationStatus, InvitationStatusLabels, LabGroupService, LabGroupsComponent, LoginComponent, RegisterComponent, ResourceRole, ResourceRoleLabels, ResourceService, ResourceType, ResourceTypeLabels, ResourceVisibility, ResourceVisibilityLabels, SiteConfigComponent, SiteConfigService, ToastContainerComponent, ToastService, UserManagementComponent, UserManagementService, UserProfileComponent, adminGuard, authGuard, authInterceptor };
1175
- export type { AccountMergeRequest, AdminPasswordResetRequest, Annotation, AnnotationCreateRequest, AnnotationFolder, AnnotationFolderCreateRequest, AnnotationFolderUpdateRequest, AnnotationUpdateRequest, ApiResponse, AuthConfig, AuthResponse, AuthStatus, BaseResource, BaseTimestampedModel, BulkPermissionRequest, CupcakeCoreConfig, EmailChangeConfirmRequest, EmailChangeConfirmResponse, EmailChangeRequest, InvitationResponseRequest, LabGroup, LabGroupCreateRequest, LabGroupInvitation, LabGroupInvitationCreateRequest, LabGroupInvitationQueryParams, LabGroupInvitationQueryResponse, LabGroupInviteRequest, LabGroupMember, LabGroupQueryParams, LabGroupQueryResponse, LabGroupUpdateRequest, PaginatedResponse, PasswordChangeRequest, PasswordChangeResponse, PasswordResetConfirmRequest, PasswordResetRequest, RegistrationStatus, RemoteHost, RemoteHostCreateRequest, RemoteHostUpdateRequest, ResourcePermission, ResourcePermissionCreateRequest, ResourcePermissionUpdateRequest, ResourceQueryParams, SiteConfig, SiteConfigUpdateRequest, ToastMessage, User, UserCreateRequest, UserListResponse, UserOrcidProfile, UserProfileUpdateRequest, UserRegistrationRequest, UserResponse };
1310
+ export { ApiService, AuthService, BaseApiService, CUPCAKE_CORE_CONFIG, CupcakeCoreModule, InvitationStatus, InvitationStatusLabels, LabGroupService, LabGroupsComponent, LoginComponent, NotificationService, PoweredByFooterComponent, RegisterComponent, ResourceRole, ResourceRoleLabels, ResourceService, ResourceType, ResourceTypeLabels, ResourceVisibility, ResourceVisibilityLabels, SiteConfigComponent, SiteConfigService, ThemeService, ToastContainerComponent, ToastService, UserManagementComponent, UserManagementService, UserProfileComponent, WEBSOCKET_ENDPOINT, WEBSOCKET_ENDPOINTS, WebSocketConfigService, WebSocketEndpoints, WebSocketService, adminGuard, authGuard, authInterceptor };
1311
+ export type { AccountMergeRequest, AdminPasswordResetRequest, Annotation, AnnotationCreateRequest, AnnotationFolder, AnnotationFolderCreateRequest, AnnotationFolderUpdateRequest, AnnotationUpdateRequest, ApiResponse, AuthConfig, AuthResponse, AuthStatus, BaseResource, BaseTimestampedModel, BulkPermissionRequest, CupcakeCoreConfig, EmailChangeConfirmRequest, EmailChangeConfirmResponse, EmailChangeRequest, InvitationResponseRequest, LabGroup, LabGroupCreateRequest, LabGroupInvitation, LabGroupInvitationCreateRequest, LabGroupInvitationQueryParams, LabGroupInvitationQueryResponse, LabGroupInviteRequest, LabGroupMember, LabGroupQueryParams, LabGroupQueryResponse, LabGroupUpdateRequest, NotificationAction, NotificationItem, PaginatedResponse, PasswordChangeRequest, PasswordChangeResponse, PasswordResetConfirmRequest, PasswordResetRequest, RegistrationStatus, RemoteHost, RemoteHostCreateRequest, RemoteHostUpdateRequest, ResourcePermission, ResourcePermissionCreateRequest, ResourcePermissionUpdateRequest, ResourceQueryParams, SiteConfig, SiteConfigUpdateRequest, Theme, ToastMessage, User, UserCreateRequest, UserListResponse, UserOrcidProfile, UserProfileUpdateRequest, UserRegistrationRequest, UserResponse, WebSocketConfig, WebSocketEndpointConfig, WebSocketMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noatgnu/cupcake-core",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A reusable Angular library that provides user management, authentication, and site configuration functionality for cupcake applications.",
5
5
  "keywords": [
6
6
  "angular",