@veloceapps/sdk 8.0.0-165 → 8.0.0-167

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) 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/src/components/doc-gen/doc-gen.component.mjs +13 -8
  13. package/esm2020/src/pages/remote/remote.component.mjs +8 -7
  14. package/esm2020/src/services/flow-dialog.service.mjs +2 -2
  15. package/fesm2015/veloceapps-sdk-cms.mjs +38 -26
  16. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  17. package/fesm2015/veloceapps-sdk-core.mjs +17 -13
  18. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  19. package/fesm2015/veloceapps-sdk.mjs +24 -19
  20. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  21. package/fesm2020/veloceapps-sdk-cms.mjs +34 -24
  22. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  23. package/fesm2020/veloceapps-sdk-core.mjs +14 -13
  24. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  25. package/fesm2020/veloceapps-sdk.mjs +20 -14
  26. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  27. package/package.json +1 -1
@@ -704,7 +704,7 @@ const parseBoundPath = (path) => {
704
704
  const regexp = new RegExp(`(?:\\/)(?:\\w+)(?:\\/)(?:ports|attributes)(?:\\/)(?:\\w+)|(?:\\/)(?:\\w+)`, 'g');
705
705
  const blocks = path.match(regexp)?.map(match => {
706
706
  const [type, property, name] = compact(match.split('/'));
707
- return { type, property, name };
707
+ return { type: type ?? '', property, name };
708
708
  }) ?? [];
709
709
  return blocks;
710
710
  };
@@ -732,7 +732,7 @@ const parsePath = (path) => {
732
732
  };
733
733
  const getAbsolutePath = (elements, subject, path) => {
734
734
  if (path.module) {
735
- return findElementByModule(elements, path.module, path.segments[0])?.path;
735
+ return findElementByModule(elements, path.module, path.segments[0] ?? '')?.path;
736
736
  }
737
737
  const subjectSegments = subject.path?.split('/') ?? [];
738
738
  const segments = [...path.segments];
@@ -777,18 +777,19 @@ class IOProviderService {
777
777
  return this.createSubjectSafe(absolutePath ?? '', finalName, undefined);
778
778
  }
779
779
  createSubjectSafe(path, name, subject) {
780
+ const pathInputs = this.inputs[path] ?? {};
780
781
  if (!this.inputs[path]) {
781
- this.inputs[path] = {};
782
+ this.inputs[path] = pathInputs;
782
783
  }
783
- const subjectAlreadyExists = Boolean(this.inputs[path][name]);
784
- if (!this.inputs[path][name]) {
785
- this.inputs[path][name] = subject ?? new BehaviorSubject(undefined);
786
- }
787
- if (subject && subjectAlreadyExists) {
784
+ const actual = pathInputs[name] ?? subject ?? new BehaviorSubject(undefined);
785
+ if (subject && pathInputs[name]) {
788
786
  // push delayed value to workaround 'changed after it was checked' issue
789
- setTimeout(() => this.inputs[path][name].next(subject.value));
787
+ setTimeout(() => actual.next(subject.value));
788
+ }
789
+ if (!pathInputs[name]) {
790
+ pathInputs[name] = actual;
790
791
  }
791
- return this.inputs[path][name];
792
+ return actual;
792
793
  }
793
794
  }
794
795
  IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IOProviderService, deps: [{ token: RuntimeService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -802,21 +803,22 @@ class TemplatesService {
802
803
  this.templates = {};
803
804
  }
804
805
  register(name, templateRef) {
805
- this.ensureStorage(name);
806
- this.templates[name].next(templateRef);
806
+ this.ensureStorage(name).next(templateRef);
807
807
  }
808
808
  get(name) {
809
- this.ensureStorage(name);
810
- return this.templates[name].value;
809
+ return this.ensureStorage(name).value;
811
810
  }
812
811
  get$(name) {
813
- this.ensureStorage(name);
814
- return this.templates[name].asObservable();
812
+ return this.ensureStorage(name).asObservable();
815
813
  }
816
814
  ensureStorage(name) {
817
- if (!this.templates[name]) {
818
- this.templates[name] = new BehaviorSubject(undefined);
815
+ const storage = this.templates[name];
816
+ if (storage) {
817
+ return storage;
819
818
  }
819
+ const newStorage = new BehaviorSubject(undefined);
820
+ this.templates[name] = newStorage;
821
+ return newStorage;
820
822
  }
821
823
  }
822
824
  TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TemplatesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -908,7 +910,7 @@ class ElementRendererComponent {
908
910
  if (!model) {
909
911
  return [];
910
912
  }
911
- if (property === 'ports' && !finalPath.property && parentPath !== path) {
913
+ if (property === 'ports' && !finalPath?.property && parentPath !== path) {
912
914
  return model.lineItems.filter(({ port }) => port === name) ?? [];
913
915
  }
914
916
  return [model];
@@ -918,7 +920,7 @@ class ElementRendererComponent {
918
920
  });
919
921
  }
920
922
  processChildren(children) {
921
- this.runtimeService.moduleRefs[0].injector.runInContext(() => {
923
+ this.runtimeService.moduleRefs[0]?.injector.runInContext(() => {
922
924
  const refs = children.reduce((acc, data, index) => {
923
925
  const key = String(data?.id ?? UUID.UUID());
924
926
  const existingRef = this.refs[key];
@@ -2017,7 +2019,11 @@ class ConfigurationPlugin {
2017
2019
  if (this.elementMetadata.model?.lineItem) {
2018
2020
  this.host.model$.pipe(takeUntil(this.destroy$)).subscribe(model => (this.modelSnapshot = model));
2019
2021
  const pathBlocks = parseBoundPath(this.elementMetadata.model?.lineItem);
2020
- const { type, property, name } = pathBlocks.reverse()[0];
2022
+ const firstPathBlock = pathBlocks.reverse()[0];
2023
+ if (!firstPathBlock) {
2024
+ return;
2025
+ }
2026
+ const { type, property, name } = firstPathBlock;
2021
2027
  this.host.boundName = name ?? type;
2022
2028
  this.register(type, property, name);
2023
2029
  }
@@ -2501,7 +2507,7 @@ class CompilationService {
2501
2507
  const sharedElements = components ?? [];
2502
2508
  return [elements, sharedElements];
2503
2509
  }), switchMap(elementsChunks => combineLatest(elementsChunks.map(chunk => new ElementMetadataWorker(chunk).get$()))), switchMap(dataChunks => combineLatest(dataChunks.map(chunk => new TranspilationWorker(chunk).get$()))), map(([metadata, sharedMetadata]) => {
2504
- this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata, config);
2510
+ this.elementsResolver = new ElementsResolver(uiDefinition, metadata ?? [], sharedMetadata, config);
2505
2511
  const componentTypes = this.elementsResolver.getNgComponents();
2506
2512
  const module = this.getModule(componentTypes);
2507
2513
  return {
@@ -2609,7 +2615,7 @@ const migrations = {
2609
2615
  3: uiDef => {
2610
2616
  const startingPage = metadataToElement(constructPage(STARTING_PAGE_NAME, STARTING_PAGE_TYPE, STARTING_PAGE_LAYOUT, STARTING_PAGE_STYLES));
2611
2617
  // overwrite children if provided from the UI Definition
2612
- if (uiDef.children && uiDef.children.length > 0) {
2618
+ if (startingPage.children[0] && uiDef.children && uiDef.children.length > 0) {
2613
2619
  // the starting page has the One Region Layout
2614
2620
  startingPage.children[0].children = uiDef.children;
2615
2621
  }
@@ -2641,7 +2647,11 @@ class MigrationsService {
2641
2647
  try {
2642
2648
  let result = cloneDeep(uiDef);
2643
2649
  for (const version of migrateVersions) {
2644
- result = migrations[version](result);
2650
+ const migration = migrations[version];
2651
+ if (!migration) {
2652
+ throw `V=${version} migration strategy is not defined`;
2653
+ }
2654
+ result = migration(result);
2645
2655
  }
2646
2656
  return result;
2647
2657
  }