@strapi/content-releases 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4 → 0.0.0-experimental.f0d3b2d782e972f1dcb8acf0dce31d4090d1e420
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-D-lWdVb2.js → App-BKB1esYS.js} +42 -19
- package/dist/_chunks/App-BKB1esYS.js.map +1 -0
- package/dist/_chunks/{App-UQxgTJY5.mjs → App-Cne--1Z8.mjs} +43 -20
- package/dist/_chunks/App-Cne--1Z8.mjs.map +1 -0
- package/dist/_chunks/{ReleasesSettingsPage-CuUXvABk.mjs → ReleasesSettingsPage-C1WwGWIH.mjs} +4 -4
- package/dist/_chunks/ReleasesSettingsPage-C1WwGWIH.mjs.map +1 -0
- package/dist/_chunks/{ReleasesSettingsPage-xfAoY8N3.js → ReleasesSettingsPage-kuXIwpWp.js} +4 -4
- package/dist/_chunks/ReleasesSettingsPage-kuXIwpWp.js.map +1 -0
- package/dist/_chunks/{en-BCDLTJn3.js → en-CmYoEnA7.js} +2 -1
- package/dist/_chunks/en-CmYoEnA7.js.map +1 -0
- package/dist/_chunks/{en-CGXIF4vQ.mjs → en-D0yVZFqf.mjs} +2 -1
- package/dist/_chunks/en-D0yVZFqf.mjs.map +1 -0
- package/dist/_chunks/{index-jnv9zdcE.js → index-5Odi61vw.js} +286 -23
- package/dist/_chunks/index-5Odi61vw.js.map +1 -0
- package/dist/_chunks/{index-b3Ej95H7.mjs → index-Cy7qwpaU.mjs} +289 -26
- package/dist/_chunks/index-Cy7qwpaU.mjs.map +1 -0
- package/dist/_chunks/{schemas-z5zp-_Gd.js → schemas-BE1LxE9J.js} +2 -2
- package/dist/_chunks/schemas-BE1LxE9J.js.map +1 -0
- package/dist/_chunks/{schemas-63pFihNF.mjs → schemas-DdA2ic2U.mjs} +2 -2
- package/dist/_chunks/schemas-DdA2ic2U.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/ReleaseListCell.d.ts +28 -0
- package/dist/admin/src/services/release.d.ts +34 -32
- package/dist/server/index.js +112 -79
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +112 -79
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/index.d.ts +2 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/release-action.d.ts +1 -0
- package/dist/server/src/controllers/release-action.d.ts.map +1 -1
- package/dist/server/src/controllers/release.d.ts +1 -0
- package/dist/server/src/controllers/release.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/migrations/database/5.0.0-document-id-in-actions.d.ts.map +1 -1
- package/dist/server/src/routes/release-action.d.ts.map +1 -1
- package/dist/server/src/routes/release.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +2 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts +3 -1
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/dist/shared/contracts/release-actions.d.ts +3 -5
- package/dist/shared/contracts/release-actions.d.ts.map +1 -1
- package/dist/shared/contracts/releases.d.ts +3 -2
- package/dist/shared/contracts/releases.d.ts.map +1 -1
- package/package.json +16 -15
- package/dist/_chunks/App-D-lWdVb2.js.map +0 -1
- package/dist/_chunks/App-UQxgTJY5.mjs.map +0 -1
- package/dist/_chunks/ReleasesSettingsPage-CuUXvABk.mjs.map +0 -1
- package/dist/_chunks/ReleasesSettingsPage-xfAoY8N3.js.map +0 -1
- package/dist/_chunks/en-BCDLTJn3.js.map +0 -1
- package/dist/_chunks/en-CGXIF4vQ.mjs.map +0 -1
- package/dist/_chunks/index-b3Ej95H7.mjs.map +0 -1
- package/dist/_chunks/index-jnv9zdcE.js.map +0 -1
- package/dist/_chunks/schemas-63pFihNF.mjs.map +0 -1
- package/dist/_chunks/schemas-z5zp-_Gd.js.map +0 -1
- package/strapi-server.js +0 -3
package/dist/server/index.mjs
CHANGED
|
@@ -306,6 +306,10 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
|
|
|
306
306
|
const addEntryDocumentToReleaseActions = {
|
|
307
307
|
name: "content-releases::5.0.0-add-entry-document-id-to-release-actions",
|
|
308
308
|
async up(trx, db) {
|
|
309
|
+
const hasTable = await trx.schema.hasTable("strapi_release_actions");
|
|
310
|
+
if (!hasTable) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
309
313
|
const hasPolymorphicColumn = await trx.schema.hasColumn("strapi_release_actions", "target_id");
|
|
310
314
|
if (hasPolymorphicColumn) {
|
|
311
315
|
const hasEntryDocumentIdColumn = await trx.schema.hasColumn(
|
|
@@ -906,7 +910,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
906
910
|
return contentTypesData;
|
|
907
911
|
};
|
|
908
912
|
return {
|
|
909
|
-
async create(releaseId, action) {
|
|
913
|
+
async create(releaseId, action, { disableUpdateReleaseStatus = false } = {}) {
|
|
910
914
|
const { validateEntryData, validateUniqueEntry } = getService("release-validation", {
|
|
911
915
|
strapi: strapi2
|
|
912
916
|
});
|
|
@@ -914,6 +918,14 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
914
918
|
validateEntryData(action.contentType, action.entryDocumentId),
|
|
915
919
|
validateUniqueEntry(releaseId, action)
|
|
916
920
|
]);
|
|
921
|
+
const model = strapi2.contentType(action.contentType);
|
|
922
|
+
if (model.kind === "singleType") {
|
|
923
|
+
const document = await strapi2.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
924
|
+
if (!document) {
|
|
925
|
+
throw new errors.NotFoundError(`No entry found for contentType ${action.contentType}`);
|
|
926
|
+
}
|
|
927
|
+
action.entryDocumentId = document.documentId;
|
|
928
|
+
}
|
|
917
929
|
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
|
|
918
930
|
if (!release2) {
|
|
919
931
|
throw new errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
@@ -939,7 +951,9 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
939
951
|
},
|
|
940
952
|
populate: { release: { select: ["id"] } }
|
|
941
953
|
});
|
|
942
|
-
|
|
954
|
+
if (!disableUpdateReleaseStatus) {
|
|
955
|
+
getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
|
|
956
|
+
}
|
|
943
957
|
return releaseAction2;
|
|
944
958
|
},
|
|
945
959
|
async findPage(releaseId, query) {
|
|
@@ -1042,7 +1056,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1042
1056
|
`Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
|
|
1043
1057
|
);
|
|
1044
1058
|
}
|
|
1045
|
-
const actionStatus = update.type === "publish" ? getDraftEntryValidStatus(
|
|
1059
|
+
const actionStatus = update.type === "publish" ? await getDraftEntryValidStatus(
|
|
1046
1060
|
{
|
|
1047
1061
|
contentType: action.contentType,
|
|
1048
1062
|
documentId: action.entryDocumentId,
|
|
@@ -1112,11 +1126,11 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
|
1112
1126
|
throw new errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
1113
1127
|
}
|
|
1114
1128
|
const isEntryInRelease = release2.actions.some(
|
|
1115
|
-
(action) =>
|
|
1129
|
+
(action) => action.entryDocumentId === releaseActionArgs.entryDocumentId && action.contentType === releaseActionArgs.contentType && (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)
|
|
1116
1130
|
);
|
|
1117
1131
|
if (isEntryInRelease) {
|
|
1118
1132
|
throw new AlreadyOnReleaseError(
|
|
1119
|
-
`Entry with documentId ${releaseActionArgs.entryDocumentId}
|
|
1133
|
+
`Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
|
|
1120
1134
|
);
|
|
1121
1135
|
}
|
|
1122
1136
|
},
|
|
@@ -1283,7 +1297,15 @@ const releaseController = {
|
|
|
1283
1297
|
const releaseService = getService("release", { strapi });
|
|
1284
1298
|
const query = await permissionsManager.sanitizeQuery(ctx.query);
|
|
1285
1299
|
await validatefindByDocumentAttachedParams(query);
|
|
1286
|
-
const
|
|
1300
|
+
const model = strapi.getModel(query.contentType);
|
|
1301
|
+
if (model.kind && model.kind === "singleType") {
|
|
1302
|
+
const document = await strapi.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
1303
|
+
if (!document) {
|
|
1304
|
+
throw new errors.NotFoundError(`No entry found for contentType ${query.contentType}`);
|
|
1305
|
+
}
|
|
1306
|
+
query.entryDocumentId = document.documentId;
|
|
1307
|
+
}
|
|
1308
|
+
const { contentType, hasEntryAttached, entryDocumentId, locale } = query;
|
|
1287
1309
|
const isEntryAttached = typeof hasEntryAttached === "string" ? Boolean(JSON.parse(hasEntryAttached)) : false;
|
|
1288
1310
|
if (isEntryAttached) {
|
|
1289
1311
|
const releases = await releaseService.findMany({
|
|
@@ -1297,7 +1319,12 @@ const releaseController = {
|
|
|
1297
1319
|
},
|
|
1298
1320
|
populate: {
|
|
1299
1321
|
actions: {
|
|
1300
|
-
fields: ["type"]
|
|
1322
|
+
fields: ["type"],
|
|
1323
|
+
filters: {
|
|
1324
|
+
contentType,
|
|
1325
|
+
entryDocumentId: entryDocumentId ?? null,
|
|
1326
|
+
locale: locale ?? null
|
|
1327
|
+
}
|
|
1301
1328
|
}
|
|
1302
1329
|
}
|
|
1303
1330
|
});
|
|
@@ -1385,43 +1412,50 @@ const releaseController = {
|
|
|
1385
1412
|
};
|
|
1386
1413
|
ctx.body = { data };
|
|
1387
1414
|
},
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1415
|
+
async mapEntriesToReleases(ctx) {
|
|
1416
|
+
const { contentTypeUid, documentIds, locale } = ctx.query;
|
|
1417
|
+
if (!contentTypeUid || !documentIds) {
|
|
1418
|
+
throw new errors.ValidationError("Missing required query parameters");
|
|
1419
|
+
}
|
|
1420
|
+
const releaseService = getService("release", { strapi });
|
|
1421
|
+
const releasesWithActions = await releaseService.findMany({
|
|
1422
|
+
where: {
|
|
1423
|
+
releasedAt: null,
|
|
1424
|
+
actions: {
|
|
1425
|
+
contentType: contentTypeUid,
|
|
1426
|
+
entryDocumentId: {
|
|
1427
|
+
$in: documentIds
|
|
1428
|
+
},
|
|
1429
|
+
locale
|
|
1430
|
+
}
|
|
1431
|
+
},
|
|
1432
|
+
populate: {
|
|
1433
|
+
actions: true
|
|
1394
1434
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
ctx.body = {
|
|
1421
|
-
data: mappedEntriesInReleases,
|
|
1422
|
-
};
|
|
1423
|
-
},
|
|
1424
|
-
*/
|
|
1435
|
+
});
|
|
1436
|
+
const mappedEntriesInReleases = releasesWithActions.reduce(
|
|
1437
|
+
(acc, release2) => {
|
|
1438
|
+
release2.actions.forEach((action) => {
|
|
1439
|
+
if (action.contentType !== contentTypeUid) {
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
if (locale && action.locale !== locale) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
if (!acc[action.entryDocumentId]) {
|
|
1446
|
+
acc[action.entryDocumentId] = [{ id: release2.id, name: release2.name }];
|
|
1447
|
+
} else {
|
|
1448
|
+
acc[action.entryDocumentId].push({ id: release2.id, name: release2.name });
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
return acc;
|
|
1452
|
+
},
|
|
1453
|
+
{}
|
|
1454
|
+
);
|
|
1455
|
+
ctx.body = {
|
|
1456
|
+
data: mappedEntriesInReleases
|
|
1457
|
+
};
|
|
1458
|
+
},
|
|
1425
1459
|
async create(ctx) {
|
|
1426
1460
|
const user = ctx.state.user;
|
|
1427
1461
|
const releaseArgs = ctx.request.body;
|
|
@@ -1514,22 +1548,23 @@ const releaseActionController = {
|
|
|
1514
1548
|
data: releaseAction2
|
|
1515
1549
|
});
|
|
1516
1550
|
},
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
const
|
|
1520
|
-
const releaseActionsArgs = ctx.request.body as CreateManyReleaseActions.Request['body'];
|
|
1551
|
+
async createMany(ctx) {
|
|
1552
|
+
const releaseId = ctx.params.releaseId;
|
|
1553
|
+
const releaseActionsArgs = ctx.request.body;
|
|
1521
1554
|
await Promise.all(
|
|
1522
1555
|
releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
|
|
1523
1556
|
);
|
|
1524
|
-
const releaseActionService = getService(
|
|
1557
|
+
const releaseActionService = getService("release-action", { strapi });
|
|
1558
|
+
const releaseService = getService("release", { strapi });
|
|
1525
1559
|
const releaseActions = await strapi.db.transaction(async () => {
|
|
1526
|
-
const
|
|
1560
|
+
const releaseActions2 = await Promise.all(
|
|
1527
1561
|
releaseActionsArgs.map(async (releaseActionArgs) => {
|
|
1528
1562
|
try {
|
|
1529
|
-
const action = await releaseActionService.create(releaseId, releaseActionArgs
|
|
1563
|
+
const action = await releaseActionService.create(releaseId, releaseActionArgs, {
|
|
1564
|
+
disableUpdateReleaseStatus: true
|
|
1565
|
+
});
|
|
1530
1566
|
return action;
|
|
1531
1567
|
} catch (error) {
|
|
1532
|
-
// If the entry is already in the release, we don't want to throw an error, so we catch and ignore it
|
|
1533
1568
|
if (error instanceof AlreadyOnReleaseError) {
|
|
1534
1569
|
return null;
|
|
1535
1570
|
}
|
|
@@ -1537,18 +1572,20 @@ const releaseActionController = {
|
|
|
1537
1572
|
}
|
|
1538
1573
|
})
|
|
1539
1574
|
);
|
|
1540
|
-
return
|
|
1575
|
+
return releaseActions2;
|
|
1541
1576
|
});
|
|
1542
1577
|
const newReleaseActions = releaseActions.filter((action) => action !== null);
|
|
1578
|
+
if (newReleaseActions.length > 0) {
|
|
1579
|
+
releaseService.updateReleaseStatus(releaseId);
|
|
1580
|
+
}
|
|
1543
1581
|
ctx.created({
|
|
1544
1582
|
data: newReleaseActions,
|
|
1545
1583
|
meta: {
|
|
1546
1584
|
entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
|
|
1547
|
-
totalEntries: releaseActions.length
|
|
1548
|
-
}
|
|
1585
|
+
totalEntries: releaseActions.length
|
|
1586
|
+
}
|
|
1549
1587
|
});
|
|
1550
1588
|
},
|
|
1551
|
-
*/
|
|
1552
1589
|
async findMany(ctx) {
|
|
1553
1590
|
const releaseId = ctx.params.releaseId;
|
|
1554
1591
|
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
@@ -1647,24 +1684,22 @@ const controllers = {
|
|
|
1647
1684
|
const release = {
|
|
1648
1685
|
type: "admin",
|
|
1649
1686
|
routes: [
|
|
1650
|
-
/*
|
|
1651
1687
|
{
|
|
1652
|
-
method:
|
|
1653
|
-
path:
|
|
1654
|
-
handler:
|
|
1688
|
+
method: "GET",
|
|
1689
|
+
path: "/mapEntriesToReleases",
|
|
1690
|
+
handler: "release.mapEntriesToReleases",
|
|
1655
1691
|
config: {
|
|
1656
1692
|
policies: [
|
|
1657
|
-
|
|
1693
|
+
"admin::isAuthenticatedAdmin",
|
|
1658
1694
|
{
|
|
1659
|
-
name:
|
|
1695
|
+
name: "admin::hasPermissions",
|
|
1660
1696
|
config: {
|
|
1661
|
-
actions: [
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
]
|
|
1665
|
-
}
|
|
1697
|
+
actions: ["plugin::content-releases.read"]
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
]
|
|
1701
|
+
}
|
|
1666
1702
|
},
|
|
1667
|
-
*/
|
|
1668
1703
|
{
|
|
1669
1704
|
method: "GET",
|
|
1670
1705
|
path: "/getByDocumentAttached",
|
|
@@ -1798,24 +1833,22 @@ const releaseAction = {
|
|
|
1798
1833
|
]
|
|
1799
1834
|
}
|
|
1800
1835
|
},
|
|
1801
|
-
/*
|
|
1802
1836
|
{
|
|
1803
|
-
method:
|
|
1804
|
-
path:
|
|
1805
|
-
handler:
|
|
1837
|
+
method: "POST",
|
|
1838
|
+
path: "/:releaseId/actions/bulk",
|
|
1839
|
+
handler: "release-action.createMany",
|
|
1806
1840
|
config: {
|
|
1807
1841
|
policies: [
|
|
1808
|
-
|
|
1842
|
+
"admin::isAuthenticatedAdmin",
|
|
1809
1843
|
{
|
|
1810
|
-
name:
|
|
1844
|
+
name: "admin::hasPermissions",
|
|
1811
1845
|
config: {
|
|
1812
|
-
actions: [
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
]
|
|
1816
|
-
}
|
|
1846
|
+
actions: ["plugin::content-releases.create-action"]
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
]
|
|
1850
|
+
}
|
|
1817
1851
|
},
|
|
1818
|
-
*/
|
|
1819
1852
|
{
|
|
1820
1853
|
method: "GET",
|
|
1821
1854
|
path: "/:releaseId/actions",
|