@veloceapps/sdk 8.0.0-117 → 8.0.0-118

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  }
@@ -1762,6 +1765,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1762
1765
  type: Injectable
1763
1766
  }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1764
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
+
1765
1821
  function calculateMetricByMethod(lineItems, metric, method) {
1766
1822
  const items = getLineItemsByMethod(lineItems, method);
1767
1823
  return items.reduce((acc, li) => {
@@ -2169,19 +2225,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2169
2225
  type: Injectable
2170
2226
  }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i6.ToastService }]; } });
2171
2227
 
2172
- class FlowConfigurationModule {
2173
- }
2174
- FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2175
- FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule });
2176
- FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
2177
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
2178
- type: NgModule,
2179
- args: [{
2180
- imports: [],
2181
- providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
2182
- }]
2183
- }] });
2184
-
2185
2228
  class ConfigurationModule {
2186
2229
  }
2187
2230
  ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -2410,5 +2453,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2410
2453
  * Generated bundle index. Do not edit.
2411
2454
  */
2412
2455
 
2413
- 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 };
2414
2457
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map