@transcommerce/cwm-shared 1.1.34 → 1.1.35
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/fesm2022/transcommerce-cwm-shared.mjs +131 -40
- package/fesm2022/transcommerce-cwm-shared.mjs.map +1 -1
- package/lib/models/config/auth-config.d.ts +2 -1
- package/lib/models/config/msalLoginPrompts.d.ts +5 -0
- package/lib/services/class-logger.service.d.ts +22 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -349,6 +349,45 @@ function isTokenValid(input) {
|
|
|
349
349
|
return exp ? Math.floor(Date.now() / 1000) < exp : false;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
/*
|
|
353
|
+
* A simple generic LIFO stack.
|
|
354
|
+
*
|
|
355
|
+
* Example:
|
|
356
|
+
* ```ts
|
|
357
|
+
* const s = new Stack<number>();
|
|
358
|
+
* s.push(1);
|
|
359
|
+
* s.push(2);
|
|
360
|
+
* console.log(s.pop());
|
|
361
|
+
* @typeParam T - Type of items stored in the stack.
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
class Stack {
|
|
365
|
+
items = [];
|
|
366
|
+
/*
|
|
367
|
+
Pushes an item onto the top of the stack.
|
|
368
|
+
@param item - Item to push.
|
|
369
|
+
*/
|
|
370
|
+
push(item) { this.items.push(item); }
|
|
371
|
+
/*
|
|
372
|
+
Removes and returns the item at the top of the stack.
|
|
373
|
+
@returns The popped item, or undefined if the stack is empty.
|
|
374
|
+
*/
|
|
375
|
+
pop() { return this.items.pop(); }
|
|
376
|
+
/*
|
|
377
|
+
Returns the item at the top without removing it.
|
|
378
|
+
@returns The top item, or undefined if the stack is empty.
|
|
379
|
+
*/
|
|
380
|
+
peek() { return this.items[this.items.length - 1]; }
|
|
381
|
+
/*
|
|
382
|
+
Number of items currently in the stack.
|
|
383
|
+
*/
|
|
384
|
+
get size() { return this.items.length; }
|
|
385
|
+
/*
|
|
386
|
+
Returns a string representation of all items currently in the stack.
|
|
387
|
+
*/
|
|
388
|
+
toString() { return this.items.toString(); }
|
|
389
|
+
}
|
|
390
|
+
|
|
352
391
|
class TimeSpanOverflowError extends Error {
|
|
353
392
|
}
|
|
354
393
|
|
|
@@ -27085,44 +27124,6 @@ const MockCustomer = {
|
|
|
27085
27124
|
"subscriptionId": "1"
|
|
27086
27125
|
};
|
|
27087
27126
|
|
|
27088
|
-
/*
|
|
27089
|
-
* A simple generic LIFO stack.
|
|
27090
|
-
*
|
|
27091
|
-
* Example:
|
|
27092
|
-
* ```ts
|
|
27093
|
-
* const s = new Stack<number>();
|
|
27094
|
-
* s.push(1);
|
|
27095
|
-
* s.push(2);
|
|
27096
|
-
* console.log(s.pop());
|
|
27097
|
-
* @typeParam T - Type of items stored in the stack.
|
|
27098
|
-
*/
|
|
27099
|
-
class Stack {
|
|
27100
|
-
items = [];
|
|
27101
|
-
/*
|
|
27102
|
-
Pushes an item onto the top of the stack.
|
|
27103
|
-
@param item - Item to push.
|
|
27104
|
-
*/
|
|
27105
|
-
push(item) { this.items.push(item); }
|
|
27106
|
-
/*
|
|
27107
|
-
Removes and returns the item at the top of the stack.
|
|
27108
|
-
@returns The popped item, or undefined if the stack is empty.
|
|
27109
|
-
*/
|
|
27110
|
-
pop() { return this.items.pop(); }
|
|
27111
|
-
/*
|
|
27112
|
-
Returns the item at the top without removing it.
|
|
27113
|
-
@returns The top item, or undefined if the stack is empty.
|
|
27114
|
-
*/
|
|
27115
|
-
peek() { return this.items[this.items.length - 1]; }
|
|
27116
|
-
/*
|
|
27117
|
-
Number of items currently in the stack.
|
|
27118
|
-
*/
|
|
27119
|
-
get size() { return this.items.length; }
|
|
27120
|
-
/*
|
|
27121
|
-
Returns a string representation of all items currently in the stack.
|
|
27122
|
-
*/
|
|
27123
|
-
toString() { return this.items.toString(); }
|
|
27124
|
-
}
|
|
27125
|
-
|
|
27126
27127
|
/*
|
|
27127
27128
|
The LogService is really just a wrapper around the existing console logging functionality
|
|
27128
27129
|
The three main reasons for using this service are:
|
|
@@ -27144,6 +27145,7 @@ class LogService {
|
|
|
27144
27145
|
if (this._classStack.size > 0 && this._classStack.peek() !== value) {
|
|
27145
27146
|
//console.groupCollapsed(this.targetName + " - " + value + " - " + new Date().toLocaleString())
|
|
27146
27147
|
console.groupEnd();
|
|
27148
|
+
console.timeEnd(this.targetName);
|
|
27147
27149
|
this._classStack.pop();
|
|
27148
27150
|
}
|
|
27149
27151
|
if (this._classStack.size === 0 || this._classStack.peek() !== value) {
|
|
@@ -27152,6 +27154,8 @@ class LogService {
|
|
|
27152
27154
|
}
|
|
27153
27155
|
else {
|
|
27154
27156
|
this._classStack.push(value);
|
|
27157
|
+
console.groupCollapsed(this.targetName);
|
|
27158
|
+
console.time(this.targetName);
|
|
27155
27159
|
}
|
|
27156
27160
|
}
|
|
27157
27161
|
_methodStack = new Stack();
|
|
@@ -27167,7 +27171,7 @@ class LogService {
|
|
|
27167
27171
|
}
|
|
27168
27172
|
else {
|
|
27169
27173
|
this._methodStack.push(value);
|
|
27170
|
-
console.
|
|
27174
|
+
console.groupCollapsed(this.targetName);
|
|
27171
27175
|
console.time(this.targetName);
|
|
27172
27176
|
this.info("Start of method");
|
|
27173
27177
|
}
|
|
@@ -27354,6 +27358,93 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
|
|
|
27354
27358
|
}]
|
|
27355
27359
|
}], ctorParameters: () => [{ type: ConfigService }, { type: i2$1.HttpClient }, { type: LogService }] });
|
|
27356
27360
|
|
|
27361
|
+
/*
|
|
27362
|
+
*The ClassLoggerService is really just a wrapper around the existing console logging functionality
|
|
27363
|
+
*The four main reasons for using this service are:
|
|
27364
|
+
* 1. The abstraction layer will allow us to pick a different logging endpoint if needed
|
|
27365
|
+
* 2. This service allows you to specify what level of verbosity you want this service to log with
|
|
27366
|
+
* 3. Has logic to log classname, method entry, and method exit points automagically
|
|
27367
|
+
* 4. Keeps track of the call stack to group nested method calls
|
|
27368
|
+
*/
|
|
27369
|
+
class ClassLoggerService {
|
|
27370
|
+
logLevel = 'Info';
|
|
27371
|
+
collapseGroups = true;
|
|
27372
|
+
_className = "";
|
|
27373
|
+
get className() {
|
|
27374
|
+
return this._className;
|
|
27375
|
+
}
|
|
27376
|
+
set className(value) {
|
|
27377
|
+
this._className = value;
|
|
27378
|
+
this.methodName = "constructor()";
|
|
27379
|
+
}
|
|
27380
|
+
callStack = new Stack();
|
|
27381
|
+
get methodName() {
|
|
27382
|
+
return this.callStack.peek() ?? "";
|
|
27383
|
+
}
|
|
27384
|
+
set methodName(value) {
|
|
27385
|
+
if (this.logLevel === 'None') {
|
|
27386
|
+
return;
|
|
27387
|
+
}
|
|
27388
|
+
if (value === "") {
|
|
27389
|
+
this.endOfMethod();
|
|
27390
|
+
}
|
|
27391
|
+
else {
|
|
27392
|
+
this.callStack.push(value);
|
|
27393
|
+
if (this.collapseGroups)
|
|
27394
|
+
console.groupCollapsed(this.targetName);
|
|
27395
|
+
else
|
|
27396
|
+
console.group(this.targetName);
|
|
27397
|
+
console.time(this.targetName);
|
|
27398
|
+
this.info("Start of method");
|
|
27399
|
+
}
|
|
27400
|
+
}
|
|
27401
|
+
endOfMethod() {
|
|
27402
|
+
this.info("End of method");
|
|
27403
|
+
console.groupEnd();
|
|
27404
|
+
console.timeEnd(this.targetName);
|
|
27405
|
+
this.callStack.pop();
|
|
27406
|
+
}
|
|
27407
|
+
get targetName() {
|
|
27408
|
+
if (this.methodName === "")
|
|
27409
|
+
return this.className;
|
|
27410
|
+
else
|
|
27411
|
+
return `${this.className}.${this.methodName}`;
|
|
27412
|
+
}
|
|
27413
|
+
get prefix() {
|
|
27414
|
+
return `${new Date().toLocaleString()} ${this.targetName}> `;
|
|
27415
|
+
}
|
|
27416
|
+
log(message, ...optionalParams) {
|
|
27417
|
+
if (this.logLevel != 'None') {
|
|
27418
|
+
console.log(`${this.prefix} ${message}`, optionalParams);
|
|
27419
|
+
}
|
|
27420
|
+
}
|
|
27421
|
+
debug(message, ...optionalParams) {
|
|
27422
|
+
if (this.logLevel === 'Debug') {
|
|
27423
|
+
console.debug(`${this.prefix} Debug: ${message}`, optionalParams);
|
|
27424
|
+
}
|
|
27425
|
+
}
|
|
27426
|
+
info(message, ...optionalParams) {
|
|
27427
|
+
if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
|
|
27428
|
+
console.info(`${this.prefix} Information: ${message}`, optionalParams);
|
|
27429
|
+
}
|
|
27430
|
+
}
|
|
27431
|
+
warn(message, ...optionalParams) {
|
|
27432
|
+
if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
|
|
27433
|
+
console.warn(`${this.prefix} Warning: ${message}`, optionalParams);
|
|
27434
|
+
}
|
|
27435
|
+
}
|
|
27436
|
+
error(message, ...optionalParams) {
|
|
27437
|
+
if (this.logLevel != 'None') {
|
|
27438
|
+
console.error(`${this.prefix} Error: ${message}`, optionalParams);
|
|
27439
|
+
}
|
|
27440
|
+
}
|
|
27441
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ClassLoggerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
27442
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ClassLoggerService });
|
|
27443
|
+
}
|
|
27444
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ClassLoggerService, decorators: [{
|
|
27445
|
+
type: Injectable
|
|
27446
|
+
}] });
|
|
27447
|
+
|
|
27357
27448
|
class CustomerApiService extends BaseApiService {
|
|
27358
27449
|
get apiFullUrl() {
|
|
27359
27450
|
return this.apiBaseUrl + this.config?.addCustomerApiRoute;
|
|
@@ -27729,5 +27820,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
|
|
|
27729
27820
|
* Generated bundle index. Do not edit.
|
|
27730
27821
|
*/
|
|
27731
27822
|
|
|
27732
|
-
export { BaseApiService, CardTypes, Category, ConfigService, Customer, CustomerApiService, CwmSharedModule, DbKeys, ExternalNavigationComponent, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MockConfig, MockCustomer, MockInventoryApiResponse, MockProfile, NamedColors, NavigateToRouteComponent, OnElementStyle, PageNotFoundComponent, Product, Profile, SafeHtmlPipe, TimeSpan, TimeSpanOverflowError, UserTypes, Utilities, decodeToken, doWithLock, isTokenValid, msalGuardConfigFactory, msalInstanceFactory, msalInterceptorConfigFactory, waitFor };
|
|
27823
|
+
export { BaseApiService, CardTypes, Category, ClassLoggerService, ConfigService, Customer, CustomerApiService, CwmSharedModule, DbKeys, ExternalNavigationComponent, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MockConfig, MockCustomer, MockInventoryApiResponse, MockProfile, NamedColors, NavigateToRouteComponent, OnElementStyle, PageNotFoundComponent, Product, Profile, SafeHtmlPipe, Stack, TimeSpan, TimeSpanOverflowError, UserTypes, Utilities, decodeToken, doWithLock, isTokenValid, msalGuardConfigFactory, msalInstanceFactory, msalInterceptorConfigFactory, waitFor };
|
|
27733
27824
|
//# sourceMappingURL=transcommerce-cwm-shared.mjs.map
|