@acontplus/ng-infrastructure 1.0.8 → 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 +320 -45
- package/fesm2022/acontplus-ng-infrastructure.mjs +44 -71
- package/fesm2022/acontplus-ng-infrastructure.mjs.map +1 -1
- package/index.d.ts +11 -54
- package/package.json +23 -9
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, Injectable, signal, computed } from '@angular/core';
|
|
3
1
|
import { HttpContextToken, HttpResponse, HttpContext, HttpClient } from '@angular/common/http';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, Injectable, signal, computed, InjectionToken } from '@angular/core';
|
|
4
4
|
import { retry, map, catchError, finalize } from 'rxjs/operators';
|
|
5
5
|
import { throwError, catchError as catchError$1, switchMap, lastValueFrom } from 'rxjs';
|
|
6
6
|
import { NotificationService } from '@acontplus/ng-notifications';
|
|
7
|
+
import { AUTH_TOKEN, ENVIRONMENT, CORE_CONFIG, DEFAULT_CONFIG as DEFAULT_CONFIG$1 } from '@acontplus/ng-config';
|
|
7
8
|
import { Router } from '@angular/router';
|
|
8
9
|
import { v4 } from 'uuid';
|
|
9
|
-
import { ENVIRONMENT } from '@acontplus/ng-config';
|
|
10
10
|
import { OverlayService } from '@acontplus/ng-components';
|
|
11
11
|
|
|
12
|
-
const TOKEN_PROVIDER = new InjectionToken('TOKEN_PROVIDER');
|
|
13
|
-
|
|
14
12
|
// A token to use with HttpContext for skipping notifications on specific requests.
|
|
15
13
|
const SKIP_NOTIFICATION = new HttpContextToken(() => false);
|
|
16
14
|
// A token to use with HttpContext for forcing notifications on specific requests (overrides exclusion patterns).
|
|
17
15
|
const SHOW_NOTIFICATIONS = new HttpContextToken(() => undefined);
|
|
18
16
|
const apiInterceptor = (req, next) => {
|
|
19
17
|
const toastr = inject(NotificationService);
|
|
20
|
-
const tokenProvider = inject(
|
|
18
|
+
const tokenProvider = inject(AUTH_TOKEN, { optional: true });
|
|
21
19
|
// Add authorization header if token is available
|
|
22
20
|
let modifiedReq = req;
|
|
23
21
|
const token = tokenProvider?.getToken();
|
|
@@ -312,17 +310,17 @@ class LoggingService {
|
|
|
312
310
|
// e.g., Sentry, LogRocket, etc.
|
|
313
311
|
// This is a placeholder for production logging implementation
|
|
314
312
|
}
|
|
315
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
316
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
313
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: LoggingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
314
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: LoggingService, providedIn: 'root' });
|
|
317
315
|
}
|
|
318
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
316
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: LoggingService, decorators: [{
|
|
319
317
|
type: Injectable,
|
|
320
318
|
args: [{
|
|
321
319
|
providedIn: 'root',
|
|
322
320
|
}]
|
|
323
321
|
}] });
|
|
324
322
|
|
|
325
|
-
class
|
|
323
|
+
class TenantInfo {
|
|
326
324
|
tenantId = null;
|
|
327
325
|
logger = inject(LoggingService);
|
|
328
326
|
getTenantId() {
|
|
@@ -361,17 +359,17 @@ class TenantService {
|
|
|
361
359
|
localStorage.removeItem('tenantId');
|
|
362
360
|
sessionStorage.removeItem('tenantId');
|
|
363
361
|
}
|
|
364
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
365
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
362
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: TenantInfo, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
363
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: TenantInfo, providedIn: 'root' });
|
|
366
364
|
}
|
|
367
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
365
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: TenantInfo, decorators: [{
|
|
368
366
|
type: Injectable,
|
|
369
367
|
args: [{
|
|
370
368
|
providedIn: 'root',
|
|
371
369
|
}]
|
|
372
370
|
}] });
|
|
373
371
|
|
|
374
|
-
class
|
|
372
|
+
class CorrelationInfo {
|
|
375
373
|
correlationId = signal(null, ...(ngDevMode ? [{ debugName: "correlationId" }] : []));
|
|
376
374
|
CORRELATION_KEY = 'correlation-id';
|
|
377
375
|
// Signal-based getter for reactive updates
|
|
@@ -396,10 +394,10 @@ class CorrelationService {
|
|
|
396
394
|
getId() {
|
|
397
395
|
return this.getOrCreateCorrelationId();
|
|
398
396
|
}
|
|
399
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
400
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
397
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: CorrelationInfo, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
398
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: CorrelationInfo, providedIn: 'root' });
|
|
401
399
|
}
|
|
402
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
400
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: CorrelationInfo, decorators: [{
|
|
403
401
|
type: Injectable,
|
|
404
402
|
args: [{
|
|
405
403
|
providedIn: 'root',
|
|
@@ -421,7 +419,7 @@ function withCustomHeaders(headers) {
|
|
|
421
419
|
return new HttpContext().set(CUSTOM_HEADERS, headers);
|
|
422
420
|
}
|
|
423
421
|
// Default configuration
|
|
424
|
-
const DEFAULT_CONFIG
|
|
422
|
+
const DEFAULT_CONFIG = {
|
|
425
423
|
enableCorrelationTracking: true,
|
|
426
424
|
enableRequestLogging: false, // This will be overridden by environment.isProduction
|
|
427
425
|
enableErrorLogging: true,
|
|
@@ -439,18 +437,18 @@ const DEFAULT_CONFIG$1 = {
|
|
|
439
437
|
};
|
|
440
438
|
// Injection token for configuration - FIXED
|
|
441
439
|
const HTTP_CONTEXT_CONFIG = new InjectionToken('HTTP_CONTEXT_CONFIG', {
|
|
442
|
-
factory: () => DEFAULT_CONFIG
|
|
440
|
+
factory: () => DEFAULT_CONFIG, // Provide a default factory in case it's not provided
|
|
443
441
|
});
|
|
444
442
|
const httpContextInterceptor = (req, next) => {
|
|
445
|
-
const tokenProvider = inject(
|
|
443
|
+
const tokenProvider = inject(AUTH_TOKEN, { optional: true });
|
|
446
444
|
const router = inject(Router);
|
|
447
|
-
const tenantService = inject(
|
|
448
|
-
const correlationService = inject(
|
|
445
|
+
const tenantService = inject(TenantInfo);
|
|
446
|
+
const correlationService = inject(CorrelationInfo);
|
|
449
447
|
const loggingService = inject(LoggingService);
|
|
450
448
|
const environment = inject(ENVIRONMENT);
|
|
451
449
|
// Get configuration (with fallback to default) - FIXED
|
|
452
450
|
const config = {
|
|
453
|
-
...DEFAULT_CONFIG
|
|
451
|
+
...DEFAULT_CONFIG,
|
|
454
452
|
// The default enableRequestLogging needs to be set based on environment here,
|
|
455
453
|
// as it's dynamic, and DEFAULT_CONFIG is static.
|
|
456
454
|
enableRequestLogging: !environment.isProduction,
|
|
@@ -640,7 +638,7 @@ const httpContextInterceptor = (req, next) => {
|
|
|
640
638
|
// Helper function to create configuration
|
|
641
639
|
function createHttpContextConfig(overrides = {}) {
|
|
642
640
|
return {
|
|
643
|
-
...DEFAULT_CONFIG
|
|
641
|
+
...DEFAULT_CONFIG,
|
|
644
642
|
...overrides,
|
|
645
643
|
};
|
|
646
644
|
}
|
|
@@ -683,10 +681,10 @@ class ActiveRequestsTracker {
|
|
|
683
681
|
requests.splice(index, 1);
|
|
684
682
|
}
|
|
685
683
|
}
|
|
686
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
687
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
684
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ActiveRequestsTracker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
685
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ActiveRequestsTracker, providedIn: 'root' });
|
|
688
686
|
}
|
|
689
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
687
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ActiveRequestsTracker, decorators: [{
|
|
690
688
|
type: Injectable,
|
|
691
689
|
args: [{
|
|
692
690
|
providedIn: 'root',
|
|
@@ -741,10 +739,10 @@ class BaseHttpRepository {
|
|
|
741
739
|
delete(path = '') {
|
|
742
740
|
return this.http.delete(this.buildUrl(path));
|
|
743
741
|
}
|
|
744
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
745
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
742
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: BaseHttpRepository, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
743
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: BaseHttpRepository });
|
|
746
744
|
}
|
|
747
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
745
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: BaseHttpRepository, decorators: [{
|
|
748
746
|
type: Injectable
|
|
749
747
|
}] });
|
|
750
748
|
|
|
@@ -788,10 +786,10 @@ class GenericRepository extends BaseHttpRepository {
|
|
|
788
786
|
}
|
|
789
787
|
return params;
|
|
790
788
|
}
|
|
791
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
792
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
789
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: GenericRepository, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
790
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: GenericRepository });
|
|
793
791
|
}
|
|
794
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
792
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: GenericRepository, decorators: [{
|
|
795
793
|
type: Injectable
|
|
796
794
|
}], ctorParameters: () => [] });
|
|
797
795
|
class SearchableGenericRepository extends GenericRepository {
|
|
@@ -800,10 +798,10 @@ class SearchableGenericRepository extends GenericRepository {
|
|
|
800
798
|
const params = this.buildParams(pagination, searchFilters);
|
|
801
799
|
return this.get('search', params);
|
|
802
800
|
}
|
|
803
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
804
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
801
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: SearchableGenericRepository, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
802
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: SearchableGenericRepository });
|
|
805
803
|
}
|
|
806
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
804
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: SearchableGenericRepository, decorators: [{
|
|
807
805
|
type: Injectable
|
|
808
806
|
}] });
|
|
809
807
|
|
|
@@ -846,10 +844,10 @@ class RepositoryFactory {
|
|
|
846
844
|
remove: (id) => this.http.delete(buildUrl(idToString(id))),
|
|
847
845
|
};
|
|
848
846
|
}
|
|
849
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
850
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
847
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: RepositoryFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
848
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: RepositoryFactory, providedIn: 'root' });
|
|
851
849
|
}
|
|
852
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
850
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: RepositoryFactory, decorators: [{
|
|
853
851
|
type: Injectable,
|
|
854
852
|
args: [{ providedIn: 'root' }]
|
|
855
853
|
}] });
|
|
@@ -899,35 +897,10 @@ class AngularHttpAdapter {
|
|
|
899
897
|
}
|
|
900
898
|
}
|
|
901
899
|
|
|
902
|
-
// Default configuration
|
|
903
|
-
const DEFAULT_CONFIG = {
|
|
904
|
-
apiBaseUrl: '',
|
|
905
|
-
apiTimeout: 30000,
|
|
906
|
-
retryAttempts: 2,
|
|
907
|
-
retryDelay: 1000,
|
|
908
|
-
enableCorrelationTracking: true,
|
|
909
|
-
enableRequestLogging: false,
|
|
910
|
-
enableErrorLogging: true,
|
|
911
|
-
enableToastNotifications: true,
|
|
912
|
-
includeAuthToken: true,
|
|
913
|
-
authTokenHeader: 'Authorization',
|
|
914
|
-
enableMultiTenancy: true,
|
|
915
|
-
tenantIdHeader: 'Tenant-Id',
|
|
916
|
-
logLevel: 'info',
|
|
917
|
-
enableConsoleLogging: true,
|
|
918
|
-
customHeaders: {},
|
|
919
|
-
excludeUrls: [],
|
|
920
|
-
excludeMethods: [],
|
|
921
|
-
};
|
|
922
|
-
// Injection token for configuration
|
|
923
|
-
const CORE_CONFIG = new InjectionToken('CORE_CONFIG', {
|
|
924
|
-
factory: () => DEFAULT_CONFIG,
|
|
925
|
-
});
|
|
926
900
|
class CoreConfigService {
|
|
927
901
|
config;
|
|
928
902
|
environment = inject(ENVIRONMENT);
|
|
929
903
|
constructor() {
|
|
930
|
-
// Initialize with default config and environment overrides
|
|
931
904
|
this.config = this.initializeConfig();
|
|
932
905
|
}
|
|
933
906
|
/**
|
|
@@ -936,9 +909,9 @@ class CoreConfigService {
|
|
|
936
909
|
initializeConfig() {
|
|
937
910
|
const injectedConfig = inject(CORE_CONFIG, { optional: true });
|
|
938
911
|
return {
|
|
939
|
-
...DEFAULT_CONFIG,
|
|
912
|
+
...DEFAULT_CONFIG$1,
|
|
940
913
|
// Environment overrides
|
|
941
|
-
apiBaseUrl: this.environment.apiBaseUrl || DEFAULT_CONFIG.apiBaseUrl,
|
|
914
|
+
apiBaseUrl: this.environment.apiBaseUrl || DEFAULT_CONFIG$1.apiBaseUrl,
|
|
942
915
|
enableRequestLogging: !this.environment.isProduction,
|
|
943
916
|
// Injected config overrides
|
|
944
917
|
...injectedConfig,
|
|
@@ -1006,10 +979,10 @@ class CoreConfigService {
|
|
|
1006
979
|
resetConfig() {
|
|
1007
980
|
this.config = this.initializeConfig();
|
|
1008
981
|
}
|
|
1009
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
1010
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
982
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: CoreConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
983
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: CoreConfigService, providedIn: 'root' });
|
|
1011
984
|
}
|
|
1012
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
985
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: CoreConfigService, decorators: [{
|
|
1013
986
|
type: Injectable,
|
|
1014
987
|
args: [{
|
|
1015
988
|
providedIn: 'root',
|
|
@@ -1027,7 +1000,7 @@ function provideCoreConfig(config = {}) {
|
|
|
1027
1000
|
// Helper function to create configuration
|
|
1028
1001
|
function createCoreConfig(overrides = {}) {
|
|
1029
1002
|
return {
|
|
1030
|
-
...DEFAULT_CONFIG,
|
|
1003
|
+
...DEFAULT_CONFIG$1,
|
|
1031
1004
|
...overrides,
|
|
1032
1005
|
};
|
|
1033
1006
|
}
|
|
@@ -1076,5 +1049,5 @@ class Query extends BaseUseCase {
|
|
|
1076
1049
|
* Generated bundle index. Do not edit.
|
|
1077
1050
|
*/
|
|
1078
1051
|
|
|
1079
|
-
export { ActiveRequestsTracker, AngularHttpAdapter, BaseHttpRepository, BaseUseCase,
|
|
1052
|
+
export { ActiveRequestsTracker, AngularHttpAdapter, BaseHttpRepository, BaseUseCase, Command, CoreConfigService, CorrelationInfo, GenericRepository, HTTP_CONTEXT_CONFIG, LoggingService, Query, REPOSITORY_CONFIG, RepositoryFactory, SHOW_NOTIFICATIONS, SKIP_NOTIFICATION, SearchableGenericRepository, apiInterceptor, createCoreConfig, createHttpContextConfig, customUrl, httpContextInterceptor, provideCoreConfig, provideHttpContext, skipContextHeaders, spinnerInterceptor, withCustomHeaders, withoutSpinner };
|
|
1080
1053
|
//# sourceMappingURL=acontplus-ng-infrastructure.mjs.map
|