@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 +6 -0
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/src/decorators/relation.ts +4 -3
package/CHANGELOG.md
CHANGED
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
|
@@ -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
|
-
|
|
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
|