@noatgnu/cupcake-core 1.0.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/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # CupcakeCore
2
+
3
+ A reusable Angular library that provides user management, authentication, and site configuration functionality for cupcake applications.
4
+
5
+ ## Features
6
+
7
+ - **Authentication**: Login/register components with ORCID support
8
+ - **User Management**: Admin user management, lab groups, user profiles
9
+ - **Site Configuration**: Configurable site settings and branding
10
+ - **Guards & Interceptors**: Auth guard, admin guard, and HTTP interceptors
11
+ - **Models & Services**: Complete set of models and services for user management
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install cupcake-core
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### 1. Configure in your app.config.ts
22
+
23
+ ```typescript
24
+ import { ApplicationConfig } from '@angular/core';
25
+ import { provideHttpClient, withInterceptors } from '@angular/common/http';
26
+ import { authInterceptor, CUPCAKE_CORE_CONFIG } from 'cupcake-core';
27
+
28
+ export const appConfig: ApplicationConfig = {
29
+ providers: [
30
+ { provide: CUPCAKE_CORE_CONFIG, useValue: { apiUrl: 'https://your-api.com' } },
31
+ provideHttpClient(
32
+ withInterceptors([authInterceptor])
33
+ ),
34
+ // ... other providers
35
+ ]
36
+ };
37
+ ```
38
+
39
+ ### 2. Use components in your routes
40
+
41
+ ```typescript
42
+ import { Routes } from '@angular/router';
43
+ import { LoginComponent, RegisterComponent, authGuard, adminGuard } from 'cupcake-core';
44
+
45
+ export const routes: Routes = [
46
+ { path: 'login', component: LoginComponent },
47
+ { path: 'register', component: RegisterComponent },
48
+ { path: 'protected', component: YourComponent, canActivate: [authGuard] },
49
+ { path: 'admin', component: AdminComponent, canActivate: [authGuard, adminGuard] },
50
+ ];
51
+ ```
52
+
53
+ ### 3. Import services in your components
54
+
55
+ ```typescript
56
+ import { Component, inject } from '@angular/core';
57
+ import { AuthService, SiteConfigService, User } from 'cupcake-core';
58
+
59
+ @Component({
60
+ selector: 'app-example',
61
+ template: \`
62
+ <div *ngIf="currentUser">
63
+ Welcome, {{ currentUser.first_name }}!
64
+ </div>
65
+ \`
66
+ })
67
+ export class ExampleComponent {
68
+ private authService = inject(AuthService);
69
+ private siteConfigService = inject(SiteConfigService);
70
+
71
+ currentUser = this.authService.currentUser$;
72
+ siteConfig = this.siteConfigService.config$;
73
+ }
74
+ ```
75
+
76
+ ## Available Components
77
+
78
+ - `LoginComponent` - Login form with username/password and ORCID support
79
+ - `RegisterComponent` - User registration form
80
+ - `UserProfileComponent` - User profile management
81
+ - `UserManagementComponent` - Admin user management
82
+ - `LabGroupsComponent` - Lab group management
83
+ - `SiteConfigComponent` - Site configuration management
84
+ - `ToastContainerComponent` - Toast notification container
85
+
86
+ ## Available Services
87
+
88
+ - `AuthService` - Authentication and user management
89
+ - `ApiService` - API communication
90
+ - `SiteConfigService` - Site configuration
91
+ - `UserManagementService` - User management operations
92
+ - `ToastService` - Toast notifications
93
+ - `ResourceService` - Resource utilities
94
+
95
+ ## Available Guards
96
+
97
+ - `authGuard` - Protect routes requiring authentication
98
+ - `adminGuard` - Protect admin-only routes
99
+
100
+ ## Available Models
101
+
102
+ All necessary TypeScript interfaces and enums for user management, authentication, and site configuration.
103
+
104
+ ## Building the Library
105
+
106
+ To build the library:
107
+
108
+ ```bash
109
+ ng build cupcake-core
110
+ ```
111
+
112
+ To publish:
113
+
114
+ ```bash
115
+ cd dist/cupcake-core
116
+ npm publish
117
+ ```
118
+
119
+ ## Development
120
+
121
+ The library is designed to be framework-agnostic and can be imported by any Angular application that needs user management functionality.