@websolutespa/bom-mixer-store 1.8.12 → 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,11 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.8.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixing: decorators collectRelations_ depth 0
8
+
3
9
  ## 1.8.12
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -606,9 +606,6 @@ async function optimizeMany_(items) {
606
606
  var import_bom_core5 = require("@websolutespa/bom-core");
607
607
  async function decorateRelation_(store, item, params = {}) {
608
608
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
609
- if (depth === 0) {
610
- return item;
611
- }
612
609
  item = await collectRelations_({ store, params, depth }, item);
613
610
  return item;
614
611
  }
@@ -620,6 +617,9 @@ async function decorateRelations_(store, items, params = {}) {
620
617
  }
621
618
  async function collectRelations_(context, item, relations = []) {
622
619
  if ((0, import_bom_core5.isUnresolvedRelation)(item)) {
620
+ if (context.depth === 0) {
621
+ return item.value;
622
+ }
623
623
  const index = relations.findIndex(
624
624
  (x) => x.relationTo === item.relationTo && x.value === item.value
625
625
  );
package/dist/index.mjs CHANGED
@@ -501,9 +501,6 @@ async function optimizeMany_(items) {
501
501
  import { isArray as isArray2, isObject as isObject2, isUnresolvedRelation } from "@websolutespa/bom-core";
502
502
  async function decorateRelation_(store, item, params = {}) {
503
503
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
504
- if (depth === 0) {
505
- return item;
506
- }
507
504
  item = await collectRelations_({ store, params, depth }, item);
508
505
  return item;
509
506
  }
@@ -515,6 +512,9 @@ async function decorateRelations_(store, items, params = {}) {
515
512
  }
516
513
  async function collectRelations_(context, item, relations = []) {
517
514
  if (isUnresolvedRelation(item)) {
515
+ if (context.depth === 0) {
516
+ return item.value;
517
+ }
518
518
  const index = relations.findIndex(
519
519
  (x) => x.relationTo === item.relationTo && x.value === item.value
520
520
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.8.12",
3
+ "version": "1.8.13",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -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