@strapi/review-workflows 0.0.0-next.959c5589d0d3efa25d7ca014656d9ff48c173399 → 0.0.0-next.b0db56479de441dfe8feb37a43c7f6f6fecf75c1
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-C_uZ98Uf.mjs → Layout-BIIxkAtf.mjs} +3 -3
- package/dist/_chunks/Layout-BIIxkAtf.mjs.map +1 -0
- package/dist/_chunks/{Layout-b_msoxIP.js → Layout-BWNbQOes.js} +3 -3
- package/dist/_chunks/Layout-BWNbQOes.js.map +1 -0
- package/dist/_chunks/{en-xcewH2pC.js → en-CYgjfSep.js} +5 -2
- package/dist/_chunks/en-CYgjfSep.js.map +1 -0
- package/dist/_chunks/{en-D9ZrQAV6.mjs → en-D9dxziEb.mjs} +5 -2
- package/dist/_chunks/en-D9dxziEb.mjs.map +1 -0
- package/dist/_chunks/{_id-4xBYY7wK.js → id-CaHzMdxL.js} +72 -12
- package/dist/_chunks/id-CaHzMdxL.js.map +1 -0
- package/dist/_chunks/{_id-mkPbu6GX.mjs → id-CtcCl3zh.mjs} +72 -12
- package/dist/_chunks/id-CtcCl3zh.mjs.map +1 -0
- package/dist/_chunks/{index-C5NgBQMb.js → index-BX5MyocW.js} +3 -3
- package/dist/_chunks/{index-C5NgBQMb.js.map → index-BX5MyocW.js.map} +1 -1
- package/dist/_chunks/{index-DL8-Q4Q5.mjs → index-ByTEmYbc.mjs} +3 -3
- package/dist/_chunks/{index-DL8-Q4Q5.mjs.map → index-ByTEmYbc.mjs.map} +1 -1
- package/dist/_chunks/{index-D_k4wfAN.mjs → index-CGmh3cED.mjs} +3 -3
- package/dist/_chunks/{index-D_k4wfAN.mjs.map → index-CGmh3cED.mjs.map} +1 -1
- package/dist/_chunks/{index-CIGzoVfk.js → index-DKLk-Z5E.js} +3 -3
- package/dist/_chunks/{index-CIGzoVfk.js.map → index-DKLk-Z5E.js.map} +1 -1
- package/dist/_chunks/{router-BFr5lHsE.js → router-Bt6JHY-e.js} +3 -3
- package/dist/_chunks/router-Bt6JHY-e.js.map +1 -0
- package/dist/_chunks/{router-DnQKLQOJ.mjs → router-Cr3nulh9.mjs} +3 -3
- package/dist/_chunks/router-Cr3nulh9.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/services/settings.d.ts +7 -3
- package/dist/server/index.js +142 -49
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +142 -49
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/constants/workflows.d.ts +1 -0
- package/dist/server/src/constants/workflows.d.ts.map +1 -1
- package/dist/server/src/content-types/index.d.ts +6 -0
- package/dist/server/src/content-types/index.d.ts.map +1 -1
- package/dist/server/src/content-types/workflow/index.d.ts +6 -0
- package/dist/server/src/content-types/workflow/index.d.ts.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 +28 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/assignees.d.ts +8 -4
- package/dist/server/src/services/assignees.d.ts.map +1 -1
- package/dist/server/src/services/document-service-middleware.d.ts +1 -0
- package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +16 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/metrics/index.d.ts +4 -4
- package/dist/server/src/services/metrics/index.d.ts.map +1 -1
- package/dist/server/src/services/stages.d.ts +6 -1
- package/dist/server/src/services/stages.d.ts.map +1 -1
- package/dist/server/src/services/workflows.d.ts.map +1 -1
- package/dist/server/src/validation/review-workflows.d.ts +4 -0
- package/dist/server/src/validation/review-workflows.d.ts.map +1 -1
- package/dist/shared/contracts/review-workflows.d.ts +8 -3
- package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/_chunks/Layout-C_uZ98Uf.mjs.map +0 -1
- package/dist/_chunks/Layout-b_msoxIP.js.map +0 -1
- package/dist/_chunks/_id-4xBYY7wK.js.map +0 -1
- package/dist/_chunks/_id-mkPbu6GX.mjs.map +0 -1
- package/dist/_chunks/en-D9ZrQAV6.mjs.map +0 -1
- package/dist/_chunks/en-xcewH2pC.js.map +0 -1
- package/dist/_chunks/router-BFr5lHsE.js.map +0 -1
- package/dist/_chunks/router-DnQKLQOJ.mjs.map +0 -1
- /package/dist/admin/src/routes/settings/{:id.d.ts → id.d.ts} +0 -0
package/dist/server/index.mjs
CHANGED
|
@@ -6386,7 +6386,8 @@ const WORKFLOW_POPULATE = {
|
|
|
6386
6386
|
}
|
|
6387
6387
|
}
|
|
6388
6388
|
}
|
|
6389
|
-
}
|
|
6389
|
+
},
|
|
6390
|
+
stageRequiredToPublish: true
|
|
6390
6391
|
};
|
|
6391
6392
|
function checkVersionThreshold(startVersion, currentVersion, thresholdVersion) {
|
|
6392
6393
|
return semver$1.gte(currentVersion, thresholdVersion) && semver$1.lt(startVersion, thresholdVersion);
|
|
@@ -6561,8 +6562,40 @@ function extendReviewWorkflowContentTypes({ strapi: strapi2 }) {
|
|
|
6561
6562
|
});
|
|
6562
6563
|
}
|
|
6563
6564
|
}
|
|
6565
|
+
function persistRWOnDowngrade({ strapi: strapi2 }) {
|
|
6566
|
+
const { removePersistedTablesWithSuffix, persistTables } = getAdminService("persist-tables");
|
|
6567
|
+
return async ({ contentTypes: contentTypes2 }) => {
|
|
6568
|
+
const getStageTableToPersist = (contentTypeUID) => {
|
|
6569
|
+
const { attributes, tableName } = strapi2.db.metadata.get(contentTypeUID);
|
|
6570
|
+
const joinTableName = attributes[ENTITY_STAGE_ATTRIBUTE].joinTable.name;
|
|
6571
|
+
return {
|
|
6572
|
+
name: joinTableName,
|
|
6573
|
+
dependsOn: [{ name: tableName }]
|
|
6574
|
+
};
|
|
6575
|
+
};
|
|
6576
|
+
const getAssigneeTableToPersist = (contentTypeUID) => {
|
|
6577
|
+
const { attributes, tableName } = strapi2.db.metadata.get(contentTypeUID);
|
|
6578
|
+
const joinTableName = attributes[ENTITY_ASSIGNEE_ATTRIBUTE].joinTable.name;
|
|
6579
|
+
return {
|
|
6580
|
+
name: joinTableName,
|
|
6581
|
+
dependsOn: [{ name: tableName }]
|
|
6582
|
+
};
|
|
6583
|
+
};
|
|
6584
|
+
const enabledRWContentTypes = fp.pipe([
|
|
6585
|
+
getVisibleContentTypesUID,
|
|
6586
|
+
fp.filter((uid) => hasStageAttribute(contentTypes2[uid]))
|
|
6587
|
+
])(contentTypes2);
|
|
6588
|
+
const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);
|
|
6589
|
+
await removePersistedTablesWithSuffix("_strapi_stage_lnk");
|
|
6590
|
+
await persistTables(stageJoinTablesToPersist);
|
|
6591
|
+
const assigneeJoinTablesToPersist = enabledRWContentTypes.map(getAssigneeTableToPersist);
|
|
6592
|
+
await removePersistedTablesWithSuffix("_strapi_assignee_lnk");
|
|
6593
|
+
await persistTables(assigneeJoinTablesToPersist);
|
|
6594
|
+
};
|
|
6595
|
+
}
|
|
6564
6596
|
const register = async ({ strapi: strapi2 }) => {
|
|
6565
6597
|
strapi2.hook("strapi::content-types.beforeSync").register(migrateStageAttribute);
|
|
6598
|
+
strapi2.hook("strapi::content-types.afterSync").register(persistRWOnDowngrade({ strapi: strapi2 }));
|
|
6566
6599
|
strapi2.hook("strapi::content-types.afterSync").register(migrateReviewWorkflowStagesColor).register(migrateReviewWorkflowStagesRoles).register(migrateReviewWorkflowName).register(migrateWorkflowsContentTypes).register(migrateDeletedCTInWorkflows);
|
|
6567
6600
|
reviewWorkflowsMiddlewares.contentTypeMiddleware(strapi2);
|
|
6568
6601
|
extendReviewWorkflowContentTypes({ strapi: strapi2 });
|
|
@@ -6607,6 +6640,12 @@ const workflow = {
|
|
|
6607
6640
|
relation: "oneToMany",
|
|
6608
6641
|
mappedBy: "workflow"
|
|
6609
6642
|
},
|
|
6643
|
+
stageRequiredToPublish: {
|
|
6644
|
+
type: "relation",
|
|
6645
|
+
target: "plugin::review-workflows.workflow-stage",
|
|
6646
|
+
relation: "oneToOne",
|
|
6647
|
+
required: false
|
|
6648
|
+
},
|
|
6610
6649
|
contentTypes: {
|
|
6611
6650
|
type: "json",
|
|
6612
6651
|
required: true,
|
|
@@ -6756,6 +6795,7 @@ const bootstrap = async (args) => {
|
|
|
6756
6795
|
const docsMiddlewares = getService("document-service-middlewares");
|
|
6757
6796
|
strapi.documents.use(docsMiddlewares.assignStageOnCreate);
|
|
6758
6797
|
strapi.documents.use(docsMiddlewares.handleStageOnUpdate);
|
|
6798
|
+
strapi.documents.use(docsMiddlewares.checkStageBeforePublish);
|
|
6759
6799
|
};
|
|
6760
6800
|
const destroy = async ({ strapi: strapi2 }) => {
|
|
6761
6801
|
};
|
|
@@ -6988,9 +7028,9 @@ const processFilters = ({ strapi: strapi2 }, filters = {}) => {
|
|
|
6988
7028
|
};
|
|
6989
7029
|
const processPopulate = (populate) => {
|
|
6990
7030
|
if (!populate) {
|
|
6991
|
-
return
|
|
7031
|
+
return WORKFLOW_POPULATE;
|
|
6992
7032
|
}
|
|
6993
|
-
return
|
|
7033
|
+
return populate;
|
|
6994
7034
|
};
|
|
6995
7035
|
const workflows$1 = ({ strapi: strapi2 }) => {
|
|
6996
7036
|
const workflowsContentTypes = workflowsContentTypesFactory({ strapi: strapi2 });
|
|
@@ -7041,14 +7081,27 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7041
7081
|
const stages2 = await getService("stages", { strapi: strapi2 }).createMany(opts.data.stages);
|
|
7042
7082
|
const mapIds = fp.map(fp.get("id"));
|
|
7043
7083
|
createOpts = fp.set("data.stages", mapIds(stages2), createOpts);
|
|
7084
|
+
if (opts.data.stageRequiredToPublishName) {
|
|
7085
|
+
const stageRequiredToPublish = stages2.find(
|
|
7086
|
+
(stage) => stage.name === opts.data.stageRequiredToPublishName
|
|
7087
|
+
);
|
|
7088
|
+
if (!stageRequiredToPublish) {
|
|
7089
|
+
throw new errors.ApplicationError("Stage required to publish does not exist");
|
|
7090
|
+
}
|
|
7091
|
+
createOpts = fp.set("data.stageRequiredToPublish", stageRequiredToPublish.id, createOpts);
|
|
7092
|
+
}
|
|
7044
7093
|
if (opts.data.contentTypes) {
|
|
7045
7094
|
await workflowsContentTypes.migrate({
|
|
7046
7095
|
destContentTypes: opts.data.contentTypes,
|
|
7047
7096
|
stageId: stages2[0].id
|
|
7048
7097
|
});
|
|
7049
7098
|
}
|
|
7050
|
-
|
|
7051
|
-
|
|
7099
|
+
const createdWorkflow = await strapi2.db.query(WORKFLOW_MODEL_UID).create(strapi2.get("query-params").transform(WORKFLOW_MODEL_UID, createOpts));
|
|
7100
|
+
metrics.sendDidCreateWorkflow(createdWorkflow.id, !!opts.data.stageRequiredToPublishName);
|
|
7101
|
+
if (opts.data.stageRequiredToPublishName) {
|
|
7102
|
+
await strapi2.plugin("content-releases").service("release-action").validateActionsByContentTypes(opts.data.contentTypes);
|
|
7103
|
+
}
|
|
7104
|
+
return createdWorkflow;
|
|
7052
7105
|
});
|
|
7053
7106
|
},
|
|
7054
7107
|
/**
|
|
@@ -7061,6 +7114,7 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7061
7114
|
async update(workflow2, opts) {
|
|
7062
7115
|
const stageService = getService("stages", { strapi: strapi2 });
|
|
7063
7116
|
let updateOpts = { ...opts, populate: { ...WORKFLOW_POPULATE } };
|
|
7117
|
+
let updatedStages = [];
|
|
7064
7118
|
let updatedStageIds;
|
|
7065
7119
|
await workflowValidator.validateWorkflowCount();
|
|
7066
7120
|
return strapi2.db.transaction(async () => {
|
|
@@ -7069,9 +7123,28 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7069
7123
|
opts.data.stages.forEach(
|
|
7070
7124
|
(stage) => this.assertStageBelongsToWorkflow(stage.id, workflow2)
|
|
7071
7125
|
);
|
|
7072
|
-
|
|
7126
|
+
updatedStages = await stageService.replaceStages(
|
|
7127
|
+
workflow2.stages,
|
|
7128
|
+
opts.data.stages,
|
|
7129
|
+
workflow2.contentTypes
|
|
7130
|
+
);
|
|
7131
|
+
updatedStageIds = updatedStages.map((stage) => stage.id);
|
|
7073
7132
|
updateOpts = fp.set("data.stages", updatedStageIds, updateOpts);
|
|
7074
7133
|
}
|
|
7134
|
+
if (opts.data.stageRequiredToPublishName !== void 0) {
|
|
7135
|
+
const stages2 = updatedStages ?? workflow2.stages;
|
|
7136
|
+
if (opts.data.stageRequiredToPublishName === null) {
|
|
7137
|
+
updateOpts = fp.set("data.stageRequiredToPublish", null, updateOpts);
|
|
7138
|
+
} else {
|
|
7139
|
+
const stageRequiredToPublish = stages2.find(
|
|
7140
|
+
(stage) => stage.name === opts.data.stageRequiredToPublishName
|
|
7141
|
+
);
|
|
7142
|
+
if (!stageRequiredToPublish) {
|
|
7143
|
+
throw new errors.ApplicationError("Stage required to publish does not exist");
|
|
7144
|
+
}
|
|
7145
|
+
updateOpts = fp.set("data.stageRequiredToPublish", stageRequiredToPublish.id, updateOpts);
|
|
7146
|
+
}
|
|
7147
|
+
}
|
|
7075
7148
|
if (opts.data.contentTypes) {
|
|
7076
7149
|
await workflowsContentTypes.migrate({
|
|
7077
7150
|
srcContentTypes: workflow2.contentTypes,
|
|
@@ -7079,12 +7152,17 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7079
7152
|
stageId: updatedStageIds ? updatedStageIds[0] : workflow2.stages[0].id
|
|
7080
7153
|
});
|
|
7081
7154
|
}
|
|
7082
|
-
metrics.sendDidEditWorkflow();
|
|
7155
|
+
metrics.sendDidEditWorkflow(workflow2.id, !!opts.data.stageRequiredToPublishName);
|
|
7083
7156
|
const query = strapi2.get("query-params").transform(WORKFLOW_MODEL_UID, updateOpts);
|
|
7084
|
-
|
|
7157
|
+
const updatedWorkflow = await strapi2.db.query(WORKFLOW_MODEL_UID).update({
|
|
7085
7158
|
...query,
|
|
7086
7159
|
where: { id: workflow2.id }
|
|
7087
7160
|
});
|
|
7161
|
+
await strapi2.plugin("content-releases").service("release-action").validateActionsByContentTypes([
|
|
7162
|
+
...workflow2.contentTypes,
|
|
7163
|
+
...opts.data.contentTypes || []
|
|
7164
|
+
]);
|
|
7165
|
+
return updatedWorkflow;
|
|
7088
7166
|
});
|
|
7089
7167
|
},
|
|
7090
7168
|
/**
|
|
@@ -7107,10 +7185,12 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7107
7185
|
destContentTypes: []
|
|
7108
7186
|
});
|
|
7109
7187
|
const query = strapi2.get("query-params").transform(WORKFLOW_MODEL_UID, opts);
|
|
7110
|
-
|
|
7188
|
+
const deletedWorkflow = await strapi2.db.query(WORKFLOW_MODEL_UID).delete({
|
|
7111
7189
|
...query,
|
|
7112
7190
|
where: { id: workflow2.id }
|
|
7113
7191
|
});
|
|
7192
|
+
await strapi2.plugin("content-releases").service("release-action").validateActionsByContentTypes(workflow2.contentTypes);
|
|
7193
|
+
return deletedWorkflow;
|
|
7114
7194
|
});
|
|
7115
7195
|
},
|
|
7116
7196
|
/**
|
|
@@ -7322,8 +7402,9 @@ const stages$1 = ({ strapi: strapi2 }) => {
|
|
|
7322
7402
|
/**
|
|
7323
7403
|
* Update the stage of an entity
|
|
7324
7404
|
*/
|
|
7325
|
-
async updateEntity(
|
|
7405
|
+
async updateEntity(entityToUpdate, model, stageId) {
|
|
7326
7406
|
const stage = await this.findById(stageId);
|
|
7407
|
+
const { documentId, locale } = entityToUpdate;
|
|
7327
7408
|
await workflowValidator.validateWorkflowCount();
|
|
7328
7409
|
if (!stage) {
|
|
7329
7410
|
throw new ApplicationError$2(`Selected stage does not exist`);
|
|
@@ -7331,9 +7412,15 @@ const stages$1 = ({ strapi: strapi2 }) => {
|
|
|
7331
7412
|
const entity = await strapi2.documents(model).update({
|
|
7332
7413
|
documentId,
|
|
7333
7414
|
locale,
|
|
7334
|
-
|
|
7415
|
+
// Stage doesn't have DP or i18n enabled, connecting it through the `id`
|
|
7416
|
+
// will be safer than relying on the `documentId` + `locale` + `status` transformation
|
|
7417
|
+
data: { [ENTITY_STAGE_ATTRIBUTE]: fp.pick(["id"], stage) },
|
|
7335
7418
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
7336
7419
|
});
|
|
7420
|
+
const { tableName } = strapi2.db.metadata.get(model);
|
|
7421
|
+
await strapi2.db.connection(tableName).where({ id: entityToUpdate.id }).update({
|
|
7422
|
+
updated_at: new Date(entityToUpdate.updatedAt)
|
|
7423
|
+
});
|
|
7337
7424
|
metrics.sendDidChangeEntryStage();
|
|
7338
7425
|
return entity;
|
|
7339
7426
|
},
|
|
@@ -7480,32 +7567,28 @@ const assignees$1 = ({ strapi: strapi2 }) => {
|
|
|
7480
7567
|
/**
|
|
7481
7568
|
* Update the assignee of an entity
|
|
7482
7569
|
*/
|
|
7483
|
-
async updateEntityAssignee(
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7570
|
+
async updateEntityAssignee(entityToUpdate, model, assigneeId) {
|
|
7571
|
+
const { documentId, locale } = entityToUpdate;
|
|
7572
|
+
if (!fp.isNil(assigneeId)) {
|
|
7573
|
+
const userExists = await getAdminService("user", { strapi: strapi2 }).exists({ id: assigneeId });
|
|
7574
|
+
if (!userExists) {
|
|
7575
|
+
throw new ApplicationError(`Selected user does not exist`);
|
|
7576
|
+
}
|
|
7490
7577
|
}
|
|
7491
|
-
|
|
7492
|
-
|
|
7578
|
+
const oldAssigneeId = await this.findEntityAssigneeId(entityToUpdate.id, model);
|
|
7579
|
+
metrics.sendDidEditAssignee(oldAssigneeId, assigneeId || null);
|
|
7580
|
+
const entity = await strapi2.documents(model).update({
|
|
7493
7581
|
documentId,
|
|
7494
7582
|
locale,
|
|
7495
|
-
data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: assigneeId },
|
|
7583
|
+
data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: assigneeId || null },
|
|
7496
7584
|
populate: [ENTITY_ASSIGNEE_ATTRIBUTE],
|
|
7497
7585
|
fields: []
|
|
7498
7586
|
});
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
return strapi2.documents(model).update({
|
|
7503
|
-
documentId,
|
|
7504
|
-
locale,
|
|
7505
|
-
data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: null },
|
|
7506
|
-
populate: [ENTITY_ASSIGNEE_ATTRIBUTE],
|
|
7507
|
-
fields: []
|
|
7587
|
+
const { tableName } = strapi2.db.metadata.get(model);
|
|
7588
|
+
await strapi2.db.connection(tableName).where({ id: entityToUpdate.id }).update({
|
|
7589
|
+
updated_at: new Date(entityToUpdate.updatedAt)
|
|
7508
7590
|
});
|
|
7591
|
+
return entity;
|
|
7509
7592
|
}
|
|
7510
7593
|
};
|
|
7511
7594
|
};
|
|
@@ -7578,11 +7661,11 @@ const sendDidDeleteStage = async () => {
|
|
|
7578
7661
|
const sendDidChangeEntryStage = async () => {
|
|
7579
7662
|
strapi.telemetry.send("didChangeEntryStage", {});
|
|
7580
7663
|
};
|
|
7581
|
-
const sendDidCreateWorkflow = async () => {
|
|
7582
|
-
strapi.telemetry.send("didCreateWorkflow", {});
|
|
7664
|
+
const sendDidCreateWorkflow = async (workflowId, hasRequiredStageToPublish) => {
|
|
7665
|
+
strapi.telemetry.send("didCreateWorkflow", { workflowId, hasRequiredStageToPublish });
|
|
7583
7666
|
};
|
|
7584
|
-
const sendDidEditWorkflow = async () => {
|
|
7585
|
-
strapi.telemetry.send("didEditWorkflow", {});
|
|
7667
|
+
const sendDidEditWorkflow = async (workflowId, hasRequiredStageToPublish) => {
|
|
7668
|
+
strapi.telemetry.send("didEditWorkflow", { workflowId, hasRequiredStageToPublish });
|
|
7586
7669
|
};
|
|
7587
7670
|
const sendDidEditAssignee = async (fromId, toId) => {
|
|
7588
7671
|
strapi.telemetry.send("didEditAssignee", { from: fromId, to: toId });
|
|
@@ -7835,9 +7918,27 @@ const handleStageOnUpdate = async (ctx, next) => {
|
|
|
7835
7918
|
}
|
|
7836
7919
|
return next();
|
|
7837
7920
|
};
|
|
7921
|
+
const checkStageBeforePublish = async (ctx, next) => {
|
|
7922
|
+
if (ctx.action !== "publish") {
|
|
7923
|
+
return next();
|
|
7924
|
+
}
|
|
7925
|
+
const workflow2 = await getService("workflows").getAssignedWorkflow(ctx.contentType.uid, {
|
|
7926
|
+
populate: "stageRequiredToPublish"
|
|
7927
|
+
});
|
|
7928
|
+
if (!workflow2 || !workflow2.stageRequiredToPublish) {
|
|
7929
|
+
return next();
|
|
7930
|
+
}
|
|
7931
|
+
const { documentId } = ctx.params;
|
|
7932
|
+
const entryStage = await getEntityStage(ctx.contentType.uid, documentId, ctx.params);
|
|
7933
|
+
if (entryStage.id !== workflow2.stageRequiredToPublish.id) {
|
|
7934
|
+
throw new errors.ValidationError("Entry is not at the required stage to publish");
|
|
7935
|
+
}
|
|
7936
|
+
return next();
|
|
7937
|
+
};
|
|
7838
7938
|
const documentServiceMiddleware = () => ({
|
|
7839
7939
|
assignStageOnCreate,
|
|
7840
|
-
handleStageOnUpdate
|
|
7940
|
+
handleStageOnUpdate,
|
|
7941
|
+
checkStageBeforePublish
|
|
7841
7942
|
});
|
|
7842
7943
|
const services = {
|
|
7843
7944
|
workflows: workflows$1,
|
|
@@ -7887,12 +7988,14 @@ const validateContentTypes = yup.array().of(
|
|
|
7887
7988
|
const validateWorkflowCreateSchema = yup.object().shape({
|
|
7888
7989
|
name: yup.string().max(255).min(1, "Workflow name can not be empty").required(),
|
|
7889
7990
|
stages: yup.array().of(stageObject).uniqueProperty("name", "Stage name must be unique").min(1, "Can not create a workflow without stages").max(200, "Can not have more than 200 stages").required("Can not create a workflow without stages"),
|
|
7890
|
-
contentTypes: validateContentTypes
|
|
7991
|
+
contentTypes: validateContentTypes,
|
|
7992
|
+
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7891
7993
|
});
|
|
7892
7994
|
const validateWorkflowUpdateSchema = yup.object().shape({
|
|
7893
7995
|
name: yup.string().max(255).min(1, "Workflow name can not be empty"),
|
|
7894
7996
|
stages: yup.array().of(stageObject).uniqueProperty("name", "Stage name must be unique").min(1, "Can not update a workflow without stages").max(200, "Can not have more than 200 stages"),
|
|
7895
|
-
contentTypes: validateContentTypes
|
|
7997
|
+
contentTypes: validateContentTypes,
|
|
7998
|
+
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7896
7999
|
});
|
|
7897
8000
|
const validateUpdateAssigneeOnEntitySchema = yup.object().shape({
|
|
7898
8001
|
id: yup.number().integer().min(1).nullable()
|
|
@@ -8095,12 +8198,7 @@ const stages = {
|
|
|
8095
8198
|
);
|
|
8096
8199
|
const workflow2 = await workflowService.assertContentTypeBelongsToWorkflow(modelUID);
|
|
8097
8200
|
workflowService.assertStageBelongsToWorkflow(stageId, workflow2);
|
|
8098
|
-
const updatedEntity = await stagesService.updateEntity(
|
|
8099
|
-
entity.documentId,
|
|
8100
|
-
entity.locale,
|
|
8101
|
-
modelUID,
|
|
8102
|
-
stageId
|
|
8103
|
-
);
|
|
8201
|
+
const updatedEntity = await stagesService.updateEntity(entity, modelUID, stageId);
|
|
8104
8202
|
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8105
8203
|
},
|
|
8106
8204
|
/**
|
|
@@ -8197,12 +8295,7 @@ const assignees = {
|
|
|
8197
8295
|
"You should pass a valid id to the body of the put request."
|
|
8198
8296
|
);
|
|
8199
8297
|
await workflowService.assertContentTypeBelongsToWorkflow(model);
|
|
8200
|
-
const updatedEntity = await assigneeService.updateEntityAssignee(
|
|
8201
|
-
documentId,
|
|
8202
|
-
locale || null,
|
|
8203
|
-
model,
|
|
8204
|
-
assigneeId
|
|
8205
|
-
);
|
|
8298
|
+
const updatedEntity = await assigneeService.updateEntityAssignee(entity, model, assigneeId);
|
|
8206
8299
|
ctx.body = { data: await sanitizeOutput(updatedEntity) };
|
|
8207
8300
|
}
|
|
8208
8301
|
};
|