@strapi/review-workflows 0.0.0-experimental.f75e3c6d67cc47c64ab37479efdbb7b43be50b78 → 0.0.0-experimental.f9cac24ba3b2f6acb12d0fb5669106e5a134174e
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/LICENSE +12 -17
- package/dist/_chunks/{Layout-lg3hbwGL.mjs → Layout-CJZ4iUxI.mjs} +8 -9
- package/dist/_chunks/Layout-CJZ4iUxI.mjs.map +1 -0
- package/dist/_chunks/{Layout-BMqtFafC.js → Layout-D7wwT4c7.js} +8 -9
- package/dist/_chunks/Layout-D7wwT4c7.js.map +1 -0
- package/dist/_chunks/{_id-B3jMqqMH.mjs → _id-DA44l-QM.mjs} +131 -165
- package/dist/_chunks/_id-DA44l-QM.mjs.map +1 -0
- package/dist/_chunks/{_id-B853wt9z.js → _id-DgUOk637.js} +130 -164
- package/dist/_chunks/_id-DgUOk637.js.map +1 -0
- package/dist/_chunks/{index-lebOqdrv.mjs → index-C33Q2-Fc.mjs} +108 -92
- package/dist/_chunks/index-C33Q2-Fc.mjs.map +1 -0
- package/dist/_chunks/{index-BhJmjDbj.mjs → index-CnyO97Gi.mjs} +16 -44
- package/dist/_chunks/index-CnyO97Gi.mjs.map +1 -0
- package/dist/_chunks/{index-CdU1x9cZ.js → index-DL9odlOl.js} +14 -42
- package/dist/_chunks/index-DL9odlOl.js.map +1 -0
- package/dist/_chunks/{index-Ujtj1Rcp.js → index-mQar1hfK.js} +106 -90
- package/dist/_chunks/index-mQar1hfK.js.map +1 -0
- package/dist/_chunks/{router-BboD243b.js → router-B1YtLp6u.js} +3 -3
- package/dist/_chunks/{router-BboD243b.js.map → router-B1YtLp6u.js.map} +1 -1
- package/dist/_chunks/{router-CvMnSjb9.mjs → router-BFv8U71z.mjs} +3 -3
- package/dist/_chunks/{router-CvMnSjb9.mjs.map → router-BFv8U71z.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/LimitsModal.d.ts +2 -4
- package/dist/admin/src/services/admin.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/content-manager.d.ts +4 -4
- package/dist/admin/src/services/settings.d.ts +1733 -7
- package/dist/server/index.js +41 -62
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +41 -62
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/assignees.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts +0 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/stages.d.ts.map +1 -1
- package/dist/server/src/controllers/workflows.d.ts +0 -7
- package/dist/server/src/controllers/workflows.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/routes/review-workflows.d.ts.map +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/dist/shared/contracts/review-workflows.d.ts +1 -14
- package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/_chunks/Layout-BMqtFafC.js.map +0 -1
- package/dist/_chunks/Layout-lg3hbwGL.mjs.map +0 -1
- package/dist/_chunks/_id-B3jMqqMH.mjs.map +0 -1
- package/dist/_chunks/_id-B853wt9z.js.map +0 -1
- package/dist/_chunks/index-BhJmjDbj.mjs.map +0 -1
- package/dist/_chunks/index-CdU1x9cZ.js.map +0 -1
- package/dist/_chunks/index-Ujtj1Rcp.js.map +0 -1
- package/dist/_chunks/index-lebOqdrv.mjs.map +0 -1
- package/strapi-server.js +0 -3
package/dist/server/index.js
CHANGED
|
@@ -6838,23 +6838,6 @@ const reviewWorkflows = {
|
|
|
6838
6838
|
]
|
|
6839
6839
|
}
|
|
6840
6840
|
},
|
|
6841
|
-
{
|
|
6842
|
-
method: "GET",
|
|
6843
|
-
path: "/workflows/:id",
|
|
6844
|
-
handler: "workflows.findById",
|
|
6845
|
-
config: {
|
|
6846
|
-
middlewares: [enableFeatureMiddleware("review-workflows")],
|
|
6847
|
-
policies: [
|
|
6848
|
-
"admin::isAuthenticatedAdmin",
|
|
6849
|
-
{
|
|
6850
|
-
name: "admin::hasPermissions",
|
|
6851
|
-
config: {
|
|
6852
|
-
actions: ["admin::review-workflows.read"]
|
|
6853
|
-
}
|
|
6854
|
-
}
|
|
6855
|
-
]
|
|
6856
|
-
}
|
|
6857
|
-
},
|
|
6858
6841
|
{
|
|
6859
6842
|
method: "GET",
|
|
6860
6843
|
path: "/workflows/:workflow_id/stages",
|
|
@@ -6918,7 +6901,7 @@ const reviewWorkflows = {
|
|
|
6918
6901
|
{
|
|
6919
6902
|
name: "admin::hasPermissions",
|
|
6920
6903
|
config: {
|
|
6921
|
-
actions: ["admin::users.read"
|
|
6904
|
+
actions: ["admin::users.read"]
|
|
6922
6905
|
}
|
|
6923
6906
|
}
|
|
6924
6907
|
]
|
|
@@ -7339,23 +7322,17 @@ const stages$1 = ({ strapi: strapi2 }) => {
|
|
|
7339
7322
|
},
|
|
7340
7323
|
/**
|
|
7341
7324
|
* Update the stage of an entity
|
|
7342
|
-
*
|
|
7343
|
-
* @param {object} entityInfo
|
|
7344
|
-
* @param {number} entityInfo.id - Entity id
|
|
7345
|
-
* @param {string} entityInfo.modelUID - the content-type of the entity
|
|
7346
|
-
* @param {number} stageId - The id of the stage to assign to the entity
|
|
7347
7325
|
*/
|
|
7348
|
-
async updateEntity(
|
|
7326
|
+
async updateEntity(documentId, locale, model, stageId) {
|
|
7349
7327
|
const stage = await this.findById(stageId);
|
|
7350
7328
|
await workflowValidator.validateWorkflowCount();
|
|
7351
7329
|
if (!stage) {
|
|
7352
7330
|
throw new ApplicationError$2(`Selected stage does not exist`);
|
|
7353
7331
|
}
|
|
7354
|
-
const entity = await strapi2.
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
},
|
|
7358
|
-
data: { [ENTITY_STAGE_ATTRIBUTE]: stageId },
|
|
7332
|
+
const entity = await strapi2.documents(model).update({
|
|
7333
|
+
documentId,
|
|
7334
|
+
locale,
|
|
7335
|
+
data: { [ENTITY_STAGE_ATTRIBUTE]: stage },
|
|
7359
7336
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
7360
7337
|
});
|
|
7361
7338
|
metrics.sendDidChangeEntryStage();
|
|
@@ -7772,7 +7749,12 @@ const reviewWorkflowsWeeklyMetrics = ({ strapi: strapi2 }) => {
|
|
|
7772
7749
|
},
|
|
7773
7750
|
async registerCron() {
|
|
7774
7751
|
const weeklySchedule = await this.ensureWeeklyStoredCronSchedule();
|
|
7775
|
-
strapi2.cron.add({
|
|
7752
|
+
strapi2.cron.add({
|
|
7753
|
+
reviewWorkflowsWeekly: {
|
|
7754
|
+
task: this.sendMetrics.bind(this),
|
|
7755
|
+
options: weeklySchedule
|
|
7756
|
+
}
|
|
7757
|
+
});
|
|
7776
7758
|
}
|
|
7777
7759
|
};
|
|
7778
7760
|
};
|
|
@@ -7828,6 +7810,7 @@ const handleStageOnUpdate = async (ctx, next) => {
|
|
|
7828
7810
|
strapi.eventHub.emit(WORKFLOW_UPDATE_STAGE, {
|
|
7829
7811
|
model: model.modelName,
|
|
7830
7812
|
uid: model.uid,
|
|
7813
|
+
// TODO v6: Rename to "entry", which is what is used for regular CRUD updates
|
|
7831
7814
|
entity: {
|
|
7832
7815
|
// @ts-expect-error
|
|
7833
7816
|
id: result?.id,
|
|
@@ -8029,30 +8012,6 @@ const workflows = {
|
|
|
8029
8012
|
workflowCount
|
|
8030
8013
|
}
|
|
8031
8014
|
};
|
|
8032
|
-
},
|
|
8033
|
-
/**
|
|
8034
|
-
* Get one workflow based on its id contained in request parameters
|
|
8035
|
-
* Returns count of workflows in meta, used to prevent workflow edition when
|
|
8036
|
-
* max workflow count is reached for the current plan
|
|
8037
|
-
* @param {import('koa').BaseContext} ctx - koa context
|
|
8038
|
-
*/
|
|
8039
|
-
async findById(ctx) {
|
|
8040
|
-
const { id } = ctx.params;
|
|
8041
|
-
const { query } = ctx.request;
|
|
8042
|
-
const { sanitizeOutput, sanitizedQuery } = getWorkflowsPermissionChecker(
|
|
8043
|
-
{ strapi },
|
|
8044
|
-
ctx.state.userAbility
|
|
8045
|
-
);
|
|
8046
|
-
const { populate } = await sanitizedQuery.read(query);
|
|
8047
|
-
const workflowService = getService("workflows");
|
|
8048
|
-
const [workflow2, workflowCount] = await Promise.all([
|
|
8049
|
-
workflowService.findById(id, { populate }).then(formatWorkflowToAdmin),
|
|
8050
|
-
workflowService.count()
|
|
8051
|
-
]);
|
|
8052
|
-
ctx.body = {
|
|
8053
|
-
data: await sanitizeOutput(workflow2),
|
|
8054
|
-
meta: { workflowCount }
|
|
8055
|
-
};
|
|
8056
8015
|
}
|
|
8057
8016
|
};
|
|
8058
8017
|
function sanitizeStage({ strapi: strapi2 }, userAbility) {
|
|
@@ -8137,7 +8096,12 @@ const stages = {
|
|
|
8137
8096
|
);
|
|
8138
8097
|
const workflow2 = await workflowService.assertContentTypeBelongsToWorkflow(modelUID);
|
|
8139
8098
|
workflowService.assertStageBelongsToWorkflow(stageId, workflow2);
|
|
8140
|
-
const updatedEntity = await stagesService.updateEntity(
|
|
8099
|
+
const updatedEntity = await stagesService.updateEntity(
|
|
8100
|
+
entity.documentId,
|
|
8101
|
+
entity.locale,
|
|
8102
|
+
modelUID,
|
|
8103
|
+
stageId
|
|
8104
|
+
);
|
|
8141
8105
|
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8142
8106
|
},
|
|
8143
8107
|
/**
|
|
@@ -8157,10 +8121,9 @@ const stages = {
|
|
|
8157
8121
|
if (strapi.plugin("content-manager").service("permission-checker").create({ userAbility: ctx.state.userAbility, model: modelUID }).cannot.read()) {
|
|
8158
8122
|
return ctx.forbidden();
|
|
8159
8123
|
}
|
|
8160
|
-
const locale = await validateLocale(query?.locale);
|
|
8124
|
+
const locale = await validateLocale(query?.locale) ?? void 0;
|
|
8161
8125
|
const entity = await strapi.documents(modelUID).findOne({
|
|
8162
8126
|
documentId,
|
|
8163
|
-
// @ts-expect-error - locale should be also null in the doc service types
|
|
8164
8127
|
locale,
|
|
8165
8128
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
8166
8129
|
});
|
|
@@ -8169,12 +8132,13 @@ const stages = {
|
|
|
8169
8132
|
}
|
|
8170
8133
|
const entityStageId = entity[ENTITY_STAGE_ATTRIBUTE]?.id;
|
|
8171
8134
|
const canTransition = stagePermissions2.can(STAGE_TRANSITION_UID, entityStageId);
|
|
8172
|
-
const [workflowCount,
|
|
8135
|
+
const [workflowCount, workflowResult] = await Promise.all([
|
|
8173
8136
|
workflowService.count(),
|
|
8174
8137
|
workflowService.getAssignedWorkflow(modelUID, {
|
|
8175
8138
|
populate: "stages"
|
|
8176
8139
|
})
|
|
8177
8140
|
]);
|
|
8141
|
+
const workflowStages = workflowResult ? workflowResult.stages : [];
|
|
8178
8142
|
const meta = {
|
|
8179
8143
|
stageCount: workflowStages.length,
|
|
8180
8144
|
workflowCount
|
|
@@ -8210,22 +8174,37 @@ const assignees = {
|
|
|
8210
8174
|
async updateEntity(ctx) {
|
|
8211
8175
|
const assigneeService = getService("assignees");
|
|
8212
8176
|
const workflowService = getService("workflows");
|
|
8177
|
+
const stagePermissions2 = getService("stage-permissions");
|
|
8213
8178
|
const { model_uid: model, id: documentId } = ctx.params;
|
|
8214
|
-
const
|
|
8179
|
+
const locale = await validateLocale(ctx.request.query?.locale) ?? void 0;
|
|
8215
8180
|
const { sanitizeOutput } = strapi.plugin("content-manager").service("permission-checker").create({ userAbility: ctx.state.userAbility, model });
|
|
8181
|
+
const entity = await strapi.documents(model).findOne({
|
|
8182
|
+
documentId,
|
|
8183
|
+
locale,
|
|
8184
|
+
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
8185
|
+
});
|
|
8186
|
+
if (!entity) {
|
|
8187
|
+
ctx.throw(404, "Entity not found");
|
|
8188
|
+
}
|
|
8189
|
+
const canTransitionStage = stagePermissions2.can(
|
|
8190
|
+
STAGE_TRANSITION_UID,
|
|
8191
|
+
entity[ENTITY_STAGE_ATTRIBUTE]?.id
|
|
8192
|
+
);
|
|
8193
|
+
if (!canTransitionStage) {
|
|
8194
|
+
ctx.throw(403, "Stage transition permission is required");
|
|
8195
|
+
}
|
|
8216
8196
|
const { id: assigneeId } = await validateUpdateAssigneeOnEntity(
|
|
8217
8197
|
ctx.request?.body?.data,
|
|
8218
8198
|
"You should pass a valid id to the body of the put request."
|
|
8219
8199
|
);
|
|
8220
|
-
await validateLocale(locale);
|
|
8221
8200
|
await workflowService.assertContentTypeBelongsToWorkflow(model);
|
|
8222
|
-
const
|
|
8201
|
+
const updatedEntity = await assigneeService.updateEntityAssignee(
|
|
8223
8202
|
documentId,
|
|
8224
8203
|
locale || null,
|
|
8225
8204
|
model,
|
|
8226
8205
|
assigneeId
|
|
8227
8206
|
);
|
|
8228
|
-
ctx.body = { data: await sanitizeOutput(
|
|
8207
|
+
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8229
8208
|
}
|
|
8230
8209
|
};
|
|
8231
8210
|
const controllers = {
|