@strapi/review-workflows 0.0.0-experimental.93a73ca8c7b85667fe8e46c0cb6627506570a02f → 0.0.0-experimental.953e1857bbad81a3c34f5d6511736c1bc8b91dcb
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/{Layout-AREWDuuq.js → Layout-8i0EXRRs.js} +2 -2
- package/dist/_chunks/{Layout-AREWDuuq.js.map → Layout-8i0EXRRs.js.map} +1 -1
- package/dist/_chunks/{Layout-D5aa9iUm.mjs → Layout-C9m07iTY.mjs} +2 -2
- package/dist/_chunks/{Layout-D5aa9iUm.mjs.map → Layout-C9m07iTY.mjs.map} +1 -1
- package/dist/_chunks/{_id-C7pCAzXV.js → id-CmtaTf1x.js} +6 -7
- package/dist/_chunks/id-CmtaTf1x.js.map +1 -0
- package/dist/_chunks/{_id-DDNHKV_W.mjs → id-DV0Ndeav.mjs} +6 -7
- package/dist/_chunks/id-DV0Ndeav.mjs.map +1 -0
- package/dist/_chunks/{index-Bv3cQ3c-.js → index-B8WmHbCU.js} +8 -28
- package/dist/_chunks/index-B8WmHbCU.js.map +1 -0
- package/dist/_chunks/{index-CIBLMG85.js → index-BCUO98DV.js} +25 -22
- package/dist/_chunks/index-BCUO98DV.js.map +1 -0
- package/dist/_chunks/{index-CeaoNBIP.mjs → index-CA5Axcoc.mjs} +10 -30
- package/dist/_chunks/index-CA5Axcoc.mjs.map +1 -0
- package/dist/_chunks/{index-Cx5QECZI.mjs → index-CqYVkW3E.mjs} +25 -22
- package/dist/_chunks/index-CqYVkW3E.mjs.map +1 -0
- package/dist/_chunks/{router-gRPIa2_c.js → router-BOXlNnrU.js} +3 -3
- package/dist/_chunks/router-BOXlNnrU.js.map +1 -0
- package/dist/_chunks/{router-BEoNwQZ1.mjs → router-Jdt6SbIA.mjs} +3 -3
- package/dist/_chunks/router-Jdt6SbIA.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +49 -27
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +49 -27
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/assignees.d.ts.map +1 -1
- package/dist/server/src/controllers/stages.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -1
- package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -1
- package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
- package/dist/server/src/services/stages.d.ts +2 -7
- package/dist/server/src/services/stages.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/_chunks/_id-C7pCAzXV.js.map +0 -1
- package/dist/_chunks/_id-DDNHKV_W.mjs.map +0 -1
- package/dist/_chunks/index-Bv3cQ3c-.js.map +0 -1
- package/dist/_chunks/index-CIBLMG85.js.map +0 -1
- package/dist/_chunks/index-CeaoNBIP.mjs.map +0 -1
- package/dist/_chunks/index-Cx5QECZI.mjs.map +0 -1
- package/dist/_chunks/router-BEoNwQZ1.mjs.map +0 -1
- package/dist/_chunks/router-gRPIa2_c.js.map +0 -1
- package/strapi-server.js +0 -3
- /package/dist/admin/src/routes/settings/{:id.d.ts → id.d.ts} +0 -0
package/dist/server/index.mjs
CHANGED
|
@@ -6900,7 +6900,7 @@ const reviewWorkflows = {
|
|
|
6900
6900
|
{
|
|
6901
6901
|
name: "admin::hasPermissions",
|
|
6902
6902
|
config: {
|
|
6903
|
-
actions: ["admin::users.read"
|
|
6903
|
+
actions: ["admin::users.read"]
|
|
6904
6904
|
}
|
|
6905
6905
|
}
|
|
6906
6906
|
]
|
|
@@ -7321,23 +7321,19 @@ const stages$1 = ({ strapi: strapi2 }) => {
|
|
|
7321
7321
|
},
|
|
7322
7322
|
/**
|
|
7323
7323
|
* Update the stage of an entity
|
|
7324
|
-
*
|
|
7325
|
-
* @param {object} entityInfo
|
|
7326
|
-
* @param {number} entityInfo.id - Entity id
|
|
7327
|
-
* @param {string} entityInfo.modelUID - the content-type of the entity
|
|
7328
|
-
* @param {number} stageId - The id of the stage to assign to the entity
|
|
7329
7324
|
*/
|
|
7330
|
-
async updateEntity(
|
|
7325
|
+
async updateEntity(documentId, locale, model, stageId) {
|
|
7331
7326
|
const stage = await this.findById(stageId);
|
|
7332
7327
|
await workflowValidator.validateWorkflowCount();
|
|
7333
7328
|
if (!stage) {
|
|
7334
7329
|
throw new ApplicationError$2(`Selected stage does not exist`);
|
|
7335
7330
|
}
|
|
7336
|
-
const entity = await strapi2.
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7331
|
+
const entity = await strapi2.documents(model).update({
|
|
7332
|
+
documentId,
|
|
7333
|
+
locale,
|
|
7334
|
+
// Stage doesn't have DP or i18n enabled, connecting it through the `id`
|
|
7335
|
+
// will be safer than relying on the `documentId` + `locale` + `status` transformation
|
|
7336
|
+
data: { [ENTITY_STAGE_ATTRIBUTE]: fp.pick(["id"], stage) },
|
|
7341
7337
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
7342
7338
|
});
|
|
7343
7339
|
metrics.sendDidChangeEntryStage();
|
|
@@ -7613,13 +7609,13 @@ const reviewWorkflowsMetrics = {
|
|
|
7613
7609
|
sendDidSendReviewWorkflowPropertiesOnceAWeek,
|
|
7614
7610
|
sendDidEditAssignee
|
|
7615
7611
|
};
|
|
7616
|
-
function _typeof(
|
|
7612
|
+
function _typeof(o) {
|
|
7617
7613
|
"@babel/helpers - typeof";
|
|
7618
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(
|
|
7619
|
-
return typeof
|
|
7620
|
-
} : function(
|
|
7621
|
-
return
|
|
7622
|
-
}, _typeof(
|
|
7614
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
7615
|
+
return typeof o2;
|
|
7616
|
+
} : function(o2) {
|
|
7617
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
7618
|
+
}, _typeof(o);
|
|
7623
7619
|
}
|
|
7624
7620
|
function toInteger(dirtyNumber) {
|
|
7625
7621
|
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
@@ -7754,7 +7750,12 @@ const reviewWorkflowsWeeklyMetrics = ({ strapi: strapi2 }) => {
|
|
|
7754
7750
|
},
|
|
7755
7751
|
async registerCron() {
|
|
7756
7752
|
const weeklySchedule = await this.ensureWeeklyStoredCronSchedule();
|
|
7757
|
-
strapi2.cron.add({
|
|
7753
|
+
strapi2.cron.add({
|
|
7754
|
+
reviewWorkflowsWeekly: {
|
|
7755
|
+
task: this.sendMetrics.bind(this),
|
|
7756
|
+
options: weeklySchedule
|
|
7757
|
+
}
|
|
7758
|
+
});
|
|
7758
7759
|
}
|
|
7759
7760
|
};
|
|
7760
7761
|
};
|
|
@@ -7810,6 +7811,7 @@ const handleStageOnUpdate = async (ctx, next) => {
|
|
|
7810
7811
|
strapi.eventHub.emit(WORKFLOW_UPDATE_STAGE, {
|
|
7811
7812
|
model: model.modelName,
|
|
7812
7813
|
uid: model.uid,
|
|
7814
|
+
// TODO v6: Rename to "entry", which is what is used for regular CRUD updates
|
|
7813
7815
|
entity: {
|
|
7814
7816
|
// @ts-expect-error
|
|
7815
7817
|
id: result?.id,
|
|
@@ -8095,7 +8097,12 @@ const stages = {
|
|
|
8095
8097
|
);
|
|
8096
8098
|
const workflow2 = await workflowService.assertContentTypeBelongsToWorkflow(modelUID);
|
|
8097
8099
|
workflowService.assertStageBelongsToWorkflow(stageId, workflow2);
|
|
8098
|
-
const updatedEntity = await stagesService.updateEntity(
|
|
8100
|
+
const updatedEntity = await stagesService.updateEntity(
|
|
8101
|
+
entity.documentId,
|
|
8102
|
+
entity.locale,
|
|
8103
|
+
modelUID,
|
|
8104
|
+
stageId
|
|
8105
|
+
);
|
|
8099
8106
|
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8100
8107
|
},
|
|
8101
8108
|
/**
|
|
@@ -8115,10 +8122,9 @@ const stages = {
|
|
|
8115
8122
|
if (strapi.plugin("content-manager").service("permission-checker").create({ userAbility: ctx.state.userAbility, model: modelUID }).cannot.read()) {
|
|
8116
8123
|
return ctx.forbidden();
|
|
8117
8124
|
}
|
|
8118
|
-
const locale = await validateLocale(query?.locale);
|
|
8125
|
+
const locale = await validateLocale(query?.locale) ?? void 0;
|
|
8119
8126
|
const entity = await strapi.documents(modelUID).findOne({
|
|
8120
8127
|
documentId,
|
|
8121
|
-
// @ts-expect-error - locale should be also null in the doc service types
|
|
8122
8128
|
locale,
|
|
8123
8129
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
8124
8130
|
});
|
|
@@ -8127,12 +8133,13 @@ const stages = {
|
|
|
8127
8133
|
}
|
|
8128
8134
|
const entityStageId = entity[ENTITY_STAGE_ATTRIBUTE]?.id;
|
|
8129
8135
|
const canTransition = stagePermissions2.can(STAGE_TRANSITION_UID, entityStageId);
|
|
8130
|
-
const [workflowCount,
|
|
8136
|
+
const [workflowCount, workflowResult] = await Promise.all([
|
|
8131
8137
|
workflowService.count(),
|
|
8132
8138
|
workflowService.getAssignedWorkflow(modelUID, {
|
|
8133
8139
|
populate: "stages"
|
|
8134
8140
|
})
|
|
8135
8141
|
]);
|
|
8142
|
+
const workflowStages = workflowResult ? workflowResult.stages : [];
|
|
8136
8143
|
const meta = {
|
|
8137
8144
|
stageCount: workflowStages.length,
|
|
8138
8145
|
workflowCount
|
|
@@ -8168,22 +8175,37 @@ const assignees = {
|
|
|
8168
8175
|
async updateEntity(ctx) {
|
|
8169
8176
|
const assigneeService = getService("assignees");
|
|
8170
8177
|
const workflowService = getService("workflows");
|
|
8178
|
+
const stagePermissions2 = getService("stage-permissions");
|
|
8171
8179
|
const { model_uid: model, id: documentId } = ctx.params;
|
|
8172
|
-
const
|
|
8180
|
+
const locale = await validateLocale(ctx.request.query?.locale) ?? void 0;
|
|
8173
8181
|
const { sanitizeOutput } = strapi.plugin("content-manager").service("permission-checker").create({ userAbility: ctx.state.userAbility, model });
|
|
8182
|
+
const entity = await strapi.documents(model).findOne({
|
|
8183
|
+
documentId,
|
|
8184
|
+
locale,
|
|
8185
|
+
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
8186
|
+
});
|
|
8187
|
+
if (!entity) {
|
|
8188
|
+
ctx.throw(404, "Entity not found");
|
|
8189
|
+
}
|
|
8190
|
+
const canTransitionStage = stagePermissions2.can(
|
|
8191
|
+
STAGE_TRANSITION_UID,
|
|
8192
|
+
entity[ENTITY_STAGE_ATTRIBUTE]?.id
|
|
8193
|
+
);
|
|
8194
|
+
if (!canTransitionStage) {
|
|
8195
|
+
ctx.throw(403, "Stage transition permission is required");
|
|
8196
|
+
}
|
|
8174
8197
|
const { id: assigneeId } = await validateUpdateAssigneeOnEntity(
|
|
8175
8198
|
ctx.request?.body?.data,
|
|
8176
8199
|
"You should pass a valid id to the body of the put request."
|
|
8177
8200
|
);
|
|
8178
|
-
await validateLocale(locale);
|
|
8179
8201
|
await workflowService.assertContentTypeBelongsToWorkflow(model);
|
|
8180
|
-
const
|
|
8202
|
+
const updatedEntity = await assigneeService.updateEntityAssignee(
|
|
8181
8203
|
documentId,
|
|
8182
8204
|
locale || null,
|
|
8183
8205
|
model,
|
|
8184
8206
|
assigneeId
|
|
8185
8207
|
);
|
|
8186
|
-
ctx.body = { data: await sanitizeOutput(
|
|
8208
|
+
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8187
8209
|
}
|
|
8188
8210
|
};
|
|
8189
8211
|
const controllers = {
|