@transcommerce/cwm-shared 1.1.20 → 1.1.22
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 +48 -30
- package/fesm2022/transcommerce-cwm-shared.mjs.map +1 -1
- package/lib/services/config.service.d.ts.map +1 -1
- package/lib/services/inventory-api.service.d.ts +2 -2
- package/lib/services/inventory-api.service.d.ts.map +1 -1
- package/lib/services/mocks/mock-profile.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -26960,19 +26960,18 @@ const MockConfig = {
|
|
|
26960
26960
|
};
|
|
26961
26961
|
|
|
26962
26962
|
const MockProfile = {
|
|
26963
|
-
companyName: "
|
|
26964
|
-
businessPhones: ["503.555.1212"],
|
|
26965
|
-
displayName: "
|
|
26966
|
-
givenName: "
|
|
26967
|
-
id: "",
|
|
26968
|
-
jobTitle: "
|
|
26969
|
-
mail: "
|
|
26970
|
-
mobilePhone: "503.555.1212",
|
|
26971
|
-
|
|
26972
|
-
|
|
26973
|
-
|
|
26974
|
-
|
|
26975
|
-
userPrincipalName: "portlandpotshop"
|
|
26963
|
+
"companyName": "Cheap Weed Menu",
|
|
26964
|
+
"businessPhones": ["503.555.1212"],
|
|
26965
|
+
"displayName": "Demo User",
|
|
26966
|
+
"givenName": "Demo",
|
|
26967
|
+
"id": "1",
|
|
26968
|
+
"jobTitle": "Budtender",
|
|
26969
|
+
"mail": "demo@app.cheapweedmenu.com",
|
|
26970
|
+
"mobilePhone": "503.555.1212",
|
|
26971
|
+
"photoUrl": "",
|
|
26972
|
+
"preferredLanguage": "en-us",
|
|
26973
|
+
"surname": "User",
|
|
26974
|
+
"userPrincipalName": "demo@app.cheapweedmenu.com"
|
|
26976
26975
|
};
|
|
26977
26976
|
|
|
26978
26977
|
class AuthService {
|
|
@@ -27099,13 +27098,27 @@ class ConfigService {
|
|
|
27099
27098
|
}
|
|
27100
27099
|
async getConfigurationSettingAsync(key, label) {
|
|
27101
27100
|
this.logService.methodName = "getConfigurationSettingAsync()";
|
|
27102
|
-
|
|
27101
|
+
var setting;
|
|
27102
|
+
if (this.mockData) {
|
|
27103
|
+
setting = {};
|
|
27104
|
+
setting.key = key;
|
|
27105
|
+
setting.value = JSON.stringify(MockConfig);
|
|
27106
|
+
this.logService.log("Mock Data Enabled, Skipping getConfigurationSettingAsync()");
|
|
27107
|
+
}
|
|
27108
|
+
else {
|
|
27109
|
+
this.logService.log("Getting Configuration Setting Key/Label", key, label);
|
|
27110
|
+
setting = await this.configClient.getConfigurationSetting({ key: key, label: label.replace(".", "") });
|
|
27111
|
+
}
|
|
27103
27112
|
this.logService.log("Configuration Setting Key/Value", key, setting.value);
|
|
27104
27113
|
return setting.value;
|
|
27105
27114
|
}
|
|
27106
27115
|
async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
|
|
27107
27116
|
this.logService.className = "ConfigService";
|
|
27108
27117
|
this.logService.methodName = "setConfigurationSettingAsync()";
|
|
27118
|
+
if (this.mockData) {
|
|
27119
|
+
this.logService.log("Mock Data Enabled, Skipping setConfigurationSettingAsync()");
|
|
27120
|
+
return;
|
|
27121
|
+
}
|
|
27109
27122
|
const configurationSetting = {
|
|
27110
27123
|
key: templateName,
|
|
27111
27124
|
label: label,
|
|
@@ -27119,18 +27132,19 @@ class ConfigService {
|
|
|
27119
27132
|
async getConfigAsync(company) {
|
|
27120
27133
|
this.logService.className = "ConfigService";
|
|
27121
27134
|
this.logService.methodName = "getConfigAsync()";
|
|
27122
|
-
if (this.
|
|
27123
|
-
this.
|
|
27124
|
-
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27135
|
+
if (this.mockData) {
|
|
27136
|
+
this.configCache = MockConfig;
|
|
27137
|
+
this.logService.log("Mock Data Enabled, Using Mock Config", this.configCache);
|
|
27138
|
+
}
|
|
27139
|
+
else if (this.configCache == undefined) {
|
|
27140
|
+
this.logService.log("Loading Configuration from Azure App Configuration");
|
|
27141
|
+
const jsonConfig = await this.getConfigurationSettingAsync("App.Config.Json", company) ?? "{ }";
|
|
27142
|
+
this.configCache = JSON.parse(jsonConfig);
|
|
27143
|
+
this.logService.log("Loaded and Cached Configuration from Azure App Configuration", this.configCache);
|
|
27144
|
+
}
|
|
27145
|
+
else {
|
|
27146
|
+
this.logService.log("Using Cached Configuration", this.configCache);
|
|
27132
27147
|
}
|
|
27133
|
-
this.logService.log("Config Cache", this.configCache);
|
|
27134
27148
|
const config = this.configCache;
|
|
27135
27149
|
this.logService.methodName = "";
|
|
27136
27150
|
return config;
|
|
@@ -27142,9 +27156,12 @@ class ConfigService {
|
|
|
27142
27156
|
this.configCache = config;
|
|
27143
27157
|
this.logService.log("Updated Config Cache", this.configCache);
|
|
27144
27158
|
if (this.mockData) {
|
|
27159
|
+
this.logService.log("Mock Data Enabled, Skipping setConfigurationSettingAsync()");
|
|
27145
27160
|
return;
|
|
27146
27161
|
}
|
|
27162
|
+
this.logService.log("Saving Configuration to Azure App Configuration");
|
|
27147
27163
|
await this.setConfigurationSettingAsync("App.Config.Json", company, config, "JSON");
|
|
27164
|
+
this.logService.log("Saved Configuration to Azure App Configuration");
|
|
27148
27165
|
this.logService.methodName = "";
|
|
27149
27166
|
}
|
|
27150
27167
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -27207,7 +27224,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
27207
27224
|
}] });
|
|
27208
27225
|
|
|
27209
27226
|
class InventoryApiService extends BaseApiService {
|
|
27210
|
-
|
|
27227
|
+
useMockData = false;
|
|
27211
27228
|
constructor(configService, httpClient, logService) {
|
|
27212
27229
|
super(configService, httpClient, logService);
|
|
27213
27230
|
logService.className = "InventoryApiService";
|
|
@@ -27221,17 +27238,18 @@ class InventoryApiService extends BaseApiService {
|
|
|
27221
27238
|
get apiFullUrl() {
|
|
27222
27239
|
return this.apiBaseUrl + this.config?.getInventoryApiRoute;
|
|
27223
27240
|
}
|
|
27224
|
-
async getProductsAsync(companyName
|
|
27241
|
+
async getProductsAsync(companyName) {
|
|
27225
27242
|
this.logService.methodName = "getProductsAsync()";
|
|
27226
27243
|
var response;
|
|
27244
|
+
this.configService.mockData = this.useMockData;
|
|
27245
|
+
this.logService.log("Fetching Configuration for Company", companyName);
|
|
27246
|
+
this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
|
|
27227
27247
|
this.logService.log("Fetching Products for Company", companyName);
|
|
27228
|
-
if (this.
|
|
27229
|
-
this.config = MockConfig.apiConfig;
|
|
27248
|
+
if (this.useMockData) {
|
|
27230
27249
|
response = Promise.resolve(MockInventoryApiResponse);
|
|
27231
27250
|
this.logService.log("Mock Data Returned", response);
|
|
27232
27251
|
}
|
|
27233
27252
|
else {
|
|
27234
|
-
this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
|
|
27235
27253
|
response = firstValueFrom(this.httpClient.get(this.apiFullUrl, { headers: this.httpHeaders }));
|
|
27236
27254
|
this.logService.log("Inventory API Response", response);
|
|
27237
27255
|
}
|