@strapi/content-manager 0.0.0-experimental.e14656d3b8681880212c13260b9a2b340c182f2d → 0.0.0-experimental.e350eaa6073e65190102b4b798c32c287053cc02
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/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-D_M8iBw5.js → ComponentConfigurationPage-BTR_hQow.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-D_M8iBw5.js.map → ComponentConfigurationPage-BTR_hQow.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-qemkOlnj.mjs → ComponentConfigurationPage-bLQr82ce.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-qemkOlnj.mjs.map → ComponentConfigurationPage-bLQr82ce.mjs.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
- package/dist/_chunks/{EditConfigurationPage-CjUrEewK.mjs → EditConfigurationPage-BhRSnUsL.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-CjUrEewK.mjs.map → EditConfigurationPage-BhRSnUsL.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BePwPuHy.js → EditConfigurationPage-z39Wv3E6.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-BePwPuHy.js.map → EditConfigurationPage-z39Wv3E6.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-De8GyU8P.mjs → EditViewPage-BCjNxNlY.mjs} +50 -10
- package/dist/_chunks/EditViewPage-BCjNxNlY.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-B-RJeiJD.js → EditViewPage-wujOq90c.js} +50 -11
- package/dist/_chunks/EditViewPage-wujOq90c.js.map +1 -0
- package/dist/_chunks/{Field-dq8Tg1M_.js → Field-B5QXnctJ.js} +238 -153
- package/dist/_chunks/Field-B5QXnctJ.js.map +1 -0
- package/dist/_chunks/{Field-pb2o8uBe.mjs → Field-Byr3mPTl.mjs} +232 -147
- package/dist/_chunks/Field-Byr3mPTl.mjs.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-DJn0Dxha.mjs → Form-BZgvE8C8.mjs} +17 -9
- package/dist/_chunks/Form-BZgvE8C8.mjs.map +1 -0
- package/dist/_chunks/{Form-DGIf4jQU.js → Form-D7mexvm3.js} +19 -12
- package/dist/_chunks/Form-D7mexvm3.js.map +1 -0
- package/dist/_chunks/{History-BowL3JKP.mjs → History-CqNgxkqK.mjs} +43 -100
- package/dist/_chunks/History-CqNgxkqK.mjs.map +1 -0
- package/dist/_chunks/{History-Dh2NEHnR.js → History-DYl2A8Z_.js} +42 -100
- package/dist/_chunks/History-DYl2A8Z_.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BxYCWz9e.js → ListConfigurationPage-BXnu_OoY.js} +7 -7
- package/dist/_chunks/ListConfigurationPage-BXnu_OoY.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BpVOB-hn.mjs → ListConfigurationPage-BbQjzKkQ.mjs} +7 -6
- package/dist/_chunks/ListConfigurationPage-BbQjzKkQ.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-4XsciqHZ.js → ListViewPage-BtSi8C1l.js} +103 -77
- package/dist/_chunks/ListViewPage-BtSi8C1l.js.map +1 -0
- package/dist/_chunks/{ListViewPage-CXFUjZQC.mjs → ListViewPage-D4ofkbjR.mjs} +99 -72
- package/dist/_chunks/ListViewPage-D4ofkbjR.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-C8OpoHeU.js → NoContentTypePage-CitJeOq4.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-C8OpoHeU.js.map → NoContentTypePage-CitJeOq4.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DuhOTp3x.mjs → NoContentTypePage-DyUx5mXh.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DuhOTp3x.mjs.map → NoContentTypePage-DyUx5mXh.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DVz3mzDz.mjs → NoPermissionsPage-DhIiyWkk.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DVz3mzDz.mjs.map → NoPermissionsPage-DhIiyWkk.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-y_r7DVA2.js → NoPermissionsPage-DzgWz0M-.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-y_r7DVA2.js.map → NoPermissionsPage-DzgWz0M-.js.map} +1 -1
- package/dist/_chunks/Preview-BaYGJ0nb.mjs +293 -0
- package/dist/_chunks/Preview-BaYGJ0nb.mjs.map +1 -0
- package/dist/_chunks/Preview-DfNx8Ke-.js +311 -0
- package/dist/_chunks/Preview-DfNx8Ke-.js.map +1 -0
- package/dist/_chunks/{Relations-CVNLrn1Y.mjs → Relations-DM2yUTST.mjs} +75 -41
- package/dist/_chunks/Relations-DM2yUTST.mjs.map +1 -0
- package/dist/_chunks/{Relations-DPFCAa7b.js → Relations-DuKCaXrv.js} +75 -42
- package/dist/_chunks/Relations-DuKCaXrv.js.map +1 -0
- package/dist/_chunks/{en-uOUIxfcQ.js → en-BK8Xyl5I.js} +28 -15
- package/dist/_chunks/{en-uOUIxfcQ.js.map → en-BK8Xyl5I.js.map} +1 -1
- package/dist/_chunks/{en-BrCTWlZv.mjs → en-Dtk_ot79.mjs} +28 -15
- package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-Dtk_ot79.mjs.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/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-C3fJE-1-.js → index-BUWEmX8m.js} +1273 -996
- package/dist/_chunks/index-BUWEmX8m.js.map +1 -0
- package/dist/_chunks/{index-DiMrfcfy.mjs → index-DVAIIsOs.mjs} +1276 -999
- package/dist/_chunks/index-DVAIIsOs.mjs.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-ls3gxfpH.mjs → layout-Bxsv5mP7.mjs} +6 -5
- package/dist/_chunks/{layout-ls3gxfpH.mjs.map → layout-Bxsv5mP7.mjs.map} +1 -1
- package/dist/_chunks/{layout-C788OmNr.js → layout-C3fN7Ejz.js} +7 -7
- package/dist/_chunks/{layout-C788OmNr.js.map → layout-C3fN7Ejz.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-DYeotliT.js → relations-BPZKAoEY.js} +6 -7
- package/dist/_chunks/relations-BPZKAoEY.js.map +1 -0
- package/dist/_chunks/{relations-CLcOmGO0.mjs → relations-o3pPhzY4.mjs} +6 -7
- package/dist/_chunks/relations-o3pPhzY4.mjs.map +1 -0
- 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/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
- 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/content-manager.d.ts +3 -2
- 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/DocumentActions.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +0 -32
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- 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/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/admin/src/services/documents.d.ts +3 -4
- package/dist/server/index.js +453 -201
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +453 -200
- 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 +3 -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/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 +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -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 +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- 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/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.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 +17 -15
- package/dist/_chunks/EditViewPage-B-RJeiJD.js.map +0 -1
- package/dist/_chunks/EditViewPage-De8GyU8P.mjs.map +0 -1
- package/dist/_chunks/Field-dq8Tg1M_.js.map +0 -1
- package/dist/_chunks/Field-pb2o8uBe.mjs.map +0 -1
- package/dist/_chunks/Form-DGIf4jQU.js.map +0 -1
- package/dist/_chunks/Form-DJn0Dxha.mjs.map +0 -1
- package/dist/_chunks/History-BowL3JKP.mjs.map +0 -1
- package/dist/_chunks/History-Dh2NEHnR.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-BpVOB-hn.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-BxYCWz9e.js.map +0 -1
- package/dist/_chunks/ListViewPage-4XsciqHZ.js.map +0 -1
- package/dist/_chunks/ListViewPage-CXFUjZQC.mjs.map +0 -1
- package/dist/_chunks/Relations-CVNLrn1Y.mjs.map +0 -1
- package/dist/_chunks/Relations-DPFCAa7b.js.map +0 -1
- package/dist/_chunks/index-C3fJE-1-.js.map +0 -1
- package/dist/_chunks/index-DiMrfcfy.mjs.map +0 -1
- package/dist/_chunks/relations-CLcOmGO0.mjs.map +0 -1
- package/dist/_chunks/relations-DYeotliT.js.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
@@ -10,8 +10,7 @@ const qs = require("qs");
|
|
10
10
|
const slugify = require("@sindresorhus/slugify");
|
11
11
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
12
12
|
function _interopNamespace(e) {
|
13
|
-
if (e && e.__esModule)
|
14
|
-
return e;
|
13
|
+
if (e && e.__esModule) return e;
|
15
14
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
16
15
|
if (e) {
|
17
16
|
for (const k in e) {
|
@@ -33,10 +32,10 @@ const isNil__default = /* @__PURE__ */ _interopDefault(isNil);
|
|
33
32
|
const ___default = /* @__PURE__ */ _interopDefault(_);
|
34
33
|
const qs__default = /* @__PURE__ */ _interopDefault(qs);
|
35
34
|
const slugify__default = /* @__PURE__ */ _interopDefault(slugify);
|
36
|
-
const getService$
|
35
|
+
const getService$2 = (name) => {
|
37
36
|
return strapi.plugin("content-manager").service(name);
|
38
37
|
};
|
39
|
-
function getService(strapi2, name) {
|
38
|
+
function getService$1(strapi2, name) {
|
40
39
|
return strapi2.service(`plugin::content-manager.${name}`);
|
41
40
|
}
|
42
41
|
const historyRestoreVersionSchema = yup__namespace.object().shape({
|
@@ -72,7 +71,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
72
71
|
if (!isSingleType && (!contentTypeUid || !ctx.query.documentId)) {
|
73
72
|
throw new strapiUtils.errors.ForbiddenError("contentType and documentId are required");
|
74
73
|
}
|
75
|
-
const permissionChecker2 = getService$
|
74
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
76
75
|
userAbility: ctx.state.userAbility,
|
77
76
|
model: ctx.query.contentType
|
78
77
|
});
|
@@ -80,7 +79,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
80
79
|
return ctx.forbidden();
|
81
80
|
}
|
82
81
|
const query = await permissionChecker2.sanitizeQuery(ctx.query);
|
83
|
-
const { results, pagination } = await getService(strapi2, "history").findVersionsPage({
|
82
|
+
const { results, pagination } = await getService$1(strapi2, "history").findVersionsPage({
|
84
83
|
query: {
|
85
84
|
...query,
|
86
85
|
...getValidPagination({ page: query.page, pageSize: query.pageSize })
|
@@ -105,14 +104,14 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
105
104
|
async restoreVersion(ctx) {
|
106
105
|
const request = ctx.request;
|
107
106
|
await validateRestoreVersion(request.body, "contentType is required");
|
108
|
-
const permissionChecker2 = getService$
|
107
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
109
108
|
userAbility: ctx.state.userAbility,
|
110
109
|
model: request.body.contentType
|
111
110
|
});
|
112
111
|
if (permissionChecker2.cannot.update()) {
|
113
112
|
throw new strapiUtils.errors.ForbiddenError();
|
114
113
|
}
|
115
|
-
const restoredDocument = await getService(strapi2, "history").restoreVersion(
|
114
|
+
const restoredDocument = await getService$1(strapi2, "history").restoreVersion(
|
116
115
|
request.params.versionId
|
117
116
|
);
|
118
117
|
return {
|
@@ -121,7 +120,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
|
|
121
120
|
}
|
122
121
|
};
|
123
122
|
};
|
124
|
-
const controllers$
|
123
|
+
const controllers$2 = {
|
125
124
|
"history-version": createHistoryVersionController
|
126
125
|
/**
|
127
126
|
* Casting is needed because the types aren't aware that Strapi supports
|
@@ -167,8 +166,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
167
166
|
};
|
168
167
|
const getRelationRestoreValue = async (versionRelationData, attribute) => {
|
169
168
|
if (Array.isArray(versionRelationData)) {
|
170
|
-
if (versionRelationData.length === 0)
|
171
|
-
return versionRelationData;
|
169
|
+
if (versionRelationData.length === 0) return versionRelationData;
|
172
170
|
const existingAndMissingRelations = await Promise.all(
|
173
171
|
versionRelationData.map((relation) => {
|
174
172
|
return strapi2.documents(attribute.target).findOne({
|
@@ -199,10 +197,11 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
199
197
|
return strapi2.db.query("plugin::upload.file").findOne({ where: { id: versionRelationData.id } });
|
200
198
|
};
|
201
199
|
const localesService = strapi2.plugin("i18n")?.service("locales");
|
200
|
+
const i18nContentTypeService = strapi2.plugin("i18n")?.service("content-types");
|
202
201
|
const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
|
202
|
+
const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
|
203
203
|
const getLocaleDictionary = async () => {
|
204
|
-
if (!localesService)
|
205
|
-
return {};
|
204
|
+
if (!localesService) return {};
|
206
205
|
const locales = await localesService.find() || [];
|
207
206
|
return locales.reduce(
|
208
207
|
(acc, locale) => {
|
@@ -226,6 +225,17 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
226
225
|
const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
|
227
226
|
return documentMetadataService.getStatus(document, meta.availableStatus);
|
228
227
|
};
|
228
|
+
const getComponentFields = (componentUID) => {
|
229
|
+
return Object.entries(strapi2.getModel(componentUID).attributes).reduce(
|
230
|
+
(fieldsAcc, [key, attribute]) => {
|
231
|
+
if (!["relation", "media", "component", "dynamiczone"].includes(attribute.type)) {
|
232
|
+
fieldsAcc.push(key);
|
233
|
+
}
|
234
|
+
return fieldsAcc;
|
235
|
+
},
|
236
|
+
[]
|
237
|
+
);
|
238
|
+
};
|
229
239
|
const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
|
230
240
|
const model = strapi2.getModel(uid2);
|
231
241
|
const attributes = Object.entries(model.attributes);
|
@@ -249,13 +259,19 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
249
259
|
}
|
250
260
|
case "component": {
|
251
261
|
const populate = getDeepPopulate2(attribute.component);
|
252
|
-
acc[attributeName] = {
|
262
|
+
acc[attributeName] = {
|
263
|
+
populate,
|
264
|
+
[fieldSelector]: getComponentFields(attribute.component)
|
265
|
+
};
|
253
266
|
break;
|
254
267
|
}
|
255
268
|
case "dynamiczone": {
|
256
269
|
const populatedComponents = (attribute.components || []).reduce(
|
257
270
|
(acc2, componentUID) => {
|
258
|
-
acc2[componentUID] = {
|
271
|
+
acc2[componentUID] = {
|
272
|
+
populate: getDeepPopulate2(componentUID),
|
273
|
+
[fieldSelector]: getComponentFields(componentUID)
|
274
|
+
};
|
259
275
|
return acc2;
|
260
276
|
},
|
261
277
|
{}
|
@@ -317,6 +333,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
317
333
|
getRelationRestoreValue,
|
318
334
|
getMediaRestoreValue,
|
319
335
|
getDefaultLocale,
|
336
|
+
isLocalizedContentType,
|
320
337
|
getLocaleDictionary,
|
321
338
|
getRetentionDays,
|
322
339
|
getVersionStatus,
|
@@ -339,7 +356,13 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
339
356
|
});
|
340
357
|
},
|
341
358
|
async findVersionsPage(params) {
|
342
|
-
const
|
359
|
+
const model = strapi2.getModel(params.query.contentType);
|
360
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
|
361
|
+
const defaultLocale = await serviceUtils.getDefaultLocale();
|
362
|
+
let locale = null;
|
363
|
+
if (isLocalizedContentType) {
|
364
|
+
locale = params.query.locale || defaultLocale;
|
365
|
+
}
|
343
366
|
const [{ results, pagination }, localeDictionary] = await Promise.all([
|
344
367
|
query.findPage({
|
345
368
|
...params.query,
|
@@ -361,7 +384,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
361
384
|
const attributeValue = entry.data[attributeKey];
|
362
385
|
const attributeValues = Array.isArray(attributeValue) ? attributeValue : [attributeValue];
|
363
386
|
if (attributeSchema.type === "media") {
|
364
|
-
const permissionChecker2 = getService$
|
387
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
365
388
|
userAbility: params.state.userAbility,
|
366
389
|
model: "plugin::upload.file"
|
367
390
|
});
|
@@ -384,7 +407,12 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
384
407
|
if (userToPopulate == null) {
|
385
408
|
return null;
|
386
409
|
}
|
387
|
-
return strapi2.query("admin::user").findOne({
|
410
|
+
return strapi2.query("admin::user").findOne({
|
411
|
+
where: {
|
412
|
+
...userToPopulate.id ? { id: userToPopulate.id } : {},
|
413
|
+
...userToPopulate.documentId ? { documentId: userToPopulate.documentId } : {}
|
414
|
+
}
|
415
|
+
});
|
388
416
|
})
|
389
417
|
);
|
390
418
|
return {
|
@@ -397,7 +425,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
397
425
|
[attributeKey]: adminUsers
|
398
426
|
};
|
399
427
|
}
|
400
|
-
const permissionChecker2 = getService$
|
428
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
401
429
|
userAbility: params.state.userAbility,
|
402
430
|
model: attributeSchema.target
|
403
431
|
});
|
@@ -555,11 +583,13 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
555
583
|
}
|
556
584
|
const uid2 = context.contentType.uid;
|
557
585
|
const schemas = getSchemas(uid2);
|
586
|
+
const model = strapi2.getModel(uid2);
|
587
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
|
558
588
|
const localeEntries = await strapi2.db.query(uid2).findMany({
|
559
589
|
where: {
|
560
590
|
documentId,
|
561
|
-
locale: { $in: locales },
|
562
|
-
publishedAt: null
|
591
|
+
...isLocalizedContentType ? { locale: { $in: locales } } : {},
|
592
|
+
...strapiUtils.contentTypes.hasDraftAndPublish(strapi2.contentTypes[uid2]) ? { publishedAt: null } : {}
|
563
593
|
},
|
564
594
|
populate: serviceUtils.getDeepPopulate(
|
565
595
|
uid2,
|
@@ -571,7 +601,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
571
601
|
onCommit(async () => {
|
572
602
|
for (const entry of localeEntries) {
|
573
603
|
const status = await serviceUtils.getVersionStatus(uid2, entry);
|
574
|
-
await getService(strapi2, "history").createVersion({
|
604
|
+
await getService$1(strapi2, "history").createVersion({
|
575
605
|
contentType: uid2,
|
576
606
|
data: fp.omit(FIELDS_TO_IGNORE, entry),
|
577
607
|
relatedDocumentId: documentId,
|
@@ -584,15 +614,19 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
584
614
|
});
|
585
615
|
return result;
|
586
616
|
});
|
587
|
-
state.deleteExpiredJob = nodeSchedule.scheduleJob("0 0 * * *", () => {
|
617
|
+
state.deleteExpiredJob = nodeSchedule.scheduleJob("historyDaily", "0 0 * * *", () => {
|
588
618
|
const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
|
589
619
|
const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
|
590
620
|
strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
|
591
621
|
where: {
|
592
622
|
created_at: {
|
593
|
-
$lt: expirationDate
|
623
|
+
$lt: expirationDate
|
594
624
|
}
|
595
625
|
}
|
626
|
+
}).catch((error) => {
|
627
|
+
if (error instanceof Error) {
|
628
|
+
strapi2.log.error("Error deleting expired history versions", error.message);
|
629
|
+
}
|
596
630
|
});
|
597
631
|
});
|
598
632
|
state.isInitialized = true;
|
@@ -604,17 +638,17 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
604
638
|
}
|
605
639
|
};
|
606
640
|
};
|
607
|
-
const services$
|
641
|
+
const services$2 = {
|
608
642
|
history: createHistoryService,
|
609
643
|
lifecycles: createLifecyclesService
|
610
644
|
};
|
611
|
-
const info = { pluginName: "content-manager", type: "admin" };
|
645
|
+
const info$1 = { pluginName: "content-manager", type: "admin" };
|
612
646
|
const historyVersionRouter = {
|
613
647
|
type: "admin",
|
614
648
|
routes: [
|
615
649
|
{
|
616
650
|
method: "GET",
|
617
|
-
info,
|
651
|
+
info: info$1,
|
618
652
|
path: "/history-versions",
|
619
653
|
handler: "history-version.findMany",
|
620
654
|
config: {
|
@@ -623,7 +657,7 @@ const historyVersionRouter = {
|
|
623
657
|
},
|
624
658
|
{
|
625
659
|
method: "PUT",
|
626
|
-
info,
|
660
|
+
info: info$1,
|
627
661
|
path: "/history-versions/:versionId/restore",
|
628
662
|
handler: "history-version.restoreVersion",
|
629
663
|
config: {
|
@@ -632,7 +666,7 @@ const historyVersionRouter = {
|
|
632
666
|
}
|
633
667
|
]
|
634
668
|
};
|
635
|
-
const routes$
|
669
|
+
const routes$2 = {
|
636
670
|
"history-version": historyVersionRouter
|
637
671
|
};
|
638
672
|
const historyVersion = {
|
@@ -679,21 +713,21 @@ const historyVersion = {
|
|
679
713
|
}
|
680
714
|
}
|
681
715
|
};
|
682
|
-
const getFeature = () => {
|
716
|
+
const getFeature$1 = () => {
|
683
717
|
if (strapi.ee.features.isEnabled("cms-content-history")) {
|
684
718
|
return {
|
685
719
|
register({ strapi: strapi2 }) {
|
686
720
|
strapi2.get("models").add(historyVersion);
|
687
721
|
},
|
688
722
|
bootstrap({ strapi: strapi2 }) {
|
689
|
-
getService(strapi2, "lifecycles").bootstrap();
|
723
|
+
getService$1(strapi2, "lifecycles").bootstrap();
|
690
724
|
},
|
691
725
|
destroy({ strapi: strapi2 }) {
|
692
|
-
getService(strapi2, "lifecycles").destroy();
|
726
|
+
getService$1(strapi2, "lifecycles").destroy();
|
693
727
|
},
|
694
|
-
controllers: controllers$
|
695
|
-
services: services$
|
696
|
-
routes: routes$
|
728
|
+
controllers: controllers$2,
|
729
|
+
services: services$2,
|
730
|
+
routes: routes$2
|
697
731
|
};
|
698
732
|
}
|
699
733
|
return {
|
@@ -702,9 +736,201 @@ const getFeature = () => {
|
|
702
736
|
}
|
703
737
|
};
|
704
738
|
};
|
705
|
-
const history = getFeature();
|
739
|
+
const history = getFeature$1();
|
740
|
+
const info = { pluginName: "content-manager", type: "admin" };
|
741
|
+
const previewRouter = {
|
742
|
+
type: "admin",
|
743
|
+
routes: [
|
744
|
+
{
|
745
|
+
method: "GET",
|
746
|
+
info,
|
747
|
+
path: "/preview/url/:contentType",
|
748
|
+
handler: "preview.getPreviewUrl",
|
749
|
+
config: {
|
750
|
+
policies: ["admin::isAuthenticatedAdmin"]
|
751
|
+
}
|
752
|
+
}
|
753
|
+
]
|
754
|
+
};
|
755
|
+
const routes$1 = {
|
756
|
+
preview: previewRouter
|
757
|
+
};
|
758
|
+
function getService(strapi2, name) {
|
759
|
+
return strapi2.service(`plugin::content-manager.${name}`);
|
760
|
+
}
|
761
|
+
const getPreviewUrlSchema = yup__namespace.object().shape({
|
762
|
+
// Will be undefined for single types
|
763
|
+
documentId: yup__namespace.string(),
|
764
|
+
locale: yup__namespace.string().nullable(),
|
765
|
+
status: yup__namespace.string()
|
766
|
+
}).required();
|
767
|
+
const validatePreviewUrl = async (strapi2, uid2, params) => {
|
768
|
+
await strapiUtils.validateYupSchema(getPreviewUrlSchema)(params);
|
769
|
+
const newParams = fp.pick(["documentId", "locale", "status"], params);
|
770
|
+
const model = strapi2.getModel(uid2);
|
771
|
+
if (!model || model.modelType !== "contentType") {
|
772
|
+
throw new strapiUtils.errors.ValidationError("Invalid content type");
|
773
|
+
}
|
774
|
+
const isSingleType = model?.kind === "singleType";
|
775
|
+
if (!isSingleType && !params.documentId) {
|
776
|
+
throw new strapiUtils.errors.ValidationError("documentId is required for Collection Types");
|
777
|
+
}
|
778
|
+
if (isSingleType) {
|
779
|
+
const doc = await strapi2.documents(uid2).findFirst();
|
780
|
+
if (!doc) {
|
781
|
+
throw new strapiUtils.errors.NotFoundError("Document not found");
|
782
|
+
}
|
783
|
+
newParams.documentId = doc?.documentId;
|
784
|
+
}
|
785
|
+
if (!newParams.status) {
|
786
|
+
const isDPEnabled = model?.options?.draftAndPublish;
|
787
|
+
newParams.status = isDPEnabled ? "draft" : "published";
|
788
|
+
}
|
789
|
+
return newParams;
|
790
|
+
};
|
791
|
+
const createPreviewController = () => {
|
792
|
+
return {
|
793
|
+
/**
|
794
|
+
* Transforms an entry into a preview URL, so that it can be previewed
|
795
|
+
* in the Content Manager.
|
796
|
+
*/
|
797
|
+
async getPreviewUrl(ctx) {
|
798
|
+
const uid2 = ctx.params.contentType;
|
799
|
+
const query = ctx.request.query;
|
800
|
+
const params = await validatePreviewUrl(strapi, uid2, query);
|
801
|
+
const previewService = getService(strapi, "preview");
|
802
|
+
const url = await previewService.getPreviewUrl(uid2, params);
|
803
|
+
if (!url) {
|
804
|
+
ctx.status = 204;
|
805
|
+
}
|
806
|
+
return {
|
807
|
+
data: { url }
|
808
|
+
};
|
809
|
+
}
|
810
|
+
};
|
811
|
+
};
|
812
|
+
const controllers$1 = {
|
813
|
+
preview: createPreviewController
|
814
|
+
/**
|
815
|
+
* Casting is needed because the types aren't aware that Strapi supports
|
816
|
+
* passing a controller factory as the value, instead of a controller object directly
|
817
|
+
*/
|
818
|
+
};
|
819
|
+
const createPreviewService = ({ strapi: strapi2 }) => {
|
820
|
+
const config = getService(strapi2, "preview-config");
|
821
|
+
return {
|
822
|
+
async getPreviewUrl(uid2, params) {
|
823
|
+
const handler = config.getPreviewHandler();
|
824
|
+
try {
|
825
|
+
return handler(uid2, params);
|
826
|
+
} catch (error) {
|
827
|
+
strapi2.log.error(`Failed to get preview URL: ${error}`);
|
828
|
+
throw new strapiUtils.errors.ApplicationError("Failed to get preview URL");
|
829
|
+
}
|
830
|
+
return;
|
831
|
+
}
|
832
|
+
};
|
833
|
+
};
|
834
|
+
const extendMiddlewareConfiguration = (middleware = { name: "", config: {} }) => {
|
835
|
+
const middlewares = strapi.config.get("middlewares");
|
836
|
+
const configuredMiddlewares = middlewares.map((currentMiddleware) => {
|
837
|
+
if (currentMiddleware === middleware.name) {
|
838
|
+
return middleware;
|
839
|
+
}
|
840
|
+
if (currentMiddleware.name === middleware.name) {
|
841
|
+
return fp.mergeWith(
|
842
|
+
(objValue, srcValue) => {
|
843
|
+
if (Array.isArray(objValue)) {
|
844
|
+
return objValue.concat(srcValue);
|
845
|
+
}
|
846
|
+
return void 0;
|
847
|
+
},
|
848
|
+
currentMiddleware,
|
849
|
+
middleware
|
850
|
+
);
|
851
|
+
}
|
852
|
+
return currentMiddleware;
|
853
|
+
});
|
854
|
+
strapi.config.set("middlewares", configuredMiddlewares);
|
855
|
+
};
|
856
|
+
const createPreviewConfigService = ({ strapi: strapi2 }) => {
|
857
|
+
return {
|
858
|
+
register() {
|
859
|
+
if (!this.isEnabled()) {
|
860
|
+
return;
|
861
|
+
}
|
862
|
+
const config = strapi2.config.get("admin.preview");
|
863
|
+
if (config.config?.allowedOrigins) {
|
864
|
+
extendMiddlewareConfiguration({
|
865
|
+
name: "strapi::security",
|
866
|
+
config: {
|
867
|
+
contentSecurityPolicy: {
|
868
|
+
directives: {
|
869
|
+
"frame-src": config.config.allowedOrigins
|
870
|
+
}
|
871
|
+
}
|
872
|
+
}
|
873
|
+
});
|
874
|
+
}
|
875
|
+
},
|
876
|
+
isEnabled() {
|
877
|
+
const config = strapi2.config.get("admin.preview");
|
878
|
+
if (!config) {
|
879
|
+
return false;
|
880
|
+
}
|
881
|
+
return config?.enabled ?? true;
|
882
|
+
},
|
883
|
+
/**
|
884
|
+
* Validate if the configuration is valid
|
885
|
+
*/
|
886
|
+
validate() {
|
887
|
+
if (!this.isEnabled()) {
|
888
|
+
return;
|
889
|
+
}
|
890
|
+
const handler = this.getPreviewHandler();
|
891
|
+
if (typeof handler !== "function") {
|
892
|
+
throw new strapiUtils.errors.ValidationError(
|
893
|
+
"Preview configuration is invalid. Handler must be a function"
|
894
|
+
);
|
895
|
+
}
|
896
|
+
},
|
897
|
+
/**
|
898
|
+
* Utility to get the preview handler from the configuration
|
899
|
+
*/
|
900
|
+
getPreviewHandler() {
|
901
|
+
const config = strapi2.config.get("admin.preview");
|
902
|
+
const emptyHandler = () => {
|
903
|
+
return void 0;
|
904
|
+
};
|
905
|
+
if (!this.isEnabled()) {
|
906
|
+
return emptyHandler;
|
907
|
+
}
|
908
|
+
return config?.config?.handler || emptyHandler;
|
909
|
+
}
|
910
|
+
};
|
911
|
+
};
|
912
|
+
const services$1 = {
|
913
|
+
preview: createPreviewService,
|
914
|
+
"preview-config": createPreviewConfigService
|
915
|
+
};
|
916
|
+
const getFeature = () => {
|
917
|
+
return {
|
918
|
+
register() {
|
919
|
+
const config = getService(strapi, "preview-config");
|
920
|
+
config.validate();
|
921
|
+
config.register();
|
922
|
+
},
|
923
|
+
bootstrap() {
|
924
|
+
},
|
925
|
+
routes: routes$1,
|
926
|
+
controllers: controllers$1,
|
927
|
+
services: services$1
|
928
|
+
};
|
929
|
+
};
|
930
|
+
const preview = getFeature();
|
706
931
|
const register = async ({ strapi: strapi2 }) => {
|
707
932
|
await history.register?.({ strapi: strapi2 });
|
933
|
+
await preview.register?.({ strapi: strapi2 });
|
708
934
|
};
|
709
935
|
const ALLOWED_WEBHOOK_EVENTS = {
|
710
936
|
ENTRY_PUBLISH: "entry.publish",
|
@@ -714,11 +940,12 @@ const bootstrap = async () => {
|
|
714
940
|
Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
|
715
941
|
strapi.get("webhookStore").addAllowedEvent(key, value);
|
716
942
|
});
|
717
|
-
getService$
|
718
|
-
await getService$
|
719
|
-
await getService$
|
720
|
-
await getService$
|
943
|
+
getService$2("field-sizes").setCustomFieldInputSizes();
|
944
|
+
await getService$2("components").syncConfigurations();
|
945
|
+
await getService$2("content-types").syncConfigurations();
|
946
|
+
await getService$2("permission").registerPermissions();
|
721
947
|
await history.bootstrap?.({ strapi });
|
948
|
+
await preview.bootstrap?.({ strapi });
|
722
949
|
};
|
723
950
|
const destroy = async ({ strapi: strapi2 }) => {
|
724
951
|
await history.destroy?.({ strapi: strapi2 });
|
@@ -1208,7 +1435,8 @@ const admin = {
|
|
1208
1435
|
};
|
1209
1436
|
const routes = {
|
1210
1437
|
admin,
|
1211
|
-
...history.routes ? history.routes : {}
|
1438
|
+
...history.routes ? history.routes : {},
|
1439
|
+
...preview.routes ? preview.routes : {}
|
1212
1440
|
};
|
1213
1441
|
const hasPermissionsSchema = strapiUtils.yup.object({
|
1214
1442
|
actions: strapiUtils.yup.array().of(strapiUtils.yup.string()),
|
@@ -1271,8 +1499,7 @@ const isSortable = (schema, name) => {
|
|
1271
1499
|
if (!___default.default.has(schema.attributes, name)) {
|
1272
1500
|
return false;
|
1273
1501
|
}
|
1274
|
-
if (schema.modelType === "component" && name === "id")
|
1275
|
-
return false;
|
1502
|
+
if (schema.modelType === "component" && name === "id") return false;
|
1276
1503
|
const attribute = schema.attributes[name];
|
1277
1504
|
if (NON_SORTABLES.includes(attribute.type)) {
|
1278
1505
|
return false;
|
@@ -1417,8 +1644,7 @@ const createDefaultSettings = async (schema) => {
|
|
1417
1644
|
};
|
1418
1645
|
};
|
1419
1646
|
const syncSettings = async (configuration, schema) => {
|
1420
|
-
if (fp.isEmpty(configuration.settings))
|
1421
|
-
return createDefaultSettings(schema);
|
1647
|
+
if (fp.isEmpty(configuration.settings)) return createDefaultSettings(schema);
|
1422
1648
|
const defaultField = getDefaultMainField(schema);
|
1423
1649
|
const { mainField = defaultField, defaultSortBy = defaultField } = configuration.settings || {};
|
1424
1650
|
return {
|
@@ -1465,7 +1691,7 @@ const createMetadasSchema = (schema) => {
|
|
1465
1691
|
if (!value) {
|
1466
1692
|
return strapiUtils.yup.string();
|
1467
1693
|
}
|
1468
|
-
const targetSchema = getService$
|
1694
|
+
const targetSchema = getService$2("content-types").findContentType(
|
1469
1695
|
schema.attributes[key].targetModel
|
1470
1696
|
);
|
1471
1697
|
if (!targetSchema) {
|
@@ -1594,8 +1820,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
|
|
1594
1820
|
}
|
1595
1821
|
switch (attribute.type) {
|
1596
1822
|
case "relation": {
|
1597
|
-
if (canCreate(attributePath))
|
1598
|
-
return body2;
|
1823
|
+
if (canCreate(attributePath)) return body2;
|
1599
1824
|
return fp.set(attributePath, { set: [] }, body2);
|
1600
1825
|
}
|
1601
1826
|
case "component": {
|
@@ -1605,8 +1830,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
|
|
1605
1830
|
]);
|
1606
1831
|
}
|
1607
1832
|
default: {
|
1608
|
-
if (canCreate(attributePath))
|
1609
|
-
return body2;
|
1833
|
+
if (canCreate(attributePath)) return body2;
|
1610
1834
|
return fp.set(attributePath, null, body2);
|
1611
1835
|
}
|
1612
1836
|
}
|
@@ -1634,7 +1858,7 @@ const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultiple
|
|
1634
1858
|
}
|
1635
1859
|
};
|
1636
1860
|
const formatDocumentWithMetadata = async (permissionChecker2, uid2, document, opts = {}) => {
|
1637
|
-
const documentMetadata2 = getService$
|
1861
|
+
const documentMetadata2 = getService$2("document-metadata");
|
1638
1862
|
const serviceOutput = await documentMetadata2.formatDocumentWithMetadata(uid2, document, opts);
|
1639
1863
|
let {
|
1640
1864
|
meta: { availableLocales, availableStatus }
|
@@ -1660,8 +1884,8 @@ const createDocument = async (ctx, opts) => {
|
|
1660
1884
|
const { userAbility, user } = ctx.state;
|
1661
1885
|
const { model } = ctx.params;
|
1662
1886
|
const { body } = ctx.request;
|
1663
|
-
const documentManager2 = getService$
|
1664
|
-
const permissionChecker2 = getService$
|
1887
|
+
const documentManager2 = getService$2("document-manager");
|
1888
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1665
1889
|
if (permissionChecker2.cannot.create()) {
|
1666
1890
|
throw new strapiUtils.errors.ForbiddenError();
|
1667
1891
|
}
|
@@ -1681,13 +1905,13 @@ const updateDocument = async (ctx, opts) => {
|
|
1681
1905
|
const { userAbility, user } = ctx.state;
|
1682
1906
|
const { id, model } = ctx.params;
|
1683
1907
|
const { body } = ctx.request;
|
1684
|
-
const documentManager2 = getService$
|
1685
|
-
const permissionChecker2 = getService$
|
1908
|
+
const documentManager2 = getService$2("document-manager");
|
1909
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1686
1910
|
if (permissionChecker2.cannot.update()) {
|
1687
1911
|
throw new strapiUtils.errors.ForbiddenError();
|
1688
1912
|
}
|
1689
1913
|
const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
|
1690
|
-
const populate = await getService$
|
1914
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1691
1915
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1692
1916
|
const [documentVersion, documentExists] = await Promise.all([
|
1693
1917
|
documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
|
@@ -1704,7 +1928,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1704
1928
|
throw new strapiUtils.errors.ForbiddenError();
|
1705
1929
|
}
|
1706
1930
|
const pickPermittedFields = documentVersion ? permissionChecker2.sanitizeUpdateInput(documentVersion) : permissionChecker2.sanitizeCreateInput;
|
1707
|
-
const setCreator = strapiUtils.setCreatorFields({ user, isEdition: true });
|
1931
|
+
const setCreator = documentVersion ? strapiUtils.setCreatorFields({ user, isEdition: true }) : strapiUtils.setCreatorFields({ user });
|
1708
1932
|
const sanitizeFn = strapiUtils.async.pipe(pickPermittedFields, setCreator);
|
1709
1933
|
const sanitizedBody = await sanitizeFn(body);
|
1710
1934
|
return documentManager2.update(documentVersion?.documentId || id, model, {
|
@@ -1718,14 +1942,14 @@ const collectionTypes = {
|
|
1718
1942
|
const { userAbility } = ctx.state;
|
1719
1943
|
const { model } = ctx.params;
|
1720
1944
|
const { query } = ctx.request;
|
1721
|
-
const documentMetadata2 = getService$
|
1722
|
-
const documentManager2 = getService$
|
1723
|
-
const permissionChecker2 = getService$
|
1945
|
+
const documentMetadata2 = getService$2("document-metadata");
|
1946
|
+
const documentManager2 = getService$2("document-manager");
|
1947
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1724
1948
|
if (permissionChecker2.cannot.read()) {
|
1725
1949
|
return ctx.forbidden();
|
1726
1950
|
}
|
1727
1951
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
1728
|
-
const populate = await getService$
|
1952
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
|
1729
1953
|
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
1730
1954
|
const { results: documents, pagination } = await documentManager2.findPage(
|
1731
1955
|
{ ...permissionQuery, populate, locale, status },
|
@@ -1754,13 +1978,13 @@ const collectionTypes = {
|
|
1754
1978
|
async findOne(ctx) {
|
1755
1979
|
const { userAbility } = ctx.state;
|
1756
1980
|
const { model, id } = ctx.params;
|
1757
|
-
const documentManager2 = getService$
|
1758
|
-
const permissionChecker2 = getService$
|
1981
|
+
const documentManager2 = getService$2("document-manager");
|
1982
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1759
1983
|
if (permissionChecker2.cannot.read()) {
|
1760
1984
|
return ctx.forbidden();
|
1761
1985
|
}
|
1762
1986
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
1763
|
-
const populate = await getService$
|
1987
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1764
1988
|
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1765
1989
|
const version = await documentManager2.findOne(id, model, {
|
1766
1990
|
populate,
|
@@ -1776,7 +2000,7 @@ const collectionTypes = {
|
|
1776
2000
|
permissionChecker2,
|
1777
2001
|
model,
|
1778
2002
|
// @ts-expect-error TODO: fix
|
1779
|
-
{ id, locale, publishedAt: null },
|
2003
|
+
{ documentId: id, locale, publishedAt: null },
|
1780
2004
|
{ availableLocales: true, availableStatus: false }
|
1781
2005
|
);
|
1782
2006
|
ctx.body = { data: {}, meta };
|
@@ -1791,7 +2015,7 @@ const collectionTypes = {
|
|
1791
2015
|
async create(ctx) {
|
1792
2016
|
const { userAbility } = ctx.state;
|
1793
2017
|
const { model } = ctx.params;
|
1794
|
-
const permissionChecker2 = getService$
|
2018
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1795
2019
|
const [totalEntries, document] = await Promise.all([
|
1796
2020
|
strapi.db.query(model).count(),
|
1797
2021
|
createDocument(ctx)
|
@@ -1812,7 +2036,7 @@ const collectionTypes = {
|
|
1812
2036
|
async update(ctx) {
|
1813
2037
|
const { userAbility } = ctx.state;
|
1814
2038
|
const { model } = ctx.params;
|
1815
|
-
const permissionChecker2 = getService$
|
2039
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1816
2040
|
const updatedVersion = await updateDocument(ctx);
|
1817
2041
|
const sanitizedVersion = await permissionChecker2.sanitizeOutput(updatedVersion);
|
1818
2042
|
ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedVersion);
|
@@ -1821,13 +2045,13 @@ const collectionTypes = {
|
|
1821
2045
|
const { userAbility, user } = ctx.state;
|
1822
2046
|
const { model, sourceId: id } = ctx.params;
|
1823
2047
|
const { body } = ctx.request;
|
1824
|
-
const documentManager2 = getService$
|
1825
|
-
const permissionChecker2 = getService$
|
2048
|
+
const documentManager2 = getService$2("document-manager");
|
2049
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1826
2050
|
if (permissionChecker2.cannot.create()) {
|
1827
2051
|
return ctx.forbidden();
|
1828
2052
|
}
|
1829
2053
|
const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
|
1830
|
-
const populate = await getService$
|
2054
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1831
2055
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1832
2056
|
const document = await documentManager2.findOne(id, model, {
|
1833
2057
|
populate,
|
@@ -1866,13 +2090,13 @@ const collectionTypes = {
|
|
1866
2090
|
async delete(ctx) {
|
1867
2091
|
const { userAbility } = ctx.state;
|
1868
2092
|
const { id, model } = ctx.params;
|
1869
|
-
const documentManager2 = getService$
|
1870
|
-
const permissionChecker2 = getService$
|
2093
|
+
const documentManager2 = getService$2("document-manager");
|
2094
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1871
2095
|
if (permissionChecker2.cannot.delete()) {
|
1872
2096
|
return ctx.forbidden();
|
1873
2097
|
}
|
1874
2098
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
|
1875
|
-
const populate = await getService$
|
2099
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1876
2100
|
const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1877
2101
|
const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
|
1878
2102
|
if (documentLocales.length === 0) {
|
@@ -1894,14 +2118,14 @@ const collectionTypes = {
|
|
1894
2118
|
const { userAbility } = ctx.state;
|
1895
2119
|
const { id, model } = ctx.params;
|
1896
2120
|
const { body } = ctx.request;
|
1897
|
-
const documentManager2 = getService$
|
1898
|
-
const permissionChecker2 = getService$
|
2121
|
+
const documentManager2 = getService$2("document-manager");
|
2122
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1899
2123
|
if (permissionChecker2.cannot.publish()) {
|
1900
2124
|
return ctx.forbidden();
|
1901
2125
|
}
|
1902
2126
|
const publishedDocument = await strapi.db.transaction(async () => {
|
1903
2127
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1904
|
-
const populate = await getService$
|
2128
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1905
2129
|
let document;
|
1906
2130
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1907
2131
|
const isCreate = fp.isNil(id);
|
@@ -1913,11 +2137,17 @@ const collectionTypes = {
|
|
1913
2137
|
}
|
1914
2138
|
const isUpdate = !isCreate;
|
1915
2139
|
if (isUpdate) {
|
1916
|
-
|
1917
|
-
if (!
|
2140
|
+
const documentExists = documentManager2.exists(model, id);
|
2141
|
+
if (!documentExists) {
|
1918
2142
|
throw new strapiUtils.errors.NotFoundError("Document not found");
|
1919
2143
|
}
|
1920
|
-
|
2144
|
+
document = await documentManager2.findOne(id, model, { populate, locale });
|
2145
|
+
if (!document) {
|
2146
|
+
if (permissionChecker2.cannot.create({ locale }) || permissionChecker2.cannot.publish({ locale })) {
|
2147
|
+
throw new strapiUtils.errors.ForbiddenError();
|
2148
|
+
}
|
2149
|
+
document = await updateDocument(ctx);
|
2150
|
+
} else if (permissionChecker2.can.update(document)) {
|
1921
2151
|
await updateDocument(ctx);
|
1922
2152
|
}
|
1923
2153
|
}
|
@@ -1943,13 +2173,13 @@ const collectionTypes = {
|
|
1943
2173
|
const { body } = ctx.request;
|
1944
2174
|
const { documentIds } = body;
|
1945
2175
|
await validateBulkActionInput(body);
|
1946
|
-
const documentManager2 = getService$
|
1947
|
-
const permissionChecker2 = getService$
|
2176
|
+
const documentManager2 = getService$2("document-manager");
|
2177
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1948
2178
|
if (permissionChecker2.cannot.publish()) {
|
1949
2179
|
return ctx.forbidden();
|
1950
2180
|
}
|
1951
2181
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1952
|
-
const populate = await getService$
|
2182
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1953
2183
|
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1954
2184
|
allowMultipleLocales: true
|
1955
2185
|
});
|
@@ -1974,12 +2204,14 @@ const collectionTypes = {
|
|
1974
2204
|
const { body } = ctx.request;
|
1975
2205
|
const { documentIds } = body;
|
1976
2206
|
await validateBulkActionInput(body);
|
1977
|
-
const documentManager2 = getService$
|
1978
|
-
const permissionChecker2 = getService$
|
2207
|
+
const documentManager2 = getService$2("document-manager");
|
2208
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
1979
2209
|
if (permissionChecker2.cannot.unpublish()) {
|
1980
2210
|
return ctx.forbidden();
|
1981
2211
|
}
|
1982
|
-
const { locale } = await getDocumentLocaleAndStatus(body, model
|
2212
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
2213
|
+
allowMultipleLocales: true
|
2214
|
+
});
|
1983
2215
|
const entityPromises = documentIds.map(
|
1984
2216
|
(documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
|
1985
2217
|
);
|
@@ -2002,8 +2234,8 @@ const collectionTypes = {
|
|
2002
2234
|
const {
|
2003
2235
|
body: { discardDraft, ...body }
|
2004
2236
|
} = ctx.request;
|
2005
|
-
const documentManager2 = getService$
|
2006
|
-
const permissionChecker2 = getService$
|
2237
|
+
const documentManager2 = getService$2("document-manager");
|
2238
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2007
2239
|
if (permissionChecker2.cannot.unpublish()) {
|
2008
2240
|
return ctx.forbidden();
|
2009
2241
|
}
|
@@ -2011,7 +2243,7 @@ const collectionTypes = {
|
|
2011
2243
|
return ctx.forbidden();
|
2012
2244
|
}
|
2013
2245
|
const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
|
2014
|
-
const populate = await getService$
|
2246
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2015
2247
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2016
2248
|
const document = await documentManager2.findOne(id, model, {
|
2017
2249
|
populate,
|
@@ -2042,13 +2274,13 @@ const collectionTypes = {
|
|
2042
2274
|
const { userAbility } = ctx.state;
|
2043
2275
|
const { id, model } = ctx.params;
|
2044
2276
|
const { body } = ctx.request;
|
2045
|
-
const documentManager2 = getService$
|
2046
|
-
const permissionChecker2 = getService$
|
2277
|
+
const documentManager2 = getService$2("document-manager");
|
2278
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2047
2279
|
if (permissionChecker2.cannot.discard()) {
|
2048
2280
|
return ctx.forbidden();
|
2049
2281
|
}
|
2050
2282
|
const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
|
2051
|
-
const populate = await getService$
|
2283
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2052
2284
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2053
2285
|
const document = await documentManager2.findOne(id, model, {
|
2054
2286
|
populate,
|
@@ -2073,13 +2305,13 @@ const collectionTypes = {
|
|
2073
2305
|
const { query, body } = ctx.request;
|
2074
2306
|
const { documentIds } = body;
|
2075
2307
|
await validateBulkActionInput(body);
|
2076
|
-
const documentManager2 = getService$
|
2077
|
-
const permissionChecker2 = getService$
|
2308
|
+
const documentManager2 = getService$2("document-manager");
|
2309
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2078
2310
|
if (permissionChecker2.cannot.delete()) {
|
2079
2311
|
return ctx.forbidden();
|
2080
2312
|
}
|
2081
2313
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2082
|
-
const populate = await getService$
|
2314
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2083
2315
|
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2084
2316
|
const documentLocales = await documentManager2.findLocales(documentIds, model, {
|
2085
2317
|
populate,
|
@@ -2100,13 +2332,13 @@ const collectionTypes = {
|
|
2100
2332
|
async countDraftRelations(ctx) {
|
2101
2333
|
const { userAbility } = ctx.state;
|
2102
2334
|
const { model, id } = ctx.params;
|
2103
|
-
const documentManager2 = getService$
|
2104
|
-
const permissionChecker2 = getService$
|
2335
|
+
const documentManager2 = getService$2("document-manager");
|
2336
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2105
2337
|
if (permissionChecker2.cannot.read()) {
|
2106
2338
|
return ctx.forbidden();
|
2107
2339
|
}
|
2108
2340
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2109
|
-
const populate = await getService$
|
2341
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2110
2342
|
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
2111
2343
|
const entity = await documentManager2.findOne(id, model, { populate, locale, status });
|
2112
2344
|
if (!entity) {
|
@@ -2125,8 +2357,8 @@ const collectionTypes = {
|
|
2125
2357
|
const ids = ctx.request.query.documentIds;
|
2126
2358
|
const locale = ctx.request.query.locale;
|
2127
2359
|
const { model } = ctx.params;
|
2128
|
-
const documentManager2 = getService$
|
2129
|
-
const permissionChecker2 = getService$
|
2360
|
+
const documentManager2 = getService$2("document-manager");
|
2361
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2130
2362
|
if (permissionChecker2.cannot.read()) {
|
2131
2363
|
return ctx.forbidden();
|
2132
2364
|
}
|
@@ -2150,13 +2382,13 @@ const collectionTypes = {
|
|
2150
2382
|
};
|
2151
2383
|
const components$1 = {
|
2152
2384
|
findComponents(ctx) {
|
2153
|
-
const components2 = getService$
|
2154
|
-
const { toDto } = getService$
|
2385
|
+
const components2 = getService$2("components").findAllComponents();
|
2386
|
+
const { toDto } = getService$2("data-mapper");
|
2155
2387
|
ctx.body = { data: components2.map(toDto) };
|
2156
2388
|
},
|
2157
2389
|
async findComponentConfiguration(ctx) {
|
2158
2390
|
const { uid: uid2 } = ctx.params;
|
2159
|
-
const componentService = getService$
|
2391
|
+
const componentService = getService$2("components");
|
2160
2392
|
const component = componentService.findComponent(uid2);
|
2161
2393
|
if (!component) {
|
2162
2394
|
return ctx.notFound("component.notFound");
|
@@ -2173,7 +2405,7 @@ const components$1 = {
|
|
2173
2405
|
async updateComponentConfiguration(ctx) {
|
2174
2406
|
const { uid: uid2 } = ctx.params;
|
2175
2407
|
const { body } = ctx.request;
|
2176
|
-
const componentService = getService$
|
2408
|
+
const componentService = getService$2("components");
|
2177
2409
|
const component = componentService.findComponent(uid2);
|
2178
2410
|
if (!component) {
|
2179
2411
|
return ctx.notFound("component.notFound");
|
@@ -2207,12 +2439,12 @@ const contentTypes = {
|
|
2207
2439
|
} catch (error) {
|
2208
2440
|
return ctx.send({ error }, 400);
|
2209
2441
|
}
|
2210
|
-
const contentTypes2 = getService$
|
2211
|
-
const { toDto } = getService$
|
2442
|
+
const contentTypes2 = getService$2("content-types").findContentTypesByKind(kind);
|
2443
|
+
const { toDto } = getService$2("data-mapper");
|
2212
2444
|
ctx.body = { data: contentTypes2.map(toDto) };
|
2213
2445
|
},
|
2214
2446
|
async findContentTypesSettings(ctx) {
|
2215
|
-
const { findAllContentTypes, findConfiguration } = getService$
|
2447
|
+
const { findAllContentTypes, findConfiguration } = getService$2("content-types");
|
2216
2448
|
const contentTypes2 = await findAllContentTypes();
|
2217
2449
|
const configurations = await Promise.all(
|
2218
2450
|
contentTypes2.map(async (contentType) => {
|
@@ -2226,7 +2458,7 @@ const contentTypes = {
|
|
2226
2458
|
},
|
2227
2459
|
async findContentTypeConfiguration(ctx) {
|
2228
2460
|
const { uid: uid2 } = ctx.params;
|
2229
|
-
const contentTypeService = getService$
|
2461
|
+
const contentTypeService = getService$2("content-types");
|
2230
2462
|
const contentType = await contentTypeService.findContentType(uid2);
|
2231
2463
|
if (!contentType) {
|
2232
2464
|
return ctx.notFound("contentType.notFound");
|
@@ -2248,13 +2480,13 @@ const contentTypes = {
|
|
2248
2480
|
const { userAbility } = ctx.state;
|
2249
2481
|
const { uid: uid2 } = ctx.params;
|
2250
2482
|
const { body } = ctx.request;
|
2251
|
-
const contentTypeService = getService$
|
2252
|
-
const metricsService = getService$
|
2483
|
+
const contentTypeService = getService$2("content-types");
|
2484
|
+
const metricsService = getService$2("metrics");
|
2253
2485
|
const contentType = await contentTypeService.findContentType(uid2);
|
2254
2486
|
if (!contentType) {
|
2255
2487
|
return ctx.notFound("contentType.notFound");
|
2256
2488
|
}
|
2257
|
-
if (!getService$
|
2489
|
+
if (!getService$2("permission").canConfigureContentType({ userAbility, contentType })) {
|
2258
2490
|
return ctx.forbidden();
|
2259
2491
|
}
|
2260
2492
|
let input;
|
@@ -2287,10 +2519,10 @@ const contentTypes = {
|
|
2287
2519
|
};
|
2288
2520
|
const init = {
|
2289
2521
|
getInitData(ctx) {
|
2290
|
-
const { toDto } = getService$
|
2291
|
-
const { findAllComponents } = getService$
|
2292
|
-
const { getAllFieldSizes } = getService$
|
2293
|
-
const { findAllContentTypes } = getService$
|
2522
|
+
const { toDto } = getService$2("data-mapper");
|
2523
|
+
const { findAllComponents } = getService$2("components");
|
2524
|
+
const { getAllFieldSizes } = getService$2("field-sizes");
|
2525
|
+
const { findAllContentTypes } = getService$2("content-types");
|
2294
2526
|
ctx.body = {
|
2295
2527
|
data: {
|
2296
2528
|
fieldSizes: getAllFieldSizes(),
|
@@ -2326,7 +2558,7 @@ const addFiltersClause = (params, filtersClause) => {
|
|
2326
2558
|
params.filters.$and.push(filtersClause);
|
2327
2559
|
};
|
2328
2560
|
const sanitizeMainField = (model, mainField, userAbility) => {
|
2329
|
-
const permissionChecker2 = getService$
|
2561
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
2330
2562
|
userAbility,
|
2331
2563
|
model: model.uid
|
2332
2564
|
});
|
@@ -2340,15 +2572,27 @@ const sanitizeMainField = (model, mainField, userAbility) => {
|
|
2340
2572
|
}
|
2341
2573
|
return mainField;
|
2342
2574
|
};
|
2343
|
-
const addStatusToRelations = async (
|
2344
|
-
if (!strapiUtils.contentTypes.hasDraftAndPublish(strapi.
|
2575
|
+
const addStatusToRelations = async (targetUid, relations2) => {
|
2576
|
+
if (!strapiUtils.contentTypes.hasDraftAndPublish(strapi.getModel(targetUid))) {
|
2577
|
+
return relations2;
|
2578
|
+
}
|
2579
|
+
const documentMetadata2 = getService$2("document-metadata");
|
2580
|
+
if (!relations2.length) {
|
2345
2581
|
return relations2;
|
2346
2582
|
}
|
2347
|
-
const
|
2348
|
-
const
|
2583
|
+
const firstRelation = relations2[0];
|
2584
|
+
const filters = {
|
2585
|
+
documentId: { $in: relations2.map((r) => r.documentId) },
|
2586
|
+
// NOTE: find the "opposite" status
|
2587
|
+
publishedAt: firstRelation.publishedAt !== null ? { $null: true } : { $notNull: true }
|
2588
|
+
};
|
2589
|
+
const availableStatus = await strapi.query(targetUid).findMany({
|
2590
|
+
select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"],
|
2591
|
+
filters
|
2592
|
+
});
|
2349
2593
|
return relations2.map((relation) => {
|
2350
|
-
const availableStatuses =
|
2351
|
-
(availableDocument) => availableDocument.documentId === relation.documentId
|
2594
|
+
const availableStatuses = availableStatus.filter(
|
2595
|
+
(availableDocument) => availableDocument.documentId === relation.documentId && (relation.locale ? availableDocument.locale === relation.locale : true)
|
2352
2596
|
);
|
2353
2597
|
return {
|
2354
2598
|
...relation,
|
@@ -2369,11 +2613,8 @@ const validateLocale = (sourceUid, targetUid, locale) => {
|
|
2369
2613
|
const isLocalized = strapi.plugin("i18n").service("content-types").isLocalizedContentType;
|
2370
2614
|
const isSourceLocalized = isLocalized(sourceModel);
|
2371
2615
|
const isTargetLocalized = isLocalized(targetModel);
|
2372
|
-
let validatedLocale = locale;
|
2373
|
-
if (!targetModel || !isTargetLocalized)
|
2374
|
-
validatedLocale = void 0;
|
2375
2616
|
return {
|
2376
|
-
locale
|
2617
|
+
locale,
|
2377
2618
|
isSourceLocalized,
|
2378
2619
|
isTargetLocalized
|
2379
2620
|
};
|
@@ -2382,8 +2623,7 @@ const validateStatus = (sourceUid, status) => {
|
|
2382
2623
|
const sourceModel = strapi.getModel(sourceUid);
|
2383
2624
|
const isDP = strapiUtils.contentTypes.hasDraftAndPublish;
|
2384
2625
|
const isSourceDP = isDP(sourceModel);
|
2385
|
-
if (!isSourceDP)
|
2386
|
-
return { status: void 0 };
|
2626
|
+
if (!isSourceDP) return { status: void 0 };
|
2387
2627
|
switch (status) {
|
2388
2628
|
case "published":
|
2389
2629
|
return { status: "published" };
|
@@ -2413,7 +2653,7 @@ const relations = {
|
|
2413
2653
|
ctx.request?.query?.locale
|
2414
2654
|
);
|
2415
2655
|
const { status } = validateStatus(sourceUid, ctx.request?.query?.status);
|
2416
|
-
const permissionChecker2 = getService$
|
2656
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
2417
2657
|
userAbility,
|
2418
2658
|
model
|
2419
2659
|
});
|
@@ -2438,7 +2678,7 @@ const relations = {
|
|
2438
2678
|
where.id = id;
|
2439
2679
|
}
|
2440
2680
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2441
|
-
const populate = await getService$
|
2681
|
+
const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2442
2682
|
const currentEntity = await strapi.db.query(model).findOne({
|
2443
2683
|
where,
|
2444
2684
|
populate
|
@@ -2453,7 +2693,7 @@ const relations = {
|
|
2453
2693
|
}
|
2454
2694
|
entryId = currentEntity.id;
|
2455
2695
|
}
|
2456
|
-
const modelConfig = isComponent2 ? await getService$
|
2696
|
+
const modelConfig = isComponent2 ? await getService$2("components").findConfiguration(sourceSchema) : await getService$2("content-types").findConfiguration(sourceSchema);
|
2457
2697
|
const targetSchema = strapi.getModel(targetUid);
|
2458
2698
|
const mainField = fp.flow(
|
2459
2699
|
fp.prop(`metadatas.${targetField}.edit.mainField`),
|
@@ -2476,7 +2716,7 @@ const relations = {
|
|
2476
2716
|
attribute,
|
2477
2717
|
fieldsToSelect,
|
2478
2718
|
mainField,
|
2479
|
-
source: { schema: sourceSchema },
|
2719
|
+
source: { schema: sourceSchema, isLocalized: isSourceLocalized },
|
2480
2720
|
target: { schema: targetSchema, isLocalized: isTargetLocalized },
|
2481
2721
|
sourceSchema,
|
2482
2722
|
targetSchema,
|
@@ -2498,7 +2738,8 @@ const relations = {
|
|
2498
2738
|
fieldsToSelect,
|
2499
2739
|
mainField,
|
2500
2740
|
source: {
|
2501
|
-
schema: { uid: sourceUid, modelType: sourceModelType }
|
2741
|
+
schema: { uid: sourceUid, modelType: sourceModelType },
|
2742
|
+
isLocalized: isSourceLocalized
|
2502
2743
|
},
|
2503
2744
|
target: {
|
2504
2745
|
schema: { uid: targetUid },
|
@@ -2506,7 +2747,7 @@ const relations = {
|
|
2506
2747
|
}
|
2507
2748
|
} = await this.extractAndValidateRequestInfo(ctx, id);
|
2508
2749
|
const { idsToOmit, idsToInclude, _q, ...query } = ctx.request.query;
|
2509
|
-
const permissionChecker2 = getService$
|
2750
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
2510
2751
|
userAbility: ctx.state.userAbility,
|
2511
2752
|
model: targetUid
|
2512
2753
|
});
|
@@ -2536,12 +2777,16 @@ const relations = {
|
|
2536
2777
|
} else {
|
2537
2778
|
where.id = id;
|
2538
2779
|
}
|
2539
|
-
|
2540
|
-
|
2780
|
+
const publishedAt = getPublishedAtClause(status, targetUid);
|
2781
|
+
if (!fp.isEmpty(publishedAt)) {
|
2782
|
+
where[`${alias}.published_at`] = publishedAt;
|
2541
2783
|
}
|
2542
|
-
if (
|
2784
|
+
if (isTargetLocalized && locale) {
|
2543
2785
|
where[`${alias}.locale`] = locale;
|
2544
2786
|
}
|
2787
|
+
if (isSourceLocalized && locale) {
|
2788
|
+
where.locale = locale;
|
2789
|
+
}
|
2545
2790
|
if ((idsToInclude?.length ?? 0) !== 0) {
|
2546
2791
|
where[`${alias}.id`].$notIn = idsToInclude;
|
2547
2792
|
}
|
@@ -2559,7 +2804,8 @@ const relations = {
|
|
2559
2804
|
id: { $notIn: fp.uniq(idsToOmit) }
|
2560
2805
|
});
|
2561
2806
|
}
|
2562
|
-
const
|
2807
|
+
const dbQuery = strapi.get("query-params").transform(targetUid, queryParams);
|
2808
|
+
const res = await strapi.db.query(targetUid).findPage(dbQuery);
|
2563
2809
|
ctx.body = {
|
2564
2810
|
...res,
|
2565
2811
|
results: await addStatusToRelations(targetUid, res.results)
|
@@ -2574,21 +2820,33 @@ const relations = {
|
|
2574
2820
|
attribute,
|
2575
2821
|
targetField,
|
2576
2822
|
fieldsToSelect,
|
2577
|
-
|
2578
|
-
|
2579
|
-
}
|
2580
|
-
target: {
|
2581
|
-
schema: { uid: targetUid }
|
2582
|
-
}
|
2823
|
+
status,
|
2824
|
+
source: { schema: sourceSchema },
|
2825
|
+
target: { schema: targetSchema }
|
2583
2826
|
} = await this.extractAndValidateRequestInfo(ctx, id);
|
2584
|
-
const
|
2827
|
+
const { uid: sourceUid } = sourceSchema;
|
2828
|
+
const { uid: targetUid } = targetSchema;
|
2829
|
+
const permissionQuery = await getService$2("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
|
2585
2830
|
const dbQuery = strapi.db.query(sourceUid);
|
2586
2831
|
const loadRelations = strapiUtils.relations.isAnyToMany(attribute) ? (...args) => dbQuery.loadPages(...args) : (...args) => dbQuery.load(...args).then((res2) => ({ results: res2 ? [res2] : [] }));
|
2832
|
+
const filters = {};
|
2833
|
+
if (sourceSchema?.options?.draftAndPublish) {
|
2834
|
+
if (targetSchema?.options?.draftAndPublish) {
|
2835
|
+
if (status === "published") {
|
2836
|
+
filters.publishedAt = { $notNull: true };
|
2837
|
+
} else {
|
2838
|
+
filters.publishedAt = { $null: true };
|
2839
|
+
}
|
2840
|
+
}
|
2841
|
+
} else if (targetSchema?.options?.draftAndPublish) {
|
2842
|
+
filters.publishedAt = { $null: true };
|
2843
|
+
}
|
2587
2844
|
const res = await loadRelations({ id: entryId }, targetField, {
|
2588
|
-
select: ["id", "documentId", "locale", "publishedAt"],
|
2845
|
+
select: ["id", "documentId", "locale", "publishedAt", "updatedAt"],
|
2589
2846
|
ordering: "desc",
|
2590
2847
|
page: ctx.request.query.page,
|
2591
|
-
pageSize: ctx.request.query.pageSize
|
2848
|
+
pageSize: ctx.request.query.pageSize,
|
2849
|
+
filters
|
2592
2850
|
});
|
2593
2851
|
const loadedIds = res.results.map((item) => item.id);
|
2594
2852
|
addFiltersClause(permissionQuery, { id: { $in: loadedIds } });
|
@@ -2609,10 +2867,10 @@ const relations = {
|
|
2609
2867
|
}
|
2610
2868
|
};
|
2611
2869
|
const buildPopulateFromQuery = async (query, model) => {
|
2612
|
-
return getService$
|
2870
|
+
return getService$2("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
|
2613
2871
|
};
|
2614
2872
|
const findDocument = async (query, uid2, opts = {}) => {
|
2615
|
-
const documentManager2 = getService$
|
2873
|
+
const documentManager2 = getService$2("document-manager");
|
2616
2874
|
const populate = await buildPopulateFromQuery(query, uid2);
|
2617
2875
|
return documentManager2.findMany({ ...opts, populate }, uid2).then((documents) => documents[0]);
|
2618
2876
|
};
|
@@ -2620,8 +2878,8 @@ const createOrUpdateDocument = async (ctx, opts) => {
|
|
2620
2878
|
const { user, userAbility } = ctx.state;
|
2621
2879
|
const { model } = ctx.params;
|
2622
2880
|
const { body, query } = ctx.request;
|
2623
|
-
const documentManager2 = getService$
|
2624
|
-
const permissionChecker2 = getService$
|
2881
|
+
const documentManager2 = getService$2("document-manager");
|
2882
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2625
2883
|
if (permissionChecker2.cannot.create() && permissionChecker2.cannot.update()) {
|
2626
2884
|
throw new strapiUtils.errors.ForbiddenError();
|
2627
2885
|
}
|
@@ -2662,7 +2920,7 @@ const singleTypes = {
|
|
2662
2920
|
const { userAbility } = ctx.state;
|
2663
2921
|
const { model } = ctx.params;
|
2664
2922
|
const { query = {} } = ctx.request;
|
2665
|
-
const permissionChecker2 = getService$
|
2923
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2666
2924
|
if (permissionChecker2.cannot.read()) {
|
2667
2925
|
return ctx.forbidden();
|
2668
2926
|
}
|
@@ -2681,7 +2939,7 @@ const singleTypes = {
|
|
2681
2939
|
permissionChecker2,
|
2682
2940
|
model,
|
2683
2941
|
// @ts-expect-error - fix types
|
2684
|
-
{
|
2942
|
+
{ documentId: document.documentId, locale, publishedAt: null },
|
2685
2943
|
{ availableLocales: true, availableStatus: false }
|
2686
2944
|
);
|
2687
2945
|
ctx.body = { data: {}, meta };
|
@@ -2696,7 +2954,7 @@ const singleTypes = {
|
|
2696
2954
|
async createOrUpdate(ctx) {
|
2697
2955
|
const { userAbility } = ctx.state;
|
2698
2956
|
const { model } = ctx.params;
|
2699
|
-
const permissionChecker2 = getService$
|
2957
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2700
2958
|
const document = await createOrUpdateDocument(ctx);
|
2701
2959
|
const sanitizedDocument = await permissionChecker2.sanitizeOutput(document);
|
2702
2960
|
ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedDocument);
|
@@ -2705,8 +2963,8 @@ const singleTypes = {
|
|
2705
2963
|
const { userAbility } = ctx.state;
|
2706
2964
|
const { model } = ctx.params;
|
2707
2965
|
const { query = {} } = ctx.request;
|
2708
|
-
const documentManager2 = getService$
|
2709
|
-
const permissionChecker2 = getService$
|
2966
|
+
const documentManager2 = getService$2("document-manager");
|
2967
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2710
2968
|
if (permissionChecker2.cannot.delete()) {
|
2711
2969
|
return ctx.forbidden();
|
2712
2970
|
}
|
@@ -2734,8 +2992,8 @@ const singleTypes = {
|
|
2734
2992
|
const { userAbility } = ctx.state;
|
2735
2993
|
const { model } = ctx.params;
|
2736
2994
|
const { query = {} } = ctx.request;
|
2737
|
-
const documentManager2 = getService$
|
2738
|
-
const permissionChecker2 = getService$
|
2995
|
+
const documentManager2 = getService$2("document-manager");
|
2996
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2739
2997
|
if (permissionChecker2.cannot.publish()) {
|
2740
2998
|
return ctx.forbidden();
|
2741
2999
|
}
|
@@ -2763,8 +3021,8 @@ const singleTypes = {
|
|
2763
3021
|
body: { discardDraft, ...body },
|
2764
3022
|
query = {}
|
2765
3023
|
} = ctx.request;
|
2766
|
-
const documentManager2 = getService$
|
2767
|
-
const permissionChecker2 = getService$
|
3024
|
+
const documentManager2 = getService$2("document-manager");
|
3025
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2768
3026
|
if (permissionChecker2.cannot.unpublish()) {
|
2769
3027
|
return ctx.forbidden();
|
2770
3028
|
}
|
@@ -2798,8 +3056,8 @@ const singleTypes = {
|
|
2798
3056
|
const { userAbility } = ctx.state;
|
2799
3057
|
const { model } = ctx.params;
|
2800
3058
|
const { body, query = {} } = ctx.request;
|
2801
|
-
const documentManager2 = getService$
|
2802
|
-
const permissionChecker2 = getService$
|
3059
|
+
const documentManager2 = getService$2("document-manager");
|
3060
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2803
3061
|
if (permissionChecker2.cannot.discard()) {
|
2804
3062
|
return ctx.forbidden();
|
2805
3063
|
}
|
@@ -2822,8 +3080,8 @@ const singleTypes = {
|
|
2822
3080
|
const { userAbility } = ctx.state;
|
2823
3081
|
const { model } = ctx.params;
|
2824
3082
|
const { query } = ctx.request;
|
2825
|
-
const documentManager2 = getService$
|
2826
|
-
const permissionChecker2 = getService$
|
3083
|
+
const documentManager2 = getService$2("document-manager");
|
3084
|
+
const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
|
2827
3085
|
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2828
3086
|
if (permissionChecker2.cannot.read()) {
|
2829
3087
|
return ctx.forbidden();
|
@@ -2847,7 +3105,7 @@ const uid$1 = {
|
|
2847
3105
|
const { query = {} } = ctx.request;
|
2848
3106
|
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2849
3107
|
await validateUIDField(contentTypeUID, field);
|
2850
|
-
const uidService = getService$
|
3108
|
+
const uidService = getService$2("uid");
|
2851
3109
|
ctx.body = {
|
2852
3110
|
data: await uidService.generateUIDField({ contentTypeUID, field, data, locale })
|
2853
3111
|
};
|
@@ -2859,7 +3117,7 @@ const uid$1 = {
|
|
2859
3117
|
const { query = {} } = ctx.request;
|
2860
3118
|
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2861
3119
|
await validateUIDField(contentTypeUID, field);
|
2862
|
-
const uidService = getService$
|
3120
|
+
const uidService = getService$2("uid");
|
2863
3121
|
const isAvailable = await uidService.checkUIDAvailability({
|
2864
3122
|
contentTypeUID,
|
2865
3123
|
field,
|
@@ -2880,7 +3138,8 @@ const controllers = {
|
|
2880
3138
|
relations,
|
2881
3139
|
"single-types": singleTypes,
|
2882
3140
|
uid: uid$1,
|
2883
|
-
...history.controllers ? history.controllers : {}
|
3141
|
+
...history.controllers ? history.controllers : {},
|
3142
|
+
...preview.controllers ? preview.controllers : {}
|
2884
3143
|
};
|
2885
3144
|
const keys = {
|
2886
3145
|
CONFIGURATION: "configuration"
|
@@ -3009,18 +3268,15 @@ async function syncMetadatas(configuration, schema) {
|
|
3009
3268
|
___default.default.set(updatedMeta, ["list", "searchable"], false);
|
3010
3269
|
___default.default.set(acc, [key], updatedMeta);
|
3011
3270
|
}
|
3012
|
-
if (!___default.default.has(edit, "mainField"))
|
3013
|
-
return acc;
|
3271
|
+
if (!___default.default.has(edit, "mainField")) return acc;
|
3014
3272
|
if (!isRelation$1(attr)) {
|
3015
3273
|
___default.default.set(updatedMeta, "edit", ___default.default.omit(edit, ["mainField"]));
|
3016
3274
|
___default.default.set(acc, [key], updatedMeta);
|
3017
3275
|
return acc;
|
3018
3276
|
}
|
3019
|
-
if (edit.mainField === "id")
|
3020
|
-
return acc;
|
3277
|
+
if (edit.mainField === "id") return acc;
|
3021
3278
|
const targetSchema = getTargetSchema(attr.targetModel);
|
3022
|
-
if (!targetSchema)
|
3023
|
-
return acc;
|
3279
|
+
if (!targetSchema) return acc;
|
3024
3280
|
if (!isSortable(targetSchema, edit.mainField) && !isListable(targetSchema, edit.mainField)) {
|
3025
3281
|
___default.default.set(updatedMeta, ["edit", "mainField"], getDefaultMainField(targetSchema));
|
3026
3282
|
___default.default.set(acc, [key], updatedMeta);
|
@@ -3031,12 +3287,12 @@ async function syncMetadatas(configuration, schema) {
|
|
3031
3287
|
return ___default.default.assign(metasWithDefaults, updatedMetas);
|
3032
3288
|
}
|
3033
3289
|
const getTargetSchema = (targetModel) => {
|
3034
|
-
return getService$
|
3290
|
+
return getService$2("content-types").findContentType(targetModel);
|
3035
3291
|
};
|
3036
3292
|
const DEFAULT_LIST_LENGTH = 4;
|
3037
3293
|
const MAX_ROW_SIZE = 12;
|
3038
3294
|
const isAllowedFieldSize = (type, size) => {
|
3039
|
-
const { getFieldSize } = getService$
|
3295
|
+
const { getFieldSize } = getService$2("field-sizes");
|
3040
3296
|
const fieldSize = getFieldSize(type);
|
3041
3297
|
if (!fieldSize.isResizable && size !== fieldSize.default) {
|
3042
3298
|
return false;
|
@@ -3044,7 +3300,7 @@ const isAllowedFieldSize = (type, size) => {
|
|
3044
3300
|
return size <= MAX_ROW_SIZE;
|
3045
3301
|
};
|
3046
3302
|
const getDefaultFieldSize = (attribute) => {
|
3047
|
-
const { hasFieldSize, getFieldSize } = getService$
|
3303
|
+
const { hasFieldSize, getFieldSize } = getService$2("field-sizes");
|
3048
3304
|
return getFieldSize(hasFieldSize(attribute.customField) ? attribute.customField : attribute.type).default;
|
3049
3305
|
};
|
3050
3306
|
async function createDefaultLayouts(schema) {
|
@@ -3065,8 +3321,7 @@ function createDefaultEditLayout(schema) {
|
|
3065
3321
|
return appendToEditLayout([], keys2, schema);
|
3066
3322
|
}
|
3067
3323
|
function syncLayouts(configuration, schema) {
|
3068
|
-
if (___default.default.isEmpty(configuration.layouts))
|
3069
|
-
return createDefaultLayouts(schema);
|
3324
|
+
if (___default.default.isEmpty(configuration.layouts)) return createDefaultLayouts(schema);
|
3070
3325
|
const { list = [], editRelations = [], edit = [] } = configuration.layouts || {};
|
3071
3326
|
let cleanList = list.filter((attr) => isListable(schema, attr));
|
3072
3327
|
const cleanEditRelations = editRelations.filter(
|
@@ -3077,9 +3332,8 @@ function syncLayouts(configuration, schema) {
|
|
3077
3332
|
for (const row of edit) {
|
3078
3333
|
const newRow = [];
|
3079
3334
|
for (const el of row) {
|
3080
|
-
if (!hasEditableAttribute(schema, el.name))
|
3081
|
-
|
3082
|
-
const { hasFieldSize } = getService$1("field-sizes");
|
3335
|
+
if (!hasEditableAttribute(schema, el.name)) continue;
|
3336
|
+
const { hasFieldSize } = getService$2("field-sizes");
|
3083
3337
|
const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
|
3084
3338
|
if (!isAllowedFieldSize(fieldType, el.size)) {
|
3085
3339
|
elementsToReAppend.push(el.name);
|
@@ -3109,8 +3363,7 @@ function syncLayouts(configuration, schema) {
|
|
3109
3363
|
};
|
3110
3364
|
}
|
3111
3365
|
const appendToEditLayout = (layout = [], keysToAppend, schema) => {
|
3112
|
-
if (keysToAppend.length === 0)
|
3113
|
-
return layout;
|
3366
|
+
if (keysToAppend.length === 0) return layout;
|
3114
3367
|
let currentRowIndex = Math.max(layout.length - 1, 0);
|
3115
3368
|
if (!layout[currentRowIndex]) {
|
3116
3369
|
layout[currentRowIndex] = [];
|
@@ -3219,17 +3472,17 @@ const configurationService$1 = createConfigurationService({
|
|
3219
3472
|
isComponent: true,
|
3220
3473
|
prefix: STORE_KEY_PREFIX,
|
3221
3474
|
getModels() {
|
3222
|
-
const { toContentManagerModel } = getService$
|
3475
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3223
3476
|
return fp.mapValues(toContentManagerModel, strapi.components);
|
3224
3477
|
}
|
3225
3478
|
});
|
3226
3479
|
const components = ({ strapi: strapi2 }) => ({
|
3227
3480
|
findAllComponents() {
|
3228
|
-
const { toContentManagerModel } = getService$
|
3481
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3229
3482
|
return Object.values(strapi2.components).map(toContentManagerModel);
|
3230
3483
|
},
|
3231
3484
|
findComponent(uid2) {
|
3232
|
-
const { toContentManagerModel } = getService$
|
3485
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3233
3486
|
const component = strapi2.components[uid2];
|
3234
3487
|
return fp.isNil(component) ? component : toContentManagerModel(component);
|
3235
3488
|
},
|
@@ -3280,17 +3533,17 @@ const configurationService = createConfigurationService({
|
|
3280
3533
|
storeUtils,
|
3281
3534
|
prefix: "content_types",
|
3282
3535
|
getModels() {
|
3283
|
-
const { toContentManagerModel } = getService$
|
3536
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3284
3537
|
return fp.mapValues(toContentManagerModel, strapi.contentTypes);
|
3285
3538
|
}
|
3286
3539
|
});
|
3287
3540
|
const service = ({ strapi: strapi2 }) => ({
|
3288
3541
|
findAllContentTypes() {
|
3289
|
-
const { toContentManagerModel } = getService$
|
3542
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3290
3543
|
return Object.values(strapi2.contentTypes).map(toContentManagerModel);
|
3291
3544
|
},
|
3292
3545
|
findContentType(uid2) {
|
3293
|
-
const { toContentManagerModel } = getService$
|
3546
|
+
const { toContentManagerModel } = getService$2("data-mapper");
|
3294
3547
|
const contentType = strapi2.contentTypes[uid2];
|
3295
3548
|
return fp.isNil(contentType) ? contentType : toContentManagerModel(contentType);
|
3296
3549
|
},
|
@@ -3319,7 +3572,7 @@ const service = ({ strapi: strapi2 }) => ({
|
|
3319
3572
|
return this.findConfiguration(contentType);
|
3320
3573
|
},
|
3321
3574
|
findComponentsConfigurations(contentType) {
|
3322
|
-
return getService$
|
3575
|
+
return getService$2("components").findComponentsConfigurations(contentType);
|
3323
3576
|
},
|
3324
3577
|
syncConfigurations() {
|
3325
3578
|
return configurationService.syncConfigurations();
|
@@ -3591,7 +3844,7 @@ const permission = ({ strapi: strapi2 }) => ({
|
|
3591
3844
|
return userAbility.can(action);
|
3592
3845
|
},
|
3593
3846
|
async registerPermissions() {
|
3594
|
-
const displayedContentTypes = getService$
|
3847
|
+
const displayedContentTypes = getService$2("content-types").findDisplayedContentTypes();
|
3595
3848
|
const contentTypesUids = displayedContentTypes.map(fp.prop("uid"));
|
3596
3849
|
const actions = [
|
3597
3850
|
{
|
@@ -3867,7 +4120,7 @@ const getQueryPopulate = async (uid2, query) => {
|
|
3867
4120
|
return populateQuery;
|
3868
4121
|
};
|
3869
4122
|
const buildDeepPopulate = (uid2) => {
|
3870
|
-
return getService$
|
4123
|
+
return getService$2("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
|
3871
4124
|
};
|
3872
4125
|
const populateBuilder = (uid2) => {
|
3873
4126
|
let getInitialPopulate = async () => {
|
@@ -4052,7 +4305,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4052
4305
|
*/
|
4053
4306
|
async getAvailableLocales(uid2, version, allVersions, validatableFields = []) {
|
4054
4307
|
const versionsByLocale = fp.groupBy("locale", allVersions);
|
4055
|
-
|
4308
|
+
if (version.locale) {
|
4309
|
+
delete versionsByLocale[version.locale];
|
4310
|
+
}
|
4056
4311
|
const model = strapi2.getModel(uid2);
|
4057
4312
|
const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
|
4058
4313
|
const traversalFunction = async (localeVersion) => strapiUtils.traverseEntity(
|
@@ -4099,8 +4354,7 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4099
4354
|
const matchStatus = status === "published" ? v.publishedAt !== null : v.publishedAt === null;
|
4100
4355
|
return matchLocale && matchStatus;
|
4101
4356
|
});
|
4102
|
-
if (!availableStatus)
|
4103
|
-
return availableStatus;
|
4357
|
+
if (!availableStatus) return availableStatus;
|
4104
4358
|
return fp.pick(AVAILABLE_STATUS_FIELDS, availableStatus);
|
4105
4359
|
},
|
4106
4360
|
/**
|
@@ -4110,8 +4364,7 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4110
4364
|
* @returns
|
4111
4365
|
*/
|
4112
4366
|
async getManyAvailableStatus(uid2, documents) {
|
4113
|
-
if (!documents.length)
|
4114
|
-
return [];
|
4367
|
+
if (!documents.length) return [];
|
4115
4368
|
const status = documents[0].publishedAt !== null ? "published" : "draft";
|
4116
4369
|
const locale = documents[0]?.locale;
|
4117
4370
|
const otherStatus = status === "published" ? "draft" : "published";
|
@@ -4138,10 +4391,8 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4138
4391
|
} else if (otherVersion) {
|
4139
4392
|
draftVersion = otherVersion;
|
4140
4393
|
}
|
4141
|
-
if (!draftVersion)
|
4142
|
-
|
4143
|
-
if (!publishedVersion)
|
4144
|
-
return CONTENT_MANAGER_STATUS.DRAFT;
|
4394
|
+
if (!draftVersion) return CONTENT_MANAGER_STATUS.PUBLISHED;
|
4395
|
+
if (!publishedVersion) return CONTENT_MANAGER_STATUS.DRAFT;
|
4145
4396
|
const isDraftModified = getIsVersionLatestModification(draftVersion, publishedVersion);
|
4146
4397
|
return isDraftModified ? CONTENT_MANAGER_STATUS.MODIFIED : CONTENT_MANAGER_STATUS.PUBLISHED;
|
4147
4398
|
},
|
@@ -4408,7 +4659,8 @@ const services = {
|
|
4408
4659
|
permission,
|
4409
4660
|
"populate-builder": populateBuilder$1,
|
4410
4661
|
uid,
|
4411
|
-
...history.services ? history.services : {}
|
4662
|
+
...history.services ? history.services : {},
|
4663
|
+
...preview.services ? preview.services : {}
|
4412
4664
|
};
|
4413
4665
|
const index = () => {
|
4414
4666
|
return {
|