@veloceapps/sdk 3.1.10 → 3.1.11

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.
@@ -30,10 +30,11 @@
30
30
  var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
31
31
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
32
32
 
33
- var getDefaultLineItem = function (context, uiDefinitionProperties) {
33
+ var getDefaultLineItem = function (context, uiDefinitionProperties, qty) {
34
+ if (qty === void 0) { qty = 1; }
34
35
  var _a, _b, _c;
35
36
  var id = core.UUID.UUID();
36
- var lineItem = Object.assign({ id: id, type: (_a = uiDefinitionProperties.rootType) !== null && _a !== void 0 ? _a : '', cfgStatus: 'Default', actionCode: 'ADD', qty: 1, productName: ((_b = context.properties) === null || _b === void 0 ? void 0 : _b.displayName) || context.productName, productId: (_c = context.productId) !== null && _c !== void 0 ? _c : '' }, (context.offeringId
37
+ var lineItem = Object.assign({ id: id, type: (_a = uiDefinitionProperties.rootType) !== null && _a !== void 0 ? _a : '', cfgStatus: 'Default', actionCode: 'ADD', qty: qty, productName: ((_b = context.properties) === null || _b === void 0 ? void 0 : _b.displayName) || context.productName, productId: (_c = context.productId) !== null && _c !== void 0 ? _c : '' }, (context.offeringId
37
38
  ? { offeringId: context.offeringId, offeringInstanceId: context.offeringInstanceId || id }
38
39
  : {}));
39
40
  return lineItem;
@@ -614,6 +615,7 @@
614
615
  this._isInitialized = false;
615
616
  this._runtimeContext = undefined;
616
617
  this._assets = undefined;
618
+ this.initializationProps = undefined;
617
619
  this.uiDefinitionProperties = {};
618
620
  };
619
621
  ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinition) {
@@ -640,6 +642,7 @@
640
642
  };
641
643
  ConfigurationRuntimeService.prototype.init = function (props) {
642
644
  var _this = this;
645
+ this.initializationProps = props;
643
646
  this._assets = props.assets;
644
647
  var context = this.contextService.resolve();
645
648
  return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(operators.tap(function (runtimeContext) {
@@ -851,7 +854,8 @@
851
854
  }());
852
855
 
853
856
  var ConfigurationService = /** @class */ (function () {
854
- function ConfigurationService(runtimeService, contextService, configurationApiService, messageService, dialogService) {
857
+ function ConfigurationService(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
858
+ this.quoteDraftService = quoteDraftService;
855
859
  this.runtimeService = runtimeService;
856
860
  this.contextService = contextService;
857
861
  this.configurationApiService = configurationApiService;
@@ -941,23 +945,24 @@
941
945
  });
942
946
  ConfigurationService.prototype.configure = function () {
943
947
  var _this = this;
944
- var _a, _b, _c, _d, _e;
948
+ var _a, _b, _c, _d, _e, _f;
945
949
  var runtimeContext = this.getRuntimeContext();
946
950
  var runtimeModel = this.getRuntimeModel();
947
951
  if (!runtimeContext || !runtimeModel) {
948
952
  return rxjs.throwError(function () { return new Error('Runtime context/model not initialized'); });
949
953
  }
950
954
  var 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 : {}));
951
- var lineItem = (_d = this.states.configurableRamp) !== null && _d !== void 0 ? _d : getDefaultLineItem(runtimeContext, uiDefinitionProperties);
955
+ var qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
956
+ var lineItem = (_e = this.states.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
952
957
  var configurationRequest = this.createRequest(lineItem);
953
958
  configurationRequest.lineItems = this.states.currentState || [];
954
959
  configurationRequest.asset = this.states.asset;
955
- var mainPricingEnabled = (_e = runtimeContext.properties) === null || _e === void 0 ? void 0 : _e.PricingEnabled;
960
+ var mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
956
961
  var pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
957
962
  return this.configurationApiService
958
963
  .configureLineItem({ configurationRequest: configurationRequest, runtimeModel: runtimeModel, pricingEnabled: pricingEnabled })
959
- .pipe(operators.map(function (_f) {
960
- var lineItem = _f.lineItem, context = _f.context, charges = _f.charges, deletedLineItems = _f.deletedLineItems;
964
+ .pipe(operators.map(function (_g) {
965
+ var lineItem = _g.lineItem, context = _g.context, charges = _g.charges, deletedLineItems = _g.deletedLineItems;
961
966
  _this.contextService.update(context !== null && context !== void 0 ? context : {});
962
967
  _this.charges.next(charges !== null && charges !== void 0 ? charges : {});
963
968
  if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
@@ -967,6 +972,17 @@
967
972
  }))
968
973
  .pipe(operators.tap(function (lineItem) { return lineItem && _this.lineItem.next(lineItem); }), operators.catchError(function (error) { return rxjs.throwError(function () { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); }); }));
969
974
  };
975
+ ConfigurationService.prototype.configureExternal$ = function (productId, qty) {
976
+ var _this = this;
977
+ // TODO: uncomment when procedure issue is fixed on backend side
978
+ // this.updateCurrentStates({
979
+ // currentState: this.quoteDraftService.quoteSnapshot?.currentState ?? [],
980
+ // });
981
+ return this.runtimeService.init({ productId: productId, defaultQty: qty }).pipe(operators.switchMap(function () { return _this.configure(); }), operators.first(), operators.catchError(function (error) {
982
+ _this.messageService.add({ severity: components.ToastType.error, summary: error });
983
+ throw error;
984
+ }), operators.finalize(function () { return _this.reset(); }));
985
+ };
970
986
  ConfigurationService.prototype.createRequest = function (lineItem) {
971
987
  return {
972
988
  lineItem: lineItem,
@@ -1004,11 +1020,11 @@
1004
1020
  };
1005
1021
  return ConfigurationService;
1006
1022
  }());
1007
- ConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationService, deps: [{ token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1__namespace.ConfigurationApiService }, { token: i2__namespace.MessageService }, { token: i5__namespace.DialogService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1023
+ ConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1__namespace.ConfigurationApiService }, { token: i2__namespace.MessageService }, { token: i5__namespace.DialogService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1008
1024
  ConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationService });
1009
1025
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationService, decorators: [{
1010
1026
  type: i0.Injectable
1011
- }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type: i2__namespace.MessageService }, { type: i5__namespace.DialogService }]; } });
1027
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type: i2__namespace.MessageService }, { type: i5__namespace.DialogService }]; } });
1012
1028
 
1013
1029
  var FlowUpdateService = /** @class */ (function () {
1014
1030
  function FlowUpdateService() {
@@ -1130,12 +1146,13 @@
1130
1146
  }] });
1131
1147
 
1132
1148
  var FlowConfigurationService = /** @class */ (function () {
1133
- function FlowConfigurationService(priceApiService, contextService, quoteDraftService, messageService, updateService) {
1149
+ function FlowConfigurationService(priceApiService, contextService, quoteDraftService, messageService, updateService, configurationService) {
1134
1150
  this.priceApiService = priceApiService;
1135
1151
  this.contextService = contextService;
1136
1152
  this.quoteDraftService = quoteDraftService;
1137
1153
  this.messageService = messageService;
1138
1154
  this.updateService = updateService;
1155
+ this.configurationService = configurationService;
1139
1156
  this.charges = new rxjs.BehaviorSubject({});
1140
1157
  this.bounceBackUpdate$ = new rxjs.BehaviorSubject(true);
1141
1158
  }
@@ -1184,6 +1201,14 @@
1184
1201
  return quoteDraft.currentState;
1185
1202
  }), rxjs.shareReplay());
1186
1203
  };
1204
+ FlowConfigurationService.prototype.addToCart$ = function (productId, qty) {
1205
+ var _this = this;
1206
+ return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.tap(function (lineItem) {
1207
+ var _a, _b;
1208
+ var currentState = (_b = (_a = _this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
1209
+ _this.quoteDraftService.setCurrentLineItemState(__spreadArray(__spreadArray([], __read(currentState)), [lineItem]));
1210
+ }), rxjs.map(rxjs.noop));
1211
+ };
1187
1212
  FlowConfigurationService.prototype.getSnapshot = function () {
1188
1213
  var _a, _b;
1189
1214
  return (_b = (_a = this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
@@ -1230,11 +1255,11 @@
1230
1255
  };
1231
1256
  return FlowConfigurationService;
1232
1257
  }());
1233
- FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.PriceApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: i2__namespace.MessageService }, { token: FlowUpdateService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1258
+ FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.PriceApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: i2__namespace.MessageService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1234
1259
  FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService });
1235
1260
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
1236
1261
  type: i0.Injectable
1237
- }], ctorParameters: function () { return [{ type: i1__namespace.PriceApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: i2__namespace.MessageService }, { type: FlowUpdateService }]; } });
1262
+ }], ctorParameters: function () { return [{ type: i1__namespace.PriceApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: i2__namespace.MessageService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1238
1263
 
1239
1264
  var FlowConfigurationModule = /** @class */ (function () {
1240
1265
  function FlowConfigurationModule() {