@strapi/review-workflows 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4 → 0.0.0-experimental.f0d4afee92a0d386f80385590c87955656f995ce
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-D3DDQmMI.js → Layout-8i0EXRRs.js} +7 -8
- package/dist/_chunks/Layout-8i0EXRRs.js.map +1 -0
- package/dist/_chunks/{Layout-Da8jupiA.mjs → Layout-C9m07iTY.mjs} +7 -8
- package/dist/_chunks/Layout-C9m07iTY.mjs.map +1 -0
- package/dist/_chunks/{_id-CnRDP3Xx.js → id-CmtaTf1x.js} +13 -40
- package/dist/_chunks/id-CmtaTf1x.js.map +1 -0
- package/dist/_chunks/{_id-xSrgPSJs.mjs → id-DV0Ndeav.mjs} +13 -40
- package/dist/_chunks/id-DV0Ndeav.mjs.map +1 -0
- package/dist/_chunks/{index-4kp4AkBB.js → index-B8WmHbCU.js} +9 -29
- package/dist/_chunks/index-B8WmHbCU.js.map +1 -0
- package/dist/_chunks/{index-DhPxWpsW.js → index-BCUO98DV.js} +78 -67
- package/dist/_chunks/index-BCUO98DV.js.map +1 -0
- package/dist/_chunks/{index-jfO5GxtW.mjs → index-CA5Axcoc.mjs} +11 -31
- package/dist/_chunks/index-CA5Axcoc.mjs.map +1 -0
- package/dist/_chunks/{index-DDsJlZQw.mjs → index-CqYVkW3E.mjs} +79 -68
- package/dist/_chunks/index-CqYVkW3E.mjs.map +1 -0
- package/dist/_chunks/{router-DSXpeew4.js → router-BOXlNnrU.js} +3 -3
- package/dist/_chunks/router-BOXlNnrU.js.map +1 -0
- package/dist/_chunks/{router-DOEULOpS.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/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 +49 -68
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +49 -68
- 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-D3DDQmMI.js.map +0 -1
- package/dist/_chunks/Layout-Da8jupiA.mjs.map +0 -1
- package/dist/_chunks/_id-CnRDP3Xx.js.map +0 -1
- package/dist/_chunks/_id-xSrgPSJs.mjs.map +0 -1
- package/dist/_chunks/index-4kp4AkBB.js.map +0 -1
- package/dist/_chunks/index-DDsJlZQw.mjs.map +0 -1
- package/dist/_chunks/index-DhPxWpsW.js.map +0 -1
- package/dist/_chunks/index-jfO5GxtW.mjs.map +0 -1
- package/dist/_chunks/router-DOEULOpS.mjs.map +0 -1
- package/dist/_chunks/router-DSXpeew4.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
|
@@ -6837,23 +6837,6 @@ const reviewWorkflows = {
|
|
|
6837
6837
|
]
|
|
6838
6838
|
}
|
|
6839
6839
|
},
|
|
6840
|
-
{
|
|
6841
|
-
method: "GET",
|
|
6842
|
-
path: "/workflows/:id",
|
|
6843
|
-
handler: "workflows.findById",
|
|
6844
|
-
config: {
|
|
6845
|
-
middlewares: [enableFeatureMiddleware("review-workflows")],
|
|
6846
|
-
policies: [
|
|
6847
|
-
"admin::isAuthenticatedAdmin",
|
|
6848
|
-
{
|
|
6849
|
-
name: "admin::hasPermissions",
|
|
6850
|
-
config: {
|
|
6851
|
-
actions: ["admin::review-workflows.read"]
|
|
6852
|
-
}
|
|
6853
|
-
}
|
|
6854
|
-
]
|
|
6855
|
-
}
|
|
6856
|
-
},
|
|
6857
6840
|
{
|
|
6858
6841
|
method: "GET",
|
|
6859
6842
|
path: "/workflows/:workflow_id/stages",
|
|
@@ -6917,7 +6900,7 @@ const reviewWorkflows = {
|
|
|
6917
6900
|
{
|
|
6918
6901
|
name: "admin::hasPermissions",
|
|
6919
6902
|
config: {
|
|
6920
|
-
actions: ["admin::users.read"
|
|
6903
|
+
actions: ["admin::users.read"]
|
|
6921
6904
|
}
|
|
6922
6905
|
}
|
|
6923
6906
|
]
|
|
@@ -7338,23 +7321,19 @@ const stages$1 = ({ strapi: strapi2 }) => {
|
|
|
7338
7321
|
},
|
|
7339
7322
|
/**
|
|
7340
7323
|
* Update the stage of an entity
|
|
7341
|
-
*
|
|
7342
|
-
* @param {object} entityInfo
|
|
7343
|
-
* @param {number} entityInfo.id - Entity id
|
|
7344
|
-
* @param {string} entityInfo.modelUID - the content-type of the entity
|
|
7345
|
-
* @param {number} stageId - The id of the stage to assign to the entity
|
|
7346
7324
|
*/
|
|
7347
|
-
async updateEntity(
|
|
7325
|
+
async updateEntity(documentId, locale, model, stageId) {
|
|
7348
7326
|
const stage = await this.findById(stageId);
|
|
7349
7327
|
await workflowValidator.validateWorkflowCount();
|
|
7350
7328
|
if (!stage) {
|
|
7351
7329
|
throw new ApplicationError$2(`Selected stage does not exist`);
|
|
7352
7330
|
}
|
|
7353
|
-
const entity = await strapi2.
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
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) },
|
|
7358
7337
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
7359
7338
|
});
|
|
7360
7339
|
metrics.sendDidChangeEntryStage();
|
|
@@ -7630,13 +7609,13 @@ const reviewWorkflowsMetrics = {
|
|
|
7630
7609
|
sendDidSendReviewWorkflowPropertiesOnceAWeek,
|
|
7631
7610
|
sendDidEditAssignee
|
|
7632
7611
|
};
|
|
7633
|
-
function _typeof(
|
|
7612
|
+
function _typeof(o) {
|
|
7634
7613
|
"@babel/helpers - typeof";
|
|
7635
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(
|
|
7636
|
-
return typeof
|
|
7637
|
-
} : function(
|
|
7638
|
-
return
|
|
7639
|
-
}, _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);
|
|
7640
7619
|
}
|
|
7641
7620
|
function toInteger(dirtyNumber) {
|
|
7642
7621
|
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
@@ -7771,7 +7750,12 @@ const reviewWorkflowsWeeklyMetrics = ({ strapi: strapi2 }) => {
|
|
|
7771
7750
|
},
|
|
7772
7751
|
async registerCron() {
|
|
7773
7752
|
const weeklySchedule = await this.ensureWeeklyStoredCronSchedule();
|
|
7774
|
-
strapi2.cron.add({
|
|
7753
|
+
strapi2.cron.add({
|
|
7754
|
+
reviewWorkflowsWeekly: {
|
|
7755
|
+
task: this.sendMetrics.bind(this),
|
|
7756
|
+
options: weeklySchedule
|
|
7757
|
+
}
|
|
7758
|
+
});
|
|
7775
7759
|
}
|
|
7776
7760
|
};
|
|
7777
7761
|
};
|
|
@@ -7827,6 +7811,7 @@ const handleStageOnUpdate = async (ctx, next) => {
|
|
|
7827
7811
|
strapi.eventHub.emit(WORKFLOW_UPDATE_STAGE, {
|
|
7828
7812
|
model: model.modelName,
|
|
7829
7813
|
uid: model.uid,
|
|
7814
|
+
// TODO v6: Rename to "entry", which is what is used for regular CRUD updates
|
|
7830
7815
|
entity: {
|
|
7831
7816
|
// @ts-expect-error
|
|
7832
7817
|
id: result?.id,
|
|
@@ -8028,30 +8013,6 @@ const workflows = {
|
|
|
8028
8013
|
workflowCount
|
|
8029
8014
|
}
|
|
8030
8015
|
};
|
|
8031
|
-
},
|
|
8032
|
-
/**
|
|
8033
|
-
* Get one workflow based on its id contained in request parameters
|
|
8034
|
-
* Returns count of workflows in meta, used to prevent workflow edition when
|
|
8035
|
-
* max workflow count is reached for the current plan
|
|
8036
|
-
* @param {import('koa').BaseContext} ctx - koa context
|
|
8037
|
-
*/
|
|
8038
|
-
async findById(ctx) {
|
|
8039
|
-
const { id } = ctx.params;
|
|
8040
|
-
const { query } = ctx.request;
|
|
8041
|
-
const { sanitizeOutput, sanitizedQuery } = getWorkflowsPermissionChecker(
|
|
8042
|
-
{ strapi },
|
|
8043
|
-
ctx.state.userAbility
|
|
8044
|
-
);
|
|
8045
|
-
const { populate } = await sanitizedQuery.read(query);
|
|
8046
|
-
const workflowService = getService("workflows");
|
|
8047
|
-
const [workflow2, workflowCount] = await Promise.all([
|
|
8048
|
-
workflowService.findById(id, { populate }).then(formatWorkflowToAdmin),
|
|
8049
|
-
workflowService.count()
|
|
8050
|
-
]);
|
|
8051
|
-
ctx.body = {
|
|
8052
|
-
data: await sanitizeOutput(workflow2),
|
|
8053
|
-
meta: { workflowCount }
|
|
8054
|
-
};
|
|
8055
8016
|
}
|
|
8056
8017
|
};
|
|
8057
8018
|
function sanitizeStage({ strapi: strapi2 }, userAbility) {
|
|
@@ -8136,7 +8097,12 @@ const stages = {
|
|
|
8136
8097
|
);
|
|
8137
8098
|
const workflow2 = await workflowService.assertContentTypeBelongsToWorkflow(modelUID);
|
|
8138
8099
|
workflowService.assertStageBelongsToWorkflow(stageId, workflow2);
|
|
8139
|
-
const updatedEntity = await stagesService.updateEntity(
|
|
8100
|
+
const updatedEntity = await stagesService.updateEntity(
|
|
8101
|
+
entity.documentId,
|
|
8102
|
+
entity.locale,
|
|
8103
|
+
modelUID,
|
|
8104
|
+
stageId
|
|
8105
|
+
);
|
|
8140
8106
|
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8141
8107
|
},
|
|
8142
8108
|
/**
|
|
@@ -8156,10 +8122,9 @@ const stages = {
|
|
|
8156
8122
|
if (strapi.plugin("content-manager").service("permission-checker").create({ userAbility: ctx.state.userAbility, model: modelUID }).cannot.read()) {
|
|
8157
8123
|
return ctx.forbidden();
|
|
8158
8124
|
}
|
|
8159
|
-
const locale = await validateLocale(query?.locale);
|
|
8125
|
+
const locale = await validateLocale(query?.locale) ?? void 0;
|
|
8160
8126
|
const entity = await strapi.documents(modelUID).findOne({
|
|
8161
8127
|
documentId,
|
|
8162
|
-
// @ts-expect-error - locale should be also null in the doc service types
|
|
8163
8128
|
locale,
|
|
8164
8129
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
8165
8130
|
});
|
|
@@ -8168,12 +8133,13 @@ const stages = {
|
|
|
8168
8133
|
}
|
|
8169
8134
|
const entityStageId = entity[ENTITY_STAGE_ATTRIBUTE]?.id;
|
|
8170
8135
|
const canTransition = stagePermissions2.can(STAGE_TRANSITION_UID, entityStageId);
|
|
8171
|
-
const [workflowCount,
|
|
8136
|
+
const [workflowCount, workflowResult] = await Promise.all([
|
|
8172
8137
|
workflowService.count(),
|
|
8173
8138
|
workflowService.getAssignedWorkflow(modelUID, {
|
|
8174
8139
|
populate: "stages"
|
|
8175
8140
|
})
|
|
8176
8141
|
]);
|
|
8142
|
+
const workflowStages = workflowResult ? workflowResult.stages : [];
|
|
8177
8143
|
const meta = {
|
|
8178
8144
|
stageCount: workflowStages.length,
|
|
8179
8145
|
workflowCount
|
|
@@ -8209,22 +8175,37 @@ const assignees = {
|
|
|
8209
8175
|
async updateEntity(ctx) {
|
|
8210
8176
|
const assigneeService = getService("assignees");
|
|
8211
8177
|
const workflowService = getService("workflows");
|
|
8178
|
+
const stagePermissions2 = getService("stage-permissions");
|
|
8212
8179
|
const { model_uid: model, id: documentId } = ctx.params;
|
|
8213
|
-
const
|
|
8180
|
+
const locale = await validateLocale(ctx.request.query?.locale) ?? void 0;
|
|
8214
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
|
+
}
|
|
8215
8197
|
const { id: assigneeId } = await validateUpdateAssigneeOnEntity(
|
|
8216
8198
|
ctx.request?.body?.data,
|
|
8217
8199
|
"You should pass a valid id to the body of the put request."
|
|
8218
8200
|
);
|
|
8219
|
-
await validateLocale(locale);
|
|
8220
8201
|
await workflowService.assertContentTypeBelongsToWorkflow(model);
|
|
8221
|
-
const
|
|
8202
|
+
const updatedEntity = await assigneeService.updateEntityAssignee(
|
|
8222
8203
|
documentId,
|
|
8223
8204
|
locale || null,
|
|
8224
8205
|
model,
|
|
8225
8206
|
assigneeId
|
|
8226
8207
|
);
|
|
8227
|
-
ctx.body = { data: await sanitizeOutput(
|
|
8208
|
+
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8228
8209
|
}
|
|
8229
8210
|
};
|
|
8230
8211
|
const controllers = {
|