@transcommerce/cwm-shared 1.1.41 → 1.1.42
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 +316 -282
- package/fesm2022/transcommerce-cwm-shared.mjs.map +1 -1
- package/lib/factories/msal-interceptor-config.factory.d.ts +3 -1
- package/lib/factories/msal.guard.config.factory.d.ts +3 -1
- package/lib/factories/msal.instance.factory.d.ts +3 -1
- package/lib/models/config/auth-config.d.ts +2 -0
- package/lib/models/config/configuration.d.ts +3 -0
- package/lib/models/config/subscription-config.d.ts +1 -2
- package/lib/models/subscription.d.ts +2 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Injectable, Pipe, NgModule, Inject } from '@angular/core';
|
|
2
|
+
import { Component, Injectable, InjectionToken, Pipe, NgModule, Inject } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/router';
|
|
4
4
|
import * as i2 from '@angular/forms';
|
|
5
5
|
import { FormsModule } from '@angular/forms';
|
|
@@ -113,79 +113,245 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
113
113
|
args: [{ selector: 'cwm-page-not-found', standalone: false, template: "<p>\n Page Not Found\n</p>\n" }]
|
|
114
114
|
}] });
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
/*
|
|
117
|
+
* A simple generic LIFO stack.
|
|
118
|
+
*
|
|
119
|
+
* Example:
|
|
120
|
+
* ```ts
|
|
121
|
+
* const s = new Stack<number>();
|
|
122
|
+
* s.push(1);
|
|
123
|
+
* s.push(2);
|
|
124
|
+
* console.log(s.pop());
|
|
125
|
+
* @typeParam T - Type of items stored in the stack.
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
class Stack {
|
|
129
|
+
items = [];
|
|
130
|
+
/*
|
|
131
|
+
Pushes an item onto the top of the stack.
|
|
132
|
+
@param item - Item to push.
|
|
133
|
+
*/
|
|
134
|
+
push(item) { this.items.push(item); }
|
|
135
|
+
/*
|
|
136
|
+
Removes and returns the item at the top of the stack.
|
|
137
|
+
@returns The popped item, or undefined if the stack is empty.
|
|
138
|
+
*/
|
|
139
|
+
pop() { return this.items.pop(); }
|
|
140
|
+
/*
|
|
141
|
+
Returns the item at the top without removing it.
|
|
142
|
+
@returns The top item, or undefined if the stack is empty.
|
|
143
|
+
*/
|
|
144
|
+
peek() { return this.items[this.items.length - 1]; }
|
|
145
|
+
/*
|
|
146
|
+
Number of items currently in the stack.
|
|
147
|
+
*/
|
|
148
|
+
get size() { return this.items.length; }
|
|
149
|
+
/*
|
|
150
|
+
Returns a string representation of all items currently in the stack.
|
|
151
|
+
*/
|
|
152
|
+
toString() { return this.items.toString(); }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/*
|
|
156
|
+
* The ClassLoggerService is really just a wrapper around the existing console logging functionality
|
|
157
|
+
* It is not intended to be used as a singleton service, but rather to be instantiated for each class that needs logging.
|
|
158
|
+
* For that reason, it is registered with DI as a plain Injectable service, not a Root Injectable service.
|
|
159
|
+
* The four main reasons for using this service are:
|
|
160
|
+
* 1. The abstraction layer will allow us to pick a different logging endpoint if needed
|
|
161
|
+
* 2. This service allows you to specify what level of verbosity you want this service to log with
|
|
162
|
+
* 3. Has logic to log classname, method entry, and method exit points automagically
|
|
163
|
+
* 4. Keeps track of the call stack and can group nested method calls if collapseGroups is set to true
|
|
164
|
+
*/
|
|
165
|
+
class ClassLoggerService {
|
|
166
|
+
/*
|
|
167
|
+
* Determines what level of verbosity you want this service to log with.
|
|
168
|
+
* This can be set to 'None', 'Error', 'Warn', 'Info', 'Debug', or 'Trace'.
|
|
169
|
+
*/
|
|
170
|
+
logLevel = 'Trace';
|
|
171
|
+
/*
|
|
172
|
+
* Determine if method entry and exit points should be logged in collapsed groups
|
|
173
|
+
*/
|
|
174
|
+
collapseGroups = true;
|
|
175
|
+
/*
|
|
176
|
+
* This is the encapsulated value for the class name.
|
|
177
|
+
*/
|
|
178
|
+
_className = "";
|
|
179
|
+
/*
|
|
180
|
+
* Gets the class name.
|
|
181
|
+
* @returns The class name
|
|
182
|
+
*/
|
|
183
|
+
get className() {
|
|
184
|
+
return this._className;
|
|
185
|
+
}
|
|
186
|
+
/*
|
|
187
|
+
* Sets the class name and logs the method name as the constructor.
|
|
188
|
+
* @param value The class name to set.
|
|
189
|
+
*/
|
|
190
|
+
set className(value) {
|
|
191
|
+
this._className = value;
|
|
192
|
+
this.methodName = "constructor()";
|
|
193
|
+
}
|
|
194
|
+
/* This will contain an encapsulated call stack with all the method names from this class that got to this method.
|
|
195
|
+
* The top of the stack will be the method that called the current method and so on down the call stack
|
|
196
|
+
*/
|
|
197
|
+
callStack = new Stack();
|
|
198
|
+
/*
|
|
199
|
+
* @returns The method name that is currently being executed for the top of the call stack.
|
|
200
|
+
*/
|
|
201
|
+
get methodName() {
|
|
202
|
+
return this.callStack.peek() ?? "";
|
|
203
|
+
}
|
|
204
|
+
/*
|
|
205
|
+
* This sets the method name that is currently being executed for the top of the call stack amd logs the method entry point.
|
|
206
|
+
* @param value The method name to set.
|
|
207
|
+
*/
|
|
208
|
+
set methodName(value) {
|
|
209
|
+
if (this.logLevel === 'None') {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (value === "") {
|
|
213
|
+
this.endOfMethod();
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
this.callStack.push(value);
|
|
217
|
+
if (this.collapseGroups)
|
|
218
|
+
console.groupCollapsed(this.targetName);
|
|
219
|
+
else
|
|
220
|
+
console.group(this.targetName);
|
|
221
|
+
console.time(this.targetName);
|
|
222
|
+
this.trace("Start of method");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/*
|
|
226
|
+
* This is used to signal the end of a method and logs the method exit point.
|
|
227
|
+
* It also pops the current method off the top of the call stack
|
|
228
|
+
*/
|
|
229
|
+
endOfMethod() {
|
|
230
|
+
this.trace("End of method");
|
|
231
|
+
console.groupEnd();
|
|
232
|
+
console.timeEnd(this.targetName);
|
|
233
|
+
this.callStack.pop();
|
|
234
|
+
}
|
|
235
|
+
/*
|
|
236
|
+
* @ returns The class name and method name if available, otherwise the class name alone.
|
|
237
|
+
*/
|
|
238
|
+
get targetName() {
|
|
239
|
+
if (this.methodName === "")
|
|
240
|
+
return this.className;
|
|
241
|
+
else
|
|
242
|
+
return `${this.className}.${this.methodName}`;
|
|
243
|
+
}
|
|
244
|
+
/*
|
|
245
|
+
* Prefix used for all log messages.
|
|
246
|
+
* @ returns The date and time of the log message, the class name, and the method name.
|
|
247
|
+
*/
|
|
248
|
+
get prefix() {
|
|
249
|
+
return `${new Date().toLocaleString()} ${this.targetName}> `;
|
|
250
|
+
}
|
|
251
|
+
/*
|
|
252
|
+
* This will write a log for the verbosity level of Error only
|
|
253
|
+
* This includes verbosity levels of Error, Warning, Information, Debug, and Trace.
|
|
254
|
+
* @param message The message to log.
|
|
255
|
+
* @param optionalParams Optional parameters to include in the log message.
|
|
256
|
+
*/
|
|
257
|
+
error(message, ...optionalParams) {
|
|
258
|
+
if (this.logLevel === 'Error' || this.logLevel === 'Warn' || this.logLevel === 'Info' || this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
259
|
+
console.error(`${this.prefix} Error: ${message}`, optionalParams);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/*
|
|
263
|
+
* Limited level of logging for warnings.
|
|
264
|
+
* This includes verbosity levels of Warning, Information, Debug, and Trace.
|
|
265
|
+
* @param message The message to log.
|
|
266
|
+
* @param optionalParams Optional parameters to include in the log message.
|
|
267
|
+
*/
|
|
268
|
+
warn(message, ...optionalParams) {
|
|
269
|
+
if (this.logLevel === 'Warn' || this.logLevel === 'Info' || this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
270
|
+
console.warn(`${this.prefix} Warning: ${message}`, optionalParams);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/*
|
|
274
|
+
* Default log level.
|
|
275
|
+
* This includes verbosity levels of Information, Debug, and Trace.
|
|
276
|
+
* This is used to provide general information about app flow but shouldn't contain values.
|
|
277
|
+
* @param message The message to log.
|
|
278
|
+
* @param optionalParams Optional parameters to include in the log message.
|
|
279
|
+
*/
|
|
280
|
+
info(message, ...optionalParams) {
|
|
281
|
+
if (this.logLevel === 'Info' || this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
282
|
+
console.info(`${this.prefix} Information: ${message}`, optionalParams);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/*
|
|
286
|
+
* Useful for debugging,
|
|
287
|
+
* This includes verbosity levels of Debug and Trace.
|
|
288
|
+
* If actual values are put in the logs, this should be chosen; they may need to be sanitized
|
|
289
|
+
* @param message The message to log.
|
|
290
|
+
* @param optionalParams Optional parameters to include in the log message.
|
|
291
|
+
*/
|
|
292
|
+
debug(message, ...optionalParams) {
|
|
293
|
+
if (this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
294
|
+
console.debug(`${this.prefix} Debug: ${message}`, optionalParams);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/*
|
|
298
|
+
*The highest verbosity should log a crazy number of records.
|
|
299
|
+
* This includes verbosity level Trace. they may need to be sanitized
|
|
300
|
+
* @param message The message to log.
|
|
301
|
+
* @param optionalParams Optional parameters to include in the log message.
|
|
302
|
+
*/
|
|
303
|
+
trace(message, ...optionalParams) {
|
|
304
|
+
if (this.logLevel === 'Trace') {
|
|
305
|
+
console.log(`${this.prefix} Trace: ${message}`, optionalParams);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ClassLoggerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
309
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ClassLoggerService });
|
|
310
|
+
}
|
|
311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ClassLoggerService, decorators: [{
|
|
312
|
+
type: Injectable
|
|
313
|
+
}] });
|
|
314
|
+
|
|
315
|
+
function msalGuardConfigFactory(authConfig, injector) {
|
|
316
|
+
const logService = injector ? injector.get(ClassLoggerService, null) : null;
|
|
317
|
+
if (logService) {
|
|
318
|
+
//logService.className = 'AppModule';
|
|
319
|
+
logService.methodName = 'msalGuardConfigFactory';
|
|
320
|
+
logService.info(`msalGuardConfigFactory: using clientId=${authConfig.clientId}`);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
console.info('msalGuardConfigFactory: auth clientId=', authConfig.clientId);
|
|
324
|
+
}
|
|
325
|
+
const scopes = authConfig && authConfig.scopes ? (Array.isArray(authConfig.scopes) ? authConfig.scopes : authConfig.scopes.split(',').map(s => s.trim())) : ['user.read'];
|
|
326
|
+
const msalGuardConfiguration = {
|
|
118
327
|
interactionType: InteractionType.Redirect,
|
|
119
328
|
authRequest: {
|
|
120
|
-
scopes:
|
|
329
|
+
scopes: scopes,
|
|
330
|
+
prompt: authConfig.prompt
|
|
121
331
|
},
|
|
122
332
|
};
|
|
333
|
+
if (logService)
|
|
334
|
+
logService.methodName = "";
|
|
335
|
+
return msalGuardConfiguration;
|
|
123
336
|
}
|
|
124
337
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
// Safe getter for runtime authConfig. Accessing the config at module-eval time
|
|
132
|
-
// can fail if the global `authConfig` script in `index.html` hasn't been injected or
|
|
133
|
-
// loaded yet. This helper reads from window.authConfig (set in index.html) or falls
|
|
134
|
-
// back to the AuthService helper if available, and logs a clear error instead of
|
|
135
|
-
// letting the application throw a TypeError.
|
|
136
|
-
function getAuthConfigSafe() {
|
|
137
|
-
try {
|
|
138
|
-
const winAny = window;
|
|
139
|
-
const cfg = winAny.authConfig ?? (getAuthConfig ? getAuthConfig() : undefined);
|
|
140
|
-
if (!cfg) {
|
|
141
|
-
// Provide a helpful console error and return a minimal object to avoid runtime crashes.
|
|
142
|
-
// The app will still not be authenticated correctly until the real config is available.
|
|
143
|
-
console.error('authConfig is not available on window and AuthService.getAuthConfig() returned no value. Ensure the inline authConfig script in index.html is present and executes before the app bundle., using default cfg:');
|
|
144
|
-
return {
|
|
145
|
-
logLevel: "Info",
|
|
146
|
-
clientId: "af1486e0-a27f-4c8d-8503-0752d90ce72d",
|
|
147
|
-
tenantId: "445012c4-563a-4795-84d0-f7473a3197e0",
|
|
148
|
-
authority: "https://login.microsoft.com/445012c4-563a-4795-84d0-f7473a3197e0",
|
|
149
|
-
scopes: "openid,email,profile",
|
|
150
|
-
redirect_uri: window.location.origin,
|
|
151
|
-
logout_redirect_uri: window.location.origin + '/logout',
|
|
152
|
-
prompt: "login",
|
|
153
|
-
configConnectString: "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=7F0m;Secret=7X8pkinp53tA8d4o2LfGUMHBWo54o68jYUSS7JcOnyQmh2lDXetkJQQJ99BEAC8vTInIcYexAAACAZAC2P1s"
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return cfg;
|
|
157
|
-
}
|
|
158
|
-
catch (e) {
|
|
159
|
-
console.error('Error while reading authConfig, using default cfg:', e);
|
|
160
|
-
return {
|
|
161
|
-
logLevel: "Info",
|
|
162
|
-
clientId: "af1486e0-a27f-4c8d-8503-0752d90ce72d",
|
|
163
|
-
tenantId: "445012c4-563a-4795-84d0-f7473a3197e0",
|
|
164
|
-
authority: "https://login.microsoft.com/445012c4-563a-4795-84d0-f7473a3197e0",
|
|
165
|
-
scopes: "openid,email,profile",
|
|
166
|
-
redirect_uri: window.location.origin,
|
|
167
|
-
logout_redirect_uri: window.location.origin + '/logout',
|
|
168
|
-
prompt: "login",
|
|
169
|
-
configConnectString: "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=7F0m;Secret=7X8pkinp53tA8d4o2LfGUMHBWo54o68jYUSS7JcOnyQmh2lDXetkJQQJ99BEAC8vTInIcYexAAACAZAC2P1s"
|
|
170
|
-
};
|
|
338
|
+
function msalInstanceFactory(authConfig, injector) {
|
|
339
|
+
const logService = injector ? injector.get(ClassLoggerService, null) : null;
|
|
340
|
+
if (logService) {
|
|
341
|
+
logService.className = 'AppModule';
|
|
342
|
+
logService.methodName = 'msalInstanceFactory';
|
|
171
343
|
}
|
|
172
|
-
|
|
173
|
-
// -----------------------------------------
|
|
174
|
-
// Runtime factories for MSAL (avoid module-eval-time access to window)
|
|
175
|
-
// -----------------------------------------
|
|
176
|
-
function msalInstanceFactory() {
|
|
177
|
-
const cfg = getAuthConfigSafe();
|
|
178
|
-
return new PublicClientApplication({
|
|
344
|
+
const publicClientApplication = new PublicClientApplication({
|
|
179
345
|
auth: {
|
|
180
|
-
clientId:
|
|
181
|
-
authority:
|
|
182
|
-
redirectUri:
|
|
183
|
-
postLogoutRedirectUri:
|
|
346
|
+
clientId: authConfig.clientId,
|
|
347
|
+
authority: authConfig.authority,
|
|
348
|
+
redirectUri: authConfig.redirect_uri,
|
|
349
|
+
postLogoutRedirectUri: authConfig.logout_redirect_uri
|
|
184
350
|
},
|
|
185
351
|
cache: {
|
|
186
352
|
cacheLocation: 'localStorage',
|
|
187
353
|
temporaryCacheLocation: 'sessionStorage',
|
|
188
|
-
storeAuthStateInCookie:
|
|
354
|
+
storeAuthStateInCookie: window.navigator.userAgent.indexOf('MSIE ') > -1 || window.navigator.userAgent.indexOf('Trident/') > -1,
|
|
189
355
|
secureCookies: true,
|
|
190
356
|
cacheMigrationEnabled: true,
|
|
191
357
|
claimsBasedCachingEnabled: true
|
|
@@ -193,12 +359,55 @@ function msalInstanceFactory() {
|
|
|
193
359
|
system: {
|
|
194
360
|
tokenRenewalOffsetSeconds: 30,
|
|
195
361
|
preventCorsPreflight: false,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
362
|
+
// Build loggerCallback as a local const so linters recognize it's used
|
|
363
|
+
// and to make it easier to test or replace in unit tests.
|
|
364
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
365
|
+
loggerOptions: (() => {
|
|
366
|
+
const loggerCallback = (level, message, _containsPii) => {
|
|
367
|
+
if (logService) {
|
|
368
|
+
switch (level) {
|
|
369
|
+
case LogLevel.Error:
|
|
370
|
+
logService.error(message);
|
|
371
|
+
break;
|
|
372
|
+
case LogLevel.Warning:
|
|
373
|
+
logService.warn(message);
|
|
374
|
+
break;
|
|
375
|
+
case LogLevel.Info:
|
|
376
|
+
logService.info(message);
|
|
377
|
+
break;
|
|
378
|
+
case LogLevel.Verbose:
|
|
379
|
+
logService.debug(message);
|
|
380
|
+
break;
|
|
381
|
+
default:
|
|
382
|
+
logService.trace(message);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
switch (level) {
|
|
387
|
+
case LogLevel.Error:
|
|
388
|
+
console.error(message);
|
|
389
|
+
break;
|
|
390
|
+
case LogLevel.Warning:
|
|
391
|
+
console.warn(message);
|
|
392
|
+
break;
|
|
393
|
+
case LogLevel.Info:
|
|
394
|
+
console.info(message);
|
|
395
|
+
break;
|
|
396
|
+
case LogLevel.Verbose:
|
|
397
|
+
console.debug(message);
|
|
398
|
+
break;
|
|
399
|
+
default:
|
|
400
|
+
console.log(message);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
return {
|
|
405
|
+
loggerCallback,
|
|
406
|
+
piiLoggingEnabled: authConfig.showPii,
|
|
407
|
+
logLevel: LogLevel.Verbose,
|
|
408
|
+
correlationId: "ff88c00e-fd95-49c6-8203-5b2b62a4eb2f"
|
|
409
|
+
};
|
|
410
|
+
})(),
|
|
202
411
|
windowHashTimeout: 1000,
|
|
203
412
|
iframeHashTimeout: 1000,
|
|
204
413
|
loadFrameTimeout: 1000,
|
|
@@ -208,26 +417,46 @@ function msalInstanceFactory() {
|
|
|
208
417
|
allowRedirectInIframe: false,
|
|
209
418
|
allowNativeBroker: false,
|
|
210
419
|
nativeBrokerHandshakeTimeout: 500,
|
|
211
|
-
pollIntervalMilliseconds: 30
|
|
420
|
+
pollIntervalMilliseconds: 30
|
|
212
421
|
},
|
|
213
422
|
telemetry: {
|
|
214
423
|
application: {
|
|
215
424
|
appName: "cwm-digital-menu",
|
|
216
|
-
appVersion: "1.
|
|
425
|
+
appVersion: "1.1.33"
|
|
217
426
|
},
|
|
218
427
|
}
|
|
219
428
|
});
|
|
429
|
+
if (logService) {
|
|
430
|
+
logService.debug(`returning publicClientApplication`, publicClientApplication);
|
|
431
|
+
logService.methodName = '';
|
|
432
|
+
}
|
|
433
|
+
return publicClientApplication;
|
|
220
434
|
}
|
|
221
435
|
|
|
222
|
-
function msalInterceptorConfigFactory() {
|
|
223
|
-
|
|
436
|
+
function msalInterceptorConfigFactory(authConfig, injector) {
|
|
437
|
+
const logService = injector ? injector.get(ClassLoggerService, null) : null;
|
|
438
|
+
if (logService) {
|
|
439
|
+
logService.className = 'AppModule';
|
|
440
|
+
logService.methodName = 'msalInterceptorConfigFactory';
|
|
441
|
+
logService.info(`msalInterceptorConfigFactory: using clientId=${authConfig.clientId}`);
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
console.info('msalInterceptorConfigFactory: auth clientId=', authConfig.clientId);
|
|
445
|
+
}
|
|
446
|
+
const msalInterceptorConfiguration = {
|
|
224
447
|
interactionType: InteractionType.Redirect,
|
|
225
448
|
protectedResourceMap: new Map([
|
|
226
449
|
['https://graph.microsoft.com/v1.0/me', ['user.read']],
|
|
227
|
-
['https://graph.microsoft.com/v1.0/me/photo/$value', ['user.read']]
|
|
228
|
-
[window.location.origin + '/api/inventory?', [
|
|
450
|
+
['https://graph.microsoft.com/v1.0/me/photo/$value', ['user.read']]
|
|
451
|
+
//[window.location.origin + '/api/inventory?', ['Inventory.Read']],
|
|
452
|
+
//[window.location.origin + '/inventory', ['Inventory.Read']],
|
|
453
|
+
//[window.location.origin + '/AddCustomer', ['User.ReadWrite']],
|
|
454
|
+
//[window.location.origin + '/subscription', ['Subscription.Add']],
|
|
229
455
|
])
|
|
230
456
|
};
|
|
457
|
+
if (logService)
|
|
458
|
+
logService.methodName = "";
|
|
459
|
+
return msalInterceptorConfiguration;
|
|
231
460
|
}
|
|
232
461
|
|
|
233
462
|
/* eslint-disable no-useless-catch */
|
|
@@ -349,45 +578,6 @@ function isTokenValid(input) {
|
|
|
349
578
|
return exp ? Math.floor(Date.now() / 1000) < exp : false;
|
|
350
579
|
}
|
|
351
580
|
|
|
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
|
-
|
|
391
581
|
class TimeSpanOverflowError extends Error {
|
|
392
582
|
}
|
|
393
583
|
|
|
@@ -1027,6 +1217,7 @@ const DEFAULT_AUTH_CONFIG = {
|
|
|
1027
1217
|
showPii: true,
|
|
1028
1218
|
configConnectString: "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=7F0m;Secret=7X8pkinp53tA8d4o2LfGUMHBWo54o68jYUSS7JcOnyQmh2lDXetkJQQJ99BEAC8vTInIcYexAAACAZAC2P1s"
|
|
1029
1219
|
};
|
|
1220
|
+
const AUTH_CONFIG = new InjectionToken('AUTH_CONFIG');
|
|
1030
1221
|
|
|
1031
1222
|
const DEFAULT_CAROUSEL_CONFIG = {
|
|
1032
1223
|
"slidesToShow": 3,
|
|
@@ -1054,22 +1245,24 @@ const DEFAULT_SLIDE = {
|
|
|
1054
1245
|
"backgroundColor": "white"
|
|
1055
1246
|
};
|
|
1056
1247
|
|
|
1248
|
+
const DEFAULT_SUBSCRIPTION_CONFIG = {
|
|
1249
|
+
amount: 0.01,
|
|
1250
|
+
days: 30,
|
|
1251
|
+
totalOccurrences: 12,
|
|
1252
|
+
trialOccurrences: 0
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
const DEFAULT_COMPANY_NAME = 'Test Weed Dispensary';
|
|
1057
1256
|
const DEFAULT_CONFIGURATION = {
|
|
1058
|
-
companyName:
|
|
1257
|
+
companyName: DEFAULT_COMPANY_NAME,
|
|
1059
1258
|
authConfig: DEFAULT_AUTH_CONFIG,
|
|
1060
1259
|
apiConfig: DEFAULT_API_CONFIG,
|
|
1260
|
+
subscriptionConfig: DEFAULT_SUBSCRIPTION_CONFIG,
|
|
1061
1261
|
menuBoardConfig: DEFAULT_MENU_BOARD_CONFIG,
|
|
1062
1262
|
footerCarouselConfig: DEFAULT_CAROUSEL_CONFIG,
|
|
1063
1263
|
footerCarouselSlideConfig: [DEFAULT_SLIDE]
|
|
1064
1264
|
};
|
|
1065
1265
|
|
|
1066
|
-
const DEFAULT_SUBSCRIPTION_CONFIG = {
|
|
1067
|
-
amount: 0.01,
|
|
1068
|
-
days: 30,
|
|
1069
|
-
totalOccurrences: 12,
|
|
1070
|
-
trialOccurrences: 0
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
1266
|
var CardTypes;
|
|
1074
1267
|
(function (CardTypes) {
|
|
1075
1268
|
CardTypes["Amex"] = "Amex";
|
|
@@ -27097,166 +27290,6 @@ const MockProfile = DEFAULT_PROFILE;
|
|
|
27097
27290
|
|
|
27098
27291
|
const MockCustomer = DEFAULT_CUSTOMER;
|
|
27099
27292
|
|
|
27100
|
-
/*
|
|
27101
|
-
* The ClassLoggerService is really just a wrapper around the existing console logging functionality
|
|
27102
|
-
* It is not intended to be used as a singleton service, but rather to be instantiated for each class that needs logging.
|
|
27103
|
-
* For that reason, it is registered with DI as a plain Injectable service, not a Root Injectable service.
|
|
27104
|
-
* The four main reasons for using this service are:
|
|
27105
|
-
* 1. The abstraction layer will allow us to pick a different logging endpoint if needed
|
|
27106
|
-
* 2. This service allows you to specify what level of verbosity you want this service to log with
|
|
27107
|
-
* 3. Has logic to log classname, method entry, and method exit points automagically
|
|
27108
|
-
* 4. Keeps track of the call stack and can group nested method calls if collapseGroups is set to true
|
|
27109
|
-
*/
|
|
27110
|
-
class ClassLoggerService {
|
|
27111
|
-
/*
|
|
27112
|
-
* Determines what level of verbosity you want this service to log with.
|
|
27113
|
-
* This can be set to 'None', 'Error', 'Warn', 'Info', 'Debug', or 'Trace'.
|
|
27114
|
-
*/
|
|
27115
|
-
logLevel = 'Trace';
|
|
27116
|
-
/*
|
|
27117
|
-
* Determine if method entry and exit points should be logged in collapsed groups
|
|
27118
|
-
*/
|
|
27119
|
-
collapseGroups = true;
|
|
27120
|
-
/*
|
|
27121
|
-
* This is the encapsulated value for the class name.
|
|
27122
|
-
*/
|
|
27123
|
-
_className = "";
|
|
27124
|
-
/*
|
|
27125
|
-
* Gets the class name.
|
|
27126
|
-
* @returns The class name
|
|
27127
|
-
*/
|
|
27128
|
-
get className() {
|
|
27129
|
-
return this._className;
|
|
27130
|
-
}
|
|
27131
|
-
/*
|
|
27132
|
-
* Sets the class name and logs the method name as the constructor.
|
|
27133
|
-
* @param value The class name to set.
|
|
27134
|
-
*/
|
|
27135
|
-
set className(value) {
|
|
27136
|
-
this._className = value;
|
|
27137
|
-
this.methodName = "constructor()";
|
|
27138
|
-
}
|
|
27139
|
-
/* This will contain an encapsulated call stack with all the method names from this class that got to this method.
|
|
27140
|
-
* The top of the stack will be the method that called the current method and so on down the call stack
|
|
27141
|
-
*/
|
|
27142
|
-
callStack = new Stack();
|
|
27143
|
-
/*
|
|
27144
|
-
* @returns The method name that is currently being executed for the top of the call stack.
|
|
27145
|
-
*/
|
|
27146
|
-
get methodName() {
|
|
27147
|
-
return this.callStack.peek() ?? "";
|
|
27148
|
-
}
|
|
27149
|
-
/*
|
|
27150
|
-
* This sets the method name that is currently being executed for the top of the call stack amd logs the method entry point.
|
|
27151
|
-
* @param value The method name to set.
|
|
27152
|
-
*/
|
|
27153
|
-
set methodName(value) {
|
|
27154
|
-
if (this.logLevel === 'None') {
|
|
27155
|
-
return;
|
|
27156
|
-
}
|
|
27157
|
-
if (value === "") {
|
|
27158
|
-
this.endOfMethod();
|
|
27159
|
-
}
|
|
27160
|
-
else {
|
|
27161
|
-
this.callStack.push(value);
|
|
27162
|
-
if (this.collapseGroups)
|
|
27163
|
-
console.groupCollapsed(this.targetName);
|
|
27164
|
-
else
|
|
27165
|
-
console.group(this.targetName);
|
|
27166
|
-
console.time(this.targetName);
|
|
27167
|
-
this.trace("Start of method");
|
|
27168
|
-
}
|
|
27169
|
-
}
|
|
27170
|
-
/*
|
|
27171
|
-
* This is used to signal the end of a method and logs the method exit point.
|
|
27172
|
-
* It also pops the current method off the top of the call stack
|
|
27173
|
-
*/
|
|
27174
|
-
endOfMethod() {
|
|
27175
|
-
this.trace("End of method");
|
|
27176
|
-
console.groupEnd();
|
|
27177
|
-
console.timeEnd(this.targetName);
|
|
27178
|
-
this.callStack.pop();
|
|
27179
|
-
}
|
|
27180
|
-
/*
|
|
27181
|
-
* @ returns The class name and method name if available, otherwise the class name alone.
|
|
27182
|
-
*/
|
|
27183
|
-
get targetName() {
|
|
27184
|
-
if (this.methodName === "")
|
|
27185
|
-
return this.className;
|
|
27186
|
-
else
|
|
27187
|
-
return `${this.className}.${this.methodName}`;
|
|
27188
|
-
}
|
|
27189
|
-
/*
|
|
27190
|
-
* Prefix used for all log messages.
|
|
27191
|
-
* @ returns The date and time of the log message, the class name, and the method name.
|
|
27192
|
-
*/
|
|
27193
|
-
get prefix() {
|
|
27194
|
-
return `${new Date().toLocaleString()} ${this.targetName}> `;
|
|
27195
|
-
}
|
|
27196
|
-
/*
|
|
27197
|
-
* This will write a log for the verbosity level of Error only
|
|
27198
|
-
* This includes verbosity levels of Error, Warning, Information, Debug, and Trace.
|
|
27199
|
-
* @param message The message to log.
|
|
27200
|
-
* @param optionalParams Optional parameters to include in the log message.
|
|
27201
|
-
*/
|
|
27202
|
-
error(message, ...optionalParams) {
|
|
27203
|
-
if (this.logLevel === 'Error' || this.logLevel === 'Warn' || this.logLevel === 'Info' || this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
27204
|
-
console.error(`${this.prefix} Error: ${message}`, optionalParams);
|
|
27205
|
-
}
|
|
27206
|
-
}
|
|
27207
|
-
/*
|
|
27208
|
-
* Limited level of logging for warnings.
|
|
27209
|
-
* This includes verbosity levels of Warning, Information, Debug, and Trace.
|
|
27210
|
-
* @param message The message to log.
|
|
27211
|
-
* @param optionalParams Optional parameters to include in the log message.
|
|
27212
|
-
*/
|
|
27213
|
-
warn(message, ...optionalParams) {
|
|
27214
|
-
if (this.logLevel === 'Warn' || this.logLevel === 'Info' || this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
27215
|
-
console.warn(`${this.prefix} Warning: ${message}`, optionalParams);
|
|
27216
|
-
}
|
|
27217
|
-
}
|
|
27218
|
-
/*
|
|
27219
|
-
* Default log level.
|
|
27220
|
-
* This includes verbosity levels of Information, Debug, and Trace.
|
|
27221
|
-
* This is used to provide general information about app flow but shouldn't contain values.
|
|
27222
|
-
* @param message The message to log.
|
|
27223
|
-
* @param optionalParams Optional parameters to include in the log message.
|
|
27224
|
-
*/
|
|
27225
|
-
info(message, ...optionalParams) {
|
|
27226
|
-
if (this.logLevel === 'Info' || this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
27227
|
-
console.info(`${this.prefix} Information: ${message}`, optionalParams);
|
|
27228
|
-
}
|
|
27229
|
-
}
|
|
27230
|
-
/*
|
|
27231
|
-
* Useful for debugging,
|
|
27232
|
-
* This includes verbosity levels of Debug and Trace.
|
|
27233
|
-
* If actual values are put in the logs, this should be chosen; they may need to be sanitized
|
|
27234
|
-
* @param message The message to log.
|
|
27235
|
-
* @param optionalParams Optional parameters to include in the log message.
|
|
27236
|
-
*/
|
|
27237
|
-
debug(message, ...optionalParams) {
|
|
27238
|
-
if (this.logLevel === 'Debug' || this.logLevel === 'Trace') {
|
|
27239
|
-
console.debug(`${this.prefix} Debug: ${message}`, optionalParams);
|
|
27240
|
-
}
|
|
27241
|
-
}
|
|
27242
|
-
/*
|
|
27243
|
-
*The highest verbosity should log a crazy number of records.
|
|
27244
|
-
* This includes verbosity level Trace. they may need to be sanitized
|
|
27245
|
-
* @param message The message to log.
|
|
27246
|
-
* @param optionalParams Optional parameters to include in the log message.
|
|
27247
|
-
*/
|
|
27248
|
-
trace(message, ...optionalParams) {
|
|
27249
|
-
if (this.logLevel === 'Trace') {
|
|
27250
|
-
console.log(`${this.prefix} Trace: ${message}`, optionalParams);
|
|
27251
|
-
}
|
|
27252
|
-
}
|
|
27253
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ClassLoggerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
27254
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ClassLoggerService });
|
|
27255
|
-
}
|
|
27256
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ClassLoggerService, decorators: [{
|
|
27257
|
-
type: Injectable
|
|
27258
|
-
}] });
|
|
27259
|
-
|
|
27260
27293
|
class ConfigService {
|
|
27261
27294
|
logger;
|
|
27262
27295
|
mockData = false;
|
|
@@ -27885,10 +27918,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
27885
27918
|
// ================================================
|
|
27886
27919
|
// Export every type you want this module to expose
|
|
27887
27920
|
// ================================================
|
|
27921
|
+
// Components
|
|
27888
27922
|
|
|
27889
27923
|
/**
|
|
27890
27924
|
* Generated bundle index. Do not edit.
|
|
27891
27925
|
*/
|
|
27892
27926
|
|
|
27893
|
-
export { BaseApiService, CardTypes, Category, ClassLoggerService, ConfigService, Customer, CwmSharedModule, DEFAULT_API_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CAROUSEL_CONFIG, DEFAULT_CONFIGURATION, DEFAULT_CUSTOMER, DEFAULT_INVENTORY_API_RESPONSE, DEFAULT_MENU_BOARD_CONFIG, DEFAULT_PROFILE, DEFAULT_SLIDE, DEFAULT_SUBSCRIPTION_CONFIG, DbKeys, ExternalNavigationComponent, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MockConfig, MockCustomer, MockInventoryApiResponse, MockProfile, NamedColors, NavigateToRouteComponent, OnElementStyle, PageNotFoundComponent, Product, Profile, SafeHtmlPipe, Stack, SubscriptionApiService, TimeSpan, TimeSpanOverflowError, UserTypes, Utilities, decodeToken, doWithLock, isTokenValid, msalGuardConfigFactory, msalInstanceFactory, msalInterceptorConfigFactory, waitFor };
|
|
27927
|
+
export { AUTH_CONFIG, BaseApiService, CardTypes, Category, ClassLoggerService, ConfigService, Customer, CwmSharedModule, DEFAULT_API_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CAROUSEL_CONFIG, DEFAULT_COMPANY_NAME, DEFAULT_CONFIGURATION, DEFAULT_CUSTOMER, DEFAULT_INVENTORY_API_RESPONSE, DEFAULT_MENU_BOARD_CONFIG, DEFAULT_PROFILE, DEFAULT_SLIDE, DEFAULT_SUBSCRIPTION_CONFIG, DbKeys, ExternalNavigationComponent, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MockConfig, MockCustomer, MockInventoryApiResponse, MockProfile, NamedColors, NavigateToRouteComponent, OnElementStyle, PageNotFoundComponent, Product, Profile, SafeHtmlPipe, Stack, SubscriptionApiService, TimeSpan, TimeSpanOverflowError, UserTypes, Utilities, decodeToken, doWithLock, isTokenValid, msalGuardConfigFactory, msalInstanceFactory, msalInterceptorConfigFactory, waitFor };
|
|
27894
27928
|
//# sourceMappingURL=transcommerce-cwm-shared.mjs.map
|