@osovitny/anatoly 3.17.72 → 3.17.74

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.
@@ -6,7 +6,7 @@ import { NavigationEnd, NavigationStart, NavigationCancel, NavigationError, Rout
6
6
  import * as i1$1 from '@angular/common/http';
7
7
  import { HttpResponse, HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
8
8
  import { map, tap, mergeMap } from 'rxjs/operators';
9
- import { BehaviorSubject, Subject, filter, takeUntil, map as map$1, catchError, of, timer, merge, fromEvent, forkJoin } from 'rxjs';
9
+ import { BehaviorSubject, Subject, filter, takeUntil, map as map$1, catchError, of, merge, forkJoin, timer, fromEvent } from 'rxjs';
10
10
  import * as i4 from '@azure/msal-angular';
11
11
  import { MSAL_GUARD_CONFIG, MsalGuard, MsalInterceptor, MSAL_INTERCEPTOR_CONFIG, MSAL_INSTANCE, MsalService, MsalBroadcastService, MsalModule } from '@azure/msal-angular';
12
12
  import { BrowserUtils, EventType, InteractionStatus, InteractionType, InteractionRequiredAuthError, PromptValue, PublicClientApplication, LogLevel } from '@azure/msal-browser';
@@ -597,27 +597,6 @@ class BaseGoService {
597
597
  type: Injectable
598
598
  }], () => [{ type: i1.ActivatedRoute }, { type: i1.Router }], null); })();
599
599
 
600
- /*
601
- <file>
602
- Project:
603
- @osovitny/anatoly
604
-
605
- Authors:
606
- Vadim Osovitny vadim@osovitny.com
607
- Anatoly Osovitny anatoly@osovitny.com
608
-
609
- Created:
610
- 26 Jun 2020
611
-
612
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
613
- </file>
614
- */
615
- function throwIfAlreadyLoaded(parentModule, moduleName) {
616
- if (parentModule) {
617
- throw new Error(`${moduleName} has already been loaded. Import ${moduleName} modules in the AppModule only.`);
618
- }
619
- }
620
-
621
600
  /*
622
601
  <file>
623
602
  Project:
@@ -1108,12 +1087,12 @@ class AppContextService extends ApiServiceBase {
1108
1087
  if (this.subscription != null) {
1109
1088
  return;
1110
1089
  }
1111
- //Log
1112
- let stopwatch = new Stopwatch("Requesting a new AppContext");
1090
+ //Logging
1091
+ let stopwatch = new Stopwatch("AppContextService: Requesting a new AppContext");
1113
1092
  stopwatch.start();
1114
1093
  this.subscription = this.get('getCurrentContext', null).subscribe({
1115
1094
  next: (data) => {
1116
- //Log
1095
+ //Logging
1117
1096
  stopwatch.stop();
1118
1097
  stopwatch.printElapsedAsMilliseconds();
1119
1098
  this.dataReceived(data);
@@ -1148,6 +1127,12 @@ class AppContextService extends ApiServiceBase {
1148
1127
  this.current = context;
1149
1128
  }
1150
1129
  }
1130
+ loadRequiredJsonFiles() {
1131
+ return null;
1132
+ }
1133
+ loadRequiredItems() {
1134
+ return null;
1135
+ }
1151
1136
  updateCurrent(success = null) {
1152
1137
  this.getCurrentPrivate(success, false);
1153
1138
  }
@@ -1785,13 +1770,17 @@ class LoadingService extends BehaviorSubject {
1785
1770
  */
1786
1771
  //Node
1787
1772
  class LoggingService {
1788
- constructor() { }
1789
- logError(error) {
1790
- console.error(error);
1773
+ constructor() {
1791
1774
  }
1792
- logInformation(info) {
1775
+ info(info) {
1793
1776
  console.info(info);
1794
1777
  }
1778
+ warn(info) {
1779
+ console.warn(info);
1780
+ }
1781
+ error(error) {
1782
+ console.error(error);
1783
+ }
1795
1784
  static { this.ɵfac = function LoggingService_Factory(t) { return new (t || LoggingService)(); }; }
1796
1785
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoggingService, factory: LoggingService.ɵfac, providedIn: "root" }); }
1797
1786
  }
@@ -1819,10 +1808,10 @@ class LoggingService {
1819
1808
  */
1820
1809
  //Node
1821
1810
  class AnatolyHttpInterceptor {
1822
- constructor(authService, loadingService, loggingService) {
1811
+ constructor(authService, loadingService, logger) {
1823
1812
  this.authService = authService;
1824
1813
  this.loadingService = loadingService;
1825
- this.loggingService = loggingService;
1814
+ this.logger = logger;
1826
1815
  this.longRunningExceptions = [
1827
1816
  'chunkupload',
1828
1817
  ];
@@ -1838,7 +1827,6 @@ class AnatolyHttpInterceptor {
1838
1827
  ];
1839
1828
  }
1840
1829
  handleHttpRequest(request, next, loadingRequired) {
1841
- //#1. old approach
1842
1830
  return next.handle(request).pipe(tap({
1843
1831
  next: (event) => {
1844
1832
  if (event instanceof HttpResponse) {
@@ -1847,27 +1835,9 @@ class AnatolyHttpInterceptor {
1847
1835
  },
1848
1836
  error: (err) => {
1849
1837
  this.onRequestEnd(loadingRequired);
1850
- this.loggingService.logError(err);
1838
+ this.logger.error(err);
1851
1839
  }
1852
1840
  }));
1853
- //#2. new approach
1854
- /*
1855
- return next.handle(request).pipe(
1856
- map(event => {
1857
- if (event instanceof HttpResponse) {
1858
- this.onRequestEnd(loadingRequired);
1859
- }
1860
-
1861
- return event;
1862
- }),
1863
- catchError((error) => {
1864
- this.onRequestEnd(loadingRequired);
1865
-
1866
- let errorMsg = "Something went wrong!";
1867
- return throwError(() => new Error(errorMsg))
1868
- })
1869
- )
1870
- */
1871
1841
  }
1872
1842
  intercept(req, next) {
1873
1843
  let isCDNEnabled = AppCoreSettings.IsCDNEnabled;
@@ -1975,23 +1945,13 @@ class AnatolyHttpInterceptor {
1975
1945
 
1976
1946
  Created:
1977
1947
  26 Jun 2020
1978
-
1948
+
1979
1949
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1980
1950
  </file>
1981
1951
  */
1982
- class Subs {
1983
- constructor() {
1984
- this.subs = [];
1985
- }
1986
- add(...subscriptions) {
1987
- this.subs = this.subs.concat(subscriptions);
1988
- }
1989
- set sink(subscription) {
1990
- this.subs.push(subscription);
1991
- }
1992
- unsubscribe() {
1993
- this.subs.forEach((sub) => sub && sub.unsubscribe());
1994
- this.subs = [];
1952
+ function throwIfAlreadyLoaded(parentModule, moduleName) {
1953
+ if (parentModule) {
1954
+ throw new Error(`${moduleName} has already been loaded. Import ${moduleName} modules in the AppModule only.`);
1995
1955
  }
1996
1956
  }
1997
1957
 
@@ -2094,6 +2054,151 @@ is = {
2094
2054
  };
2095
2055
  */
2096
2056
 
2057
+ class StarterService extends ApiServiceBase {
2058
+ constructor(http, appContext, logger) {
2059
+ super(http);
2060
+ this.http = http;
2061
+ this.appContext = appContext;
2062
+ this.logger = logger;
2063
+ }
2064
+ applicationStarting() {
2065
+ let context = this.appContext.current;
2066
+ if (!is.objectNullOrEmpty(context)) {
2067
+ //Logging
2068
+ this.logger.info('StarterService.applicationStarting: got AppContext from Session Storage');
2069
+ this.appContext.init(context);
2070
+ return of(context);
2071
+ }
2072
+ //Logging
2073
+ this.logger.info('StarterService.applicationStarting: there is no AppContext in Session Storage');
2074
+ //Logging
2075
+ let stopwatch = new Stopwatch("StarterService.applicationStarting: getting AppContext");
2076
+ stopwatch.start();
2077
+ this.baseUrl = `${ApiUrl}/appContext`;
2078
+ return this.get('applicationStarting').pipe(map(data => {
2079
+ //Logging
2080
+ stopwatch.stop();
2081
+ stopwatch.printElapsedAsMilliseconds();
2082
+ this.appContext.init(data.context);
2083
+ }));
2084
+ }
2085
+ ensureApplicationStarted() {
2086
+ //1. Application Starting
2087
+ let applicationStarting$ = this.applicationStarting();
2088
+ //2. Load json files
2089
+ let jsonFiles$ = this.appContext.loadRequiredJsonFiles();
2090
+ //3. Load required items, like settings
2091
+ let requiredItems$ = this.appContext.loadRequiredItems();
2092
+ //Tasks to execute
2093
+ let parallelTasks = [];
2094
+ let tasks$ = null;
2095
+ if (jsonFiles$)
2096
+ parallelTasks.push(jsonFiles$);
2097
+ if (requiredItems$)
2098
+ parallelTasks.push(requiredItems$);
2099
+ /*
2100
+ VadimOS:
2101
+ concat is NOT wokring here, no idea why. Just executing first task
2102
+ let tasks$ = concat(applicationStarting$, parallelTasks$);
2103
+
2104
+ https://github.com/ReactiveX/rxjs/issues/2427
2105
+ https://github.com/ReactiveX/rxjs/issues/2188
2106
+ */
2107
+ if (parallelTasks.length > 0) {
2108
+ let parallelTasks$ = merge(...parallelTasks);
2109
+ tasks$ = forkJoin([applicationStarting$, parallelTasks$]);
2110
+ }
2111
+ else {
2112
+ tasks$ = applicationStarting$;
2113
+ }
2114
+ //Logging
2115
+ let stopwatch = new Stopwatch("StarterService.ensureApplicationStarted");
2116
+ stopwatch.start();
2117
+ return tasks$.pipe(map(() => {
2118
+ //Logging
2119
+ stopwatch.stop();
2120
+ stopwatch.printElapsedAsMilliseconds();
2121
+ }));
2122
+ }
2123
+ static { this.ɵfac = function StarterService_Factory(t) { return new (t || StarterService)(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(AppContextService), i0.ɵɵinject(LoggingService)); }; }
2124
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StarterService, factory: StarterService.ɵfac }); }
2125
+ }
2126
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StarterService, [{
2127
+ type: Injectable
2128
+ }], () => [{ type: i1$1.HttpClient }, { type: AppContextService }, { type: LoggingService }], null); })();
2129
+
2130
+ /*
2131
+ <file>
2132
+ Project:
2133
+ @osovitny/anatoly
2134
+
2135
+ Authors:
2136
+ Vadim Osovitny vadim@osovitny.com
2137
+ Anatoly Osovitny anatoly@osovitny.com
2138
+
2139
+ Created:
2140
+ 15 Nov 2023
2141
+
2142
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
2143
+ </file>
2144
+ */
2145
+ //Node
2146
+ class StarterGuard {
2147
+ constructor(starter) {
2148
+ this.starter = starter;
2149
+ }
2150
+ ensureApplicationStarted() {
2151
+ return this.starter.ensureApplicationStarted().pipe(mergeMap(() => {
2152
+ return of(true);
2153
+ }));
2154
+ }
2155
+ canActivate(next, state) {
2156
+ return this.ensureApplicationStarted();
2157
+ }
2158
+ canActivateChild(route, state) {
2159
+ if (route.component) {
2160
+ return this.ensureApplicationStarted();
2161
+ }
2162
+ return of(true);
2163
+ }
2164
+ static { this.ɵfac = function StarterGuard_Factory(t) { return new (t || StarterGuard)(i0.ɵɵinject(StarterService)); }; }
2165
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StarterGuard, factory: StarterGuard.ɵfac }); }
2166
+ }
2167
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StarterGuard, [{
2168
+ type: Injectable
2169
+ }], () => [{ type: StarterService }], null); })();
2170
+
2171
+ /*
2172
+ <file>
2173
+ Project:
2174
+ @osovitny/anatoly
2175
+
2176
+ Authors:
2177
+ Vadim Osovitny vadim@osovitny.com
2178
+ Anatoly Osovitny anatoly@osovitny.com
2179
+
2180
+ Created:
2181
+ 26 Jun 2020
2182
+
2183
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
2184
+ </file>
2185
+ */
2186
+ class Subs {
2187
+ constructor() {
2188
+ this.subs = [];
2189
+ }
2190
+ add(...subscriptions) {
2191
+ this.subs = this.subs.concat(subscriptions);
2192
+ }
2193
+ set sink(subscription) {
2194
+ this.subs.push(subscription);
2195
+ }
2196
+ unsubscribe() {
2197
+ this.subs.forEach((sub) => sub && sub.unsubscribe());
2198
+ this.subs = [];
2199
+ }
2200
+ }
2201
+
2097
2202
  /*
2098
2203
  <file>
2099
2204
  Project:
@@ -2503,13 +2608,13 @@ class L10nUtils {
2503
2608
  Created:
2504
2609
  26 Jun 2020
2505
2610
 
2611
+ Details:
2612
+ https://medium.com/@amcdnl/global-error-handling-with-angular2-6b992bdfb59c
2613
+ https://medium.com/angular-in-depth/expecting-the-unexpected-best-practices-for-error-handling-in-angular-21c3662ef9e4
2614
+
2506
2615
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
2507
2616
  </file>
2508
2617
  */
2509
- /*
2510
- https://medium.com/@amcdnl/global-error-handling-with-angular2-6b992bdfb59c
2511
- https://medium.com/angular-in-depth/expecting-the-unexpected-best-practices-for-error-handling-in-angular-21c3662ef9e4
2512
- */
2513
2618
  //Node
2514
2619
  class GlobalErrorHandler {
2515
2620
  constructor(injector) {
@@ -2517,7 +2622,7 @@ class GlobalErrorHandler {
2517
2622
  }
2518
2623
  handleError(error) {
2519
2624
  const loggingService = this.injector.get(LoggingService);
2520
- loggingService.logError(error);
2625
+ loggingService.error(error);
2521
2626
  // IMPORTANT: Rethrow the error otherwise it gets swallowed
2522
2627
  throw error;
2523
2628
  }
@@ -2813,11 +2918,12 @@ class DigitalMarketingService {
2813
2918
  29 Nov 2020
2814
2919
 
2815
2920
  Details:
2816
- https://yashints.dev/blog/2019/02/12/angular-ga-tagmanager
2817
- https://developers.google.com/analytics/devguides/collection/gtagjs/pages
2818
- https://developers.google.com/analytics/devguides/collection/upgrade/analyticsjs
2819
2921
  https://medium.com/@danielfilipkowskiblogs/adding-google-analytics-to-angular-v15-1766c4bdaed5
2820
2922
 
2923
+ API:
2924
+ https://developers.google.com/tag-platform/gtagjs/reference
2925
+ https://developers.google.com/analytics/devguides/collection/ga4/events?client_type=gtag
2926
+
2821
2927
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
2822
2928
  </file>
2823
2929
  */
@@ -2943,84 +3049,6 @@ class IdleService {
2943
3049
  }]
2944
3050
  }], null, null); })();
2945
3051
 
2946
- /*
2947
- <file>
2948
- Project:
2949
- @osovitny/anatoly
2950
-
2951
- Authors:
2952
- Vadim Osovitny vadim@osovitny.com
2953
- Anatoly Osovitny anatoly@osovitny.com
2954
-
2955
- Created:
2956
- 15 Nov 2023
2957
-
2958
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
2959
- </file>
2960
- */
2961
- class StarterServiceBase extends ApiServiceBase {
2962
- constructor(http, appContext) {
2963
- super(http);
2964
- this.http = http;
2965
- this.appContext = appContext;
2966
- }
2967
- applicationStarting() {
2968
- let context = this.appContext.current;
2969
- if (!is.objectNullOrEmpty(context)) {
2970
- //this.appContext.init(context);
2971
- return of(context);
2972
- }
2973
- //Log
2974
- let stopwatch = new Stopwatch("applicationStarting");
2975
- stopwatch.start();
2976
- this.baseUrl = `${ApiUrl}/appContext`;
2977
- return this.get('applicationStarting').pipe(map(data => {
2978
- //Log
2979
- stopwatch.stop();
2980
- stopwatch.printElapsedAsMilliseconds();
2981
- this.appContext.init(data.context);
2982
- }));
2983
- }
2984
- ensureApplicationStarted() {
2985
- //1. Application Starting
2986
- let applicationStarting$ = this.applicationStarting();
2987
- //2. Load json files
2988
- let jsonFiles$ = this.appContext.loadRequiredJsonFiles();
2989
- //3. Load required items, like settings
2990
- let requiredItems$ = this.appContext.loadRequiredItems();
2991
- //Tasks to execute
2992
- let parallelTasks = [];
2993
- let tasks$ = null;
2994
- if (jsonFiles$)
2995
- parallelTasks.push(jsonFiles$);
2996
- if (requiredItems$)
2997
- parallelTasks.push(requiredItems$);
2998
- /*
2999
- VadimOS:
3000
- concat is NOT wokring here, no idea why. Just executing first task
3001
- let tasks$ = concat(applicationStarting$, parallelTasks$);
3002
-
3003
- https://github.com/ReactiveX/rxjs/issues/2427
3004
- https://github.com/ReactiveX/rxjs/issues/2188
3005
- */
3006
- if (parallelTasks.length > 0) {
3007
- let parallelTasks$ = merge(...parallelTasks);
3008
- tasks$ = forkJoin([applicationStarting$, parallelTasks$]);
3009
- }
3010
- else {
3011
- tasks$ = applicationStarting$;
3012
- }
3013
- //Log
3014
- let stopwatch = new Stopwatch("ensureApplicationStarted");
3015
- stopwatch.start();
3016
- return tasks$.pipe(map(() => {
3017
- //Log
3018
- stopwatch.stop();
3019
- stopwatch.printElapsedAsMilliseconds();
3020
- }));
3021
- }
3022
- }
3023
-
3024
3052
  /*
3025
3053
  <file>
3026
3054
  Project:
@@ -7551,6 +7579,7 @@ class AnatolyCoreModule {
7551
7579
  DigitalMarketingService,
7552
7580
  GoogleAnalyticsService,
7553
7581
  LoadingService,
7582
+ StarterService,
7554
7583
  LocalStorageService,
7555
7584
  SessionStorageService,
7556
7585
  LoggingService,
@@ -7582,6 +7611,7 @@ class AnatolyCoreModule {
7582
7611
  DigitalMarketingService,
7583
7612
  GoogleAnalyticsService,
7584
7613
  LoadingService,
7614
+ StarterService,
7585
7615
  LocalStorageService,
7586
7616
  SessionStorageService,
7587
7617
  LoggingService,
@@ -8413,5 +8443,5 @@ class AnatolyModule {
8413
8443
  * Generated bundle index. Do not edit.
8414
8444
  */
8415
8445
 
8416
- export { AddressComponent, AdminGuard, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyPaymentsModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AuthService, AuthenticationGuard, BaseGoService, Browser, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, DOM, DataPagerComponent, DateConvert, DefaultEditorOptions, DialogBase, DigitalMarketingService, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, InjectorInstance, IsDevMode, IsProdMode, ItemValidationSummaryComponent, L10NUrl, L10nUtils, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, NativeElementDirective, NodataComponent, NotificationService, PageBase, PageSpinnerComponent, PagedPageBase, PayPalComponent, PayPalScriptService, QSUtils, ReplaceTextPipe, SafeHtmlPipe, ScriptService, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterServiceBase, Stopwatch, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, dateFormats, dateTimeFormats, getAppSettingsById, getAppSettingsByName, is, localizationInitializerFactory, throwIfAlreadyLoaded, timeFormats, translateLoaderFactory };
8446
+ export { AddressComponent, AdminGuard, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyPaymentsModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AuthService, AuthenticationGuard, BaseGoService, Browser, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, DOM, DataPagerComponent, DateConvert, DefaultEditorOptions, DialogBase, DigitalMarketingService, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, InjectorInstance, IsDevMode, IsProdMode, ItemValidationSummaryComponent, L10NUrl, L10nUtils, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, NativeElementDirective, NodataComponent, NotificationService, PageBase, PageSpinnerComponent, PagedPageBase, PayPalComponent, PayPalScriptService, QSUtils, ReplaceTextPipe, SafeHtmlPipe, ScriptService, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterGuard, StarterService, Stopwatch, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, dateFormats, dateTimeFormats, getAppSettingsById, getAppSettingsByName, is, localizationInitializerFactory, throwIfAlreadyLoaded, timeFormats, translateLoaderFactory };
8417
8447
  //# sourceMappingURL=osovitny-anatoly.mjs.map