@strapi/content-manager 0.0.0-next.c9f32f6f0c2be1b88323373117f12eb33219d20e → 0.0.0-next.cb5f24c83e8fde7c31e5850c14430d38aa9b8862
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-N-CTtgQa.js → ComponentConfigurationPage-BSEZcJVB.js} +4 -5
- package/dist/_chunks/{ComponentConfigurationPage-N-CTtgQa.js.map → ComponentConfigurationPage-BSEZcJVB.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BaJMOQyq.mjs → ComponentConfigurationPage-BiASGi7x.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BaJMOQyq.mjs.map → ComponentConfigurationPage-BiASGi7x.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-BHkjAbxH.js → EditConfigurationPage-D2rtvneE.js} +4 -5
- package/dist/_chunks/{EditConfigurationPage-BHkjAbxH.js.map → EditConfigurationPage-D2rtvneE.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CKK-5LfX.mjs → EditConfigurationPage-vN4zupij.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CKK-5LfX.mjs.map → EditConfigurationPage-vN4zupij.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-QPUftxUd.js → EditViewPage-BwisF04Q.js} +4 -5
- package/dist/_chunks/{EditViewPage-QPUftxUd.js.map → EditViewPage-BwisF04Q.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-B11aeMcf.mjs → EditViewPage-_A31Cl4g.mjs} +3 -3
- package/dist/_chunks/{EditViewPage-B11aeMcf.mjs.map → EditViewPage-_A31Cl4g.mjs.map} +1 -1
- package/dist/_chunks/{Field-Bj_RgtGo.mjs → Field-CvIunNOj.mjs} +129 -96
- package/dist/_chunks/Field-CvIunNOj.mjs.map +1 -0
- package/dist/_chunks/{Field-DUK83cfh.js → Field-Dsu6-FrM.js} +132 -99
- package/dist/_chunks/Field-Dsu6-FrM.js.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-DLMSoXV7.mjs → Form-DK0fG0Gj.mjs} +3 -3
- package/dist/_chunks/{Form-DLMSoXV7.mjs.map → Form-DK0fG0Gj.mjs.map} +1 -1
- package/dist/_chunks/{Form-DHmBRlHd.js → Form-DUwWcCmA.js} +5 -6
- package/dist/_chunks/{Form-DHmBRlHd.js.map → Form-DUwWcCmA.js.map} +1 -1
- package/dist/_chunks/{History-Di3zm4HT.js → History-CeCDhoJG.js} +5 -6
- package/dist/_chunks/{History-Di3zm4HT.js.map → History-CeCDhoJG.js.map} +1 -1
- package/dist/_chunks/{History-CfCSNlG9.mjs → History-DP8gmXpm.mjs} +4 -4
- package/dist/_chunks/{History-CfCSNlG9.mjs.map → History-DP8gmXpm.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-0mtv_iqk.mjs → ListConfigurationPage-BCkO5iuN.mjs} +3 -3
- package/dist/_chunks/{ListConfigurationPage-0mtv_iqk.mjs.map → ListConfigurationPage-BCkO5iuN.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-Cq361KIt.js → ListConfigurationPage-C-bAd44a.js} +4 -5
- package/dist/_chunks/{ListConfigurationPage-Cq361KIt.js.map → ListConfigurationPage-C-bAd44a.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-DFDcG8gM.js → ListViewPage-BKTZFhsM.js} +4 -5
- package/dist/_chunks/{ListViewPage-DFDcG8gM.js.map → ListViewPage-BKTZFhsM.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-BxLVROX8.mjs → ListViewPage-Cf_DgaFV.mjs} +3 -3
- package/dist/_chunks/{ListViewPage-BxLVROX8.mjs.map → ListViewPage-Cf_DgaFV.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BSyvnDZZ.js → NoContentTypePage-D3Cm3v3q.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BSyvnDZZ.js.map → NoContentTypePage-D3Cm3v3q.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BRfDd67_.mjs → NoContentTypePage-nHIyvJcB.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BRfDd67_.mjs.map → NoContentTypePage-nHIyvJcB.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CV9V8KWa.mjs → NoPermissionsPage-BALVSJ7x.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CV9V8KWa.mjs.map → NoPermissionsPage-BALVSJ7x.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DyLphsn_.js → NoPermissionsPage-CChGWBj5.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DyLphsn_.js.map → NoPermissionsPage-CChGWBj5.js.map} +1 -1
- package/dist/_chunks/{Preview-C_B1nx3g.mjs → Preview-C4NBzKUV.mjs} +33 -11
- package/dist/_chunks/Preview-C4NBzKUV.mjs.map +1 -0
- package/dist/_chunks/{Preview-D_3aO6Ly.js → Preview-CT28Ckpg.js} +33 -12
- package/dist/_chunks/Preview-CT28Ckpg.js.map +1 -0
- package/dist/_chunks/{Relations-C6pwmDXh.mjs → Relations-C8uC89cT.mjs} +6 -8
- package/dist/_chunks/{Relations-C6pwmDXh.mjs.map → Relations-C8uC89cT.mjs.map} +1 -1
- package/dist/_chunks/{Relations-Cne2AlrL.js → Relations-CvkPCng_.js} +7 -10
- package/dist/_chunks/{Relations-Cne2AlrL.js.map → Relations-CvkPCng_.js.map} +1 -1
- package/dist/_chunks/{en-Ic0kXjxB.js → en-BK8Xyl5I.js} +2 -1
- package/dist/_chunks/{en-Ic0kXjxB.js.map → en-BK8Xyl5I.js.map} +1 -1
- package/dist/_chunks/{en-DhFUjrNW.mjs → en-Dtk_ot79.mjs} +2 -1
- package/dist/_chunks/{en-DhFUjrNW.mjs.map → en-Dtk_ot79.mjs.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-T-aWjbj2.js → index-CnX_j5h-.js} +206 -124
- package/dist/_chunks/index-CnX_j5h-.js.map +1 -0
- package/dist/_chunks/{index-BpxR3En4.mjs → index-Dh2aGTGJ.mjs} +205 -122
- package/dist/_chunks/index-Dh2aGTGJ.mjs.map +1 -0
- package/dist/_chunks/{layout-DhMZ_lDx.mjs → layout-B5qsPihj.mjs} +4 -4
- package/dist/_chunks/{layout-DhMZ_lDx.mjs.map → layout-B5qsPihj.mjs.map} +1 -1
- package/dist/_chunks/{layout-BEuNwv-F.js → layout-B_qdWGny.js} +5 -6
- package/dist/_chunks/{layout-BEuNwv-F.js.map → layout-B_qdWGny.js.map} +1 -1
- package/dist/_chunks/objects-BcXOv6_9.js.map +1 -1
- package/dist/_chunks/objects-D6yBsdmx.mjs.map +1 -1
- package/dist/_chunks/{relations-kLcuobLk.js → relations-ChcieiF5.js} +2 -2
- package/dist/_chunks/{relations-kLcuobLk.js.map → relations-ChcieiF5.js.map} +1 -1
- package/dist/_chunks/{relations-BdnxoX6f.mjs → relations-DMXpNY-e.mjs} +2 -2
- package/dist/_chunks/{relations-BdnxoX6f.mjs.map → relations-DMXpNY-e.mjs.map} +1 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -1
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -1
- 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 +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
- 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/server/index.js +95 -103
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +95 -102
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +3 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/preview/index.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +4 -2
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +3 -2
- 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/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +11 -9
- package/dist/_chunks/Field-Bj_RgtGo.mjs.map +0 -1
- package/dist/_chunks/Field-DUK83cfh.js.map +0 -1
- package/dist/_chunks/Preview-C_B1nx3g.mjs.map +0 -1
- package/dist/_chunks/Preview-D_3aO6Ly.js.map +0 -1
- package/dist/_chunks/index-BpxR3En4.mjs.map +0 -1
- package/dist/_chunks/index-T-aWjbj2.js.map +0 -1
- package/dist/admin/src/preview/constants.d.ts +0 -1
- package/dist/server/src/preview/constants.d.ts +0 -2
- package/dist/server/src/preview/constants.d.ts.map +0 -1
package/dist/server/index.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import strapiUtils, { validateYupSchema, errors, async, contentTypes as contentTypes$1, yup as yup$1, validateYupSchemaSync, policy, traverse, setCreatorFields, isOperatorOfType, relations as relations$1,
|
1
|
+
import strapiUtils, { validateYupSchema, errors, async, contentTypes as contentTypes$1, yup as yup$1, validateYupSchemaSync, policy, traverse, setCreatorFields, isOperatorOfType, relations as relations$1, pagination } from "@strapi/utils";
|
2
2
|
import { pick, omit, difference, castArray, mergeWith, intersection, pipe, propOr, isEqual, isEmpty, set, isNil as isNil$1, has, prop, assoc, mapValues, flow, uniq, uniqBy, concat, getOr, propEq, merge, groupBy } from "lodash/fp";
|
3
3
|
import "@strapi/types";
|
4
4
|
import * as yup from "yup";
|
@@ -141,8 +141,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
141
141
|
};
|
142
142
|
const getRelationRestoreValue = async (versionRelationData, attribute) => {
|
143
143
|
if (Array.isArray(versionRelationData)) {
|
144
|
-
if (versionRelationData.length === 0)
|
145
|
-
return versionRelationData;
|
144
|
+
if (versionRelationData.length === 0) return versionRelationData;
|
146
145
|
const existingAndMissingRelations = await Promise.all(
|
147
146
|
versionRelationData.map((relation) => {
|
148
147
|
return strapi2.documents(attribute.target).findOne({
|
@@ -177,8 +176,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
177
176
|
const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
|
178
177
|
const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
|
179
178
|
const getLocaleDictionary = async () => {
|
180
|
-
if (!localesService)
|
181
|
-
return {};
|
179
|
+
if (!localesService) return {};
|
182
180
|
const locales = await localesService.find() || [];
|
183
181
|
return locales.reduce(
|
184
182
|
(acc, locale) => {
|
@@ -714,7 +712,6 @@ const getFeature$1 = () => {
|
|
714
712
|
};
|
715
713
|
};
|
716
714
|
const history = getFeature$1();
|
717
|
-
const FEATURE_ID = "preview";
|
718
715
|
const info = { pluginName: "content-manager", type: "admin" };
|
719
716
|
const previewRouter = {
|
720
717
|
type: "admin",
|
@@ -892,9 +889,6 @@ const services$1 = {
|
|
892
889
|
"preview-config": createPreviewConfigService
|
893
890
|
};
|
894
891
|
const getFeature = () => {
|
895
|
-
if (!strapi.features.future.isEnabled(FEATURE_ID)) {
|
896
|
-
return {};
|
897
|
-
}
|
898
892
|
return {
|
899
893
|
register() {
|
900
894
|
const config = getService(strapi, "preview-config");
|
@@ -1480,8 +1474,7 @@ const isSortable = (schema, name) => {
|
|
1480
1474
|
if (!_.has(schema.attributes, name)) {
|
1481
1475
|
return false;
|
1482
1476
|
}
|
1483
|
-
if (schema.modelType === "component" && name === "id")
|
1484
|
-
return false;
|
1477
|
+
if (schema.modelType === "component" && name === "id") return false;
|
1485
1478
|
const attribute = schema.attributes[name];
|
1486
1479
|
if (NON_SORTABLES.includes(attribute.type)) {
|
1487
1480
|
return false;
|
@@ -1626,8 +1619,7 @@ const createDefaultSettings = async (schema) => {
|
|
1626
1619
|
};
|
1627
1620
|
};
|
1628
1621
|
const syncSettings = async (configuration, schema) => {
|
1629
|
-
if (isEmpty(configuration.settings))
|
1630
|
-
return createDefaultSettings(schema);
|
1622
|
+
if (isEmpty(configuration.settings)) return createDefaultSettings(schema);
|
1631
1623
|
const defaultField = getDefaultMainField(schema);
|
1632
1624
|
const { mainField = defaultField, defaultSortBy = defaultField } = configuration.settings || {};
|
1633
1625
|
return {
|
@@ -1803,8 +1795,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
|
|
1803
1795
|
}
|
1804
1796
|
switch (attribute.type) {
|
1805
1797
|
case "relation": {
|
1806
|
-
if (canCreate(attributePath))
|
1807
|
-
return body2;
|
1798
|
+
if (canCreate(attributePath)) return body2;
|
1808
1799
|
return set(attributePath, { set: [] }, body2);
|
1809
1800
|
}
|
1810
1801
|
case "component": {
|
@@ -1814,8 +1805,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
|
|
1814
1805
|
]);
|
1815
1806
|
}
|
1816
1807
|
default: {
|
1817
|
-
if (canCreate(attributePath))
|
1818
|
-
return body2;
|
1808
|
+
if (canCreate(attributePath)) return body2;
|
1819
1809
|
return set(attributePath, null, body2);
|
1820
1810
|
}
|
1821
1811
|
}
|
@@ -2608,8 +2598,7 @@ const validateStatus = (sourceUid, status) => {
|
|
2608
2598
|
const sourceModel = strapi.getModel(sourceUid);
|
2609
2599
|
const isDP = contentTypes$1.hasDraftAndPublish;
|
2610
2600
|
const isSourceDP = isDP(sourceModel);
|
2611
|
-
if (!isSourceDP)
|
2612
|
-
return { status: void 0 };
|
2601
|
+
if (!isSourceDP) return { status: void 0 };
|
2613
2602
|
switch (status) {
|
2614
2603
|
case "published":
|
2615
2604
|
return { status: "published" };
|
@@ -3254,18 +3243,15 @@ async function syncMetadatas(configuration, schema) {
|
|
3254
3243
|
_.set(updatedMeta, ["list", "searchable"], false);
|
3255
3244
|
_.set(acc, [key], updatedMeta);
|
3256
3245
|
}
|
3257
|
-
if (!_.has(edit, "mainField"))
|
3258
|
-
return acc;
|
3246
|
+
if (!_.has(edit, "mainField")) return acc;
|
3259
3247
|
if (!isRelation$1(attr)) {
|
3260
3248
|
_.set(updatedMeta, "edit", _.omit(edit, ["mainField"]));
|
3261
3249
|
_.set(acc, [key], updatedMeta);
|
3262
3250
|
return acc;
|
3263
3251
|
}
|
3264
|
-
if (edit.mainField === "id")
|
3265
|
-
return acc;
|
3252
|
+
if (edit.mainField === "id") return acc;
|
3266
3253
|
const targetSchema = getTargetSchema(attr.targetModel);
|
3267
|
-
if (!targetSchema)
|
3268
|
-
return acc;
|
3254
|
+
if (!targetSchema) return acc;
|
3269
3255
|
if (!isSortable(targetSchema, edit.mainField) && !isListable(targetSchema, edit.mainField)) {
|
3270
3256
|
_.set(updatedMeta, ["edit", "mainField"], getDefaultMainField(targetSchema));
|
3271
3257
|
_.set(acc, [key], updatedMeta);
|
@@ -3310,8 +3296,7 @@ function createDefaultEditLayout(schema) {
|
|
3310
3296
|
return appendToEditLayout([], keys2, schema);
|
3311
3297
|
}
|
3312
3298
|
function syncLayouts(configuration, schema) {
|
3313
|
-
if (_.isEmpty(configuration.layouts))
|
3314
|
-
return createDefaultLayouts(schema);
|
3299
|
+
if (_.isEmpty(configuration.layouts)) return createDefaultLayouts(schema);
|
3315
3300
|
const { list = [], editRelations = [], edit = [] } = configuration.layouts || {};
|
3316
3301
|
let cleanList = list.filter((attr) => isListable(schema, attr));
|
3317
3302
|
const cleanEditRelations = editRelations.filter(
|
@@ -3322,8 +3307,7 @@ function syncLayouts(configuration, schema) {
|
|
3322
3307
|
for (const row of edit) {
|
3323
3308
|
const newRow = [];
|
3324
3309
|
for (const el of row) {
|
3325
|
-
if (!hasEditableAttribute(schema, el.name))
|
3326
|
-
continue;
|
3310
|
+
if (!hasEditableAttribute(schema, el.name)) continue;
|
3327
3311
|
const { hasFieldSize } = getService$2("field-sizes");
|
3328
3312
|
const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
|
3329
3313
|
if (!isAllowedFieldSize(fieldType, el.size)) {
|
@@ -3354,8 +3338,7 @@ function syncLayouts(configuration, schema) {
|
|
3354
3338
|
};
|
3355
3339
|
}
|
3356
3340
|
const appendToEditLayout = (layout = [], keysToAppend, schema) => {
|
3357
|
-
if (keysToAppend.length === 0)
|
3358
|
-
return layout;
|
3341
|
+
if (keysToAppend.length === 0) return layout;
|
3359
3342
|
let currentRowIndex = Math.max(layout.length - 1, 0);
|
3360
3343
|
if (!layout[currentRowIndex]) {
|
3361
3344
|
layout[currentRowIndex] = [];
|
@@ -3921,6 +3904,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
|
|
3921
3904
|
if (initialPopulate) {
|
3922
3905
|
return initialPopulate;
|
3923
3906
|
}
|
3907
|
+
if (attributeName === "localizations") {
|
3908
|
+
const validationPopulate = getPopulateForValidation(model.uid);
|
3909
|
+
return {
|
3910
|
+
populate: validationPopulate.populate
|
3911
|
+
};
|
3912
|
+
}
|
3924
3913
|
if (!isVisibleAttribute$1(model, attributeName)) {
|
3925
3914
|
return true;
|
3926
3915
|
}
|
@@ -3980,6 +3969,9 @@ const getDeepPopulate = (uid2, {
|
|
3980
3969
|
return {};
|
3981
3970
|
}
|
3982
3971
|
const model = strapi.getModel(uid2);
|
3972
|
+
if (!model) {
|
3973
|
+
return {};
|
3974
|
+
}
|
3983
3975
|
return Object.keys(model.attributes).reduce(
|
3984
3976
|
(populateAcc, attributeName) => merge(
|
3985
3977
|
populateAcc,
|
@@ -3999,40 +3991,46 @@ const getDeepPopulate = (uid2, {
|
|
3999
3991
|
{}
|
4000
3992
|
);
|
4001
3993
|
};
|
4002
|
-
const
|
4003
|
-
|
4004
|
-
|
4005
|
-
countOne = false,
|
4006
|
-
maxLevel = Infinity
|
4007
|
-
} = {}, level = 1) => {
|
4008
|
-
if (level > maxLevel) {
|
3994
|
+
const getPopulateForValidation = (uid2) => {
|
3995
|
+
const model = strapi.getModel(uid2);
|
3996
|
+
if (!model) {
|
4009
3997
|
return {};
|
4010
3998
|
}
|
4011
|
-
const model = strapi.getModel(uid2);
|
4012
3999
|
return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
|
4013
|
-
if (
|
4000
|
+
if (isScalarAttribute(attribute)) {
|
4001
|
+
if (getDoesAttributeRequireValidation(attribute)) {
|
4002
|
+
populateAcc.fields = populateAcc.fields || [];
|
4003
|
+
populateAcc.fields.push(attributeName);
|
4004
|
+
}
|
4014
4005
|
return populateAcc;
|
4015
4006
|
}
|
4016
|
-
if (
|
4017
|
-
|
4018
|
-
|
4019
|
-
|
4007
|
+
if (isComponent(attribute)) {
|
4008
|
+
const component = attribute.component;
|
4009
|
+
const componentResult = getPopulateForValidation(component);
|
4010
|
+
if (Object.keys(componentResult).length > 0) {
|
4011
|
+
populateAcc.populate = populateAcc.populate || {};
|
4012
|
+
populateAcc.populate[attributeName] = componentResult;
|
4013
|
+
}
|
4014
|
+
return populateAcc;
|
4020
4015
|
}
|
4021
|
-
|
4022
|
-
|
4023
|
-
|
4024
|
-
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
countOne,
|
4031
|
-
maxLevel
|
4016
|
+
if (isDynamicZone(attribute)) {
|
4017
|
+
const components2 = attribute.components;
|
4018
|
+
const componentsResult = (components2 || []).reduce(
|
4019
|
+
(acc, componentUID) => {
|
4020
|
+
const componentResult = getPopulateForValidation(componentUID);
|
4021
|
+
if (Object.keys(componentResult).length > 0) {
|
4022
|
+
acc[componentUID] = componentResult;
|
4023
|
+
}
|
4024
|
+
return acc;
|
4032
4025
|
},
|
4033
|
-
|
4034
|
-
)
|
4035
|
-
|
4026
|
+
{}
|
4027
|
+
);
|
4028
|
+
if (Object.keys(componentsResult).length > 0) {
|
4029
|
+
populateAcc.populate = populateAcc.populate || {};
|
4030
|
+
populateAcc.populate[attributeName] = { on: componentsResult };
|
4031
|
+
}
|
4032
|
+
}
|
4033
|
+
return populateAcc;
|
4036
4034
|
}, {});
|
4037
4035
|
};
|
4038
4036
|
const getDeepPopulateDraftCount = (uid2) => {
|
@@ -4274,7 +4272,6 @@ const AVAILABLE_LOCALES_FIELDS = [
|
|
4274
4272
|
"locale",
|
4275
4273
|
"updatedAt",
|
4276
4274
|
"createdAt",
|
4277
|
-
"status",
|
4278
4275
|
"publishedAt",
|
4279
4276
|
"documentId"
|
4280
4277
|
];
|
@@ -4295,36 +4292,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4295
4292
|
/**
|
4296
4293
|
* Returns available locales of a document for the current status
|
4297
4294
|
*/
|
4298
|
-
async getAvailableLocales(uid2, version, allVersions
|
4295
|
+
async getAvailableLocales(uid2, version, allVersions) {
|
4299
4296
|
const versionsByLocale = groupBy("locale", allVersions);
|
4300
4297
|
if (version.locale) {
|
4301
4298
|
delete versionsByLocale[version.locale];
|
4302
4299
|
}
|
4303
4300
|
const model = strapi2.getModel(uid2);
|
4304
|
-
const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
|
4305
|
-
const traversalFunction = async (localeVersion) => traverseEntity(
|
4306
|
-
({ key }, { remove }) => {
|
4307
|
-
if (keysToKeep.includes(key)) {
|
4308
|
-
return;
|
4309
|
-
}
|
4310
|
-
remove(key);
|
4311
|
-
},
|
4312
|
-
{ schema: model, getModel: strapi2.getModel.bind(strapi2) },
|
4313
|
-
// @ts-expect-error fix types DocumentVersion incompatible with Data
|
4314
|
-
localeVersion
|
4315
|
-
);
|
4316
4301
|
const mappingResult = await async.map(
|
4317
4302
|
Object.values(versionsByLocale),
|
4318
4303
|
async (localeVersions) => {
|
4319
|
-
const mappedLocaleVersions = await async.map(
|
4320
|
-
localeVersions,
|
4321
|
-
traversalFunction
|
4322
|
-
);
|
4323
4304
|
if (!contentTypes$1.hasDraftAndPublish(model)) {
|
4324
|
-
return
|
4305
|
+
return localeVersions[0];
|
4325
4306
|
}
|
4326
|
-
const draftVersion =
|
4327
|
-
const otherVersions =
|
4307
|
+
const draftVersion = localeVersions.find((v) => v.publishedAt === null);
|
4308
|
+
const otherVersions = localeVersions.filter((v) => v.id !== draftVersion?.id);
|
4328
4309
|
if (!draftVersion) {
|
4329
4310
|
return;
|
4330
4311
|
}
|
@@ -4346,8 +4327,7 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4346
4327
|
const matchStatus = status === "published" ? v.publishedAt !== null : v.publishedAt === null;
|
4347
4328
|
return matchLocale && matchStatus;
|
4348
4329
|
});
|
4349
|
-
if (!availableStatus)
|
4350
|
-
return availableStatus;
|
4330
|
+
if (!availableStatus) return availableStatus;
|
4351
4331
|
return pick(AVAILABLE_STATUS_FIELDS, availableStatus);
|
4352
4332
|
},
|
4353
4333
|
/**
|
@@ -4357,18 +4337,19 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4357
4337
|
* @returns
|
4358
4338
|
*/
|
4359
4339
|
async getManyAvailableStatus(uid2, documents) {
|
4360
|
-
if (!documents.length)
|
4361
|
-
return [];
|
4340
|
+
if (!documents.length) return [];
|
4362
4341
|
const status = documents[0].publishedAt !== null ? "published" : "draft";
|
4363
|
-
const
|
4364
|
-
const
|
4365
|
-
|
4366
|
-
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
4370
|
-
|
4371
|
-
|
4342
|
+
const locales = documents.map((d) => d.locale).filter(Boolean);
|
4343
|
+
const where = {
|
4344
|
+
documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
|
4345
|
+
publishedAt: { $null: status === "published" }
|
4346
|
+
};
|
4347
|
+
if (locales.length) {
|
4348
|
+
where.locale = { $in: locales };
|
4349
|
+
}
|
4350
|
+
return strapi2.query(uid2).findMany({
|
4351
|
+
where,
|
4352
|
+
select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
|
4372
4353
|
});
|
4373
4354
|
},
|
4374
4355
|
getStatus(version, otherDocumentStatuses) {
|
@@ -4385,10 +4366,8 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4385
4366
|
} else if (otherVersion) {
|
4386
4367
|
draftVersion = otherVersion;
|
4387
4368
|
}
|
4388
|
-
if (!draftVersion)
|
4389
|
-
|
4390
|
-
if (!publishedVersion)
|
4391
|
-
return CONTENT_MANAGER_STATUS.DRAFT;
|
4369
|
+
if (!draftVersion) return CONTENT_MANAGER_STATUS.PUBLISHED;
|
4370
|
+
if (!publishedVersion) return CONTENT_MANAGER_STATUS.DRAFT;
|
4392
4371
|
const isDraftModified = getIsVersionLatestModification(draftVersion, publishedVersion);
|
4393
4372
|
return isDraftModified ? CONTENT_MANAGER_STATUS.MODIFIED : CONTENT_MANAGER_STATUS.PUBLISHED;
|
4394
4373
|
},
|
@@ -4396,11 +4375,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4396
4375
|
// We could refactor this so the locales are only loaded when they're
|
4397
4376
|
// needed. e.g. in the bulk locale action modal.
|
4398
4377
|
async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
|
4399
|
-
const populate =
|
4400
|
-
const
|
4401
|
-
where: { documentId: version.documentId },
|
4378
|
+
const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
|
4379
|
+
const params = {
|
4402
4380
|
populate: {
|
4403
|
-
// Populate only fields that require validation for bulk locale actions
|
4404
4381
|
...populate,
|
4405
4382
|
// NOTE: creator fields are selected in this way to avoid exposing sensitive data
|
4406
4383
|
createdBy: {
|
@@ -4409,9 +4386,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4409
4386
|
updatedBy: {
|
4410
4387
|
select: ["id", "firstname", "lastname", "email"]
|
4411
4388
|
}
|
4389
|
+
},
|
4390
|
+
fields: uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
|
4391
|
+
filters: {
|
4392
|
+
documentId: version.documentId
|
4412
4393
|
}
|
4413
|
-
}
|
4414
|
-
const
|
4394
|
+
};
|
4395
|
+
const dbParams = strapi2.get("query-params").transform(uid2, params);
|
4396
|
+
const versions = await strapi2.db.query(uid2).findMany(dbParams);
|
4397
|
+
const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
|
4415
4398
|
const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
|
4416
4399
|
return {
|
4417
4400
|
availableLocales: availableLocalesResult,
|
@@ -4438,6 +4421,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4438
4421
|
opts.availableStatus = false;
|
4439
4422
|
}
|
4440
4423
|
const meta = await this.getMetadata(uid2, document, opts);
|
4424
|
+
if (document.localizations) {
|
4425
|
+
const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
|
4426
|
+
document.localizations = document.localizations.map((d) => {
|
4427
|
+
const status = otherStatus.find((s) => s.documentId === d.documentId);
|
4428
|
+
return {
|
4429
|
+
...d,
|
4430
|
+
status: this.getStatus(d, status ? [status] : [])
|
4431
|
+
};
|
4432
|
+
});
|
4433
|
+
}
|
4441
4434
|
return {
|
4442
4435
|
data: {
|
4443
4436
|
...document,
|