@veloceapps/sdk 8.0.0-166 → 8.0.0-168

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -3
  2. package/esm2020/cms/modules/migrations/migrations.mjs +2 -2
  3. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +6 -2
  4. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +3 -3
  5. package/esm2020/cms/plugins/configuration.plugin.mjs +8 -4
  6. package/esm2020/cms/services/io-provider.service.mjs +10 -9
  7. package/esm2020/cms/services/templates.service.mjs +10 -9
  8. package/esm2020/cms/utils/path.utils.mjs +3 -3
  9. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +7 -8
  10. package/esm2020/core/services/flow-state.service.mjs +8 -6
  11. package/esm2020/core/services/product-images.service.mjs +2 -2
  12. package/esm2020/core/utils/line-item.utils.mjs +2 -2
  13. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +13 -8
  14. package/esm2020/src/pages/remote/remote.component.mjs +8 -7
  15. package/esm2020/src/services/flow-dialog.service.mjs +2 -2
  16. package/fesm2015/veloceapps-sdk-cms.mjs +38 -26
  17. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  18. package/fesm2015/veloceapps-sdk-core.mjs +18 -14
  19. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  20. package/fesm2015/veloceapps-sdk.mjs +24 -19
  21. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  22. package/fesm2020/veloceapps-sdk-cms.mjs +34 -24
  23. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  24. package/fesm2020/veloceapps-sdk-core.mjs +15 -14
  25. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  26. package/fesm2020/veloceapps-sdk.mjs +20 -14
  27. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  28. package/package.json +1 -1
@@ -594,7 +594,7 @@ const parseBoundPath = (path) => {
594
594
  const regexp = new RegExp(`(?:\\/)(?:\\w+)(?:\\/)(?:ports|attributes)(?:\\/)(?:\\w+)|(?:\\/)(?:\\w+)`, 'g');
595
595
  const blocks = (_b = (_a = path.match(regexp)) === null || _a === void 0 ? void 0 : _a.map(match => {
596
596
  const [type, property, name] = compact(match.split('/'));
597
- return { type, property, name };
597
+ return { type: type !== null && type !== void 0 ? type : '', property, name };
598
598
  })) !== null && _b !== void 0 ? _b : [];
599
599
  return blocks;
600
600
  };
@@ -622,11 +622,11 @@ const parsePath = (path) => {
622
622
  };
623
623
  };
624
624
  const getAbsolutePath = (elements, subject, path) => {
625
- var _a, _b, _c;
625
+ var _a, _b, _c, _d;
626
626
  if (path.module) {
627
- return (_a = findElementByModule(elements, path.module, path.segments[0])) === null || _a === void 0 ? void 0 : _a.path;
627
+ return (_b = findElementByModule(elements, path.module, (_a = path.segments[0]) !== null && _a !== void 0 ? _a : '')) === null || _b === void 0 ? void 0 : _b.path;
628
628
  }
629
- const subjectSegments = (_c = (_b = subject.path) === null || _b === void 0 ? void 0 : _b.split('/')) !== null && _c !== void 0 ? _c : [];
629
+ const subjectSegments = (_d = (_c = subject.path) === null || _c === void 0 ? void 0 : _c.split('/')) !== null && _d !== void 0 ? _d : [];
630
630
  const segments = [...path.segments];
631
631
  if (path.isAbsolute) {
632
632
  return segments.join('/');
@@ -772,18 +772,20 @@ class IOProviderService {
772
772
  return this.createSubjectSafe(absolutePath !== null && absolutePath !== void 0 ? absolutePath : '', finalName, undefined);
773
773
  }
774
774
  createSubjectSafe(path, name, subject) {
775
+ var _a, _b, _c;
776
+ const pathInputs = (_a = this.inputs[path]) !== null && _a !== void 0 ? _a : {};
775
777
  if (!this.inputs[path]) {
776
- this.inputs[path] = {};
778
+ this.inputs[path] = pathInputs;
777
779
  }
778
- const subjectAlreadyExists = Boolean(this.inputs[path][name]);
779
- if (!this.inputs[path][name]) {
780
- this.inputs[path][name] = subject !== null && subject !== void 0 ? subject : new BehaviorSubject(undefined);
781
- }
782
- if (subject && subjectAlreadyExists) {
780
+ const actual = (_c = (_b = pathInputs[name]) !== null && _b !== void 0 ? _b : subject) !== null && _c !== void 0 ? _c : new BehaviorSubject(undefined);
781
+ if (subject && pathInputs[name]) {
783
782
  // push delayed value to workaround 'changed after it was checked' issue
784
- setTimeout(() => this.inputs[path][name].next(subject.value));
783
+ setTimeout(() => actual.next(subject.value));
784
+ }
785
+ if (!pathInputs[name]) {
786
+ pathInputs[name] = actual;
785
787
  }
786
- return this.inputs[path][name];
788
+ return actual;
787
789
  }
788
790
  }
789
791
  IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IOProviderService, deps: [{ token: RuntimeService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -797,21 +799,22 @@ class TemplatesService {
797
799
  this.templates = {};
798
800
  }
799
801
  register(name, templateRef) {
800
- this.ensureStorage(name);
801
- this.templates[name].next(templateRef);
802
+ this.ensureStorage(name).next(templateRef);
802
803
  }
803
804
  get(name) {
804
- this.ensureStorage(name);
805
- return this.templates[name].value;
805
+ return this.ensureStorage(name).value;
806
806
  }
807
807
  get$(name) {
808
- this.ensureStorage(name);
809
- return this.templates[name].asObservable();
808
+ return this.ensureStorage(name).asObservable();
810
809
  }
811
810
  ensureStorage(name) {
812
- if (!this.templates[name]) {
813
- this.templates[name] = new BehaviorSubject(undefined);
811
+ const storage = this.templates[name];
812
+ if (storage) {
813
+ return storage;
814
814
  }
815
+ const newStorage = new BehaviorSubject(undefined);
816
+ this.templates[name] = newStorage;
817
+ return newStorage;
815
818
  }
816
819
  }
817
820
  TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TemplatesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -905,7 +908,7 @@ class ElementRendererComponent {
905
908
  if (!model) {
906
909
  return [];
907
910
  }
908
- if (property === 'ports' && !finalPath.property && parentPath !== path) {
911
+ if (property === 'ports' && !(finalPath === null || finalPath === void 0 ? void 0 : finalPath.property) && parentPath !== path) {
909
912
  return (_a = model.lineItems.filter(({ port }) => port === name)) !== null && _a !== void 0 ? _a : [];
910
913
  }
911
914
  return [model];
@@ -915,7 +918,8 @@ class ElementRendererComponent {
915
918
  });
916
919
  }
917
920
  processChildren(children) {
918
- this.runtimeService.moduleRefs[0].injector.runInContext(() => {
921
+ var _a;
922
+ (_a = this.runtimeService.moduleRefs[0]) === null || _a === void 0 ? void 0 : _a.injector.runInContext(() => {
919
923
  const refs = children.reduce((acc, data, index) => {
920
924
  var _a;
921
925
  const key = String((_a = data === null || data === void 0 ? void 0 : data.id) !== null && _a !== void 0 ? _a : UUID.UUID());
@@ -2023,7 +2027,11 @@ class ConfigurationPlugin {
2023
2027
  if ((_a = this.elementMetadata.model) === null || _a === void 0 ? void 0 : _a.lineItem) {
2024
2028
  this.host.model$.pipe(takeUntil(this.destroy$)).subscribe(model => (this.modelSnapshot = model));
2025
2029
  const pathBlocks = parseBoundPath((_b = this.elementMetadata.model) === null || _b === void 0 ? void 0 : _b.lineItem);
2026
- const { type, property, name } = pathBlocks.reverse()[0];
2030
+ const firstPathBlock = pathBlocks.reverse()[0];
2031
+ if (!firstPathBlock) {
2032
+ return;
2033
+ }
2034
+ const { type, property, name } = firstPathBlock;
2027
2035
  this.host.boundName = name !== null && name !== void 0 ? name : type;
2028
2036
  this.register(type, property, name);
2029
2037
  }
@@ -2470,7 +2478,7 @@ class CompilationService {
2470
2478
  return [elements, sharedElements];
2471
2479
  }), switchMap(elementsChunks => combineLatest(elementsChunks.map(chunk => new ElementMetadataWorker(chunk).get$()))), switchMap(dataChunks => combineLatest(dataChunks.map(chunk => new TranspilationWorker(chunk).get$()))), map(([metadata, sharedMetadata]) => {
2472
2480
  var _a, _b;
2473
- this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata, config);
2481
+ this.elementsResolver = new ElementsResolver(uiDefinition, metadata !== null && metadata !== void 0 ? metadata : [], sharedMetadata, config);
2474
2482
  const componentTypes = this.elementsResolver.getNgComponents();
2475
2483
  const module = this.getModule(componentTypes);
2476
2484
  return {
@@ -2579,7 +2587,7 @@ const migrations = {
2579
2587
  3: uiDef => {
2580
2588
  const startingPage = metadataToElement(constructPage(STARTING_PAGE_NAME, STARTING_PAGE_TYPE, STARTING_PAGE_LAYOUT, STARTING_PAGE_STYLES));
2581
2589
  // overwrite children if provided from the UI Definition
2582
- if (uiDef.children && uiDef.children.length > 0) {
2590
+ if (startingPage.children[0] && uiDef.children && uiDef.children.length > 0) {
2583
2591
  // the starting page has the One Region Layout
2584
2592
  startingPage.children[0].children = uiDef.children;
2585
2593
  }
@@ -2606,7 +2614,11 @@ class MigrationsService {
2606
2614
  try {
2607
2615
  let result = cloneDeep(uiDef);
2608
2616
  for (const version of migrateVersions) {
2609
- result = migrations[version](result);
2617
+ const migration = migrations[version];
2618
+ if (!migration) {
2619
+ throw `V=${version} migration strategy is not defined`;
2620
+ }
2621
+ result = migration(result);
2610
2622
  }
2611
2623
  return result;
2612
2624
  }