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