@strapi/content-manager 0.0.0-experimental.dd3311938ac827f1fa8560c8840a9a394f5896c0 → 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4
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/LICENSE +18 -3
- package/dist/_chunks/{ComponentConfigurationPage-y_7iLdmB.js → ComponentConfigurationPage-5ukroXAh.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-y_7iLdmB.js.map → ComponentConfigurationPage-5ukroXAh.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BMajAl1u.mjs → ComponentConfigurationPage-BAgyHiMm.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BMajAl1u.mjs.map → ComponentConfigurationPage-BAgyHiMm.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs → EditConfigurationPage-DmoXawIh.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs.map → EditConfigurationPage-DmoXawIh.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js → EditConfigurationPage-Xp7lun0f.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js.map → EditConfigurationPage-Xp7lun0f.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DWb0DE7R.mjs → EditViewPage-BLsjc5F-.mjs} +46 -46
- package/dist/_chunks/EditViewPage-BLsjc5F-.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-CTTDHKkQ.js → EditViewPage-C-ukDOB7.js} +45 -45
- package/dist/_chunks/EditViewPage-C-ukDOB7.js.map +1 -0
- package/dist/_chunks/{Field-C5Z1Ivdv.js → Field-Bfph5SOd.js} +421 -141
- package/dist/_chunks/Field-Bfph5SOd.js.map +1 -0
- package/dist/_chunks/{Field-DnStdvQw.mjs → Field-Cs7duwWd.mjs} +422 -142
- package/dist/_chunks/Field-Cs7duwWd.mjs.map +1 -0
- package/dist/_chunks/{Form-B81OtW-k.js → Form-CPYqIWDG.js} +25 -26
- package/dist/_chunks/Form-CPYqIWDG.js.map +1 -0
- package/dist/_chunks/{Form-DqGgE55Q.mjs → Form-Dg_GS5TQ.mjs} +27 -28
- package/dist/_chunks/Form-Dg_GS5TQ.mjs.map +1 -0
- package/dist/_chunks/{History-4NbOq2dX.js → History-DNQkXANT.js} +51 -28
- package/dist/_chunks/History-DNQkXANT.js.map +1 -0
- package/dist/_chunks/{History-DS6-HCYX.mjs → History-wrnHqf09.mjs} +52 -29
- package/dist/_chunks/History-wrnHqf09.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CpfstlYY.js → ListConfigurationPage-CUQxfpjT.js} +48 -47
- package/dist/_chunks/ListConfigurationPage-CUQxfpjT.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DQJJltko.mjs → ListConfigurationPage-DScmJVkW.mjs} +49 -49
- package/dist/_chunks/ListConfigurationPage-DScmJVkW.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-CA3I75m5.js → ListViewPage-BsLiH2-2.js} +59 -67
- package/dist/_chunks/ListViewPage-BsLiH2-2.js.map +1 -0
- package/dist/_chunks/{ListViewPage-nQrOQuVo.mjs → ListViewPage-C4IvrMgY.mjs} +60 -68
- package/dist/_chunks/ListViewPage-C4IvrMgY.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js → NoContentTypePage-BZ-PnGAf.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js.map → NoContentTypePage-BZ-PnGAf.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs → NoContentTypePage-Djg8nPlj.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs.map → NoContentTypePage-Djg8nPlj.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs → NoPermissionsPage-DSP7R-hv.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs.map → NoPermissionsPage-DSP7R-hv.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js → NoPermissionsPage-_lUqjGW3.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js.map → NoPermissionsPage-_lUqjGW3.js.map} +1 -1
- package/dist/_chunks/{Relations-BDRl99Ux.mjs → Relations-BZr8tL0R.mjs} +3 -3
- package/dist/_chunks/Relations-BZr8tL0R.mjs.map +1 -0
- package/dist/_chunks/{Relations-DG2jnOcr.js → Relations-CtELXYIK.js} +3 -3
- package/dist/_chunks/Relations-CtELXYIK.js.map +1 -0
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-BrCTWlZv.mjs} +5 -4
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
- package/dist/_chunks/{en-fbKQxLGn.js → en-uOUIxfcQ.js} +5 -4
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-uOUIxfcQ.js.map} +1 -1
- package/dist/_chunks/{index-BZoNZMXL.js → index-OerGjbAN.js} +365 -375
- package/dist/_chunks/index-OerGjbAN.js.map +1 -0
- package/dist/_chunks/{index-Drt2DN7v.mjs → index-c_5DdJi-.mjs} +380 -390
- package/dist/_chunks/index-c_5DdJi-.mjs.map +1 -0
- package/dist/_chunks/{layout-DEYBqgF1.js → layout-Ci7qHlFb.js} +7 -7
- package/dist/_chunks/layout-Ci7qHlFb.js.map +1 -0
- package/dist/_chunks/{layout-BzAbmoO6.mjs → layout-oPBiO7RY.mjs} +8 -8
- package/dist/_chunks/layout-oPBiO7RY.mjs.map +1 -0
- package/dist/_chunks/{relations-D26zVRdi.mjs → relations-BIdWFjdq.mjs} +2 -2
- package/dist/_chunks/{relations-D26zVRdi.mjs.map → relations-BIdWFjdq.mjs.map} +1 -1
- package/dist/_chunks/{relations-D0eZ4VWw.js → relations-COBpStiF.js} +2 -2
- package/dist/_chunks/{relations-D0eZ4VWw.js.map → relations-COBpStiF.js.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +4 -4
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +8 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/server/index.js +41 -34
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +41 -34
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/_chunks/EditViewPage-CTTDHKkQ.js.map +0 -1
- package/dist/_chunks/EditViewPage-DWb0DE7R.mjs.map +0 -1
- package/dist/_chunks/Field-C5Z1Ivdv.js.map +0 -1
- package/dist/_chunks/Field-DnStdvQw.mjs.map +0 -1
- package/dist/_chunks/Form-B81OtW-k.js.map +0 -1
- package/dist/_chunks/Form-DqGgE55Q.mjs.map +0 -1
- package/dist/_chunks/History-4NbOq2dX.js.map +0 -1
- package/dist/_chunks/History-DS6-HCYX.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CpfstlYY.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DQJJltko.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-CA3I75m5.js.map +0 -1
- package/dist/_chunks/ListViewPage-nQrOQuVo.mjs.map +0 -1
- package/dist/_chunks/Relations-BDRl99Ux.mjs.map +0 -1
- package/dist/_chunks/Relations-DG2jnOcr.js.map +0 -1
- package/dist/_chunks/index-BZoNZMXL.js.map +0 -1
- package/dist/_chunks/index-Drt2DN7v.mjs.map +0 -1
- package/dist/_chunks/layout-BzAbmoO6.mjs.map +0 -1
- package/dist/_chunks/layout-DEYBqgF1.js.map +0 -1
package/dist/server/index.mjs
CHANGED
@@ -206,6 +206,10 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
206
206
|
return attributes.reduce((acc, [attributeName, attribute]) => {
|
207
207
|
switch (attribute.type) {
|
208
208
|
case "relation": {
|
209
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
210
|
+
if (isMorphRelation) {
|
211
|
+
break;
|
212
|
+
}
|
209
213
|
const isVisible2 = contentTypes$1.isVisibleAttribute(model, attributeName);
|
210
214
|
if (isVisible2) {
|
211
215
|
acc[attributeName] = { fields: ["documentId", "locale", "publishedAt"] };
|
@@ -469,8 +473,6 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
469
473
|
deleteExpiredJob: null,
|
470
474
|
isInitialized: false
|
471
475
|
};
|
472
|
-
const query = strapi2.db.query(HISTORY_VERSION_UID);
|
473
|
-
const historyService = getService(strapi2, "history");
|
474
476
|
const serviceUtils = createServiceUtils({ strapi: strapi2 });
|
475
477
|
return {
|
476
478
|
async bootstrap() {
|
@@ -526,7 +528,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
526
528
|
}, {});
|
527
529
|
await strapi2.db.transaction(async ({ onCommit }) => {
|
528
530
|
onCommit(() => {
|
529
|
-
|
531
|
+
getService(strapi2, "history").createVersion({
|
530
532
|
contentType: contentTypeUid,
|
531
533
|
data: omit(FIELDS_TO_IGNORE, document),
|
532
534
|
schema: omit(FIELDS_TO_IGNORE, attributesSchema),
|
@@ -542,7 +544,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
542
544
|
state.deleteExpiredJob = scheduleJob("0 0 * * *", () => {
|
543
545
|
const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
|
544
546
|
const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
|
545
|
-
query.deleteMany({
|
547
|
+
strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
|
546
548
|
where: {
|
547
549
|
created_at: {
|
548
550
|
$lt: expirationDate.toISOString()
|
@@ -1567,9 +1569,11 @@ const multipleLocaleSchema = yup$1.lazy(
|
|
1567
1569
|
(value) => Array.isArray(value) ? yup$1.array().of(singleLocaleSchema.required()) : singleLocaleSchema
|
1568
1570
|
);
|
1569
1571
|
const statusSchema = yup$1.mixed().oneOf(["draft", "published"], "Invalid status");
|
1570
|
-
const getDocumentLocaleAndStatus = async (request, opts = { allowMultipleLocales: false }) => {
|
1572
|
+
const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultipleLocales: false }) => {
|
1571
1573
|
const { allowMultipleLocales } = opts;
|
1572
|
-
const { locale, status, ...rest } = request || {};
|
1574
|
+
const { locale, status: providedStatus, ...rest } = request || {};
|
1575
|
+
const defaultStatus = contentTypes$1.hasDraftAndPublish(strapi.getModel(model)) ? void 0 : "published";
|
1576
|
+
const status = providedStatus !== void 0 ? providedStatus : defaultStatus;
|
1573
1577
|
const schema = yup$1.object().shape({
|
1574
1578
|
locale: allowMultipleLocales ? multipleLocaleSchema : singleLocaleSchema,
|
1575
1579
|
status: statusSchema
|
@@ -1617,7 +1621,7 @@ const createDocument = async (ctx, opts) => {
|
|
1617
1621
|
const setCreator = setCreatorFields({ user });
|
1618
1622
|
const sanitizeFn = async.pipe(pickPermittedFields, setCreator);
|
1619
1623
|
const sanitizedBody = await sanitizeFn(body);
|
1620
|
-
const { locale, status
|
1624
|
+
const { locale, status } = await getDocumentLocaleAndStatus(body, model);
|
1621
1625
|
return documentManager2.create(model, {
|
1622
1626
|
data: sanitizedBody,
|
1623
1627
|
locale,
|
@@ -1636,7 +1640,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1636
1640
|
}
|
1637
1641
|
const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
|
1638
1642
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1639
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1643
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1640
1644
|
const [documentVersion, documentExists] = await Promise.all([
|
1641
1645
|
documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
|
1642
1646
|
documentManager2.exists(model, id)
|
@@ -1674,7 +1678,7 @@ const collectionTypes = {
|
|
1674
1678
|
}
|
1675
1679
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
1676
1680
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
|
1677
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
1681
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
1678
1682
|
const { results: documents, pagination: pagination2 } = await documentManager2.findPage(
|
1679
1683
|
{ ...permissionQuery, populate, locale, status },
|
1680
1684
|
model
|
@@ -1709,7 +1713,7 @@ const collectionTypes = {
|
|
1709
1713
|
}
|
1710
1714
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
1711
1715
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1712
|
-
const { locale, status
|
1716
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1713
1717
|
const version = await documentManager2.findOne(id, model, {
|
1714
1718
|
populate,
|
1715
1719
|
locale,
|
@@ -1776,7 +1780,7 @@ const collectionTypes = {
|
|
1776
1780
|
}
|
1777
1781
|
const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
|
1778
1782
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1779
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1783
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1780
1784
|
const document = await documentManager2.findOne(id, model, {
|
1781
1785
|
populate,
|
1782
1786
|
locale,
|
@@ -1821,7 +1825,7 @@ const collectionTypes = {
|
|
1821
1825
|
}
|
1822
1826
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
|
1823
1827
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1824
|
-
const { locale } = await getDocumentLocaleAndStatus(ctx.query);
|
1828
|
+
const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1825
1829
|
const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
|
1826
1830
|
if (documentLocales.length === 0) {
|
1827
1831
|
return ctx.notFound();
|
@@ -1854,7 +1858,7 @@ const collectionTypes = {
|
|
1854
1858
|
if (permissionChecker2.cannot.publish(document)) {
|
1855
1859
|
throw new errors.ForbiddenError();
|
1856
1860
|
}
|
1857
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1861
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1858
1862
|
const publishResult = await documentManager2.publish(document.documentId, model, {
|
1859
1863
|
locale
|
1860
1864
|
// TODO: Allow setting creator fields on publish
|
@@ -1881,7 +1885,9 @@ const collectionTypes = {
|
|
1881
1885
|
}
|
1882
1886
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1883
1887
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1884
|
-
const { locale } = await getDocumentLocaleAndStatus(body, {
|
1888
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1889
|
+
allowMultipleLocales: true
|
1890
|
+
});
|
1885
1891
|
const entityPromises = documentIds.map(
|
1886
1892
|
(documentId) => documentManager2.findLocales(documentId, model, { populate, locale, isPublished: false })
|
1887
1893
|
);
|
@@ -1908,7 +1914,7 @@ const collectionTypes = {
|
|
1908
1914
|
if (permissionChecker2.cannot.unpublish()) {
|
1909
1915
|
return ctx.forbidden();
|
1910
1916
|
}
|
1911
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1917
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1912
1918
|
const entityPromises = documentIds.map(
|
1913
1919
|
(documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
|
1914
1920
|
);
|
@@ -1941,7 +1947,7 @@ const collectionTypes = {
|
|
1941
1947
|
}
|
1942
1948
|
const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
|
1943
1949
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1944
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1950
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1945
1951
|
const document = await documentManager2.findOne(id, model, {
|
1946
1952
|
populate,
|
1947
1953
|
locale,
|
@@ -1978,7 +1984,7 @@ const collectionTypes = {
|
|
1978
1984
|
}
|
1979
1985
|
const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
|
1980
1986
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1981
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1987
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1982
1988
|
const document = await documentManager2.findOne(id, model, {
|
1983
1989
|
populate,
|
1984
1990
|
locale,
|
@@ -2009,7 +2015,7 @@ const collectionTypes = {
|
|
2009
2015
|
}
|
2010
2016
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2011
2017
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2012
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2018
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2013
2019
|
const documentLocales = await documentManager2.findLocales(documentIds, model, {
|
2014
2020
|
populate,
|
2015
2021
|
locale
|
@@ -2036,7 +2042,7 @@ const collectionTypes = {
|
|
2036
2042
|
}
|
2037
2043
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2038
2044
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2039
|
-
const { locale, status
|
2045
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
2040
2046
|
const entity = await documentManager2.findOne(id, model, { populate, locale, status });
|
2041
2047
|
if (!entity) {
|
2042
2048
|
return ctx.notFound();
|
@@ -2059,7 +2065,7 @@ const collectionTypes = {
|
|
2059
2065
|
if (permissionChecker2.cannot.read()) {
|
2060
2066
|
return ctx.forbidden();
|
2061
2067
|
}
|
2062
|
-
const
|
2068
|
+
const documents = await documentManager2.findMany(
|
2063
2069
|
{
|
2064
2070
|
filters: {
|
2065
2071
|
documentId: ids
|
@@ -2068,7 +2074,7 @@ const collectionTypes = {
|
|
2068
2074
|
},
|
2069
2075
|
model
|
2070
2076
|
);
|
2071
|
-
if (!
|
2077
|
+
if (!documents) {
|
2072
2078
|
return ctx.notFound();
|
2073
2079
|
}
|
2074
2080
|
const number = await documentManager2.countManyEntriesDraftRelations(ids, model, locale);
|
@@ -2564,7 +2570,7 @@ const createOrUpdateDocument = async (ctx, opts) => {
|
|
2564
2570
|
throw new errors.ForbiddenError();
|
2565
2571
|
}
|
2566
2572
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.update(query);
|
2567
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2573
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2568
2574
|
const [documentVersion, otherDocumentVersion] = await Promise.all([
|
2569
2575
|
findDocument(sanitizedQuery, model, { locale, status: "draft" }),
|
2570
2576
|
// Find the first document to check if it exists
|
@@ -2605,7 +2611,7 @@ const singleTypes = {
|
|
2605
2611
|
return ctx.forbidden();
|
2606
2612
|
}
|
2607
2613
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
2608
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
2614
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
2609
2615
|
const version = await findDocument(permissionQuery, model, { locale, status });
|
2610
2616
|
if (!version) {
|
2611
2617
|
if (permissionChecker2.cannot.create()) {
|
@@ -2650,7 +2656,7 @@ const singleTypes = {
|
|
2650
2656
|
}
|
2651
2657
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2652
2658
|
const populate = await buildPopulateFromQuery(sanitizedQuery, model);
|
2653
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2659
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2654
2660
|
const documentLocales = await documentManager2.findLocales(void 0, model, {
|
2655
2661
|
populate,
|
2656
2662
|
locale
|
@@ -2687,7 +2693,7 @@ const singleTypes = {
|
|
2687
2693
|
if (permissionChecker2.cannot.publish(document)) {
|
2688
2694
|
throw new errors.ForbiddenError();
|
2689
2695
|
}
|
2690
|
-
const { locale } = await getDocumentLocaleAndStatus(document);
|
2696
|
+
const { locale } = await getDocumentLocaleAndStatus(document, model);
|
2691
2697
|
const publishResult = await documentManager2.publish(document.documentId, model, { locale });
|
2692
2698
|
return publishResult.at(0);
|
2693
2699
|
});
|
@@ -2710,7 +2716,7 @@ const singleTypes = {
|
|
2710
2716
|
return ctx.forbidden();
|
2711
2717
|
}
|
2712
2718
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.unpublish(query);
|
2713
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2719
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2714
2720
|
const document = await findDocument(sanitizedQuery, model, { locale });
|
2715
2721
|
if (!document) {
|
2716
2722
|
return ctx.notFound();
|
@@ -2742,7 +2748,7 @@ const singleTypes = {
|
|
2742
2748
|
return ctx.forbidden();
|
2743
2749
|
}
|
2744
2750
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.discard(query);
|
2745
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2751
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2746
2752
|
const document = await findDocument(sanitizedQuery, model, { locale, status: "published" });
|
2747
2753
|
if (!document) {
|
2748
2754
|
return ctx.notFound();
|
@@ -2762,7 +2768,7 @@ const singleTypes = {
|
|
2762
2768
|
const { query } = ctx.request;
|
2763
2769
|
const documentManager2 = getService$1("document-manager");
|
2764
2770
|
const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
|
2765
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2771
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2766
2772
|
if (permissionChecker2.cannot.read()) {
|
2767
2773
|
return ctx.forbidden();
|
2768
2774
|
}
|
@@ -2783,7 +2789,7 @@ const uid$1 = {
|
|
2783
2789
|
async generateUID(ctx) {
|
2784
2790
|
const { contentTypeUID, field, data } = await validateGenerateUIDInput(ctx.request.body);
|
2785
2791
|
const { query = {} } = ctx.request;
|
2786
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2792
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2787
2793
|
await validateUIDField(contentTypeUID, field);
|
2788
2794
|
const uidService = getService$1("uid");
|
2789
2795
|
ctx.body = {
|
@@ -2795,7 +2801,7 @@ const uid$1 = {
|
|
2795
2801
|
ctx.request.body
|
2796
2802
|
);
|
2797
2803
|
const { query = {} } = ctx.request;
|
2798
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2804
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2799
2805
|
await validateUIDField(contentTypeUID, field);
|
2800
2806
|
const uidService = getService$1("uid");
|
2801
2807
|
const isAvailable = await uidService.checkUIDAvailability({
|
@@ -3720,6 +3726,10 @@ const getDeepPopulateDraftCount = (uid2) => {
|
|
3720
3726
|
const attribute = model.attributes[attributeName];
|
3721
3727
|
switch (attribute.type) {
|
3722
3728
|
case "relation": {
|
3729
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
3730
|
+
if (isMorphRelation) {
|
3731
|
+
break;
|
3732
|
+
}
|
3723
3733
|
if (isVisibleAttribute$1(model, attributeName)) {
|
3724
3734
|
populateAcc[attributeName] = {
|
3725
3735
|
count: true,
|
@@ -4205,10 +4215,7 @@ const documentManager = ({ strapi: strapi2 }) => {
|
|
4205
4215
|
async clone(id, body, uid2) {
|
4206
4216
|
const populate = await buildDeepPopulate(uid2);
|
4207
4217
|
const params = {
|
4208
|
-
data:
|
4209
|
-
...omitIdField(body),
|
4210
|
-
[PUBLISHED_AT_ATTRIBUTE]: null
|
4211
|
-
},
|
4218
|
+
data: omitIdField(body),
|
4212
4219
|
populate
|
4213
4220
|
};
|
4214
4221
|
return strapi2.documents(uid2).clone({ ...params, documentId: id }).then((result) => result?.entries.at(0));
|