@transcommerce/cwm-shared 1.1.33 → 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 +170 -43
- package/fesm2022/transcommerce-cwm-shared.mjs.map +1 -1
- package/lib/helpers/stack.d.ts +8 -0
- 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/lib/services/log.service.d.ts +3 -2
- 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
|
|
|
@@ -27088,42 +27127,61 @@ const MockCustomer = {
|
|
|
27088
27127
|
/*
|
|
27089
27128
|
The LogService is really just a wrapper around the existing console logging functionality
|
|
27090
27129
|
The three main reasons for using this service are:
|
|
27091
|
-
1. The abstraction layer will allow us to pick a different logging
|
|
27130
|
+
1. The abstraction layer will allow us to pick a different logging endpoint if needed
|
|
27092
27131
|
2. This service allows you to specify what level verbosity you want this service tp log with
|
|
27093
27132
|
3. Has logic to log method entry and exit points automagically
|
|
27094
|
-
|
|
27133
|
+
4. Keeps track of call stack for nested method calls
|
|
27134
|
+
02*/
|
|
27095
27135
|
class LogService {
|
|
27096
27136
|
logLevel = 'Info';
|
|
27097
|
-
|
|
27098
|
-
get className() {
|
|
27137
|
+
_classStack = new Stack();
|
|
27138
|
+
get className() {
|
|
27139
|
+
return this._classStack.peek() ?? "";
|
|
27140
|
+
}
|
|
27099
27141
|
set className(value) {
|
|
27100
|
-
if (this.
|
|
27101
|
-
|
|
27142
|
+
if (this.logLevel === 'None') {
|
|
27143
|
+
return;
|
|
27102
27144
|
}
|
|
27103
|
-
if (this.
|
|
27104
|
-
this.
|
|
27145
|
+
if (this._classStack.size > 0 && this._classStack.peek() !== value) {
|
|
27146
|
+
//console.groupCollapsed(this.targetName + " - " + value + " - " + new Date().toLocaleString())
|
|
27147
|
+
console.groupEnd();
|
|
27148
|
+
console.timeEnd(this.targetName);
|
|
27149
|
+
this._classStack.pop();
|
|
27150
|
+
}
|
|
27151
|
+
if (this._classStack.size === 0 || this._classStack.peek() !== value) {
|
|
27152
|
+
this._classStack.push(value);
|
|
27105
27153
|
this.methodName = "constructor()";
|
|
27106
27154
|
}
|
|
27107
27155
|
else {
|
|
27108
|
-
this.
|
|
27156
|
+
this._classStack.push(value);
|
|
27157
|
+
console.groupCollapsed(this.targetName);
|
|
27158
|
+
console.time(this.targetName);
|
|
27109
27159
|
}
|
|
27110
27160
|
}
|
|
27111
|
-
|
|
27112
|
-
get methodName() {
|
|
27161
|
+
_methodStack = new Stack();
|
|
27162
|
+
get methodName() {
|
|
27163
|
+
return this._methodStack.peek() ?? "";
|
|
27164
|
+
}
|
|
27113
27165
|
set methodName(value) {
|
|
27114
|
-
if (
|
|
27115
|
-
|
|
27116
|
-
console.groupEnd();
|
|
27117
|
-
console.timeEnd(this.targetName);
|
|
27118
|
-
this._methodName = value;
|
|
27166
|
+
if (this.logLevel === 'None') {
|
|
27167
|
+
return;
|
|
27119
27168
|
}
|
|
27120
|
-
|
|
27121
|
-
this.
|
|
27122
|
-
|
|
27169
|
+
if (value === "") {
|
|
27170
|
+
this.endOfMethod();
|
|
27171
|
+
}
|
|
27172
|
+
else {
|
|
27173
|
+
this._methodStack.push(value);
|
|
27174
|
+
console.groupCollapsed(this.targetName);
|
|
27123
27175
|
console.time(this.targetName);
|
|
27124
27176
|
this.info("Start of method");
|
|
27125
27177
|
}
|
|
27126
27178
|
}
|
|
27179
|
+
endOfMethod() {
|
|
27180
|
+
this.info("End of method");
|
|
27181
|
+
console.groupEnd();
|
|
27182
|
+
console.timeEnd(this.targetName);
|
|
27183
|
+
this._methodStack.pop();
|
|
27184
|
+
}
|
|
27127
27185
|
get targetName() {
|
|
27128
27186
|
if (this.methodName === "")
|
|
27129
27187
|
return this.className;
|
|
@@ -27135,45 +27193,27 @@ class LogService {
|
|
|
27135
27193
|
}
|
|
27136
27194
|
log(message, ...optionalParams) {
|
|
27137
27195
|
if (this.logLevel != 'None') {
|
|
27138
|
-
|
|
27139
|
-
console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
|
|
27140
|
-
else
|
|
27141
|
-
console.log(this.prefix + " " + message, optionalParams);
|
|
27196
|
+
console.log(this.prefix + " " + message, optionalParams);
|
|
27142
27197
|
}
|
|
27143
27198
|
}
|
|
27144
27199
|
debug(message, ...optionalParams) {
|
|
27145
27200
|
if (this.logLevel === 'Debug') {
|
|
27146
|
-
|
|
27147
|
-
console.timeEnd(this.targetName);
|
|
27148
|
-
console.time(this.targetName);
|
|
27149
|
-
}
|
|
27150
|
-
console.debug(this.prefix + " " + message, optionalParams);
|
|
27201
|
+
console.debug(this.prefix + " Debug: " + message, optionalParams);
|
|
27151
27202
|
}
|
|
27152
27203
|
}
|
|
27153
27204
|
info(message, ...optionalParams) {
|
|
27154
27205
|
if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
|
|
27155
|
-
|
|
27156
|
-
console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
|
|
27157
|
-
else
|
|
27158
|
-
console.info(this.prefix + " " + message, optionalParams);
|
|
27206
|
+
console.info(this.prefix + " Information: " + message, optionalParams);
|
|
27159
27207
|
}
|
|
27160
27208
|
}
|
|
27161
27209
|
warn(message, ...optionalParams) {
|
|
27162
27210
|
if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
|
|
27163
|
-
|
|
27164
|
-
console.timeEnd(this.targetName);
|
|
27165
|
-
console.time(this.targetName);
|
|
27166
|
-
}
|
|
27167
|
-
console.warn(this.prefix + " " + message, optionalParams);
|
|
27211
|
+
console.warn(this.prefix + " Warning: " + message, optionalParams);
|
|
27168
27212
|
}
|
|
27169
27213
|
}
|
|
27170
27214
|
error(message, ...optionalParams) {
|
|
27171
27215
|
if (this.logLevel != 'None') {
|
|
27172
|
-
|
|
27173
|
-
console.timeEnd(this.targetName);
|
|
27174
|
-
console.time(this.targetName);
|
|
27175
|
-
}
|
|
27176
|
-
console.error(this.prefix + " " + message, optionalParams);
|
|
27216
|
+
console.error(this.prefix + " Error: " + message, optionalParams);
|
|
27177
27217
|
}
|
|
27178
27218
|
}
|
|
27179
27219
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -27318,6 +27358,93 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
|
|
|
27318
27358
|
}]
|
|
27319
27359
|
}], ctorParameters: () => [{ type: ConfigService }, { type: i2$1.HttpClient }, { type: LogService }] });
|
|
27320
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
|
+
|
|
27321
27448
|
class CustomerApiService extends BaseApiService {
|
|
27322
27449
|
get apiFullUrl() {
|
|
27323
27450
|
return this.apiBaseUrl + this.config?.addCustomerApiRoute;
|
|
@@ -27693,5 +27820,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
|
|
|
27693
27820
|
* Generated bundle index. Do not edit.
|
|
27694
27821
|
*/
|
|
27695
27822
|
|
|
27696
|
-
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 };
|
|
27697
27824
|
//# sourceMappingURL=transcommerce-cwm-shared.mjs.map
|