@websolutespa/bom-mixer-store 1.8.11 → 1.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.8.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixing: decorators collectRelations_ depth 0
8
+
9
+ ## 1.8.12
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified: menu category decorator
14
+
3
15
  ## 1.8.11
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -424,6 +424,9 @@ function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
424
424
  const route = routes.find((route2) => route2.isDefault && route2.resolvedCategory === category.id);
425
425
  if (route) {
426
426
  decoratedItem.href = route.id;
427
+ if (!decoratedItem.media) {
428
+ decoratedItem.media = route.media;
429
+ }
427
430
  }
428
431
  }
429
432
  let maxDepth = item.maxDepth;
@@ -603,9 +606,6 @@ async function optimizeMany_(items) {
603
606
  var import_bom_core5 = require("@websolutespa/bom-core");
604
607
  async function decorateRelation_(store, item, params = {}) {
605
608
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
606
- if (depth === 0) {
607
- return item;
608
- }
609
609
  item = await collectRelations_({ store, params, depth }, item);
610
610
  return item;
611
611
  }
@@ -617,6 +617,9 @@ async function decorateRelations_(store, items, params = {}) {
617
617
  }
618
618
  async function collectRelations_(context, item, relations = []) {
619
619
  if ((0, import_bom_core5.isUnresolvedRelation)(item)) {
620
+ if (context.depth === 0) {
621
+ return item.value;
622
+ }
620
623
  const index = relations.findIndex(
621
624
  (x) => x.relationTo === item.relationTo && x.value === item.value
622
625
  );
package/dist/index.mjs CHANGED
@@ -319,6 +319,9 @@ function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
319
319
  const route = routes.find((route2) => route2.isDefault && route2.resolvedCategory === category.id);
320
320
  if (route) {
321
321
  decoratedItem.href = route.id;
322
+ if (!decoratedItem.media) {
323
+ decoratedItem.media = route.media;
324
+ }
322
325
  }
323
326
  }
324
327
  let maxDepth = item.maxDepth;
@@ -498,9 +501,6 @@ async function optimizeMany_(items) {
498
501
  import { isArray as isArray2, isObject as isObject2, isUnresolvedRelation } from "@websolutespa/bom-core";
499
502
  async function decorateRelation_(store, item, params = {}) {
500
503
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
501
- if (depth === 0) {
502
- return item;
503
- }
504
504
  item = await collectRelations_({ store, params, depth }, item);
505
505
  return item;
506
506
  }
@@ -512,6 +512,9 @@ async function decorateRelations_(store, items, params = {}) {
512
512
  }
513
513
  async function collectRelations_(context, item, relations = []) {
514
514
  if (isUnresolvedRelation(item)) {
515
+ if (context.depth === 0) {
516
+ return item.value;
517
+ }
515
518
  const index = relations.findIndex(
516
519
  (x) => x.relationTo === item.relationTo && x.value === item.value
517
520
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.8.11",
3
+ "version": "1.8.13",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -139,6 +139,9 @@ function decorateMenuCategory_(
139
139
  const route = routes.find((route: IRoute) => route.isDefault && route.resolvedCategory === category.id);
140
140
  if (route) {
141
141
  (decoratedItem as IMenuCategory).href = route.id;
142
+ if (!decoratedItem.media) {
143
+ decoratedItem.media = route.media;
144
+ }
142
145
  }
143
146
  }
144
147
  // checking for max depth recursion
@@ -3,9 +3,7 @@ import { DEFAULT_DEPTH } from './consts';
3
3
 
4
4
  export async function decorateRelation_<T extends ISchema = ISchema>(store: IStore, item: T, params: QueryParams = {}): Promise<T> {
5
5
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
6
- if (depth === 0) {
7
- return item;
8
- }
6
+ // console.log('decorateRelation_', depth, typeof depth);
9
7
  item = await collectRelations_({ store, params, depth }, item);
10
8
  return item;
11
9
  }
@@ -30,6 +28,9 @@ async function collectRelations_<T = any>(context: {
30
28
  depth: number;
31
29
  }, item: T, relations: IPageResolvedRelation[] = []): Promise<T> {
32
30
  if (isUnresolvedRelation(item)) {
31
+ if (context.depth === 0) {
32
+ return item.value as T;
33
+ }
33
34
  // skip circular reference
34
35
  const index = relations.findIndex(x =>
35
36
  x.relationTo === item.relationTo && x.value === item.value