@strapi/content-releases 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4 → 0.0.0-experimental.ee7402bacc4656d268ab76aa9c334a7b7a951201
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-UQxgTJY5.mjs → App-CiZCkScI.mjs} +314 -107
- package/dist/_chunks/App-CiZCkScI.mjs.map +1 -0
- package/dist/_chunks/{App-D-lWdVb2.js → App-SGjO5UPV.js} +354 -148
- package/dist/_chunks/App-SGjO5UPV.js.map +1 -0
- package/dist/_chunks/{PurchaseContentReleases-Be3acS2L.js → PurchaseContentReleases--qQepXpP.js} +2 -2
- package/dist/_chunks/PurchaseContentReleases--qQepXpP.js.map +1 -0
- package/dist/_chunks/{PurchaseContentReleases-_MxP6-Dt.mjs → PurchaseContentReleases-D-n-w-st.mjs} +2 -2
- package/dist/_chunks/{PurchaseContentReleases-_MxP6-Dt.mjs.map → PurchaseContentReleases-D-n-w-st.mjs.map} +1 -1
- package/dist/_chunks/{ReleasesSettingsPage-xfAoY8N3.js → ReleasesSettingsPage-Cto_NLUd.js} +4 -4
- package/dist/_chunks/ReleasesSettingsPage-Cto_NLUd.js.map +1 -0
- package/dist/_chunks/{ReleasesSettingsPage-CuUXvABk.mjs → ReleasesSettingsPage-DQT8N3A-.mjs} +4 -4
- package/dist/_chunks/ReleasesSettingsPage-DQT8N3A-.mjs.map +1 -0
- package/dist/_chunks/{en-BCDLTJn3.js → en-BWPPsSH-.js} +12 -2
- package/dist/_chunks/en-BWPPsSH-.js.map +1 -0
- package/dist/_chunks/{en-CGXIF4vQ.mjs → en-D9Q4YW03.mjs} +12 -2
- package/dist/_chunks/en-D9Q4YW03.mjs.map +1 -0
- package/dist/_chunks/{index-b3Ej95H7.mjs → index-BjvFfTtA.mjs} +316 -29
- package/dist/_chunks/index-BjvFfTtA.mjs.map +1 -0
- package/dist/_chunks/{index-jnv9zdcE.js → index-CyU534vL.js} +314 -28
- package/dist/_chunks/index-CyU534vL.js.map +1 -0
- package/dist/_chunks/{schemas-z5zp-_Gd.js → schemas-DBYv9gK8.js} +3 -4
- package/dist/_chunks/schemas-DBYv9gK8.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/EntryValidationPopover.d.ts +13 -0
- 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 +192 -90
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +191 -88
- 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 +6 -6
- package/dist/server/src/middlewares/documents.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 +4 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts +6 -8
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/release-actions.d.ts +11 -6
- 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 +18 -16
- package/dist/_chunks/App-D-lWdVb2.js.map +0 -1
- package/dist/_chunks/App-UQxgTJY5.mjs.map +0 -1
- package/dist/_chunks/PurchaseContentReleases-Be3acS2L.js.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.js
CHANGED
|
@@ -7,8 +7,7 @@ const nodeSchedule = require("node-schedule");
|
|
|
7
7
|
const yup = require("yup");
|
|
8
8
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
9
|
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule)
|
|
11
|
-
return e;
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
12
11
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
12
|
if (e) {
|
|
14
13
|
for (const k in e) {
|
|
@@ -111,6 +110,13 @@ const isEntryValid = async (contentTypeUid, entry, { strapi: strapi2 }) => {
|
|
|
111
110
|
// @ts-expect-error - FIXME: entity here is unnecessary
|
|
112
111
|
entry
|
|
113
112
|
);
|
|
113
|
+
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
114
|
+
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
115
|
+
populate: "stageRequiredToPublish"
|
|
116
|
+
});
|
|
117
|
+
if (workflow?.stageRequiredToPublish) {
|
|
118
|
+
return entry.strapi_stage.id === workflow.stageRequiredToPublish.id;
|
|
119
|
+
}
|
|
114
120
|
return true;
|
|
115
121
|
} catch {
|
|
116
122
|
return false;
|
|
@@ -124,7 +130,11 @@ const getEntry = async ({
|
|
|
124
130
|
status = "draft"
|
|
125
131
|
}, { strapi: strapi2 }) => {
|
|
126
132
|
if (documentId) {
|
|
127
|
-
|
|
133
|
+
const entry = await strapi2.documents(contentType).findOne({ documentId, locale, populate, status });
|
|
134
|
+
if (status === "published" && !entry) {
|
|
135
|
+
return strapi2.documents(contentType).findOne({ documentId, locale, populate, status: "draft" });
|
|
136
|
+
}
|
|
137
|
+
return entry;
|
|
128
138
|
}
|
|
129
139
|
return strapi2.documents(contentType).findFirst({ locale, populate, status });
|
|
130
140
|
};
|
|
@@ -329,6 +339,10 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
|
|
|
329
339
|
const addEntryDocumentToReleaseActions = {
|
|
330
340
|
name: "content-releases::5.0.0-add-entry-document-id-to-release-actions",
|
|
331
341
|
async up(trx, db) {
|
|
342
|
+
const hasTable = await trx.schema.hasTable("strapi_release_actions");
|
|
343
|
+
if (!hasTable) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
332
346
|
const hasPolymorphicColumn = await trx.schema.hasColumn("strapi_release_actions", "target_id");
|
|
333
347
|
if (hasPolymorphicColumn) {
|
|
334
348
|
const hasEntryDocumentIdColumn = await trx.schema.hasColumn(
|
|
@@ -370,6 +384,7 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
370
384
|
const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) => {
|
|
371
385
|
const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
372
386
|
where: {
|
|
387
|
+
releasedAt: null,
|
|
373
388
|
actions: {
|
|
374
389
|
contentType,
|
|
375
390
|
entryDocumentId: entry.documentId,
|
|
@@ -378,7 +393,7 @@ const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) =>
|
|
|
378
393
|
}
|
|
379
394
|
});
|
|
380
395
|
const entryStatus = await isEntryValid(contentType, entry, { strapi });
|
|
381
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).
|
|
396
|
+
await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
|
|
382
397
|
where: {
|
|
383
398
|
contentType,
|
|
384
399
|
entryDocumentId: entry.documentId,
|
|
@@ -482,8 +497,8 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
482
497
|
const { where } = event.params;
|
|
483
498
|
deleteReleasesActionsAndUpdateReleaseStatus({
|
|
484
499
|
contentType: model.uid,
|
|
485
|
-
locale: where
|
|
486
|
-
...where
|
|
500
|
+
locale: where?.locale ?? null,
|
|
501
|
+
...where?.documentId && { entryDocumentId: where.documentId }
|
|
487
502
|
});
|
|
488
503
|
}
|
|
489
504
|
} catch (error) {
|
|
@@ -929,7 +944,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
929
944
|
return contentTypesData;
|
|
930
945
|
};
|
|
931
946
|
return {
|
|
932
|
-
async create(releaseId, action) {
|
|
947
|
+
async create(releaseId, action, { disableUpdateReleaseStatus = false } = {}) {
|
|
933
948
|
const { validateEntryData, validateUniqueEntry } = getService("release-validation", {
|
|
934
949
|
strapi: strapi2
|
|
935
950
|
});
|
|
@@ -937,6 +952,14 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
937
952
|
validateEntryData(action.contentType, action.entryDocumentId),
|
|
938
953
|
validateUniqueEntry(releaseId, action)
|
|
939
954
|
]);
|
|
955
|
+
const model = strapi2.contentType(action.contentType);
|
|
956
|
+
if (model.kind === "singleType") {
|
|
957
|
+
const document = await strapi2.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
958
|
+
if (!document) {
|
|
959
|
+
throw new utils.errors.NotFoundError(`No entry found for contentType ${action.contentType}`);
|
|
960
|
+
}
|
|
961
|
+
action.entryDocumentId = document.documentId;
|
|
962
|
+
}
|
|
940
963
|
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
|
|
941
964
|
if (!release2) {
|
|
942
965
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
@@ -962,7 +985,9 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
962
985
|
},
|
|
963
986
|
populate: { release: { select: ["id"] } }
|
|
964
987
|
});
|
|
965
|
-
|
|
988
|
+
if (!disableUpdateReleaseStatus) {
|
|
989
|
+
getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
|
|
990
|
+
}
|
|
966
991
|
return releaseAction2;
|
|
967
992
|
},
|
|
968
993
|
async findPage(releaseId, query) {
|
|
@@ -1028,16 +1053,26 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1028
1053
|
const groupName = getGroupName(groupBy);
|
|
1029
1054
|
return ___default.default.groupBy(groupName)(formattedData);
|
|
1030
1055
|
},
|
|
1031
|
-
getContentTypeModelsFromActions(actions) {
|
|
1056
|
+
async getContentTypeModelsFromActions(actions) {
|
|
1032
1057
|
const contentTypeUids = actions.reduce((acc, action) => {
|
|
1033
1058
|
if (!acc.includes(action.contentType)) {
|
|
1034
1059
|
acc.push(action.contentType);
|
|
1035
1060
|
}
|
|
1036
1061
|
return acc;
|
|
1037
1062
|
}, []);
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
1063
|
+
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
1064
|
+
const contentTypeModelsMap = await utils.async.reduce(contentTypeUids)(
|
|
1065
|
+
async (accPromise, contentTypeUid) => {
|
|
1066
|
+
const acc = await accPromise;
|
|
1067
|
+
const contentTypeModel = strapi2.getModel(contentTypeUid);
|
|
1068
|
+
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
1069
|
+
populate: "stageRequiredToPublish"
|
|
1070
|
+
});
|
|
1071
|
+
acc[contentTypeUid] = {
|
|
1072
|
+
...contentTypeModel,
|
|
1073
|
+
hasReviewWorkflow: !!workflow,
|
|
1074
|
+
stageRequiredToPublish: workflow?.stageRequiredToPublish
|
|
1075
|
+
};
|
|
1041
1076
|
return acc;
|
|
1042
1077
|
},
|
|
1043
1078
|
{}
|
|
@@ -1065,7 +1100,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1065
1100
|
`Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
|
|
1066
1101
|
);
|
|
1067
1102
|
}
|
|
1068
|
-
const actionStatus = update.type === "publish" ? getDraftEntryValidStatus(
|
|
1103
|
+
const actionStatus = update.type === "publish" ? await getDraftEntryValidStatus(
|
|
1069
1104
|
{
|
|
1070
1105
|
contentType: action.contentType,
|
|
1071
1106
|
documentId: action.entryDocumentId,
|
|
@@ -1112,6 +1147,54 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1112
1147
|
}
|
|
1113
1148
|
getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1114
1149
|
return deletedAction;
|
|
1150
|
+
},
|
|
1151
|
+
async validateActionsByContentTypes(contentTypeUids) {
|
|
1152
|
+
const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
|
|
1153
|
+
where: {
|
|
1154
|
+
contentType: {
|
|
1155
|
+
$in: contentTypeUids
|
|
1156
|
+
},
|
|
1157
|
+
// We only want to validate actions that are going to be published
|
|
1158
|
+
type: "publish",
|
|
1159
|
+
release: {
|
|
1160
|
+
releasedAt: {
|
|
1161
|
+
$null: true
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
populate: { release: true }
|
|
1166
|
+
});
|
|
1167
|
+
const releasesUpdated = [];
|
|
1168
|
+
await utils.async.map(actions, async (action) => {
|
|
1169
|
+
const isValid = await getDraftEntryValidStatus(
|
|
1170
|
+
{
|
|
1171
|
+
contentType: action.contentType,
|
|
1172
|
+
documentId: action.entryDocumentId,
|
|
1173
|
+
locale: action.locale
|
|
1174
|
+
},
|
|
1175
|
+
{ strapi: strapi2 }
|
|
1176
|
+
);
|
|
1177
|
+
await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
1178
|
+
where: {
|
|
1179
|
+
id: action.id
|
|
1180
|
+
},
|
|
1181
|
+
data: {
|
|
1182
|
+
isEntryValid: isValid
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
if (!releasesUpdated.includes(action.release.id)) {
|
|
1186
|
+
releasesUpdated.push(action.release.id);
|
|
1187
|
+
}
|
|
1188
|
+
return {
|
|
1189
|
+
id: action.id,
|
|
1190
|
+
isEntryValid: isValid
|
|
1191
|
+
};
|
|
1192
|
+
});
|
|
1193
|
+
if (releasesUpdated.length > 0) {
|
|
1194
|
+
await utils.async.map(releasesUpdated, async (releaseId) => {
|
|
1195
|
+
await getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1115
1198
|
}
|
|
1116
1199
|
};
|
|
1117
1200
|
};
|
|
@@ -1135,11 +1218,11 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
|
1135
1218
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
1136
1219
|
}
|
|
1137
1220
|
const isEntryInRelease = release2.actions.some(
|
|
1138
|
-
(action) =>
|
|
1221
|
+
(action) => action.entryDocumentId === releaseActionArgs.entryDocumentId && action.contentType === releaseActionArgs.contentType && (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)
|
|
1139
1222
|
);
|
|
1140
1223
|
if (isEntryInRelease) {
|
|
1141
1224
|
throw new AlreadyOnReleaseError(
|
|
1142
|
-
`Entry with documentId ${releaseActionArgs.entryDocumentId}
|
|
1225
|
+
`Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
|
|
1143
1226
|
);
|
|
1144
1227
|
}
|
|
1145
1228
|
},
|
|
@@ -1306,7 +1389,15 @@ const releaseController = {
|
|
|
1306
1389
|
const releaseService = getService("release", { strapi });
|
|
1307
1390
|
const query = await permissionsManager.sanitizeQuery(ctx.query);
|
|
1308
1391
|
await validatefindByDocumentAttachedParams(query);
|
|
1309
|
-
const
|
|
1392
|
+
const model = strapi.getModel(query.contentType);
|
|
1393
|
+
if (model.kind && model.kind === "singleType") {
|
|
1394
|
+
const document = await strapi.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
1395
|
+
if (!document) {
|
|
1396
|
+
throw new utils.errors.NotFoundError(`No entry found for contentType ${query.contentType}`);
|
|
1397
|
+
}
|
|
1398
|
+
query.entryDocumentId = document.documentId;
|
|
1399
|
+
}
|
|
1400
|
+
const { contentType, hasEntryAttached, entryDocumentId, locale } = query;
|
|
1310
1401
|
const isEntryAttached = typeof hasEntryAttached === "string" ? Boolean(JSON.parse(hasEntryAttached)) : false;
|
|
1311
1402
|
if (isEntryAttached) {
|
|
1312
1403
|
const releases = await releaseService.findMany({
|
|
@@ -1320,7 +1411,12 @@ const releaseController = {
|
|
|
1320
1411
|
},
|
|
1321
1412
|
populate: {
|
|
1322
1413
|
actions: {
|
|
1323
|
-
fields: ["type"]
|
|
1414
|
+
fields: ["type"],
|
|
1415
|
+
filters: {
|
|
1416
|
+
contentType,
|
|
1417
|
+
entryDocumentId: entryDocumentId ?? null,
|
|
1418
|
+
locale: locale ?? null
|
|
1419
|
+
}
|
|
1324
1420
|
}
|
|
1325
1421
|
}
|
|
1326
1422
|
});
|
|
@@ -1408,43 +1504,50 @@ const releaseController = {
|
|
|
1408
1504
|
};
|
|
1409
1505
|
ctx.body = { data };
|
|
1410
1506
|
},
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1507
|
+
async mapEntriesToReleases(ctx) {
|
|
1508
|
+
const { contentTypeUid, documentIds, locale } = ctx.query;
|
|
1509
|
+
if (!contentTypeUid || !documentIds) {
|
|
1510
|
+
throw new utils.errors.ValidationError("Missing required query parameters");
|
|
1511
|
+
}
|
|
1512
|
+
const releaseService = getService("release", { strapi });
|
|
1513
|
+
const releasesWithActions = await releaseService.findMany({
|
|
1514
|
+
where: {
|
|
1515
|
+
releasedAt: null,
|
|
1516
|
+
actions: {
|
|
1517
|
+
contentType: contentTypeUid,
|
|
1518
|
+
entryDocumentId: {
|
|
1519
|
+
$in: documentIds
|
|
1520
|
+
},
|
|
1521
|
+
locale
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
populate: {
|
|
1525
|
+
actions: true
|
|
1417
1526
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
ctx.body = {
|
|
1444
|
-
data: mappedEntriesInReleases,
|
|
1445
|
-
};
|
|
1446
|
-
},
|
|
1447
|
-
*/
|
|
1527
|
+
});
|
|
1528
|
+
const mappedEntriesInReleases = releasesWithActions.reduce(
|
|
1529
|
+
(acc, release2) => {
|
|
1530
|
+
release2.actions.forEach((action) => {
|
|
1531
|
+
if (action.contentType !== contentTypeUid) {
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
if (locale && action.locale !== locale) {
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (!acc[action.entryDocumentId]) {
|
|
1538
|
+
acc[action.entryDocumentId] = [{ id: release2.id, name: release2.name }];
|
|
1539
|
+
} else {
|
|
1540
|
+
acc[action.entryDocumentId].push({ id: release2.id, name: release2.name });
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1543
|
+
return acc;
|
|
1544
|
+
},
|
|
1545
|
+
{}
|
|
1546
|
+
);
|
|
1547
|
+
ctx.body = {
|
|
1548
|
+
data: mappedEntriesInReleases
|
|
1549
|
+
};
|
|
1550
|
+
},
|
|
1448
1551
|
async create(ctx) {
|
|
1449
1552
|
const user = ctx.state.user;
|
|
1450
1553
|
const releaseArgs = ctx.request.body;
|
|
@@ -1537,22 +1640,23 @@ const releaseActionController = {
|
|
|
1537
1640
|
data: releaseAction2
|
|
1538
1641
|
});
|
|
1539
1642
|
},
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const
|
|
1543
|
-
const releaseActionsArgs = ctx.request.body as CreateManyReleaseActions.Request['body'];
|
|
1643
|
+
async createMany(ctx) {
|
|
1644
|
+
const releaseId = ctx.params.releaseId;
|
|
1645
|
+
const releaseActionsArgs = ctx.request.body;
|
|
1544
1646
|
await Promise.all(
|
|
1545
1647
|
releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
|
|
1546
1648
|
);
|
|
1547
|
-
const releaseActionService = getService(
|
|
1649
|
+
const releaseActionService = getService("release-action", { strapi });
|
|
1650
|
+
const releaseService = getService("release", { strapi });
|
|
1548
1651
|
const releaseActions = await strapi.db.transaction(async () => {
|
|
1549
|
-
const
|
|
1652
|
+
const releaseActions2 = await Promise.all(
|
|
1550
1653
|
releaseActionsArgs.map(async (releaseActionArgs) => {
|
|
1551
1654
|
try {
|
|
1552
|
-
const action = await releaseActionService.create(releaseId, releaseActionArgs
|
|
1655
|
+
const action = await releaseActionService.create(releaseId, releaseActionArgs, {
|
|
1656
|
+
disableUpdateReleaseStatus: true
|
|
1657
|
+
});
|
|
1553
1658
|
return action;
|
|
1554
1659
|
} catch (error) {
|
|
1555
|
-
// If the entry is already in the release, we don't want to throw an error, so we catch and ignore it
|
|
1556
1660
|
if (error instanceof AlreadyOnReleaseError) {
|
|
1557
1661
|
return null;
|
|
1558
1662
|
}
|
|
@@ -1560,18 +1664,20 @@ const releaseActionController = {
|
|
|
1560
1664
|
}
|
|
1561
1665
|
})
|
|
1562
1666
|
);
|
|
1563
|
-
return
|
|
1667
|
+
return releaseActions2;
|
|
1564
1668
|
});
|
|
1565
1669
|
const newReleaseActions = releaseActions.filter((action) => action !== null);
|
|
1670
|
+
if (newReleaseActions.length > 0) {
|
|
1671
|
+
releaseService.updateReleaseStatus(releaseId);
|
|
1672
|
+
}
|
|
1566
1673
|
ctx.created({
|
|
1567
1674
|
data: newReleaseActions,
|
|
1568
1675
|
meta: {
|
|
1569
1676
|
entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
|
|
1570
|
-
totalEntries: releaseActions.length
|
|
1571
|
-
}
|
|
1677
|
+
totalEntries: releaseActions.length
|
|
1678
|
+
}
|
|
1572
1679
|
});
|
|
1573
1680
|
},
|
|
1574
|
-
*/
|
|
1575
1681
|
async findMany(ctx) {
|
|
1576
1682
|
const releaseId = ctx.params.releaseId;
|
|
1577
1683
|
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
@@ -1607,7 +1713,7 @@ const releaseActionController = {
|
|
|
1607
1713
|
entry: action.entry ? await contentTypeOutputSanitizers[action.contentType](action.entry) : {}
|
|
1608
1714
|
}));
|
|
1609
1715
|
const groupedData = await releaseActionService.groupActions(sanitizedResults, query.sort);
|
|
1610
|
-
const contentTypes2 = releaseActionService.getContentTypeModelsFromActions(results);
|
|
1716
|
+
const contentTypes2 = await releaseActionService.getContentTypeModelsFromActions(results);
|
|
1611
1717
|
const releaseService = getService("release", { strapi });
|
|
1612
1718
|
const components = await releaseService.getAllComponents();
|
|
1613
1719
|
ctx.body = {
|
|
@@ -1670,24 +1776,22 @@ const controllers = {
|
|
|
1670
1776
|
const release = {
|
|
1671
1777
|
type: "admin",
|
|
1672
1778
|
routes: [
|
|
1673
|
-
/*
|
|
1674
1779
|
{
|
|
1675
|
-
method:
|
|
1676
|
-
path:
|
|
1677
|
-
handler:
|
|
1780
|
+
method: "GET",
|
|
1781
|
+
path: "/mapEntriesToReleases",
|
|
1782
|
+
handler: "release.mapEntriesToReleases",
|
|
1678
1783
|
config: {
|
|
1679
1784
|
policies: [
|
|
1680
|
-
|
|
1785
|
+
"admin::isAuthenticatedAdmin",
|
|
1681
1786
|
{
|
|
1682
|
-
name:
|
|
1787
|
+
name: "admin::hasPermissions",
|
|
1683
1788
|
config: {
|
|
1684
|
-
actions: [
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
]
|
|
1688
|
-
}
|
|
1789
|
+
actions: ["plugin::content-releases.read"]
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
]
|
|
1793
|
+
}
|
|
1689
1794
|
},
|
|
1690
|
-
*/
|
|
1691
1795
|
{
|
|
1692
1796
|
method: "GET",
|
|
1693
1797
|
path: "/getByDocumentAttached",
|
|
@@ -1821,24 +1925,22 @@ const releaseAction = {
|
|
|
1821
1925
|
]
|
|
1822
1926
|
}
|
|
1823
1927
|
},
|
|
1824
|
-
/*
|
|
1825
1928
|
{
|
|
1826
|
-
method:
|
|
1827
|
-
path:
|
|
1828
|
-
handler:
|
|
1929
|
+
method: "POST",
|
|
1930
|
+
path: "/:releaseId/actions/bulk",
|
|
1931
|
+
handler: "release-action.createMany",
|
|
1829
1932
|
config: {
|
|
1830
1933
|
policies: [
|
|
1831
|
-
|
|
1934
|
+
"admin::isAuthenticatedAdmin",
|
|
1832
1935
|
{
|
|
1833
|
-
name:
|
|
1936
|
+
name: "admin::hasPermissions",
|
|
1834
1937
|
config: {
|
|
1835
|
-
actions: [
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
]
|
|
1839
|
-
}
|
|
1938
|
+
actions: ["plugin::content-releases.create-action"]
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
]
|
|
1942
|
+
}
|
|
1840
1943
|
},
|
|
1841
|
-
*/
|
|
1842
1944
|
{
|
|
1843
1945
|
method: "GET",
|
|
1844
1946
|
path: "/:releaseId/actions",
|