@strapi/content-manager 0.0.0-next.7315bad3dd6542d457c3c837db874e3e6336ae9f → 0.0.0-next.76a9dc5ca66301db734af3bc2111406c17ccb860
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-DHV8IFbd.js → ComponentConfigurationPage-BLWQy8ru.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DHV8IFbd.js.map → ComponentConfigurationPage-BLWQy8ru.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-D4J64ny7.mjs → ComponentConfigurationPage-CtIa3aa2.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-D4J64ny7.mjs.map → ComponentConfigurationPage-CtIa3aa2.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DMnf8orh.mjs → EditConfigurationPage-DsPR2DVk.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-DMnf8orh.mjs.map → EditConfigurationPage-DsPR2DVk.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-q76oeVU1.js → EditConfigurationPage-RQkymxCy.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-q76oeVU1.js.map → EditConfigurationPage-RQkymxCy.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-BXoY-ITh.js → EditViewPage-B-kExt8C.js} +3 -3
- package/dist/_chunks/{EditViewPage-BXoY-ITh.js.map → EditViewPage-B-kExt8C.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-COVXj9bh.mjs → EditViewPage-BPyVuPfM.mjs} +3 -3
- package/dist/_chunks/{EditViewPage-COVXj9bh.mjs.map → EditViewPage-BPyVuPfM.mjs.map} +1 -1
- package/dist/_chunks/{Field-Dj1nOvt8.js → Field-DPIsQRre.js} +117 -61
- package/dist/_chunks/Field-DPIsQRre.js.map +1 -0
- package/dist/_chunks/{Field-CcppsFQR.mjs → Field-Dltnt1km.mjs} +116 -61
- package/dist/_chunks/Field-Dltnt1km.mjs.map +1 -0
- package/dist/_chunks/{Form-aTchNxab.js → Form-BFi4MXMT.js} +2 -2
- package/dist/_chunks/{Form-aTchNxab.js.map → Form-BFi4MXMT.js.map} +1 -1
- package/dist/_chunks/{Form-DbWwH0-A.mjs → Form-C1IcWm1u.mjs} +2 -2
- package/dist/_chunks/{Form-DbWwH0-A.mjs.map → Form-C1IcWm1u.mjs.map} +1 -1
- package/dist/_chunks/{History-tU567_hc.mjs → History-04ChQ4pl.mjs} +32 -8
- package/dist/_chunks/History-04ChQ4pl.mjs.map +1 -0
- package/dist/_chunks/{History-Cs6XM6EU.js → History-wjcK4L0C.js} +32 -8
- package/dist/_chunks/History-wjcK4L0C.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DQryo_4i.mjs → ListConfigurationPage-BYqPYLSU.mjs} +2 -2
- package/dist/_chunks/{ListConfigurationPage-DQryo_4i.mjs.map → ListConfigurationPage-BYqPYLSU.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-7LeytuFD.js → ListConfigurationPage-CRbxIC3J.js} +2 -2
- package/dist/_chunks/{ListConfigurationPage-7LeytuFD.js.map → ListConfigurationPage-CRbxIC3J.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-CaGBu5H5.js → ListViewPage-D5NY9183.js} +3 -3
- package/dist/_chunks/{ListViewPage-CaGBu5H5.js.map → ListViewPage-D5NY9183.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-B50esy_x.mjs → ListViewPage-FU2LBuhl.mjs} +3 -3
- package/dist/_chunks/{ListViewPage-B50esy_x.mjs.map → ListViewPage-FU2LBuhl.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BaBE00IO.js → NoContentTypePage-BgQVE_Qb.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BaBE00IO.js.map → NoContentTypePage-BgQVE_Qb.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-CiPP8cLx.mjs → NoContentTypePage-DCKUkwb8.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-CiPP8cLx.mjs.map → NoContentTypePage-DCKUkwb8.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DQn5cqZz.js → NoPermissionsPage-C5jwn70o.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DQn5cqZz.js.map → NoPermissionsPage-C5jwn70o.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-0-CW106p.mjs → NoPermissionsPage-jqve7C8l.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-0-CW106p.mjs.map → NoPermissionsPage-jqve7C8l.mjs.map} +1 -1
- package/dist/_chunks/{Preview-C1dBkhXf.mjs → Preview-BMYN548c.mjs} +33 -11
- package/dist/_chunks/Preview-BMYN548c.mjs.map +1 -0
- package/dist/_chunks/{Preview-DH1h7kJ6.js → Preview-DaOihysv.js} +32 -10
- package/dist/_chunks/Preview-DaOihysv.js.map +1 -0
- package/dist/_chunks/{Relations-CkECnBOd.js → Relations-CTGM7Hv5.js} +3 -3
- package/dist/_chunks/{Relations-CkECnBOd.js.map → Relations-CTGM7Hv5.js.map} +1 -1
- package/dist/_chunks/{Relations-Bvne4TvU.mjs → Relations-gscPkxjF.mjs} +3 -3
- package/dist/_chunks/{Relations-Bvne4TvU.mjs.map → Relations-gscPkxjF.mjs.map} +1 -1
- package/dist/_chunks/{en-BK8Xyl5I.js → en-BzQmavmK.js} +7 -2
- package/dist/_chunks/{en-BK8Xyl5I.js.map → en-BzQmavmK.js.map} +1 -1
- package/dist/_chunks/{en-Dtk_ot79.mjs → en-CSxLmrh1.mjs} +7 -2
- package/dist/_chunks/{en-Dtk_ot79.mjs.map → en-CSxLmrh1.mjs.map} +1 -1
- package/dist/_chunks/{index-BN1pPa5v.js → index-Ca7YWlAA.js} +170 -108
- package/dist/_chunks/index-Ca7YWlAA.js.map +1 -0
- package/dist/_chunks/{index-ByPZ754U.mjs → index-DqasUQ6Q.mjs} +170 -108
- package/dist/_chunks/index-DqasUQ6Q.mjs.map +1 -0
- package/dist/_chunks/{layout-nBPDlXjr.js → layout-BW80JSCd.js} +3 -3
- package/dist/_chunks/{layout-nBPDlXjr.js.map → layout-BW80JSCd.js.map} +1 -1
- package/dist/_chunks/{layout-CUTOYU8I.mjs → layout-W3clJSCy.mjs} +3 -3
- package/dist/_chunks/{layout-CUTOYU8I.mjs.map → layout-W3clJSCy.mjs.map} +1 -1
- package/dist/_chunks/{relations-CBc5HYHC.mjs → relations-BlDkoeWh.mjs} +2 -2
- package/dist/_chunks/{relations-CBc5HYHC.mjs.map → relations-BlDkoeWh.mjs.map} +1 -1
- package/dist/_chunks/{relations-B6B-b7lI.js → relations-C9Usz9k5.js} +2 -2
- package/dist/_chunks/{relations-B6B-b7lI.js.map → relations-C9Usz9k5.js.map} +1 -1
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +2 -1
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.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/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/preview/services/preview.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +16 -16
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/server/index.js +156 -142
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +157 -143
- 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/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +6 -10
- package/dist/server/src/history/services/utils.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 +8 -7
- package/dist/_chunks/Field-CcppsFQR.mjs.map +0 -1
- package/dist/_chunks/Field-Dj1nOvt8.js.map +0 -1
- package/dist/_chunks/History-Cs6XM6EU.js.map +0 -1
- package/dist/_chunks/History-tU567_hc.mjs.map +0 -1
- package/dist/_chunks/Preview-C1dBkhXf.mjs.map +0 -1
- package/dist/_chunks/Preview-DH1h7kJ6.js.map +0 -1
- package/dist/_chunks/index-BN1pPa5v.js.map +0 -1
- package/dist/_chunks/index-ByPZ754U.mjs.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.js
CHANGED
@@ -175,19 +175,16 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
175
175
|
});
|
176
176
|
})
|
177
177
|
);
|
178
|
-
return existingAndMissingRelations.filter(
|
179
|
-
(relation) => relation !== null
|
180
|
-
);
|
178
|
+
return existingAndMissingRelations.filter((relation) => relation !== null);
|
181
179
|
}
|
182
180
|
return strapi2.documents(attribute.target).findOne({
|
183
181
|
documentId: versionRelationData.documentId,
|
184
182
|
locale: versionRelationData.locale || void 0
|
185
183
|
});
|
186
184
|
};
|
187
|
-
const getMediaRestoreValue = async (versionRelationData
|
188
|
-
if (
|
185
|
+
const getMediaRestoreValue = async (versionRelationData) => {
|
186
|
+
if (Array.isArray(versionRelationData)) {
|
189
187
|
const existingAndMissingMedias = await Promise.all(
|
190
|
-
// @ts-expect-error Fix the type definitions so this isn't any
|
191
188
|
versionRelationData.map((media) => {
|
192
189
|
return strapi2.db.query("plugin::upload.file").findOne({ where: { id: media.id } });
|
193
190
|
})
|
@@ -356,8 +353,8 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
356
353
|
});
|
357
354
|
},
|
358
355
|
async findVersionsPage(params) {
|
359
|
-
const
|
360
|
-
const isLocalizedContentType = serviceUtils.isLocalizedContentType(
|
356
|
+
const schema = strapi2.getModel(params.query.contentType);
|
357
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(schema);
|
361
358
|
const defaultLocale = await serviceUtils.getDefaultLocale();
|
362
359
|
let locale = null;
|
363
360
|
if (isLocalizedContentType) {
|
@@ -378,32 +375,20 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
378
375
|
}),
|
379
376
|
serviceUtils.getLocaleDictionary()
|
380
377
|
]);
|
381
|
-
const
|
382
|
-
|
383
|
-
async (
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
model: "plugin::upload.file"
|
390
|
-
});
|
391
|
-
const response = await serviceUtils.buildMediaResponse(attributeValues);
|
392
|
-
const sanitizedResults = await Promise.all(
|
393
|
-
response.results.map((media) => permissionChecker2.sanitizeOutput(media))
|
394
|
-
);
|
395
|
-
return {
|
396
|
-
...await currentDataWithRelations,
|
397
|
-
[attributeKey]: {
|
398
|
-
results: sanitizedResults,
|
399
|
-
meta: response.meta
|
400
|
-
}
|
401
|
-
};
|
378
|
+
const populateEntry = async (entry) => {
|
379
|
+
return strapiUtils.traverseEntity(
|
380
|
+
async (options, utils) => {
|
381
|
+
if (!options.attribute) return;
|
382
|
+
if (!options.value) return;
|
383
|
+
const currentValue = Array.isArray(options.value) ? options.value : [options.value];
|
384
|
+
if (options.attribute.type === "component") {
|
385
|
+
utils.remove("id");
|
402
386
|
}
|
403
|
-
if (
|
404
|
-
|
387
|
+
if (options.attribute.type === "relation" && // TODO: handle polymorphic relations
|
388
|
+
options.attribute.relation !== "morphToOne" && options.attribute.relation !== "morphToMany") {
|
389
|
+
if (options.attribute.target === "admin::user") {
|
405
390
|
const adminUsers = await Promise.all(
|
406
|
-
|
391
|
+
currentValue.map((userToPopulate) => {
|
407
392
|
if (userToPopulate == null) {
|
408
393
|
return null;
|
409
394
|
}
|
@@ -415,46 +400,51 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
415
400
|
});
|
416
401
|
})
|
417
402
|
);
|
418
|
-
|
419
|
-
...await currentDataWithRelations,
|
420
|
-
/**
|
421
|
-
* Ideally we would return the same "{results: [], meta: {}}" shape, however,
|
422
|
-
* when sanitizing the data as a whole in the controller before sending to the client,
|
423
|
-
* the data for admin relation user is completely sanitized if we return an object here as opposed to an array.
|
424
|
-
*/
|
425
|
-
[attributeKey]: adminUsers
|
426
|
-
};
|
403
|
+
utils.set(options.key, adminUsers);
|
427
404
|
}
|
428
405
|
const permissionChecker2 = getService$2("permission-checker").create({
|
429
406
|
userAbility: params.state.userAbility,
|
430
|
-
model:
|
407
|
+
model: options.attribute.target
|
431
408
|
});
|
432
409
|
const response = await serviceUtils.buildRelationReponse(
|
433
|
-
|
434
|
-
|
410
|
+
currentValue,
|
411
|
+
options.attribute
|
435
412
|
);
|
436
413
|
const sanitizedResults = await Promise.all(
|
437
414
|
response.results.map((media) => permissionChecker2.sanitizeOutput(media))
|
438
415
|
);
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
416
|
+
utils.set(options.key, {
|
417
|
+
results: sanitizedResults,
|
418
|
+
meta: response.meta
|
419
|
+
});
|
420
|
+
}
|
421
|
+
if (options.attribute.type === "media") {
|
422
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
423
|
+
userAbility: params.state.userAbility,
|
424
|
+
model: "plugin::upload.file"
|
425
|
+
});
|
426
|
+
const response = await serviceUtils.buildMediaResponse(currentValue);
|
427
|
+
const sanitizedResults = await Promise.all(
|
428
|
+
response.results.map((media) => permissionChecker2.sanitizeOutput(media))
|
429
|
+
);
|
430
|
+
utils.set(options.key, {
|
431
|
+
results: sanitizedResults,
|
432
|
+
meta: response.meta
|
433
|
+
});
|
446
434
|
}
|
447
|
-
return currentDataWithRelations;
|
448
435
|
},
|
449
|
-
|
436
|
+
{
|
437
|
+
schema,
|
438
|
+
getModel: strapi2.getModel.bind(strapi2)
|
439
|
+
},
|
440
|
+
entry.data
|
450
441
|
);
|
451
|
-
return entryWithRelations;
|
452
442
|
};
|
453
443
|
const formattedResults = await Promise.all(
|
454
444
|
results.map(async (result) => {
|
455
445
|
return {
|
456
446
|
...result,
|
457
|
-
data: await
|
447
|
+
data: await populateEntry(result),
|
458
448
|
meta: {
|
459
449
|
unknownAttributes: serviceUtils.getSchemaAttributesDiff(
|
460
450
|
result.schema,
|
@@ -485,30 +475,44 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
485
475
|
// Clone to avoid mutating the original version data
|
486
476
|
structuredClone(version.data)
|
487
477
|
);
|
488
|
-
const
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
478
|
+
const schema = structuredClone(version.schema);
|
479
|
+
schema.attributes = fp.omit(FIELDS_TO_IGNORE, contentTypeSchemaAttributes);
|
480
|
+
const dataWithoutMissingRelations = await strapiUtils.traverseEntity(
|
481
|
+
async (options, utils) => {
|
482
|
+
if (!options.attribute) return;
|
483
|
+
if (options.attribute.type === "component") {
|
484
|
+
utils.remove("id");
|
485
|
+
if (options.attribute.repeatable && options.value === null) {
|
486
|
+
utils.set(options.key, []);
|
487
|
+
}
|
488
|
+
}
|
489
|
+
if (options.attribute.type === "dynamiczone") {
|
490
|
+
if (options.value === null) {
|
491
|
+
utils.set(options.key, []);
|
492
|
+
}
|
498
493
|
}
|
499
|
-
if (attribute.type === "relation" && // TODO: handle polymorphic relations
|
500
|
-
attribute.relation !== "morphToOne" && attribute.relation !== "morphToMany") {
|
501
|
-
|
502
|
-
|
494
|
+
if (options.attribute.type === "relation" && // TODO: handle polymorphic relations
|
495
|
+
options.attribute.relation !== "morphToOne" && options.attribute.relation !== "morphToMany") {
|
496
|
+
if (!options.value) return;
|
497
|
+
const data2 = await serviceUtils.getRelationRestoreValue(
|
498
|
+
options.value,
|
499
|
+
options.attribute
|
500
|
+
);
|
501
|
+
utils.set(options.key, data2);
|
503
502
|
}
|
504
|
-
if (attribute.type === "media") {
|
505
|
-
|
506
|
-
|
503
|
+
if (options.attribute.type === "media") {
|
504
|
+
if (!options.value) return;
|
505
|
+
const data2 = await serviceUtils.getMediaRestoreValue(
|
506
|
+
options.value
|
507
|
+
);
|
508
|
+
utils.set(options.key, data2);
|
507
509
|
}
|
508
|
-
return previousRelationAttributes;
|
509
510
|
},
|
510
|
-
|
511
|
-
|
511
|
+
{
|
512
|
+
schema,
|
513
|
+
getModel: strapi2.getModel.bind(strapi2)
|
514
|
+
},
|
515
|
+
dataWithoutAddedAttributes
|
512
516
|
);
|
513
517
|
const data = fp.omit(["id", ...Object.keys(schemaDiff.removed)], dataWithoutMissingRelations);
|
514
518
|
const restoredDocument = await strapi2.documents(version.contentType).update({
|
@@ -737,7 +741,6 @@ const getFeature$1 = () => {
|
|
737
741
|
};
|
738
742
|
};
|
739
743
|
const history = getFeature$1();
|
740
|
-
const FEATURE_ID = "preview";
|
741
744
|
const info = { pluginName: "content-manager", type: "admin" };
|
742
745
|
const previewRouter = {
|
743
746
|
type: "admin",
|
@@ -915,9 +918,6 @@ const services$1 = {
|
|
915
918
|
"preview-config": createPreviewConfigService
|
916
919
|
};
|
917
920
|
const getFeature = () => {
|
918
|
-
if (!strapi.features.future.isEnabled(FEATURE_ID)) {
|
919
|
-
return {};
|
920
|
-
}
|
921
921
|
return {
|
922
922
|
register() {
|
923
923
|
const config = getService(strapi, "preview-config");
|
@@ -3933,6 +3933,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
|
|
3933
3933
|
if (initialPopulate) {
|
3934
3934
|
return initialPopulate;
|
3935
3935
|
}
|
3936
|
+
if (attributeName === "localizations") {
|
3937
|
+
const validationPopulate = getPopulateForValidation(model.uid);
|
3938
|
+
return {
|
3939
|
+
populate: validationPopulate.populate
|
3940
|
+
};
|
3941
|
+
}
|
3936
3942
|
if (!isVisibleAttribute$1(model, attributeName)) {
|
3937
3943
|
return true;
|
3938
3944
|
}
|
@@ -3992,6 +3998,9 @@ const getDeepPopulate = (uid2, {
|
|
3992
3998
|
return {};
|
3993
3999
|
}
|
3994
4000
|
const model = strapi.getModel(uid2);
|
4001
|
+
if (!model) {
|
4002
|
+
return {};
|
4003
|
+
}
|
3995
4004
|
return Object.keys(model.attributes).reduce(
|
3996
4005
|
(populateAcc, attributeName) => fp.merge(
|
3997
4006
|
populateAcc,
|
@@ -4011,40 +4020,46 @@ const getDeepPopulate = (uid2, {
|
|
4011
4020
|
{}
|
4012
4021
|
);
|
4013
4022
|
};
|
4014
|
-
const
|
4015
|
-
|
4016
|
-
|
4017
|
-
countOne = false,
|
4018
|
-
maxLevel = Infinity
|
4019
|
-
} = {}, level = 1) => {
|
4020
|
-
if (level > maxLevel) {
|
4023
|
+
const getPopulateForValidation = (uid2) => {
|
4024
|
+
const model = strapi.getModel(uid2);
|
4025
|
+
if (!model) {
|
4021
4026
|
return {};
|
4022
4027
|
}
|
4023
|
-
const model = strapi.getModel(uid2);
|
4024
4028
|
return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
|
4025
|
-
if (
|
4029
|
+
if (isScalarAttribute(attribute)) {
|
4030
|
+
if (getDoesAttributeRequireValidation(attribute)) {
|
4031
|
+
populateAcc.fields = populateAcc.fields || [];
|
4032
|
+
populateAcc.fields.push(attributeName);
|
4033
|
+
}
|
4026
4034
|
return populateAcc;
|
4027
4035
|
}
|
4028
|
-
if (
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4036
|
+
if (isComponent(attribute)) {
|
4037
|
+
const component = attribute.component;
|
4038
|
+
const componentResult = getPopulateForValidation(component);
|
4039
|
+
if (Object.keys(componentResult).length > 0) {
|
4040
|
+
populateAcc.populate = populateAcc.populate || {};
|
4041
|
+
populateAcc.populate[attributeName] = componentResult;
|
4042
|
+
}
|
4043
|
+
return populateAcc;
|
4032
4044
|
}
|
4033
|
-
|
4034
|
-
|
4035
|
-
|
4036
|
-
|
4037
|
-
|
4038
|
-
|
4039
|
-
|
4040
|
-
|
4041
|
-
|
4042
|
-
countOne,
|
4043
|
-
maxLevel
|
4045
|
+
if (isDynamicZone(attribute)) {
|
4046
|
+
const components2 = attribute.components;
|
4047
|
+
const componentsResult = (components2 || []).reduce(
|
4048
|
+
(acc, componentUID) => {
|
4049
|
+
const componentResult = getPopulateForValidation(componentUID);
|
4050
|
+
if (Object.keys(componentResult).length > 0) {
|
4051
|
+
acc[componentUID] = componentResult;
|
4052
|
+
}
|
4053
|
+
return acc;
|
4044
4054
|
},
|
4045
|
-
|
4046
|
-
)
|
4047
|
-
|
4055
|
+
{}
|
4056
|
+
);
|
4057
|
+
if (Object.keys(componentsResult).length > 0) {
|
4058
|
+
populateAcc.populate = populateAcc.populate || {};
|
4059
|
+
populateAcc.populate[attributeName] = { on: componentsResult };
|
4060
|
+
}
|
4061
|
+
}
|
4062
|
+
return populateAcc;
|
4048
4063
|
}, {});
|
4049
4064
|
};
|
4050
4065
|
const getDeepPopulateDraftCount = (uid2) => {
|
@@ -4286,7 +4301,6 @@ const AVAILABLE_LOCALES_FIELDS = [
|
|
4286
4301
|
"locale",
|
4287
4302
|
"updatedAt",
|
4288
4303
|
"createdAt",
|
4289
|
-
"status",
|
4290
4304
|
"publishedAt",
|
4291
4305
|
"documentId"
|
4292
4306
|
];
|
@@ -4307,36 +4321,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4307
4321
|
/**
|
4308
4322
|
* Returns available locales of a document for the current status
|
4309
4323
|
*/
|
4310
|
-
async getAvailableLocales(uid2, version, allVersions
|
4324
|
+
async getAvailableLocales(uid2, version, allVersions) {
|
4311
4325
|
const versionsByLocale = fp.groupBy("locale", allVersions);
|
4312
4326
|
if (version.locale) {
|
4313
4327
|
delete versionsByLocale[version.locale];
|
4314
4328
|
}
|
4315
4329
|
const model = strapi2.getModel(uid2);
|
4316
|
-
const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
|
4317
|
-
const traversalFunction = async (localeVersion) => strapiUtils.traverseEntity(
|
4318
|
-
({ key }, { remove }) => {
|
4319
|
-
if (keysToKeep.includes(key)) {
|
4320
|
-
return;
|
4321
|
-
}
|
4322
|
-
remove(key);
|
4323
|
-
},
|
4324
|
-
{ schema: model, getModel: strapi2.getModel.bind(strapi2) },
|
4325
|
-
// @ts-expect-error fix types DocumentVersion incompatible with Data
|
4326
|
-
localeVersion
|
4327
|
-
);
|
4328
4330
|
const mappingResult = await strapiUtils.async.map(
|
4329
4331
|
Object.values(versionsByLocale),
|
4330
4332
|
async (localeVersions) => {
|
4331
|
-
const mappedLocaleVersions = await strapiUtils.async.map(
|
4332
|
-
localeVersions,
|
4333
|
-
traversalFunction
|
4334
|
-
);
|
4335
4333
|
if (!strapiUtils.contentTypes.hasDraftAndPublish(model)) {
|
4336
|
-
return
|
4334
|
+
return localeVersions[0];
|
4337
4335
|
}
|
4338
|
-
const draftVersion =
|
4339
|
-
const otherVersions =
|
4336
|
+
const draftVersion = localeVersions.find((v) => v.publishedAt === null);
|
4337
|
+
const otherVersions = localeVersions.filter((v) => v.id !== draftVersion?.id);
|
4340
4338
|
if (!draftVersion) {
|
4341
4339
|
return;
|
4342
4340
|
}
|
@@ -4370,15 +4368,17 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4370
4368
|
async getManyAvailableStatus(uid2, documents) {
|
4371
4369
|
if (!documents.length) return [];
|
4372
4370
|
const status = documents[0].publishedAt !== null ? "published" : "draft";
|
4373
|
-
const
|
4374
|
-
const
|
4375
|
-
|
4376
|
-
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4371
|
+
const locales = documents.map((d) => d.locale).filter(Boolean);
|
4372
|
+
const where = {
|
4373
|
+
documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
|
4374
|
+
publishedAt: { $null: status === "published" }
|
4375
|
+
};
|
4376
|
+
if (locales.length) {
|
4377
|
+
where.locale = { $in: locales };
|
4378
|
+
}
|
4379
|
+
return strapi2.query(uid2).findMany({
|
4380
|
+
where,
|
4381
|
+
select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
|
4382
4382
|
});
|
4383
4383
|
},
|
4384
4384
|
getStatus(version, otherDocumentStatuses) {
|
@@ -4404,11 +4404,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4404
4404
|
// We could refactor this so the locales are only loaded when they're
|
4405
4405
|
// needed. e.g. in the bulk locale action modal.
|
4406
4406
|
async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
|
4407
|
-
const populate =
|
4408
|
-
const
|
4409
|
-
where: { documentId: version.documentId },
|
4407
|
+
const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
|
4408
|
+
const params = {
|
4410
4409
|
populate: {
|
4411
|
-
// Populate only fields that require validation for bulk locale actions
|
4412
4410
|
...populate,
|
4413
4411
|
// NOTE: creator fields are selected in this way to avoid exposing sensitive data
|
4414
4412
|
createdBy: {
|
@@ -4417,9 +4415,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4417
4415
|
updatedBy: {
|
4418
4416
|
select: ["id", "firstname", "lastname", "email"]
|
4419
4417
|
}
|
4418
|
+
},
|
4419
|
+
fields: fp.uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
|
4420
|
+
filters: {
|
4421
|
+
documentId: version.documentId
|
4420
4422
|
}
|
4421
|
-
}
|
4422
|
-
const
|
4423
|
+
};
|
4424
|
+
const dbParams = strapi2.get("query-params").transform(uid2, params);
|
4425
|
+
const versions = await strapi2.db.query(uid2).findMany(dbParams);
|
4426
|
+
const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
|
4423
4427
|
const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
|
4424
4428
|
return {
|
4425
4429
|
availableLocales: availableLocalesResult,
|
@@ -4446,6 +4450,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4446
4450
|
opts.availableStatus = false;
|
4447
4451
|
}
|
4448
4452
|
const meta = await this.getMetadata(uid2, document, opts);
|
4453
|
+
if (document.localizations) {
|
4454
|
+
const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
|
4455
|
+
document.localizations = document.localizations.map((d) => {
|
4456
|
+
const status = otherStatus.find((s) => s.documentId === d.documentId);
|
4457
|
+
return {
|
4458
|
+
...d,
|
4459
|
+
status: this.getStatus(d, status ? [status] : [])
|
4460
|
+
};
|
4461
|
+
});
|
4462
|
+
}
|
4449
4463
|
return {
|
4450
4464
|
data: {
|
4451
4465
|
...document,
|