@transcommerce/cwm-shared 1.1.34 → 1.1.36

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.
@@ -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
 
@@ -27086,77 +27125,27 @@ const MockCustomer = {
27086
27125
  };
27087
27126
 
27088
27127
  /*
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.
27128
+ *The ClassLoggerService is really just a wrapper around the existing console logging functionality
27129
+ *The four main reasons for using this service are:
27130
+ * 1. The abstraction layer will allow us to pick a different logging endpoint if needed
27131
+ * 2. This service allows you to specify what level of verbosity you want this service to log with
27132
+ * 3. Has logic to log classname, method entry, and method exit points automagically
27133
+ * 4. Keeps track of the call stack to group nested method calls
27098
27134
  */
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
- The LogService is really just a wrapper around the existing console logging functionality
27128
- The three main reasons for using this service are:
27129
- 1. The abstraction layer will allow us to pick a different logging endpoint if needed
27130
- 2. This service allows you to specify what level verbosity you want this service tp log with
27131
- 3. Has logic to log method entry and exit points automagically
27132
- 4. Keeps track of call stack for nested method calls
27133
- 02*/
27134
- class LogService {
27135
+ class ClassLoggerService {
27135
27136
  logLevel = 'Info';
27136
- _classStack = new Stack();
27137
+ collapseGroups = true;
27138
+ _className = "";
27137
27139
  get className() {
27138
- return this._classStack.peek() ?? "";
27140
+ return this._className;
27139
27141
  }
27140
27142
  set className(value) {
27141
- if (this.logLevel === 'None') {
27142
- return;
27143
- }
27144
- if (this._classStack.size > 0 && this._classStack.peek() !== value) {
27145
- //console.groupCollapsed(this.targetName + " - " + value + " - " + new Date().toLocaleString())
27146
- console.groupEnd();
27147
- this._classStack.pop();
27148
- }
27149
- if (this._classStack.size === 0 || this._classStack.peek() !== value) {
27150
- this._classStack.push(value);
27151
- this.methodName = "constructor()";
27152
- }
27153
- else {
27154
- this._classStack.push(value);
27155
- }
27143
+ this._className = value;
27144
+ this.methodName = "constructor()";
27156
27145
  }
27157
- _methodStack = new Stack();
27146
+ callStack = new Stack();
27158
27147
  get methodName() {
27159
- return this._methodStack.peek() ?? "";
27148
+ return this.callStack.peek() ?? "";
27160
27149
  }
27161
27150
  set methodName(value) {
27162
27151
  if (this.logLevel === 'None') {
@@ -27166,8 +27155,11 @@ class LogService {
27166
27155
  this.endOfMethod();
27167
27156
  }
27168
27157
  else {
27169
- this._methodStack.push(value);
27170
- console.group(this.targetName);
27158
+ this.callStack.push(value);
27159
+ if (this.collapseGroups)
27160
+ console.groupCollapsed(this.targetName);
27161
+ else
27162
+ console.group(this.targetName);
27171
27163
  console.time(this.targetName);
27172
27164
  this.info("Start of method");
27173
27165
  }
@@ -27176,54 +27168,51 @@ class LogService {
27176
27168
  this.info("End of method");
27177
27169
  console.groupEnd();
27178
27170
  console.timeEnd(this.targetName);
27179
- this._methodStack.pop();
27171
+ this.callStack.pop();
27180
27172
  }
27181
27173
  get targetName() {
27182
27174
  if (this.methodName === "")
27183
27175
  return this.className;
27184
27176
  else
27185
- return this.className + "." + this.methodName;
27177
+ return `${this.className}.${this.methodName}`;
27186
27178
  }
27187
27179
  get prefix() {
27188
- return Date.now().toLocaleString() + " " + this.targetName + "> ";
27180
+ return `${new Date().toLocaleString()} ${this.targetName}> `;
27189
27181
  }
27190
27182
  log(message, ...optionalParams) {
27191
27183
  if (this.logLevel != 'None') {
27192
- console.log(this.prefix + " " + message, optionalParams);
27184
+ console.log(`${this.prefix} ${message}`, optionalParams);
27193
27185
  }
27194
27186
  }
27195
27187
  debug(message, ...optionalParams) {
27196
27188
  if (this.logLevel === 'Debug') {
27197
- console.debug(this.prefix + " Debug: " + message, optionalParams);
27189
+ console.debug(`${this.prefix} Debug: ${message}`, optionalParams);
27198
27190
  }
27199
27191
  }
27200
27192
  info(message, ...optionalParams) {
27201
27193
  if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
27202
- console.info(this.prefix + " Information: " + message, optionalParams);
27194
+ console.info(`${this.prefix} Information: ${message}`, optionalParams);
27203
27195
  }
27204
27196
  }
27205
27197
  warn(message, ...optionalParams) {
27206
27198
  if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
27207
- console.warn(this.prefix + " Warning: " + message, optionalParams);
27199
+ console.warn(`${this.prefix} Warning: ${message}`, optionalParams);
27208
27200
  }
27209
27201
  }
27210
27202
  error(message, ...optionalParams) {
27211
27203
  if (this.logLevel != 'None') {
27212
- console.error(this.prefix + " Error: " + message, optionalParams);
27204
+ console.error(`${this.prefix} Error: ${message}`, optionalParams);
27213
27205
  }
27214
27206
  }
27215
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27216
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, providedIn: 'root' });
27207
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ClassLoggerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27208
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ClassLoggerService });
27217
27209
  }
27218
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, decorators: [{
27219
- type: Injectable,
27220
- args: [{
27221
- providedIn: 'root'
27222
- }]
27210
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ClassLoggerService, decorators: [{
27211
+ type: Injectable
27223
27212
  }] });
27224
27213
 
27225
27214
  class ConfigService {
27226
- logService;
27215
+ logger;
27227
27216
  mockData = false;
27228
27217
  configClient;
27229
27218
  configConnectString;
@@ -27234,40 +27223,41 @@ class ConfigService {
27234
27223
  set configCache(value) {
27235
27224
  this._configCache = value;
27236
27225
  }
27237
- constructor(logService) {
27238
- this.logService = logService;
27239
- this.logService.className = "ConfigService";
27226
+ constructor(logger) {
27227
+ this.logger = logger;
27228
+ this.logger.className = "ConfigService";
27240
27229
  this.configConnectString = "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF";
27241
27230
  this.configClient = new AppConfigurationClient(this.configConnectString);
27242
- this.logService.log("Config Client", this.configClient);
27243
- this.logService.methodName = "";
27231
+ this.logger.info("Config Client", this.configClient);
27232
+ this.logger.methodName = "";
27244
27233
  }
27245
27234
  async getConfigurationSettingAsync(key, label) {
27246
- this.logService.methodName = "getConfigurationSettingAsync()";
27235
+ this.logger.methodName = "getConfigurationSettingAsync()";
27247
27236
  let setting = {};
27248
- this.logService.log("Get Configuration Setting for Key/Label requested", key, label);
27237
+ this.logger.info("Get Configuration Setting for Key/Label requested", key, label);
27249
27238
  if (this.mockData || this.configCache != undefined) {
27250
27239
  if (this.configCache == undefined) {
27251
27240
  this.configCache = MockConfig;
27252
- this.logService.log("Configuration Cache was undefined and Mock Data Enabled. Mock Config will be cached and used for this and all subsequent calls", this.configCache);
27241
+ this.logger.info("Configuration Cache was undefined and Mock Data Enabled. Mock Config will be cached and used for this and all subsequent calls", this.configCache);
27253
27242
  }
27254
27243
  setting.key = key;
27255
27244
  setting.value = JSON.stringify(this.configCache);
27256
27245
  if (this.mockData)
27257
- this.logService.log("Mock Data Enabled, Skipping getConfigurationSetting() and using Mock Config from the Configuration Cache", this.configCache);
27258
- this.logService.log("Configuration Cache was available, skipping getConfigurationSetting() and using Cached Configuration", this.configCache);
27246
+ this.logger.info("Mock Data Enabled, Skipping getConfigurationSetting() and using Mock Config from the Configuration Cache", this.configCache);
27247
+ else
27248
+ this.logger.info("Configuration Cache was available, skipping getConfigurationSetting() and using Cached Configuration", this.configCache);
27259
27249
  }
27260
27250
  else if (this.configCache == undefined) {
27261
- this.logService.log("Configuration Cache was undefined and Mock Data disabled. Getting Configuration Setting Key/Label. Configuration will be cached and used for this and all subsequent calls", key, label);
27251
+ this.logger.info("Configuration Cache was undefined and Mock Data disabled. Getting Configuration Setting Key/Label. Configuration will be cached and used for this and all subsequent calls", key, label);
27262
27252
  setting = await this.configClient.getConfigurationSetting({ key: key, label: label.replace(".", "") });
27263
27253
  }
27264
27254
  return setting.value;
27265
27255
  }
27266
27256
  async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
27267
- this.logService.className = "ConfigService";
27268
- this.logService.methodName = "setConfigurationSettingAsync()";
27257
+ this.logger.methodName = "setConfigurationSettingAsync()";
27269
27258
  if (this.mockData) {
27270
- this.logService.log("Mock Data Enabled, Skipping setConfigurationSettingAsync()");
27259
+ this.logger.info("Mock Data Enabled, Skipping setConfigurationSettingAsync()");
27260
+ this.logger.methodName = "";
27271
27261
  return;
27272
27262
  }
27273
27263
  const configurationSetting = {
@@ -27276,46 +27266,45 @@ class ConfigService {
27276
27266
  value: setting,
27277
27267
  contentType: contentType,
27278
27268
  };
27279
- this.logService.log("Setting", configurationSetting);
27269
+ this.logger.info("Calling configClient.setConfigurationSetting", configurationSetting);
27280
27270
  await this.configClient.setConfigurationSetting(configurationSetting);
27281
- this.logService.methodName = "";
27271
+ this.logger.methodName = "";
27282
27272
  }
27283
27273
  async getConfigAsync(company) {
27284
- this.logService.className = "ConfigService";
27285
- this.logService.methodName = "getConfigAsync()";
27274
+ this.logger.methodName = "getConfigAsync()";
27286
27275
  if (this.mockData) {
27287
27276
  this.configCache = MockConfig;
27288
- this.logService.log("Mock Data Enabled, Using Mock Config", this.configCache);
27277
+ this.logger.info("Mock Data Enabled, Using Mock Config", this.configCache);
27289
27278
  }
27290
27279
  else if (this.configCache == undefined) {
27291
- this.logService.log("Loading Configuration from Azure App Configuration");
27280
+ this.logger.info("Config Cache was undefined. Loading Configuration from Azure App Configuration");
27292
27281
  const jsonConfig = await this.getConfigurationSettingAsync("App.Config.Json", company) ?? "{ }";
27293
27282
  this.configCache = JSON.parse(jsonConfig);
27294
- this.logService.log("Loaded and Cached Configuration from Azure App Configuration", this.configCache);
27283
+ this.logger.debug("Loaded and Cached Configuration from Azure App Configuration", this.configCache);
27295
27284
  }
27296
27285
  else {
27297
- this.logService.log("Using Cached Configuration", this.configCache);
27286
+ this.logger.info("Using Cached Configuration", this.configCache);
27298
27287
  }
27299
27288
  const config = this.configCache;
27300
- this.logService.methodName = "";
27289
+ this.logger.methodName = "";
27301
27290
  return config;
27302
27291
  }
27303
27292
  async saveConfigAsync(config, company) {
27304
- this.logService.className = "ConfigService";
27305
- this.logService.methodName = "saveConfigAsync()";
27293
+ this.logger.methodName = "saveConfigAsync()";
27306
27294
  // Update configuration cache
27307
27295
  this.configCache = config;
27308
- this.logService.log("Updated Config Cache", this.configCache);
27296
+ this.logger.info("Updated Config Cache", this.configCache);
27309
27297
  if (this.mockData) {
27310
- this.logService.log("Mock Data Enabled, Skipping setConfigurationSettingAsync()");
27298
+ this.logger.info("Mock Data Enabled, Skipping setConfigurationSettingAsync()");
27299
+ this.logger.methodName = "";
27311
27300
  return;
27312
27301
  }
27313
- this.logService.log("Saving Configuration to Azure App Configuration");
27302
+ this.logger.info("Saving Configuration to Azure App Configuration");
27314
27303
  await this.setConfigurationSettingAsync("App.Config.Json", company, config, "JSON");
27315
- this.logService.log("Saved Configuration to Azure App Configuration");
27316
- this.logService.methodName = "";
27304
+ this.logger.debug("Saved Configuration to Azure App Configuration");
27305
+ this.logger.methodName = "";
27317
27306
  }
27318
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ConfigService, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
27307
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ConfigService, deps: [{ token: ClassLoggerService }], target: i0.ɵɵFactoryTarget.Injectable });
27319
27308
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ConfigService, providedIn: 'root' });
27320
27309
  }
27321
27310
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ConfigService, decorators: [{
@@ -27323,12 +27312,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
27323
27312
  args: [{
27324
27313
  providedIn: 'root'
27325
27314
  }]
27326
- }], ctorParameters: () => [{ type: LogService }] });
27315
+ }], ctorParameters: () => [{ type: ClassLoggerService }] });
27327
27316
 
27328
27317
  class BaseApiService {
27329
27318
  configService;
27330
27319
  httpClient;
27331
- logService;
27320
+ logger;
27332
27321
  config;
27333
27322
  get apiBaseUrl() {
27334
27323
  if (this.config)
@@ -27339,12 +27328,12 @@ class BaseApiService {
27339
27328
  get apiFullUrl() {
27340
27329
  return this.apiBaseUrl;
27341
27330
  }
27342
- constructor(configService, httpClient, logService) {
27331
+ constructor(configService, httpClient, logger) {
27343
27332
  this.configService = configService;
27344
27333
  this.httpClient = httpClient;
27345
- this.logService = logService;
27334
+ this.logger = logger;
27346
27335
  }
27347
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: BaseApiService, deps: [{ token: ConfigService }, { token: i2$1.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
27336
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: BaseApiService, deps: [{ token: ConfigService }, { token: i2$1.HttpClient }, { token: ClassLoggerService }], target: i0.ɵɵFactoryTarget.Injectable });
27348
27337
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: BaseApiService, providedIn: 'root' });
27349
27338
  }
27350
27339
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: BaseApiService, decorators: [{
@@ -27352,7 +27341,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
27352
27341
  args: [{
27353
27342
  providedIn: 'root'
27354
27343
  }]
27355
- }], ctorParameters: () => [{ type: ConfigService }, { type: i2$1.HttpClient }, { type: LogService }] });
27344
+ }], ctorParameters: () => [{ type: ConfigService }, { type: i2$1.HttpClient }, { type: ClassLoggerService }] });
27356
27345
 
27357
27346
  class CustomerApiService extends BaseApiService {
27358
27347
  get apiFullUrl() {
@@ -27376,9 +27365,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
27376
27365
 
27377
27366
  class InventoryApiService extends BaseApiService {
27378
27367
  useMockData = false;
27379
- constructor(configService, httpClient, logService) {
27380
- super(configService, httpClient, logService);
27381
- logService.className = "InventoryApiService";
27368
+ constructor(configService, httpClient, logger) {
27369
+ super(configService, httpClient, logger);
27370
+ logger.className = "InventoryApiService";
27382
27371
  }
27383
27372
  get httpHeaders() {
27384
27373
  return new HttpHeaders()
@@ -27390,21 +27379,21 @@ class InventoryApiService extends BaseApiService {
27390
27379
  return this.apiBaseUrl + (this.config ?? MockConfig.apiConfig).getInventoryApiRoute;
27391
27380
  }
27392
27381
  async getProductsAsync(companyName) {
27393
- this.logService.methodName = "getProductsAsync()";
27382
+ this.logger.methodName = "getProductsAsync()";
27394
27383
  let response;
27395
27384
  this.configService.mockData = this.useMockData;
27396
- this.logService.log("Fetching Configuration for Company", companyName);
27385
+ this.logger.log("Fetching Configuration for Company", companyName);
27397
27386
  this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
27398
- this.logService.log("Fetching Products for Company", companyName);
27387
+ this.logger.log("Fetching Products for Company", companyName);
27399
27388
  if (this.useMockData) {
27400
27389
  response = Promise.resolve(MockInventoryApiResponse);
27401
- this.logService.log("Mock Data Returned", response);
27390
+ this.logger.log("Mock Data Returned", response);
27402
27391
  }
27403
27392
  else {
27404
27393
  response = firstValueFrom(this.httpClient.get(this.apiFullUrl, { headers: this.httpHeaders }));
27405
- this.logService.log("Inventory API Response", response);
27394
+ this.logger.log("Inventory API Response", response);
27406
27395
  }
27407
- this.logService.methodName = "";
27396
+ this.logger.methodName = "";
27408
27397
  return response;
27409
27398
  }
27410
27399
  async getCategoriesAsync(companyName) {
@@ -27430,7 +27419,7 @@ class InventoryApiService extends BaseApiService {
27430
27419
  return productsByAllCategories;
27431
27420
  }
27432
27421
  ;
27433
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: InventoryApiService, deps: [{ token: ConfigService }, { token: i2$1.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
27422
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: InventoryApiService, deps: [{ token: ConfigService }, { token: i2$1.HttpClient }, { token: ClassLoggerService }], target: i0.ɵɵFactoryTarget.Injectable });
27434
27423
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: InventoryApiService, providedIn: 'root' });
27435
27424
  }
27436
27425
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: InventoryApiService, decorators: [{
@@ -27438,7 +27427,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
27438
27427
  args: [{
27439
27428
  providedIn: 'root'
27440
27429
  }]
27441
- }], ctorParameters: () => [{ type: ConfigService }, { type: i2$1.HttpClient }, { type: LogService }] });
27430
+ }], ctorParameters: () => [{ type: ConfigService }, { type: i2$1.HttpClient }, { type: ClassLoggerService }] });
27442
27431
 
27443
27432
  /**
27444
27433
  * Provides a wrapper for accessing the web storage API and synchronizing session storage across tabs/windows.
@@ -27721,6 +27710,108 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
27721
27710
  }]
27722
27711
  }] });
27723
27712
 
27713
+ /*
27714
+ The ClassLoggerService is really just a wrapper around the existing console logging functionality
27715
+ The three main reasons for using this service are:
27716
+ 1. The abstraction layer will allow us to pick a different logging endpoint if needed
27717
+ 2. This service allows you to specify what level verbosity you want this service tp log with
27718
+ 3. Has logic to log method entry and exit points automagically
27719
+ 4. Keeps track of call stack for nested method calls
27720
+ 02*/
27721
+ class LogService {
27722
+ logLevel = 'Info';
27723
+ _classStack = new Stack();
27724
+ get className() {
27725
+ return this._classStack.peek() ?? "";
27726
+ }
27727
+ set className(value) {
27728
+ if (this.logLevel === 'None') {
27729
+ return;
27730
+ }
27731
+ if (this._classStack.size > 0 && this._classStack.peek() !== value) {
27732
+ //console.groupCollapsed(this.targetName + " - " + value + " - " + new Date().toLocaleString())
27733
+ console.groupEnd();
27734
+ console.timeEnd(this.targetName);
27735
+ this._classStack.pop();
27736
+ }
27737
+ if (this._classStack.size === 0 || this._classStack.peek() !== value) {
27738
+ this._classStack.push(value);
27739
+ this.methodName = "constructor()";
27740
+ }
27741
+ else {
27742
+ this._classStack.push(value);
27743
+ console.groupCollapsed(this.targetName);
27744
+ console.time(this.targetName);
27745
+ }
27746
+ }
27747
+ _methodStack = new Stack();
27748
+ get methodName() {
27749
+ return this._methodStack.peek() ?? "";
27750
+ }
27751
+ set methodName(value) {
27752
+ if (this.logLevel === 'None') {
27753
+ return;
27754
+ }
27755
+ if (value === "") {
27756
+ this.endOfMethod();
27757
+ }
27758
+ else {
27759
+ this._methodStack.push(value);
27760
+ console.groupCollapsed(this.targetName);
27761
+ console.time(this.targetName);
27762
+ this.info("Start of method");
27763
+ }
27764
+ }
27765
+ endOfMethod() {
27766
+ this.info("End of method");
27767
+ console.groupEnd();
27768
+ console.timeEnd(this.targetName);
27769
+ this._methodStack.pop();
27770
+ }
27771
+ get targetName() {
27772
+ if (this.methodName === "")
27773
+ return this.className;
27774
+ else
27775
+ return this.className + "." + this.methodName;
27776
+ }
27777
+ get prefix() {
27778
+ return Date.now().toLocaleString() + " " + this.targetName + "> ";
27779
+ }
27780
+ log(message, ...optionalParams) {
27781
+ if (this.logLevel != 'None') {
27782
+ console.log(this.prefix + " " + message, optionalParams);
27783
+ }
27784
+ }
27785
+ debug(message, ...optionalParams) {
27786
+ if (this.logLevel === 'Debug') {
27787
+ console.debug(this.prefix + " Debug: " + message, optionalParams);
27788
+ }
27789
+ }
27790
+ info(message, ...optionalParams) {
27791
+ if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
27792
+ console.info(this.prefix + " Information: " + message, optionalParams);
27793
+ }
27794
+ }
27795
+ warn(message, ...optionalParams) {
27796
+ if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
27797
+ console.warn(this.prefix + " Warning: " + message, optionalParams);
27798
+ }
27799
+ }
27800
+ error(message, ...optionalParams) {
27801
+ if (this.logLevel != 'None') {
27802
+ console.error(this.prefix + " Error: " + message, optionalParams);
27803
+ }
27804
+ }
27805
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27806
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, providedIn: 'root' });
27807
+ }
27808
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LogService, decorators: [{
27809
+ type: Injectable,
27810
+ args: [{
27811
+ providedIn: 'root'
27812
+ }]
27813
+ }] });
27814
+
27724
27815
  // ================================================
27725
27816
  // Export every type you want this module to expose
27726
27817
  // ================================================
@@ -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