@memberjunction/ng-bootstrap 3.4.0 → 4.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/README.md +78 -150
- package/fesm2022/memberjunction-ng-bootstrap.mjs +476 -38
- package/fesm2022/memberjunction-ng-bootstrap.mjs.map +1 -1
- package/package.json +26 -15
- package/types/memberjunction-ng-bootstrap.d.ts +251 -0
- package/esm2022/lib/bootstrap.component.mjs +0 -38
- package/esm2022/lib/bootstrap.module.mjs +0 -98
- package/esm2022/lib/bootstrap.types.mjs +0 -13
- package/esm2022/lib/components/auth-shell.component.mjs +0 -148
- package/esm2022/lib/services/initialization.service.mjs +0 -186
- package/esm2022/memberjunction-ng-bootstrap.mjs +0 -5
- package/esm2022/public-api.mjs +0 -9
- package/index.d.ts +0 -5
- package/lib/bootstrap.component.d.ts +0 -16
- package/lib/bootstrap.module.d.ts +0 -63
- package/lib/bootstrap.types.d.ts +0 -72
- package/lib/components/auth-shell.component.d.ts +0 -36
- package/lib/services/initialization.service.d.ts +0 -52
- package/public-api.d.ts +0 -8
package/README.md
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
# @memberjunction/ng-bootstrap
|
|
2
2
|
|
|
3
|
-
MemberJunction
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
In MemberJunction 3.0, Angular applications (MJExplorer) become **minimal configuration files** (~15-20 lines) that import all functionality from NPM packages. This package provides the `MJBootstrapModule` and `MJBootstrapComponent` that handle all authentication, GraphQL setup, and application initialization.
|
|
3
|
+
MemberJunction Angular Bootstrap -- encapsulates all Angular authentication and initialization logic into a single reusable module. Reduces an entire MJExplorer application module to approximately 15 lines of code.
|
|
8
4
|
|
|
9
5
|
## Installation
|
|
10
6
|
|
|
@@ -12,22 +8,51 @@ In MemberJunction 3.0, Angular applications (MJExplorer) become **minimal config
|
|
|
12
8
|
npm install @memberjunction/ng-bootstrap
|
|
13
9
|
```
|
|
14
10
|
|
|
15
|
-
##
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
In MemberJunction 3.0+, Angular applications become minimal configuration files that delegate authentication, GraphQL setup, metadata loading, and user validation to this bootstrap package. The `MJBootstrapModule` configures all necessary providers via `forRoot()`, while `MJBootstrapComponent` serves as the root component handling the full application lifecycle from login through to the authenticated shell.
|
|
14
|
+
|
|
15
|
+
```mermaid
|
|
16
|
+
flowchart TD
|
|
17
|
+
subgraph Bootstrap["MJBootstrapModule.forRoot(env)"]
|
|
18
|
+
A["MJEnvironmentConfig"]
|
|
19
|
+
A --> B["Auth Provider (MSAL / Auth0)"]
|
|
20
|
+
A --> C["GraphQL Client + WebSocket"]
|
|
21
|
+
A --> D["MJ_ENVIRONMENT Token"]
|
|
22
|
+
end
|
|
23
|
+
subgraph Lifecycle["MJBootstrapComponent"]
|
|
24
|
+
E["Login Screen"] --> F["Authentication"]
|
|
25
|
+
F --> G["Token Management"]
|
|
26
|
+
G --> H["Metadata Loading"]
|
|
27
|
+
H --> I["User Validation"]
|
|
28
|
+
I --> J["Startup Validation"]
|
|
29
|
+
J --> K["Authenticated Shell"]
|
|
30
|
+
end
|
|
31
|
+
subgraph States["Application States"]
|
|
32
|
+
L["Not Authenticated"]
|
|
33
|
+
M["Authenticated"]
|
|
34
|
+
N["Error State"]
|
|
35
|
+
O["Validation Banner"]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
Bootstrap --> Lifecycle
|
|
39
|
+
Lifecycle --> States
|
|
40
|
+
|
|
41
|
+
style Bootstrap fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
42
|
+
style Lifecycle fill:#7c5295,stroke:#563a6b,color:#fff
|
|
43
|
+
style States fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
44
|
+
```
|
|
16
45
|
|
|
17
|
-
|
|
46
|
+
## Usage
|
|
18
47
|
|
|
19
|
-
|
|
48
|
+
### Minimal Application Module
|
|
20
49
|
|
|
21
50
|
```typescript
|
|
22
51
|
import { NgModule } from '@angular/core';
|
|
23
52
|
import { BrowserModule } from '@angular/platform-browser';
|
|
24
53
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
25
|
-
|
|
26
54
|
import { MJBootstrapModule, MJBootstrapComponent } from '@memberjunction/ng-bootstrap';
|
|
27
55
|
import { MJExplorerModule } from '@memberjunction/ng-explorer-core';
|
|
28
|
-
import { CoreGeneratedFormsModule } from '@memberjunction/ng-core-entity-forms';
|
|
29
|
-
import { GeneratedFormsModule } from '@mycompany/generated-forms';
|
|
30
|
-
|
|
31
56
|
import { environment } from '../environments/environment';
|
|
32
57
|
|
|
33
58
|
@NgModule({
|
|
@@ -35,21 +60,15 @@ import { environment } from '../environments/environment';
|
|
|
35
60
|
BrowserModule,
|
|
36
61
|
BrowserAnimationsModule,
|
|
37
62
|
MJBootstrapModule.forRoot(environment),
|
|
38
|
-
MJExplorerModule
|
|
39
|
-
CoreGeneratedFormsModule,
|
|
40
|
-
GeneratedFormsModule
|
|
63
|
+
MJExplorerModule
|
|
41
64
|
],
|
|
42
|
-
bootstrap: [MJBootstrapComponent]
|
|
65
|
+
bootstrap: [MJBootstrapComponent]
|
|
43
66
|
})
|
|
44
67
|
export class AppModule {}
|
|
45
68
|
```
|
|
46
69
|
|
|
47
|
-
**That's it!** Your entire MJExplorer application module in ~15 lines.
|
|
48
|
-
|
|
49
70
|
### Environment Configuration
|
|
50
71
|
|
|
51
|
-
Create your `packages/explorer/src/environments/environment.ts`:
|
|
52
|
-
|
|
53
72
|
```typescript
|
|
54
73
|
import { MJEnvironmentConfig } from '@memberjunction/ng-bootstrap';
|
|
55
74
|
|
|
@@ -70,54 +89,31 @@ export const environment: MJEnvironmentConfig = {
|
|
|
70
89
|
};
|
|
71
90
|
```
|
|
72
91
|
|
|
73
|
-
## What It
|
|
74
|
-
|
|
75
|
-
The `MJBootstrapModule` and `MJBootstrapComponent` handle:
|
|
92
|
+
## What It Handles
|
|
76
93
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
The bootstrap component provides a clean template structure:
|
|
89
|
-
|
|
90
|
-
```html
|
|
91
|
-
<mj-bootstrap>
|
|
92
|
-
<!-- Authenticated: Shows the main shell -->
|
|
93
|
-
<mj-shell *ngIf="authenticated"></mj-shell>
|
|
94
|
-
|
|
95
|
-
<!-- Not authenticated: Shows login screen -->
|
|
96
|
-
<mj-login *ngIf="!authenticated"></mj-login>
|
|
97
|
-
|
|
98
|
-
<!-- Error state: Shows error message -->
|
|
99
|
-
<mj-error *ngIf="hasError"></mj-error>
|
|
100
|
-
|
|
101
|
-
<!-- Validation issues: Shows validation banner -->
|
|
102
|
-
<mj-validation-banner *ngIf="showValidation"></mj-validation-banner>
|
|
103
|
-
</mj-bootstrap>
|
|
104
|
-
```
|
|
94
|
+
| Concern | Description |
|
|
95
|
+
|---------|-------------|
|
|
96
|
+
| Authentication | MSAL or Auth0 login/logout with token management |
|
|
97
|
+
| GraphQL setup | Client configuration with WebSocket subscriptions |
|
|
98
|
+
| Token refresh | Automatic token refresh before expiration |
|
|
99
|
+
| Metadata loading | MemberJunction entity metadata and definitions |
|
|
100
|
+
| User validation | Access and permission checks |
|
|
101
|
+
| Startup validation | System health checks on initialization |
|
|
102
|
+
| Error handling | Appropriate error messages for auth failures |
|
|
103
|
+
| Navigation | Initial routing after successful login |
|
|
105
104
|
|
|
106
105
|
## API Reference
|
|
107
106
|
|
|
108
|
-
###
|
|
107
|
+
### MJBootstrapModule.forRoot(environment)
|
|
109
108
|
|
|
110
109
|
Configures the bootstrap module with environment settings.
|
|
111
110
|
|
|
112
|
-
|
|
111
|
+
**Parameters:**
|
|
112
|
+
- `environment: MJEnvironmentConfig` -- Application configuration
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
**Returns:** `ModuleWithProviders<MJBootstrapModule>`
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
ModuleWithProviders with environment configuration injected
|
|
119
|
-
|
|
120
|
-
### `MJEnvironmentConfig` Interface
|
|
116
|
+
### MJEnvironmentConfig
|
|
121
117
|
|
|
122
118
|
```typescript
|
|
123
119
|
interface MJEnvironmentConfig {
|
|
@@ -127,114 +123,46 @@ interface MJEnvironmentConfig {
|
|
|
127
123
|
AUTH_TYPE: 'msal' | 'auth0';
|
|
128
124
|
MJ_CORE_SCHEMA_NAME: string;
|
|
129
125
|
|
|
130
|
-
// MSAL-specific
|
|
126
|
+
// MSAL-specific
|
|
131
127
|
CLIENT_ID?: string;
|
|
132
128
|
TENANT_ID?: string;
|
|
133
129
|
|
|
134
|
-
// Auth0-specific
|
|
130
|
+
// Auth0-specific
|
|
135
131
|
AUTH0_DOMAIN?: string;
|
|
136
132
|
AUTH0_CLIENTID?: string;
|
|
137
|
-
|
|
138
|
-
// Additional custom properties
|
|
139
|
-
[key: string]: any;
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Migration from 2.x
|
|
144
|
-
|
|
145
|
-
In MemberJunction 2.x, your MJExplorer had:
|
|
146
|
-
- `app.component.ts` with ~245 lines of authentication logic
|
|
147
|
-
- `app.module.ts` with ~107 lines of module imports and configuration
|
|
148
|
-
|
|
149
|
-
**Before (2.x):**
|
|
150
|
-
```typescript
|
|
151
|
-
// app.component.ts - 245 lines of auth/initialization code
|
|
152
|
-
@Component({...})
|
|
153
|
-
export class AppComponent implements OnInit {
|
|
154
|
-
// Complex authentication logic
|
|
155
|
-
// GraphQL setup
|
|
156
|
-
// Error handling
|
|
157
|
-
// Navigation logic
|
|
158
|
-
// ...
|
|
159
133
|
}
|
|
160
|
-
|
|
161
|
-
// app.module.ts - 107 lines of imports and configuration
|
|
162
|
-
@NgModule({
|
|
163
|
-
declarations: [AppComponent, ...],
|
|
164
|
-
imports: [BrowserModule, ...many modules...],
|
|
165
|
-
providers: [...many providers...],
|
|
166
|
-
bootstrap: [AppComponent]
|
|
167
|
-
})
|
|
168
|
-
export class AppModule {}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
**After (3.0):**
|
|
172
|
-
```typescript
|
|
173
|
-
// app.module.ts - ~15 lines total
|
|
174
|
-
@NgModule({
|
|
175
|
-
imports: [
|
|
176
|
-
BrowserModule,
|
|
177
|
-
BrowserAnimationsModule,
|
|
178
|
-
MJBootstrapModule.forRoot(environment),
|
|
179
|
-
MJExplorerModule,
|
|
180
|
-
GeneratedFormsModule
|
|
181
|
-
],
|
|
182
|
-
bootstrap: [MJBootstrapComponent]
|
|
183
|
-
})
|
|
184
|
-
export class AppModule {}
|
|
185
134
|
```
|
|
186
135
|
|
|
187
|
-
|
|
136
|
+
### Injection Tokens
|
|
188
137
|
|
|
189
|
-
|
|
138
|
+
- `MJ_ENVIRONMENT` -- Provides the `MJEnvironmentConfig` throughout the application
|
|
190
139
|
|
|
191
|
-
###
|
|
140
|
+
### MJStartupValidationService
|
|
192
141
|
|
|
193
|
-
|
|
142
|
+
An optional interface for implementing custom startup validation:
|
|
194
143
|
|
|
195
144
|
```typescript
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
@Component({
|
|
199
|
-
selector: 'app-custom-bootstrap',
|
|
200
|
-
template: `
|
|
201
|
-
<mj-bootstrap></mj-bootstrap>
|
|
202
|
-
<app-custom-error *ngIf="hasCustomError"></app-custom-error>
|
|
203
|
-
`
|
|
204
|
-
})
|
|
205
|
-
export class CustomBootstrapComponent extends MJBootstrapComponent {
|
|
206
|
-
// Add custom logic
|
|
145
|
+
interface MJStartupValidationService {
|
|
146
|
+
Validate(): Promise<ValidationResult>;
|
|
207
147
|
}
|
|
208
148
|
```
|
|
209
149
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
Configure your environment to support both MSAL and Auth0:
|
|
213
|
-
|
|
214
|
-
```typescript
|
|
215
|
-
export const environment: MJEnvironmentConfig = {
|
|
216
|
-
production: false,
|
|
217
|
-
AUTH_TYPE: 'msal', // Default
|
|
218
|
-
|
|
219
|
-
// MSAL config
|
|
220
|
-
CLIENT_ID: 'msal-client-id',
|
|
221
|
-
TENANT_ID: 'tenant-id',
|
|
222
|
-
|
|
223
|
-
// Auth0 config (fallback)
|
|
224
|
-
AUTH0_DOMAIN: 'yourapp.us.auth0.com',
|
|
225
|
-
AUTH0_CLIENTID: 'auth0-client-id'
|
|
226
|
-
};
|
|
227
|
-
```
|
|
150
|
+
## Migration from MJ 2.x
|
|
228
151
|
|
|
229
|
-
|
|
152
|
+
MemberJunction 2.x required ~350 lines of custom code in `app.component.ts` and `app.module.ts` for authentication and initialization. With 3.0+, this entire surface area is encapsulated in the bootstrap package:
|
|
230
153
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
154
|
+
| Before (2.x) | After (3.0+) |
|
|
155
|
+
|--------------|--------------|
|
|
156
|
+
| ~245 lines in `app.component.ts` | Removed entirely |
|
|
157
|
+
| ~107 lines in `app.module.ts` | ~15 lines |
|
|
158
|
+
| Custom auth logic | `MJBootstrapModule.forRoot(env)` |
|
|
159
|
+
| Manual GraphQL setup | Automatic |
|
|
160
|
+
| Custom error handling | Built-in |
|
|
237
161
|
|
|
238
|
-
##
|
|
162
|
+
## Dependencies
|
|
239
163
|
|
|
240
|
-
|
|
164
|
+
- [@memberjunction/core](../../MJCore/README.md) -- Core framework
|
|
165
|
+
- [@memberjunction/graphql-dataprovider](../../GraphQLDataProvider/README.md) -- GraphQL client
|
|
166
|
+
- [@memberjunction/ng-auth-services](../auth-services/README.md) -- Authentication services
|
|
167
|
+
- [@memberjunction/ng-explorer-core](../../Angular/Explorer/explorer-core/README.md) -- Explorer shell
|
|
168
|
+
- [@memberjunction/ng-shared](../shared/README.md) -- Shared utilities
|