@acontplus/ng-config 1.0.6 → 1.1.1
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 +198 -141
- package/fesm2022/acontplus-ng-config.mjs +29 -27
- package/fesm2022/acontplus-ng-config.mjs.map +1 -1
- package/index.d.ts +28 -21
- package/package.json +12 -9
package/README.md
CHANGED
|
@@ -1,34 +1,50 @@
|
|
|
1
1
|
# @acontplus/ng-config
|
|
2
2
|
|
|
3
|
-
Angular configuration library
|
|
4
|
-
|
|
3
|
+
Angular configuration library providing dependency injection tokens, repository
|
|
4
|
+
interfaces, and configuration constants for AcontPlus applications.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
+
# Using npm
|
|
9
10
|
npm install @acontplus/ng-config
|
|
11
|
+
|
|
12
|
+
# Using pnpm
|
|
13
|
+
pnpm add @acontplus/ng-config
|
|
10
14
|
```
|
|
11
15
|
|
|
12
16
|
## Features
|
|
13
17
|
|
|
14
|
-
- **
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- **
|
|
19
|
-
|
|
18
|
+
- **Injection Tokens**: Type-safe DI tokens for environment, core config, and
|
|
19
|
+
authentication
|
|
20
|
+
- **Repository Interfaces**: Base repository patterns and auth token repository
|
|
21
|
+
contracts
|
|
22
|
+
- **Configuration Constants**: Authentication and application configuration
|
|
23
|
+
constants
|
|
24
|
+
- **Base Repository**: Abstract base repository with common CRUD operations
|
|
25
|
+
- **TypeScript Support**: Full type safety with comprehensive interfaces
|
|
20
26
|
|
|
21
27
|
## Quick Start
|
|
22
28
|
|
|
23
29
|
### 1. Provide Environment Configuration
|
|
24
30
|
|
|
25
31
|
```typescript
|
|
26
|
-
//
|
|
27
|
-
import {
|
|
32
|
+
// app.config.ts
|
|
33
|
+
import { ApplicationConfig } from '@angular/core';
|
|
28
34
|
import { ENVIRONMENT } from '@acontplus/ng-config';
|
|
29
35
|
import { Environment } from '@acontplus/core';
|
|
36
|
+
import { environment } from './environments/environment';
|
|
30
37
|
|
|
31
|
-
const
|
|
38
|
+
export const appConfig: ApplicationConfig = {
|
|
39
|
+
providers: [{ provide: ENVIRONMENT, useValue: environment }],
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// environments/environment.ts
|
|
45
|
+
import { Environment } from '@acontplus/core';
|
|
46
|
+
|
|
47
|
+
export const environment: Environment = {
|
|
32
48
|
isProduction: false,
|
|
33
49
|
apiBaseUrl: 'http://localhost:3000/api/',
|
|
34
50
|
tokenKey: 'access_token',
|
|
@@ -36,30 +52,25 @@ const environment: Environment = {
|
|
|
36
52
|
clientId: 'my-app',
|
|
37
53
|
loginRoute: 'login',
|
|
38
54
|
};
|
|
39
|
-
|
|
40
|
-
bootstrapApplication(AppComponent, {
|
|
41
|
-
providers: [
|
|
42
|
-
{ provide: ENVIRONMENT, useValue: environment },
|
|
43
|
-
// other providers
|
|
44
|
-
],
|
|
45
|
-
});
|
|
46
55
|
```
|
|
47
56
|
|
|
48
|
-
### 2.
|
|
57
|
+
### 2. Inject and Use Environment
|
|
49
58
|
|
|
50
59
|
```typescript
|
|
51
|
-
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
import { inject, Injectable } from '@angular/core';
|
|
61
|
+
import { ENVIRONMENT } from '@acontplus/ng-config';
|
|
62
|
+
|
|
63
|
+
@Injectable({ providedIn: 'root' })
|
|
64
|
+
export class ApiService {
|
|
65
|
+
private environment = inject(ENVIRONMENT);
|
|
66
|
+
|
|
67
|
+
getApiUrl(): string {
|
|
68
|
+
return this.environment.apiBaseUrl;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
isProduction(): boolean {
|
|
72
|
+
return this.environment.isProduction;
|
|
73
|
+
}
|
|
63
74
|
}
|
|
64
75
|
```
|
|
65
76
|
|
|
@@ -67,171 +78,217 @@ export class DashboardComponent {
|
|
|
67
78
|
|
|
68
79
|
### ENVIRONMENT Token
|
|
69
80
|
|
|
70
|
-
Injection token for environment configuration
|
|
81
|
+
Injection token for environment configuration with default factory.
|
|
82
|
+
|
|
83
|
+
**Type:** `InjectionToken<Environment>`
|
|
84
|
+
|
|
85
|
+
**Default Value:**
|
|
71
86
|
|
|
72
87
|
```typescript
|
|
88
|
+
{
|
|
89
|
+
isProduction: false,
|
|
90
|
+
apiBaseUrl: 'http://localhost:4200/api/',
|
|
91
|
+
tokenKey: 'access_token',
|
|
92
|
+
refreshTokenKey: 'refresh_token',
|
|
93
|
+
clientId: 'angular-app',
|
|
94
|
+
loginRoute: 'auth',
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Environment Interface:**
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
interface Environment {
|
|
102
|
+
apiBaseUrl: string; // Base URL for API requests
|
|
103
|
+
isProduction: boolean; // Production mode flag
|
|
104
|
+
tokenKey: string; // Storage key for access token
|
|
105
|
+
refreshTokenKey: string; // Storage key for refresh token
|
|
106
|
+
clientId: string; // Application client identifier
|
|
107
|
+
loginRoute: string; // Route path for login page
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Usage:**
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { inject } from '@angular/core';
|
|
73
115
|
import { ENVIRONMENT } from '@acontplus/ng-config';
|
|
74
|
-
import { Environment } from '@acontplus/core';
|
|
75
116
|
|
|
76
|
-
@Injectable()
|
|
77
|
-
export class
|
|
78
|
-
private
|
|
117
|
+
@Injectable({ providedIn: 'root' })
|
|
118
|
+
export class AuthService {
|
|
119
|
+
private env = inject(ENVIRONMENT);
|
|
79
120
|
|
|
80
|
-
|
|
81
|
-
return this.
|
|
121
|
+
getTokenKey(): string {
|
|
122
|
+
return this.env.tokenKey;
|
|
82
123
|
}
|
|
83
124
|
|
|
84
|
-
|
|
85
|
-
return this.
|
|
125
|
+
getLoginRoute(): string {
|
|
126
|
+
return this.env.loginRoute;
|
|
86
127
|
}
|
|
87
128
|
}
|
|
88
129
|
```
|
|
89
130
|
|
|
90
|
-
###
|
|
131
|
+
### CORE_CONFIG Token
|
|
132
|
+
|
|
133
|
+
Injection token for core application configuration.
|
|
91
134
|
|
|
92
|
-
|
|
135
|
+
**Type:** `InjectionToken<CoreConfig>`
|
|
136
|
+
|
|
137
|
+
**Usage:**
|
|
93
138
|
|
|
94
139
|
```typescript
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
apiTimeout: number;
|
|
98
|
-
enableLogging: boolean;
|
|
99
|
-
production: boolean;
|
|
100
|
-
}
|
|
140
|
+
import { inject } from '@angular/core';
|
|
141
|
+
import { CORE_CONFIG } from '@acontplus/ng-config';
|
|
101
142
|
|
|
102
143
|
@Injectable({ providedIn: 'root' })
|
|
103
|
-
export class
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
144
|
+
export class ConfigService {
|
|
145
|
+
private config = inject(CORE_CONFIG);
|
|
146
|
+
|
|
147
|
+
getApiTimeout(): number {
|
|
148
|
+
return this.config.apiTimeout;
|
|
149
|
+
}
|
|
108
150
|
}
|
|
109
151
|
```
|
|
110
152
|
|
|
111
|
-
|
|
153
|
+
### AUTH_TOKEN Token
|
|
154
|
+
|
|
155
|
+
Injection token for authentication token configuration.
|
|
156
|
+
|
|
157
|
+
**Type:** `InjectionToken<string>`
|
|
158
|
+
|
|
159
|
+
**Usage:**
|
|
112
160
|
|
|
113
161
|
```typescript
|
|
114
|
-
|
|
115
|
-
@
|
|
116
|
-
export class HttpService {
|
|
117
|
-
private config = inject(AppConfigService);
|
|
118
|
-
|
|
119
|
-
private httpOptions = {
|
|
120
|
-
timeout: this.config.apiTimeout,
|
|
121
|
-
baseURL: this.config.apiUrl
|
|
122
|
-
};
|
|
123
|
-
}
|
|
162
|
+
import { inject } from '@angular/core';
|
|
163
|
+
import { AUTH_TOKEN } from '@acontplus/ng-config';
|
|
124
164
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
private config = inject(AppConfigService);
|
|
165
|
+
@Injectable({ providedIn: 'root' })
|
|
166
|
+
export class TokenService {
|
|
167
|
+
private tokenKey = inject(AUTH_TOKEN);
|
|
129
168
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
console.log(message);
|
|
133
|
-
}
|
|
169
|
+
getStorageKey(): string {
|
|
170
|
+
return this.tokenKey;
|
|
134
171
|
}
|
|
135
172
|
}
|
|
173
|
+
```
|
|
136
174
|
|
|
137
|
-
|
|
138
|
-
@Component({...})
|
|
139
|
-
export class DebugPanelComponent {
|
|
140
|
-
private config = inject(AppConfigService);
|
|
175
|
+
## Repository Interfaces
|
|
141
176
|
|
|
142
|
-
|
|
177
|
+
### AuthTokenRepository
|
|
178
|
+
|
|
179
|
+
Interface for authentication token storage and retrieval.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
export interface AuthTokenRepository {
|
|
183
|
+
getToken(): string | null;
|
|
184
|
+
setToken(token: string): void;
|
|
185
|
+
removeToken(): void;
|
|
186
|
+
getRefreshToken(): string | null;
|
|
187
|
+
setRefreshToken(token: string): void;
|
|
188
|
+
removeRefreshToken(): void;
|
|
143
189
|
}
|
|
144
190
|
```
|
|
145
191
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
Predefined authentication API endpoints:
|
|
192
|
+
**Usage:**
|
|
149
193
|
|
|
150
194
|
```typescript
|
|
151
|
-
import {
|
|
195
|
+
import { AuthTokenRepository } from '@acontplus/ng-config';
|
|
152
196
|
|
|
153
|
-
@Injectable()
|
|
154
|
-
export class
|
|
155
|
-
|
|
197
|
+
@Injectable({ providedIn: 'root' })
|
|
198
|
+
export class LocalStorageTokenRepository implements AuthTokenRepository {
|
|
199
|
+
getToken(): string | null {
|
|
200
|
+
return localStorage.getItem('access_token');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
setToken(token: string): void {
|
|
204
|
+
localStorage.setItem('access_token', token);
|
|
205
|
+
}
|
|
156
206
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
`${this.baseUrl}${AUTH_API.AUTH}login`,
|
|
160
|
-
credentials,
|
|
161
|
-
);
|
|
207
|
+
removeToken(): void {
|
|
208
|
+
localStorage.removeItem('access_token');
|
|
162
209
|
}
|
|
163
210
|
|
|
164
|
-
|
|
165
|
-
return
|
|
211
|
+
getRefreshToken(): string | null {
|
|
212
|
+
return localStorage.getItem('refresh_token');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
setRefreshToken(token: string): void {
|
|
216
|
+
localStorage.setItem('refresh_token', token);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
removeRefreshToken(): void {
|
|
220
|
+
localStorage.removeItem('refresh_token');
|
|
166
221
|
}
|
|
167
222
|
}
|
|
168
223
|
```
|
|
169
224
|
|
|
170
|
-
|
|
225
|
+
### BaseRepository
|
|
171
226
|
|
|
172
|
-
|
|
227
|
+
Abstract base repository with common CRUD operations.
|
|
173
228
|
|
|
174
229
|
```typescript
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
loginRoute: 'auth',
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// environments/environment.prod.ts
|
|
186
|
-
export const environment: Environment = {
|
|
187
|
-
isProduction: true,
|
|
188
|
-
apiBaseUrl: 'https://api.myapp.com/',
|
|
189
|
-
tokenKey: 'prod_token',
|
|
190
|
-
refreshTokenKey: 'prod_refresh_token',
|
|
191
|
-
clientId: 'prod-app',
|
|
192
|
-
loginRoute: 'login',
|
|
193
|
-
};
|
|
230
|
+
export abstract class BaseRepository<T, ID> {
|
|
231
|
+
abstract findById(id: ID): Promise<T | null>;
|
|
232
|
+
abstract findAll(): Promise<T[]>;
|
|
233
|
+
abstract create(entity: Omit<T, 'id'>): Promise<T>;
|
|
234
|
+
abstract update(id: ID, entity: Partial<T>): Promise<T>;
|
|
235
|
+
abstract delete(id: ID): Promise<void>;
|
|
236
|
+
}
|
|
194
237
|
```
|
|
195
238
|
|
|
196
|
-
|
|
239
|
+
**Usage:**
|
|
197
240
|
|
|
198
241
|
```typescript
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const isDev = window.location.hostname === 'localhost';
|
|
208
|
-
return isDev ? devEnvironment : prodEnvironment;
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
};
|
|
242
|
+
import { BaseRepository } from '@acontplus/ng-config';
|
|
243
|
+
import { Injectable } from '@angular/core';
|
|
244
|
+
import { HttpClient } from '@angular/common/http';
|
|
245
|
+
|
|
246
|
+
interface User {
|
|
247
|
+
id: number;
|
|
248
|
+
name: string;
|
|
249
|
+
email: string;
|
|
213
250
|
}
|
|
214
|
-
```
|
|
215
251
|
|
|
216
|
-
|
|
252
|
+
@Injectable({ providedIn: 'root' })
|
|
253
|
+
export class UserRepository extends BaseRepository<User, number> {
|
|
254
|
+
constructor(private http: HttpClient) {
|
|
255
|
+
super();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async findById(id: number): Promise<User | null> {
|
|
259
|
+
return this.http.get<User>(`/api/users/${id}`).toPromise() || null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async findAll(): Promise<User[]> {
|
|
263
|
+
return this.http.get<User[]>('/api/users').toPromise() || [];
|
|
264
|
+
}
|
|
217
265
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
private config = inject(AppConfigService);
|
|
266
|
+
async create(user: Omit<User, 'id'>): Promise<User> {
|
|
267
|
+
return this.http.post<User>('/api/users', user).toPromise() as Promise<User>;
|
|
268
|
+
}
|
|
222
269
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return !this.config.production || this.isFeatureInProd(feature);
|
|
270
|
+
async update(id: number, user: Partial<User>): Promise<User> {
|
|
271
|
+
return this.http.put<User>(`/api/users/${id}`, user).toPromise() as Promise<User>;
|
|
226
272
|
}
|
|
227
273
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return ['core-features', 'stable-features'].includes(feature);
|
|
274
|
+
async delete(id: number): Promise<void> {
|
|
275
|
+
await this.http.delete(`/api/users/${id}`).toPromise();
|
|
231
276
|
}
|
|
232
277
|
}
|
|
233
278
|
```
|
|
234
279
|
|
|
235
|
-
##
|
|
280
|
+
## Configuration Constants
|
|
281
|
+
|
|
282
|
+
### Authentication Constants
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { AUTH_CONSTANTS, CONFIG_CONSTANTS } from '@acontplus/ng-config';
|
|
286
|
+
|
|
287
|
+
// Authentication configuration
|
|
288
|
+
const tokenExpiry = AUTH_CONSTANTS.TOKEN_EXPIRY_TIME;
|
|
289
|
+
const refreshThreshold = AUTH_CONSTANTS.REFRESH_THRESHOLD;
|
|
236
290
|
|
|
237
|
-
|
|
291
|
+
// Application configuration
|
|
292
|
+
const apiTimeout = CONFIG_CONSTANTS.DEFAULT_API_TIMEOUT;
|
|
293
|
+
const retryAttempts = CONFIG_CONSTANTS.MAX_RETRY_ATTEMPTS;
|
|
294
|
+
```
|
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { InjectionToken, inject, Injectable } from '@angular/core';
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
3
2
|
|
|
4
|
-
// src/lib/constants/auth.constants.ts
|
|
3
|
+
// src/lib/constants/auth.app.constants.ts
|
|
5
4
|
const AUTH_API = {
|
|
6
5
|
AUTH: 'auth/',
|
|
7
6
|
};
|
|
8
7
|
|
|
8
|
+
const DEFAULT_CONFIG = {
|
|
9
|
+
apiBaseUrl: '',
|
|
10
|
+
apiTimeout: 30000,
|
|
11
|
+
retryAttempts: 2,
|
|
12
|
+
retryDelay: 1000,
|
|
13
|
+
enableCorrelationTracking: true,
|
|
14
|
+
enableRequestLogging: false,
|
|
15
|
+
enableErrorLogging: true,
|
|
16
|
+
enableToastNotifications: true,
|
|
17
|
+
includeAuthToken: true,
|
|
18
|
+
authTokenHeader: 'Authorization',
|
|
19
|
+
enableMultiTenancy: true,
|
|
20
|
+
tenantIdHeader: 'Tenant-Id',
|
|
21
|
+
logLevel: 'info',
|
|
22
|
+
enableConsoleLogging: true,
|
|
23
|
+
customHeaders: {},
|
|
24
|
+
excludeUrls: [],
|
|
25
|
+
excludeMethods: [],
|
|
26
|
+
};
|
|
27
|
+
|
|
9
28
|
// src/lib/constants/index.ts
|
|
10
29
|
|
|
30
|
+
const AUTH_TOKEN = new InjectionToken('AUTH_TOKEN_PROVIDER');
|
|
31
|
+
|
|
32
|
+
const CORE_CONFIG = new InjectionToken('CORE_CONFIG', {
|
|
33
|
+
factory: () => DEFAULT_CONFIG,
|
|
34
|
+
});
|
|
35
|
+
|
|
11
36
|
/**
|
|
12
37
|
* @const ENVIRONMENT
|
|
13
38
|
* Injection token for the environment interface to be provided by the applications.
|
|
@@ -23,32 +48,9 @@ const ENVIRONMENT = new InjectionToken('ENVIRONMENT', {
|
|
|
23
48
|
}),
|
|
24
49
|
});
|
|
25
50
|
|
|
26
|
-
class AppConfigService {
|
|
27
|
-
environment = inject(ENVIRONMENT);
|
|
28
|
-
defaultTimeout = 30000; // Default timeout
|
|
29
|
-
get apiUrl() {
|
|
30
|
-
return this.environment.apiBaseUrl;
|
|
31
|
-
}
|
|
32
|
-
get apiTimeout() {
|
|
33
|
-
return this.defaultTimeout;
|
|
34
|
-
}
|
|
35
|
-
get enableLogging() {
|
|
36
|
-
return !this.environment.isProduction;
|
|
37
|
-
}
|
|
38
|
-
get production() {
|
|
39
|
-
return this.environment.isProduction;
|
|
40
|
-
}
|
|
41
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: AppConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
42
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: AppConfigService, providedIn: 'root' });
|
|
43
|
-
}
|
|
44
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: AppConfigService, decorators: [{
|
|
45
|
-
type: Injectable,
|
|
46
|
-
args: [{ providedIn: 'root' }]
|
|
47
|
-
}] });
|
|
48
|
-
|
|
49
51
|
/**
|
|
50
52
|
* Generated bundle index. Do not edit.
|
|
51
53
|
*/
|
|
52
54
|
|
|
53
|
-
export { AUTH_API,
|
|
55
|
+
export { AUTH_API, AUTH_TOKEN, CORE_CONFIG, DEFAULT_CONFIG, ENVIRONMENT };
|
|
54
56
|
//# sourceMappingURL=acontplus-ng-config.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acontplus-ng-config.mjs","sources":["
|
|
1
|
+
{"version":3,"file":"acontplus-ng-config.mjs","sources":["../../../../packages/ng-config/src/lib/constants/auth.constants.ts","../../../../packages/ng-config/src/lib/constants/config.constants.ts","../../../../packages/ng-config/src/lib/constants/index.ts","../../../../packages/ng-config/src/lib/tokens/auth-token.ts","../../../../packages/ng-config/src/lib/tokens/core-config-token.ts","../../../../packages/ng-config/src/lib/tokens/environment-token.ts","../../../../packages/ng-config/src/acontplus-ng-config.ts"],"sourcesContent":["// src/lib/constants/auth.app.constants.ts\nexport const AUTH_API = {\n AUTH: 'auth/',\n} as const;\n","import { CoreConfig } from '@acontplus/core';\n\nexport const DEFAULT_CONFIG: Required<CoreConfig> = {\n apiBaseUrl: '',\n apiTimeout: 30000,\n retryAttempts: 2,\n retryDelay: 1000,\n enableCorrelationTracking: true,\n enableRequestLogging: false,\n enableErrorLogging: true,\n enableToastNotifications: true,\n includeAuthToken: true,\n authTokenHeader: 'Authorization',\n enableMultiTenancy: true,\n tenantIdHeader: 'Tenant-Id',\n logLevel: 'info',\n enableConsoleLogging: true,\n customHeaders: {},\n excludeUrls: [],\n excludeMethods: [],\n};\n","// src/lib/constants/index.ts\nexport * from './auth.constants';\nexport * from './config.constants';\n","import { InjectionToken } from '@angular/core';\nimport { AuthTokenRepository } from '../repositories';\n\nexport const AUTH_TOKEN = new InjectionToken<AuthTokenRepository>('AUTH_TOKEN_PROVIDER');\n","import { InjectionToken } from '@angular/core';\nimport { CoreConfig } from '@acontplus/core';\nimport { DEFAULT_CONFIG } from '../constants';\n\nexport const CORE_CONFIG = new InjectionToken<CoreConfig>('CORE_CONFIG', {\n factory: () => DEFAULT_CONFIG,\n});\n","import { InjectionToken } from '@angular/core';\nimport { Environment } from '@acontplus/core';\n\n/**\n * @const ENVIRONMENT\n * Injection token for the environment interface to be provided by the applications.\n */\nexport const ENVIRONMENT = new InjectionToken<Environment>('ENVIRONMENT', {\n factory: () => ({\n isProduction: false,\n apiBaseUrl: 'http://localhost:4200/api/',\n tokenKey: 'access_token',\n refreshTokenKey: 'refresh_token',\n clientId: 'angular-app',\n loginRoute: 'auth',\n }),\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;AACO,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,OAAO;;;ACAR,MAAM,cAAc,GAAyB;AAClD,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,aAAa,EAAE,CAAC;AAChB,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,yBAAyB,EAAE,IAAI;AAC/B,IAAA,oBAAoB,EAAE,KAAK;AAC3B,IAAA,kBAAkB,EAAE,IAAI;AACxB,IAAA,wBAAwB,EAAE,IAAI;AAC9B,IAAA,gBAAgB,EAAE,IAAI;AACtB,IAAA,eAAe,EAAE,eAAe;AAChC,IAAA,kBAAkB,EAAE,IAAI;AACxB,IAAA,cAAc,EAAE,WAAW;AAC3B,IAAA,QAAQ,EAAE,MAAM;AAChB,IAAA,oBAAoB,EAAE,IAAI;AAC1B,IAAA,aAAa,EAAE,EAAE;AACjB,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,cAAc,EAAE,EAAE;;;ACnBpB;;MCGa,UAAU,GAAG,IAAI,cAAc,CAAsB,qBAAqB;;MCC1E,WAAW,GAAG,IAAI,cAAc,CAAa,aAAa,EAAE;AACvE,IAAA,OAAO,EAAE,MAAM,cAAc;AAC9B,CAAA;;ACHD;;;AAGG;MACU,WAAW,GAAG,IAAI,cAAc,CAAc,aAAa,EAAE;AACxE,IAAA,OAAO,EAAE,OAAO;AACd,QAAA,YAAY,EAAE,KAAK;AACnB,QAAA,UAAU,EAAE,4BAA4B;AACxC,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,eAAe,EAAE,eAAe;AAChC,QAAA,QAAQ,EAAE,aAAa;AACvB,QAAA,UAAU,EAAE,MAAM;KACnB,CAAC;AACH,CAAA;;AChBD;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CoreConfig, UserData, PaginationParams, PagedResult, Environment } from '@acontplus/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
2
3
|
import { InjectionToken } from '@angular/core';
|
|
3
|
-
import { Environment } from '@acontplus/core';
|
|
4
4
|
|
|
5
5
|
declare const AUTH_API: {
|
|
6
6
|
readonly AUTH: "auth/";
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
declare const DEFAULT_CONFIG: Required<CoreConfig>;
|
|
10
|
+
|
|
11
|
+
interface AuthTokenRepository {
|
|
12
|
+
getToken(): string | null;
|
|
13
|
+
isAuthenticated(): boolean;
|
|
14
|
+
getRefreshToken?(): string | null;
|
|
15
|
+
getUserData(): UserData | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface BaseRepository<TEntity = any, TId = number> {
|
|
19
|
+
getById?(id: TId): Observable<TEntity>;
|
|
20
|
+
getAll?(pagination?: PaginationParams): Observable<PagedResult<TEntity>>;
|
|
21
|
+
create?(entity: Partial<TEntity>): Observable<TEntity>;
|
|
22
|
+
update?(id: TId, entity: Partial<TEntity>): Observable<TEntity>;
|
|
23
|
+
remove?(id: TId): Observable<void>;
|
|
24
|
+
}
|
|
25
|
+
interface SearchableRepository<TEntity = any, TId = number> extends BaseRepository<TEntity, TId> {
|
|
26
|
+
search?(query: string, pagination: PaginationParams): Observable<PagedResult<TEntity>>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare const AUTH_TOKEN: InjectionToken<AuthTokenRepository>;
|
|
30
|
+
|
|
31
|
+
declare const CORE_CONFIG: InjectionToken<CoreConfig>;
|
|
32
|
+
|
|
9
33
|
/**
|
|
10
34
|
* @const ENVIRONMENT
|
|
11
35
|
* Injection token for the environment interface to be provided by the applications.
|
|
12
36
|
*/
|
|
13
37
|
declare const ENVIRONMENT: InjectionToken<Environment>;
|
|
14
38
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
apiTimeout: number;
|
|
18
|
-
enableLogging: boolean;
|
|
19
|
-
production: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare class AppConfigService implements IAppConfig {
|
|
22
|
-
private environment;
|
|
23
|
-
private readonly defaultTimeout;
|
|
24
|
-
get apiUrl(): string;
|
|
25
|
-
get apiTimeout(): number;
|
|
26
|
-
get enableLogging(): boolean;
|
|
27
|
-
get production(): boolean;
|
|
28
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<AppConfigService, never>;
|
|
29
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<AppConfigService>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { AUTH_API, AppConfigService, ENVIRONMENT };
|
|
33
|
-
export type { IAppConfig };
|
|
39
|
+
export { AUTH_API, AUTH_TOKEN, CORE_CONFIG, DEFAULT_CONFIG, ENVIRONMENT };
|
|
40
|
+
export type { AuthTokenRepository, BaseRepository, SearchableRepository };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acontplus/ng-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Angular configuration management library providing environment tokens, application settings, dependency injection patterns, and runtime configuration services for enterprise applications.",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@acontplus/core": "^1.
|
|
7
|
-
"@angular/common": "^20.3.
|
|
8
|
-
"@angular/core": "^20.3.
|
|
6
|
+
"@acontplus/core": "^1.1.1",
|
|
7
|
+
"@angular/common": "^20.3.9",
|
|
8
|
+
"@angular/core": "^20.3.9"
|
|
9
9
|
},
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"main": "fesm2022/acontplus-ng-config.mjs",
|
|
@@ -28,14 +28,17 @@
|
|
|
28
28
|
"acontplus",
|
|
29
29
|
"angular",
|
|
30
30
|
"configuration",
|
|
31
|
-
"environment",
|
|
31
|
+
"environment-tokens",
|
|
32
32
|
"app-config",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"runtime-configuration",
|
|
34
|
+
"settings-management",
|
|
35
|
+
"injection-tokens",
|
|
35
36
|
"dependency-injection",
|
|
37
|
+
"config-services",
|
|
38
|
+
"environment-management",
|
|
36
39
|
"typescript",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
40
|
+
"enterprise",
|
|
41
|
+
"frontend"
|
|
39
42
|
],
|
|
40
43
|
"author": "Ivan Paz <ifer343@gmail.com>",
|
|
41
44
|
"license": "MIT",
|