@veloceapps/sdk 8.0.0-116 → 8.0.0-118
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/cms/vendor-map.d.ts +2 -1
- package/core/services/flow-state-configuration.service.d.ts +20 -0
- package/core/services/flow-state.service.d.ts +5 -2
- package/core/services/index.d.ts +1 -0
- package/esm2020/cms/vendor-map.mjs +3 -2
- package/esm2020/core/services/flow-state-configuration.service.mjs +53 -0
- package/esm2020/core/services/flow-state.service.mjs +51 -36
- package/esm2020/core/services/index.mjs +2 -1
- package/fesm2015/veloceapps-sdk-cms.mjs +2 -1
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +149 -92
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +2 -1
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +104 -49
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -784,7 +784,7 @@ class FlowStateService {
|
|
|
784
784
|
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.quoteDraftService.quoteDraft$), skip$1(1), switchMap(() => this.executeRequest$({}, true)))
|
|
785
785
|
.subscribe();
|
|
786
786
|
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
|
787
|
-
if (!flow
|
|
787
|
+
if (!flow.properties.stateful) {
|
|
788
788
|
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
|
|
789
789
|
}
|
|
790
790
|
else {
|
|
@@ -792,7 +792,7 @@ class FlowStateService {
|
|
|
792
792
|
cold: true,
|
|
793
793
|
}).pipe(map$1(response => (response.success ? response.result : {})));
|
|
794
794
|
}
|
|
795
|
-
}), shareReplay$1());
|
|
795
|
+
}), filter$1(isDefined), shareReplay$1());
|
|
796
796
|
this.charges$.subscribe();
|
|
797
797
|
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
|
798
798
|
if (!flow.properties.stateful) {
|
|
@@ -803,10 +803,10 @@ class FlowStateService {
|
|
|
803
803
|
cold: true,
|
|
804
804
|
}).pipe(map$1(response => (response.success ? response.result : {})));
|
|
805
805
|
}
|
|
806
|
-
}), shareReplay$1());
|
|
806
|
+
}), filter$1(isDefined), shareReplay$1());
|
|
807
807
|
this.pricePlans$.subscribe();
|
|
808
808
|
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
|
809
|
-
if (!flow
|
|
809
|
+
if (!flow.properties.stateful) {
|
|
810
810
|
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
|
|
811
811
|
}
|
|
812
812
|
else {
|
|
@@ -814,7 +814,7 @@ class FlowStateService {
|
|
|
814
814
|
cold: true,
|
|
815
815
|
}).pipe(map$1(response => (response.success ? response.result : [])));
|
|
816
816
|
}
|
|
817
|
-
}), shareReplay$1());
|
|
817
|
+
}), filter$1(isDefined), shareReplay$1());
|
|
818
818
|
this.activeMetrics$.subscribe();
|
|
819
819
|
}
|
|
820
820
|
init$() {
|
|
@@ -842,6 +842,9 @@ class FlowStateService {
|
|
|
842
842
|
? this._hasStatefulUnsavedChanges
|
|
843
843
|
: this.quoteDraftService.hasUnsavedChanges;
|
|
844
844
|
}
|
|
845
|
+
get stateId() {
|
|
846
|
+
return this.stateId$.value;
|
|
847
|
+
}
|
|
845
848
|
isInitialized$() {
|
|
846
849
|
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
|
847
850
|
}
|
|
@@ -1018,7 +1021,7 @@ class FlowStateService {
|
|
|
1018
1021
|
if (!this.stateId$.value) {
|
|
1019
1022
|
throw 'Stateful session is not initialized';
|
|
1020
1023
|
}
|
|
1021
|
-
return this.flowStateApiService.execute(this.stateId$.value, request).pipe(tap$1(
|
|
1024
|
+
return this.flowStateApiService.execute(this.stateId$.value, request).pipe(tap$1(() => {
|
|
1022
1025
|
if (request.actions?.length) {
|
|
1023
1026
|
this._hasStatefulUnsavedChanges = true;
|
|
1024
1027
|
}
|
|
@@ -1046,38 +1049,50 @@ class FlowStateService {
|
|
|
1046
1049
|
return this.flowConfiguration.calculate$(flowState);
|
|
1047
1050
|
}
|
|
1048
1051
|
executeStateless$(request) {
|
|
1049
|
-
return of(undefined).pipe(switchMap(() => {
|
|
1050
|
-
|
|
1052
|
+
return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
|
|
1053
|
+
/*
|
|
1054
|
+
Skip price calculation in case
|
|
1055
|
+
1. No actions in the request
|
|
1056
|
+
2. Initialization process execution (state not initialized yet)
|
|
1057
|
+
*/
|
|
1058
|
+
if (!request.actions?.length || !this.isInitialized()) {
|
|
1051
1059
|
return of(undefined);
|
|
1052
1060
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
flowState = this.executeActionScript(flowState, action) ?? flowState;
|
|
1056
|
-
});
|
|
1057
|
-
this.quoteDraftService.updateQuoteDraft(flowState);
|
|
1058
|
-
return this.calculate$();
|
|
1059
|
-
}), map$1(() => {
|
|
1060
|
-
if (!this.quoteDraftService.quoteDraft) {
|
|
1061
|
-
throw 'QuoteDraft is not initialized';
|
|
1061
|
+
else {
|
|
1062
|
+
return this.calculate$();
|
|
1062
1063
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}))
|
|
1064
|
+
}), map$1(() => this.executeStatelessSelectors(request)));
|
|
1065
|
+
}
|
|
1066
|
+
executeStatelessActions(request) {
|
|
1067
|
+
if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
let flowState = this.quoteDraftService.quoteDraft;
|
|
1071
|
+
request.actions.forEach(action => {
|
|
1072
|
+
flowState = this.executeActionScript(flowState, action) ?? flowState;
|
|
1073
|
+
});
|
|
1074
|
+
this.quoteDraftService.updateQuoteDraft(flowState);
|
|
1075
|
+
}
|
|
1076
|
+
executeStatelessSelectors(request) {
|
|
1077
|
+
if (!this.quoteDraftService.quoteDraft) {
|
|
1078
|
+
throw 'QuoteDraft is not initialized';
|
|
1079
|
+
}
|
|
1080
|
+
const flowState = this.quoteDraftService.quoteDraft;
|
|
1081
|
+
return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
|
|
1082
|
+
try {
|
|
1083
|
+
result.selectors[key] = {
|
|
1084
|
+
success: true,
|
|
1085
|
+
result: this.executeSelectorScript(flowState, selector),
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
catch (e) {
|
|
1089
|
+
result.selectors[key] = {
|
|
1090
|
+
success: false,
|
|
1091
|
+
errorMessage: String(e),
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
return result;
|
|
1095
|
+
}, { stateId: '', selectors: {} });
|
|
1081
1096
|
}
|
|
1082
1097
|
getFlowSafe() {
|
|
1083
1098
|
if (!this.flowInfoService.flow) {
|
|
@@ -1750,6 +1765,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
1750
1765
|
type: Injectable
|
|
1751
1766
|
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
|
1752
1767
|
|
|
1768
|
+
class FlowConfigurationModule {
|
|
1769
|
+
}
|
|
1770
|
+
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1771
|
+
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule });
|
|
1772
|
+
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
|
|
1773
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
|
1774
|
+
type: NgModule,
|
|
1775
|
+
args: [{
|
|
1776
|
+
imports: [],
|
|
1777
|
+
providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
|
|
1778
|
+
}]
|
|
1779
|
+
}] });
|
|
1780
|
+
|
|
1781
|
+
class FlowStateConfigurationService {
|
|
1782
|
+
constructor(flowStateService, flowInfoService, configurationService, flowConfigurationService, flowStateApiService) {
|
|
1783
|
+
this.flowStateService = flowStateService;
|
|
1784
|
+
this.flowInfoService = flowInfoService;
|
|
1785
|
+
this.configurationService = configurationService;
|
|
1786
|
+
this.flowConfigurationService = flowConfigurationService;
|
|
1787
|
+
this.flowStateApiService = flowStateApiService;
|
|
1788
|
+
this.configurationStateId$ = new BehaviorSubject(null);
|
|
1789
|
+
}
|
|
1790
|
+
get configurationStateId() {
|
|
1791
|
+
return this.configurationStateId$.value;
|
|
1792
|
+
}
|
|
1793
|
+
addToCart$(props) {
|
|
1794
|
+
const stateful = this.flowInfoService.flow?.properties.stateful;
|
|
1795
|
+
if (stateful) {
|
|
1796
|
+
const stateId = this.flowStateService.stateId;
|
|
1797
|
+
if (!stateId) {
|
|
1798
|
+
return of();
|
|
1799
|
+
}
|
|
1800
|
+
return this.configurationService.configureExternal$(props).pipe(switchMap(lineItem => this.flowStateApiService
|
|
1801
|
+
.newConfiguration(stateId, { lineItem })
|
|
1802
|
+
.pipe(tap$1(r => this.configurationStateId$.next(r.stateId)))), switchMap(() => {
|
|
1803
|
+
if (!this.configurationStateId) {
|
|
1804
|
+
return of();
|
|
1805
|
+
}
|
|
1806
|
+
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
|
|
1807
|
+
}));
|
|
1808
|
+
}
|
|
1809
|
+
else {
|
|
1810
|
+
return this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowStateService }, { token: FlowInfoService }, { token: ConfigurationService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1815
|
+
FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, providedIn: 'root' });
|
|
1816
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
|
|
1817
|
+
type: Injectable,
|
|
1818
|
+
args: [{ providedIn: 'root' }]
|
|
1819
|
+
}], ctorParameters: function () { return [{ type: FlowStateService }, { type: FlowInfoService }, { type: ConfigurationService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }]; } });
|
|
1820
|
+
|
|
1753
1821
|
function calculateMetricByMethod(lineItems, metric, method) {
|
|
1754
1822
|
const items = getLineItemsByMethod(lineItems, method);
|
|
1755
1823
|
return items.reduce((acc, li) => {
|
|
@@ -2157,19 +2225,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2157
2225
|
type: Injectable
|
|
2158
2226
|
}], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i6.ToastService }]; } });
|
|
2159
2227
|
|
|
2160
|
-
class FlowConfigurationModule {
|
|
2161
|
-
}
|
|
2162
|
-
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2163
|
-
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule });
|
|
2164
|
-
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
|
|
2165
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
|
2166
|
-
type: NgModule,
|
|
2167
|
-
args: [{
|
|
2168
|
-
imports: [],
|
|
2169
|
-
providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
|
|
2170
|
-
}]
|
|
2171
|
-
}] });
|
|
2172
|
-
|
|
2173
2228
|
class ConfigurationModule {
|
|
2174
2229
|
}
|
|
2175
2230
|
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -2398,5 +2453,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2398
2453
|
* Generated bundle index. Do not edit.
|
|
2399
2454
|
*/
|
|
2400
2455
|
|
|
2401
|
-
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateService, FlowUpdateService, IntegrationState, 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 };
|
|
2456
|
+
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, 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 };
|
|
2402
2457
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|