@veloceapps/sdk 8.0.0-66 → 8.0.0-68
Sign up to get free protection for your applications and to get access to all the features.
- package/core/modules/configuration/services/configuration.service.d.ts +3 -1
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +16 -5
- package/fesm2015/veloceapps-sdk-core.mjs +109 -100
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +108 -99
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
@@ -1,9 +1,9 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, InjectionToken, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContextMode, ConfigurationContext,
|
3
|
+
import { UUID, ConfigurationContextMode, ConfigurationContext, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, getUIDefinitionProperties, ChargeGroupUtils, RuntimeModel, isLegacyUIDefinition, SalesforceIdUtils, EntityUtil, formatNumber } from '@veloceapps/core';
|
4
4
|
import * as i1 from '@veloceapps/api';
|
5
5
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
6
|
-
import { BehaviorSubject, zip, noop, combineLatest,
|
6
|
+
import { BehaviorSubject, zip, noop, combineLatest, map as map$2, tap as tap$1, throwError, shareReplay as shareReplay$1, of, switchMap as switchMap$1, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
|
7
7
|
import { filter, tap, map, switchMap, skip, take, shareReplay, catchError, finalize, first } from 'rxjs/operators';
|
8
8
|
import { merge, isEqual, flatten, sortBy, map as map$1, transform, omit, cloneDeep, uniq } from 'lodash';
|
9
9
|
import { HttpErrorResponse } from '@angular/common/http';
|
@@ -561,6 +561,99 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
561
561
|
upsertAttributes: upsertAttributes
|
562
562
|
});
|
563
563
|
|
564
|
+
class RuntimeSettingsService {
|
565
|
+
constructor(configurationSettingsApiService) {
|
566
|
+
this.configurationSettingsApiService = configurationSettingsApiService;
|
567
|
+
this.configurationSettings$ = new BehaviorSubject({});
|
568
|
+
this.currencySettings$ = new BehaviorSubject({
|
569
|
+
iso: DEFAULT_CURRENCY_ISO_CODE,
|
570
|
+
symbol: DEFAULT_CURRENCY_SYMBOL,
|
571
|
+
});
|
572
|
+
this.getCurrencySymbol = (locale, currency) => {
|
573
|
+
return (0)
|
574
|
+
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
575
|
+
.replace(/\d/g, '')
|
576
|
+
.trim();
|
577
|
+
};
|
578
|
+
}
|
579
|
+
create() {
|
580
|
+
return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
|
581
|
+
this.configurationSettings$.next(configurationSettings);
|
582
|
+
this.formattingSettings = this.getFormattingSettings();
|
583
|
+
}), map$2(() => undefined));
|
584
|
+
}
|
585
|
+
initCurrency(iso) {
|
586
|
+
if (iso) {
|
587
|
+
const symbol = this.getCurrencySymbol('en-US', iso);
|
588
|
+
this.currencySettings$.next({ iso, symbol });
|
589
|
+
}
|
590
|
+
}
|
591
|
+
getFormattingSettings() {
|
592
|
+
if (this.formattingSettings) {
|
593
|
+
return this.formattingSettings;
|
594
|
+
}
|
595
|
+
const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
|
596
|
+
return { ...acc, [setting.id]: setting.properties };
|
597
|
+
}, {});
|
598
|
+
const currencySettings = this.getCurrencySettings();
|
599
|
+
const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
|
600
|
+
DEFAULT_DATE_FORMAT;
|
601
|
+
const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
|
602
|
+
const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
|
603
|
+
// the number of decimal places can be 0
|
604
|
+
const priceScale = shoppingCartSettings?.PRICE_SCALE;
|
605
|
+
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
606
|
+
? Number(priceScale)
|
607
|
+
: DEFAULT_DECIMALS_COUNT;
|
608
|
+
const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
|
609
|
+
return {
|
610
|
+
currencySymbol: currencySettings.symbol,
|
611
|
+
dateFormats: getSupportedDateFormats(dateFormat),
|
612
|
+
decimalsCount,
|
613
|
+
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
614
|
+
? decimalSeparator
|
615
|
+
: DEFAULT_DECIMAL_SEPARATOR,
|
616
|
+
// thousands separator can be a blank value, so it can also be null
|
617
|
+
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
618
|
+
? thousandsSeparator || ''
|
619
|
+
: DEFAULT_THOUSANDS_SEPARATOR,
|
620
|
+
actionCodeLabels: actionCodeSettings?.length
|
621
|
+
? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
|
622
|
+
: DEFAULT_ACTION_CODE_LABELS,
|
623
|
+
};
|
624
|
+
}
|
625
|
+
getConfigurationSettings() {
|
626
|
+
return this.configurationSettings$.value;
|
627
|
+
}
|
628
|
+
getCurrencySettings() {
|
629
|
+
return this.currencySettings$.value;
|
630
|
+
}
|
631
|
+
parseConfigurationSettings(settings) {
|
632
|
+
return settings.reduce((acc, setting) => {
|
633
|
+
switch (setting.key) {
|
634
|
+
case 'shopping-cart':
|
635
|
+
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
636
|
+
break;
|
637
|
+
case 'navigation':
|
638
|
+
acc.navigation = parseJsonSafely(setting.value, {});
|
639
|
+
break;
|
640
|
+
case 'flows':
|
641
|
+
acc.flows = parseJsonSafely(setting.value, []);
|
642
|
+
break;
|
643
|
+
default:
|
644
|
+
acc[setting.key] = setting.value;
|
645
|
+
}
|
646
|
+
return acc;
|
647
|
+
}, {});
|
648
|
+
}
|
649
|
+
}
|
650
|
+
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
651
|
+
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
|
652
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
653
|
+
type: Injectable,
|
654
|
+
args: [{ providedIn: 'root' }]
|
655
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
656
|
+
|
564
657
|
const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
|
565
658
|
|
566
659
|
var RuntimeMode;
|
@@ -600,13 +693,14 @@ class LineItemWorker {
|
|
600
693
|
}
|
601
694
|
|
602
695
|
class ConfigurationService {
|
603
|
-
constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
|
696
|
+
constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
|
604
697
|
this.quoteDraftService = quoteDraftService;
|
605
698
|
this.runtimeService = runtimeService;
|
606
699
|
this.contextService = contextService;
|
607
700
|
this.configurationApiService = configurationApiService;
|
608
701
|
this.messageService = messageService;
|
609
702
|
this.dialogService = dialogService;
|
703
|
+
this.runtimeSettings = runtimeSettings;
|
610
704
|
this.mode = ConfigurationMode.SEARCH;
|
611
705
|
this.lineItem = new BehaviorSubject(undefined);
|
612
706
|
this.charges = new BehaviorSubject({});
|
@@ -703,8 +797,16 @@ class ConfigurationService {
|
|
703
797
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
704
798
|
const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
|
705
799
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
800
|
+
const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
|
706
801
|
this.isLoadingSubj$.next(true);
|
707
|
-
|
802
|
+
const configure$ = pricingEnabled && customPriceApi
|
803
|
+
? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
|
804
|
+
: this.configurationApiService.configureLineItem({
|
805
|
+
configurationRequest,
|
806
|
+
runtimeModel,
|
807
|
+
pricingEnabled,
|
808
|
+
});
|
809
|
+
return configure$.pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems, procedureContext }) => {
|
708
810
|
this.contextService.update(context ?? {});
|
709
811
|
this.charges.next(charges ?? {});
|
710
812
|
this.pricePlans.next(pricePlans ?? {});
|
@@ -801,11 +903,11 @@ class ConfigurationService {
|
|
801
903
|
return this.quoteDraftService.quoteDraft?.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
|
802
904
|
}
|
803
905
|
}
|
804
|
-
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
|
906
|
+
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6.DialogService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
805
907
|
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
|
806
908
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
|
807
909
|
type: Injectable
|
808
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
|
910
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }, { type: RuntimeSettingsService }]; } });
|
809
911
|
|
810
912
|
function extractMetadata(uiDefinition) {
|
811
913
|
return omit(uiDefinition, [
|
@@ -1224,99 +1326,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1224
1326
|
args: [{ providedIn: 'root' }]
|
1225
1327
|
}], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
|
1226
1328
|
|
1227
|
-
class RuntimeSettingsService {
|
1228
|
-
constructor(configurationSettingsApiService) {
|
1229
|
-
this.configurationSettingsApiService = configurationSettingsApiService;
|
1230
|
-
this.configurationSettings$ = new BehaviorSubject({});
|
1231
|
-
this.currencySettings$ = new BehaviorSubject({
|
1232
|
-
iso: DEFAULT_CURRENCY_ISO_CODE,
|
1233
|
-
symbol: DEFAULT_CURRENCY_SYMBOL,
|
1234
|
-
});
|
1235
|
-
this.getCurrencySymbol = (locale, currency) => {
|
1236
|
-
return (0)
|
1237
|
-
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
1238
|
-
.replace(/\d/g, '')
|
1239
|
-
.trim();
|
1240
|
-
};
|
1241
|
-
}
|
1242
|
-
create() {
|
1243
|
-
return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
|
1244
|
-
this.configurationSettings$.next(configurationSettings);
|
1245
|
-
this.formattingSettings = this.getFormattingSettings();
|
1246
|
-
}), map$2(() => undefined));
|
1247
|
-
}
|
1248
|
-
initCurrency(iso) {
|
1249
|
-
if (iso) {
|
1250
|
-
const symbol = this.getCurrencySymbol('en-US', iso);
|
1251
|
-
this.currencySettings$.next({ iso, symbol });
|
1252
|
-
}
|
1253
|
-
}
|
1254
|
-
getFormattingSettings() {
|
1255
|
-
if (this.formattingSettings) {
|
1256
|
-
return this.formattingSettings;
|
1257
|
-
}
|
1258
|
-
const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
|
1259
|
-
return { ...acc, [setting.id]: setting.properties };
|
1260
|
-
}, {});
|
1261
|
-
const currencySettings = this.getCurrencySettings();
|
1262
|
-
const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
|
1263
|
-
DEFAULT_DATE_FORMAT;
|
1264
|
-
const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
|
1265
|
-
const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
|
1266
|
-
// the number of decimal places can be 0
|
1267
|
-
const priceScale = shoppingCartSettings?.PRICE_SCALE;
|
1268
|
-
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
1269
|
-
? Number(priceScale)
|
1270
|
-
: DEFAULT_DECIMALS_COUNT;
|
1271
|
-
const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
|
1272
|
-
return {
|
1273
|
-
currencySymbol: currencySettings.symbol,
|
1274
|
-
dateFormats: getSupportedDateFormats(dateFormat),
|
1275
|
-
decimalsCount,
|
1276
|
-
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
1277
|
-
? decimalSeparator
|
1278
|
-
: DEFAULT_DECIMAL_SEPARATOR,
|
1279
|
-
// thousands separator can be a blank value, so it can also be null
|
1280
|
-
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
1281
|
-
? thousandsSeparator || ''
|
1282
|
-
: DEFAULT_THOUSANDS_SEPARATOR,
|
1283
|
-
actionCodeLabels: actionCodeSettings?.length
|
1284
|
-
? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
|
1285
|
-
: DEFAULT_ACTION_CODE_LABELS,
|
1286
|
-
};
|
1287
|
-
}
|
1288
|
-
getConfigurationSettings() {
|
1289
|
-
return this.configurationSettings$.value;
|
1290
|
-
}
|
1291
|
-
getCurrencySettings() {
|
1292
|
-
return this.currencySettings$.value;
|
1293
|
-
}
|
1294
|
-
parseConfigurationSettings(settings) {
|
1295
|
-
return settings.reduce((acc, setting) => {
|
1296
|
-
switch (setting.key) {
|
1297
|
-
case 'shopping-cart':
|
1298
|
-
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
1299
|
-
break;
|
1300
|
-
case 'navigation':
|
1301
|
-
acc.navigation = parseJsonSafely(setting.value, {});
|
1302
|
-
break;
|
1303
|
-
case 'flows':
|
1304
|
-
acc.flows = parseJsonSafely(setting.value, []);
|
1305
|
-
break;
|
1306
|
-
default:
|
1307
|
-
acc[setting.key] = setting.value;
|
1308
|
-
}
|
1309
|
-
return acc;
|
1310
|
-
}, {});
|
1311
|
-
}
|
1312
|
-
}
|
1313
|
-
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1314
|
-
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
|
1315
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
1316
|
-
type: Injectable,
|
1317
|
-
args: [{ providedIn: 'root' }]
|
1318
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
1319
|
-
|
1320
1329
|
class RuntimeContextService {
|
1321
1330
|
constructor(configurationApiService) {
|
1322
1331
|
this.configurationApiService = configurationApiService;
|