@strapi/content-manager 0.0.0-experimental.e350eaa6073e65190102b4b798c32c287053cc02 → 0.0.0-experimental.e8d8fc824d0f6a695b2a9ebaa4680ed21c3645ca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{ComponentConfigurationPage-BTR_hQow.js → ComponentConfigurationPage-BlzvDpbX.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BTR_hQow.js.map → ComponentConfigurationPage-BlzvDpbX.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs → ComponentConfigurationPage-DaPOlQaD.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs.map → ComponentConfigurationPage-DaPOlQaD.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs → EditConfigurationPage-BZPXItXo.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs.map → EditConfigurationPage-BZPXItXo.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js → EditConfigurationPage-uy-v43AR.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js.map → EditConfigurationPage-uy-v43AR.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-wujOq90c.js → EditViewPage-DT6A4ayX.js} +3 -3
- package/dist/_chunks/{EditViewPage-wujOq90c.js.map → EditViewPage-DT6A4ayX.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-BCjNxNlY.mjs → EditViewPage-oOLeTySr.mjs} +3 -3
- package/dist/_chunks/{EditViewPage-BCjNxNlY.mjs.map → EditViewPage-oOLeTySr.mjs.map} +1 -1
- package/dist/_chunks/{Field-Byr3mPTl.mjs → Field-D7dv2aUX.mjs} +23 -50
- package/dist/_chunks/Field-D7dv2aUX.mjs.map +1 -0
- package/dist/_chunks/{Field-B5QXnctJ.js → Field-kYFVIGiP.js} +23 -50
- package/dist/_chunks/Field-kYFVIGiP.js.map +1 -0
- package/dist/_chunks/{Form-BZgvE8C8.mjs → Form-BxR6sc29.mjs} +2 -2
- package/dist/_chunks/{Form-BZgvE8C8.mjs.map → Form-BxR6sc29.mjs.map} +1 -1
- package/dist/_chunks/{Form-D7mexvm3.js → Form-CCijSg3V.js} +2 -2
- package/dist/_chunks/{Form-D7mexvm3.js.map → Form-CCijSg3V.js.map} +1 -1
- package/dist/_chunks/{History-DYl2A8Z_.js → History-BMndx49M.js} +4 -4
- package/dist/_chunks/{History-DYl2A8Z_.js.map → History-BMndx49M.js.map} +1 -1
- package/dist/_chunks/{History-CqNgxkqK.mjs → History-D8F7aYQU.mjs} +4 -4
- package/dist/_chunks/{History-CqNgxkqK.mjs.map → History-D8F7aYQU.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js → ListConfigurationPage-DouY1EWM.js} +2 -2
- package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js.map → ListConfigurationPage-DouY1EWM.js.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs → ListConfigurationPage-DqAdSPwC.mjs} +2 -2
- package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs.map → ListConfigurationPage-DqAdSPwC.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-BtSi8C1l.js → ListViewPage-BPVmh9pq.js} +3 -3
- package/dist/_chunks/{ListViewPage-BtSi8C1l.js.map → ListViewPage-BPVmh9pq.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs → ListViewPage-C73F0jPh.mjs} +3 -3
- package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs.map → ListViewPage-C73F0jPh.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs → NoContentTypePage-B5w7iJOF.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs.map → NoContentTypePage-B5w7iJOF.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-CitJeOq4.js → NoContentTypePage-BwcL--4H.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-CitJeOq4.js.map → NoContentTypePage-BwcL--4H.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js → NoPermissionsPage-BMFKVcwJ.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js.map → NoPermissionsPage-BMFKVcwJ.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs → NoPermissionsPage-UnEgMGK4.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs.map → NoPermissionsPage-UnEgMGK4.mjs.map} +1 -1
- package/dist/_chunks/{Preview-DfNx8Ke-.js → Preview-B7PR3Ok_.js} +5 -4
- package/dist/_chunks/Preview-B7PR3Ok_.js.map +1 -0
- package/dist/_chunks/{Preview-BaYGJ0nb.mjs → Preview-DECOhK0D.mjs} +5 -4
- package/dist/_chunks/Preview-DECOhK0D.mjs.map +1 -0
- package/dist/_chunks/{Relations-DM2yUTST.mjs → Relations-DinMQJ4B.mjs} +3 -3
- package/dist/_chunks/{Relations-DM2yUTST.mjs.map → Relations-DinMQJ4B.mjs.map} +1 -1
- package/dist/_chunks/{Relations-DuKCaXrv.js → Relations-lndx3aQk.js} +3 -3
- package/dist/_chunks/{Relations-DuKCaXrv.js.map → Relations-lndx3aQk.js.map} +1 -1
- package/dist/_chunks/{index-DVAIIsOs.mjs → index-C2SagWVW.mjs} +11 -11
- package/dist/_chunks/{index-DVAIIsOs.mjs.map → index-C2SagWVW.mjs.map} +1 -1
- package/dist/_chunks/{index-BUWEmX8m.js → index-Cnw4gqee.js} +11 -11
- package/dist/_chunks/{index-BUWEmX8m.js.map → index-Cnw4gqee.js.map} +1 -1
- package/dist/_chunks/{layout-Bxsv5mP7.mjs → layout-DY_D9MGA.mjs} +3 -3
- package/dist/_chunks/{layout-Bxsv5mP7.mjs.map → layout-DY_D9MGA.mjs.map} +1 -1
- package/dist/_chunks/{layout-C3fN7Ejz.js → layout-ivwIVPnV.js} +3 -3
- package/dist/_chunks/{layout-C3fN7Ejz.js.map → layout-ivwIVPnV.js.map} +1 -1
- package/dist/_chunks/{relations-BPZKAoEY.js → relations-B7C7O_Pv.js} +2 -2
- package/dist/_chunks/{relations-BPZKAoEY.js.map → relations-B7C7O_Pv.js.map} +1 -1
- package/dist/_chunks/{relations-o3pPhzY4.mjs → relations-Boc5Y9kX.mjs} +2 -2
- package/dist/_chunks/{relations-o3pPhzY4.mjs.map → relations-Boc5Y9kX.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +74 -62
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +75 -63
- 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/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 +6 -6
- package/dist/_chunks/Field-B5QXnctJ.js.map +0 -1
- package/dist/_chunks/Field-Byr3mPTl.mjs.map +0 -1
- package/dist/_chunks/Preview-BaYGJ0nb.mjs.map +0 -1
- package/dist/_chunks/Preview-DfNx8Ke-.js.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";
|
@@ -3904,6 +3904,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
|
|
3904
3904
|
if (initialPopulate) {
|
3905
3905
|
return initialPopulate;
|
3906
3906
|
}
|
3907
|
+
if (attributeName === "localizations") {
|
3908
|
+
const validationPopulate = getPopulateForValidation(model.uid);
|
3909
|
+
return {
|
3910
|
+
populate: validationPopulate.populate
|
3911
|
+
};
|
3912
|
+
}
|
3907
3913
|
if (!isVisibleAttribute$1(model, attributeName)) {
|
3908
3914
|
return true;
|
3909
3915
|
}
|
@@ -3963,6 +3969,9 @@ const getDeepPopulate = (uid2, {
|
|
3963
3969
|
return {};
|
3964
3970
|
}
|
3965
3971
|
const model = strapi.getModel(uid2);
|
3972
|
+
if (!model) {
|
3973
|
+
return {};
|
3974
|
+
}
|
3966
3975
|
return Object.keys(model.attributes).reduce(
|
3967
3976
|
(populateAcc, attributeName) => merge(
|
3968
3977
|
populateAcc,
|
@@ -3982,40 +3991,46 @@ const getDeepPopulate = (uid2, {
|
|
3982
3991
|
{}
|
3983
3992
|
);
|
3984
3993
|
};
|
3985
|
-
const
|
3986
|
-
|
3987
|
-
|
3988
|
-
countOne = false,
|
3989
|
-
maxLevel = Infinity
|
3990
|
-
} = {}, level = 1) => {
|
3991
|
-
if (level > maxLevel) {
|
3994
|
+
const getPopulateForValidation = (uid2) => {
|
3995
|
+
const model = strapi.getModel(uid2);
|
3996
|
+
if (!model) {
|
3992
3997
|
return {};
|
3993
3998
|
}
|
3994
|
-
const model = strapi.getModel(uid2);
|
3995
3999
|
return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
|
3996
|
-
if (
|
4000
|
+
if (isScalarAttribute(attribute)) {
|
4001
|
+
if (getDoesAttributeRequireValidation(attribute)) {
|
4002
|
+
populateAcc.fields = populateAcc.fields || [];
|
4003
|
+
populateAcc.fields.push(attributeName);
|
4004
|
+
}
|
3997
4005
|
return populateAcc;
|
3998
4006
|
}
|
3999
|
-
if (
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
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;
|
4003
4015
|
}
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
4013
|
-
countOne,
|
4014
|
-
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;
|
4015
4025
|
},
|
4016
|
-
|
4017
|
-
)
|
4018
|
-
|
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;
|
4019
4034
|
}, {});
|
4020
4035
|
};
|
4021
4036
|
const getDeepPopulateDraftCount = (uid2) => {
|
@@ -4257,7 +4272,6 @@ const AVAILABLE_LOCALES_FIELDS = [
|
|
4257
4272
|
"locale",
|
4258
4273
|
"updatedAt",
|
4259
4274
|
"createdAt",
|
4260
|
-
"status",
|
4261
4275
|
"publishedAt",
|
4262
4276
|
"documentId"
|
4263
4277
|
];
|
@@ -4278,36 +4292,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4278
4292
|
/**
|
4279
4293
|
* Returns available locales of a document for the current status
|
4280
4294
|
*/
|
4281
|
-
async getAvailableLocales(uid2, version, allVersions
|
4295
|
+
async getAvailableLocales(uid2, version, allVersions) {
|
4282
4296
|
const versionsByLocale = groupBy("locale", allVersions);
|
4283
4297
|
if (version.locale) {
|
4284
4298
|
delete versionsByLocale[version.locale];
|
4285
4299
|
}
|
4286
4300
|
const model = strapi2.getModel(uid2);
|
4287
|
-
const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
|
4288
|
-
const traversalFunction = async (localeVersion) => traverseEntity(
|
4289
|
-
({ key }, { remove }) => {
|
4290
|
-
if (keysToKeep.includes(key)) {
|
4291
|
-
return;
|
4292
|
-
}
|
4293
|
-
remove(key);
|
4294
|
-
},
|
4295
|
-
{ schema: model, getModel: strapi2.getModel.bind(strapi2) },
|
4296
|
-
// @ts-expect-error fix types DocumentVersion incompatible with Data
|
4297
|
-
localeVersion
|
4298
|
-
);
|
4299
4301
|
const mappingResult = await async.map(
|
4300
4302
|
Object.values(versionsByLocale),
|
4301
4303
|
async (localeVersions) => {
|
4302
|
-
const mappedLocaleVersions = await async.map(
|
4303
|
-
localeVersions,
|
4304
|
-
traversalFunction
|
4305
|
-
);
|
4306
4304
|
if (!contentTypes$1.hasDraftAndPublish(model)) {
|
4307
|
-
return
|
4305
|
+
return localeVersions[0];
|
4308
4306
|
}
|
4309
|
-
const draftVersion =
|
4310
|
-
const otherVersions =
|
4307
|
+
const draftVersion = localeVersions.find((v) => v.publishedAt === null);
|
4308
|
+
const otherVersions = localeVersions.filter((v) => v.id !== draftVersion?.id);
|
4311
4309
|
if (!draftVersion) {
|
4312
4310
|
return;
|
4313
4311
|
}
|
@@ -4341,15 +4339,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4341
4339
|
async getManyAvailableStatus(uid2, documents) {
|
4342
4340
|
if (!documents.length) return [];
|
4343
4341
|
const status = documents[0].publishedAt !== null ? "published" : "draft";
|
4344
|
-
const
|
4345
|
-
|
4346
|
-
|
4347
|
-
|
4348
|
-
|
4342
|
+
const locales = documents.map((d) => d.locale).filter(Boolean);
|
4343
|
+
return strapi2.query(uid2).findMany({
|
4344
|
+
where: {
|
4345
|
+
documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
|
4346
|
+
// NOTE: find the "opposite" status
|
4347
|
+
publishedAt: { $null: status === "published" },
|
4348
|
+
locale: { $in: locales }
|
4349
4349
|
},
|
4350
|
-
|
4351
|
-
locale,
|
4352
|
-
fields: ["documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
|
4350
|
+
select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
|
4353
4351
|
});
|
4354
4352
|
},
|
4355
4353
|
getStatus(version, otherDocumentStatuses) {
|
@@ -4375,11 +4373,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4375
4373
|
// We could refactor this so the locales are only loaded when they're
|
4376
4374
|
// needed. e.g. in the bulk locale action modal.
|
4377
4375
|
async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
|
4378
|
-
const populate =
|
4379
|
-
const
|
4380
|
-
where: { documentId: version.documentId },
|
4376
|
+
const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
|
4377
|
+
const params = {
|
4381
4378
|
populate: {
|
4382
|
-
// Populate only fields that require validation for bulk locale actions
|
4383
4379
|
...populate,
|
4384
4380
|
// NOTE: creator fields are selected in this way to avoid exposing sensitive data
|
4385
4381
|
createdBy: {
|
@@ -4388,9 +4384,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4388
4384
|
updatedBy: {
|
4389
4385
|
select: ["id", "firstname", "lastname", "email"]
|
4390
4386
|
}
|
4387
|
+
},
|
4388
|
+
fields: uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
|
4389
|
+
filters: {
|
4390
|
+
documentId: version.documentId
|
4391
4391
|
}
|
4392
|
-
}
|
4393
|
-
const
|
4392
|
+
};
|
4393
|
+
const dbParams = strapi2.get("query-params").transform(uid2, params);
|
4394
|
+
const versions = await strapi2.db.query(uid2).findMany(dbParams);
|
4395
|
+
const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
|
4394
4396
|
const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
|
4395
4397
|
return {
|
4396
4398
|
availableLocales: availableLocalesResult,
|
@@ -4417,6 +4419,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4417
4419
|
opts.availableStatus = false;
|
4418
4420
|
}
|
4419
4421
|
const meta = await this.getMetadata(uid2, document, opts);
|
4422
|
+
if (document.localizations) {
|
4423
|
+
const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
|
4424
|
+
document.localizations = document.localizations.map((d) => {
|
4425
|
+
const status = otherStatus.find((s) => s.documentId === d.documentId);
|
4426
|
+
return {
|
4427
|
+
...d,
|
4428
|
+
status: this.getStatus(d, status ? [status] : [])
|
4429
|
+
};
|
4430
|
+
});
|
4431
|
+
}
|
4420
4432
|
return {
|
4421
4433
|
data: {
|
4422
4434
|
...document,
|