@labdigital/commercetools-mock 2.20.1 → 2.20.2
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/dist/index.cjs +14 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/abstract.ts +10 -3
- package/src/repositories/category/index.test.ts +10 -0
- package/src/repositories/category/index.ts +18 -1
package/dist/index.cjs
CHANGED
|
@@ -1798,7 +1798,7 @@ var AbstractResourceRepository = class extends AbstractRepository {
|
|
|
1798
1798
|
id,
|
|
1799
1799
|
params
|
|
1800
1800
|
);
|
|
1801
|
-
return resource ? this.postProcessResource(context, resource) : null;
|
|
1801
|
+
return resource ? this.postProcessResource(context, resource, params) : null;
|
|
1802
1802
|
}
|
|
1803
1803
|
get(context, id, params = {}) {
|
|
1804
1804
|
const resource = this._storage.get(
|
|
@@ -1807,7 +1807,7 @@ var AbstractResourceRepository = class extends AbstractRepository {
|
|
|
1807
1807
|
id,
|
|
1808
1808
|
params
|
|
1809
1809
|
);
|
|
1810
|
-
return resource ? this.postProcessResource(context, resource) : null;
|
|
1810
|
+
return resource ? this.postProcessResource(context, resource, params) : null;
|
|
1811
1811
|
}
|
|
1812
1812
|
getByKey(context, key, params = {}) {
|
|
1813
1813
|
const resource = this._storage.getByKey(
|
|
@@ -1816,9 +1816,9 @@ var AbstractResourceRepository = class extends AbstractRepository {
|
|
|
1816
1816
|
key,
|
|
1817
1817
|
params
|
|
1818
1818
|
);
|
|
1819
|
-
return resource ? this.postProcessResource(context, resource) : null;
|
|
1819
|
+
return resource ? this.postProcessResource(context, resource, params) : null;
|
|
1820
1820
|
}
|
|
1821
|
-
postProcessResource(context, resource) {
|
|
1821
|
+
postProcessResource(context, resource, params) {
|
|
1822
1822
|
return resource;
|
|
1823
1823
|
}
|
|
1824
1824
|
query(context, params = {}) {
|
|
@@ -3090,15 +3090,23 @@ var CategoryRepository = class extends AbstractResourceRepository {
|
|
|
3090
3090
|
};
|
|
3091
3091
|
return this.saveNew(context, resource);
|
|
3092
3092
|
}
|
|
3093
|
-
postProcessResource(context, resource) {
|
|
3093
|
+
postProcessResource(context, resource, params) {
|
|
3094
3094
|
let node = resource;
|
|
3095
3095
|
const ancestors = [];
|
|
3096
|
+
const expandClauses = params?.expand?.map(parseExpandClause) ?? [];
|
|
3097
|
+
const addExpand = expandClauses?.find(
|
|
3098
|
+
(c) => c.element === "ancestors" && c.index === "*"
|
|
3099
|
+
);
|
|
3096
3100
|
while (node.parent) {
|
|
3097
3101
|
node = this._storage.getByResourceIdentifier(
|
|
3098
3102
|
context.projectKey,
|
|
3099
3103
|
node.parent
|
|
3100
3104
|
);
|
|
3101
|
-
ancestors.push({
|
|
3105
|
+
ancestors.push({
|
|
3106
|
+
typeId: "category",
|
|
3107
|
+
id: node.id,
|
|
3108
|
+
obj: addExpand ? node : void 0
|
|
3109
|
+
});
|
|
3102
3110
|
}
|
|
3103
3111
|
resource.ancestors = ancestors;
|
|
3104
3112
|
return resource;
|