@veloceapps/sdk 7.0.2-60 → 7.0.2-61
Sign up to get free protection for your applications and to get access to all the features.
- package/cms/cms.actions.d.ts +72 -10
- package/cms/types/integration.types.d.ts +1 -0
- package/cms/vendor-map.d.ts +4 -12
- package/core/modules/configuration/helpers.d.ts +3 -1
- package/core/modules/configuration/index.d.ts +1 -0
- package/core/modules/configuration/services/configuration.service.d.ts +4 -2
- package/core/modules/configuration/types/configuration-runtime.types.d.ts +1 -0
- package/core/modules/configuration/types/configuration.types.d.ts +10 -0
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +2 -1
- package/core/utils/line-item.utils.d.ts +5 -13
- package/core/utils/line-item.worker.d.ts +2 -5
- package/esm2020/cms/cms.actions.mjs +99 -39
- package/esm2020/cms/types/integration.types.mjs +1 -1
- package/esm2020/core/modules/configuration/helpers.mjs +35 -2
- package/esm2020/core/modules/configuration/index.mjs +2 -1
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +30 -6
- package/esm2020/core/modules/configuration/types/configuration-runtime.types.mjs +1 -1
- package/esm2020/core/modules/configuration/types/configuration.types.mjs +2 -0
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +4 -4
- package/esm2020/core/utils/line-item.utils.mjs +5 -2
- package/esm2020/core/utils/line-item.worker.mjs +1 -1
- package/esm2020/src/components/doc-gen/doc-gen.component.mjs +29 -6
- package/esm2020/src/components/guided-selling/guided-selling.component.mjs +117 -0
- package/esm2020/src/components/guided-selling/guided-selling.module.mjs +19 -0
- package/esm2020/src/components/header/header.component.mjs +3 -3
- package/esm2020/src/flow.component.mjs +4 -3
- package/esm2020/src/flow.module.mjs +11 -6
- package/esm2020/src/pages/product/product.component.mjs +15 -8
- package/esm2020/src/services/flow-router.service.mjs +10 -5
- package/esm2020/src/services/flow.service.mjs +2 -2
- package/esm2020/src/services/guided-selling.service.mjs +33 -0
- package/esm2020/src/types/flow-customization.types.mjs +1 -1
- package/fesm2015/veloceapps-sdk-cms.mjs +98 -38
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +75 -15
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +238 -52
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +98 -38
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +71 -11
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +230 -52
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/doc-gen/doc-gen.component.d.ts +5 -2
- package/src/components/guided-selling/guided-selling.component.d.ts +29 -0
- package/src/components/guided-selling/guided-selling.module.d.ts +9 -0
- package/src/flow.module.d.ts +6 -5
- package/src/pages/product/product.component.d.ts +4 -2
- package/src/services/flow-router.service.d.ts +3 -1
- package/src/services/guided-selling.service.d.ts +13 -0
- package/src/types/flow-customization.types.d.ts +1 -0
@@ -1,11 +1,12 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { InjectionToken, Injectable, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContext, RuntimeModel, isLegacyUIDefinition,
|
3
|
+
import { UUID, ConfigurationContextMode, ConfigurationContext, RuntimeModel, isLegacyUIDefinition, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, getSupportedDateFormats, DEFAULT_DECIMALS_COUNT, parseJsonSafely, formatNumber } from '@veloceapps/core';
|
4
4
|
import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, tap as tap$1, map as map$2, of, switchMap as switchMap$1, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
|
5
5
|
import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
|
6
6
|
import * as i1 from '@veloceapps/api';
|
7
7
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
8
|
-
import { merge, flatten, sortBy, map as map$1, isEqual, omit, cloneDeep, uniq } from 'lodash';
|
8
|
+
import { merge, flatten, sortBy, map as map$1, isEqual, transform, omit, cloneDeep, uniq } from 'lodash';
|
9
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
9
10
|
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
10
11
|
import * as i5 from 'primeng/api';
|
11
12
|
import * as i6 from 'primeng/dynamicdialog';
|
@@ -16,7 +17,40 @@ import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
|
|
16
17
|
const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
|
17
18
|
var _a, _b, _c;
|
18
19
|
const id = UUID.UUID();
|
19
|
-
|
20
|
+
const attributes = [];
|
21
|
+
const lineItems = [];
|
22
|
+
return Object.assign({ id, type: (_a = uiDefinitionProperties.rootType) !== null && _a !== void 0 ? _a : '', cfgStatus: 'Default', actionCode: 'ADD', qty,
|
23
|
+
attributes,
|
24
|
+
lineItems, productName: ((_b = context.properties) === null || _b === void 0 ? void 0 : _b['displayName']) || context.productName, productId: (_c = context.productId) !== null && _c !== void 0 ? _c : '' }, (uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}));
|
25
|
+
};
|
26
|
+
const getGuidedSellingConfigurationRequest = (data) => {
|
27
|
+
return {
|
28
|
+
mode: 'SEARCH',
|
29
|
+
step: 'START',
|
30
|
+
attributeDomainMode: 'ALL',
|
31
|
+
context: {
|
32
|
+
headerId: 'TestId',
|
33
|
+
mode: ConfigurationContextMode.TEST,
|
34
|
+
properties: {
|
35
|
+
ModelId: data.modelId,
|
36
|
+
Name: 'Veloce Guided Selling',
|
37
|
+
PricingEnabled: 'false',
|
38
|
+
RuntimeMode: 'TEST',
|
39
|
+
},
|
40
|
+
},
|
41
|
+
lineItem: {
|
42
|
+
actionCode: 'ADD',
|
43
|
+
cfgStatus: 'Default',
|
44
|
+
id: UUID.UUID(),
|
45
|
+
qty: 1,
|
46
|
+
type: data.modelType,
|
47
|
+
attributes: Object.entries(data.attributesMap).map(([name, value]) => ({
|
48
|
+
name,
|
49
|
+
value,
|
50
|
+
cfgStatus: 'User',
|
51
|
+
})),
|
52
|
+
},
|
53
|
+
};
|
20
54
|
};
|
21
55
|
|
22
56
|
const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
|
@@ -361,8 +395,11 @@ const multiplyLineItems = (lineItem, qty, split) => {
|
|
361
395
|
];
|
362
396
|
}
|
363
397
|
};
|
398
|
+
const isTechnicalAttribute = (name) => {
|
399
|
+
return name.startsWith('#') || name.startsWith('$');
|
400
|
+
};
|
364
401
|
const filterOutTechnicalAttributes = (attributes) => {
|
365
|
-
return attributes.filter(({ name }) => !
|
402
|
+
return attributes.filter(({ name }) => !isTechnicalAttribute(name));
|
366
403
|
};
|
367
404
|
|
368
405
|
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
@@ -379,6 +416,7 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
379
416
|
getRecommendedPrices: getRecommendedPrices,
|
380
417
|
insertLineItem: insertLineItem,
|
381
418
|
isLineItemModified: isLineItemModified,
|
419
|
+
isTechnicalAttribute: isTechnicalAttribute,
|
382
420
|
mapAttributes: mapAttributes,
|
383
421
|
multiplyLineItems: multiplyLineItems,
|
384
422
|
patchAttributes: patchAttributes,
|
@@ -694,17 +732,25 @@ class ConfigurationService {
|
|
694
732
|
return this.pricePlans.value;
|
695
733
|
}
|
696
734
|
configure() {
|
697
|
-
var _a, _b, _c, _d, _e
|
735
|
+
var _a, _b, _c, _d, _e;
|
698
736
|
const runtimeContext = this.getRuntimeContext();
|
699
737
|
const runtimeModel = this.getRuntimeModel();
|
700
738
|
if (!runtimeContext || !runtimeModel) {
|
701
739
|
return throwError(() => new Error('Runtime context/model not initialized'));
|
702
740
|
}
|
703
741
|
const uiDefinitionProperties = Object.assign(Object.assign({}, ((_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {})), ((_c = this.runtimeService.uiDefinitionProperties) !== null && _c !== void 0 ? _c : {}));
|
704
|
-
|
705
|
-
|
742
|
+
let lineItem = this.configurableRamp;
|
743
|
+
if (!lineItem) {
|
744
|
+
const { initializationProps } = (_d = this.runtimeService) !== null && _d !== void 0 ? _d : {};
|
745
|
+
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
|
746
|
+
// Set default attributes
|
747
|
+
if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
|
748
|
+
const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
|
749
|
+
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
750
|
+
}
|
751
|
+
}
|
706
752
|
const configurationRequest = this.createRequest(lineItem);
|
707
|
-
const mainPricingEnabled = (
|
753
|
+
const mainPricingEnabled = (_e = runtimeContext.properties) === null || _e === void 0 ? void 0 : _e.PricingEnabled;
|
708
754
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
709
755
|
return this.configurationApiService
|
710
756
|
.configureLineItem({ configurationRequest, runtimeModel, pricingEnabled })
|
@@ -719,12 +765,26 @@ class ConfigurationService {
|
|
719
765
|
}))
|
720
766
|
.pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })));
|
721
767
|
}
|
722
|
-
configureExternal$(
|
723
|
-
return this.runtimeService
|
768
|
+
configureExternal$(props) {
|
769
|
+
return this.runtimeService
|
770
|
+
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
771
|
+
.pipe(switchMap(() => this.configure()), first(), catchError(error => {
|
724
772
|
this.messageService.add({ severity: ToastType.error, summary: error });
|
725
773
|
throw error;
|
726
774
|
}), finalize(() => this.reset()));
|
727
775
|
}
|
776
|
+
configureGuidedSelling$(data) {
|
777
|
+
return this.configurationApiService
|
778
|
+
.configureLineItem({
|
779
|
+
configurationRequest: getGuidedSellingConfigurationRequest(data),
|
780
|
+
})
|
781
|
+
.pipe(catchError(error => {
|
782
|
+
if (error instanceof HttpErrorResponse) {
|
783
|
+
this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
|
784
|
+
}
|
785
|
+
throw error;
|
786
|
+
}));
|
787
|
+
}
|
728
788
|
createRequest(lineItem) {
|
729
789
|
var _a;
|
730
790
|
let request = {
|
@@ -982,16 +1042,16 @@ class FlowConfigurationService {
|
|
982
1042
|
const updatedState = [...quoteDraft.currentState, term];
|
983
1043
|
return of([]).pipe(switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
984
1044
|
}
|
985
|
-
addToCart$(
|
1045
|
+
addToCart$(props) {
|
986
1046
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
987
1047
|
if (!quoteDraft) {
|
988
1048
|
return of(null);
|
989
1049
|
}
|
990
|
-
return this.configurationService.configureExternal$(
|
991
|
-
var _a, _b;
|
1050
|
+
return this.configurationService.configureExternal$(props).pipe(map$2(lineItem => {
|
1051
|
+
var _a, _b, _c;
|
992
1052
|
const model = this.configurationService.getRuntimeModel();
|
993
1053
|
const split = (_b = (_a = model === null || model === void 0 ? void 0 : model.types.find(type => type.name === lineItem.type)) === null || _a === void 0 ? void 0 : _a.split) !== null && _b !== void 0 ? _b : false;
|
994
|
-
const lineItems = multiplyLineItems(lineItem, qty !== null &&
|
1054
|
+
const lineItems = multiplyLineItems(lineItem, (_c = props.qty) !== null && _c !== void 0 ? _c : 1, split);
|
995
1055
|
return [...quoteDraft.currentState, ...lineItems];
|
996
1056
|
}), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
997
1057
|
}
|
@@ -1506,5 +1566,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
1506
1566
|
* Generated bundle index. Do not edit.
|
1507
1567
|
*/
|
1508
1568
|
|
1509
|
-
export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
1569
|
+
export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
1510
1570
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|