@littlebox/strapi-suite 1.0.37 → 1.0.39
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
|
@@ -1635,6 +1635,38 @@ function buildFullSlug(params) {
|
|
|
1635
1635
|
});
|
|
1636
1636
|
return `${parentFullSlug}/${params.page.slug}`;
|
|
1637
1637
|
}
|
|
1638
|
+
function handleAttributes(attributes2) {
|
|
1639
|
+
const query = {};
|
|
1640
|
+
Object.keys(attributes2).forEach((key) => {
|
|
1641
|
+
switch (attributes2[key]["type"]) {
|
|
1642
|
+
case "component":
|
|
1643
|
+
const componentData = strapi.components[attributes2[key]["component"]];
|
|
1644
|
+
query[key] = { populate: handleAttributes(componentData.attributes) };
|
|
1645
|
+
break;
|
|
1646
|
+
case "media":
|
|
1647
|
+
query[key] = { populate: "*" };
|
|
1648
|
+
break;
|
|
1649
|
+
case "relation":
|
|
1650
|
+
if (key === "roles" || key === "users" || key === "createdBy" || key === "updatedBy") break;
|
|
1651
|
+
query[key] = key === "localizations" ? { populate: "*" } : { populate: populateQueryFromContentType(strapi, attributes2[key]["target"]) };
|
|
1652
|
+
break;
|
|
1653
|
+
case "dynamiczone":
|
|
1654
|
+
const components = attributes2[key]["components"];
|
|
1655
|
+
query[key] = { on: {} };
|
|
1656
|
+
components.forEach((component) => {
|
|
1657
|
+
const componentData2 = strapi.components[component];
|
|
1658
|
+
query[key]["on"][component] = { populate: handleAttributes(componentData2.attributes) };
|
|
1659
|
+
});
|
|
1660
|
+
break;
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
return Object.keys(query).length === 0 ? "*" : query;
|
|
1664
|
+
}
|
|
1665
|
+
function populateQueryFromContentType(strapi2, contentType) {
|
|
1666
|
+
const attributes2 = strapi2.contentTypes[contentType]["attributes"];
|
|
1667
|
+
const query = handleAttributes(attributes2);
|
|
1668
|
+
return query;
|
|
1669
|
+
}
|
|
1638
1670
|
const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
1639
1671
|
async adminGetAll() {
|
|
1640
1672
|
const ctx = strapi2.requestContext.get();
|
|
@@ -1744,9 +1776,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1744
1776
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1745
1777
|
};
|
|
1746
1778
|
}
|
|
1779
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1747
1780
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1748
1781
|
locale: page.locale,
|
|
1749
|
-
populate:
|
|
1782
|
+
populate: query,
|
|
1750
1783
|
status: "published",
|
|
1751
1784
|
documentId: page.contentId
|
|
1752
1785
|
});
|
|
@@ -1904,9 +1937,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1904
1937
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1905
1938
|
};
|
|
1906
1939
|
}
|
|
1940
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1907
1941
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1908
1942
|
locale: page.locale,
|
|
1909
|
-
populate:
|
|
1943
|
+
populate: query,
|
|
1910
1944
|
status: "published",
|
|
1911
1945
|
documentId: page.contentId
|
|
1912
1946
|
});
|
package/dist/server/index.mjs
CHANGED
|
@@ -1634,6 +1634,38 @@ function buildFullSlug(params) {
|
|
|
1634
1634
|
});
|
|
1635
1635
|
return `${parentFullSlug}/${params.page.slug}`;
|
|
1636
1636
|
}
|
|
1637
|
+
function handleAttributes(attributes2) {
|
|
1638
|
+
const query = {};
|
|
1639
|
+
Object.keys(attributes2).forEach((key) => {
|
|
1640
|
+
switch (attributes2[key]["type"]) {
|
|
1641
|
+
case "component":
|
|
1642
|
+
const componentData = strapi.components[attributes2[key]["component"]];
|
|
1643
|
+
query[key] = { populate: handleAttributes(componentData.attributes) };
|
|
1644
|
+
break;
|
|
1645
|
+
case "media":
|
|
1646
|
+
query[key] = { populate: "*" };
|
|
1647
|
+
break;
|
|
1648
|
+
case "relation":
|
|
1649
|
+
if (key === "roles" || key === "users" || key === "createdBy" || key === "updatedBy") break;
|
|
1650
|
+
query[key] = key === "localizations" ? { populate: "*" } : { populate: populateQueryFromContentType(strapi, attributes2[key]["target"]) };
|
|
1651
|
+
break;
|
|
1652
|
+
case "dynamiczone":
|
|
1653
|
+
const components = attributes2[key]["components"];
|
|
1654
|
+
query[key] = { on: {} };
|
|
1655
|
+
components.forEach((component) => {
|
|
1656
|
+
const componentData2 = strapi.components[component];
|
|
1657
|
+
query[key]["on"][component] = { populate: handleAttributes(componentData2.attributes) };
|
|
1658
|
+
});
|
|
1659
|
+
break;
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
return Object.keys(query).length === 0 ? "*" : query;
|
|
1663
|
+
}
|
|
1664
|
+
function populateQueryFromContentType(strapi2, contentType) {
|
|
1665
|
+
const attributes2 = strapi2.contentTypes[contentType]["attributes"];
|
|
1666
|
+
const query = handleAttributes(attributes2);
|
|
1667
|
+
return query;
|
|
1668
|
+
}
|
|
1637
1669
|
const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
1638
1670
|
async adminGetAll() {
|
|
1639
1671
|
const ctx = strapi2.requestContext.get();
|
|
@@ -1743,9 +1775,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1743
1775
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1744
1776
|
};
|
|
1745
1777
|
}
|
|
1778
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1746
1779
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1747
1780
|
locale: page.locale,
|
|
1748
|
-
populate:
|
|
1781
|
+
populate: query,
|
|
1749
1782
|
status: "published",
|
|
1750
1783
|
documentId: page.contentId
|
|
1751
1784
|
});
|
|
@@ -1903,9 +1936,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1903
1936
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1904
1937
|
};
|
|
1905
1938
|
}
|
|
1939
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1906
1940
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1907
1941
|
locale: page.locale,
|
|
1908
|
-
populate:
|
|
1942
|
+
populate: query,
|
|
1909
1943
|
status: "published",
|
|
1910
1944
|
documentId: page.contentId
|
|
1911
1945
|
});
|
package/package.json
CHANGED