@strapi/content-manager 0.0.0-experimental.25e22c6cc9bc6b35392bb55d09f641a0a65e7403 → 0.0.0-experimental.2cfaca2410c03f1dee31ca18c06aedfb313e0fb4
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-WRPUXGd6.js → ComponentConfigurationPage-DnnZJc1F.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js.map → ComponentConfigurationPage-DnnZJc1F.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs → ComponentConfigurationPage-hLMNf7KI.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs.map → ComponentConfigurationPage-hLMNf7KI.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js → EditConfigurationPage-CpLj5gYZ.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js.map → EditConfigurationPage-CpLj5gYZ.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs → EditConfigurationPage-Dh6sq-G4.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs.map → EditConfigurationPage-Dh6sq-G4.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-0MiFkXa8.mjs → EditViewPage-BU1ugeVi.mjs} +19 -8
- package/dist/_chunks/EditViewPage-BU1ugeVi.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-DbcGfyqK.js → EditViewPage-D2QVRr_2.js} +19 -8
- package/dist/_chunks/EditViewPage-D2QVRr_2.js.map +1 -0
- package/dist/_chunks/{Field-BG1xu38N.js → Field-BEDX9i_V.js} +465 -145
- package/dist/_chunks/Field-BEDX9i_V.js.map +1 -0
- package/dist/_chunks/{Field-BDMSCcy5.mjs → Field-VSPY6uzs.mjs} +463 -143
- package/dist/_chunks/Field-VSPY6uzs.mjs.map +1 -0
- package/dist/_chunks/{Form-CPVWavB8.mjs → Form-05Oaes1N.mjs} +39 -17
- package/dist/_chunks/Form-05Oaes1N.mjs.map +1 -0
- package/dist/_chunks/{Form-9BnFyUjy.js → Form-DCaY8xBX.js} +39 -17
- package/dist/_chunks/Form-DCaY8xBX.js.map +1 -0
- package/dist/_chunks/{History-BVpd8LP3.mjs → History-BqO2G3MV.mjs} +44 -19
- package/dist/_chunks/History-BqO2G3MV.mjs.map +1 -0
- package/dist/_chunks/{History-BWWxLt2Z.js → History-BrJ1tUvt.js} +44 -19
- package/dist/_chunks/History-BrJ1tUvt.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DozVMKcR.mjs → ListConfigurationPage-C6rsFlme.mjs} +20 -8
- package/dist/_chunks/ListConfigurationPage-C6rsFlme.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-6swzjdAZ.js → ListConfigurationPage-Eane5LKE.js} +20 -8
- package/dist/_chunks/ListConfigurationPage-Eane5LKE.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BlzfjS2Q.js → ListViewPage-Coj-RPsx.js} +61 -43
- package/dist/_chunks/ListViewPage-Coj-RPsx.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Ds0ulgfG.mjs → ListViewPage-yE_zYhcI.mjs} +59 -41
- package/dist/_chunks/ListViewPage-yE_zYhcI.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js → NoContentTypePage-BDJ0dshy.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js.map → NoContentTypePage-BDJ0dshy.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs → NoContentTypePage-NW_FSVdY.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs.map → NoContentTypePage-NW_FSVdY.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js → NoPermissionsPage-BOtb5FTM.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js.map → NoPermissionsPage-BOtb5FTM.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs → NoPermissionsPage-h0I3ImsX.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs.map → NoPermissionsPage-h0I3ImsX.mjs.map} +1 -1
- package/dist/_chunks/{Relations-CcgFTcWo.js → Relations-CVh0DOKv.js} +4 -4
- package/dist/_chunks/Relations-CVh0DOKv.js.map +1 -0
- package/dist/_chunks/{Relations-Dnag3fhV.mjs → Relations-FP0uWpBz.mjs} +4 -4
- package/dist/_chunks/Relations-FP0uWpBz.mjs.map +1 -0
- package/dist/_chunks/{en-fbKQxLGn.js → en-BlhnxQfj.js} +11 -9
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-BlhnxQfj.js.map} +1 -1
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-C8YBvRrK.mjs} +11 -9
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-C8YBvRrK.mjs.map} +1 -1
- package/dist/_chunks/{index-JNNNKUHs.mjs → index-CPCHQ3X_.mjs} +976 -658
- package/dist/_chunks/index-CPCHQ3X_.mjs.map +1 -0
- package/dist/_chunks/{index-CWpLBSt0.js → index-DTKVhcla.js} +968 -650
- package/dist/_chunks/index-DTKVhcla.js.map +1 -0
- package/dist/_chunks/{layout-DC503LnF.mjs → layout-B4UhJ8MJ.mjs} +27 -14
- package/dist/_chunks/layout-B4UhJ8MJ.mjs.map +1 -0
- package/dist/_chunks/{layout--iHdZzRk.js → layout-CWgZzMYf.js} +25 -12
- package/dist/_chunks/layout-CWgZzMYf.js.map +1 -0
- package/dist/_chunks/{relations-CTje5t-a.mjs → relations-B83Ge9a7.mjs} +2 -2
- package/dist/_chunks/{relations-CTje5t-a.mjs.map → relations-B83Ge9a7.mjs.map} +1 -1
- package/dist/_chunks/{relations-BbHizA5K.js → relations-D81a_2zw.js} +2 -2
- package/dist/_chunks/{relations-BbHizA5K.js.map → relations-D81a_2zw.js.map} +1 -1
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +30 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -0
- 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/EditorLayout.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
- package/dist/admin/src/pages/EditView/components/Header.d.ts +10 -11
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +19 -17
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/validation.d.ts +4 -1
- package/dist/server/index.js +185 -113
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +186 -114
- 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/relations.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/history.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 +2 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/_chunks/EditViewPage-0MiFkXa8.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DbcGfyqK.js.map +0 -1
- package/dist/_chunks/Field-BDMSCcy5.mjs.map +0 -1
- package/dist/_chunks/Field-BG1xu38N.js.map +0 -1
- package/dist/_chunks/Form-9BnFyUjy.js.map +0 -1
- package/dist/_chunks/Form-CPVWavB8.mjs.map +0 -1
- package/dist/_chunks/History-BVpd8LP3.mjs.map +0 -1
- package/dist/_chunks/History-BWWxLt2Z.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-6swzjdAZ.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DozVMKcR.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BlzfjS2Q.js.map +0 -1
- package/dist/_chunks/ListViewPage-Ds0ulgfG.mjs.map +0 -1
- package/dist/_chunks/Relations-CcgFTcWo.js.map +0 -1
- package/dist/_chunks/Relations-Dnag3fhV.mjs.map +0 -1
- package/dist/_chunks/index-CWpLBSt0.js.map +0 -1
- package/dist/_chunks/index-JNNNKUHs.mjs.map +0 -1
- package/dist/_chunks/layout--iHdZzRk.js.map +0 -1
- package/dist/_chunks/layout-DC503LnF.mjs.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
package/dist/server/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import strapiUtils, { validateYupSchema, errors, async, contentTypes as contentTypes$1, yup as yup$1, validateYupSchemaSync, policy, traverse, setCreatorFields, isOperatorOfType, relations as relations$1, traverseEntity, pagination } from "@strapi/utils";
|
2
|
-
import { pick, omit, difference, intersection, pipe, propOr, isEqual, isEmpty, set, has, prop, assoc, mapValues, flow, uniq, uniqBy, concat,
|
2
|
+
import { pick, omit, difference, castArray, intersection, pipe, propOr, isEqual, isEmpty, set, isNil as isNil$1, has, prop, assoc, mapValues, flow, uniq, uniqBy, concat, getOr, propEq, merge, groupBy } from "lodash/fp";
|
3
3
|
import "@strapi/types";
|
4
4
|
import * as yup from "yup";
|
5
5
|
import { scheduleJob } from "node-schedule";
|
@@ -173,7 +173,9 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
173
173
|
return strapi2.db.query("plugin::upload.file").findOne({ where: { id: versionRelationData.id } });
|
174
174
|
};
|
175
175
|
const localesService = strapi2.plugin("i18n")?.service("locales");
|
176
|
+
const i18nContentTypeService = strapi2.plugin("i18n")?.service("content-types");
|
176
177
|
const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
|
178
|
+
const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
|
177
179
|
const getLocaleDictionary = async () => {
|
178
180
|
if (!localesService)
|
179
181
|
return {};
|
@@ -200,20 +202,25 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
200
202
|
const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
|
201
203
|
return documentMetadataService.getStatus(document, meta.availableStatus);
|
202
204
|
};
|
203
|
-
const getDeepPopulate2 = (uid2) => {
|
205
|
+
const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
|
204
206
|
const model = strapi2.getModel(uid2);
|
205
207
|
const attributes = Object.entries(model.attributes);
|
208
|
+
const fieldSelector = useDatabaseSyntax ? "select" : "fields";
|
206
209
|
return attributes.reduce((acc, [attributeName, attribute]) => {
|
207
210
|
switch (attribute.type) {
|
208
211
|
case "relation": {
|
212
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
213
|
+
if (isMorphRelation) {
|
214
|
+
break;
|
215
|
+
}
|
209
216
|
const isVisible2 = contentTypes$1.isVisibleAttribute(model, attributeName);
|
210
217
|
if (isVisible2) {
|
211
|
-
acc[attributeName] = {
|
218
|
+
acc[attributeName] = { [fieldSelector]: ["documentId", "locale", "publishedAt"] };
|
212
219
|
}
|
213
220
|
break;
|
214
221
|
}
|
215
222
|
case "media": {
|
216
|
-
acc[attributeName] = {
|
223
|
+
acc[attributeName] = { [fieldSelector]: ["id"] };
|
217
224
|
break;
|
218
225
|
}
|
219
226
|
case "component": {
|
@@ -286,6 +293,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
286
293
|
getRelationRestoreValue,
|
287
294
|
getMediaRestoreValue,
|
288
295
|
getDefaultLocale,
|
296
|
+
isLocalizedContentType,
|
289
297
|
getLocaleDictionary,
|
290
298
|
getRetentionDays,
|
291
299
|
getVersionStatus,
|
@@ -308,7 +316,13 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
308
316
|
});
|
309
317
|
},
|
310
318
|
async findVersionsPage(params) {
|
311
|
-
const
|
319
|
+
const model = strapi2.getModel(params.query.contentType);
|
320
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
|
321
|
+
const defaultLocale = await serviceUtils.getDefaultLocale();
|
322
|
+
let locale = null;
|
323
|
+
if (isLocalizedContentType) {
|
324
|
+
locale = params.query.locale || defaultLocale;
|
325
|
+
}
|
312
326
|
const [{ results, pagination: pagination2 }, localeDictionary] = await Promise.all([
|
313
327
|
query.findPage({
|
314
328
|
...params.query,
|
@@ -464,13 +478,47 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
464
478
|
}
|
465
479
|
};
|
466
480
|
};
|
481
|
+
const shouldCreateHistoryVersion = (context) => {
|
482
|
+
if (!strapi.requestContext.get()?.request.url.startsWith("/content-manager")) {
|
483
|
+
return false;
|
484
|
+
}
|
485
|
+
if (context.action !== "create" && context.action !== "update" && context.action !== "clone" && context.action !== "publish" && context.action !== "unpublish" && context.action !== "discardDraft") {
|
486
|
+
return false;
|
487
|
+
}
|
488
|
+
if (context.action === "update" && strapi.requestContext.get()?.request.url.endsWith("/actions/publish")) {
|
489
|
+
return false;
|
490
|
+
}
|
491
|
+
if (!context.contentType.uid.startsWith("api::")) {
|
492
|
+
return false;
|
493
|
+
}
|
494
|
+
return true;
|
495
|
+
};
|
496
|
+
const getSchemas = (uid2) => {
|
497
|
+
const attributesSchema = strapi.getModel(uid2).attributes;
|
498
|
+
const componentsSchemas = Object.keys(attributesSchema).reduce(
|
499
|
+
(currentComponentSchemas, key) => {
|
500
|
+
const fieldSchema = attributesSchema[key];
|
501
|
+
if (fieldSchema.type === "component") {
|
502
|
+
const componentSchema = strapi.getModel(fieldSchema.component).attributes;
|
503
|
+
return {
|
504
|
+
...currentComponentSchemas,
|
505
|
+
[fieldSchema.component]: componentSchema
|
506
|
+
};
|
507
|
+
}
|
508
|
+
return currentComponentSchemas;
|
509
|
+
},
|
510
|
+
{}
|
511
|
+
);
|
512
|
+
return {
|
513
|
+
schema: omit(FIELDS_TO_IGNORE, attributesSchema),
|
514
|
+
componentsSchemas
|
515
|
+
};
|
516
|
+
};
|
467
517
|
const createLifecyclesService = ({ strapi: strapi2 }) => {
|
468
518
|
const state = {
|
469
519
|
deleteExpiredJob: null,
|
470
520
|
isInitialized: false
|
471
521
|
};
|
472
|
-
const query = strapi2.db.query(HISTORY_VERSION_UID);
|
473
|
-
const historyService = getService(strapi2, "history");
|
474
522
|
const serviceUtils = createServiceUtils({ strapi: strapi2 });
|
475
523
|
return {
|
476
524
|
async bootstrap() {
|
@@ -478,63 +526,45 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
478
526
|
return;
|
479
527
|
}
|
480
528
|
strapi2.documents.use(async (context, next) => {
|
481
|
-
if (!strapi2.requestContext.get()?.request.url.startsWith("/content-manager")) {
|
482
|
-
return next();
|
483
|
-
}
|
484
|
-
if (context.action !== "create" && context.action !== "update" && context.action !== "clone" && context.action !== "publish" && context.action !== "unpublish" && context.action !== "discardDraft") {
|
485
|
-
return next();
|
486
|
-
}
|
487
|
-
if (context.action === "update" && strapi2.requestContext.get()?.request.url.endsWith("/actions/publish")) {
|
488
|
-
return next();
|
489
|
-
}
|
490
|
-
const contentTypeUid = context.contentType.uid;
|
491
|
-
if (!contentTypeUid.startsWith("api::")) {
|
492
|
-
return next();
|
493
|
-
}
|
494
529
|
const result = await next();
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
530
|
+
if (!shouldCreateHistoryVersion(context)) {
|
531
|
+
return result;
|
532
|
+
}
|
533
|
+
const documentId = context.action === "create" || context.action === "clone" ? result.documentId : context.params.documentId;
|
499
534
|
const defaultLocale = await serviceUtils.getDefaultLocale();
|
500
|
-
const
|
501
|
-
if (
|
502
|
-
|
503
|
-
"[Content manager history middleware]: An array of locales was provided, but only a single locale is supported for the findOne operation."
|
504
|
-
);
|
505
|
-
return next();
|
535
|
+
const locales = castArray(context.params?.locale || defaultLocale);
|
536
|
+
if (!locales.length) {
|
537
|
+
return result;
|
506
538
|
}
|
507
|
-
const
|
508
|
-
|
509
|
-
|
510
|
-
|
539
|
+
const uid2 = context.contentType.uid;
|
540
|
+
const schemas = getSchemas(uid2);
|
541
|
+
const model = strapi2.getModel(uid2);
|
542
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
|
543
|
+
const localeEntries = await strapi2.db.query(uid2).findMany({
|
544
|
+
where: {
|
545
|
+
documentId,
|
546
|
+
...isLocalizedContentType ? { locale: { $in: locales } } : {},
|
547
|
+
...contentTypes$1.hasDraftAndPublish(strapi2.contentTypes[uid2]) ? { publishedAt: null } : {}
|
548
|
+
},
|
549
|
+
populate: serviceUtils.getDeepPopulate(
|
550
|
+
uid2,
|
551
|
+
true
|
552
|
+
/* use database syntax */
|
553
|
+
)
|
511
554
|
});
|
512
|
-
const status = await serviceUtils.getVersionStatus(contentTypeUid, document);
|
513
|
-
const attributesSchema = strapi2.getModel(contentTypeUid).attributes;
|
514
|
-
const componentsSchemas = Object.keys(
|
515
|
-
attributesSchema
|
516
|
-
).reduce((currentComponentSchemas, key) => {
|
517
|
-
const fieldSchema = attributesSchema[key];
|
518
|
-
if (fieldSchema.type === "component") {
|
519
|
-
const componentSchema = strapi2.getModel(fieldSchema.component).attributes;
|
520
|
-
return {
|
521
|
-
...currentComponentSchemas,
|
522
|
-
[fieldSchema.component]: componentSchema
|
523
|
-
};
|
524
|
-
}
|
525
|
-
return currentComponentSchemas;
|
526
|
-
}, {});
|
527
555
|
await strapi2.db.transaction(async ({ onCommit }) => {
|
528
|
-
onCommit(() => {
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
556
|
+
onCommit(async () => {
|
557
|
+
for (const entry of localeEntries) {
|
558
|
+
const status = await serviceUtils.getVersionStatus(uid2, entry);
|
559
|
+
await getService(strapi2, "history").createVersion({
|
560
|
+
contentType: uid2,
|
561
|
+
data: omit(FIELDS_TO_IGNORE, entry),
|
562
|
+
relatedDocumentId: documentId,
|
563
|
+
locale: entry.locale,
|
564
|
+
status,
|
565
|
+
...schemas
|
566
|
+
});
|
567
|
+
}
|
538
568
|
});
|
539
569
|
});
|
540
570
|
return result;
|
@@ -542,7 +572,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
542
572
|
state.deleteExpiredJob = scheduleJob("0 0 * * *", () => {
|
543
573
|
const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
|
544
574
|
const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
|
545
|
-
query.deleteMany({
|
575
|
+
strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
|
546
576
|
where: {
|
547
577
|
created_at: {
|
548
578
|
$lt: expirationDate.toISOString()
|
@@ -1174,6 +1204,11 @@ const { createPolicy } = policy;
|
|
1174
1204
|
const hasPermissions = createPolicy({
|
1175
1205
|
name: "plugin::content-manager.hasPermissions",
|
1176
1206
|
validator: validateHasPermissionsInput,
|
1207
|
+
/**
|
1208
|
+
* NOTE: Action aliases are currently not checked at this level (policy).
|
1209
|
+
* This is currently the intended behavior to avoid changing the behavior of API related permissions.
|
1210
|
+
* If you want to add support for it, please create a dedicated RFC with a list of potential side effect this could have.
|
1211
|
+
*/
|
1177
1212
|
handler(ctx, config = {}) {
|
1178
1213
|
const { actions = [], hasAtLeastOne = false } = config;
|
1179
1214
|
const { userAbility } = ctx.state;
|
@@ -1567,9 +1602,11 @@ const multipleLocaleSchema = yup$1.lazy(
|
|
1567
1602
|
(value) => Array.isArray(value) ? yup$1.array().of(singleLocaleSchema.required()) : singleLocaleSchema
|
1568
1603
|
);
|
1569
1604
|
const statusSchema = yup$1.mixed().oneOf(["draft", "published"], "Invalid status");
|
1570
|
-
const getDocumentLocaleAndStatus = async (request, opts = { allowMultipleLocales: false }) => {
|
1605
|
+
const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultipleLocales: false }) => {
|
1571
1606
|
const { allowMultipleLocales } = opts;
|
1572
|
-
const { locale, status, ...rest } = request || {};
|
1607
|
+
const { locale, status: providedStatus, ...rest } = request || {};
|
1608
|
+
const defaultStatus = contentTypes$1.hasDraftAndPublish(strapi.getModel(model)) ? void 0 : "published";
|
1609
|
+
const status = providedStatus !== void 0 ? providedStatus : defaultStatus;
|
1573
1610
|
const schema = yup$1.object().shape({
|
1574
1611
|
locale: allowMultipleLocales ? multipleLocaleSchema : singleLocaleSchema,
|
1575
1612
|
status: statusSchema
|
@@ -1617,7 +1654,7 @@ const createDocument = async (ctx, opts) => {
|
|
1617
1654
|
const setCreator = setCreatorFields({ user });
|
1618
1655
|
const sanitizeFn = async.pipe(pickPermittedFields, setCreator);
|
1619
1656
|
const sanitizedBody = await sanitizeFn(body);
|
1620
|
-
const { locale, status
|
1657
|
+
const { locale, status } = await getDocumentLocaleAndStatus(body, model);
|
1621
1658
|
return documentManager2.create(model, {
|
1622
1659
|
data: sanitizedBody,
|
1623
1660
|
locale,
|
@@ -1636,7 +1673,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1636
1673
|
}
|
1637
1674
|
const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
|
1638
1675
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1639
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1676
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1640
1677
|
const [documentVersion, documentExists] = await Promise.all([
|
1641
1678
|
documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
|
1642
1679
|
documentManager2.exists(model, id)
|
@@ -1674,7 +1711,7 @@ const collectionTypes = {
|
|
1674
1711
|
}
|
1675
1712
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
1676
1713
|
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);
|
1714
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
1678
1715
|
const { results: documents, pagination: pagination2 } = await documentManager2.findPage(
|
1679
1716
|
{ ...permissionQuery, populate, locale, status },
|
1680
1717
|
model
|
@@ -1709,7 +1746,7 @@ const collectionTypes = {
|
|
1709
1746
|
}
|
1710
1747
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
1711
1748
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1712
|
-
const { locale, status
|
1749
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1713
1750
|
const version = await documentManager2.findOne(id, model, {
|
1714
1751
|
populate,
|
1715
1752
|
locale,
|
@@ -1724,7 +1761,7 @@ const collectionTypes = {
|
|
1724
1761
|
permissionChecker2,
|
1725
1762
|
model,
|
1726
1763
|
// @ts-expect-error TODO: fix
|
1727
|
-
{ id, locale, publishedAt: null },
|
1764
|
+
{ documentId: id, locale, publishedAt: null },
|
1728
1765
|
{ availableLocales: true, availableStatus: false }
|
1729
1766
|
);
|
1730
1767
|
ctx.body = { data: {}, meta };
|
@@ -1776,7 +1813,7 @@ const collectionTypes = {
|
|
1776
1813
|
}
|
1777
1814
|
const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
|
1778
1815
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1779
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1816
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1780
1817
|
const document = await documentManager2.findOne(id, model, {
|
1781
1818
|
populate,
|
1782
1819
|
locale,
|
@@ -1821,7 +1858,7 @@ const collectionTypes = {
|
|
1821
1858
|
}
|
1822
1859
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
|
1823
1860
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1824
|
-
const { locale } = await getDocumentLocaleAndStatus(ctx.query);
|
1861
|
+
const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1825
1862
|
const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
|
1826
1863
|
if (documentLocales.length === 0) {
|
1827
1864
|
return ctx.notFound();
|
@@ -1850,11 +1887,28 @@ const collectionTypes = {
|
|
1850
1887
|
const publishedDocument = await strapi.db.transaction(async () => {
|
1851
1888
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1852
1889
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1853
|
-
|
1890
|
+
let document;
|
1891
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1892
|
+
const isCreate = isNil$1(id);
|
1893
|
+
if (isCreate) {
|
1894
|
+
if (permissionChecker2.cannot.create()) {
|
1895
|
+
throw new errors.ForbiddenError();
|
1896
|
+
}
|
1897
|
+
document = await createDocument(ctx, { populate });
|
1898
|
+
}
|
1899
|
+
const isUpdate = !isCreate;
|
1900
|
+
if (isUpdate) {
|
1901
|
+
document = await documentManager2.findOne(id, model, { populate, locale });
|
1902
|
+
if (!document) {
|
1903
|
+
throw new errors.NotFoundError("Document not found");
|
1904
|
+
}
|
1905
|
+
if (permissionChecker2.can.update(document)) {
|
1906
|
+
await updateDocument(ctx);
|
1907
|
+
}
|
1908
|
+
}
|
1854
1909
|
if (permissionChecker2.cannot.publish(document)) {
|
1855
1910
|
throw new errors.ForbiddenError();
|
1856
1911
|
}
|
1857
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1858
1912
|
const publishResult = await documentManager2.publish(document.documentId, model, {
|
1859
1913
|
locale
|
1860
1914
|
// TODO: Allow setting creator fields on publish
|
@@ -1881,7 +1935,9 @@ const collectionTypes = {
|
|
1881
1935
|
}
|
1882
1936
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1883
1937
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1884
|
-
const { locale } = await getDocumentLocaleAndStatus(body, {
|
1938
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1939
|
+
allowMultipleLocales: true
|
1940
|
+
});
|
1885
1941
|
const entityPromises = documentIds.map(
|
1886
1942
|
(documentId) => documentManager2.findLocales(documentId, model, { populate, locale, isPublished: false })
|
1887
1943
|
);
|
@@ -1908,7 +1964,9 @@ const collectionTypes = {
|
|
1908
1964
|
if (permissionChecker2.cannot.unpublish()) {
|
1909
1965
|
return ctx.forbidden();
|
1910
1966
|
}
|
1911
|
-
const { locale } = await getDocumentLocaleAndStatus(body
|
1967
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1968
|
+
allowMultipleLocales: true
|
1969
|
+
});
|
1912
1970
|
const entityPromises = documentIds.map(
|
1913
1971
|
(documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
|
1914
1972
|
);
|
@@ -1941,7 +1999,7 @@ const collectionTypes = {
|
|
1941
1999
|
}
|
1942
2000
|
const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
|
1943
2001
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1944
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2002
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1945
2003
|
const document = await documentManager2.findOne(id, model, {
|
1946
2004
|
populate,
|
1947
2005
|
locale,
|
@@ -1978,7 +2036,7 @@ const collectionTypes = {
|
|
1978
2036
|
}
|
1979
2037
|
const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
|
1980
2038
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1981
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2039
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1982
2040
|
const document = await documentManager2.findOne(id, model, {
|
1983
2041
|
populate,
|
1984
2042
|
locale,
|
@@ -2009,7 +2067,7 @@ const collectionTypes = {
|
|
2009
2067
|
}
|
2010
2068
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2011
2069
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2012
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2070
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2013
2071
|
const documentLocales = await documentManager2.findLocales(documentIds, model, {
|
2014
2072
|
populate,
|
2015
2073
|
locale
|
@@ -2036,7 +2094,7 @@ const collectionTypes = {
|
|
2036
2094
|
}
|
2037
2095
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2038
2096
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2039
|
-
const { locale, status
|
2097
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
2040
2098
|
const entity = await documentManager2.findOne(id, model, { populate, locale, status });
|
2041
2099
|
if (!entity) {
|
2042
2100
|
return ctx.notFound();
|
@@ -2059,7 +2117,7 @@ const collectionTypes = {
|
|
2059
2117
|
if (permissionChecker2.cannot.read()) {
|
2060
2118
|
return ctx.forbidden();
|
2061
2119
|
}
|
2062
|
-
const
|
2120
|
+
const documents = await documentManager2.findMany(
|
2063
2121
|
{
|
2064
2122
|
filters: {
|
2065
2123
|
documentId: ids
|
@@ -2068,7 +2126,7 @@ const collectionTypes = {
|
|
2068
2126
|
},
|
2069
2127
|
model
|
2070
2128
|
);
|
2071
|
-
if (!
|
2129
|
+
if (!documents) {
|
2072
2130
|
return ctx.notFound();
|
2073
2131
|
}
|
2074
2132
|
const number = await documentManager2.countManyEntriesDraftRelations(ids, model, locale);
|
@@ -2259,20 +2317,13 @@ const sanitizeMainField = (model, mainField, userAbility) => {
|
|
2259
2317
|
userAbility,
|
2260
2318
|
model: model.uid
|
2261
2319
|
});
|
2262
|
-
|
2320
|
+
const isMainFieldListable = isListable(model, mainField);
|
2321
|
+
const canReadMainField = permissionChecker2.can.read(null, mainField);
|
2322
|
+
if (!isMainFieldListable || !canReadMainField) {
|
2263
2323
|
return "id";
|
2264
2324
|
}
|
2265
|
-
if (
|
2266
|
-
|
2267
|
-
const userPermissionChecker = getService$1("permission-checker").create({
|
2268
|
-
userAbility,
|
2269
|
-
model: "plugin::users-permissions.user"
|
2270
|
-
});
|
2271
|
-
if (userPermissionChecker.can.read()) {
|
2272
|
-
return "name";
|
2273
|
-
}
|
2274
|
-
}
|
2275
|
-
return "id";
|
2325
|
+
if (model.uid === "plugin::users-permissions.role") {
|
2326
|
+
return "name";
|
2276
2327
|
}
|
2277
2328
|
return mainField;
|
2278
2329
|
};
|
@@ -2472,8 +2523,9 @@ const relations = {
|
|
2472
2523
|
} else {
|
2473
2524
|
where.id = id;
|
2474
2525
|
}
|
2475
|
-
|
2476
|
-
|
2526
|
+
const publishedAt = getPublishedAtClause(status, targetUid);
|
2527
|
+
if (!isEmpty(publishedAt)) {
|
2528
|
+
where[`${alias}.published_at`] = publishedAt;
|
2477
2529
|
}
|
2478
2530
|
if (filterByLocale) {
|
2479
2531
|
where[`${alias}.locale`] = locale;
|
@@ -2530,9 +2582,7 @@ const relations = {
|
|
2530
2582
|
addFiltersClause(permissionQuery, { id: { $in: loadedIds } });
|
2531
2583
|
const sanitizedRes = await loadRelations({ id: entryId }, targetField, {
|
2532
2584
|
...strapi.get("query-params").transform(targetUid, permissionQuery),
|
2533
|
-
ordering: "desc"
|
2534
|
-
page: ctx.request.query.page,
|
2535
|
-
pageSize: ctx.request.query.pageSize
|
2585
|
+
ordering: "desc"
|
2536
2586
|
});
|
2537
2587
|
const relationsUnion = uniqBy("id", concat(sanitizedRes.results, res.results));
|
2538
2588
|
ctx.body = {
|
@@ -2564,7 +2614,7 @@ const createOrUpdateDocument = async (ctx, opts) => {
|
|
2564
2614
|
throw new errors.ForbiddenError();
|
2565
2615
|
}
|
2566
2616
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.update(query);
|
2567
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2617
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2568
2618
|
const [documentVersion, otherDocumentVersion] = await Promise.all([
|
2569
2619
|
findDocument(sanitizedQuery, model, { locale, status: "draft" }),
|
2570
2620
|
// Find the first document to check if it exists
|
@@ -2605,7 +2655,7 @@ const singleTypes = {
|
|
2605
2655
|
return ctx.forbidden();
|
2606
2656
|
}
|
2607
2657
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
2608
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
2658
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
2609
2659
|
const version = await findDocument(permissionQuery, model, { locale, status });
|
2610
2660
|
if (!version) {
|
2611
2661
|
if (permissionChecker2.cannot.create()) {
|
@@ -2619,7 +2669,7 @@ const singleTypes = {
|
|
2619
2669
|
permissionChecker2,
|
2620
2670
|
model,
|
2621
2671
|
// @ts-expect-error - fix types
|
2622
|
-
{
|
2672
|
+
{ documentId: document.documentId, locale, publishedAt: null },
|
2623
2673
|
{ availableLocales: true, availableStatus: false }
|
2624
2674
|
);
|
2625
2675
|
ctx.body = { data: {}, meta };
|
@@ -2650,7 +2700,7 @@ const singleTypes = {
|
|
2650
2700
|
}
|
2651
2701
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2652
2702
|
const populate = await buildPopulateFromQuery(sanitizedQuery, model);
|
2653
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2703
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2654
2704
|
const documentLocales = await documentManager2.findLocales(void 0, model, {
|
2655
2705
|
populate,
|
2656
2706
|
locale
|
@@ -2687,7 +2737,7 @@ const singleTypes = {
|
|
2687
2737
|
if (permissionChecker2.cannot.publish(document)) {
|
2688
2738
|
throw new errors.ForbiddenError();
|
2689
2739
|
}
|
2690
|
-
const { locale } = await getDocumentLocaleAndStatus(document);
|
2740
|
+
const { locale } = await getDocumentLocaleAndStatus(document, model);
|
2691
2741
|
const publishResult = await documentManager2.publish(document.documentId, model, { locale });
|
2692
2742
|
return publishResult.at(0);
|
2693
2743
|
});
|
@@ -2710,7 +2760,7 @@ const singleTypes = {
|
|
2710
2760
|
return ctx.forbidden();
|
2711
2761
|
}
|
2712
2762
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.unpublish(query);
|
2713
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2763
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2714
2764
|
const document = await findDocument(sanitizedQuery, model, { locale });
|
2715
2765
|
if (!document) {
|
2716
2766
|
return ctx.notFound();
|
@@ -2742,7 +2792,7 @@ const singleTypes = {
|
|
2742
2792
|
return ctx.forbidden();
|
2743
2793
|
}
|
2744
2794
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.discard(query);
|
2745
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2795
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2746
2796
|
const document = await findDocument(sanitizedQuery, model, { locale, status: "published" });
|
2747
2797
|
if (!document) {
|
2748
2798
|
return ctx.notFound();
|
@@ -2762,7 +2812,7 @@ const singleTypes = {
|
|
2762
2812
|
const { query } = ctx.request;
|
2763
2813
|
const documentManager2 = getService$1("document-manager");
|
2764
2814
|
const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
|
2765
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2815
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2766
2816
|
if (permissionChecker2.cannot.read()) {
|
2767
2817
|
return ctx.forbidden();
|
2768
2818
|
}
|
@@ -2783,7 +2833,7 @@ const uid$1 = {
|
|
2783
2833
|
async generateUID(ctx) {
|
2784
2834
|
const { contentTypeUID, field, data } = await validateGenerateUIDInput(ctx.request.body);
|
2785
2835
|
const { query = {} } = ctx.request;
|
2786
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2836
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2787
2837
|
await validateUIDField(contentTypeUID, field);
|
2788
2838
|
const uidService = getService$1("uid");
|
2789
2839
|
ctx.body = {
|
@@ -2795,7 +2845,7 @@ const uid$1 = {
|
|
2795
2845
|
ctx.request.body
|
2796
2846
|
);
|
2797
2847
|
const { query = {} } = ctx.request;
|
2798
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2848
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2799
2849
|
await validateUIDField(contentTypeUID, field);
|
2800
2850
|
const uidService = getService$1("uid");
|
2801
2851
|
const isAvailable = await uidService.checkUIDAvailability({
|
@@ -3438,12 +3488,27 @@ const createPermissionChecker = (strapi2) => ({ userAbility, model }) => {
|
|
3438
3488
|
ability: userAbility,
|
3439
3489
|
model
|
3440
3490
|
});
|
3441
|
-
const
|
3491
|
+
const { actionProvider } = strapi2.service("admin::permission");
|
3492
|
+
const toSubject = (entity) => {
|
3493
|
+
return entity ? permissionsManager.toSubject(entity, model) : model;
|
3494
|
+
};
|
3442
3495
|
const can = (action, entity, field) => {
|
3443
|
-
|
3496
|
+
const subject = toSubject(entity);
|
3497
|
+
const aliases = actionProvider.unstable_aliases(action, model);
|
3498
|
+
return (
|
3499
|
+
// Test the original action to see if it passes
|
3500
|
+
userAbility.can(action, subject, field) || // Else try every known alias if at least one of them succeed, then the user "can"
|
3501
|
+
aliases.some((alias) => userAbility.can(alias, subject, field))
|
3502
|
+
);
|
3444
3503
|
};
|
3445
3504
|
const cannot = (action, entity, field) => {
|
3446
|
-
|
3505
|
+
const subject = toSubject(entity);
|
3506
|
+
const aliases = actionProvider.unstable_aliases(action, model);
|
3507
|
+
return (
|
3508
|
+
// Test both the original action
|
3509
|
+
userAbility.cannot(action, subject, field) && // and every known alias, if all of them fail (cannot), then the user truly "cannot"
|
3510
|
+
aliases.every((alias) => userAbility.cannot(alias, subject, field))
|
3511
|
+
);
|
3447
3512
|
};
|
3448
3513
|
const sanitizeOutput = (data, { action = ACTIONS.read } = {}) => {
|
3449
3514
|
return permissionsManager.sanitizeOutput(data, { subject: toSubject(data), action });
|
@@ -3720,6 +3785,10 @@ const getDeepPopulateDraftCount = (uid2) => {
|
|
3720
3785
|
const attribute = model.attributes[attributeName];
|
3721
3786
|
switch (attribute.type) {
|
3722
3787
|
case "relation": {
|
3788
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
3789
|
+
if (isMorphRelation) {
|
3790
|
+
break;
|
3791
|
+
}
|
3723
3792
|
if (isVisibleAttribute$1(model, attributeName)) {
|
3724
3793
|
populateAcc[attributeName] = {
|
3725
3794
|
count: true,
|
@@ -4097,7 +4166,13 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4097
4166
|
*/
|
4098
4167
|
async formatDocumentWithMetadata(uid2, document, opts = {}) {
|
4099
4168
|
if (!document) {
|
4100
|
-
return
|
4169
|
+
return {
|
4170
|
+
data: document,
|
4171
|
+
meta: {
|
4172
|
+
availableLocales: [],
|
4173
|
+
availableStatus: []
|
4174
|
+
}
|
4175
|
+
};
|
4101
4176
|
}
|
4102
4177
|
const hasDraftAndPublish = contentTypes$1.hasDraftAndPublish(strapi2.getModel(uid2));
|
4103
4178
|
if (!hasDraftAndPublish) {
|
@@ -4205,10 +4280,7 @@ const documentManager = ({ strapi: strapi2 }) => {
|
|
4205
4280
|
async clone(id, body, uid2) {
|
4206
4281
|
const populate = await buildDeepPopulate(uid2);
|
4207
4282
|
const params = {
|
4208
|
-
data:
|
4209
|
-
...omitIdField(body),
|
4210
|
-
[PUBLISHED_AT_ATTRIBUTE]: null
|
4211
|
-
},
|
4283
|
+
data: omitIdField(body),
|
4212
4284
|
populate
|
4213
4285
|
};
|
4214
4286
|
return strapi2.documents(uid2).clone({ ...params, documentId: id }).then((result) => result?.entries.at(0));
|