@veloceapps/sdk 7.0.2-3 → 7.0.2-31
Sign up to get free protection for your applications and to get access to all the features.
- package/cms/cms.actions.d.ts +30 -1
- package/cms/components/element-children/element-children.component.d.ts +3 -1
- package/cms/components/element-tools-panel/element-tools-panel.component.d.ts +14 -0
- package/cms/components/preview/preview.component.d.ts +1 -0
- package/cms/components/preview/preview.module.d.ts +2 -1
- package/cms/components/preview/preview.types.d.ts +4 -0
- package/cms/injection-tokens.d.ts +1 -3
- package/cms/modules/runtime/index.d.ts +1 -0
- package/cms/modules/runtime/services/compilation.service.d.ts +2 -1
- package/cms/modules/runtime/services/runtime-editor.service.d.ts +6 -4
- package/cms/modules/runtime/services/runtime.service.d.ts +5 -1
- package/cms/modules/runtime/types/runtime.actions.d.ts +5 -2
- package/cms/plugins/element-hover.plugin.d.ts +32 -0
- package/cms/plugins/page.plugin.d.ts +15 -0
- package/cms/plugins/script.plugin.d.ts +0 -3
- package/cms/types/common.types.d.ts +11 -1
- package/cms/types/index.d.ts +2 -0
- package/cms/types/layouts.types.d.ts +28 -2
- package/cms/types/pages.types.d.ts +1 -0
- package/cms/utils/elements-resolver.d.ts +5 -1
- package/cms/utils/script.utils.d.ts +2 -0
- package/cms/vendor-map.d.ts +9 -6
- package/core/modules/configuration/services/configuration.service.d.ts +3 -3
- package/core/services/index.d.ts +1 -0
- package/core/services/runtime-settings.service.d.ts +18 -0
- package/core/types/ui-definition.types.d.ts +7 -2
- package/core/utils/line-item.utils.d.ts +4 -2
- package/core/utils/line-item.worker.d.ts +2 -2
- package/esm2020/cms/cms.actions.mjs +42 -2
- package/esm2020/cms/cms.elements.mjs +16 -4
- package/esm2020/cms/cms.layouts.mjs +53 -1
- package/esm2020/cms/components/element-children/element-children.component.mjs +11 -6
- package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +2 -2
- package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +35 -0
- package/esm2020/cms/components/preview/preview.component.mjs +11 -7
- package/esm2020/cms/components/preview/preview.module.mjs +22 -4
- package/esm2020/cms/components/preview/preview.types.mjs +1 -1
- package/esm2020/cms/injection-tokens.mjs +1 -2
- package/esm2020/cms/modules/runtime/index.mjs +2 -1
- package/esm2020/cms/modules/runtime/services/compilation.service.mjs +3 -3
- package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +5 -3
- package/esm2020/cms/modules/runtime/services/runtime.service.mjs +39 -5
- package/esm2020/cms/modules/runtime/types/runtime.actions.mjs +1 -1
- package/esm2020/cms/plugins/element-hover.plugin.mjs +112 -0
- package/esm2020/cms/plugins/page.plugin.mjs +37 -0
- package/esm2020/cms/plugins/script.plugin.mjs +6 -40
- package/esm2020/cms/services/integration.state.mjs +3 -6
- package/esm2020/cms/services/io-provider.service.mjs +7 -5
- package/esm2020/cms/types/common.types.mjs +1 -1
- package/esm2020/cms/types/index.mjs +3 -1
- package/esm2020/cms/types/layouts.types.mjs +70 -1
- package/esm2020/cms/types/pages.types.mjs +2 -0
- package/esm2020/cms/utils/elements-resolver.mjs +22 -8
- package/esm2020/cms/utils/script.utils.mjs +42 -0
- package/esm2020/cms/vendor-map.mjs +5 -3
- package/esm2020/core/core.module.mjs +16 -4
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +6 -5
- package/esm2020/core/services/index.mjs +2 -1
- package/esm2020/core/services/runtime-settings.service.mjs +62 -0
- package/esm2020/core/types/ui-definition.types.mjs +1 -1
- package/esm2020/core/utils/line-item.utils.mjs +35 -16
- package/esm2020/core/utils/line-item.worker.mjs +5 -5
- package/esm2020/src/components/header/header.component.mjs +15 -3
- package/esm2020/src/components/header/metrics/metrics.component.mjs +9 -7
- package/esm2020/src/flow-routing.module.mjs +1 -1
- package/esm2020/src/guards/context.guard.mjs +11 -8
- package/fesm2015/veloceapps-sdk-cms.mjs +497 -150
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +117 -27
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +31 -13
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +578 -164
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +117 -27
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +30 -13
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/header/metrics/metrics.component.d.ts +4 -2
- package/src/guards/context.guard.d.ts +3 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, NgModule } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContext, RuntimeModel, ConfigurationContextMode, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils } from '@veloceapps/core';
|
3
|
+
import { UUID, ConfigurationContext, RuntimeModel, ConfigurationContextMode, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, parseJsonSafely } from '@veloceapps/core';
|
4
4
|
import * as i1 from '@veloceapps/api';
|
5
5
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
6
6
|
import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, tap as tap$1, map as map$2, of, switchMap as switchMap$1, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
|
@@ -503,18 +503,25 @@ const removeLineItem = (lineItem, idToRemove) => {
|
|
503
503
|
.filter(r => !!r),
|
504
504
|
};
|
505
505
|
};
|
506
|
-
const replaceLineItem = (lineItem, replaceTo) => {
|
506
|
+
const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
|
507
507
|
if (lineItem.id === replaceTo.id) {
|
508
|
-
|
508
|
+
if (!skipCardinalityCalculation) {
|
509
|
+
return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
|
510
|
+
}
|
511
|
+
else {
|
512
|
+
return { ...replaceTo };
|
513
|
+
}
|
509
514
|
}
|
510
515
|
return {
|
511
516
|
...lineItem,
|
512
|
-
lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo)),
|
517
|
+
lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)),
|
513
518
|
};
|
514
519
|
};
|
515
520
|
const calculateCardinalityVariables = (lineItems) => {
|
516
521
|
const cardVars = new Map();
|
517
|
-
lineItems
|
522
|
+
lineItems
|
523
|
+
.filter(({ port, type }) => !!port && !!type)
|
524
|
+
.forEach(li => {
|
518
525
|
const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
|
519
526
|
cardVars.set(cardinalityVariableName, (cardVars.get(cardinalityVariableName) ?? 0) + li.qty);
|
520
527
|
});
|
@@ -554,13 +561,13 @@ const upsertAttributes = (originalAttributes, attributesToUpsert) => {
|
|
554
561
|
];
|
555
562
|
}, originalAttributes);
|
556
563
|
};
|
557
|
-
const patchAttributes = (rootLineItem, id, attrs) => {
|
564
|
+
const patchAttributes = (rootLineItem, id, attrs, skipCardinalityCalculation = false) => {
|
558
565
|
const lineItem = findLineItem(id, [rootLineItem]);
|
559
566
|
if (!lineItem) {
|
560
567
|
return rootLineItem;
|
561
568
|
}
|
562
569
|
const attributes = upsertAttributes(lineItem.attributes, attrs);
|
563
|
-
return replaceLineItem(rootLineItem, { ...lineItem, attributes });
|
570
|
+
return replaceLineItem(rootLineItem, { ...lineItem, attributes }, skipCardinalityCalculation);
|
564
571
|
};
|
565
572
|
const getAttributeValue = (attributes, name) => attributes.find(attr => attr.name === name)?.value;
|
566
573
|
const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
|
@@ -588,19 +595,31 @@ const getRecommendedPrices = (portDomain, type) => {
|
|
588
595
|
};
|
589
596
|
const generateModifiedAssetsMap = (lineItems) => {
|
590
597
|
return lineItems.reduce((acc, li) => {
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
}
|
598
|
+
const isModified = isLineItemModified(li);
|
599
|
+
if (!isModified) {
|
600
|
+
return acc;
|
601
|
+
}
|
602
|
+
const target = getOriginParent(lineItems, li);
|
603
|
+
const id = target?.assetId ?? target?.openOrderLineItemId;
|
604
|
+
if (id) {
|
605
|
+
acc[id] = true;
|
600
606
|
}
|
601
607
|
return acc;
|
602
608
|
}, {});
|
603
609
|
};
|
610
|
+
const getOriginParent = (lineItems, currentLineItem) => {
|
611
|
+
let target = currentLineItem;
|
612
|
+
while (target && target.rampInstanceId) {
|
613
|
+
target = lineItems.find(sub => sub.id === currentLineItem.rampInstanceId);
|
614
|
+
}
|
615
|
+
return target;
|
616
|
+
};
|
617
|
+
const isLineItemModified = (lineItem) => {
|
618
|
+
if (lineItem.actionCode === 'EXIST' && lineItem.status === 'PENDING') {
|
619
|
+
return false;
|
620
|
+
}
|
621
|
+
return lineItem.actionCode !== 'EXIST';
|
622
|
+
};
|
604
623
|
const multiplyLineItems = (lineItem, qty, split) => {
|
605
624
|
if (split) {
|
606
625
|
const unifyIds = (lineItem) => ({
|
@@ -629,8 +648,10 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
629
648
|
generateModifiedAssetsMap: generateModifiedAssetsMap,
|
630
649
|
getAttributeValue: getAttributeValue,
|
631
650
|
getAttributes: getAttributes,
|
651
|
+
getOriginParent: getOriginParent,
|
632
652
|
getRecommendedPrices: getRecommendedPrices,
|
633
653
|
insertLineItem: insertLineItem,
|
654
|
+
isLineItemModified: isLineItemModified,
|
634
655
|
mapAttributes: mapAttributes,
|
635
656
|
multiplyLineItems: multiplyLineItems,
|
636
657
|
patchAttributes: patchAttributes,
|
@@ -650,11 +671,11 @@ class LineItemWorker {
|
|
650
671
|
remove(id) {
|
651
672
|
return new LineItemWorker(removeLineItem(this.li, id));
|
652
673
|
}
|
653
|
-
replace(toReplace) {
|
654
|
-
return new LineItemWorker(replaceLineItem(this.li, toReplace));
|
674
|
+
replace(toReplace, skipCardinalityCalculation = false) {
|
675
|
+
return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
|
655
676
|
}
|
656
|
-
patchAttribute(attrs, id) {
|
657
|
-
return new LineItemWorker(patchAttributes(this.li, id ?? this.li.id, attrs));
|
677
|
+
patchAttribute(attrs, id, skipCardinalityCalculation = false) {
|
678
|
+
return new LineItemWorker(patchAttributes(this.li, id ?? this.li.id, attrs, skipCardinalityCalculation));
|
658
679
|
}
|
659
680
|
}
|
660
681
|
|
@@ -680,11 +701,12 @@ class ConfigurationService {
|
|
680
701
|
this.charges.next({});
|
681
702
|
this.pricePlans.next({});
|
682
703
|
}
|
683
|
-
patch$(lineItem) {
|
704
|
+
patch$(lineItem, options) {
|
684
705
|
if (!this.lineItem.value) {
|
685
706
|
return throwError(() => new Error(`Source LineItem not found`));
|
686
707
|
}
|
687
|
-
|
708
|
+
const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
|
709
|
+
this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
|
688
710
|
return this.configure().pipe(catchError(error => {
|
689
711
|
console.error(error);
|
690
712
|
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
@@ -699,8 +721,8 @@ class ConfigurationService {
|
|
699
721
|
}
|
700
722
|
}));
|
701
723
|
}
|
702
|
-
patch(lineItem) {
|
703
|
-
this.patch$(lineItem).subscribe();
|
724
|
+
patch(lineItem, options) {
|
725
|
+
this.patch$(lineItem, options).subscribe();
|
704
726
|
}
|
705
727
|
setConfigurableRamp(lineItem) {
|
706
728
|
this.configurableRamp = lineItem;
|
@@ -1268,16 +1290,84 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
1268
1290
|
args: [{ providedIn: 'root' }]
|
1269
1291
|
}], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
|
1270
1292
|
|
1293
|
+
class RuntimeSettingsService {
|
1294
|
+
constructor(configurationSettingsApiService) {
|
1295
|
+
this.configurationSettingsApiService = configurationSettingsApiService;
|
1296
|
+
this.configurationSettings$ = new BehaviorSubject({});
|
1297
|
+
this.currencySettings$ = new BehaviorSubject({
|
1298
|
+
iso: 'USD',
|
1299
|
+
symbol: '$',
|
1300
|
+
});
|
1301
|
+
this.getCurrencySymbol = (locale, currency) => {
|
1302
|
+
return (0)
|
1303
|
+
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
1304
|
+
.replace(/\d/g, '')
|
1305
|
+
.trim();
|
1306
|
+
};
|
1307
|
+
}
|
1308
|
+
create() {
|
1309
|
+
return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => this.configurationSettings$.next(configurationSettings)), map$2(() => undefined));
|
1310
|
+
}
|
1311
|
+
initCurrency(iso) {
|
1312
|
+
if (iso) {
|
1313
|
+
const symbol = this.getCurrencySymbol('en-US', iso);
|
1314
|
+
this.currencySettings$.next({ iso, symbol });
|
1315
|
+
}
|
1316
|
+
}
|
1317
|
+
getConfigurationSettings() {
|
1318
|
+
return this.configurationSettings$.value;
|
1319
|
+
}
|
1320
|
+
getCurrencySettings() {
|
1321
|
+
return this.currencySettings$.value;
|
1322
|
+
}
|
1323
|
+
parseConfigurationSettings(settings) {
|
1324
|
+
return settings.reduce((acc, setting) => {
|
1325
|
+
switch (setting.key) {
|
1326
|
+
case 'shopping-cart':
|
1327
|
+
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
1328
|
+
break;
|
1329
|
+
case 'navigation':
|
1330
|
+
acc.navigation = parseJsonSafely(setting.value, {});
|
1331
|
+
break;
|
1332
|
+
case 'flows':
|
1333
|
+
acc.flows = parseJsonSafely(setting.value, []);
|
1334
|
+
break;
|
1335
|
+
default:
|
1336
|
+
acc[setting.key] = setting.value;
|
1337
|
+
}
|
1338
|
+
return acc;
|
1339
|
+
}, {});
|
1340
|
+
}
|
1341
|
+
}
|
1342
|
+
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1343
|
+
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
|
1344
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
1345
|
+
type: Injectable,
|
1346
|
+
args: [{ providedIn: 'root' }]
|
1347
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
1348
|
+
|
1271
1349
|
class SdkCoreModule {
|
1272
1350
|
}
|
1273
1351
|
SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1274
1352
|
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
1275
|
-
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, providers: [
|
1353
|
+
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, providers: [
|
1354
|
+
ContextService,
|
1355
|
+
QuoteDraftService,
|
1356
|
+
ProductImagesService,
|
1357
|
+
MetricsCalculationService,
|
1358
|
+
RuntimeSettingsService,
|
1359
|
+
], imports: [ConfigurationModule, FlowConfigurationModule] });
|
1276
1360
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
|
1277
1361
|
type: NgModule,
|
1278
1362
|
args: [{
|
1279
1363
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
1280
|
-
providers: [
|
1364
|
+
providers: [
|
1365
|
+
ContextService,
|
1366
|
+
QuoteDraftService,
|
1367
|
+
ProductImagesService,
|
1368
|
+
MetricsCalculationService,
|
1369
|
+
RuntimeSettingsService,
|
1370
|
+
],
|
1281
1371
|
}]
|
1282
1372
|
}] });
|
1283
1373
|
|
@@ -1285,5 +1375,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
1285
1375
|
* Generated bundle index. Do not edit.
|
1286
1376
|
*/
|
1287
1377
|
|
1288
|
-
export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getRecommendedPrices, insertLineItem, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
1378
|
+
export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
1289
1379
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|