@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 CHANGED
@@ -1,34 +1,50 @@
1
1
  # @acontplus/ng-config
2
2
 
3
- Angular configuration library for AcontPlus applications, providing environment
4
- configuration, authentication constants, and app configuration services.
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
- - **Environment Token**: Type-safe environment injection token
15
- - **App Configuration Service**: Centralized application configuration
16
- management
17
- - **Authentication Constants**: Predefined API endpoint constants
18
- - **Angular Integration**: Seamless dependency injection integration
19
- - **TypeScript Support**: Full type safety with comprehensive definitions
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
- // main.ts or app.config.ts
27
- import { bootstrapApplication } from '@angular/platform-browser';
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 environment: Environment = {
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. Use App Configuration Service
57
+ ### 2. Inject and Use Environment
49
58
 
50
59
  ```typescript
51
- import { AppConfigService } from '@acontplus/ng-config';
52
-
53
- @Component({
54
- selector: 'app-dashboard',
55
- template: `
56
- <div>API URL: {{ config.apiUrl }}</div>
57
- <div>Production: {{ config.production }}</div>
58
- <div>Logging: {{ config.enableLogging }}</div>
59
- `,
60
- })
61
- export class DashboardComponent {
62
- config = inject(AppConfigService);
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 ApiService {
78
- private environment = inject(ENVIRONMENT);
117
+ @Injectable({ providedIn: 'root' })
118
+ export class AuthService {
119
+ private env = inject(ENVIRONMENT);
79
120
 
80
- getApiUrl(): string {
81
- return this.environment.apiBaseUrl;
121
+ getTokenKey(): string {
122
+ return this.env.tokenKey;
82
123
  }
83
124
 
84
- isProduction(): boolean {
85
- return this.environment.isProduction;
125
+ getLoginRoute(): string {
126
+ return this.env.loginRoute;
86
127
  }
87
128
  }
88
129
  ```
89
130
 
90
- ### AppConfigService
131
+ ### CORE_CONFIG Token
132
+
133
+ Injection token for core application configuration.
91
134
 
92
- Centralized configuration service:
135
+ **Type:** `InjectionToken<CoreConfig>`
136
+
137
+ **Usage:**
93
138
 
94
139
  ```typescript
95
- interface IAppConfig {
96
- apiUrl: string;
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 AppConfigService implements IAppConfig {
104
- get apiUrl(): string;
105
- get apiTimeout(): number;
106
- get enableLogging(): boolean;
107
- get production(): boolean;
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
- **Usage Examples:**
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
- // HTTP Service Configuration
115
- @Injectable()
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
- // Conditional Logging
126
- @Injectable()
127
- export class LoggerService {
128
- private config = inject(AppConfigService);
165
+ @Injectable({ providedIn: 'root' })
166
+ export class TokenService {
167
+ private tokenKey = inject(AUTH_TOKEN);
129
168
 
130
- log(message: string): void {
131
- if (this.config.enableLogging) {
132
- console.log(message);
133
- }
169
+ getStorageKey(): string {
170
+ return this.tokenKey;
134
171
  }
135
172
  }
173
+ ```
136
174
 
137
- // Environment-based Features
138
- @Component({...})
139
- export class DebugPanelComponent {
140
- private config = inject(AppConfigService);
175
+ ## Repository Interfaces
141
176
 
142
- showDebugInfo = !this.config.production;
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
- ### AUTH_API Constants
147
-
148
- Predefined authentication API endpoints:
192
+ **Usage:**
149
193
 
150
194
  ```typescript
151
- import { AUTH_API } from '@acontplus/ng-config';
195
+ import { AuthTokenRepository } from '@acontplus/ng-config';
152
196
 
153
- @Injectable()
154
- export class AuthService {
155
- private baseUrl = inject(AppConfigService).apiUrl;
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
- login(credentials: LoginCredentials): Observable<AuthResponse> {
158
- return this.http.post<AuthResponse>(
159
- `${this.baseUrl}${AUTH_API.AUTH}login`,
160
- credentials,
161
- );
207
+ removeToken(): void {
208
+ localStorage.removeItem('access_token');
162
209
  }
163
210
 
164
- logout(): Observable<void> {
165
- return this.http.post<void>(`${this.baseUrl}${AUTH_API.AUTH}logout`, {});
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
- ## Configuration Patterns
225
+ ### BaseRepository
171
226
 
172
- ### Multi-Environment Setup
227
+ Abstract base repository with common CRUD operations.
173
228
 
174
229
  ```typescript
175
- // environments/environment.ts
176
- export const environment: Environment = {
177
- isProduction: false,
178
- apiBaseUrl: 'http://localhost:3000/api/',
179
- tokenKey: 'dev_token',
180
- refreshTokenKey: 'dev_refresh_token',
181
- clientId: 'dev-app',
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
- ### Runtime Configuration
239
+ **Usage:**
197
240
 
198
241
  ```typescript
199
- // app.config.ts
200
- export function createAppConfig(): ApplicationConfig {
201
- return {
202
- providers: [
203
- {
204
- provide: ENVIRONMENT,
205
- useFactory: () => {
206
- // Load from external config or detect environment
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
- ### Feature Flags Integration
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
- ```typescript
219
- @Injectable()
220
- export class FeatureService {
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
- isFeatureEnabled(feature: string): boolean {
224
- // Use configuration to enable/disable features
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
- private isFeatureInProd(feature: string): boolean {
229
- // Production feature logic
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
- ## Running unit tests
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
- Run `nx test ng-config` to execute the unit tests.
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 * as i0 from '@angular/core';
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, AppConfigService, ENVIRONMENT };
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":["../tmp-esm2022/lib/constants/auth.constants.js","../tmp-esm2022/lib/constants/index.js","../tmp-esm2022/lib/environment.token.js","../tmp-esm2022/lib/services/app-config.service.js","../tmp-esm2022/acontplus-ng-config.js"],"sourcesContent":["// src/lib/constants/auth.constants.ts\nexport const AUTH_API = {\n AUTH: 'auth/',\n};\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aC5jb25zdGFudHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9uZy1jb25maWcvc3JjL2xpYi9jb25zdGFudHMvYXV0aC5jb25zdGFudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsc0NBQXNDO0FBQ3RDLE1BQU0sQ0FBQyxNQUFNLFFBQVEsR0FBRztJQUN0QixJQUFJLEVBQUUsT0FBTztDQUNMLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBzcmMvbGliL2NvbnN0YW50cy9hdXRoLmNvbnN0YW50cy50c1xuZXhwb3J0IGNvbnN0IEFVVEhfQVBJID0ge1xuICBBVVRIOiAnYXV0aC8nLFxufSBhcyBjb25zdDtcbiJdfQ==","// src/lib/constants/index.ts\nexport * from './auth.constants';\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9uZy1jb25maWcvc3JjL2xpYi9jb25zdGFudHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNkJBQTZCO0FBQzdCLGNBQWMsa0JBQWtCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBzcmMvbGliL2NvbnN0YW50cy9pbmRleC50c1xuZXhwb3J0ICogZnJvbSAnLi9hdXRoLmNvbnN0YW50cyc7XG4iXX0=","import { InjectionToken } from '@angular/core';\n/**\n * @const ENVIRONMENT\n * Injection token for the environment interface to be provided by the applications.\n */\nexport const ENVIRONMENT = new InjectionToken('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//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW52aXJvbm1lbnQudG9rZW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9uZy1jb25maWcvc3JjL2xpYi9lbnZpcm9ubWVudC50b2tlbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQU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FyLWFwcCcsXG4gICAgbG9naW5Sb3V0ZTogJ2F1dGgnLFxuICB9KSxcbn0pO1xuIl19","import { Injectable, inject } from '@angular/core';\nimport { ENVIRONMENT } from '../environment.token';\nimport * as i0 from \"@angular/core\";\nexport class AppConfigService {\n environment = inject(ENVIRONMENT);\n defaultTimeout = 30000; // Default timeout\n get apiUrl() {\n return this.environment.apiBaseUrl;\n }\n get apiTimeout() {\n return this.defaultTimeout;\n }\n get enableLogging() {\n return !this.environment.isProduction;\n }\n get production() {\n return this.environment.isProduction;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"20.3.2\", ngImport: i0, type: AppConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"20.3.2\", ngImport: i0, type: AppConfigService, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"20.3.2\", ngImport: i0, type: AppConfigService, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLWNvbmZpZy5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvbmctY29uZmlnL3NyYy9saWIvc2VydmljZXMvYXBwLWNvbmZpZy5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ25ELE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQzs7QUFVbkQsTUFBTSxPQUFPLGdCQUFnQjtJQUNuQixXQUFXLEdBQUcsTUFBTSxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQ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Fkb25seSBkZWZhdWx0VGltZW91dCA9IDMwMDAwOyAvLyBEZWZhdWx0IHRpbWVvdXRcblxuICBnZXQgYXBpVXJsKCk6IHN0cmluZyB7XG4gICAgcmV0dXJuIHRoaXMuZW52aXJvbm1lbnQuYXBpQmFzZVVybDtcbiAgfVxuXG4gIGdldCBhcGlUaW1lb3V0KCk6IG51bWJlciB7XG4gICAgcmV0dXJuIHRoaXMuZGVmYXVsdFRpbWVvdXQ7XG4gIH1cblxuICBnZXQgZW5hYmxlTG9nZ2luZygpOiBib29sZWFuIHtcbiAgICByZXR1cm4gIXRoaXMuZW52aXJvbm1lbnQuaXNQcm9kdWN0aW9uO1xuICB9XG5cbiAgZ2V0IHByb2R1Y3Rpb24oKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuIHRoaXMuZW52aXJvbm1lbnQuaXNQcm9kdWN0aW9uO1xuICB9XG59XG4iXX0=","/**\n * Generated bundle index. Do not edit.\n */\nexport * from './index';\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNvbnRwbHVzLW5nLWNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL25nLWNvbmZpZy9zcmMvYWNvbnRwbHVzLW5nLWNvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ=="],"names":[],"mappings":";;;AAAA;AACY,MAAC,QAAQ,GAAG;AACxB,IAAI,IAAI,EAAE,OAAO;AACjB;;ACHA;;ACCA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,IAAI,cAAc,CAAC,aAA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EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC;AAC1H,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE;AACzC,SAAS,CAAC,EAAE,CAAC;;ACxBb;AACA;AACA;;;;"}
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 * as i0 from '@angular/core';
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
- interface IAppConfig {
16
- apiUrl: string;
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.0.6",
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.0.17",
7
- "@angular/common": "^20.3.2",
8
- "@angular/core": "^20.3.2"
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
- "settings",
34
- "tokens",
33
+ "runtime-configuration",
34
+ "settings-management",
35
+ "injection-tokens",
35
36
  "dependency-injection",
37
+ "config-services",
38
+ "environment-management",
36
39
  "typescript",
37
- "frontend",
38
- "library"
40
+ "enterprise",
41
+ "frontend"
39
42
  ],
40
43
  "author": "Ivan Paz <ifer343@gmail.com>",
41
44
  "license": "MIT",