@veloceapps/sdk 3.0.15 → 3.1.0

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.
Files changed (192) hide show
  1. package/bundles/veloce-sdk-cms.umd.js +74 -836
  2. package/bundles/veloce-sdk-cms.umd.js.map +1 -1
  3. package/bundles/veloce-sdk-core.umd.js +1269 -0
  4. package/bundles/veloce-sdk-core.umd.js.map +1 -0
  5. package/bundles/veloce-sdk-runtime.umd.js +53 -166
  6. package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
  7. package/bundles/veloce-sdk.umd.js +322 -155
  8. package/bundles/veloce-sdk.umd.js.map +1 -1
  9. package/cms/cms.default.d.ts +1 -1
  10. package/cms/components/element-renderer/element-renderer.component.d.ts +1 -1
  11. package/cms/components/preview/preview.component.d.ts +1 -3
  12. package/cms/decorators/element.decorator.d.ts +2 -2
  13. package/cms/index.d.ts +1 -1
  14. package/cms/injection-tokens.d.ts +1 -1
  15. package/cms/launcher.module.d.ts +2 -3
  16. package/cms/plugins/script.plugin.d.ts +1 -0
  17. package/cms/services/launcher.service.d.ts +1 -1
  18. package/cms/types/common.types.d.ts +4 -9
  19. package/cms/types/configuration.types.d.ts +0 -5
  20. package/cms/types/index.d.ts +1 -2
  21. package/cms/types/path.types.d.ts +11 -0
  22. package/cms/utils/element.utils.d.ts +6 -5
  23. package/cms/utils/elements-resolver.d.ts +2 -1
  24. package/cms/utils/index.d.ts +3 -1
  25. package/cms/utils/path.utils.d.ts +2 -1
  26. package/cms/vendor-map.d.ts +677 -2
  27. package/core/core.module.d.ts +8 -0
  28. package/core/index.d.ts +6 -0
  29. package/{cms → core}/modules/configuration/configuration.module.d.ts +0 -0
  30. package/{cms → core}/modules/configuration/helpers.d.ts +1 -2
  31. package/{cms → core}/modules/configuration/index.d.ts +0 -1
  32. package/{cms → core}/modules/configuration/services/configuration-runtime.service.d.ts +2 -3
  33. package/{cms → core}/modules/configuration/services/configuration.service.d.ts +2 -2
  34. package/{cms → core}/modules/configuration/services/runtime-context.service.d.ts +1 -1
  35. package/{cms → core}/modules/configuration/types/configuration-runtime.types.d.ts +0 -0
  36. package/{cms → core}/modules/flow-configuration/flow-configuration.module.d.ts +0 -0
  37. package/{cms → core}/modules/flow-configuration/index.d.ts +0 -0
  38. package/{cms → core}/modules/flow-configuration/services/flow-configuration.service.d.ts +7 -4
  39. package/{cms → core}/modules/flow-configuration/services/flow-update.service.d.ts +0 -0
  40. package/{cms → core}/modules/flow-configuration/types/update.types.d.ts +0 -0
  41. package/{cms → core}/modules/index.d.ts +0 -0
  42. package/core/package.json +10 -0
  43. package/{runtime → core}/services/context.service.d.ts +0 -0
  44. package/core/services/index.d.ts +2 -0
  45. package/{runtime/services/quote.service.d.ts → core/services/quote-draft.service.d.ts} +11 -6
  46. package/core/types/index.d.ts +3 -0
  47. package/core/types/quote-states.types.d.ts +6 -0
  48. package/{runtime/types/runtime-context.types.d.ts → core/types/runtime.types.d.ts} +4 -5
  49. package/{cms → core}/types/ui-definition.types.d.ts +0 -4
  50. package/core/utils/index.d.ts +2 -0
  51. package/{cms → core}/utils/line-item.utils.d.ts +0 -2
  52. package/{cms/types/line-item.types.d.ts → core/utils/line-item.worker.d.ts} +0 -0
  53. package/core/veloce-sdk-core.d.ts +5 -0
  54. package/esm2015/cms/cms.default.js +1 -1
  55. package/esm2015/cms/components/element-renderer/element-renderer.component.js +3 -3
  56. package/esm2015/cms/components/preview/preview.component.js +9 -10
  57. package/esm2015/cms/decorators/element.decorator.js +1 -1
  58. package/esm2015/cms/index.js +1 -2
  59. package/esm2015/cms/injection-tokens.js +1 -1
  60. package/esm2015/cms/launcher.module.js +5 -6
  61. package/esm2015/cms/plugins/configuration.plugin.js +3 -4
  62. package/esm2015/cms/plugins/script.plugin.js +27 -14
  63. package/esm2015/cms/services/launcher.service.js +1 -1
  64. package/esm2015/cms/types/common.types.js +1 -1
  65. package/esm2015/cms/types/configuration.types.js +1 -1
  66. package/esm2015/cms/types/index.js +2 -3
  67. package/esm2015/cms/types/path.types.js +2 -0
  68. package/esm2015/cms/utils/element.utils.js +1 -1
  69. package/esm2015/cms/utils/elements-resolver.js +1 -1
  70. package/esm2015/cms/utils/index.js +4 -2
  71. package/esm2015/cms/utils/path.utils.js +11 -1
  72. package/esm2015/cms/vendor-map.js +6 -5
  73. package/esm2015/core/core.module.js +18 -0
  74. package/esm2015/core/index.js +7 -0
  75. package/esm2015/core/modules/configuration/configuration.module.js +34 -0
  76. package/esm2015/core/modules/configuration/helpers.js +10 -0
  77. package/esm2015/core/modules/configuration/index.js +5 -0
  78. package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +93 -0
  79. package/esm2015/core/modules/configuration/services/configuration.service.js +147 -0
  80. package/esm2015/core/modules/configuration/services/runtime-context.service.js +61 -0
  81. package/esm2015/core/modules/configuration/types/configuration-runtime.types.js +2 -0
  82. package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +18 -0
  83. package/esm2015/core/modules/flow-configuration/index.js +5 -0
  84. package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +90 -0
  85. package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +114 -0
  86. package/esm2015/core/modules/flow-configuration/types/update.types.js +2 -0
  87. package/esm2015/core/modules/index.js +3 -0
  88. package/esm2015/core/services/context.service.js +41 -0
  89. package/esm2015/core/services/index.js +3 -0
  90. package/esm2015/core/services/quote-draft.service.js +67 -0
  91. package/esm2015/core/types/index.js +4 -0
  92. package/esm2015/core/types/quote-states.types.js +2 -0
  93. package/esm2015/core/types/runtime.types.js +16 -0
  94. package/esm2015/core/types/ui-definition.types.js +2 -0
  95. package/esm2015/core/utils/index.js +3 -0
  96. package/esm2015/core/utils/line-item.utils.js +98 -0
  97. package/esm2015/core/utils/line-item.worker.js +19 -0
  98. package/esm2015/core/veloce-sdk-core.js +5 -0
  99. package/esm2015/runtime/components/component-preview/component-preview.component.js +2 -2
  100. package/esm2015/runtime/components/ui-runtime/runtime.component.js +10 -9
  101. package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +3 -3
  102. package/esm2015/runtime/execution/directives/section-script.directive.js +19 -20
  103. package/esm2015/runtime/execution/directives/velo-port.directive.js +1 -1
  104. package/esm2015/runtime/execution/directives/vl-quote.directive.js +1 -1
  105. package/esm2015/runtime/execution/directives/vl-ramp.directive.js +2 -2
  106. package/esm2015/runtime/execution/runtime-execution.module.js +6 -8
  107. package/esm2015/runtime/runtime.module.js +7 -9
  108. package/esm2015/runtime/services/cart.service.js +5 -6
  109. package/esm2015/runtime/services/configuration.service.js +9 -9
  110. package/esm2015/runtime/services/index.js +1 -3
  111. package/esm2015/runtime/services/runtime-context.service.js +4 -4
  112. package/esm2015/runtime/services/runtime.service.js +3 -3
  113. package/esm2015/runtime/types/index.js +1 -2
  114. package/esm2015/runtime/types/runtime.types.js +1 -1
  115. package/esm2015/src/components/dialog/dialog.component.js +30 -0
  116. package/esm2015/src/components/dialog/dialog.module.js +19 -0
  117. package/esm2015/src/components/dialog/dialog.types.js +2 -0
  118. package/esm2015/src/components/header/cart-overlay/cart-overlay.component.js +2 -2
  119. package/esm2015/src/components/header/header.component.js +51 -11
  120. package/esm2015/src/flow.component.js +2 -2
  121. package/esm2015/src/flow.module.js +33 -6
  122. package/esm2015/src/pages/debug/debug.component.js +14 -16
  123. package/esm2015/src/pages/legacy-product/legacy-product.component.js +12 -11
  124. package/esm2015/src/pages/product/product.component.js +12 -12
  125. package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +1 -1
  126. package/esm2015/src/resolvers/context.resolver.js +2 -2
  127. package/esm2015/src/resolvers/quote.resolver.js +9 -16
  128. package/esm2015/src/services/flow-router.service.js +2 -2
  129. package/esm2015/src/services/fow-dialog.service.js +58 -0
  130. package/esm2015/src/types/flow-customization.types.js +1 -1
  131. package/esm2015/src/utils/flow.utils.js +11 -1
  132. package/fesm2015/veloce-sdk-cms.js +64 -714
  133. package/fesm2015/veloce-sdk-cms.js.map +1 -1
  134. package/fesm2015/veloce-sdk-core.js +785 -0
  135. package/fesm2015/veloce-sdk-core.js.map +1 -0
  136. package/fesm2015/veloce-sdk-runtime.js +48 -144
  137. package/fesm2015/veloce-sdk-runtime.js.map +1 -1
  138. package/fesm2015/veloce-sdk.js +260 -99
  139. package/fesm2015/veloce-sdk.js.map +1 -1
  140. package/package.json +2 -2
  141. package/runtime/components/ui-runtime/runtime.component.d.ts +3 -3
  142. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +1 -1
  143. package/runtime/execution/directives/section-script.directive.d.ts +2 -3
  144. package/runtime/execution/directives/velo-port.directive.d.ts +2 -2
  145. package/runtime/execution/directives/vl-ramp.directive.d.ts +1 -1
  146. package/runtime/execution/runtime-execution.module.d.ts +2 -1
  147. package/runtime/runtime.module.d.ts +2 -1
  148. package/runtime/services/cart.service.d.ts +2 -3
  149. package/runtime/services/configuration.service.d.ts +4 -5
  150. package/runtime/services/index.d.ts +0 -2
  151. package/runtime/services/runtime-context.service.d.ts +3 -3
  152. package/runtime/services/runtime.service.d.ts +5 -6
  153. package/runtime/types/index.d.ts +0 -1
  154. package/runtime/types/runtime.types.d.ts +5 -6
  155. package/src/components/dialog/dialog.component.d.ts +13 -0
  156. package/src/components/dialog/dialog.module.d.ts +9 -0
  157. package/src/components/dialog/dialog.types.d.ts +6 -0
  158. package/src/components/header/cart-overlay/cart-overlay.component.d.ts +1 -1
  159. package/src/components/header/header.component.d.ts +10 -5
  160. package/src/flow.component.d.ts +1 -1
  161. package/src/flow.module.d.ts +3 -1
  162. package/src/pages/debug/debug.component.d.ts +3 -4
  163. package/src/pages/legacy-product/legacy-product.component.d.ts +4 -3
  164. package/src/pages/product/product.component.d.ts +3 -4
  165. package/src/pages/shopping-cart/shopping-cart.component.d.ts +1 -1
  166. package/src/resolvers/context.resolver.d.ts +1 -1
  167. package/src/resolvers/quote.resolver.d.ts +3 -4
  168. package/src/services/flow-router.service.d.ts +1 -1
  169. package/src/services/fow-dialog.service.d.ts +17 -0
  170. package/src/types/flow-customization.types.d.ts +1 -1
  171. package/src/utils/flow.utils.d.ts +2 -0
  172. package/cms/modules/configuration/types/configuration.types.d.ts +0 -15
  173. package/esm2015/cms/modules/configuration/configuration.module.js +0 -37
  174. package/esm2015/cms/modules/configuration/helpers.js +0 -10
  175. package/esm2015/cms/modules/configuration/index.js +0 -6
  176. package/esm2015/cms/modules/configuration/services/configuration-runtime.service.js +0 -93
  177. package/esm2015/cms/modules/configuration/services/configuration.service.js +0 -147
  178. package/esm2015/cms/modules/configuration/services/runtime-context.service.js +0 -61
  179. package/esm2015/cms/modules/configuration/types/configuration-runtime.types.js +0 -2
  180. package/esm2015/cms/modules/configuration/types/configuration.types.js +0 -2
  181. package/esm2015/cms/modules/flow-configuration/flow-configuration.module.js +0 -18
  182. package/esm2015/cms/modules/flow-configuration/index.js +0 -5
  183. package/esm2015/cms/modules/flow-configuration/services/flow-configuration.service.js +0 -83
  184. package/esm2015/cms/modules/flow-configuration/services/flow-update.service.js +0 -114
  185. package/esm2015/cms/modules/flow-configuration/types/update.types.js +0 -2
  186. package/esm2015/cms/modules/index.js +0 -3
  187. package/esm2015/cms/types/line-item.types.js +0 -19
  188. package/esm2015/cms/types/ui-definition.types.js +0 -2
  189. package/esm2015/cms/utils/line-item.utils.js +0 -107
  190. package/esm2015/runtime/services/context.service.js +0 -41
  191. package/esm2015/runtime/services/quote.service.js +0 -53
  192. package/esm2015/runtime/types/runtime-context.types.js +0 -16
@@ -2,28 +2,24 @@ import { __decorate, __param, __awaiter, __rest } from 'tslib';
2
2
  import * as i0 from '@angular/core';
3
3
  import { InjectionToken, Component, ChangeDetectionStrategy, Inject, Injector, Injectable, Directive, ViewContainerRef, SkipSelf, ViewChild, Input, EventEmitter, TemplateRef, Output, NgModule, ViewEncapsulation } from '@angular/core';
4
4
  import * as rxjs from 'rxjs';
5
- import { BehaviorSubject, combineLatest, of, throwError, shareReplay, Subject, takeUntil, map as map$1, tap as tap$1, switchMap, catchError as catchError$1, filter, from, forkJoin } from 'rxjs';
6
- import * as i8 from '@angular/common';
5
+ import { BehaviorSubject, Subject, takeUntil, map, filter, from, tap, of, switchMap, forkJoin, catchError } from 'rxjs';
6
+ import * as lodash from 'lodash';
7
+ import { compact, isArray, pull, flatten, set } from 'lodash';
8
+ import * as i7 from '@angular/common';
7
9
  import { DOCUMENT, CommonModule } from '@angular/common';
8
- import { UUID, RuntimeModel, ConfigurationContextMode, SalesforceIdUtils, ConfigurationMode, CoreModule } from '@veloce/core';
10
+ import { UUID, CoreModule } from '@veloce/core';
9
11
  import { DragDropModule } from '@angular/cdk/drag-drop';
10
12
  import * as angularForms from '@angular/forms';
11
13
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
12
- import * as lodash from 'lodash';
13
- import { compact, flatten, sortBy, isArray, pull, cloneDeep, set } from 'lodash';
14
- import * as i6 from '@veloce/components';
15
- import { ConfirmationComponent, LoaderModule, ConfirmationDialogModule } from '@veloce/components';
16
- import * as i2 from '@veloce/sdk/runtime';
17
- import { RuntimeMode, RuntimeStep, ContextService } from '@veloce/sdk/runtime';
14
+ import * as i2 from '@veloce/sdk/core';
15
+ import { ConfigurationService, LineItemWorker, generateLineItem, getAttributeValue, FlowConfigurationService, lineItemUtils, SdkCoreModule } from '@veloce/sdk/core';
16
+ import { transform } from '@babel/standalone';
17
+ import { SalesforceApiService, QuoteApiService, DocumentTemplatesApiService, DocumentAttachmentApiService, RampApiService, ApiModule } from '@veloce/api';
18
18
  import * as rxjsOperators from 'rxjs/operators';
19
- import { map, first, tap, catchError } from 'rxjs/operators';
20
- import * as i1 from '@veloce/api';
21
- import { PriceApiService, SalesforceApiService, QuoteApiService, DocumentTemplatesApiService, DocumentAttachmentApiService, RampApiService, ContextApiService, ProductModelApiService, ConfigurationApiService, ApiModule } from '@veloce/api';
22
19
  import * as i3 from 'primeng/api';
23
- import * as i5 from 'primeng/dynamicdialog';
20
+ import * as i5 from '@veloce/components';
21
+ import { LoaderModule } from '@veloce/components';
24
22
  import { DialogService } from 'primeng/dynamicdialog';
25
- import { transform } from '@babel/standalone';
26
- import moment from 'moment';
27
23
 
28
24
  const DEFAULT_PLUGINS_TOKEN = new InjectionToken('DEFAULT_PLUGINS_TOKEN');
29
25
  const UI_DEFINITION_METADATA = new InjectionToken('UI_DEFINITION_METADATA_TOKEN');
@@ -85,6 +81,15 @@ ElementComponent = __decorate([
85
81
  __param(0, Inject(Injector))
86
82
  ], ElementComponent);
87
83
 
84
+ const parseBoundPath = (path) => {
85
+ var _a, _b;
86
+ const regexp = new RegExp(`(?:\\/)(?:\\w+)(?:\\/)(?:ports|attributes)(?:\\/)(?:\\w+)|(?:\\/)(?:\\w+)`, 'g');
87
+ const blocks = (_b = (_a = path.match(regexp)) === null || _a === void 0 ? void 0 : _a.map(match => {
88
+ const [type, property, name] = compact(match.split('/'));
89
+ return { type, property, name };
90
+ })) !== null && _b !== void 0 ? _b : [];
91
+ return blocks;
92
+ };
88
93
  const parsePath = (path) => {
89
94
  var _a, _b, _c, _d;
90
95
  const segments = path.split('/');
@@ -268,30 +273,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
268
273
  type: Directive
269
274
  }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
270
275
 
271
- const normalizeImports = (script) => {
272
- const regexp = new RegExp(`import([ \\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)from[ \\n\\t]*(['"])([^'"\\n]+)(?:['"]);`, 'g');
273
- const result = script.replace(regexp, (match, g1, g2, src) => `const ${g1} = vendor['${src}'];`);
274
- return result;
275
- };
276
276
  class ScriptPlugin {
277
277
  constructor(host) {
278
278
  this.host = host;
279
+ this.normalizeImports = (script, elementPath) => {
280
+ const regexp = new RegExp(`import([ \\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)from[ \\n\\t]*(['"])([^'"\\n]+)(?:['"]);`, 'g');
281
+ const result = script.replace(regexp, (match, g1, g2, src) => {
282
+ const imports = g1
283
+ .trim()
284
+ .slice(1, -1)
285
+ .split(',')
286
+ .map(item => item.trim());
287
+ imports.forEach(item => {
288
+ var _a;
289
+ if (!((_a = this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
290
+ throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
291
+ }
292
+ });
293
+ return `const ${g1} = vendor['${src}'];`;
294
+ });
295
+ return result;
296
+ };
279
297
  this.document = this.host.injector.get(DOCUMENT);
280
298
  this.vendorMap = this.host.injector.get(VENDOR_MAP);
281
299
  const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
282
300
  const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
283
- if (sharedElementMetadata === null || sharedElementMetadata === void 0 ? void 0 : sharedElementMetadata.script) {
284
- this.addScript(sharedElementMetadata.script);
285
- }
286
- if (elementMetadata.script) {
287
- this.addScript(elementMetadata.script);
288
- }
301
+ this.addScript(sharedElementMetadata);
302
+ this.addScript(elementMetadata);
289
303
  }
290
- addScript(scriptStr) {
304
+ addScript(metadata) {
305
+ var _a;
306
+ if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
307
+ return;
308
+ }
291
309
  const id = btoa(UUID.UUID());
292
310
  const script = this.document.createElement('script');
293
311
  script.type = `text/javascript`;
294
- let scriptContent = normalizeImports(scriptStr);
312
+ let scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
295
313
  const classMatch = /export class (\S+)/.exec(scriptContent);
296
314
  const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
297
315
  if (!classMatch || !className) {
@@ -496,415 +514,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
496
514
  type: Injectable
497
515
  }] });
498
516
 
499
- const parseBoundPath = (path) => {
500
- var _a, _b;
501
- const regexp = new RegExp(`(?:\\/)(?:\\w+)(?:\\/)(?:ports|attributes)(?:\\/)(?:\\w+)|(?:\\/)(?:\\w+)`, 'g');
502
- const blocks = (_b = (_a = path.match(regexp)) === null || _a === void 0 ? void 0 : _a.map(match => {
503
- const [type, property, name] = compact(match.split('/'));
504
- return { type, property, name };
505
- })) !== null && _b !== void 0 ? _b : [];
506
- return blocks;
507
- };
508
- const findLineItem = (id, lineItems) => {
509
- return findLineItemWithComparator(lineItems, (li) => li.id === id);
510
- };
511
- const findLineItemWithComparator = (lineItems, comparator) => {
512
- let currentLevel = lineItems;
513
- while (currentLevel.length) {
514
- const found = currentLevel.find(comparator);
515
- if (found) {
516
- return found;
517
- }
518
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
519
- }
520
- return;
521
- };
522
- const insertLineItem = (lineItem, parentId, toInsert) => {
523
- const insertData = lineItem.id === parentId ? [toInsert] : [];
524
- return Object.assign(Object.assign({}, lineItem), { lineItems: [
525
- ...insertData,
526
- ...lineItem.lineItems.map(li => {
527
- return insertLineItem(li, parentId, toInsert);
528
- }),
529
- ] });
530
- };
531
- const removeLineItem = (lineItem, idToRemove) => {
532
- return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
533
- .map(li => {
534
- if (li.id === idToRemove) {
535
- return;
536
- }
537
- else if (li.lineItems.length) {
538
- return removeLineItem(li, idToRemove);
539
- }
540
- return li;
541
- })
542
- .filter(r => !!r) });
543
- };
544
- const replaceLineItem = (lineItem, replaceTo) => {
545
- if (lineItem.id === replaceTo.id) {
546
- return Object.assign({}, replaceTo);
547
- }
548
- return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(li => {
549
- if (li.id === replaceTo.id) {
550
- return replaceTo;
551
- }
552
- else if (li.lineItems.length) {
553
- return replaceLineItem(li, replaceTo);
554
- }
555
- return li;
556
- }) });
557
- };
558
- const mapAttributes = (attributes) => {
559
- return attributes.reduce((acc, { name, value }) => (Object.assign(Object.assign({}, acc), { [name]: value })), {});
560
- };
561
- const getAttributes = (attributes, names = []) => {
562
- const filtered = attributes.filter(({ name }) => names.includes(name));
563
- return sortBy(filtered, [({ name }) => names.indexOf(name)]);
564
- };
565
- const upsertAttributes = (originalAttributes, attributesToUpsert) => {
566
- return attributesToUpsert.reduce((acc, { name, value }) => {
567
- const [origAttr] = getAttributes(acc, [name]);
568
- return [
569
- ...acc.filter(attr => attr.name !== name),
570
- Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name })), { cfgStatus: 'User', value }),
571
- ];
572
- }, originalAttributes);
573
- };
574
- const patchAttributes = (rootLineItem, id, attrs) => {
575
- const lineItem = findLineItem(id, [rootLineItem]);
576
- if (!lineItem) {
577
- return rootLineItem;
578
- }
579
- const attributes = upsertAttributes(lineItem.attributes, attrs);
580
- return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes }));
581
- };
582
- const getAttributeValue = (attributes, name) => { var _a; return (_a = attributes.find(attr => attr.name === name)) === null || _a === void 0 ? void 0 : _a.value; };
583
- const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
584
- return {
585
- port,
586
- type,
587
- actionCode: 'ADD',
588
- cfgStatus: 'New',
589
- attributes: attributes.map(({ name, value }) => ({ cfgStatus: 'User', name, value })),
590
- lineItems,
591
- parentId,
592
- qty: 1,
593
- };
594
- };
595
- const getRecommendedPrices = (portDomain, type) => {
596
- var _a, _b;
597
- const domainType = portDomain.domainTypes.find(({ name }) => name === type);
598
- const [net, list] = (_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(({ chargeMethod }) => chargeMethod === 'ONE_TIME').reduce((acc, rp) => {
599
- const [netPrice, listPrice] = acc;
600
- return [netPrice + rp.netPrice, listPrice + rp.listPrice];
601
- }, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0];
602
- return { net, list };
603
- };
604
-
605
- class LineItemWorker {
606
- constructor(src) {
607
- this.li = Object.assign({}, src);
608
- }
609
- insert(parentId, toInsert) {
610
- return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
611
- }
612
- remove(id) {
613
- return new LineItemWorker(removeLineItem(this.li, id));
614
- }
615
- replace(toReplace) {
616
- return new LineItemWorker(replaceLineItem(this.li, toReplace));
617
- }
618
- patchAttribute(attrs, id) {
619
- return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs));
620
- }
621
- }
622
-
623
- var vlCmsLineItemTypes = /*#__PURE__*/Object.freeze({
624
- __proto__: null,
625
- LineItemWorker: LineItemWorker
626
- });
627
-
628
- const getDefaultLineItem = (context, uiDefinitionProperties) => {
629
- var _a, _b, _c;
630
- const id = UUID.UUID();
631
- const lineItem = Object.assign({ 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
632
- ? { offeringId: context.offeringId, offeringInstanceId: context.offeringInstanceId || id }
633
- : {}));
634
- return lineItem;
635
- };
636
-
637
- class RuntimeContextService {
638
- constructor(configurationApiService, messageService) {
639
- this.configurationApiService = configurationApiService;
640
- this.messageService = messageService;
641
- }
642
- getRuntimeContext(productId, offeringId) {
643
- return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
644
- var _a, _b, _c;
645
- const uiDefinition = this.getUIDefinition(runtimeData);
646
- const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
647
- const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
648
- return {
649
- modelId: runtimeData.modelId,
650
- uiDefinition: uiDefinition,
651
- runtimeModel: runtimeModel,
652
- runtimeMode: RuntimeMode.PROD,
653
- productId: productId,
654
- productType: (properties === null || properties === void 0 ? void 0 : properties.displayName) || productName,
655
- offeringId: offeringId,
656
- properties: {
657
- PricingEnabled: ((_b = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _b === void 0 ? void 0 : _b.pricingEnabled) ? 'true' : 'false',
658
- PriceListId: (_c = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _c === void 0 ? void 0 : _c.priceList,
659
- },
660
- };
661
- }));
662
- }
663
- getUIDefinition(runtimeData) {
664
- var _a;
665
- let rawUiDefinitions;
666
- try {
667
- rawUiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
668
- }
669
- catch (e) {
670
- return;
671
- }
672
- const uiDefinitions = rawUiDefinitions.filter(uiDef => uiDef.version);
673
- const uiDefinition = (_a = uiDefinitions.find(uiDef => uiDef.primary)) !== null && _a !== void 0 ? _a : uiDefinitions[0];
674
- if (!uiDefinition) {
675
- const errMsg = `Unable to find Default UI`;
676
- this.messageService.add({
677
- severity: 'error',
678
- summary: 'ERROR',
679
- });
680
- throw new Error(errMsg);
681
- }
682
- return uiDefinition;
683
- }
684
- }
685
- RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }, { token: i3.MessageService }], target: i0.ɵɵFactoryTarget.Injectable });
686
- RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeContextService });
687
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeContextService, decorators: [{
688
- type: Injectable
689
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: i3.MessageService }]; } });
690
-
691
- class ConfigurationRuntimeService {
692
- constructor(apiService, contextService, runtimeContextService) {
693
- this.apiService = apiService;
694
- this.contextService = contextService;
695
- this.runtimeContextService = runtimeContextService;
696
- this._isInitialized = false;
697
- this.uiDefinitionProperties = {};
698
- }
699
- reset() {
700
- this._isInitialized = false;
701
- this._runtimeContext = undefined;
702
- this._assets = undefined;
703
- this.uiDefinitionProperties = {};
704
- }
705
- initTestMode(modelId, uiDefinition) {
706
- var _a, _b;
707
- this.uiDefinitionProperties = (_a = uiDefinition.properties) !== null && _a !== void 0 ? _a : {};
708
- const uiDefinitionExternals = (_b = uiDefinition.externals) !== null && _b !== void 0 ? _b : {};
709
- return combineLatest([
710
- this.apiService.getRuntimeDataByModelId(modelId),
711
- this.contextService.create('TestId', ConfigurationContextMode.TEST),
712
- ]).pipe(first(), tap(([runtimeData, context]) => {
713
- var _a;
714
- this._runtimeContext = {
715
- modelId: modelId,
716
- runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
717
- runtimeMode: RuntimeMode.TEST,
718
- };
719
- this.contextService.update({
720
- properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: modelId, RuntimeMode: ConfigurationContextMode.TEST, PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', StartDate: new Date().toISOString().substring(0, 10), PriceListId: this.uiDefinitionProperties.priceList }), uiDefinitionExternals),
721
- });
722
- this._isInitialized = true;
723
- }));
724
- }
725
- init(props) {
726
- this._assets = props.assets;
727
- const context = this.contextService.resolve();
728
- if (!context) {
729
- return of();
730
- }
731
- return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
732
- var _a, _b, _c, _d;
733
- this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
734
- const { PriceListId } = (_c = context.properties) !== null && _c !== void 0 ? _c : {};
735
- const mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
736
- this.id15to18('AccountId', mergeContext.properties);
737
- this._runtimeContext = mergeContext;
738
- if (context.properties && ((_d = this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
739
- this.contextService.update({
740
- properties: Object.assign(Object.assign({}, this._runtimeContext.properties), context.properties),
741
- });
742
- }
743
- this._isInitialized = true;
744
- }));
745
- }
746
- id15to18(propertyName, source) {
747
- if (!source) {
748
- return;
749
- }
750
- const value = source[propertyName];
751
- if (typeof value === 'string' && value.length === 15) {
752
- source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
753
- }
754
- }
755
- getAsset(lineItem) {
756
- return this._assets && this._assets.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
757
- }
758
- get isInitialized() {
759
- return this._isInitialized;
760
- }
761
- get runtimeModel() {
762
- var _a;
763
- return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
764
- }
765
- get runtimeContext() {
766
- return this._runtimeContext;
767
- }
768
- }
769
- ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: i2.ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
770
- ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationRuntimeService });
771
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
772
- type: Injectable
773
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: i2.ContextService }, { type: RuntimeContextService }]; } });
774
-
775
- class ConfigurationService {
776
- constructor(runtimeService, contextService, configurationApiService, messageService, dialogService) {
777
- this.runtimeService = runtimeService;
778
- this.contextService = contextService;
779
- this.configurationApiService = configurationApiService;
780
- this.messageService = messageService;
781
- this.dialogService = dialogService;
782
- this.mode = ConfigurationMode.SEARCH;
783
- this.states = {};
784
- this.lineItem = new BehaviorSubject(undefined);
785
- this.charges = new BehaviorSubject({});
786
- }
787
- reset() {
788
- this.runtimeService.reset();
789
- this.states = {};
790
- this.lineItem.next(undefined);
791
- this.charges.next({});
792
- }
793
- patch$(lineItem) {
794
- if (!this.lineItem.value) {
795
- return throwError(() => new Error(`Source LineItem not found`));
796
- }
797
- this.states.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem).li;
798
- this.states.asset = this.states.configurableRamp
799
- ? this.runtimeService.getAsset(this.states.configurableRamp)
800
- : undefined;
801
- return this.configure().pipe(catchError(error => {
802
- console.error(error);
803
- if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
804
- this.messageService.add({ severity: 'error', summary: error });
805
- }
806
- // bounce back if configuration call has failed
807
- this.lineItem.next(this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined);
808
- return throwError(() => error);
809
- }));
810
- }
811
- patch(lineItem) {
812
- this.patch$(lineItem).subscribe();
813
- }
814
- updateCurrentStates(update) {
815
- this.states = Object.assign(Object.assign({}, this.states), update);
816
- }
817
- get() {
818
- return this.lineItem.asObservable().pipe(shareReplay());
819
- }
820
- getSnapshot() {
821
- return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
822
- }
823
- getRuntimeModel() {
824
- return this.runtimeService.runtimeModel;
825
- }
826
- getRuntimeContext() {
827
- return this.runtimeService.runtimeContext;
828
- }
829
- get contextSnapshot() {
830
- return this.contextService.resolve();
831
- }
832
- get context$() {
833
- return this.contextService.resolve$();
834
- }
835
- get charges$() {
836
- return this.charges.asObservable();
837
- }
838
- get chargesSnapshot() {
839
- return this.charges.value;
840
- }
841
- configure() {
842
- var _a, _b, _c, _d, _e;
843
- const runtimeContext = this.getRuntimeContext();
844
- const runtimeModel = this.getRuntimeModel();
845
- if (!runtimeContext || !runtimeModel) {
846
- return throwError(() => new Error('Runtime context/model not initialized'));
847
- }
848
- const 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 : {}));
849
- const lineItem = (_d = this.states.configurableRamp) !== null && _d !== void 0 ? _d : getDefaultLineItem(runtimeContext, uiDefinitionProperties);
850
- const configurationRequest = this.createRequest(lineItem);
851
- configurationRequest.lineItems = this.states.currentState || [];
852
- configurationRequest.asset = this.states.asset;
853
- const mainPricingEnabled = (_e = runtimeContext.properties) === null || _e === void 0 ? void 0 : _e.PricingEnabled;
854
- const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
855
- return this.configurationApiService
856
- .configureLineItem({ configurationRequest, runtimeModel, pricingEnabled })
857
- .pipe(map(({ lineItem, context, charges, deletedLineItems }) => {
858
- this.contextService.update(context !== null && context !== void 0 ? context : {});
859
- this.charges.next(charges !== null && charges !== void 0 ? charges : {});
860
- if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
861
- this.showInactiveProductsConfirmation();
862
- }
863
- return lineItem;
864
- }))
865
- .pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })));
866
- }
867
- createRequest(lineItem) {
868
- return {
869
- lineItem,
870
- mode: this.mode,
871
- step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
872
- attributeDomainMode: 'ALL',
873
- context: this.contextService.resolve(),
874
- };
875
- }
876
- showInactiveProductsConfirmation() {
877
- this.dialogService
878
- .open(ConfirmationComponent, {
879
- dismissableMask: false,
880
- closeOnEscape: false,
881
- closable: false,
882
- showHeader: true,
883
- header: `Inactive Products in Quote`,
884
- width: '440px',
885
- data: {
886
- confirmationConfig: {
887
- title: ' ',
888
- description: 'This quote contains inactive products. Do you want to remove them?',
889
- submitBtn: 'Remove products',
890
- cancelBtn: 'Back to Quote',
891
- },
892
- },
893
- })
894
- .onClose.subscribe(result => {
895
- if (!result) {
896
- const context = this.contextService.resolve();
897
- window['VELO_BACK_FN'].apply(null, [(context === null || context === void 0 ? void 0 : context.headerId) || '']);
898
- }
899
- });
900
- }
901
- }
902
- ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, deps: [{ token: ConfigurationRuntimeService }, { token: i2.ContextService }, { token: i1.ConfigurationApiService }, { token: i3.MessageService }, { token: i5.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
903
- ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService });
904
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, decorators: [{
905
- type: Injectable
906
- }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: i2.ContextService }, { type: i1.ConfigurationApiService }, { type: i3.MessageService }, { type: i5.DialogService }]; } });
907
-
908
517
  class ElementRendererComponent {
909
518
  constructor(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
910
519
  this.parentInjector = parentInjector;
@@ -956,7 +565,7 @@ class ElementRendererComponent {
956
565
  const pathBlocks = parseBoundPath(path).reverse();
957
566
  const { property, name } = (_b = pathBlocks[1]) !== null && _b !== void 0 ? _b : {};
958
567
  const finalPath = pathBlocks[0];
959
- const children$ = this.getParentLineItem$(parentComp).pipe(map$1(model => {
568
+ const children$ = this.getParentLineItem$(parentComp).pipe(map(model => {
960
569
  var _a;
961
570
  if (property === 'ports' && !finalPath.property && parentPath !== path) {
962
571
  return (_a = model.lineItems.filter(({ port }) => port === name)) !== null && _a !== void 0 ? _a : [];
@@ -1017,7 +626,7 @@ class ElementRendererComponent {
1017
626
  this.refs = {};
1018
627
  }
1019
628
  }
1020
- ElementRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererComponent, deps: [{ token: i0.Injector, skipSelf: true }, { token: DynamicModuleService }, { token: ElementContextService }, { token: IOProviderService }, { token: ConfigurationService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
629
+ ElementRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererComponent, deps: [{ token: i0.Injector, skipSelf: true }, { token: DynamicModuleService }, { token: ElementContextService }, { token: IOProviderService }, { token: i2.ConfigurationService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1021
630
  ElementRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: { meta: "meta" }, providers: [ElementContextService], viewQueries: [{ propertyName: "el", first: true, predicate: ["el"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<ng-template #el></ng-template>\n", styles: [":host{display:contents}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1022
631
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererComponent, decorators: [{
1023
632
  type: Component,
@@ -1030,7 +639,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
1030
639
  }]
1031
640
  }], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
1032
641
  type: SkipSelf
1033
- }] }, { type: DynamicModuleService }, { type: ElementContextService }, { type: IOProviderService }, { type: ConfigurationService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { el: [{
642
+ }] }, { type: DynamicModuleService }, { type: ElementContextService }, { type: IOProviderService }, { type: i2.ConfigurationService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { el: [{
1034
643
  type: ViewChild,
1035
644
  args: ['el', { read: ViewContainerRef, static: true }]
1036
645
  }], meta: [{
@@ -1267,7 +876,7 @@ class ConfigurationPlugin {
1267
876
  if (!this.host.model$) {
1268
877
  return;
1269
878
  }
1270
- const value$ = (_a = this.host.model$) === null || _a === void 0 ? void 0 : _a.pipe(map$1(model => { var _a; return getAttributeValue((_a = model === null || model === void 0 ? void 0 : model.attributes) !== null && _a !== void 0 ? _a : [], name); }));
879
+ const value$ = (_a = this.host.model$) === null || _a === void 0 ? void 0 : _a.pipe(map(model => { var _a; return getAttributeValue((_a = model === null || model === void 0 ? void 0 : model.attributes) !== null && _a !== void 0 ? _a : [], name); }));
1271
880
  const patch = (value) => {
1272
881
  if (!this.modelSnapshot) {
1273
882
  return;
@@ -1298,212 +907,6 @@ const DEFAULT_PLUGINS = {
1298
907
  DEFAULT: [],
1299
908
  };
1300
909
 
1301
- class FlowUpdateService {
1302
- update(rootLineItems, updates) {
1303
- let remainingUpdates = [...updates];
1304
- let currentLevel = rootLineItems;
1305
- while (currentLevel.length && remainingUpdates.length) {
1306
- currentLevel.forEach(li => {
1307
- const unhandledUpdates = [];
1308
- remainingUpdates.forEach(update => {
1309
- let updated = false;
1310
- switch (update.dataType) {
1311
- case 'LINEITEM':
1312
- updated = this.applyLineItemUpdate(li, update);
1313
- break;
1314
- case 'CHARGE':
1315
- updated = this.applyChargeUpdate(li, update);
1316
- break;
1317
- case 'GROUP_CHARGE':
1318
- updated = this.applyChargeGroupUpdate(li, update);
1319
- break;
1320
- default:
1321
- // Unknown dataType. Do not try to handle it anymore
1322
- updated = true;
1323
- }
1324
- if (!updated) {
1325
- unhandledUpdates.push(update);
1326
- }
1327
- });
1328
- remainingUpdates = unhandledUpdates;
1329
- });
1330
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
1331
- }
1332
- }
1333
- delete(lineItems, id) {
1334
- const idsToRemove = [id];
1335
- const topLevelLineItem = lineItems.find(li => li.id === id);
1336
- if (topLevelLineItem) {
1337
- // find term-related line items (which are only top level)
1338
- // expired term line items won't be deleted
1339
- let foundTermLineItem = topLevelLineItem;
1340
- while (foundTermLineItem) {
1341
- foundTermLineItem = lineItems.find(li => foundTermLineItem && li.rampInstanceId === foundTermLineItem.id);
1342
- if (foundTermLineItem) {
1343
- idsToRemove.push(foundTermLineItem.id);
1344
- }
1345
- }
1346
- }
1347
- const filtered = lineItems.filter(lineItem => !idsToRemove.includes(lineItem.id));
1348
- return filtered.map(lineItem => new LineItemWorker(lineItem).remove(id).li);
1349
- }
1350
- applyLineItemUpdate(lineItem, update) {
1351
- if (lineItem.id !== update.id) {
1352
- return false;
1353
- }
1354
- switch (update.attributeType) {
1355
- case 'QTY':
1356
- lineItem.qty = update.newValue;
1357
- break;
1358
- case 'EFFECTIVE_START_DATE':
1359
- lineItem.effectiveStartDate = moment(update.newValue).format('YYYY-MM-DD');
1360
- break;
1361
- case 'END_DATE':
1362
- lineItem.endDate = moment(update.newValue).format('YYYY-MM-DD');
1363
- break;
1364
- case 'PRICE_ADJUSTMENT':
1365
- {
1366
- const [charge] = lineItem.chargeItems;
1367
- if (charge) {
1368
- charge.priceAdjustment = update.newValue;
1369
- }
1370
- }
1371
- break;
1372
- default:
1373
- throw new Error(`Not suppored AttributeType for LineItem update: ${update.attributeType}`);
1374
- }
1375
- return true;
1376
- }
1377
- applyChargeUpdate(lineItem, update) {
1378
- const foundCharge = lineItem.chargeItems.find(({ id }) => id === update.id);
1379
- if (!foundCharge) {
1380
- return false;
1381
- }
1382
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
1383
- foundCharge.priceAdjustment = update.newValue;
1384
- }
1385
- else {
1386
- throw new Error(`Not suppored AttributeType for Charge Item update: ${update.attributeType}`);
1387
- }
1388
- return true;
1389
- }
1390
- applyChargeGroupUpdate(lineItem, update) {
1391
- const foundChargeGroup = lineItem.chargeGroupItems.find(({ id }) => id === update.id);
1392
- if (!foundChargeGroup) {
1393
- return false;
1394
- }
1395
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
1396
- foundChargeGroup.priceAdjustment = update.newValue;
1397
- }
1398
- else {
1399
- throw new Error(`Not suppored AttributeType for Charge Group Item update: ${update.attributeType}`);
1400
- }
1401
- return true;
1402
- }
1403
- }
1404
- FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1405
- FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowUpdateService });
1406
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowUpdateService, decorators: [{
1407
- type: Injectable
1408
- }] });
1409
-
1410
- class FlowConfigurationService {
1411
- constructor(priceApiService, contextService, messageService, updateService) {
1412
- this.priceApiService = priceApiService;
1413
- this.contextService = contextService;
1414
- this.messageService = messageService;
1415
- this.updateService = updateService;
1416
- this.lineItems = new BehaviorSubject([]);
1417
- this.charges = new BehaviorSubject({});
1418
- }
1419
- reset() {
1420
- this.lineItems.next([]);
1421
- this.charges.next({});
1422
- }
1423
- calculate$(currentState) {
1424
- const context = this.contextService.resolve();
1425
- return this.priceApiService.calculate({ context, currentState }).pipe(tap$1((result) => {
1426
- this.lineItems.next(result.lineItems);
1427
- this.charges.next(result.charges);
1428
- if (context) {
1429
- this.contextService.update({ properties: context.properties });
1430
- }
1431
- }), this.handleError());
1432
- }
1433
- calculate(currentState) {
1434
- this.calculate$(currentState).subscribe();
1435
- }
1436
- update$(updates) {
1437
- const lineItems = cloneDeep(this.lineItems.value);
1438
- return of([]).pipe(tap$1(() => this.updateService.update(lineItems, updates)), this.handleError(), switchMap(() => this.calculate$(lineItems)));
1439
- }
1440
- update(updates) {
1441
- this.update$(updates).subscribe();
1442
- }
1443
- delete$(ids) {
1444
- return of([]).pipe(map$1(() => ids.reduce((result, id) => this.updateService.delete(result, id), this.lineItems.value)), this.handleError(), switchMap(currentState => this.calculate$(currentState)));
1445
- }
1446
- delete(ids) {
1447
- this.delete$(ids).subscribe();
1448
- }
1449
- get() {
1450
- return this.lineItems.asObservable().pipe(shareReplay());
1451
- }
1452
- getSnapshot() {
1453
- return this.lineItems.value.slice();
1454
- }
1455
- get charges$() {
1456
- return this.charges.asObservable();
1457
- }
1458
- get chargesSnapshot() {
1459
- return this.charges.value;
1460
- }
1461
- get contextSnapshot() {
1462
- return this.contextService.resolve();
1463
- }
1464
- get context$() {
1465
- return this.contextService.resolve$();
1466
- }
1467
- handleError() {
1468
- return (source$) => {
1469
- return source$.pipe(catchError$1(error => {
1470
- console.error(error);
1471
- this.messageService.add({ severity: 'error', summary: error });
1472
- // bounce back if configuration call has failed
1473
- this.lineItems.next(this.lineItems.value.slice());
1474
- return throwError(() => error);
1475
- }));
1476
- };
1477
- }
1478
- }
1479
- FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.PriceApiService }, { token: i2.ContextService }, { token: i3.MessageService }, { token: FlowUpdateService }], target: i0.ɵɵFactoryTarget.Injectable });
1480
- FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService });
1481
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, decorators: [{
1482
- type: Injectable
1483
- }], ctorParameters: function () { return [{ type: i1.PriceApiService }, { type: i2.ContextService }, { type: i3.MessageService }, { type: FlowUpdateService }]; } });
1484
-
1485
- class FlowConfigurationModule {
1486
- }
1487
- FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1488
- FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationModule });
1489
- FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, ContextService, PriceApiService] });
1490
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1491
- type: NgModule,
1492
- args: [{
1493
- providers: [FlowConfigurationService, FlowUpdateService, ContextService, PriceApiService],
1494
- }]
1495
- }] });
1496
-
1497
- var vlCmsModules = /*#__PURE__*/Object.freeze({
1498
- __proto__: null,
1499
- getDefaultLineItem: getDefaultLineItem,
1500
- ConfigurationRuntimeService: ConfigurationRuntimeService,
1501
- ConfigurationService: ConfigurationService,
1502
- FlowConfigurationModule: FlowConfigurationModule,
1503
- FlowConfigurationService: FlowConfigurationService,
1504
- FlowUpdateService: FlowUpdateService
1505
- });
1506
-
1507
910
  const InitAction = { type: 'INIT' };
1508
911
  const ClearAction = { type: 'CLEAR' };
1509
912
  class IntegrationState {
@@ -1524,7 +927,7 @@ class IntegrationState {
1524
927
  this.action$.next(action);
1525
928
  }
1526
929
  listen$(actionType) {
1527
- return this.action$.pipe(filter(action => action.type === actionType), map$1(action => action.payload));
930
+ return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
1528
931
  }
1529
932
  listenAll$() {
1530
933
  return this.action$.asObservable();
@@ -1541,35 +944,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
1541
944
  args: [{ providedIn: 'root' }]
1542
945
  }] });
1543
946
 
1544
- var vlCmsUtils = /*#__PURE__*/Object.freeze({
1545
- __proto__: null,
1546
- UiBuildError: UiBuildError,
1547
- elementToMetadata: elementToMetadata,
1548
- metadataToElement: metadataToElement,
1549
- normalizeElementMetadata: normalizeElementMetadata,
1550
- extractElementMetadata: extractElementMetadata,
1551
- extendElementMetadata: extendElementMetadata,
1552
- getElementConfig: getElementConfig,
1553
- doesElementSupportIO: doesElementSupportIO,
1554
- stringifyElementMetadata: stringifyElementMetadata,
1555
- isValidScript: isValidScript,
1556
- parseBoundPath: parseBoundPath,
1557
- findLineItem: findLineItem,
1558
- findLineItemWithComparator: findLineItemWithComparator,
1559
- insertLineItem: insertLineItem,
1560
- removeLineItem: removeLineItem,
1561
- replaceLineItem: replaceLineItem,
1562
- mapAttributes: mapAttributes,
1563
- getAttributes: getAttributes,
1564
- upsertAttributes: upsertAttributes,
1565
- patchAttributes: patchAttributes,
1566
- getAttributeValue: getAttributeValue,
1567
- generateLineItem: generateLineItem,
1568
- getRecommendedPrices: getRecommendedPrices
1569
- });
1570
-
1571
947
  const vendorMap = {
1572
- '@veloce/sdk/cms': Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, vlCmsModules), vlCmsUtils), vlCmsLineItemTypes), vlInjectionTokens), { TemplatesService,
948
+ '@veloce/sdk/core': Object.assign({ ConfigurationService,
949
+ FlowConfigurationService,
950
+ LineItemWorker }, lineItemUtils),
951
+ '@veloce/sdk/cms': Object.assign(Object.assign({}, vlInjectionTokens), { TemplatesService,
1573
952
  IntegrationState }),
1574
953
  '@veloce/api': {
1575
954
  SalesforceApiService,
@@ -1693,7 +1072,7 @@ class LauncherService {
1693
1072
  }
1694
1073
  compileModule(elements, uiDefs) {
1695
1074
  this.module = this.getModule(elements, uiDefs);
1696
- return from(this.compiler.compileModuleAndAllComponentsAsync(this.module)).pipe(tap$1(m => {
1075
+ return from(this.compiler.compileModuleAndAllComponentsAsync(this.module)).pipe(tap(m => {
1697
1076
  this.dynamicModuleService.componentFactories = m.componentFactories;
1698
1077
  this.moduleInstance = m;
1699
1078
  }));
@@ -1788,7 +1167,7 @@ class PreviewComponent {
1788
1167
  this.elements = this.elementToMetadataSafe(children);
1789
1168
  const compilation$ = this.launcherService.compileModule(this.elements, uiDefinitionMeta);
1790
1169
  forkJoin([compilation$, this.initializeConfiguration$()])
1791
- .pipe(tap$1(() => this.state$.next({ loading: false, failure: false })), catchError$1(error => {
1170
+ .pipe(tap(() => this.state$.next({ loading: false, failure: false })), catchError(error => {
1792
1171
  var _a, _b;
1793
1172
  console.error(error);
1794
1173
  if (!((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
@@ -1800,8 +1179,8 @@ class PreviewComponent {
1800
1179
  .subscribe();
1801
1180
  }
1802
1181
  }
1803
- PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, deps: [{ token: LauncherService }, { token: ConfigurationService }, { token: i3.MessageService }, { token: ConfigurationRuntimeService }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Component });
1804
- PreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition", clearState: "clearState" }, providers: [IOProviderService, TemplatesService], ngImport: i0, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-element-renderer *ngFor=\"let el of elements\" [meta]=\"el\"></vl-cms-element-renderer>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [":host{flex-grow:1;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: i6.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i8.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i8.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
1182
+ PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, deps: [{ token: LauncherService }, { token: i2.ConfigurationService }, { token: i3.MessageService }, { token: i2.ConfigurationRuntimeService }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Component });
1183
+ PreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition", clearState: "clearState" }, providers: [IOProviderService, TemplatesService], ngImport: i0, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-element-renderer *ngFor=\"let el of elements\" [meta]=\"el\"></vl-cms-element-renderer>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [":host{flex-grow:1;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: i5.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
1805
1184
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, decorators: [{
1806
1185
  type: Component,
1807
1186
  args: [{
@@ -1813,7 +1192,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
1813
1192
  // use shadow DOM to prevent UI from being affected by global styles
1814
1193
  encapsulation: ViewEncapsulation.ShadowDom,
1815
1194
  }]
1816
- }], ctorParameters: function () { return [{ type: LauncherService }, { type: ConfigurationService }, { type: i3.MessageService }, { type: ConfigurationRuntimeService }, { type: IntegrationState }]; }, propDecorators: { modelId: [{
1195
+ }], ctorParameters: function () { return [{ type: LauncherService }, { type: i2.ConfigurationService }, { type: i3.MessageService }, { type: i2.ConfigurationRuntimeService }, { type: IntegrationState }]; }, propDecorators: { modelId: [{
1817
1196
  type: Input
1818
1197
  }], uiDefinition: [{
1819
1198
  type: Input
@@ -1869,44 +1248,15 @@ function ElementDefinition(definition) {
1869
1248
  };
1870
1249
  }
1871
1250
 
1872
- class ConfigurationModule {
1873
- }
1874
- ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1875
- ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
1876
- ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, providers: [
1877
- ContextService,
1878
- ContextApiService,
1879
- ProductModelApiService,
1880
- ConfigurationApiService,
1881
- ConfigurationRuntimeService,
1882
- RuntimeContextService,
1883
- ConfigurationService,
1884
- ], imports: [[ConfirmationDialogModule]] });
1885
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, decorators: [{
1886
- type: NgModule,
1887
- args: [{
1888
- imports: [ConfirmationDialogModule],
1889
- providers: [
1890
- ContextService,
1891
- ContextApiService,
1892
- ProductModelApiService,
1893
- ConfigurationApiService,
1894
- ConfigurationRuntimeService,
1895
- RuntimeContextService,
1896
- ConfigurationService,
1897
- ],
1898
- }]
1899
- }] });
1900
-
1901
1251
  class LauncherModule {
1902
1252
  }
1903
1253
  LauncherModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1904
- LauncherModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, imports: [CommonModule, CoreModule, ApiModule, ConfigurationModule, FlowConfigurationModule] });
1905
- LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, providers: [LauncherService, IntegrationState, DynamicModuleService, DialogService], imports: [[CommonModule, CoreModule, ApiModule, ConfigurationModule, FlowConfigurationModule]] });
1254
+ LauncherModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule] });
1255
+ LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, providers: [LauncherService, IntegrationState, DynamicModuleService, DialogService], imports: [[CommonModule, CoreModule, ApiModule, SdkCoreModule]] });
1906
1256
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, decorators: [{
1907
1257
  type: NgModule,
1908
1258
  args: [{
1909
- imports: [CommonModule, CoreModule, ApiModule, ConfigurationModule, FlowConfigurationModule],
1259
+ imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule],
1910
1260
  providers: [LauncherService, IntegrationState, DynamicModuleService, DialogService],
1911
1261
  }]
1912
1262
  }] });
@@ -1915,5 +1265,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
1915
1265
  * Generated bundle index. Do not edit.
1916
1266
  */
1917
1267
 
1918
- export { ConfigurationRuntimeService, ConfigurationService, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, IntegrationState, LauncherModule, LauncherService, LineItemWorker, PreviewComponent, PreviewModule, SHARED_ELEMENT_METADATA, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, VENDOR_MAP, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findLineItem, findLineItemWithComparator, generateLineItem, getAttributeValue, getAttributes, getDefaultLineItem, getElementConfig, getRecommendedPrices, insertLineItem, isValidScript, mapAttributes, metadataToElement, normalizeElementMetadata, parseBoundPath, patchAttributes, removeLineItem, replaceLineItem, stringifyElementMetadata, upsertAttributes };
1268
+ export { DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, IntegrationState, LauncherModule, LauncherService, PreviewComponent, PreviewModule, SHARED_ELEMENT_METADATA, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, VENDOR_MAP, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, getAbsolutePath, getElementConfig, isValidScript, loadRemoteModule, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, stringifyElementMetadata };
1919
1269
  //# sourceMappingURL=veloce-sdk-cms.js.map