@littlebox/strapi-suite 1.0.41 → 1.0.42
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/server/index.js
CHANGED
|
@@ -1731,36 +1731,44 @@ async function buildBreadcrumbs(params) {
|
|
|
1731
1731
|
}, []);
|
|
1732
1732
|
return mappedResult;
|
|
1733
1733
|
}
|
|
1734
|
-
function handleAttributes(attributes2) {
|
|
1734
|
+
function handleAttributes(attributes2, level) {
|
|
1735
1735
|
const query = {};
|
|
1736
1736
|
Object.keys(attributes2).forEach((key) => {
|
|
1737
1737
|
switch (attributes2[key]["type"]) {
|
|
1738
1738
|
case "component":
|
|
1739
1739
|
const componentData = strapi.components[attributes2[key]["component"]];
|
|
1740
|
-
query[key] = { populate: handleAttributes(componentData.attributes) };
|
|
1740
|
+
query[key] = { populate: handleAttributes(componentData.attributes, level) };
|
|
1741
1741
|
break;
|
|
1742
1742
|
case "media":
|
|
1743
1743
|
query[key] = { populate: "*" };
|
|
1744
1744
|
break;
|
|
1745
1745
|
case "relation":
|
|
1746
1746
|
if (key === "roles" || key === "users" || key === "createdBy" || key === "updatedBy") break;
|
|
1747
|
-
query[key] = key === "localizations" ? { populate: "*" } : { populate:
|
|
1747
|
+
query[key] = key === "localizations" ? { populate: "*" } : level === 3 ? { populate: "*" } : {
|
|
1748
|
+
populate: populateQueryFromContentType(
|
|
1749
|
+
strapi,
|
|
1750
|
+
attributes2[key]["target"],
|
|
1751
|
+
level + 1
|
|
1752
|
+
)
|
|
1753
|
+
};
|
|
1748
1754
|
break;
|
|
1749
1755
|
case "dynamiczone":
|
|
1750
1756
|
const components = attributes2[key]["components"];
|
|
1751
1757
|
query[key] = { on: {} };
|
|
1752
1758
|
components.forEach((component) => {
|
|
1753
1759
|
const componentData2 = strapi.components[component];
|
|
1754
|
-
query[key]["on"][component] = {
|
|
1760
|
+
query[key]["on"][component] = {
|
|
1761
|
+
populate: handleAttributes(componentData2.attributes, level)
|
|
1762
|
+
};
|
|
1755
1763
|
});
|
|
1756
1764
|
break;
|
|
1757
1765
|
}
|
|
1758
1766
|
});
|
|
1759
1767
|
return Object.keys(query).length === 0 ? "*" : query;
|
|
1760
1768
|
}
|
|
1761
|
-
function populateQueryFromContentType(strapi2, contentType) {
|
|
1769
|
+
function populateQueryFromContentType(strapi2, contentType, level = 1) {
|
|
1762
1770
|
const attributes2 = strapi2.contentTypes[contentType]["attributes"];
|
|
1763
|
-
const query = handleAttributes(attributes2);
|
|
1771
|
+
const query = handleAttributes(attributes2, level);
|
|
1764
1772
|
return query;
|
|
1765
1773
|
}
|
|
1766
1774
|
const SlugModuleService = ({ strapi: strapi2 }) => ({
|
package/dist/server/index.mjs
CHANGED
|
@@ -1730,36 +1730,44 @@ async function buildBreadcrumbs(params) {
|
|
|
1730
1730
|
}, []);
|
|
1731
1731
|
return mappedResult;
|
|
1732
1732
|
}
|
|
1733
|
-
function handleAttributes(attributes2) {
|
|
1733
|
+
function handleAttributes(attributes2, level) {
|
|
1734
1734
|
const query = {};
|
|
1735
1735
|
Object.keys(attributes2).forEach((key) => {
|
|
1736
1736
|
switch (attributes2[key]["type"]) {
|
|
1737
1737
|
case "component":
|
|
1738
1738
|
const componentData = strapi.components[attributes2[key]["component"]];
|
|
1739
|
-
query[key] = { populate: handleAttributes(componentData.attributes) };
|
|
1739
|
+
query[key] = { populate: handleAttributes(componentData.attributes, level) };
|
|
1740
1740
|
break;
|
|
1741
1741
|
case "media":
|
|
1742
1742
|
query[key] = { populate: "*" };
|
|
1743
1743
|
break;
|
|
1744
1744
|
case "relation":
|
|
1745
1745
|
if (key === "roles" || key === "users" || key === "createdBy" || key === "updatedBy") break;
|
|
1746
|
-
query[key] = key === "localizations" ? { populate: "*" } : { populate:
|
|
1746
|
+
query[key] = key === "localizations" ? { populate: "*" } : level === 3 ? { populate: "*" } : {
|
|
1747
|
+
populate: populateQueryFromContentType(
|
|
1748
|
+
strapi,
|
|
1749
|
+
attributes2[key]["target"],
|
|
1750
|
+
level + 1
|
|
1751
|
+
)
|
|
1752
|
+
};
|
|
1747
1753
|
break;
|
|
1748
1754
|
case "dynamiczone":
|
|
1749
1755
|
const components = attributes2[key]["components"];
|
|
1750
1756
|
query[key] = { on: {} };
|
|
1751
1757
|
components.forEach((component) => {
|
|
1752
1758
|
const componentData2 = strapi.components[component];
|
|
1753
|
-
query[key]["on"][component] = {
|
|
1759
|
+
query[key]["on"][component] = {
|
|
1760
|
+
populate: handleAttributes(componentData2.attributes, level)
|
|
1761
|
+
};
|
|
1754
1762
|
});
|
|
1755
1763
|
break;
|
|
1756
1764
|
}
|
|
1757
1765
|
});
|
|
1758
1766
|
return Object.keys(query).length === 0 ? "*" : query;
|
|
1759
1767
|
}
|
|
1760
|
-
function populateQueryFromContentType(strapi2, contentType) {
|
|
1768
|
+
function populateQueryFromContentType(strapi2, contentType, level = 1) {
|
|
1761
1769
|
const attributes2 = strapi2.contentTypes[contentType]["attributes"];
|
|
1762
|
-
const query = handleAttributes(attributes2);
|
|
1770
|
+
const query = handleAttributes(attributes2, level);
|
|
1763
1771
|
return query;
|
|
1764
1772
|
}
|
|
1765
1773
|
const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Core } from '@strapi/strapi';
|
|
2
|
-
export declare function populateQueryFromContentType(strapi: Core.Strapi, contentType: string): any;
|
|
2
|
+
export declare function populateQueryFromContentType(strapi: Core.Strapi, contentType: string, level?: number): any;
|
package/package.json
CHANGED