@transcommerce/cwm-shared 1.1.25 → 1.1.28
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 +164 -33
- package/fesm2022/transcommerce-cwm-shared.mjs.map +1 -1
- package/lib/factories/msal-interceptor-config.factory.d.ts +1 -1
- package/lib/factories/msal-interceptor-config.factory.d.ts.map +1 -1
- package/lib/factories/msal.guard.config.factory.d.ts +1 -1
- package/lib/factories/msal.guard.config.factory.d.ts.map +1 -1
- package/lib/factories/msal.instance.factory.d.ts +2 -2
- package/lib/factories/msal.instance.factory.d.ts.map +1 -1
- package/lib/services/config.service.d.ts.map +1 -1
- package/lib/services/inventory-api.service.d.ts.map +1 -1
- package/lib/services/log.service.d.ts +1 -0
- package/lib/services/log.service.d.ts.map +1 -1
- package/lib/services/mocks/mock-customer.d.ts +3 -0
- package/lib/services/mocks/mock-customer.d.ts.map +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/public-api.d.ts.map +1 -1
|
@@ -3,7 +3,7 @@ import { Component, Injectable, Pipe, NgModule } 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';
|
|
6
|
-
import { InteractionType, PublicClientApplication } from '@azure/msal-browser';
|
|
6
|
+
import { InteractionType, PublicClientApplication, LogLevel } from '@azure/msal-browser';
|
|
7
7
|
import * as i2$1 from '@angular/common/http';
|
|
8
8
|
import { HttpResponseBase, HttpResponse, HttpErrorResponse, HttpHeaders, HttpStatusCode } from '@angular/common/http';
|
|
9
9
|
import { CommonModule } from '@angular/common';
|
|
@@ -113,31 +113,120 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", 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
|
-
function
|
|
116
|
+
function msalGuardConfigFactory() {
|
|
117
117
|
return {
|
|
118
118
|
interactionType: InteractionType.Redirect,
|
|
119
119
|
authRequest: {
|
|
120
120
|
scopes: ['user.read']
|
|
121
|
-
}
|
|
121
|
+
},
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
const isIE = window.navigator.userAgent.indexOf('MSIE ') > -1 || window.navigator.userAgent.indexOf('Trident/') > -1;
|
|
126
|
+
function getAuthConfig() {
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
const wind = window;
|
|
129
|
+
return wind.authConfig;
|
|
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
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// -----------------------------------------
|
|
174
|
+
// Runtime factories for MSAL (avoid module-eval-time access to window)
|
|
175
|
+
// -----------------------------------------
|
|
176
|
+
function msalInstanceFactory() {
|
|
177
|
+
const cfg = getAuthConfigSafe();
|
|
126
178
|
return new PublicClientApplication({
|
|
127
179
|
auth: {
|
|
128
|
-
clientId:
|
|
129
|
-
authority:
|
|
130
|
-
redirectUri:
|
|
180
|
+
clientId: cfg.clientId,
|
|
181
|
+
authority: cfg.authority,
|
|
182
|
+
redirectUri: cfg.redirect_uri,
|
|
183
|
+
postLogoutRedirectUri: cfg.redirect_uri,
|
|
184
|
+
},
|
|
185
|
+
cache: {
|
|
186
|
+
cacheLocation: 'localStorage',
|
|
187
|
+
temporaryCacheLocation: 'sessionStorage',
|
|
188
|
+
storeAuthStateInCookie: isIE,
|
|
189
|
+
secureCookies: true,
|
|
190
|
+
cacheMigrationEnabled: true,
|
|
191
|
+
claimsBasedCachingEnabled: true
|
|
192
|
+
},
|
|
193
|
+
system: {
|
|
194
|
+
tokenRenewalOffsetSeconds: 30,
|
|
195
|
+
preventCorsPreflight: false,
|
|
196
|
+
loggerOptions: {
|
|
197
|
+
loggerCallback: {},
|
|
198
|
+
piiLoggingEnabled: true,
|
|
199
|
+
logLevel: LogLevel.Verbose,
|
|
200
|
+
correlationId: "ff88c00e-fd95-49c6-8203-5b2b62a4eb2f",
|
|
201
|
+
},
|
|
202
|
+
windowHashTimeout: 1000,
|
|
203
|
+
iframeHashTimeout: 1000,
|
|
204
|
+
loadFrameTimeout: 1000,
|
|
205
|
+
navigateFrameWait: 1000,
|
|
206
|
+
redirectNavigationTimeout: 1000,
|
|
207
|
+
asyncPopups: false,
|
|
208
|
+
allowRedirectInIframe: false,
|
|
209
|
+
allowNativeBroker: false,
|
|
210
|
+
nativeBrokerHandshakeTimeout: 500,
|
|
211
|
+
pollIntervalMilliseconds: 30,
|
|
212
|
+
},
|
|
213
|
+
telemetry: {
|
|
214
|
+
application: {
|
|
215
|
+
appName: "cwm-digital-menu",
|
|
216
|
+
appVersion: "1.0"
|
|
217
|
+
},
|
|
131
218
|
}
|
|
132
219
|
});
|
|
133
220
|
}
|
|
134
221
|
|
|
135
|
-
function
|
|
136
|
-
const protectedResourceMap = new Map();
|
|
137
|
-
protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read']);
|
|
222
|
+
function msalInterceptorConfigFactory() {
|
|
138
223
|
return {
|
|
139
|
-
interactionType: InteractionType.
|
|
140
|
-
protectedResourceMap
|
|
224
|
+
interactionType: InteractionType.Redirect,
|
|
225
|
+
protectedResourceMap: new Map([
|
|
226
|
+
['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?', ["api://" + window.location.hostname + '/inventory.read']]
|
|
229
|
+
])
|
|
141
230
|
};
|
|
142
231
|
}
|
|
143
232
|
|
|
@@ -26869,7 +26958,7 @@ const MockConfig = {
|
|
|
26869
26958
|
"configConnectString": "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF",
|
|
26870
26959
|
"clientId": "af1486e0-a27f-4c8d-8503-0752d90ce72d",
|
|
26871
26960
|
"tenantId": "72950c7a-314c-4ce9-87e5-a9866db20070",
|
|
26872
|
-
"authority": "https://
|
|
26961
|
+
"authority": "https://cwmcustomers.ciamlogin.com/72950c7a-314c-4ce9-87e5-a9866db20070",
|
|
26873
26962
|
"scopes": "openid,email,profile",
|
|
26874
26963
|
"menu_uri": "http://localhost:4280/",
|
|
26875
26964
|
"redirect_uri": "https://localhost:4280",
|
|
@@ -26902,7 +26991,7 @@ const MockConfig = {
|
|
|
26902
26991
|
},
|
|
26903
26992
|
"footerCarouselSlideConfig": [
|
|
26904
26993
|
{
|
|
26905
|
-
"image": "../../../images/sunday.png",
|
|
26994
|
+
"image": "../../../assets/images/sunday.png",
|
|
26906
26995
|
"title": "CBD Sunday",
|
|
26907
26996
|
"description": "20% off all CBD products & house pre-rolls",
|
|
26908
26997
|
"highlighted": false,
|
|
@@ -26910,7 +26999,7 @@ const MockConfig = {
|
|
|
26910
26999
|
"backgroundColor": "black"
|
|
26911
27000
|
},
|
|
26912
27001
|
{
|
|
26913
|
-
"image": "../../../images/new-monday.jpg",
|
|
27002
|
+
"image": "../../../assets/images/new-monday.jpg",
|
|
26914
27003
|
"title": "Edible Monday",
|
|
26915
27004
|
"description": "10% off edibles",
|
|
26916
27005
|
"highlighted": false,
|
|
@@ -26918,7 +27007,7 @@ const MockConfig = {
|
|
|
26918
27007
|
"backgroundColor": "black"
|
|
26919
27008
|
},
|
|
26920
27009
|
{
|
|
26921
|
-
"image": "../../../images/tuesday.png",
|
|
27010
|
+
"image": "../../../assets/images/tuesday.png",
|
|
26922
27011
|
"title": "Doobie Tuesday",
|
|
26923
27012
|
"description": "10% off all pre-rolls & packs<",
|
|
26924
27013
|
"highlighted": false,
|
|
@@ -26926,7 +27015,7 @@ const MockConfig = {
|
|
|
26926
27015
|
"backgroundColor": "white"
|
|
26927
27016
|
},
|
|
26928
27017
|
{
|
|
26929
|
-
"image": "../../../images/wednesday.png",
|
|
27018
|
+
"image": "../../../assets/images/wednesday.png",
|
|
26930
27019
|
"title": "Weed Crush Wednesday",
|
|
26931
27020
|
"description": "10% off all jar bud",
|
|
26932
27021
|
"highlighted": false,
|
|
@@ -26934,7 +27023,7 @@ const MockConfig = {
|
|
|
26934
27023
|
"backgroundColor": "white"
|
|
26935
27024
|
},
|
|
26936
27025
|
{
|
|
26937
|
-
"image": "../../../images/thursday.png",
|
|
27026
|
+
"image": "../../../assets/images/thursday.png",
|
|
26938
27027
|
"title": "Thirsty Thursday",
|
|
26939
27028
|
"description": "10% off Tinctures, RSO & cartridges",
|
|
26940
27029
|
"highlighted": false,
|
|
@@ -26942,7 +27031,7 @@ const MockConfig = {
|
|
|
26942
27031
|
"backgroundColor": "white"
|
|
26943
27032
|
},
|
|
26944
27033
|
{
|
|
26945
|
-
"image": "../../../images/friday.png",
|
|
27034
|
+
"image": "../../../assets/images/friday.png",
|
|
26946
27035
|
"title": "Fire Friday",
|
|
26947
27036
|
"description": "10% off all jar bud",
|
|
26948
27037
|
"highlighted": false,
|
|
@@ -26950,7 +27039,7 @@ const MockConfig = {
|
|
|
26950
27039
|
"backgroundColor": "white"
|
|
26951
27040
|
},
|
|
26952
27041
|
{
|
|
26953
|
-
"image": "../../../images/saturday.png",
|
|
27042
|
+
"image": "../../../assets/images/saturday.png",
|
|
26954
27043
|
"title": "Shatterday Saturday",
|
|
26955
27044
|
"description": "10% off all concentrate",
|
|
26956
27045
|
"highlighted": false,
|
|
@@ -26975,6 +27064,26 @@ const MockProfile = {
|
|
|
26975
27064
|
"userPrincipalName": "demo@app.cheapweedmenu.com"
|
|
26976
27065
|
};
|
|
26977
27066
|
|
|
27067
|
+
const MockCustomer = {
|
|
27068
|
+
"apiClientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
|
|
27069
|
+
"apiLocationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae",
|
|
27070
|
+
"companyName": "Test Weed Dispensary",
|
|
27071
|
+
"emailAddress": "demo@app.cheapweedmenu.com",
|
|
27072
|
+
"id": "1",
|
|
27073
|
+
"phoneNumber": "5035551212",
|
|
27074
|
+
"jobTitle": "Budtender",
|
|
27075
|
+
"userType": UserTypes.Administrator,
|
|
27076
|
+
"displayName": "Demo User",
|
|
27077
|
+
"givenName": "Demo",
|
|
27078
|
+
"surName": "User",
|
|
27079
|
+
"streetAddress": "123 Any Street",
|
|
27080
|
+
"city": "Anytown",
|
|
27081
|
+
"state": "OR",
|
|
27082
|
+
"postalCode": "12345",
|
|
27083
|
+
"country": "USA",
|
|
27084
|
+
"subscriptionId": "1"
|
|
27085
|
+
};
|
|
27086
|
+
|
|
26978
27087
|
/*
|
|
26979
27088
|
The LogService is really just a wrapper around the existing console logging functionality
|
|
26980
27089
|
The three main reasons for using this service are:
|
|
@@ -26987,8 +27096,16 @@ class LogService {
|
|
|
26987
27096
|
_className = "";
|
|
26988
27097
|
get className() { return this._className; }
|
|
26989
27098
|
set className(value) {
|
|
26990
|
-
this._className
|
|
26991
|
-
|
|
27099
|
+
if (this._className !== "" && this._className !== value && this.logLevel != 'None') {
|
|
27100
|
+
console.groupCollapsed(this.targetName + " - " + value + " - " + new Date().toLocaleString());
|
|
27101
|
+
}
|
|
27102
|
+
if (this._className === "" || this._className !== value) {
|
|
27103
|
+
this._className = value;
|
|
27104
|
+
this.methodName = "constructor()";
|
|
27105
|
+
}
|
|
27106
|
+
else {
|
|
27107
|
+
this._className = value;
|
|
27108
|
+
}
|
|
26992
27109
|
}
|
|
26993
27110
|
_methodName = "";
|
|
26994
27111
|
get methodName() { return this._methodName; }
|
|
@@ -27023,6 +27140,15 @@ class LogService {
|
|
|
27023
27140
|
console.log(this.prefix + " " + message, optionalParams);
|
|
27024
27141
|
}
|
|
27025
27142
|
}
|
|
27143
|
+
debug(message, ...optionalParams) {
|
|
27144
|
+
if (this.logLevel === 'Debug') {
|
|
27145
|
+
if (this.targetName != this.className) {
|
|
27146
|
+
console.timeEnd(this.targetName);
|
|
27147
|
+
console.time(this.targetName);
|
|
27148
|
+
}
|
|
27149
|
+
console.debug(this.prefix + " " + message, optionalParams);
|
|
27150
|
+
}
|
|
27151
|
+
}
|
|
27026
27152
|
info(message, ...optionalParams) {
|
|
27027
27153
|
if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
|
|
27028
27154
|
if (this.targetName != this.className)
|
|
@@ -27081,18 +27207,23 @@ class ConfigService {
|
|
|
27081
27207
|
}
|
|
27082
27208
|
async getConfigurationSettingAsync(key, label) {
|
|
27083
27209
|
this.logService.methodName = "getConfigurationSettingAsync()";
|
|
27084
|
-
|
|
27085
|
-
|
|
27086
|
-
|
|
27210
|
+
let setting = {};
|
|
27211
|
+
this.logService.log("Get Configuration Setting for Key/Label requested", key, label);
|
|
27212
|
+
if (this.mockData || this.configCache != undefined) {
|
|
27213
|
+
if (this.configCache == undefined) {
|
|
27214
|
+
this.configCache = MockConfig;
|
|
27215
|
+
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);
|
|
27216
|
+
}
|
|
27087
27217
|
setting.key = key;
|
|
27088
|
-
setting.value = JSON.stringify(
|
|
27089
|
-
this.
|
|
27218
|
+
setting.value = JSON.stringify(this.configCache);
|
|
27219
|
+
if (this.mockData)
|
|
27220
|
+
this.logService.log("Mock Data Enabled, Skipping getConfigurationSetting() and using Mock Config from the Configuration Cache", this.configCache);
|
|
27221
|
+
this.logService.log("Configuration Cache was available, skipping getConfigurationSetting() and using Cached Configuration", this.configCache);
|
|
27090
27222
|
}
|
|
27091
|
-
else {
|
|
27092
|
-
this.logService.log("Getting Configuration Setting Key/Label", key, label);
|
|
27223
|
+
else if (this.configCache == undefined) {
|
|
27224
|
+
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);
|
|
27093
27225
|
setting = await this.configClient.getConfigurationSetting({ key: key, label: label.replace(".", "") });
|
|
27094
27226
|
}
|
|
27095
|
-
this.logService.log("Configuration Setting Key/Value", key, setting.value);
|
|
27096
27227
|
return setting.value;
|
|
27097
27228
|
}
|
|
27098
27229
|
async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
|
|
@@ -27219,11 +27350,11 @@ class InventoryApiService extends BaseApiService {
|
|
|
27219
27350
|
.set('locationId', this.config?.locationId);
|
|
27220
27351
|
}
|
|
27221
27352
|
get apiFullUrl() {
|
|
27222
|
-
return this.apiBaseUrl + this.config
|
|
27353
|
+
return this.apiBaseUrl + (this.config ?? MockConfig.apiConfig).getInventoryApiRoute;
|
|
27223
27354
|
}
|
|
27224
27355
|
async getProductsAsync(companyName) {
|
|
27225
27356
|
this.logService.methodName = "getProductsAsync()";
|
|
27226
|
-
|
|
27357
|
+
let response;
|
|
27227
27358
|
this.configService.mockData = this.useMockData;
|
|
27228
27359
|
this.logService.log("Fetching Configuration for Company", companyName);
|
|
27229
27360
|
this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
|
|
@@ -27561,5 +27692,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
27561
27692
|
* Generated bundle index. Do not edit.
|
|
27562
27693
|
*/
|
|
27563
27694
|
|
|
27564
|
-
export { BaseApiService, CardTypes, Category, ConfigService, Customer, CustomerApiService, CwmSharedModule, DbKeys, ExternalNavigationComponent, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity,
|
|
27695
|
+
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 };
|
|
27565
27696
|
//# sourceMappingURL=transcommerce-cwm-shared.mjs.map
|