@opensourcekd/ng-common-libs 2.0.1 โ†’ 2.0.3

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 CHANGED
@@ -1,22 +1,19 @@
1
1
  # ng-common-libs
2
2
 
3
- Angular 18 library with Auth0 authentication service and MicroFrontend event bus.
3
+ Pure TypeScript library with Auth0 authentication service and framework-agnostic event bus.
4
4
 
5
5
  ## ๐ŸŽฏ Simple Architecture
6
6
 
7
- **One import path. Everything you need.**
7
+ **One import path. Everything you need. Framework-agnostic.**
8
8
 
9
9
  All services, utilities, and types are exported from a single package:
10
10
 
11
11
  ```typescript
12
12
  import {
13
13
  AuthService,
14
- EventBusService,
15
- getAuthService,
16
- getEventBusService,
17
- getApiUrl,
18
- UserInfo,
19
- EventBus
14
+ EventBus,
15
+ APP_CONFIG,
16
+ UserInfo
20
17
  } from '@opensourcekd/ng-common-libs';
21
18
  ```
22
19
 
@@ -24,11 +21,11 @@ import {
24
21
 
25
22
  ## ๐Ÿš€ Features
26
23
 
27
- - **AuthService**: Complete Auth0 authentication with token management
28
- - **EventBusService**: MicroFrontend-ready event bus with replay buffer
24
+ - **AuthService**: Complete Auth0 authentication with token management (Pure TypeScript - no Angular dependency)
25
+ - **EventBus**: Framework-agnostic event bus using RxJS
26
+ - **Works with any framework**: Angular, React, Vue, Svelte, vanilla JS
29
27
  - **Module Federation Support**: Singleton pattern works across shell + MFEs
30
- - **AOT-Safe**: No JIT compiler required, works in production builds
31
- - **Framework-Agnostic Core**: EventBus can be used in React, Vue, or vanilla JS
28
+ - **Zero Framework Lock-in**: Core services are pure TypeScript classes
32
29
 
33
30
  ## ๐Ÿ“ฆ Installation
34
31
 
@@ -40,46 +37,31 @@ npm install @opensourcekd/ng-common-libs
40
37
 
41
38
  ## ๐Ÿ”ง Quick Start
42
39
 
43
- ### For Module Federation (Shell + MFEs)
44
-
45
- **In your shell app AND each MFE's `app.config.ts`:**
40
+ ### Pure TypeScript Usage (Framework-Agnostic)
46
41
 
47
42
  ```typescript
48
- import { ApplicationConfig } from '@angular/core';
49
- import {
50
- AuthService,
51
- EventBusService,
52
- getAuthService,
53
- getEventBusService
54
- } from '@opensourcekd/ng-common-libs';
55
-
56
- // No configuration needed - API URL is baked into the library during build
57
-
58
- export const appConfig: ApplicationConfig = {
59
- providers: [
60
- // Factory functions ensure singleton across all MFEs
61
- { provide: EventBusService, useFactory: getEventBusService },
62
- { provide: AuthService, useFactory: getAuthService },
63
- ]
43
+ import { AuthService, EventBus } from '@opensourcekd/ng-common-libs';
44
+
45
+ // Create instances
46
+ const eventBus = new EventBus();
47
+ const authConfig = {
48
+ domain: 'your-domain.auth0.com',
49
+ clientId: 'your-client-id',
50
+ redirectUri: window.location.origin,
51
+ logoutUri: window.location.origin,
52
+ scope: 'openid profile email'
64
53
  };
65
- ```
66
-
67
- **Why factory functions?**
68
- They create a **JavaScript module-level singleton** shared across ALL applications (shell + MFEs). Module Federation ensures the module loads once, so all apps get the same instance.
54
+ const authService = new AuthService(authConfig, eventBus);
69
55
 
70
- ### For Standalone Components
71
-
72
- Then use normally with `inject()`:
73
- ```typescript
74
- import { Component, inject } from '@angular/core';
75
- import { AuthService, EventBusService } from '@opensourcekd/ng-common-libs';
56
+ // Use the service
57
+ await authService.login();
58
+ const user = authService.getUser();
59
+ const token = await authService.getToken();
76
60
 
77
- export class MyComponent {
78
- private authService = inject(AuthService);
79
- private eventBus = inject(EventBusService);
80
-
81
- login() { this.authService.login(); }
82
- }
61
+ // Subscribe to events
62
+ eventBus.on('auth:login_success').subscribe(data => {
63
+ console.log('User logged in:', data);
64
+ });
83
65
  ```
84
66
 
85
67
  ### API URL Access
@@ -87,10 +69,10 @@ export class MyComponent {
87
69
  **No configuration needed** - API URL is automatically available:
88
70
 
89
71
  ```typescript
90
- import { getApiUrl } from '@opensourcekd/ng-common-libs';
72
+ import { APP_CONFIG } from '@opensourcekd/ng-common-libs';
91
73
 
92
74
  // API URL is baked into the library during build from GitHub repository variables
93
- const apiUrl = getApiUrl();
75
+ const apiUrl = APP_CONFIG.apiUrl;
94
76
  const endpoint = `${apiUrl}/users`;
95
77
  ```
96
78
 
@@ -111,22 +93,29 @@ Everything you need from one import:
111
93
  import {
112
94
  // Services
113
95
  AuthService,
114
- EventBusService,
96
+ EventBus,
115
97
 
116
- // Factory Functions
117
- getAuthService,
118
- getEventBusService,
98
+ // Configuration
99
+ APP_CONFIG,
100
+ AUTH0_CONFIG,
101
+ STORAGE_CONFIG,
102
+ STORAGE_KEYS,
119
103
 
120
- // API Access
121
- getApiUrl,
122
-
123
- // Core Utilities
124
- EventBus,
104
+ // Utilities
105
+ getStorageItem,
106
+ setStorageItem,
107
+ removeStorageItem,
125
108
 
126
109
  // Types & Interfaces
127
110
  UserInfo,
128
111
  UserData,
129
112
  EventPayload,
113
+ Auth0Config,
114
+ StorageConfig,
115
+ StorageKeys,
116
+ AppState,
117
+ AuthorizationParams,
118
+ CallbackResult,
130
119
  } from '@opensourcekd/ng-common-libs';
131
120
  ```
132
121
 
@@ -141,8 +130,26 @@ npm run build
141
130
 
142
131
  # Run linter
143
132
  npm run lint
133
+
134
+ # Run tests
135
+ npm test
136
+
137
+ # Run tests with coverage
138
+ npm run test:coverage
139
+
140
+ # Run tests in watch mode
141
+ npm run test:watch
144
142
  ```
145
143
 
144
+ ## ๐Ÿงช Testing
145
+
146
+ This library maintains high test coverage:
147
+ - **99.26%** statement coverage
148
+ - **83.45%** branch coverage
149
+ - **100%** function coverage
150
+
151
+ All core utilities and services are thoroughly tested using Jest and Angular testing utilities.
152
+
146
153
  ## ๐Ÿ“„ License
147
154
 
148
155
  MIT