@strapi/content-manager 0.0.0-experimental.25e22c6cc9bc6b35392bb55d09f641a0a65e7403 → 0.0.0-experimental.2bad311ac375d1115d085a9cee4fdbe11a455caf
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-gdUj_t-O.mjs → ComponentConfigurationPage-7-qB29e7.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs.map → ComponentConfigurationPage-7-qB29e7.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js → ComponentConfigurationPage-DP7AC0UU.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js.map → ComponentConfigurationPage-DP7AC0UU.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs → EditConfigurationPage-CI4XoymK.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs.map → EditConfigurationPage-CI4XoymK.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js → EditConfigurationPage-DITVliEI.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js.map → EditConfigurationPage-DITVliEI.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DbcGfyqK.js → EditViewPage-CUS2EAhB.js} +24 -9
- package/dist/_chunks/EditViewPage-CUS2EAhB.js.map +1 -0
- package/dist/_chunks/{EditViewPage-0MiFkXa8.mjs → EditViewPage-Dzpno8xI.mjs} +24 -9
- package/dist/_chunks/EditViewPage-Dzpno8xI.mjs.map +1 -0
- package/dist/_chunks/{Field-BDMSCcy5.mjs → Field-B_jG_EV9.mjs} +479 -147
- package/dist/_chunks/Field-B_jG_EV9.mjs.map +1 -0
- package/dist/_chunks/{Field-BG1xu38N.js → Field-CtUU1Fg8.js} +481 -149
- package/dist/_chunks/Field-CtUU1Fg8.js.map +1 -0
- package/dist/_chunks/{Form-CPVWavB8.mjs → Form-BXHao2mZ.mjs} +39 -17
- package/dist/_chunks/Form-BXHao2mZ.mjs.map +1 -0
- package/dist/_chunks/{Form-9BnFyUjy.js → Form-DTqO0ymI.js} +39 -17
- package/dist/_chunks/Form-DTqO0ymI.js.map +1 -0
- package/dist/_chunks/{History-BVpd8LP3.mjs → History-2Ah2CQ4T.mjs} +44 -19
- package/dist/_chunks/History-2Ah2CQ4T.mjs.map +1 -0
- package/dist/_chunks/{History-BWWxLt2Z.js → History-C_uSGzO5.js} +44 -19
- package/dist/_chunks/History-C_uSGzO5.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DozVMKcR.mjs → ListConfigurationPage-BjSJlaoC.mjs} +20 -8
- package/dist/_chunks/ListConfigurationPage-BjSJlaoC.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-6swzjdAZ.js → ListConfigurationPage-nyuP7OSy.js} +20 -8
- package/dist/_chunks/ListConfigurationPage-nyuP7OSy.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Ds0ulgfG.mjs → ListViewPage-B75x3nz2.mjs} +59 -41
- package/dist/_chunks/ListViewPage-B75x3nz2.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-BlzfjS2Q.js → ListViewPage-DHgHD8Xg.js} +61 -43
- package/dist/_chunks/ListViewPage-DHgHD8Xg.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js → NoContentTypePage-CDUKdZ7d.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js.map → NoContentTypePage-CDUKdZ7d.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs → NoContentTypePage-DUacQSyF.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs.map → NoContentTypePage-DUacQSyF.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs → NoPermissionsPage-SFllMekk.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs.map → NoPermissionsPage-SFllMekk.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js → NoPermissionsPage-zwIZydDI.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js.map → NoPermissionsPage-zwIZydDI.js.map} +1 -1
- package/dist/_chunks/{Relations-Dnag3fhV.mjs → Relations-D2NRW8fC.mjs} +14 -10
- package/dist/_chunks/Relations-D2NRW8fC.mjs.map +1 -0
- package/dist/_chunks/{Relations-CcgFTcWo.js → Relations-NFLaRNPr.js} +14 -10
- package/dist/_chunks/Relations-NFLaRNPr.js.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-C9HxCo5R.mjs} +981 -662
- package/dist/_chunks/index-C9HxCo5R.mjs.map +1 -0
- package/dist/_chunks/{index-CWpLBSt0.js → index-ovJRE1FM.js} +973 -654
- package/dist/_chunks/index-ovJRE1FM.js.map +1 -0
- package/dist/_chunks/{layout-DC503LnF.mjs → layout-DaUjDiWQ.mjs} +27 -14
- package/dist/_chunks/layout-DaUjDiWQ.mjs.map +1 -0
- package/dist/_chunks/{layout--iHdZzRk.js → layout-UNWstw_s.js} +25 -12
- package/dist/_chunks/layout-UNWstw_s.js.map +1 -0
- package/dist/_chunks/{relations-CTje5t-a.mjs → relations-D8iFAeRu.mjs} +2 -2
- package/dist/_chunks/{relations-CTje5t-a.mjs.map → relations-D8iFAeRu.mjs.map} +1 -1
- package/dist/_chunks/{relations-BbHizA5K.js → relations-NN3coOG5.js} +2 -2
- package/dist/_chunks/{relations-BbHizA5K.js.map → relations-NN3coOG5.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 +32 -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 +11 -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 +191 -113
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +192 -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.js
CHANGED
@@ -199,7 +199,9 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
199
199
|
return strapi2.db.query("plugin::upload.file").findOne({ where: { id: versionRelationData.id } });
|
200
200
|
};
|
201
201
|
const localesService = strapi2.plugin("i18n")?.service("locales");
|
202
|
+
const i18nContentTypeService = strapi2.plugin("i18n")?.service("content-types");
|
202
203
|
const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
|
204
|
+
const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
|
203
205
|
const getLocaleDictionary = async () => {
|
204
206
|
if (!localesService)
|
205
207
|
return {};
|
@@ -226,20 +228,25 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
226
228
|
const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
|
227
229
|
return documentMetadataService.getStatus(document, meta.availableStatus);
|
228
230
|
};
|
229
|
-
const getDeepPopulate2 = (uid2) => {
|
231
|
+
const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
|
230
232
|
const model = strapi2.getModel(uid2);
|
231
233
|
const attributes = Object.entries(model.attributes);
|
234
|
+
const fieldSelector = useDatabaseSyntax ? "select" : "fields";
|
232
235
|
return attributes.reduce((acc, [attributeName, attribute]) => {
|
233
236
|
switch (attribute.type) {
|
234
237
|
case "relation": {
|
238
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
239
|
+
if (isMorphRelation) {
|
240
|
+
break;
|
241
|
+
}
|
235
242
|
const isVisible2 = strapiUtils.contentTypes.isVisibleAttribute(model, attributeName);
|
236
243
|
if (isVisible2) {
|
237
|
-
acc[attributeName] = {
|
244
|
+
acc[attributeName] = { [fieldSelector]: ["documentId", "locale", "publishedAt"] };
|
238
245
|
}
|
239
246
|
break;
|
240
247
|
}
|
241
248
|
case "media": {
|
242
|
-
acc[attributeName] = {
|
249
|
+
acc[attributeName] = { [fieldSelector]: ["id"] };
|
243
250
|
break;
|
244
251
|
}
|
245
252
|
case "component": {
|
@@ -312,6 +319,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
312
319
|
getRelationRestoreValue,
|
313
320
|
getMediaRestoreValue,
|
314
321
|
getDefaultLocale,
|
322
|
+
isLocalizedContentType,
|
315
323
|
getLocaleDictionary,
|
316
324
|
getRetentionDays,
|
317
325
|
getVersionStatus,
|
@@ -334,7 +342,13 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
334
342
|
});
|
335
343
|
},
|
336
344
|
async findVersionsPage(params) {
|
337
|
-
const
|
345
|
+
const model = strapi2.getModel(params.query.contentType);
|
346
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
|
347
|
+
const defaultLocale = await serviceUtils.getDefaultLocale();
|
348
|
+
let locale = null;
|
349
|
+
if (isLocalizedContentType) {
|
350
|
+
locale = params.query.locale || defaultLocale;
|
351
|
+
}
|
338
352
|
const [{ results, pagination }, localeDictionary] = await Promise.all([
|
339
353
|
query.findPage({
|
340
354
|
...params.query,
|
@@ -490,13 +504,47 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
490
504
|
}
|
491
505
|
};
|
492
506
|
};
|
507
|
+
const shouldCreateHistoryVersion = (context) => {
|
508
|
+
if (!strapi.requestContext.get()?.request.url.startsWith("/content-manager")) {
|
509
|
+
return false;
|
510
|
+
}
|
511
|
+
if (context.action !== "create" && context.action !== "update" && context.action !== "clone" && context.action !== "publish" && context.action !== "unpublish" && context.action !== "discardDraft") {
|
512
|
+
return false;
|
513
|
+
}
|
514
|
+
if (context.action === "update" && strapi.requestContext.get()?.request.url.endsWith("/actions/publish")) {
|
515
|
+
return false;
|
516
|
+
}
|
517
|
+
if (!context.contentType.uid.startsWith("api::")) {
|
518
|
+
return false;
|
519
|
+
}
|
520
|
+
return true;
|
521
|
+
};
|
522
|
+
const getSchemas = (uid2) => {
|
523
|
+
const attributesSchema = strapi.getModel(uid2).attributes;
|
524
|
+
const componentsSchemas = Object.keys(attributesSchema).reduce(
|
525
|
+
(currentComponentSchemas, key) => {
|
526
|
+
const fieldSchema = attributesSchema[key];
|
527
|
+
if (fieldSchema.type === "component") {
|
528
|
+
const componentSchema = strapi.getModel(fieldSchema.component).attributes;
|
529
|
+
return {
|
530
|
+
...currentComponentSchemas,
|
531
|
+
[fieldSchema.component]: componentSchema
|
532
|
+
};
|
533
|
+
}
|
534
|
+
return currentComponentSchemas;
|
535
|
+
},
|
536
|
+
{}
|
537
|
+
);
|
538
|
+
return {
|
539
|
+
schema: fp.omit(FIELDS_TO_IGNORE, attributesSchema),
|
540
|
+
componentsSchemas
|
541
|
+
};
|
542
|
+
};
|
493
543
|
const createLifecyclesService = ({ strapi: strapi2 }) => {
|
494
544
|
const state = {
|
495
545
|
deleteExpiredJob: null,
|
496
546
|
isInitialized: false
|
497
547
|
};
|
498
|
-
const query = strapi2.db.query(HISTORY_VERSION_UID);
|
499
|
-
const historyService = getService(strapi2, "history");
|
500
548
|
const serviceUtils = createServiceUtils({ strapi: strapi2 });
|
501
549
|
return {
|
502
550
|
async bootstrap() {
|
@@ -504,63 +552,45 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
504
552
|
return;
|
505
553
|
}
|
506
554
|
strapi2.documents.use(async (context, next) => {
|
507
|
-
if (!strapi2.requestContext.get()?.request.url.startsWith("/content-manager")) {
|
508
|
-
return next();
|
509
|
-
}
|
510
|
-
if (context.action !== "create" && context.action !== "update" && context.action !== "clone" && context.action !== "publish" && context.action !== "unpublish" && context.action !== "discardDraft") {
|
511
|
-
return next();
|
512
|
-
}
|
513
|
-
if (context.action === "update" && strapi2.requestContext.get()?.request.url.endsWith("/actions/publish")) {
|
514
|
-
return next();
|
515
|
-
}
|
516
|
-
const contentTypeUid = context.contentType.uid;
|
517
|
-
if (!contentTypeUid.startsWith("api::")) {
|
518
|
-
return next();
|
519
|
-
}
|
520
555
|
const result = await next();
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
556
|
+
if (!shouldCreateHistoryVersion(context)) {
|
557
|
+
return result;
|
558
|
+
}
|
559
|
+
const documentId = context.action === "create" || context.action === "clone" ? result.documentId : context.params.documentId;
|
525
560
|
const defaultLocale = await serviceUtils.getDefaultLocale();
|
526
|
-
const
|
527
|
-
if (
|
528
|
-
|
529
|
-
"[Content manager history middleware]: An array of locales was provided, but only a single locale is supported for the findOne operation."
|
530
|
-
);
|
531
|
-
return next();
|
561
|
+
const locales = fp.castArray(context.params?.locale || defaultLocale);
|
562
|
+
if (!locales.length) {
|
563
|
+
return result;
|
532
564
|
}
|
533
|
-
const
|
534
|
-
|
535
|
-
|
536
|
-
|
565
|
+
const uid2 = context.contentType.uid;
|
566
|
+
const schemas = getSchemas(uid2);
|
567
|
+
const model = strapi2.getModel(uid2);
|
568
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
|
569
|
+
const localeEntries = await strapi2.db.query(uid2).findMany({
|
570
|
+
where: {
|
571
|
+
documentId,
|
572
|
+
...isLocalizedContentType ? { locale: { $in: locales } } : {},
|
573
|
+
...strapiUtils.contentTypes.hasDraftAndPublish(strapi2.contentTypes[uid2]) ? { publishedAt: null } : {}
|
574
|
+
},
|
575
|
+
populate: serviceUtils.getDeepPopulate(
|
576
|
+
uid2,
|
577
|
+
true
|
578
|
+
/* use database syntax */
|
579
|
+
)
|
537
580
|
});
|
538
|
-
const status = await serviceUtils.getVersionStatus(contentTypeUid, document);
|
539
|
-
const attributesSchema = strapi2.getModel(contentTypeUid).attributes;
|
540
|
-
const componentsSchemas = Object.keys(
|
541
|
-
attributesSchema
|
542
|
-
).reduce((currentComponentSchemas, key) => {
|
543
|
-
const fieldSchema = attributesSchema[key];
|
544
|
-
if (fieldSchema.type === "component") {
|
545
|
-
const componentSchema = strapi2.getModel(fieldSchema.component).attributes;
|
546
|
-
return {
|
547
|
-
...currentComponentSchemas,
|
548
|
-
[fieldSchema.component]: componentSchema
|
549
|
-
};
|
550
|
-
}
|
551
|
-
return currentComponentSchemas;
|
552
|
-
}, {});
|
553
581
|
await strapi2.db.transaction(async ({ onCommit }) => {
|
554
|
-
onCommit(() => {
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
582
|
+
onCommit(async () => {
|
583
|
+
for (const entry of localeEntries) {
|
584
|
+
const status = await serviceUtils.getVersionStatus(uid2, entry);
|
585
|
+
await getService(strapi2, "history").createVersion({
|
586
|
+
contentType: uid2,
|
587
|
+
data: fp.omit(FIELDS_TO_IGNORE, entry),
|
588
|
+
relatedDocumentId: documentId,
|
589
|
+
locale: entry.locale,
|
590
|
+
status,
|
591
|
+
...schemas
|
592
|
+
});
|
593
|
+
}
|
564
594
|
});
|
565
595
|
});
|
566
596
|
return result;
|
@@ -568,7 +598,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
568
598
|
state.deleteExpiredJob = nodeSchedule.scheduleJob("0 0 * * *", () => {
|
569
599
|
const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
|
570
600
|
const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
|
571
|
-
query.deleteMany({
|
601
|
+
strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
|
572
602
|
where: {
|
573
603
|
created_at: {
|
574
604
|
$lt: expirationDate.toISOString()
|
@@ -1200,6 +1230,11 @@ const { createPolicy } = strapiUtils.policy;
|
|
1200
1230
|
const hasPermissions = createPolicy({
|
1201
1231
|
name: "plugin::content-manager.hasPermissions",
|
1202
1232
|
validator: validateHasPermissionsInput,
|
1233
|
+
/**
|
1234
|
+
* NOTE: Action aliases are currently not checked at this level (policy).
|
1235
|
+
* This is currently the intended behavior to avoid changing the behavior of API related permissions.
|
1236
|
+
* If you want to add support for it, please create a dedicated RFC with a list of potential side effect this could have.
|
1237
|
+
*/
|
1203
1238
|
handler(ctx, config = {}) {
|
1204
1239
|
const { actions = [], hasAtLeastOne = false } = config;
|
1205
1240
|
const { userAbility } = ctx.state;
|
@@ -1593,9 +1628,11 @@ const multipleLocaleSchema = strapiUtils.yup.lazy(
|
|
1593
1628
|
(value) => Array.isArray(value) ? strapiUtils.yup.array().of(singleLocaleSchema.required()) : singleLocaleSchema
|
1594
1629
|
);
|
1595
1630
|
const statusSchema = strapiUtils.yup.mixed().oneOf(["draft", "published"], "Invalid status");
|
1596
|
-
const getDocumentLocaleAndStatus = async (request, opts = { allowMultipleLocales: false }) => {
|
1631
|
+
const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultipleLocales: false }) => {
|
1597
1632
|
const { allowMultipleLocales } = opts;
|
1598
|
-
const { locale, status, ...rest } = request || {};
|
1633
|
+
const { locale, status: providedStatus, ...rest } = request || {};
|
1634
|
+
const defaultStatus = strapiUtils.contentTypes.hasDraftAndPublish(strapi.getModel(model)) ? void 0 : "published";
|
1635
|
+
const status = providedStatus !== void 0 ? providedStatus : defaultStatus;
|
1599
1636
|
const schema = strapiUtils.yup.object().shape({
|
1600
1637
|
locale: allowMultipleLocales ? multipleLocaleSchema : singleLocaleSchema,
|
1601
1638
|
status: statusSchema
|
@@ -1643,7 +1680,7 @@ const createDocument = async (ctx, opts) => {
|
|
1643
1680
|
const setCreator = strapiUtils.setCreatorFields({ user });
|
1644
1681
|
const sanitizeFn = strapiUtils.async.pipe(pickPermittedFields, setCreator);
|
1645
1682
|
const sanitizedBody = await sanitizeFn(body);
|
1646
|
-
const { locale, status
|
1683
|
+
const { locale, status } = await getDocumentLocaleAndStatus(body, model);
|
1647
1684
|
return documentManager2.create(model, {
|
1648
1685
|
data: sanitizedBody,
|
1649
1686
|
locale,
|
@@ -1662,7 +1699,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1662
1699
|
}
|
1663
1700
|
const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
|
1664
1701
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1665
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1702
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1666
1703
|
const [documentVersion, documentExists] = await Promise.all([
|
1667
1704
|
documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
|
1668
1705
|
documentManager2.exists(model, id)
|
@@ -1700,7 +1737,7 @@ const collectionTypes = {
|
|
1700
1737
|
}
|
1701
1738
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
1702
1739
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
|
1703
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
1740
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
1704
1741
|
const { results: documents, pagination } = await documentManager2.findPage(
|
1705
1742
|
{ ...permissionQuery, populate, locale, status },
|
1706
1743
|
model
|
@@ -1735,7 +1772,7 @@ const collectionTypes = {
|
|
1735
1772
|
}
|
1736
1773
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
1737
1774
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1738
|
-
const { locale, status
|
1775
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1739
1776
|
const version = await documentManager2.findOne(id, model, {
|
1740
1777
|
populate,
|
1741
1778
|
locale,
|
@@ -1750,7 +1787,7 @@ const collectionTypes = {
|
|
1750
1787
|
permissionChecker2,
|
1751
1788
|
model,
|
1752
1789
|
// @ts-expect-error TODO: fix
|
1753
|
-
{ id, locale, publishedAt: null },
|
1790
|
+
{ documentId: id, locale, publishedAt: null },
|
1754
1791
|
{ availableLocales: true, availableStatus: false }
|
1755
1792
|
);
|
1756
1793
|
ctx.body = { data: {}, meta };
|
@@ -1802,7 +1839,7 @@ const collectionTypes = {
|
|
1802
1839
|
}
|
1803
1840
|
const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
|
1804
1841
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1805
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1842
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1806
1843
|
const document = await documentManager2.findOne(id, model, {
|
1807
1844
|
populate,
|
1808
1845
|
locale,
|
@@ -1847,7 +1884,7 @@ const collectionTypes = {
|
|
1847
1884
|
}
|
1848
1885
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
|
1849
1886
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1850
|
-
const { locale } = await getDocumentLocaleAndStatus(ctx.query);
|
1887
|
+
const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1851
1888
|
const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
|
1852
1889
|
if (documentLocales.length === 0) {
|
1853
1890
|
return ctx.notFound();
|
@@ -1876,11 +1913,34 @@ const collectionTypes = {
|
|
1876
1913
|
const publishedDocument = await strapi.db.transaction(async () => {
|
1877
1914
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1878
1915
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1879
|
-
|
1916
|
+
let document;
|
1917
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1918
|
+
const isCreate = fp.isNil(id);
|
1919
|
+
if (isCreate) {
|
1920
|
+
if (permissionChecker2.cannot.create()) {
|
1921
|
+
throw new strapiUtils.errors.ForbiddenError();
|
1922
|
+
}
|
1923
|
+
document = await createDocument(ctx, { populate });
|
1924
|
+
}
|
1925
|
+
const isUpdate = !isCreate;
|
1926
|
+
if (isUpdate) {
|
1927
|
+
const documentExists = documentManager2.exists(model, id);
|
1928
|
+
if (!documentExists) {
|
1929
|
+
throw new strapiUtils.errors.NotFoundError("Document not found");
|
1930
|
+
}
|
1931
|
+
document = await documentManager2.findOne(id, model, { populate, locale });
|
1932
|
+
if (!document) {
|
1933
|
+
if (permissionChecker2.cannot.create({ locale }) || permissionChecker2.cannot.publish({ locale })) {
|
1934
|
+
throw new strapiUtils.errors.ForbiddenError();
|
1935
|
+
}
|
1936
|
+
document = await updateDocument(ctx);
|
1937
|
+
} else if (permissionChecker2.can.update(document)) {
|
1938
|
+
await updateDocument(ctx);
|
1939
|
+
}
|
1940
|
+
}
|
1880
1941
|
if (permissionChecker2.cannot.publish(document)) {
|
1881
1942
|
throw new strapiUtils.errors.ForbiddenError();
|
1882
1943
|
}
|
1883
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1884
1944
|
const publishResult = await documentManager2.publish(document.documentId, model, {
|
1885
1945
|
locale
|
1886
1946
|
// TODO: Allow setting creator fields on publish
|
@@ -1907,7 +1967,9 @@ const collectionTypes = {
|
|
1907
1967
|
}
|
1908
1968
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1909
1969
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1910
|
-
const { locale } = await getDocumentLocaleAndStatus(body, {
|
1970
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1971
|
+
allowMultipleLocales: true
|
1972
|
+
});
|
1911
1973
|
const entityPromises = documentIds.map(
|
1912
1974
|
(documentId) => documentManager2.findLocales(documentId, model, { populate, locale, isPublished: false })
|
1913
1975
|
);
|
@@ -1934,7 +1996,9 @@ const collectionTypes = {
|
|
1934
1996
|
if (permissionChecker2.cannot.unpublish()) {
|
1935
1997
|
return ctx.forbidden();
|
1936
1998
|
}
|
1937
|
-
const { locale } = await getDocumentLocaleAndStatus(body
|
1999
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
2000
|
+
allowMultipleLocales: true
|
2001
|
+
});
|
1938
2002
|
const entityPromises = documentIds.map(
|
1939
2003
|
(documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
|
1940
2004
|
);
|
@@ -1967,7 +2031,7 @@ const collectionTypes = {
|
|
1967
2031
|
}
|
1968
2032
|
const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
|
1969
2033
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1970
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2034
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1971
2035
|
const document = await documentManager2.findOne(id, model, {
|
1972
2036
|
populate,
|
1973
2037
|
locale,
|
@@ -2004,7 +2068,7 @@ const collectionTypes = {
|
|
2004
2068
|
}
|
2005
2069
|
const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
|
2006
2070
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2007
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2071
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2008
2072
|
const document = await documentManager2.findOne(id, model, {
|
2009
2073
|
populate,
|
2010
2074
|
locale,
|
@@ -2035,7 +2099,7 @@ const collectionTypes = {
|
|
2035
2099
|
}
|
2036
2100
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2037
2101
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2038
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2102
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2039
2103
|
const documentLocales = await documentManager2.findLocales(documentIds, model, {
|
2040
2104
|
populate,
|
2041
2105
|
locale
|
@@ -2062,7 +2126,7 @@ const collectionTypes = {
|
|
2062
2126
|
}
|
2063
2127
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2064
2128
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2065
|
-
const { locale, status
|
2129
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
2066
2130
|
const entity = await documentManager2.findOne(id, model, { populate, locale, status });
|
2067
2131
|
if (!entity) {
|
2068
2132
|
return ctx.notFound();
|
@@ -2085,7 +2149,7 @@ const collectionTypes = {
|
|
2085
2149
|
if (permissionChecker2.cannot.read()) {
|
2086
2150
|
return ctx.forbidden();
|
2087
2151
|
}
|
2088
|
-
const
|
2152
|
+
const documents = await documentManager2.findMany(
|
2089
2153
|
{
|
2090
2154
|
filters: {
|
2091
2155
|
documentId: ids
|
@@ -2094,7 +2158,7 @@ const collectionTypes = {
|
|
2094
2158
|
},
|
2095
2159
|
model
|
2096
2160
|
);
|
2097
|
-
if (!
|
2161
|
+
if (!documents) {
|
2098
2162
|
return ctx.notFound();
|
2099
2163
|
}
|
2100
2164
|
const number = await documentManager2.countManyEntriesDraftRelations(ids, model, locale);
|
@@ -2285,20 +2349,13 @@ const sanitizeMainField = (model, mainField, userAbility) => {
|
|
2285
2349
|
userAbility,
|
2286
2350
|
model: model.uid
|
2287
2351
|
});
|
2288
|
-
|
2352
|
+
const isMainFieldListable = isListable(model, mainField);
|
2353
|
+
const canReadMainField = permissionChecker2.can.read(null, mainField);
|
2354
|
+
if (!isMainFieldListable || !canReadMainField) {
|
2289
2355
|
return "id";
|
2290
2356
|
}
|
2291
|
-
if (
|
2292
|
-
|
2293
|
-
const userPermissionChecker = getService$1("permission-checker").create({
|
2294
|
-
userAbility,
|
2295
|
-
model: "plugin::users-permissions.user"
|
2296
|
-
});
|
2297
|
-
if (userPermissionChecker.can.read()) {
|
2298
|
-
return "name";
|
2299
|
-
}
|
2300
|
-
}
|
2301
|
-
return "id";
|
2357
|
+
if (model.uid === "plugin::users-permissions.role") {
|
2358
|
+
return "name";
|
2302
2359
|
}
|
2303
2360
|
return mainField;
|
2304
2361
|
};
|
@@ -2498,8 +2555,9 @@ const relations = {
|
|
2498
2555
|
} else {
|
2499
2556
|
where.id = id;
|
2500
2557
|
}
|
2501
|
-
|
2502
|
-
|
2558
|
+
const publishedAt = getPublishedAtClause(status, targetUid);
|
2559
|
+
if (!fp.isEmpty(publishedAt)) {
|
2560
|
+
where[`${alias}.published_at`] = publishedAt;
|
2503
2561
|
}
|
2504
2562
|
if (filterByLocale) {
|
2505
2563
|
where[`${alias}.locale`] = locale;
|
@@ -2556,9 +2614,7 @@ const relations = {
|
|
2556
2614
|
addFiltersClause(permissionQuery, { id: { $in: loadedIds } });
|
2557
2615
|
const sanitizedRes = await loadRelations({ id: entryId }, targetField, {
|
2558
2616
|
...strapi.get("query-params").transform(targetUid, permissionQuery),
|
2559
|
-
ordering: "desc"
|
2560
|
-
page: ctx.request.query.page,
|
2561
|
-
pageSize: ctx.request.query.pageSize
|
2617
|
+
ordering: "desc"
|
2562
2618
|
});
|
2563
2619
|
const relationsUnion = fp.uniqBy("id", fp.concat(sanitizedRes.results, res.results));
|
2564
2620
|
ctx.body = {
|
@@ -2590,7 +2646,7 @@ const createOrUpdateDocument = async (ctx, opts) => {
|
|
2590
2646
|
throw new strapiUtils.errors.ForbiddenError();
|
2591
2647
|
}
|
2592
2648
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.update(query);
|
2593
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2649
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2594
2650
|
const [documentVersion, otherDocumentVersion] = await Promise.all([
|
2595
2651
|
findDocument(sanitizedQuery, model, { locale, status: "draft" }),
|
2596
2652
|
// Find the first document to check if it exists
|
@@ -2631,7 +2687,7 @@ const singleTypes = {
|
|
2631
2687
|
return ctx.forbidden();
|
2632
2688
|
}
|
2633
2689
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
2634
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
2690
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
2635
2691
|
const version = await findDocument(permissionQuery, model, { locale, status });
|
2636
2692
|
if (!version) {
|
2637
2693
|
if (permissionChecker2.cannot.create()) {
|
@@ -2645,7 +2701,7 @@ const singleTypes = {
|
|
2645
2701
|
permissionChecker2,
|
2646
2702
|
model,
|
2647
2703
|
// @ts-expect-error - fix types
|
2648
|
-
{
|
2704
|
+
{ documentId: document.documentId, locale, publishedAt: null },
|
2649
2705
|
{ availableLocales: true, availableStatus: false }
|
2650
2706
|
);
|
2651
2707
|
ctx.body = { data: {}, meta };
|
@@ -2676,7 +2732,7 @@ const singleTypes = {
|
|
2676
2732
|
}
|
2677
2733
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2678
2734
|
const populate = await buildPopulateFromQuery(sanitizedQuery, model);
|
2679
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2735
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2680
2736
|
const documentLocales = await documentManager2.findLocales(void 0, model, {
|
2681
2737
|
populate,
|
2682
2738
|
locale
|
@@ -2713,7 +2769,7 @@ const singleTypes = {
|
|
2713
2769
|
if (permissionChecker2.cannot.publish(document)) {
|
2714
2770
|
throw new strapiUtils.errors.ForbiddenError();
|
2715
2771
|
}
|
2716
|
-
const { locale } = await getDocumentLocaleAndStatus(document);
|
2772
|
+
const { locale } = await getDocumentLocaleAndStatus(document, model);
|
2717
2773
|
const publishResult = await documentManager2.publish(document.documentId, model, { locale });
|
2718
2774
|
return publishResult.at(0);
|
2719
2775
|
});
|
@@ -2736,7 +2792,7 @@ const singleTypes = {
|
|
2736
2792
|
return ctx.forbidden();
|
2737
2793
|
}
|
2738
2794
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.unpublish(query);
|
2739
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2795
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2740
2796
|
const document = await findDocument(sanitizedQuery, model, { locale });
|
2741
2797
|
if (!document) {
|
2742
2798
|
return ctx.notFound();
|
@@ -2768,7 +2824,7 @@ const singleTypes = {
|
|
2768
2824
|
return ctx.forbidden();
|
2769
2825
|
}
|
2770
2826
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.discard(query);
|
2771
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2827
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2772
2828
|
const document = await findDocument(sanitizedQuery, model, { locale, status: "published" });
|
2773
2829
|
if (!document) {
|
2774
2830
|
return ctx.notFound();
|
@@ -2788,7 +2844,7 @@ const singleTypes = {
|
|
2788
2844
|
const { query } = ctx.request;
|
2789
2845
|
const documentManager2 = getService$1("document-manager");
|
2790
2846
|
const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
|
2791
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2847
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2792
2848
|
if (permissionChecker2.cannot.read()) {
|
2793
2849
|
return ctx.forbidden();
|
2794
2850
|
}
|
@@ -2809,7 +2865,7 @@ const uid$1 = {
|
|
2809
2865
|
async generateUID(ctx) {
|
2810
2866
|
const { contentTypeUID, field, data } = await validateGenerateUIDInput(ctx.request.body);
|
2811
2867
|
const { query = {} } = ctx.request;
|
2812
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2868
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2813
2869
|
await validateUIDField(contentTypeUID, field);
|
2814
2870
|
const uidService = getService$1("uid");
|
2815
2871
|
ctx.body = {
|
@@ -2821,7 +2877,7 @@ const uid$1 = {
|
|
2821
2877
|
ctx.request.body
|
2822
2878
|
);
|
2823
2879
|
const { query = {} } = ctx.request;
|
2824
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2880
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2825
2881
|
await validateUIDField(contentTypeUID, field);
|
2826
2882
|
const uidService = getService$1("uid");
|
2827
2883
|
const isAvailable = await uidService.checkUIDAvailability({
|
@@ -3464,12 +3520,27 @@ const createPermissionChecker = (strapi2) => ({ userAbility, model }) => {
|
|
3464
3520
|
ability: userAbility,
|
3465
3521
|
model
|
3466
3522
|
});
|
3467
|
-
const
|
3523
|
+
const { actionProvider } = strapi2.service("admin::permission");
|
3524
|
+
const toSubject = (entity) => {
|
3525
|
+
return entity ? permissionsManager.toSubject(entity, model) : model;
|
3526
|
+
};
|
3468
3527
|
const can = (action, entity, field) => {
|
3469
|
-
|
3528
|
+
const subject = toSubject(entity);
|
3529
|
+
const aliases = actionProvider.unstable_aliases(action, model);
|
3530
|
+
return (
|
3531
|
+
// Test the original action to see if it passes
|
3532
|
+
userAbility.can(action, subject, field) || // Else try every known alias if at least one of them succeed, then the user "can"
|
3533
|
+
aliases.some((alias) => userAbility.can(alias, subject, field))
|
3534
|
+
);
|
3470
3535
|
};
|
3471
3536
|
const cannot = (action, entity, field) => {
|
3472
|
-
|
3537
|
+
const subject = toSubject(entity);
|
3538
|
+
const aliases = actionProvider.unstable_aliases(action, model);
|
3539
|
+
return (
|
3540
|
+
// Test both the original action
|
3541
|
+
userAbility.cannot(action, subject, field) && // and every known alias, if all of them fail (cannot), then the user truly "cannot"
|
3542
|
+
aliases.every((alias) => userAbility.cannot(alias, subject, field))
|
3543
|
+
);
|
3473
3544
|
};
|
3474
3545
|
const sanitizeOutput = (data, { action = ACTIONS.read } = {}) => {
|
3475
3546
|
return permissionsManager.sanitizeOutput(data, { subject: toSubject(data), action });
|
@@ -3746,6 +3817,10 @@ const getDeepPopulateDraftCount = (uid2) => {
|
|
3746
3817
|
const attribute = model.attributes[attributeName];
|
3747
3818
|
switch (attribute.type) {
|
3748
3819
|
case "relation": {
|
3820
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
3821
|
+
if (isMorphRelation) {
|
3822
|
+
break;
|
3823
|
+
}
|
3749
3824
|
if (isVisibleAttribute$1(model, attributeName)) {
|
3750
3825
|
populateAcc[attributeName] = {
|
3751
3826
|
count: true,
|
@@ -4123,7 +4198,13 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4123
4198
|
*/
|
4124
4199
|
async formatDocumentWithMetadata(uid2, document, opts = {}) {
|
4125
4200
|
if (!document) {
|
4126
|
-
return
|
4201
|
+
return {
|
4202
|
+
data: document,
|
4203
|
+
meta: {
|
4204
|
+
availableLocales: [],
|
4205
|
+
availableStatus: []
|
4206
|
+
}
|
4207
|
+
};
|
4127
4208
|
}
|
4128
4209
|
const hasDraftAndPublish = strapiUtils.contentTypes.hasDraftAndPublish(strapi2.getModel(uid2));
|
4129
4210
|
if (!hasDraftAndPublish) {
|
@@ -4231,10 +4312,7 @@ const documentManager = ({ strapi: strapi2 }) => {
|
|
4231
4312
|
async clone(id, body, uid2) {
|
4232
4313
|
const populate = await buildDeepPopulate(uid2);
|
4233
4314
|
const params = {
|
4234
|
-
data:
|
4235
|
-
...omitIdField(body),
|
4236
|
-
[PUBLISHED_AT_ATTRIBUTE]: null
|
4237
|
-
},
|
4315
|
+
data: omitIdField(body),
|
4238
4316
|
populate
|
4239
4317
|
};
|
4240
4318
|
return strapi2.documents(uid2).clone({ ...params, documentId: id }).then((result) => result?.entries.at(0));
|