@strapi/content-releases 4.22.1 → 4.23.0
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/{App-OP70yd5M.js → App-HjWtUYmc.js} +39 -24
- package/dist/_chunks/App-HjWtUYmc.js.map +1 -0
- package/dist/_chunks/{App-x6Tjj3HN.mjs → App-gu1aiP6i.mjs} +40 -25
- package/dist/_chunks/App-gu1aiP6i.mjs.map +1 -0
- package/dist/_chunks/{en-3SGjiVyR.js → en-HrREghh3.js} +2 -1
- package/dist/_chunks/en-HrREghh3.js.map +1 -0
- package/dist/_chunks/{en-bpHsnU0n.mjs → en-ltT1TlKQ.mjs} +2 -1
- package/dist/_chunks/en-ltT1TlKQ.mjs.map +1 -0
- package/dist/_chunks/{index-ydocdaZ0.js → index-ZNwxYN8H.js} +124 -13
- package/dist/_chunks/index-ZNwxYN8H.js.map +1 -0
- package/dist/_chunks/{index-1ejXLtzt.mjs → index-mvj9PSKd.mjs} +131 -20
- package/dist/_chunks/index-mvj9PSKd.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +69 -7
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +69 -7
- package/dist/server/index.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/_chunks/App-OP70yd5M.js.map +0 -1
- package/dist/_chunks/App-x6Tjj3HN.mjs.map +0 -1
- package/dist/_chunks/en-3SGjiVyR.js.map +0 -1
- package/dist/_chunks/en-bpHsnU0n.mjs.map +0 -1
- package/dist/_chunks/index-1ejXLtzt.mjs.map +0 -1
- package/dist/_chunks/index-ydocdaZ0.js.map +0 -1
package/dist/server/index.mjs
CHANGED
|
@@ -211,13 +211,16 @@ async function disableContentTypeLocalized({ oldContentTypes, contentTypes: cont
|
|
|
211
211
|
if (!oldContentTypes) {
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
+
const i18nPlugin = strapi.plugin("i18n");
|
|
215
|
+
if (!i18nPlugin) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
214
218
|
for (const uid in contentTypes2) {
|
|
215
219
|
if (!oldContentTypes[uid]) {
|
|
216
220
|
continue;
|
|
217
221
|
}
|
|
218
222
|
const oldContentType = oldContentTypes[uid];
|
|
219
223
|
const contentType = contentTypes2[uid];
|
|
220
|
-
const i18nPlugin = strapi.plugin("i18n");
|
|
221
224
|
const { isLocalizedContentType } = i18nPlugin.service("content-types");
|
|
222
225
|
if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {
|
|
223
226
|
await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
|
|
@@ -230,13 +233,16 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
|
|
|
230
233
|
if (!oldContentTypes) {
|
|
231
234
|
return;
|
|
232
235
|
}
|
|
236
|
+
const i18nPlugin = strapi.plugin("i18n");
|
|
237
|
+
if (!i18nPlugin) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
233
240
|
for (const uid in contentTypes2) {
|
|
234
241
|
if (!oldContentTypes[uid]) {
|
|
235
242
|
continue;
|
|
236
243
|
}
|
|
237
244
|
const oldContentType = oldContentTypes[uid];
|
|
238
245
|
const contentType = contentTypes2[uid];
|
|
239
|
-
const i18nPlugin = strapi.plugin("i18n");
|
|
240
246
|
const { isLocalizedContentType } = i18nPlugin.service("content-types");
|
|
241
247
|
const { getDefaultLocale } = i18nPlugin.service("locales");
|
|
242
248
|
if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {
|
|
@@ -655,12 +661,18 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
655
661
|
}
|
|
656
662
|
});
|
|
657
663
|
},
|
|
658
|
-
async findManyWithContentTypeEntryAttached(contentTypeUid,
|
|
664
|
+
async findManyWithContentTypeEntryAttached(contentTypeUid, entriesIds) {
|
|
665
|
+
let entries = entriesIds;
|
|
666
|
+
if (!Array.isArray(entriesIds)) {
|
|
667
|
+
entries = [entriesIds];
|
|
668
|
+
}
|
|
659
669
|
const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
|
|
660
670
|
where: {
|
|
661
671
|
actions: {
|
|
662
672
|
target_type: contentTypeUid,
|
|
663
|
-
target_id:
|
|
673
|
+
target_id: {
|
|
674
|
+
$in: entries
|
|
675
|
+
}
|
|
664
676
|
},
|
|
665
677
|
releasedAt: {
|
|
666
678
|
$null: true
|
|
@@ -671,18 +683,25 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
671
683
|
actions: {
|
|
672
684
|
where: {
|
|
673
685
|
target_type: contentTypeUid,
|
|
674
|
-
target_id:
|
|
686
|
+
target_id: {
|
|
687
|
+
$in: entries
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
populate: {
|
|
691
|
+
entry: {
|
|
692
|
+
select: ["id"]
|
|
693
|
+
}
|
|
675
694
|
}
|
|
676
695
|
}
|
|
677
696
|
}
|
|
678
697
|
});
|
|
679
698
|
return releases.map((release2) => {
|
|
680
699
|
if (release2.actions?.length) {
|
|
681
|
-
const
|
|
700
|
+
const actionsForEntry = release2.actions;
|
|
682
701
|
delete release2.actions;
|
|
683
702
|
return {
|
|
684
703
|
...release2,
|
|
685
|
-
|
|
704
|
+
actions: actionsForEntry
|
|
686
705
|
};
|
|
687
706
|
}
|
|
688
707
|
return release2;
|
|
@@ -1298,6 +1317,33 @@ const releaseController = {
|
|
|
1298
1317
|
};
|
|
1299
1318
|
ctx.body = { data };
|
|
1300
1319
|
},
|
|
1320
|
+
async mapEntriesToReleases(ctx) {
|
|
1321
|
+
const { contentTypeUid, entriesIds } = ctx.query;
|
|
1322
|
+
if (!contentTypeUid || !entriesIds) {
|
|
1323
|
+
throw new errors.ValidationError("Missing required query parameters");
|
|
1324
|
+
}
|
|
1325
|
+
const releaseService = getService("release", { strapi });
|
|
1326
|
+
const releasesWithActions = await releaseService.findManyWithContentTypeEntryAttached(
|
|
1327
|
+
contentTypeUid,
|
|
1328
|
+
entriesIds
|
|
1329
|
+
);
|
|
1330
|
+
const mappedEntriesInReleases = releasesWithActions.reduce(
|
|
1331
|
+
(acc, release2) => {
|
|
1332
|
+
release2.actions.forEach((action) => {
|
|
1333
|
+
if (!acc[action.entry.id]) {
|
|
1334
|
+
acc[action.entry.id] = [{ id: release2.id, name: release2.name }];
|
|
1335
|
+
} else {
|
|
1336
|
+
acc[action.entry.id].push({ id: release2.id, name: release2.name });
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
return acc;
|
|
1340
|
+
},
|
|
1341
|
+
{}
|
|
1342
|
+
);
|
|
1343
|
+
ctx.body = {
|
|
1344
|
+
data: mappedEntriesInReleases
|
|
1345
|
+
};
|
|
1346
|
+
},
|
|
1301
1347
|
async create(ctx) {
|
|
1302
1348
|
const user = ctx.state.user;
|
|
1303
1349
|
const releaseArgs = ctx.request.body;
|
|
@@ -1487,6 +1533,22 @@ const controllers = { release: releaseController, "release-action": releaseActio
|
|
|
1487
1533
|
const release = {
|
|
1488
1534
|
type: "admin",
|
|
1489
1535
|
routes: [
|
|
1536
|
+
{
|
|
1537
|
+
method: "GET",
|
|
1538
|
+
path: "/mapEntriesToReleases",
|
|
1539
|
+
handler: "release.mapEntriesToReleases",
|
|
1540
|
+
config: {
|
|
1541
|
+
policies: [
|
|
1542
|
+
"admin::isAuthenticatedAdmin",
|
|
1543
|
+
{
|
|
1544
|
+
name: "admin::hasPermissions",
|
|
1545
|
+
config: {
|
|
1546
|
+
actions: ["plugin::content-releases.read"]
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
]
|
|
1550
|
+
}
|
|
1551
|
+
},
|
|
1490
1552
|
{
|
|
1491
1553
|
method: "POST",
|
|
1492
1554
|
path: "/",
|