@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 { Injectable, InjectionToken, 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 * as i1 from '@veloceapps/api';
|
5
5
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
6
6
|
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';
|
7
7
|
import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
|
8
|
-
import { merge, isEqual, flatten, sortBy, map as map$1, omit, cloneDeep, uniq } from 'lodash';
|
8
|
+
import { merge, isEqual, flatten, sortBy, map as map$1, 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,17 +17,50 @@ import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
|
|
16
17
|
|
17
18
|
const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
|
18
19
|
const id = UUID.UUID();
|
20
|
+
const attributes = [];
|
21
|
+
const lineItems = [];
|
19
22
|
return {
|
20
23
|
id,
|
21
24
|
type: uiDefinitionProperties.rootType ?? '',
|
22
25
|
cfgStatus: 'Default',
|
23
26
|
actionCode: 'ADD',
|
24
27
|
qty,
|
28
|
+
attributes,
|
29
|
+
lineItems,
|
25
30
|
productName: context.properties?.['displayName'] || context.productName,
|
26
31
|
productId: context.productId ?? '',
|
27
32
|
...(uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}),
|
28
33
|
};
|
29
34
|
};
|
35
|
+
const getGuidedSellingConfigurationRequest = (data) => {
|
36
|
+
return {
|
37
|
+
mode: 'SEARCH',
|
38
|
+
step: 'START',
|
39
|
+
attributeDomainMode: 'ALL',
|
40
|
+
context: {
|
41
|
+
headerId: 'TestId',
|
42
|
+
mode: ConfigurationContextMode.TEST,
|
43
|
+
properties: {
|
44
|
+
ModelId: data.modelId,
|
45
|
+
Name: 'Veloce Guided Selling',
|
46
|
+
PricingEnabled: 'false',
|
47
|
+
RuntimeMode: 'TEST',
|
48
|
+
},
|
49
|
+
},
|
50
|
+
lineItem: {
|
51
|
+
actionCode: 'ADD',
|
52
|
+
cfgStatus: 'Default',
|
53
|
+
id: UUID.UUID(),
|
54
|
+
qty: 1,
|
55
|
+
type: data.modelType,
|
56
|
+
attributes: Object.entries(data.attributesMap).map(([name, value]) => ({
|
57
|
+
name,
|
58
|
+
value,
|
59
|
+
cfgStatus: 'User',
|
60
|
+
})),
|
61
|
+
},
|
62
|
+
};
|
63
|
+
};
|
30
64
|
|
31
65
|
class ContextService {
|
32
66
|
constructor(contextApiService) {
|
@@ -635,8 +669,11 @@ const multiplyLineItems = (lineItem, qty, split) => {
|
|
635
669
|
];
|
636
670
|
}
|
637
671
|
};
|
672
|
+
const isTechnicalAttribute = (name) => {
|
673
|
+
return name.startsWith('#') || name.startsWith('$');
|
674
|
+
};
|
638
675
|
const filterOutTechnicalAttributes = (attributes) => {
|
639
|
-
return attributes.filter(({ name }) => !
|
676
|
+
return attributes.filter(({ name }) => !isTechnicalAttribute(name));
|
640
677
|
};
|
641
678
|
|
642
679
|
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
@@ -653,6 +690,7 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
653
690
|
getRecommendedPrices: getRecommendedPrices,
|
654
691
|
insertLineItem: insertLineItem,
|
655
692
|
isLineItemModified: isLineItemModified,
|
693
|
+
isTechnicalAttribute: isTechnicalAttribute,
|
656
694
|
mapAttributes: mapAttributes,
|
657
695
|
multiplyLineItems: multiplyLineItems,
|
658
696
|
patchAttributes: patchAttributes,
|
@@ -768,8 +806,16 @@ class ConfigurationService {
|
|
768
806
|
...(runtimeContext.uiDefinition?.properties ?? {}),
|
769
807
|
...(this.runtimeService.uiDefinitionProperties ?? {}),
|
770
808
|
};
|
771
|
-
|
772
|
-
|
809
|
+
let lineItem = this.configurableRamp;
|
810
|
+
if (!lineItem) {
|
811
|
+
const { initializationProps } = this.runtimeService ?? {};
|
812
|
+
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
|
813
|
+
// Set default attributes
|
814
|
+
if (initializationProps?.attributesMap) {
|
815
|
+
const attributes = transform(initializationProps?.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
|
816
|
+
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
817
|
+
}
|
818
|
+
}
|
773
819
|
const configurationRequest = this.createRequest(lineItem);
|
774
820
|
const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
|
775
821
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
@@ -786,12 +832,26 @@ class ConfigurationService {
|
|
786
832
|
}))
|
787
833
|
.pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError(error => throwError(() => new Error(error.error?.message || error.message || JSON.stringify(error)))));
|
788
834
|
}
|
789
|
-
configureExternal$(
|
790
|
-
return this.runtimeService
|
835
|
+
configureExternal$(props) {
|
836
|
+
return this.runtimeService
|
837
|
+
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
838
|
+
.pipe(switchMap(() => this.configure()), first(), catchError(error => {
|
791
839
|
this.messageService.add({ severity: ToastType.error, summary: error });
|
792
840
|
throw error;
|
793
841
|
}), finalize(() => this.reset()));
|
794
842
|
}
|
843
|
+
configureGuidedSelling$(data) {
|
844
|
+
return this.configurationApiService
|
845
|
+
.configureLineItem({
|
846
|
+
configurationRequest: getGuidedSellingConfigurationRequest(data),
|
847
|
+
})
|
848
|
+
.pipe(catchError(error => {
|
849
|
+
if (error instanceof HttpErrorResponse) {
|
850
|
+
this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
|
851
|
+
}
|
852
|
+
throw error;
|
853
|
+
}));
|
854
|
+
}
|
795
855
|
createRequest(lineItem) {
|
796
856
|
let request = {
|
797
857
|
lineItem,
|
@@ -1047,15 +1107,15 @@ class FlowConfigurationService {
|
|
1047
1107
|
const updatedState = [...quoteDraft.currentState, term];
|
1048
1108
|
return of([]).pipe(switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
1049
1109
|
}
|
1050
|
-
addToCart$(
|
1110
|
+
addToCart$(props) {
|
1051
1111
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1052
1112
|
if (!quoteDraft) {
|
1053
1113
|
return of(null);
|
1054
1114
|
}
|
1055
|
-
return this.configurationService.configureExternal$(
|
1115
|
+
return this.configurationService.configureExternal$(props).pipe(map$2(lineItem => {
|
1056
1116
|
const model = this.configurationService.getRuntimeModel();
|
1057
1117
|
const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
|
1058
|
-
const lineItems = multiplyLineItems(lineItem, qty ?? 1, split);
|
1118
|
+
const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
|
1059
1119
|
return [...quoteDraft.currentState, ...lineItems];
|
1060
1120
|
}), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
1061
1121
|
}
|
@@ -1556,5 +1616,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
1556
1616
|
* Generated bundle index. Do not edit.
|
1557
1617
|
*/
|
1558
1618
|
|
1559
|
-
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 };
|
1619
|
+
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 };
|
1560
1620
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|