@veloceapps/sdk 8.0.0-101 → 8.0.0-103

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/cms/utils/index.d.ts +1 -0
  2. package/core/services/flow-info.service.d.ts +4 -2
  3. package/core/services/flow-state.service.d.ts +6 -3
  4. package/core/types/flow-customization.types.d.ts +22 -0
  5. package/core/types/index.d.ts +1 -0
  6. package/esm2020/cms/utils/elements-resolver.mjs +8 -2
  7. package/esm2020/cms/utils/index.mjs +2 -1
  8. package/esm2020/core/services/flow-info.service.mjs +20 -8
  9. package/esm2020/core/services/flow-state.service.mjs +32 -11
  10. package/esm2020/core/types/flow-customization.types.mjs +3 -0
  11. package/esm2020/core/types/index.mjs +2 -1
  12. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +14 -25
  13. package/esm2020/src/components/flow-header/flow-header.component.mjs +16 -26
  14. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +16 -26
  15. package/esm2020/src/pages/assets/assets.component.mjs +20 -29
  16. package/esm2020/src/pages/catalog/catalog.component.mjs +20 -28
  17. package/esm2020/src/pages/product/product.component.mjs +2 -3
  18. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +21 -29
  19. package/esm2020/src/types/index.mjs +1 -2
  20. package/fesm2015/veloceapps-sdk-cms.mjs +8 -2
  21. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  22. package/fesm2015/veloceapps-sdk-core.mjs +60 -20
  23. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  24. package/fesm2015/veloceapps-sdk.mjs +92 -171
  25. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  26. package/fesm2020/veloceapps-sdk-cms.mjs +8 -2
  27. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  28. package/fesm2020/veloceapps-sdk-core.mjs +69 -37
  29. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  30. package/fesm2020/veloceapps-sdk.mjs +92 -171
  31. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  32. package/package.json +5 -3
  33. package/src/components/doc-gen/doc-gen.component.d.ts +3 -5
  34. package/src/components/flow-header/flow-header.component.d.ts +3 -5
  35. package/src/components/guided-selling/guided-selling.component.d.ts +3 -5
  36. package/src/pages/assets/assets.component.d.ts +3 -5
  37. package/src/pages/catalog/catalog.component.d.ts +3 -5
  38. package/src/pages/product/product.component.d.ts +1 -2
  39. package/src/pages/shopping-cart/shopping-cart.component.d.ts +3 -5
  40. package/src/types/index.d.ts +0 -1
  41. package/esm2020/src/types/flow-customization.types.mjs +0 -3
  42. package/src/types/flow-customization.types.d.ts +0 -12
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, InjectionToken, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
- import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, EntityUtil, isDefined, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
2
+ import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, ConfigurationProcessorTypes, EntityUtil, isDefined, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
4
4
  import * as i1 from '@veloceapps/api';
5
5
  import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
6
- import { BehaviorSubject, tap as tap$1, switchMap, map as map$1, noop, catchError, throwError, of, Subject, filter as filter$1, zip, combineLatest, forkJoin, shareReplay as shareReplay$1, take as take$1, distinctUntilChanged } from 'rxjs';
6
+ import { BehaviorSubject, tap as tap$1, switchMap, map as map$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, shareReplay as shareReplay$1, take as take$1, distinctUntilChanged } from 'rxjs';
7
7
  import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize, first } from 'rxjs/operators';
8
8
  import { merge, isEmpty, flatten, sortBy, map as map$2, omit, isEqual, uniqBy, transform, cloneDeep, uniq } from 'lodash';
9
9
  import * as i6 from '@veloceapps/components';
@@ -139,6 +139,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
139
139
  args: [{ providedIn: 'root' }]
140
140
  }], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
141
141
 
142
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
143
+
144
+ const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
145
+
146
+ var RuntimeMode;
147
+ (function (RuntimeMode) {
148
+ RuntimeMode[RuntimeMode["TEST"] = 0] = "TEST";
149
+ RuntimeMode[RuntimeMode["PROD"] = 1] = "PROD";
150
+ })(RuntimeMode || (RuntimeMode = {}));
151
+ var RuntimeOperation;
152
+ (function (RuntimeOperation) {
153
+ RuntimeOperation["INIT"] = "INIT";
154
+ RuntimeOperation["UPDATE"] = "UPDATE";
155
+ })(RuntimeOperation || (RuntimeOperation = {}));
156
+ var RuntimeStep;
157
+ (function (RuntimeStep) {
158
+ RuntimeStep["START"] = "START";
159
+ RuntimeStep["UPDATE"] = "UPDATE";
160
+ })(RuntimeStep || (RuntimeStep = {}));
161
+
162
+ const UI_DEFINITION_VERSION = 3;
163
+
142
164
  class FlowInfoService {
143
165
  get flow() {
144
166
  return this.flowSubj$.value;
@@ -146,9 +168,10 @@ class FlowInfoService {
146
168
  set flow(value) {
147
169
  this.flowSubj$.next(value);
148
170
  }
149
- constructor(flowsApiService, templatesApiService) {
171
+ constructor(flowsApiService, templatesApiService, customizationService) {
150
172
  this.flowsApiService = flowsApiService;
151
173
  this.templatesApiService = templatesApiService;
174
+ this.customizationService = customizationService;
152
175
  this.templates = {};
153
176
  this.flowSubj$ = new BehaviorSubject(null);
154
177
  this.flow$ = this.flowSubj$.asObservable();
@@ -169,11 +192,16 @@ class FlowInfoService {
169
192
  if (isEmpty(flow.properties.templates)) {
170
193
  return of(undefined);
171
194
  }
172
- return this.templatesApiService.fetchTemplates$().pipe(map$1(templates => {
195
+ return forkJoin([
196
+ this.templatesApiService.fetchTemplates$(),
197
+ this.customizationService?.getTemplates?.() ?? of([]),
198
+ ]).pipe(map$1(([templates, localTemplates]) => {
173
199
  Object.entries(flow.properties.templates).forEach(([key, name]) => {
174
200
  const type = this.remapTemplateName(key);
175
201
  if (type) {
176
- this.templates[type] = templates.find(template => template.name === name && template.type === type);
202
+ this.templates[type] =
203
+ localTemplates.find(template => template.name === name && template.type === type) ??
204
+ templates.find(template => template.name === name && template.type === type);
177
205
  }
178
206
  });
179
207
  }));
@@ -197,12 +225,17 @@ class FlowInfoService {
197
225
  }
198
226
  }
199
227
  }
200
- FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }], target: i0.ɵɵFactoryTarget.Injectable });
228
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
201
229
  FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, providedIn: 'root' });
202
230
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
203
231
  type: Injectable,
204
232
  args: [{ providedIn: 'root' }]
205
- }], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }]; } });
233
+ }], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
234
+ type: Optional
235
+ }, {
236
+ type: Inject,
237
+ args: [FLOW_CUSTOMIZATION]
238
+ }] }]; } });
206
239
 
207
240
  const findLineItem = (id, lineItems) => {
208
241
  return findLineItemWithComparator(lineItems, (li) => li.id === id);
@@ -717,7 +750,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
717
750
  }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }, { type: IntegrationState }]; } });
718
751
 
719
752
  class FlowStateService {
720
- constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService) {
753
+ constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
721
754
  this.contextService = contextService;
722
755
  this.quoteDraftService = quoteDraftService;
723
756
  this.flowInfoService = flowInfoService;
@@ -726,6 +759,7 @@ class FlowStateService {
726
759
  this.flowStateApiService = flowStateApiService;
727
760
  this.quoteApiService = quoteApiService;
728
761
  this.toastService = toastService;
762
+ this.customizationService = customizationService;
729
763
  this.NOT_INITIALIZED = Symbol();
730
764
  this.stateId$ = new BehaviorSubject(null);
731
765
  this.processors = {};
@@ -889,12 +923,12 @@ class FlowStateService {
889
923
  }));
890
924
  }
891
925
  initStateful$() {
892
- return this.flowStateApiService
893
- .init({
926
+ return this.getLocalProcessors$().pipe(switchMap(processors => this.flowStateApiService.init({
894
927
  quoteId: this.contextService.resolve().headerId,
895
928
  params: this.flowInfoService.params ?? {},
896
- })
897
- .pipe(map$1(({ stateId }) => {
929
+ actionsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
930
+ selectorsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
931
+ })), map$1(({ stateId }) => {
898
932
  this.stateId$.next(stateId);
899
933
  }));
900
934
  }
@@ -977,7 +1011,8 @@ class FlowStateService {
977
1011
  if (!template) {
978
1012
  return;
979
1013
  }
980
- return this.processorsApiService.fetchConfigurationProcessors$(template.id).pipe(tap$1(processors => {
1014
+ const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
1015
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
981
1016
  const processorsMap = processors.reduce((acc, p) => {
982
1017
  acc[p.apiName] = p;
983
1018
  return acc;
@@ -988,6 +1023,18 @@ class FlowStateService {
988
1023
  .filter(isDefined);
989
1024
  return forkJoin(owners$).pipe(map$1(noop));
990
1025
  }
1026
+ getLocalProcessors$() {
1027
+ const processorsPerTemplate$ = Object.values(this.flowInfoService.templates).map(template => this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null));
1028
+ return forkJoin(processorsPerTemplate$).pipe(map$1(processors => {
1029
+ const definedProcessors = processors.filter(isDefined);
1030
+ if (definedProcessors.length) {
1031
+ return flatten(definedProcessors);
1032
+ }
1033
+ else {
1034
+ return null;
1035
+ }
1036
+ }));
1037
+ }
991
1038
  executeActionScript(request, executable) {
992
1039
  const script = this.processors[executable.ownerId]?.[executable.apiName]?.script;
993
1040
  if (!script) {
@@ -1013,12 +1060,17 @@ class FlowStateService {
1013
1060
  });
1014
1061
  }
1015
1062
  }
1016
- FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
1063
+ FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1017
1064
  FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, providedIn: 'root' });
1018
1065
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
1019
1066
  type: Injectable,
1020
1067
  args: [{ providedIn: 'root' }]
1021
- }], ctorParameters: function () { return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }]; } });
1068
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1069
+ type: Optional
1070
+ }, {
1071
+ type: Inject,
1072
+ args: [FLOW_CUSTOMIZATION]
1073
+ }] }]; } });
1022
1074
 
1023
1075
  class RuntimeSettingsService {
1024
1076
  constructor(configurationSettingsApiService) {
@@ -1123,26 +1175,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1123
1175
  args: [{ providedIn: 'root' }]
1124
1176
  }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1125
1177
 
1126
- const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
1127
-
1128
- var RuntimeMode;
1129
- (function (RuntimeMode) {
1130
- RuntimeMode[RuntimeMode["TEST"] = 0] = "TEST";
1131
- RuntimeMode[RuntimeMode["PROD"] = 1] = "PROD";
1132
- })(RuntimeMode || (RuntimeMode = {}));
1133
- var RuntimeOperation;
1134
- (function (RuntimeOperation) {
1135
- RuntimeOperation["INIT"] = "INIT";
1136
- RuntimeOperation["UPDATE"] = "UPDATE";
1137
- })(RuntimeOperation || (RuntimeOperation = {}));
1138
- var RuntimeStep;
1139
- (function (RuntimeStep) {
1140
- RuntimeStep["START"] = "START";
1141
- RuntimeStep["UPDATE"] = "UPDATE";
1142
- })(RuntimeStep || (RuntimeStep = {}));
1143
-
1144
- const UI_DEFINITION_VERSION = 3;
1145
-
1146
1178
  class ConfigurationService {
1147
1179
  constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
1148
1180
  this.quoteDraftService = quoteDraftService;
@@ -2275,5 +2307,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2275
2307
  * Generated bundle index. Do not edit.
2276
2308
  */
2277
2309
 
2278
- export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, 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 };
2310
+ 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 };
2279
2311
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map