@veloceapps/sdk 8.0.0-139 → 8.0.0-140
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 +0 -1
- package/core/utils/line-item.utils.d.ts +0 -1
- package/esm2020/core/utils/line-item.utils.mjs +29 -14
- package/fesm2015/veloceapps-sdk-core.mjs +31 -15
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +29 -15
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import * as i1 from '@veloceapps/api';
|
|
|
5
5
|
import { ApiModule } from '@veloceapps/api';
|
|
6
6
|
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, shareReplay as shareReplay$1, finalize, takeUntil, 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 as finalize$1, first } from 'rxjs/operators';
|
|
8
|
-
import { merge, isEmpty, flatten, sortBy, map as map$2, omit, isEqual, cloneDeep, assign, uniqBy, transform, uniq } from 'lodash';
|
|
8
|
+
import { merge, isEmpty, flatten, entries, sortBy, map as map$2, omit, isEqual, cloneDeep, assign, uniqBy, transform, uniq } from 'lodash';
|
|
9
9
|
import * as i6 from '@veloceapps/components';
|
|
10
10
|
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
|
11
11
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
@@ -340,27 +340,42 @@ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false
|
|
|
340
340
|
lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)),
|
|
341
341
|
};
|
|
342
342
|
};
|
|
343
|
-
const
|
|
343
|
+
const collectCardinalityComputations = (portDomains) => {
|
|
344
|
+
const cardinalityComputations = new Map();
|
|
345
|
+
entries(portDomains).forEach(([key, portDomain]) => {
|
|
346
|
+
cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
|
|
347
|
+
});
|
|
348
|
+
return cardinalityComputations;
|
|
349
|
+
};
|
|
350
|
+
const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
|
|
344
351
|
const cardVars = new Map();
|
|
345
352
|
lineItems
|
|
346
353
|
.filter(({ port, type }) => !!port && !!type)
|
|
347
354
|
.forEach(li => {
|
|
348
|
-
|
|
349
|
-
|
|
355
|
+
if (cardinalityComputations.get(`${li.port}`)) {
|
|
356
|
+
const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
|
|
357
|
+
cardVars.set(cardinalityVariableName, (cardVars.get(cardinalityVariableName) ?? 0) + li.qty);
|
|
358
|
+
}
|
|
350
359
|
});
|
|
351
360
|
return cardVars;
|
|
352
361
|
};
|
|
362
|
+
const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
|
|
353
363
|
const recalculateCardinalityVariables = (original, updated) => {
|
|
354
|
-
const
|
|
355
|
-
const
|
|
364
|
+
const cardinalityComputations = collectCardinalityComputations(updated.portDomains ?? original.portDomains ?? {});
|
|
365
|
+
const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
|
|
366
|
+
const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
|
|
356
367
|
originalCardinalityVariables.forEach((value, key) => {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
368
|
+
const execArray = cardinalityRegexp.exec(key);
|
|
369
|
+
const portName = execArray?.groups?.['portName'];
|
|
370
|
+
if (!portName || cardinalityComputations.get(portName)) {
|
|
371
|
+
if (cardinalityVariables.get(key) === value) {
|
|
372
|
+
// no need to update cardinality if no changes
|
|
373
|
+
cardinalityVariables.delete(key);
|
|
374
|
+
}
|
|
375
|
+
else if (!cardinalityVariables.has(key)) {
|
|
376
|
+
// remove last item from port
|
|
377
|
+
cardinalityVariables.set(key, 0);
|
|
378
|
+
}
|
|
364
379
|
}
|
|
365
380
|
});
|
|
366
381
|
return {
|
|
@@ -470,7 +485,6 @@ const filterOutTechnicalAttributes = (attributes) => {
|
|
|
470
485
|
|
|
471
486
|
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
472
487
|
__proto__: null,
|
|
473
|
-
calculateCardinalityVariables: calculateCardinalityVariables,
|
|
474
488
|
filterOutTechnicalAttributes: filterOutTechnicalAttributes,
|
|
475
489
|
findLineItem: findLineItem,
|
|
476
490
|
findLineItemWithComparator: findLineItemWithComparator,
|
|
@@ -2669,5 +2683,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2669
2683
|
* Generated bundle index. Do not edit.
|
|
2670
2684
|
*/
|
|
2671
2685
|
|
|
2672
|
-
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, 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,
|
|
2686
|
+
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, 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, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
|
2673
2687
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|