@strapi/content-manager 5.7.0 → 5.8.1
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-CJPoOvy3.js → ComponentConfigurationPage-DquE3cSt.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-CJPoOvy3.js.map → ComponentConfigurationPage-DquE3cSt.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-CcRDqD0e.mjs → ComponentConfigurationPage-xgUutqCq.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-CcRDqD0e.mjs.map → ComponentConfigurationPage-xgUutqCq.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-C1ddZ_zf.mjs → EditConfigurationPage-BxxS_VjE.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-C1ddZ_zf.mjs.map → EditConfigurationPage-BxxS_VjE.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CF3lxOy2.js → EditConfigurationPage-DBZcYu4y.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CF3lxOy2.js.map → EditConfigurationPage-DBZcYu4y.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-BPFcUbqi.mjs → EditViewPage-CxbLxtSZ.mjs} +3 -3
- package/dist/_chunks/{EditViewPage-BPFcUbqi.mjs.map → EditViewPage-CxbLxtSZ.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CDyTC6aU.js → EditViewPage-eVQAzqrX.js} +3 -3
- package/dist/_chunks/{EditViewPage-CDyTC6aU.js.map → EditViewPage-eVQAzqrX.js.map} +1 -1
- package/dist/_chunks/{Field-DuxAW9q2.js → Field-B1V9AyU1.js} +22 -14
- package/dist/_chunks/{Field-DuxAW9q2.js.map → Field-B1V9AyU1.js.map} +1 -1
- package/dist/_chunks/{Field-fBnTwgU4.mjs → Field-CZwQcrmw.mjs} +22 -14
- package/dist/_chunks/{Field-fBnTwgU4.mjs.map → Field-CZwQcrmw.mjs.map} +1 -1
- package/dist/_chunks/{Form-BGl7PhlZ.mjs → Form-3kEYdc-J.mjs} +2 -2
- package/dist/_chunks/{Form-BGl7PhlZ.mjs.map → Form-3kEYdc-J.mjs.map} +1 -1
- package/dist/_chunks/{Form-DSGh_zkz.js → Form-DDb5-H01.js} +2 -2
- package/dist/_chunks/{Form-DSGh_zkz.js.map → Form-DDb5-H01.js.map} +1 -1
- package/dist/_chunks/{History-DrDJv698.js → History-COpTRR4s.js} +32 -8
- package/dist/_chunks/History-COpTRR4s.js.map +1 -0
- package/dist/_chunks/{History-DTYB9CSB.mjs → History-DXZrV891.mjs} +32 -8
- package/dist/_chunks/History-DXZrV891.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-qWx8r4D_.mjs → ListConfigurationPage-B1BlI0vS.mjs} +2 -2
- package/dist/_chunks/{ListConfigurationPage-qWx8r4D_.mjs.map → ListConfigurationPage-B1BlI0vS.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-zurIlUZ7.js → ListConfigurationPage-D5zn8EA8.js} +2 -2
- package/dist/_chunks/{ListConfigurationPage-zurIlUZ7.js.map → ListConfigurationPage-D5zn8EA8.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-GKpL5p8A.mjs → ListViewPage-CfHJAt9S.mjs} +3 -3
- package/dist/_chunks/{ListViewPage-GKpL5p8A.mjs.map → ListViewPage-CfHJAt9S.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-DTM2uO_S.js → ListViewPage-OqGWxoXp.js} +3 -3
- package/dist/_chunks/{ListViewPage-DTM2uO_S.js.map → ListViewPage-OqGWxoXp.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-B5Vc5Cal.mjs → NoContentTypePage-B1vde0d2.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-B5Vc5Cal.mjs.map → NoContentTypePage-B1vde0d2.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BuZlNroO.js → NoContentTypePage-BwuxzVhz.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BuZlNroO.js.map → NoContentTypePage-BwuxzVhz.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BAZlWgJ4.mjs → NoPermissionsPage-BZx6YZ0-.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BAZlWgJ4.mjs.map → NoPermissionsPage-BZx6YZ0-.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DLzkS4Hy.js → NoPermissionsPage-CM4q9eyp.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DLzkS4Hy.js.map → NoPermissionsPage-CM4q9eyp.js.map} +1 -1
- package/dist/_chunks/{Preview-VOJ8RuQp.js → Preview-DZWvwEHg.js} +3 -3
- package/dist/_chunks/{Preview-VOJ8RuQp.js.map → Preview-DZWvwEHg.js.map} +1 -1
- package/dist/_chunks/{Preview-Zzjg2_K_.mjs → Preview-DeD_aLg6.mjs} +3 -3
- package/dist/_chunks/{Preview-Zzjg2_K_.mjs.map → Preview-DeD_aLg6.mjs.map} +1 -1
- package/dist/_chunks/{Relations-Dsj0boFJ.js → Relations-DXVAOSqj.js} +3 -3
- package/dist/_chunks/{Relations-Dsj0boFJ.js.map → Relations-DXVAOSqj.js.map} +1 -1
- package/dist/_chunks/{Relations-BVdRfDkW.mjs → Relations-i1BqMPqp.mjs} +3 -3
- package/dist/_chunks/{Relations-BVdRfDkW.mjs.map → Relations-i1BqMPqp.mjs.map} +1 -1
- package/dist/_chunks/{index-Ct-GZ0iV.js → index-D9vDl-4J.js} +11 -11
- package/dist/_chunks/{index-Ct-GZ0iV.js.map → index-D9vDl-4J.js.map} +1 -1
- package/dist/_chunks/{index-Bu_-B7ZA.mjs → index-Rej95OkL.mjs} +11 -11
- package/dist/_chunks/{index-Bu_-B7ZA.mjs.map → index-Rej95OkL.mjs.map} +1 -1
- package/dist/_chunks/{layout-CDBEgRsM.js → layout-B4X3h5C4.js} +3 -3
- package/dist/_chunks/{layout-CDBEgRsM.js.map → layout-B4X3h5C4.js.map} +1 -1
- package/dist/_chunks/{layout-COzAvgJh.mjs → layout-CKw8rE38.mjs} +3 -3
- package/dist/_chunks/{layout-COzAvgJh.mjs.map → layout-CKw8rE38.mjs.map} +1 -1
- package/dist/_chunks/{relations-BjiF1Aad.js → relations-CvZ0Uu8l.js} +2 -2
- package/dist/_chunks/{relations-BjiF1Aad.js.map → relations-CvZ0Uu8l.js.map} +1 -1
- package/dist/_chunks/{relations-BtmMFBpM.mjs → relations-GpHbwwdj.mjs} +2 -2
- package/dist/_chunks/{relations-BtmMFBpM.mjs.map → relations-GpHbwwdj.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- 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/server/index.js +79 -75
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +80 -76
- package/dist/server/index.mjs.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/package.json +5 -5
- package/dist/_chunks/History-DTYB9CSB.mjs.map +0 -1
- package/dist/_chunks/History-DrDJv698.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, pagination } from "@strapi/utils";
|
1
|
+
import strapiUtils, { validateYupSchema, errors, async, contentTypes as contentTypes$1, traverseEntity, 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";
|
@@ -150,19 +150,16 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
150
150
|
});
|
151
151
|
})
|
152
152
|
);
|
153
|
-
return existingAndMissingRelations.filter(
|
154
|
-
(relation) => relation !== null
|
155
|
-
);
|
153
|
+
return existingAndMissingRelations.filter((relation) => relation !== null);
|
156
154
|
}
|
157
155
|
return strapi2.documents(attribute.target).findOne({
|
158
156
|
documentId: versionRelationData.documentId,
|
159
157
|
locale: versionRelationData.locale || void 0
|
160
158
|
});
|
161
159
|
};
|
162
|
-
const getMediaRestoreValue = async (versionRelationData
|
163
|
-
if (
|
160
|
+
const getMediaRestoreValue = async (versionRelationData) => {
|
161
|
+
if (Array.isArray(versionRelationData)) {
|
164
162
|
const existingAndMissingMedias = await Promise.all(
|
165
|
-
// @ts-expect-error Fix the type definitions so this isn't any
|
166
163
|
versionRelationData.map((media) => {
|
167
164
|
return strapi2.db.query("plugin::upload.file").findOne({ where: { id: media.id } });
|
168
165
|
})
|
@@ -331,8 +328,8 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
331
328
|
});
|
332
329
|
},
|
333
330
|
async findVersionsPage(params) {
|
334
|
-
const
|
335
|
-
const isLocalizedContentType = serviceUtils.isLocalizedContentType(
|
331
|
+
const schema = strapi2.getModel(params.query.contentType);
|
332
|
+
const isLocalizedContentType = serviceUtils.isLocalizedContentType(schema);
|
336
333
|
const defaultLocale = await serviceUtils.getDefaultLocale();
|
337
334
|
let locale = null;
|
338
335
|
if (isLocalizedContentType) {
|
@@ -353,32 +350,20 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
353
350
|
}),
|
354
351
|
serviceUtils.getLocaleDictionary()
|
355
352
|
]);
|
356
|
-
const
|
357
|
-
|
358
|
-
async (
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
model: "plugin::upload.file"
|
365
|
-
});
|
366
|
-
const response = await serviceUtils.buildMediaResponse(attributeValues);
|
367
|
-
const sanitizedResults = await Promise.all(
|
368
|
-
response.results.map((media) => permissionChecker2.sanitizeOutput(media))
|
369
|
-
);
|
370
|
-
return {
|
371
|
-
...await currentDataWithRelations,
|
372
|
-
[attributeKey]: {
|
373
|
-
results: sanitizedResults,
|
374
|
-
meta: response.meta
|
375
|
-
}
|
376
|
-
};
|
353
|
+
const populateEntry = async (entry) => {
|
354
|
+
return traverseEntity(
|
355
|
+
async (options, utils) => {
|
356
|
+
if (!options.attribute) return;
|
357
|
+
if (!options.value) return;
|
358
|
+
const currentValue = Array.isArray(options.value) ? options.value : [options.value];
|
359
|
+
if (options.attribute.type === "component") {
|
360
|
+
utils.remove("id");
|
377
361
|
}
|
378
|
-
if (
|
379
|
-
|
362
|
+
if (options.attribute.type === "relation" && // TODO: handle polymorphic relations
|
363
|
+
options.attribute.relation !== "morphToOne" && options.attribute.relation !== "morphToMany") {
|
364
|
+
if (options.attribute.target === "admin::user") {
|
380
365
|
const adminUsers = await Promise.all(
|
381
|
-
|
366
|
+
currentValue.map((userToPopulate) => {
|
382
367
|
if (userToPopulate == null) {
|
383
368
|
return null;
|
384
369
|
}
|
@@ -390,46 +375,51 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
390
375
|
});
|
391
376
|
})
|
392
377
|
);
|
393
|
-
|
394
|
-
...await currentDataWithRelations,
|
395
|
-
/**
|
396
|
-
* Ideally we would return the same "{results: [], meta: {}}" shape, however,
|
397
|
-
* when sanitizing the data as a whole in the controller before sending to the client,
|
398
|
-
* the data for admin relation user is completely sanitized if we return an object here as opposed to an array.
|
399
|
-
*/
|
400
|
-
[attributeKey]: adminUsers
|
401
|
-
};
|
378
|
+
utils.set(options.key, adminUsers);
|
402
379
|
}
|
403
380
|
const permissionChecker2 = getService$2("permission-checker").create({
|
404
381
|
userAbility: params.state.userAbility,
|
405
|
-
model:
|
382
|
+
model: options.attribute.target
|
406
383
|
});
|
407
384
|
const response = await serviceUtils.buildRelationReponse(
|
408
|
-
|
409
|
-
|
385
|
+
currentValue,
|
386
|
+
options.attribute
|
410
387
|
);
|
411
388
|
const sanitizedResults = await Promise.all(
|
412
389
|
response.results.map((media) => permissionChecker2.sanitizeOutput(media))
|
413
390
|
);
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
391
|
+
utils.set(options.key, {
|
392
|
+
results: sanitizedResults,
|
393
|
+
meta: response.meta
|
394
|
+
});
|
395
|
+
}
|
396
|
+
if (options.attribute.type === "media") {
|
397
|
+
const permissionChecker2 = getService$2("permission-checker").create({
|
398
|
+
userAbility: params.state.userAbility,
|
399
|
+
model: "plugin::upload.file"
|
400
|
+
});
|
401
|
+
const response = await serviceUtils.buildMediaResponse(currentValue);
|
402
|
+
const sanitizedResults = await Promise.all(
|
403
|
+
response.results.map((media) => permissionChecker2.sanitizeOutput(media))
|
404
|
+
);
|
405
|
+
utils.set(options.key, {
|
406
|
+
results: sanitizedResults,
|
407
|
+
meta: response.meta
|
408
|
+
});
|
421
409
|
}
|
422
|
-
return currentDataWithRelations;
|
423
410
|
},
|
424
|
-
|
411
|
+
{
|
412
|
+
schema,
|
413
|
+
getModel: strapi2.getModel.bind(strapi2)
|
414
|
+
},
|
415
|
+
entry.data
|
425
416
|
);
|
426
|
-
return entryWithRelations;
|
427
417
|
};
|
428
418
|
const formattedResults = await Promise.all(
|
429
419
|
results.map(async (result) => {
|
430
420
|
return {
|
431
421
|
...result,
|
432
|
-
data: await
|
422
|
+
data: await populateEntry(result),
|
433
423
|
meta: {
|
434
424
|
unknownAttributes: serviceUtils.getSchemaAttributesDiff(
|
435
425
|
result.schema,
|
@@ -460,30 +450,44 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
460
450
|
// Clone to avoid mutating the original version data
|
461
451
|
structuredClone(version.data)
|
462
452
|
);
|
463
|
-
const
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
453
|
+
const schema = structuredClone(version.schema);
|
454
|
+
schema.attributes = omit(FIELDS_TO_IGNORE, contentTypeSchemaAttributes);
|
455
|
+
const dataWithoutMissingRelations = await traverseEntity(
|
456
|
+
async (options, utils) => {
|
457
|
+
if (!options.attribute) return;
|
458
|
+
if (options.attribute.type === "component") {
|
459
|
+
utils.remove("id");
|
460
|
+
if (options.attribute.repeatable && options.value === null) {
|
461
|
+
utils.set(options.key, []);
|
462
|
+
}
|
463
|
+
}
|
464
|
+
if (options.attribute.type === "dynamiczone") {
|
465
|
+
if (options.value === null) {
|
466
|
+
utils.set(options.key, []);
|
467
|
+
}
|
473
468
|
}
|
474
|
-
if (attribute.type === "relation" && // TODO: handle polymorphic relations
|
475
|
-
attribute.relation !== "morphToOne" && attribute.relation !== "morphToMany") {
|
476
|
-
|
477
|
-
|
469
|
+
if (options.attribute.type === "relation" && // TODO: handle polymorphic relations
|
470
|
+
options.attribute.relation !== "morphToOne" && options.attribute.relation !== "morphToMany") {
|
471
|
+
if (!options.value) return;
|
472
|
+
const data2 = await serviceUtils.getRelationRestoreValue(
|
473
|
+
options.value,
|
474
|
+
options.attribute
|
475
|
+
);
|
476
|
+
utils.set(options.key, data2);
|
478
477
|
}
|
479
|
-
if (attribute.type === "media") {
|
480
|
-
|
481
|
-
|
478
|
+
if (options.attribute.type === "media") {
|
479
|
+
if (!options.value) return;
|
480
|
+
const data2 = await serviceUtils.getMediaRestoreValue(
|
481
|
+
options.value
|
482
|
+
);
|
483
|
+
utils.set(options.key, data2);
|
482
484
|
}
|
483
|
-
return previousRelationAttributes;
|
484
485
|
},
|
485
|
-
|
486
|
-
|
486
|
+
{
|
487
|
+
schema,
|
488
|
+
getModel: strapi2.getModel.bind(strapi2)
|
489
|
+
},
|
490
|
+
dataWithoutAddedAttributes
|
487
491
|
);
|
488
492
|
const data = omit(["id", ...Object.keys(schemaDiff.removed)], dataWithoutMissingRelations);
|
489
493
|
const restoredDocument = await strapi2.documents(version.contentType).update({
|