@strapi/content-manager 0.0.0-experimental.f2351bcfa3965c60f063a492da51faa2c636eee8 → 0.0.0-experimental.f49f46a1c17445a39e8af3f63124bcccf73842e6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{ComponentConfigurationPage-BlAzljQ6.js → ComponentConfigurationPage-ClKl_TA2.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-BlAzljQ6.js.map → ComponentConfigurationPage-ClKl_TA2.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-Ccwb19Qj.mjs → ComponentConfigurationPage-D3ZWDAHG.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-Ccwb19Qj.mjs.map → ComponentConfigurationPage-D3ZWDAHG.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-C19b_9RL.mjs → EditConfigurationPage-BYCBSJxP.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-C19b_9RL.mjs.map → EditConfigurationPage-BYCBSJxP.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BPoOzhCM.js → EditConfigurationPage-OWez0Kxp.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-BPoOzhCM.js.map → EditConfigurationPage-OWez0Kxp.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-nmrHNiJ9.mjs → EditViewPage-5pdbvsO_.mjs} +50 -10
- package/dist/_chunks/EditViewPage-5pdbvsO_.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-D9xH8HYD.js → EditViewPage-BEs5iGDi.js} +49 -9
- package/dist/_chunks/EditViewPage-BEs5iGDi.js.map +1 -0
- package/dist/_chunks/{Field-BB_pHo6D.js → Field-DNHm4wHx.js} +107 -44
- package/dist/_chunks/Field-DNHm4wHx.js.map +1 -0
- package/dist/_chunks/{Field--kmlJuSb.mjs → Field-DcKuFHYK.mjs} +107 -44
- package/dist/_chunks/Field-DcKuFHYK.mjs.map +1 -0
- package/dist/_chunks/{Form-CUtOiC4S.mjs → Form-CGwM_-5c.mjs} +3 -3
- package/dist/_chunks/Form-CGwM_-5c.mjs.map +1 -0
- package/dist/_chunks/{Form-iwbkoaAF.js → Form-CoRxWJOz.js} +3 -3
- package/dist/_chunks/Form-CoRxWJOz.js.map +1 -0
- package/dist/_chunks/{History-guuZF4lR.js → History-BcUTQrfG.js} +40 -97
- package/dist/_chunks/History-BcUTQrfG.js.map +1 -0
- package/dist/_chunks/{History-BKR3KyU3.mjs → History-DEvr3Q_V.mjs} +42 -99
- package/dist/_chunks/History-DEvr3Q_V.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Cu26t5sE.js → ListConfigurationPage-BE_Ho7tV.js} +5 -4
- package/dist/_chunks/ListConfigurationPage-BE_Ho7tV.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-B_O3hiLT.mjs → ListConfigurationPage-BM4zZZcM.mjs} +6 -5
- package/dist/_chunks/ListConfigurationPage-BM4zZZcM.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-B4sTBfu6.mjs → ListViewPage-BK2mkrql.mjs} +29 -7
- package/dist/_chunks/{ListViewPage-B4sTBfu6.mjs.map → ListViewPage-BK2mkrql.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-DWqqGno8.js → ListViewPage-BkT8Eao0.js} +29 -7
- package/dist/_chunks/ListViewPage-BkT8Eao0.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Daktt4t9.mjs → NoContentTypePage-BvcAutu9.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Daktt4t9.mjs.map → NoContentTypePage-BvcAutu9.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-TTkwA8uk.js → NoContentTypePage-C8mtyc4H.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-TTkwA8uk.js.map → NoContentTypePage-C8mtyc4H.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-D8_k39Q0.js → NoPermissionsPage-B5Y9Y78B.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-D8_k39Q0.js.map → NoPermissionsPage-B5Y9Y78B.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CBUXY2Pt.mjs → NoPermissionsPage-BmbRz7PR.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CBUXY2Pt.mjs.map → NoPermissionsPage-BmbRz7PR.mjs.map} +1 -1
- package/dist/_chunks/Preview-BF8ZDYqS.js +286 -0
- package/dist/_chunks/Preview-BF8ZDYqS.js.map +1 -0
- package/dist/_chunks/Preview-DcexhKJE.mjs +267 -0
- package/dist/_chunks/Preview-DcexhKJE.mjs.map +1 -0
- package/dist/_chunks/{Relations-DjvmZ_XQ.js → Relations-BKnoK1R0.js} +71 -35
- package/dist/_chunks/Relations-BKnoK1R0.js.map +1 -0
- package/dist/_chunks/{Relations-HKmXF7eO.mjs → Relations-BjIzc4EK.mjs} +72 -36
- package/dist/_chunks/Relations-BjIzc4EK.mjs.map +1 -0
- package/dist/_chunks/{en-CPTj6CjC.mjs → en-CfIXaZf9.mjs} +21 -10
- package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
- package/dist/_chunks/{en-BVzUkPxZ.js → en-DTWPCdTS.js} +21 -10
- package/dist/_chunks/{en-BVzUkPxZ.js.map → en-DTWPCdTS.js.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/{index-CB1AN26E.mjs → index-BW-rXkjn.mjs} +882 -721
- package/dist/_chunks/index-BW-rXkjn.mjs.map +1 -0
- package/dist/_chunks/{index-jDJgW_Lf.js → index-DOzAG2cq.js} +879 -717
- package/dist/_chunks/index-DOzAG2cq.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-BCzDsMgN.mjs → layout-DFVbgjp2.mjs} +3 -3
- package/dist/_chunks/{layout-BCzDsMgN.mjs.map → layout-DFVbgjp2.mjs.map} +1 -1
- package/dist/_chunks/{layout-D6A3K-ut.js → layout-RC3W2obV.js} +3 -3
- package/dist/_chunks/{layout-D6A3K-ut.js.map → layout-RC3W2obV.js.map} +1 -1
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-B5Jnw32V.mjs → relations-Dogh8HWI.mjs} +6 -7
- package/dist/_chunks/relations-Dogh8HWI.mjs.map +1 -0
- package/dist/_chunks/{relations-C10QoukP.js → relations-zam7-5H7.js} +6 -7
- package/dist/_chunks/relations-zam7-5H7.js.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +4 -3
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/constants.d.ts +1 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/server/index.js +374 -160
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +374 -160
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.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 -3
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/preview/constants.d.ts +2 -0
- package/dist/server/src/preview/constants.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +15 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +30 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +18 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/routes/index.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 +8 -8
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/_chunks/EditViewPage-D9xH8HYD.js.map +0 -1
- package/dist/_chunks/EditViewPage-nmrHNiJ9.mjs.map +0 -1
- package/dist/_chunks/Field--kmlJuSb.mjs.map +0 -1
- package/dist/_chunks/Field-BB_pHo6D.js.map +0 -1
- package/dist/_chunks/Form-CUtOiC4S.mjs.map +0 -1
- package/dist/_chunks/Form-iwbkoaAF.js.map +0 -1
- package/dist/_chunks/History-BKR3KyU3.mjs.map +0 -1
- package/dist/_chunks/History-guuZF4lR.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-B_O3hiLT.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Cu26t5sE.js.map +0 -1
- package/dist/_chunks/ListViewPage-DWqqGno8.js.map +0 -1
- package/dist/_chunks/Relations-DjvmZ_XQ.js.map +0 -1
- package/dist/_chunks/Relations-HKmXF7eO.mjs.map +0 -1
- package/dist/_chunks/index-CB1AN26E.mjs.map +0 -1
- package/dist/_chunks/index-jDJgW_Lf.js.map +0 -1
- package/dist/_chunks/relations-B5Jnw32V.mjs.map +0 -1
- package/dist/_chunks/relations-C10QoukP.js.map +0 -1
- package/strapi-server.js +0 -3
package/dist/server/index.js
CHANGED
@@ -33,10 +33,10 @@ const isNil__default = /* @__PURE__ */ _interopDefault(isNil);
|
|
33
33
|
const ___default = /* @__PURE__ */ _interopDefault(_);
|
34
34
|
const qs__default = /* @__PURE__ */ _interopDefault(qs);
|
35
35
|
const slugify__default = /* @__PURE__ */ _interopDefault(slugify);
|
36
|
-
const getService$
|
36
|
+
const getService$2 = (name) => {
|
37
37
|
return strapi.plugin("content-manager").service(name);
|
38
38
|
};
|
39
|
-
function getService(strapi2, name) {
|
39
|
+
function getService$1(strapi2, name) {
|
40
40
|
return strapi2.service(`plugin::content-manager.${name}`);
|
41
41
|
}
|
42
42
|
const historyRestoreVersionSchema = yup__namespace.object().shape({
|
@@ -72,7 +72,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
72
72
|
if (!isSingleType && (!contentTypeUid || !ctx.query.documentId)) {
|
73
73
|
throw new strapiUtils.errors.ForbiddenError("contentType and documentId are required");
|
74
74
|
}
|
75
|
-
const permissionChecker2 = getService$
|
75
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
76
76
|
userAbility: ctx.state.userAbility,
|
77
77
|
model: ctx.query.contentType
|
78
78
|
});
|
@@ -80,7 +80,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
80
80
|
return ctx.forbidden();
|
81
81
|
}
|
82
82
|
const query = await permissionChecker2.sanitizeQuery(ctx.query);
|
83
|
-
const { results, pagination } = await getService(strapi2, "history").findVersionsPage({
|
83
|
+
const { results, pagination } = await getService$1(strapi2, "history").findVersionsPage({
|
84
84
|
query: {
|
85
85
|
...query,
|
86
86
|
...getValidPagination({ page: query.page, pageSize: query.pageSize })
|
@@ -105,14 +105,14 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
105
105
|
async restoreVersion(ctx) {
|
106
106
|
const request = ctx.request;
|
107
107
|
await validateRestoreVersion(request.body, "contentType is required");
|
108
|
-
const permissionChecker2 = getService$
|
108
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
109
109
|
userAbility: ctx.state.userAbility,
|
110
110
|
model: request.body.contentType
|
111
111
|
});
|
112
112
|
if (permissionChecker2.cannot.update()) {
|
113
113
|
throw new strapiUtils.errors.ForbiddenError();
|
114
114
|
}
|
115
|
-
const restoredDocument = await getService(strapi2, "history").restoreVersion(
|
115
|
+
const restoredDocument = await getService$1(strapi2, "history").restoreVersion(
|
116
116
|
request.params.versionId
|
117
117
|
);
|
118
118
|
return {
|
@@ -121,7 +121,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
121
121
|
}
|
122
122
|
};
|
123
123
|
};
|
124
|
-
const controllers$
|
124
|
+
const controllers$2 = {
|
125
125
|
"history-version": createHistoryVersionController
|
126
126
|
/**
|
127
127
|
* Casting is needed because the types aren't aware that Strapi supports
|
@@ -228,6 +228,17 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
228
228
|
const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
|
229
229
|
return documentMetadataService.getStatus(document, meta.availableStatus);
|
230
230
|
};
|
231
|
+
const getComponentFields = (componentUID) => {
|
232
|
+
return Object.entries(strapi2.getModel(componentUID).attributes).reduce(
|
233
|
+
(fieldsAcc, [key, attribute]) => {
|
234
|
+
if (!["relation", "media", "component", "dynamiczone"].includes(attribute.type)) {
|
235
|
+
fieldsAcc.push(key);
|
236
|
+
}
|
237
|
+
return fieldsAcc;
|
238
|
+
},
|
239
|
+
[]
|
240
|
+
);
|
241
|
+
};
|
231
242
|
const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
|
232
243
|
const model = strapi2.getModel(uid2);
|
233
244
|
const attributes = Object.entries(model.attributes);
|
@@ -251,13 +262,19 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
251
262
|
}
|
252
263
|
case "component": {
|
253
264
|
const populate = getDeepPopulate2(attribute.component);
|
254
|
-
acc[attributeName] = {
|
265
|
+
acc[attributeName] = {
|
266
|
+
populate,
|
267
|
+
[fieldSelector]: getComponentFields(attribute.component)
|
268
|
+
};
|
255
269
|
break;
|
256
270
|
}
|
257
271
|
case "dynamiczone": {
|
258
272
|
const populatedComponents = (attribute.components || []).reduce(
|
259
273
|
(acc2, componentUID) => {
|
260
|
-
acc2[componentUID] = {
|
274
|
+
acc2[componentUID] = {
|
275
|
+
populate: getDeepPopulate2(componentUID),
|
276
|
+
[fieldSelector]: getComponentFields(componentUID)
|
277
|
+
};
|
261
278
|
return acc2;
|
262
279
|
},
|
263
280
|
{}
|
@@ -370,7 +387,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
370
387
|
const attributeValue = entry.data[attributeKey];
|
371
388
|
const attributeValues = Array.isArray(attributeValue) ? attributeValue : [attributeValue];
|
372
389
|
if (attributeSchema.type === "media") {
|
373
|
-
const permissionChecker2 = getService$
|
390
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
374
391
|
userAbility: params.state.userAbility,
|
375
392
|
model: "plugin::upload.file"
|
376
393
|
});
|
@@ -393,7 +410,12 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
393
410
|
if (userToPopulate == null) {
|
394
411
|
return null;
|
395
412
|
}
|
396
|
-
return strapi2.query("admin::user").findOne({
|
413
|
+
return strapi2.query("admin::user").findOne({
|
414
|
+
where: {
|
415
|
+
...userToPopulate.id ? { id: userToPopulate.id } : {},
|
416
|
+
...userToPopulate.documentId ? { documentId: userToPopulate.documentId } : {}
|
417
|
+
}
|
418
|
+
});
|
397
419
|
})
|
398
420
|
);
|
399
421
|
return {
|
@@ -406,7 +428,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
406
428
|
[attributeKey]: adminUsers
|
407
429
|
};
|
408
430
|
}
|
409
|
-
const permissionChecker2 = getService$
|
431
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
410
432
|
userAbility: params.state.userAbility,
|
411
433
|
model: attributeSchema.target
|
412
434
|
});
|
@@ -582,7 +604,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
582
604
|
onCommit(async () => {
|
583
605
|
for (const entry of localeEntries) {
|
584
606
|
const status = await serviceUtils.getVersionStatus(uid2, entry);
|
585
|
-
await getService(strapi2, "history").createVersion({
|
607
|
+
await getService$1(strapi2, "history").createVersion({
|
586
608
|
contentType: uid2,
|
587
609
|
data: fp.omit(FIELDS_TO_IGNORE, entry),
|
588
610
|
relatedDocumentId: documentId,
|
@@ -595,15 +617,19 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
595
617
|
});
|
596
618
|
return result;
|
597
619
|
});
|
598
|
-
state.deleteExpiredJob = nodeSchedule.scheduleJob("0 0 * * *", () => {
|
620
|
+
state.deleteExpiredJob = nodeSchedule.scheduleJob("historyDaily", "0 0 * * *", () => {
|
599
621
|
const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
|
600
622
|
const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
|
601
623
|
strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
|
602
624
|
where: {
|
603
625
|
created_at: {
|
604
|
-
$lt: expirationDate
|
626
|
+
$lt: expirationDate
|
605
627
|
}
|
606
628
|
}
|
629
|
+
}).catch((error) => {
|
630
|
+
if (error instanceof Error) {
|
631
|
+
strapi2.log.error("Error deleting expired history versions", error.message);
|
632
|
+
}
|
607
633
|
});
|
608
634
|
});
|
609
635
|
state.isInitialized = true;
|
@@ -615,17 +641,17 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
615
641
|
}
|
616
642
|
};
|
617
643
|
};
|
618
|
-
const services$
|
644
|
+
const services$2 = {
|
619
645
|
history: createHistoryService,
|
620
646
|
lifecycles: createLifecyclesService
|
621
647
|
};
|
622
|
-
const info = { pluginName: "content-manager", type: "admin" };
|
648
|
+
const info$1 = { pluginName: "content-manager", type: "admin" };
|
623
649
|
const historyVersionRouter = {
|
624
650
|
type: "admin",
|
625
651
|
routes: [
|
626
652
|
{
|
627
653
|
method: "GET",
|
628
|
-
info,
|
654
|
+
info: info$1,
|
629
655
|
path: "/history-versions",
|
630
656
|
handler: "history-version.findMany",
|
631
657
|
config: {
|
@@ -634,7 +660,7 @@ const historyVersionRouter = {
|
|
634
660
|
},
|
635
661
|
{
|
636
662
|
method: "PUT",
|
637
|
-
info,
|
663
|
+
info: info$1,
|
638
664
|
path: "/history-versions/:versionId/restore",
|
639
665
|
handler: "history-version.restoreVersion",
|
640
666
|
config: {
|
@@ -643,7 +669,7 @@ const historyVersionRouter = {
|
|
643
669
|
}
|
644
670
|
]
|
645
671
|
};
|
646
|
-
const routes$
|
672
|
+
const routes$2 = {
|
647
673
|
"history-version": historyVersionRouter
|
648
674
|
};
|
649
675
|
const historyVersion = {
|
@@ -690,21 +716,21 @@ const historyVersion = {
|
|
690
716
|
}
|
691
717
|
}
|
692
718
|
};
|
693
|
-
const getFeature = () => {
|
719
|
+
const getFeature$1 = () => {
|
694
720
|
if (strapi.ee.features.isEnabled("cms-content-history")) {
|
695
721
|
return {
|
696
722
|
register({ strapi: strapi2 }) {
|
697
723
|
strapi2.get("models").add(historyVersion);
|
698
724
|
},
|
699
725
|
bootstrap({ strapi: strapi2 }) {
|
700
|
-
getService(strapi2, "lifecycles").bootstrap();
|
726
|
+
getService$1(strapi2, "lifecycles").bootstrap();
|
701
727
|
},
|
702
728
|
destroy({ strapi: strapi2 }) {
|
703
|
-
getService(strapi2, "lifecycles").destroy();
|
729
|
+
getService$1(strapi2, "lifecycles").destroy();
|
704
730
|
},
|
705
|
-
controllers: controllers$
|
706
|
-
services: services$
|
707
|
-
routes: routes$
|
731
|
+
controllers: controllers$2,
|
732
|
+
services: services$2,
|
733
|
+
routes: routes$2
|
708
734
|
};
|
709
735
|
}
|
710
736
|
return {
|
@@ -713,7 +739,7 @@ const getFeature = () => {
|
|
713
739
|
}
|
714
740
|
};
|
715
741
|
};
|
716
|
-
const history = getFeature();
|
742
|
+
const history = getFeature$1();
|
717
743
|
const register = async ({ strapi: strapi2 }) => {
|
718
744
|
await history.register?.({ strapi: strapi2 });
|
719
745
|
};
|
@@ -721,15 +747,165 @@ const ALLOWED_WEBHOOK_EVENTS = {
|
|
721
747
|
ENTRY_PUBLISH: "entry.publish",
|
722
748
|
ENTRY_UNPUBLISH: "entry.unpublish"
|
723
749
|
};
|
750
|
+
const FEATURE_ID = "preview";
|
751
|
+
const info = { pluginName: "content-manager", type: "admin" };
|
752
|
+
const previewRouter = {
|
753
|
+
type: "admin",
|
754
|
+
routes: [
|
755
|
+
{
|
756
|
+
method: "GET",
|
757
|
+
info,
|
758
|
+
path: "/preview/url/:contentType",
|
759
|
+
handler: "preview.getPreviewUrl",
|
760
|
+
config: {
|
761
|
+
policies: ["admin::isAuthenticatedAdmin"]
|
762
|
+
}
|
763
|
+
}
|
764
|
+
]
|
765
|
+
};
|
766
|
+
const routes$1 = {
|
767
|
+
preview: previewRouter
|
768
|
+
};
|
769
|
+
function getService(strapi2, name) {
|
770
|
+
return strapi2.service(`plugin::content-manager.${name}`);
|
771
|
+
}
|
772
|
+
const getPreviewUrlSchema = yup__namespace.object().shape({
|
773
|
+
// Will be undefined for single types
|
774
|
+
documentId: yup__namespace.string(),
|
775
|
+
locale: yup__namespace.string().nullable(),
|
776
|
+
status: yup__namespace.string()
|
777
|
+
}).required();
|
778
|
+
const validatePreviewUrl = async (strapi2, uid2, params) => {
|
779
|
+
await strapiUtils.validateYupSchema(getPreviewUrlSchema)(params);
|
780
|
+
const newParams = fp.pick(["documentId", "locale", "status"], params);
|
781
|
+
const model = strapi2.getModel(uid2);
|
782
|
+
if (!model || model.modelType !== "contentType") {
|
783
|
+
throw new strapiUtils.errors.ValidationError("Invalid content type");
|
784
|
+
}
|
785
|
+
const isSingleType = model?.kind === "singleType";
|
786
|
+
if (!isSingleType && !params.documentId) {
|
787
|
+
throw new strapiUtils.errors.ValidationError("documentId is required for Collection Types");
|
788
|
+
}
|
789
|
+
if (isSingleType) {
|
790
|
+
const doc = await strapi2.documents(uid2).findFirst();
|
791
|
+
if (!doc) {
|
792
|
+
throw new strapiUtils.errors.NotFoundError("Document not found");
|
793
|
+
}
|
794
|
+
newParams.documentId = doc?.documentId;
|
795
|
+
}
|
796
|
+
return newParams;
|
797
|
+
};
|
798
|
+
const createPreviewController = () => {
|
799
|
+
return {
|
800
|
+
/**
|
801
|
+
* Transforms an entry into a preview URL, so that it can be previewed
|
802
|
+
* in the Content Manager.
|
803
|
+
*/
|
804
|
+
async getPreviewUrl(ctx) {
|
805
|
+
const uid2 = ctx.params.contentType;
|
806
|
+
const query = ctx.request.query;
|
807
|
+
const params = await validatePreviewUrl(strapi, uid2, query);
|
808
|
+
const previewService = getService(strapi, "preview");
|
809
|
+
const url = await previewService.getPreviewUrl(uid2, params);
|
810
|
+
if (!url) {
|
811
|
+
ctx.status = 204;
|
812
|
+
}
|
813
|
+
return {
|
814
|
+
data: { url }
|
815
|
+
};
|
816
|
+
}
|
817
|
+
};
|
818
|
+
};
|
819
|
+
const controllers$1 = {
|
820
|
+
preview: createPreviewController
|
821
|
+
/**
|
822
|
+
* Casting is needed because the types aren't aware that Strapi supports
|
823
|
+
* passing a controller factory as the value, instead of a controller object directly
|
824
|
+
*/
|
825
|
+
};
|
826
|
+
const createPreviewService = ({ strapi: strapi2 }) => {
|
827
|
+
const config = getService(strapi2, "preview-config");
|
828
|
+
return {
|
829
|
+
async getPreviewUrl(uid2, params) {
|
830
|
+
const handler = config.getPreviewHandler();
|
831
|
+
try {
|
832
|
+
return handler(uid2, params);
|
833
|
+
} catch (error) {
|
834
|
+
strapi2.log.error(`Failed to get preview URL: ${error}`);
|
835
|
+
throw new strapiUtils.errors.ApplicationError("Failed to get preview URL");
|
836
|
+
}
|
837
|
+
return;
|
838
|
+
}
|
839
|
+
};
|
840
|
+
};
|
841
|
+
const createPreviewConfigService = ({ strapi: strapi2 }) => {
|
842
|
+
return {
|
843
|
+
isEnabled() {
|
844
|
+
const config = strapi2.config.get("admin.preview");
|
845
|
+
if (!config) {
|
846
|
+
return false;
|
847
|
+
}
|
848
|
+
return config?.enabled ?? true;
|
849
|
+
},
|
850
|
+
/**
|
851
|
+
* Validate if the configuration is valid
|
852
|
+
*/
|
853
|
+
validate() {
|
854
|
+
if (!this.isEnabled()) {
|
855
|
+
return;
|
856
|
+
}
|
857
|
+
const handler = this.getPreviewHandler();
|
858
|
+
if (typeof handler !== "function") {
|
859
|
+
throw new strapiUtils.errors.ValidationError(
|
860
|
+
"Preview configuration is invalid. Handler must be a function"
|
861
|
+
);
|
862
|
+
}
|
863
|
+
},
|
864
|
+
/**
|
865
|
+
* Utility to get the preview handler from the configuration
|
866
|
+
*/
|
867
|
+
getPreviewHandler() {
|
868
|
+
const config = strapi2.config.get("admin.preview");
|
869
|
+
const emptyHandler = () => {
|
870
|
+
return void 0;
|
871
|
+
};
|
872
|
+
if (!this.isEnabled()) {
|
873
|
+
return emptyHandler;
|
874
|
+
}
|
875
|
+
return config?.config?.handler || emptyHandler;
|
876
|
+
}
|
877
|
+
};
|
878
|
+
};
|
879
|
+
const services$1 = {
|
880
|
+
preview: createPreviewService,
|
881
|
+
"preview-config": createPreviewConfigService
|
882
|
+
};
|
883
|
+
const getFeature = () => {
|
884
|
+
if (!strapi.features.future.isEnabled(FEATURE_ID)) {
|
885
|
+
return {};
|
886
|
+
}
|
887
|
+
return {
|
888
|
+
bootstrap() {
|
889
|
+
console.log("Bootstrapping preview server");
|
890
|
+
const config = getService(strapi, "preview-config");
|
891
|
+
config.validate();
|
892
|
+
},
|
893
|
+
routes: routes$1,
|
894
|
+
controllers: controllers$1,
|
895
|
+
services: services$1
|
896
|
+
};
|
897
|
+
};
|
898
|
+
const preview = getFeature();
|
724
899
|
const bootstrap = async () => {
|
725
900
|
Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
|
726
901
|
strapi.get("webhookStore").addAllowedEvent(key, value);
|
727
902
|
});
|
728
|
-
getService$
|
729
|
-
await getService$
|
730
|
-
await getService$
|
731
|
-
await getService$
|
903
|
+
getService$2("field-sizes").setCustomFieldInputSizes();
|
904
|
+
await getService$2("components").syncConfigurations();
|
905
|
+
await getService$2("content-types").syncConfigurations();
|
906
|
+
await getService$2("permission").registerPermissions();
|
732
907
|
await history.bootstrap?.({ strapi });
|
908
|
+
await preview.bootstrap?.({ strapi });
|
733
909
|
};
|
734
910
|
const destroy = async ({ strapi: strapi2 }) => {
|
735
911
|
await history.destroy?.({ strapi: strapi2 });
|
@@ -1219,7 +1395,8 @@ const admin = {
|
|
1219
1395
|
};
|
1220
1396
|
const routes = {
|
1221
1397
|
admin,
|
1222
|
-
...history.routes ? history.routes : {}
|
1398
|
+
...history.routes ? history.routes : {},
|
1399
|
+
...preview.routes ? preview.routes : {}
|
1223
1400
|
};
|
1224
1401
|
const hasPermissionsSchema = strapiUtils.yup.object({
|
1225
1402
|
actions: strapiUtils.yup.array().of(strapiUtils.yup.string()),
|
@@ -1476,7 +1653,7 @@ const createMetadasSchema = (schema) => {
|
|
1476
1653
|
if (!value) {
|
1477
1654
|
return strapiUtils.yup.string();
|
1478
1655
|
}
|
1479
|
-
const targetSchema = getService$
|
1656
|
+
const targetSchema = getService$2("content-types").findContentType(
|
1480
1657
|
schema.attributes[key].targetModel
|
1481
1658
|
);
|
1482
1659
|
if (!targetSchema) {
|
@@ -1645,7 +1822,7 @@ const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultiple
|
|
1645
1822
|
}
|
1646
1823
|
};
|
1647
1824
|
const formatDocumentWithMetadata = async (permissionChecker2, uid2, document, opts = {}) => {
|
1648
|
-
const documentMetadata2 = getService$
|
1825
|
+
const documentMetadata2 = getService$2("document-metadata");
|
1649
1826
|
const serviceOutput = await documentMetadata2.formatDocumentWithMetadata(uid2, document, opts);
|
1650
1827
|
let {
|
1651
1828
|
meta: { availableLocales, availableStatus }
|
@@ -1671,8 +1848,8 @@ const createDocument = async (ctx, opts) => {
|
|
1671
1848
|
const { userAbility, user } = ctx.state;
|
1672
1849
|
const { model } = ctx.params;
|
1673
1850
|
const { body } = ctx.request;
|
1674
|
-
const documentManager2 = getService$
|
1675
|
-
const permissionChecker2 = getService$
|
1851
|
+
const documentManager2 = getService$2("document-manager");
|
1852
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1676
1853
|
if (permissionChecker2.cannot.create()) {
|
1677
1854
|
throw new strapiUtils.errors.ForbiddenError();
|
1678
1855
|
}
|
@@ -1692,13 +1869,13 @@ const updateDocument = async (ctx, opts) => {
|
|
1692
1869
|
const { userAbility, user } = ctx.state;
|
1693
1870
|
const { id, model } = ctx.params;
|
1694
1871
|
const { body } = ctx.request;
|
1695
|
-
const documentManager2 = getService$
|
1696
|
-
const permissionChecker2 = getService$
|
1872
|
+
const documentManager2 = getService$2("document-manager");
|
1873
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1697
1874
|
if (permissionChecker2.cannot.update()) {
|
1698
1875
|
throw new strapiUtils.errors.ForbiddenError();
|
1699
1876
|
}
|
1700
1877
|
const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
|
1701
|
-
const populate = await getService$
|
1878
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1702
1879
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1703
1880
|
const [documentVersion, documentExists] = await Promise.all([
|
1704
1881
|
documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
|
@@ -1715,7 +1892,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1715
1892
|
throw new strapiUtils.errors.ForbiddenError();
|
1716
1893
|
}
|
1717
1894
|
const pickPermittedFields = documentVersion ? permissionChecker2.sanitizeUpdateInput(documentVersion) : permissionChecker2.sanitizeCreateInput;
|
1718
|
-
const setCreator = strapiUtils.setCreatorFields({ user, isEdition: true });
|
1895
|
+
const setCreator = documentVersion ? strapiUtils.setCreatorFields({ user, isEdition: true }) : strapiUtils.setCreatorFields({ user });
|
1719
1896
|
const sanitizeFn = strapiUtils.async.pipe(pickPermittedFields, setCreator);
|
1720
1897
|
const sanitizedBody = await sanitizeFn(body);
|
1721
1898
|
return documentManager2.update(documentVersion?.documentId || id, model, {
|
@@ -1729,14 +1906,14 @@ const collectionTypes = {
|
|
1729
1906
|
const { userAbility } = ctx.state;
|
1730
1907
|
const { model } = ctx.params;
|
1731
1908
|
const { query } = ctx.request;
|
1732
|
-
const documentMetadata2 = getService$
|
1733
|
-
const documentManager2 = getService$
|
1734
|
-
const permissionChecker2 = getService$
|
1909
|
+
const documentMetadata2 = getService$2("document-metadata");
|
1910
|
+
const documentManager2 = getService$2("document-manager");
|
1911
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1735
1912
|
if (permissionChecker2.cannot.read()) {
|
1736
1913
|
return ctx.forbidden();
|
1737
1914
|
}
|
1738
1915
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
1739
|
-
const populate = await getService$
|
1916
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
|
1740
1917
|
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
1741
1918
|
const { results: documents, pagination } = await documentManager2.findPage(
|
1742
1919
|
{ ...permissionQuery, populate, locale, status },
|
@@ -1765,13 +1942,13 @@ const collectionTypes = {
|
|
1765
1942
|
async findOne(ctx) {
|
1766
1943
|
const { userAbility } = ctx.state;
|
1767
1944
|
const { model, id } = ctx.params;
|
1768
|
-
const documentManager2 = getService$
|
1769
|
-
const permissionChecker2 = getService$
|
1945
|
+
const documentManager2 = getService$2("document-manager");
|
1946
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1770
1947
|
if (permissionChecker2.cannot.read()) {
|
1771
1948
|
return ctx.forbidden();
|
1772
1949
|
}
|
1773
1950
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
1774
|
-
const populate = await getService$
|
1951
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1775
1952
|
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1776
1953
|
const version = await documentManager2.findOne(id, model, {
|
1777
1954
|
populate,
|
@@ -1802,7 +1979,7 @@ const collectionTypes = {
|
|
1802
1979
|
async create(ctx) {
|
1803
1980
|
const { userAbility } = ctx.state;
|
1804
1981
|
const { model } = ctx.params;
|
1805
|
-
const permissionChecker2 = getService$
|
1982
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1806
1983
|
const [totalEntries, document] = await Promise.all([
|
1807
1984
|
strapi.db.query(model).count(),
|
1808
1985
|
createDocument(ctx)
|
@@ -1823,7 +2000,7 @@ const collectionTypes = {
|
|
1823
2000
|
async update(ctx) {
|
1824
2001
|
const { userAbility } = ctx.state;
|
1825
2002
|
const { model } = ctx.params;
|
1826
|
-
const permissionChecker2 = getService$
|
2003
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1827
2004
|
const updatedVersion = await updateDocument(ctx);
|
1828
2005
|
const sanitizedVersion = await permissionChecker2.sanitizeOutput(updatedVersion);
|
1829
2006
|
ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedVersion);
|
@@ -1832,13 +2009,13 @@ const collectionTypes = {
|
|
1832
2009
|
const { userAbility, user } = ctx.state;
|
1833
2010
|
const { model, sourceId: id } = ctx.params;
|
1834
2011
|
const { body } = ctx.request;
|
1835
|
-
const documentManager2 = getService$
|
1836
|
-
const permissionChecker2 = getService$
|
2012
|
+
const documentManager2 = getService$2("document-manager");
|
2013
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1837
2014
|
if (permissionChecker2.cannot.create()) {
|
1838
2015
|
return ctx.forbidden();
|
1839
2016
|
}
|
1840
2017
|
const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
|
1841
|
-
const populate = await getService$
|
2018
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1842
2019
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1843
2020
|
const document = await documentManager2.findOne(id, model, {
|
1844
2021
|
populate,
|
@@ -1877,13 +2054,13 @@ const collectionTypes = {
|
|
1877
2054
|
async delete(ctx) {
|
1878
2055
|
const { userAbility } = ctx.state;
|
1879
2056
|
const { id, model } = ctx.params;
|
1880
|
-
const documentManager2 = getService$
|
1881
|
-
const permissionChecker2 = getService$
|
2057
|
+
const documentManager2 = getService$2("document-manager");
|
2058
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1882
2059
|
if (permissionChecker2.cannot.delete()) {
|
1883
2060
|
return ctx.forbidden();
|
1884
2061
|
}
|
1885
2062
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
|
1886
|
-
const populate = await getService$
|
2063
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1887
2064
|
const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1888
2065
|
const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
|
1889
2066
|
if (documentLocales.length === 0) {
|
@@ -1905,14 +2082,14 @@ const collectionTypes = {
|
|
1905
2082
|
const { userAbility } = ctx.state;
|
1906
2083
|
const { id, model } = ctx.params;
|
1907
2084
|
const { body } = ctx.request;
|
1908
|
-
const documentManager2 = getService$
|
1909
|
-
const permissionChecker2 = getService$
|
2085
|
+
const documentManager2 = getService$2("document-manager");
|
2086
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1910
2087
|
if (permissionChecker2.cannot.publish()) {
|
1911
2088
|
return ctx.forbidden();
|
1912
2089
|
}
|
1913
2090
|
const publishedDocument = await strapi.db.transaction(async () => {
|
1914
2091
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1915
|
-
const populate = await getService$
|
2092
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1916
2093
|
let document;
|
1917
2094
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1918
2095
|
const isCreate = fp.isNil(id);
|
@@ -1924,11 +2101,17 @@ const collectionTypes = {
|
|
1924
2101
|
}
|
1925
2102
|
const isUpdate = !isCreate;
|
1926
2103
|
if (isUpdate) {
|
1927
|
-
|
1928
|
-
if (!
|
2104
|
+
const documentExists = documentManager2.exists(model, id);
|
2105
|
+
if (!documentExists) {
|
1929
2106
|
throw new strapiUtils.errors.NotFoundError("Document not found");
|
1930
2107
|
}
|
1931
|
-
|
2108
|
+
document = await documentManager2.findOne(id, model, { populate, locale });
|
2109
|
+
if (!document) {
|
2110
|
+
if (permissionChecker2.cannot.create({ locale }) || permissionChecker2.cannot.publish({ locale })) {
|
2111
|
+
throw new strapiUtils.errors.ForbiddenError();
|
2112
|
+
}
|
2113
|
+
document = await updateDocument(ctx);
|
2114
|
+
} else if (permissionChecker2.can.update(document)) {
|
1932
2115
|
await updateDocument(ctx);
|
1933
2116
|
}
|
1934
2117
|
}
|
@@ -1954,13 +2137,13 @@ const collectionTypes = {
|
|
1954
2137
|
const { body } = ctx.request;
|
1955
2138
|
const { documentIds } = body;
|
1956
2139
|
await validateBulkActionInput(body);
|
1957
|
-
const documentManager2 = getService$
|
1958
|
-
const permissionChecker2 = getService$
|
2140
|
+
const documentManager2 = getService$2("document-manager");
|
2141
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1959
2142
|
if (permissionChecker2.cannot.publish()) {
|
1960
2143
|
return ctx.forbidden();
|
1961
2144
|
}
|
1962
2145
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1963
|
-
const populate = await getService$
|
2146
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1964
2147
|
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1965
2148
|
allowMultipleLocales: true
|
1966
2149
|
});
|
@@ -1985,8 +2168,8 @@ const collectionTypes = {
|
|
1985
2168
|
const { body } = ctx.request;
|
1986
2169
|
const { documentIds } = body;
|
1987
2170
|
await validateBulkActionInput(body);
|
1988
|
-
const documentManager2 = getService$
|
1989
|
-
const permissionChecker2 = getService$
|
2171
|
+
const documentManager2 = getService$2("document-manager");
|
2172
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1990
2173
|
if (permissionChecker2.cannot.unpublish()) {
|
1991
2174
|
return ctx.forbidden();
|
1992
2175
|
}
|
@@ -2015,8 +2198,8 @@ const collectionTypes = {
|
|
2015
2198
|
const {
|
2016
2199
|
body: { discardDraft, ...body }
|
2017
2200
|
} = ctx.request;
|
2018
|
-
const documentManager2 = getService$
|
2019
|
-
const permissionChecker2 = getService$
|
2201
|
+
const documentManager2 = getService$2("document-manager");
|
2202
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2020
2203
|
if (permissionChecker2.cannot.unpublish()) {
|
2021
2204
|
return ctx.forbidden();
|
2022
2205
|
}
|
@@ -2024,7 +2207,7 @@ const collectionTypes = {
|
|
2024
2207
|
return ctx.forbidden();
|
2025
2208
|
}
|
2026
2209
|
const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
|
2027
|
-
const populate = await getService$
|
2210
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2028
2211
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2029
2212
|
const document = await documentManager2.findOne(id, model, {
|
2030
2213
|
populate,
|
@@ -2055,13 +2238,13 @@ const collectionTypes = {
|
|
2055
2238
|
const { userAbility } = ctx.state;
|
2056
2239
|
const { id, model } = ctx.params;
|
2057
2240
|
const { body } = ctx.request;
|
2058
|
-
const documentManager2 = getService$
|
2059
|
-
const permissionChecker2 = getService$
|
2241
|
+
const documentManager2 = getService$2("document-manager");
|
2242
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2060
2243
|
if (permissionChecker2.cannot.discard()) {
|
2061
2244
|
return ctx.forbidden();
|
2062
2245
|
}
|
2063
2246
|
const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
|
2064
|
-
const populate = await getService$
|
2247
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2065
2248
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2066
2249
|
const document = await documentManager2.findOne(id, model, {
|
2067
2250
|
populate,
|
@@ -2086,13 +2269,13 @@ const collectionTypes = {
|
|
2086
2269
|
const { query, body } = ctx.request;
|
2087
2270
|
const { documentIds } = body;
|
2088
2271
|
await validateBulkActionInput(body);
|
2089
|
-
const documentManager2 = getService$
|
2090
|
-
const permissionChecker2 = getService$
|
2272
|
+
const documentManager2 = getService$2("document-manager");
|
2273
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2091
2274
|
if (permissionChecker2.cannot.delete()) {
|
2092
2275
|
return ctx.forbidden();
|
2093
2276
|
}
|
2094
2277
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2095
|
-
const populate = await getService$
|
2278
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2096
2279
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2097
2280
|
const documentLocales = await documentManager2.findLocales(documentIds, model, {
|
2098
2281
|
populate,
|
@@ -2113,13 +2296,13 @@ const collectionTypes = {
|
|
2113
2296
|
async countDraftRelations(ctx) {
|
2114
2297
|
const { userAbility } = ctx.state;
|
2115
2298
|
const { model, id } = ctx.params;
|
2116
|
-
const documentManager2 = getService$
|
2117
|
-
const permissionChecker2 = getService$
|
2299
|
+
const documentManager2 = getService$2("document-manager");
|
2300
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2118
2301
|
if (permissionChecker2.cannot.read()) {
|
2119
2302
|
return ctx.forbidden();
|
2120
2303
|
}
|
2121
2304
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2122
|
-
const populate = await getService$
|
2305
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2123
2306
|
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
2124
2307
|
const entity = await documentManager2.findOne(id, model, { populate, locale, status });
|
2125
2308
|
if (!entity) {
|
@@ -2138,8 +2321,8 @@ const collectionTypes = {
|
|
2138
2321
|
const ids = ctx.request.query.documentIds;
|
2139
2322
|
const locale = ctx.request.query.locale;
|
2140
2323
|
const { model } = ctx.params;
|
2141
|
-
const documentManager2 = getService$
|
2142
|
-
const permissionChecker2 = getService$
|
2324
|
+
const documentManager2 = getService$2("document-manager");
|
2325
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2143
2326
|
if (permissionChecker2.cannot.read()) {
|
2144
2327
|
return ctx.forbidden();
|
2145
2328
|
}
|
@@ -2163,13 +2346,13 @@ const collectionTypes = {
|
|
2163
2346
|
};
|
2164
2347
|
const components$1 = {
|
2165
2348
|
findComponents(ctx) {
|
2166
|
-
const components2 = getService$
|
2167
|
-
const { toDto } = getService$
|
2349
|
+
const components2 = getService$2("components").findAllComponents();
|
2350
|
+
const { toDto } = getService$2("data-mapper");
|
2168
2351
|
ctx.body = { data: components2.map(toDto) };
|
2169
2352
|
},
|
2170
2353
|
async findComponentConfiguration(ctx) {
|
2171
2354
|
const { uid: uid2 } = ctx.params;
|
2172
|
-
const componentService = getService$
|
2355
|
+
const componentService = getService$2("components");
|
2173
2356
|
const component = componentService.findComponent(uid2);
|
2174
2357
|
if (!component) {
|
2175
2358
|
return ctx.notFound("component.notFound");
|
@@ -2186,7 +2369,7 @@ const components$1 = {
|
|
2186
2369
|
async updateComponentConfiguration(ctx) {
|
2187
2370
|
const { uid: uid2 } = ctx.params;
|
2188
2371
|
const { body } = ctx.request;
|
2189
|
-
const componentService = getService$
|
2372
|
+
const componentService = getService$2("components");
|
2190
2373
|
const component = componentService.findComponent(uid2);
|
2191
2374
|
if (!component) {
|
2192
2375
|
return ctx.notFound("component.notFound");
|
@@ -2220,12 +2403,12 @@ const contentTypes = {
|
|
2220
2403
|
} catch (error) {
|
2221
2404
|
return ctx.send({ error }, 400);
|
2222
2405
|
}
|
2223
|
-
const contentTypes2 = getService$
|
2224
|
-
const { toDto } = getService$
|
2406
|
+
const contentTypes2 = getService$2("content-types").findContentTypesByKind(kind);
|
2407
|
+
const { toDto } = getService$2("data-mapper");
|
2225
2408
|
ctx.body = { data: contentTypes2.map(toDto) };
|
2226
2409
|
},
|
2227
2410
|
async findContentTypesSettings(ctx) {
|
2228
|
-
const { findAllContentTypes, findConfiguration } = getService$
|
2411
|
+
const { findAllContentTypes, findConfiguration } = getService$2("content-types");
|
2229
2412
|
const contentTypes2 = await findAllContentTypes();
|
2230
2413
|
const configurations = await Promise.all(
|
2231
2414
|
contentTypes2.map(async (contentType) => {
|
@@ -2239,7 +2422,7 @@ const contentTypes = {
|
|
2239
2422
|
},
|
2240
2423
|
async findContentTypeConfiguration(ctx) {
|
2241
2424
|
const { uid: uid2 } = ctx.params;
|
2242
|
-
const contentTypeService = getService$
|
2425
|
+
const contentTypeService = getService$2("content-types");
|
2243
2426
|
const contentType = await contentTypeService.findContentType(uid2);
|
2244
2427
|
if (!contentType) {
|
2245
2428
|
return ctx.notFound("contentType.notFound");
|
@@ -2261,13 +2444,13 @@ const contentTypes = {
|
|
2261
2444
|
const { userAbility } = ctx.state;
|
2262
2445
|
const { uid: uid2 } = ctx.params;
|
2263
2446
|
const { body } = ctx.request;
|
2264
|
-
const contentTypeService = getService$
|
2265
|
-
const metricsService = getService$
|
2447
|
+
const contentTypeService = getService$2("content-types");
|
2448
|
+
const metricsService = getService$2("metrics");
|
2266
2449
|
const contentType = await contentTypeService.findContentType(uid2);
|
2267
2450
|
if (!contentType) {
|
2268
2451
|
return ctx.notFound("contentType.notFound");
|
2269
2452
|
}
|
2270
|
-
if (!getService$
|
2453
|
+
if (!getService$2("permission").canConfigureContentType({ userAbility, contentType })) {
|
2271
2454
|
return ctx.forbidden();
|
2272
2455
|
}
|
2273
2456
|
let input;
|
@@ -2300,10 +2483,10 @@ const contentTypes = {
|
|
2300
2483
|
};
|
2301
2484
|
const init = {
|
2302
2485
|
getInitData(ctx) {
|
2303
|
-
const { toDto } = getService$
|
2304
|
-
const { findAllComponents } = getService$
|
2305
|
-
const { getAllFieldSizes } = getService$
|
2306
|
-
const { findAllContentTypes } = getService$
|
2486
|
+
const { toDto } = getService$2("data-mapper");
|
2487
|
+
const { findAllComponents } = getService$2("components");
|
2488
|
+
const { getAllFieldSizes } = getService$2("field-sizes");
|
2489
|
+
const { findAllContentTypes } = getService$2("content-types");
|
2307
2490
|
ctx.body = {
|
2308
2491
|
data: {
|
2309
2492
|
fieldSizes: getAllFieldSizes(),
|
@@ -2339,7 +2522,7 @@ const addFiltersClause = (params, filtersClause) => {
|
|
2339
2522
|
params.filters.$and.push(filtersClause);
|
2340
2523
|
};
|
2341
2524
|
const sanitizeMainField = (model, mainField, userAbility) => {
|
2342
|
-
const permissionChecker2 = getService$
|
2525
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
2343
2526
|
userAbility,
|
2344
2527
|
model: model.uid
|
2345
2528
|
});
|
@@ -2353,15 +2536,27 @@ const sanitizeMainField = (model, mainField, userAbility) => {
|
|
2353
2536
|
}
|
2354
2537
|
return mainField;
|
2355
2538
|
};
|
2356
|
-
const addStatusToRelations = async (
|
2357
|
-
if (!strapiUtils.contentTypes.hasDraftAndPublish(strapi.
|
2539
|
+
const addStatusToRelations = async (targetUid, relations2) => {
|
2540
|
+
if (!strapiUtils.contentTypes.hasDraftAndPublish(strapi.getModel(targetUid))) {
|
2541
|
+
return relations2;
|
2542
|
+
}
|
2543
|
+
const documentMetadata2 = getService$2("document-metadata");
|
2544
|
+
if (!relations2.length) {
|
2358
2545
|
return relations2;
|
2359
2546
|
}
|
2360
|
-
const
|
2361
|
-
const
|
2547
|
+
const firstRelation = relations2[0];
|
2548
|
+
const filters = {
|
2549
|
+
documentId: { $in: relations2.map((r) => r.documentId) },
|
2550
|
+
// NOTE: find the "opposite" status
|
2551
|
+
publishedAt: firstRelation.publishedAt !== null ? { $null: true } : { $notNull: true }
|
2552
|
+
};
|
2553
|
+
const availableStatus = await strapi.query(targetUid).findMany({
|
2554
|
+
select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"],
|
2555
|
+
filters
|
2556
|
+
});
|
2362
2557
|
return relations2.map((relation) => {
|
2363
|
-
const availableStatuses =
|
2364
|
-
(availableDocument) => availableDocument.documentId === relation.documentId
|
2558
|
+
const availableStatuses = availableStatus.filter(
|
2559
|
+
(availableDocument) => availableDocument.documentId === relation.documentId && (relation.locale ? availableDocument.locale === relation.locale : true)
|
2365
2560
|
);
|
2366
2561
|
return {
|
2367
2562
|
...relation,
|
@@ -2382,11 +2577,8 @@ const validateLocale = (sourceUid, targetUid, locale) => {
|
|
2382
2577
|
const isLocalized = strapi.plugin("i18n").service("content-types").isLocalizedContentType;
|
2383
2578
|
const isSourceLocalized = isLocalized(sourceModel);
|
2384
2579
|
const isTargetLocalized = isLocalized(targetModel);
|
2385
|
-
let validatedLocale = locale;
|
2386
|
-
if (!targetModel || !isTargetLocalized)
|
2387
|
-
validatedLocale = void 0;
|
2388
2580
|
return {
|
2389
|
-
locale
|
2581
|
+
locale,
|
2390
2582
|
isSourceLocalized,
|
2391
2583
|
isTargetLocalized
|
2392
2584
|
};
|
@@ -2426,7 +2618,7 @@ const relations = {
|
|
2426
2618
|
ctx.request?.query?.locale
|
2427
2619
|
);
|
2428
2620
|
const { status } = validateStatus(sourceUid, ctx.request?.query?.status);
|
2429
|
-
const permissionChecker2 = getService$
|
2621
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
2430
2622
|
userAbility,
|
2431
2623
|
model
|
2432
2624
|
});
|
@@ -2451,7 +2643,7 @@ const relations = {
|
|
2451
2643
|
where.id = id;
|
2452
2644
|
}
|
2453
2645
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2454
|
-
const populate = await getService$
|
2646
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2455
2647
|
const currentEntity = await strapi.db.query(model).findOne({
|
2456
2648
|
where,
|
2457
2649
|
populate
|
@@ -2466,7 +2658,7 @@ const relations = {
|
|
2466
2658
|
}
|
2467
2659
|
entryId = currentEntity.id;
|
2468
2660
|
}
|
2469
|
-
const modelConfig = isComponent2 ? await getService$
|
2661
|
+
const modelConfig = isComponent2 ? await getService$2("components").findConfiguration(sourceSchema) : await getService$2("content-types").findConfiguration(sourceSchema);
|
2470
2662
|
const targetSchema = strapi.getModel(targetUid);
|
2471
2663
|
const mainField = fp.flow(
|
2472
2664
|
fp.prop(`metadatas.${targetField}.edit.mainField`),
|
@@ -2489,7 +2681,7 @@ const relations = {
|
|
2489
2681
|
attribute,
|
2490
2682
|
fieldsToSelect,
|
2491
2683
|
mainField,
|
2492
|
-
source: { schema: sourceSchema },
|
2684
|
+
source: { schema: sourceSchema, isLocalized: isSourceLocalized },
|
2493
2685
|
target: { schema: targetSchema, isLocalized: isTargetLocalized },
|
2494
2686
|
sourceSchema,
|
2495
2687
|
targetSchema,
|
@@ -2511,7 +2703,8 @@ const relations = {
|
|
2511
2703
|
fieldsToSelect,
|
2512
2704
|
mainField,
|
2513
2705
|
source: {
|
2514
|
-
schema: { uid: sourceUid, modelType: sourceModelType }
|
2706
|
+
schema: { uid: sourceUid, modelType: sourceModelType },
|
2707
|
+
isLocalized: isSourceLocalized
|
2515
2708
|
},
|
2516
2709
|
target: {
|
2517
2710
|
schema: { uid: targetUid },
|
@@ -2519,7 +2712,7 @@ const relations = {
|
|
2519
2712
|
}
|
2520
2713
|
} = await this.extractAndValidateRequestInfo(ctx, id);
|
2521
2714
|
const { idsToOmit, idsToInclude, _q, ...query } = ctx.request.query;
|
2522
|
-
const permissionChecker2 = getService$
|
2715
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
2523
2716
|
userAbility: ctx.state.userAbility,
|
2524
2717
|
model: targetUid
|
2525
2718
|
});
|
@@ -2549,12 +2742,16 @@ const relations = {
|
|
2549
2742
|
} else {
|
2550
2743
|
where.id = id;
|
2551
2744
|
}
|
2552
|
-
|
2553
|
-
|
2745
|
+
const publishedAt = getPublishedAtClause(status, targetUid);
|
2746
|
+
if (!fp.isEmpty(publishedAt)) {
|
2747
|
+
where[`${alias}.published_at`] = publishedAt;
|
2554
2748
|
}
|
2555
|
-
if (
|
2749
|
+
if (isTargetLocalized && locale) {
|
2556
2750
|
where[`${alias}.locale`] = locale;
|
2557
2751
|
}
|
2752
|
+
if (isSourceLocalized && locale) {
|
2753
|
+
where.locale = locale;
|
2754
|
+
}
|
2558
2755
|
if ((idsToInclude?.length ?? 0) !== 0) {
|
2559
2756
|
where[`${alias}.id`].$notIn = idsToInclude;
|
2560
2757
|
}
|
@@ -2572,7 +2769,8 @@ const relations = {
|
|
2572
2769
|
id: { $notIn: fp.uniq(idsToOmit) }
|
2573
2770
|
});
|
2574
2771
|
}
|
2575
|
-
const
|
2772
|
+
const dbQuery = strapi.get("query-params").transform(targetUid, queryParams);
|
2773
|
+
const res = await strapi.db.query(targetUid).findPage(dbQuery);
|
2576
2774
|
ctx.body = {
|
2577
2775
|
...res,
|
2578
2776
|
results: await addStatusToRelations(targetUid, res.results)
|
@@ -2587,21 +2785,33 @@ const relations = {
|
|
2587
2785
|
attribute,
|
2588
2786
|
targetField,
|
2589
2787
|
fieldsToSelect,
|
2590
|
-
|
2591
|
-
|
2592
|
-
}
|
2593
|
-
target: {
|
2594
|
-
schema: { uid: targetUid }
|
2595
|
-
}
|
2788
|
+
status,
|
2789
|
+
source: { schema: sourceSchema },
|
2790
|
+
target: { schema: targetSchema }
|
2596
2791
|
} = await this.extractAndValidateRequestInfo(ctx, id);
|
2597
|
-
const
|
2792
|
+
const { uid: sourceUid } = sourceSchema;
|
2793
|
+
const { uid: targetUid } = targetSchema;
|
2794
|
+
const permissionQuery = await getService$2("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
|
2598
2795
|
const dbQuery = strapi.db.query(sourceUid);
|
2599
2796
|
const loadRelations = strapiUtils.relations.isAnyToMany(attribute) ? (...args) => dbQuery.loadPages(...args) : (...args) => dbQuery.load(...args).then((res2) => ({ results: res2 ? [res2] : [] }));
|
2797
|
+
const filters = {};
|
2798
|
+
if (sourceSchema?.options?.draftAndPublish) {
|
2799
|
+
if (targetSchema?.options?.draftAndPublish) {
|
2800
|
+
if (status === "published") {
|
2801
|
+
filters.publishedAt = { $notNull: true };
|
2802
|
+
} else {
|
2803
|
+
filters.publishedAt = { $null: true };
|
2804
|
+
}
|
2805
|
+
}
|
2806
|
+
} else if (targetSchema?.options?.draftAndPublish) {
|
2807
|
+
filters.publishedAt = { $null: true };
|
2808
|
+
}
|
2600
2809
|
const res = await loadRelations({ id: entryId }, targetField, {
|
2601
|
-
select: ["id", "documentId", "locale", "publishedAt"],
|
2810
|
+
select: ["id", "documentId", "locale", "publishedAt", "updatedAt"],
|
2602
2811
|
ordering: "desc",
|
2603
2812
|
page: ctx.request.query.page,
|
2604
|
-
pageSize: ctx.request.query.pageSize
|
2813
|
+
pageSize: ctx.request.query.pageSize,
|
2814
|
+
filters
|
2605
2815
|
});
|
2606
2816
|
const loadedIds = res.results.map((item) => item.id);
|
2607
2817
|
addFiltersClause(permissionQuery, { id: { $in: loadedIds } });
|
@@ -2622,10 +2832,10 @@ const relations = {
|
|
2622
2832
|
}
|
2623
2833
|
};
|
2624
2834
|
const buildPopulateFromQuery = async (query, model) => {
|
2625
|
-
return getService$
|
2835
|
+
return getService$2("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
|
2626
2836
|
};
|
2627
2837
|
const findDocument = async (query, uid2, opts = {}) => {
|
2628
|
-
const documentManager2 = getService$
|
2838
|
+
const documentManager2 = getService$2("document-manager");
|
2629
2839
|
const populate = await buildPopulateFromQuery(query, uid2);
|
2630
2840
|
return documentManager2.findMany({ ...opts, populate }, uid2).then((documents) => documents[0]);
|
2631
2841
|
};
|
@@ -2633,8 +2843,8 @@ const createOrUpdateDocument = async (ctx, opts) => {
|
|
2633
2843
|
const { user, userAbility } = ctx.state;
|
2634
2844
|
const { model } = ctx.params;
|
2635
2845
|
const { body, query } = ctx.request;
|
2636
|
-
const documentManager2 = getService$
|
2637
|
-
const permissionChecker2 = getService$
|
2846
|
+
const documentManager2 = getService$2("document-manager");
|
2847
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2638
2848
|
if (permissionChecker2.cannot.create() && permissionChecker2.cannot.update()) {
|
2639
2849
|
throw new strapiUtils.errors.ForbiddenError();
|
2640
2850
|
}
|
@@ -2675,7 +2885,7 @@ const singleTypes = {
|
|
2675
2885
|
const { userAbility } = ctx.state;
|
2676
2886
|
const { model } = ctx.params;
|
2677
2887
|
const { query = {} } = ctx.request;
|
2678
|
-
const permissionChecker2 = getService$
|
2888
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2679
2889
|
if (permissionChecker2.cannot.read()) {
|
2680
2890
|
return ctx.forbidden();
|
2681
2891
|
}
|
@@ -2694,7 +2904,7 @@ const singleTypes = {
|
|
2694
2904
|
permissionChecker2,
|
2695
2905
|
model,
|
2696
2906
|
// @ts-expect-error - fix types
|
2697
|
-
{
|
2907
|
+
{ documentId: document.documentId, locale, publishedAt: null },
|
2698
2908
|
{ availableLocales: true, availableStatus: false }
|
2699
2909
|
);
|
2700
2910
|
ctx.body = { data: {}, meta };
|
@@ -2709,7 +2919,7 @@ const singleTypes = {
|
|
2709
2919
|
async createOrUpdate(ctx) {
|
2710
2920
|
const { userAbility } = ctx.state;
|
2711
2921
|
const { model } = ctx.params;
|
2712
|
-
const permissionChecker2 = getService$
|
2922
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2713
2923
|
const document = await createOrUpdateDocument(ctx);
|
2714
2924
|
const sanitizedDocument = await permissionChecker2.sanitizeOutput(document);
|
2715
2925
|
ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedDocument);
|
@@ -2718,8 +2928,8 @@ const singleTypes = {
|
|
2718
2928
|
const { userAbility } = ctx.state;
|
2719
2929
|
const { model } = ctx.params;
|
2720
2930
|
const { query = {} } = ctx.request;
|
2721
|
-
const documentManager2 = getService$
|
2722
|
-
const permissionChecker2 = getService$
|
2931
|
+
const documentManager2 = getService$2("document-manager");
|
2932
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2723
2933
|
if (permissionChecker2.cannot.delete()) {
|
2724
2934
|
return ctx.forbidden();
|
2725
2935
|
}
|
@@ -2747,8 +2957,8 @@ const singleTypes = {
|
|
2747
2957
|
const { userAbility } = ctx.state;
|
2748
2958
|
const { model } = ctx.params;
|
2749
2959
|
const { query = {} } = ctx.request;
|
2750
|
-
const documentManager2 = getService$
|
2751
|
-
const permissionChecker2 = getService$
|
2960
|
+
const documentManager2 = getService$2("document-manager");
|
2961
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2752
2962
|
if (permissionChecker2.cannot.publish()) {
|
2753
2963
|
return ctx.forbidden();
|
2754
2964
|
}
|
@@ -2776,8 +2986,8 @@ const singleTypes = {
|
|
2776
2986
|
body: { discardDraft, ...body },
|
2777
2987
|
query = {}
|
2778
2988
|
} = ctx.request;
|
2779
|
-
const documentManager2 = getService$
|
2780
|
-
const permissionChecker2 = getService$
|
2989
|
+
const documentManager2 = getService$2("document-manager");
|
2990
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2781
2991
|
if (permissionChecker2.cannot.unpublish()) {
|
2782
2992
|
return ctx.forbidden();
|
2783
2993
|
}
|
@@ -2811,8 +3021,8 @@ const singleTypes = {
|
|
2811
3021
|
const { userAbility } = ctx.state;
|
2812
3022
|
const { model } = ctx.params;
|
2813
3023
|
const { body, query = {} } = ctx.request;
|
2814
|
-
const documentManager2 = getService$
|
2815
|
-
const permissionChecker2 = getService$
|
3024
|
+
const documentManager2 = getService$2("document-manager");
|
3025
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2816
3026
|
if (permissionChecker2.cannot.discard()) {
|
2817
3027
|
return ctx.forbidden();
|
2818
3028
|
}
|
@@ -2835,8 +3045,8 @@ const singleTypes = {
|
|
2835
3045
|
const { userAbility } = ctx.state;
|
2836
3046
|
const { model } = ctx.params;
|
2837
3047
|
const { query } = ctx.request;
|
2838
|
-
const documentManager2 = getService$
|
2839
|
-
const permissionChecker2 = getService$
|
3048
|
+
const documentManager2 = getService$2("document-manager");
|
3049
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2840
3050
|
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2841
3051
|
if (permissionChecker2.cannot.read()) {
|
2842
3052
|
return ctx.forbidden();
|
@@ -2860,7 +3070,7 @@ const uid$1 = {
|
|
2860
3070
|
const { query = {} } = ctx.request;
|
2861
3071
|
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2862
3072
|
await validateUIDField(contentTypeUID, field);
|
2863
|
-
const uidService = getService$
|
3073
|
+
const uidService = getService$2("uid");
|
2864
3074
|
ctx.body = {
|
2865
3075
|
data: await uidService.generateUIDField({ contentTypeUID, field, data, locale })
|
2866
3076
|
};
|
@@ -2872,7 +3082,7 @@ const uid$1 = {
|
|
2872
3082
|
const { query = {} } = ctx.request;
|
2873
3083
|
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2874
3084
|
await validateUIDField(contentTypeUID, field);
|
2875
|
-
const uidService = getService$
|
3085
|
+
const uidService = getService$2("uid");
|
2876
3086
|
const isAvailable = await uidService.checkUIDAvailability({
|
2877
3087
|
contentTypeUID,
|
2878
3088
|
field,
|
@@ -2893,7 +3103,8 @@ const controllers = {
|
|
2893
3103
|
relations,
|
2894
3104
|
"single-types": singleTypes,
|
2895
3105
|
uid: uid$1,
|
2896
|
-
...history.controllers ? history.controllers : {}
|
3106
|
+
...history.controllers ? history.controllers : {},
|
3107
|
+
...preview.controllers ? preview.controllers : {}
|
2897
3108
|
};
|
2898
3109
|
const keys = {
|
2899
3110
|
CONFIGURATION: "configuration"
|
@@ -3044,12 +3255,12 @@ async function syncMetadatas(configuration, schema) {
|
|
3044
3255
|
return ___default.default.assign(metasWithDefaults, updatedMetas);
|
3045
3256
|
}
|
3046
3257
|
const getTargetSchema = (targetModel) => {
|
3047
|
-
return getService$
|
3258
|
+
return getService$2("content-types").findContentType(targetModel);
|
3048
3259
|
};
|
3049
3260
|
const DEFAULT_LIST_LENGTH = 4;
|
3050
3261
|
const MAX_ROW_SIZE = 12;
|
3051
3262
|
const isAllowedFieldSize = (type, size) => {
|
3052
|
-
const { getFieldSize } = getService$
|
3263
|
+
const { getFieldSize } = getService$2("field-sizes");
|
3053
3264
|
const fieldSize = getFieldSize(type);
|
3054
3265
|
if (!fieldSize.isResizable && size !== fieldSize.default) {
|
3055
3266
|
return false;
|
@@ -3057,7 +3268,7 @@ const isAllowedFieldSize = (type, size) => {
|
|
3057
3268
|
return size <= MAX_ROW_SIZE;
|
3058
3269
|
};
|
3059
3270
|
const getDefaultFieldSize = (attribute) => {
|
3060
|
-
const { hasFieldSize, getFieldSize } = getService$
|
3271
|
+
const { hasFieldSize, getFieldSize } = getService$2("field-sizes");
|
3061
3272
|
return getFieldSize(hasFieldSize(attribute.customField) ? attribute.customField : attribute.type).default;
|
3062
3273
|
};
|
3063
3274
|
async function createDefaultLayouts(schema) {
|
@@ -3092,7 +3303,7 @@ function syncLayouts(configuration, schema) {
|
|
3092
3303
|
for (const el of row) {
|
3093
3304
|
if (!hasEditableAttribute(schema, el.name))
|
3094
3305
|
continue;
|
3095
|
-
const { hasFieldSize } = getService$
|
3306
|
+
const { hasFieldSize } = getService$2("field-sizes");
|
3096
3307
|
const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
|
3097
3308
|
if (!isAllowedFieldSize(fieldType, el.size)) {
|
3098
3309
|
elementsToReAppend.push(el.name);
|
@@ -3232,17 +3443,17 @@ const configurationService$1 = createConfigurationService({
|
|
3232
3443
|
isComponent: true,
|
3233
3444
|
prefix: STORE_KEY_PREFIX,
|
3234
3445
|
getModels() {
|
3235
|
-
const { toContentManagerModel } = getService$
|
3446
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3236
3447
|
return fp.mapValues(toContentManagerModel, strapi.components);
|
3237
3448
|
}
|
3238
3449
|
});
|
3239
3450
|
const components = ({ strapi: strapi2 }) => ({
|
3240
3451
|
findAllComponents() {
|
3241
|
-
const { toContentManagerModel } = getService$
|
3452
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3242
3453
|
return Object.values(strapi2.components).map(toContentManagerModel);
|
3243
3454
|
},
|
3244
3455
|
findComponent(uid2) {
|
3245
|
-
const { toContentManagerModel } = getService$
|
3456
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3246
3457
|
const component = strapi2.components[uid2];
|
3247
3458
|
return fp.isNil(component) ? component : toContentManagerModel(component);
|
3248
3459
|
},
|
@@ -3293,17 +3504,17 @@ const configurationService = createConfigurationService({
|
|
3293
3504
|
storeUtils,
|
3294
3505
|
prefix: "content_types",
|
3295
3506
|
getModels() {
|
3296
|
-
const { toContentManagerModel } = getService$
|
3507
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3297
3508
|
return fp.mapValues(toContentManagerModel, strapi.contentTypes);
|
3298
3509
|
}
|
3299
3510
|
});
|
3300
3511
|
const service = ({ strapi: strapi2 }) => ({
|
3301
3512
|
findAllContentTypes() {
|
3302
|
-
const { toContentManagerModel } = getService$
|
3513
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3303
3514
|
return Object.values(strapi2.contentTypes).map(toContentManagerModel);
|
3304
3515
|
},
|
3305
3516
|
findContentType(uid2) {
|
3306
|
-
const { toContentManagerModel } = getService$
|
3517
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3307
3518
|
const contentType = strapi2.contentTypes[uid2];
|
3308
3519
|
return fp.isNil(contentType) ? contentType : toContentManagerModel(contentType);
|
3309
3520
|
},
|
@@ -3332,7 +3543,7 @@ const service = ({ strapi: strapi2 }) => ({
|
|
3332
3543
|
return this.findConfiguration(contentType);
|
3333
3544
|
},
|
3334
3545
|
findComponentsConfigurations(contentType) {
|
3335
|
-
return getService$
|
3546
|
+
return getService$2("components").findComponentsConfigurations(contentType);
|
3336
3547
|
},
|
3337
3548
|
syncConfigurations() {
|
3338
3549
|
return configurationService.syncConfigurations();
|
@@ -3604,7 +3815,7 @@ const permission = ({ strapi: strapi2 }) => ({
|
|
3604
3815
|
return userAbility.can(action);
|
3605
3816
|
},
|
3606
3817
|
async registerPermissions() {
|
3607
|
-
const displayedContentTypes = getService$
|
3818
|
+
const displayedContentTypes = getService$2("content-types").findDisplayedContentTypes();
|
3608
3819
|
const contentTypesUids = displayedContentTypes.map(fp.prop("uid"));
|
3609
3820
|
const actions = [
|
3610
3821
|
{
|
@@ -3880,7 +4091,7 @@ const getQueryPopulate = async (uid2, query) => {
|
|
3880
4091
|
return populateQuery;
|
3881
4092
|
};
|
3882
4093
|
const buildDeepPopulate = (uid2) => {
|
3883
|
-
return getService$
|
4094
|
+
return getService$2("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
|
3884
4095
|
};
|
3885
4096
|
const populateBuilder = (uid2) => {
|
3886
4097
|
let getInitialPopulate = async () => {
|
@@ -4065,7 +4276,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4065
4276
|
*/
|
4066
4277
|
async getAvailableLocales(uid2, version, allVersions, validatableFields = []) {
|
4067
4278
|
const versionsByLocale = fp.groupBy("locale", allVersions);
|
4068
|
-
|
4279
|
+
if (version.locale) {
|
4280
|
+
delete versionsByLocale[version.locale];
|
4281
|
+
}
|
4069
4282
|
const model = strapi2.getModel(uid2);
|
4070
4283
|
const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
|
4071
4284
|
const traversalFunction = async (localeVersion) => strapiUtils.traverseEntity(
|
@@ -4421,7 +4634,8 @@ const services = {
|
|
4421
4634
|
permission,
|
4422
4635
|
"populate-builder": populateBuilder$1,
|
4423
4636
|
uid,
|
4424
|
-
...history.services ? history.services : {}
|
4637
|
+
...history.services ? history.services : {},
|
4638
|
+
...preview.services ? preview.services : {}
|
4425
4639
|
};
|
4426
4640
|
const index = () => {
|
4427
4641
|
return {
|