@strapi/review-workflows 0.0.0-experimental.fd379e4937e431407d784eaa5fe7f93cf2a53386 → 0.0.0-experimental.fdacf4285d1cada9d94ab4dcd756c5362cba1b54
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-b_msoxIP.js → Layout-COeOgRsc.js} +3 -3
- package/dist/_chunks/Layout-COeOgRsc.js.map +1 -0
- package/dist/_chunks/{Layout-C_uZ98Uf.mjs → Layout-CefL-rfa.mjs} +3 -3
- package/dist/_chunks/Layout-CefL-rfa.mjs.map +1 -0
- package/dist/_chunks/{_id-mkPbu6GX.mjs → _id-Dt2oEiro.mjs} +73 -12
- package/dist/_chunks/_id-Dt2oEiro.mjs.map +1 -0
- package/dist/_chunks/{_id-4xBYY7wK.js → _id-PmPKIqUm.js} +73 -12
- package/dist/_chunks/_id-PmPKIqUm.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/{index-D_k4wfAN.mjs → index-DJtnx2X1.mjs} +3 -3
- package/dist/_chunks/{index-D_k4wfAN.mjs.map → index-DJtnx2X1.mjs.map} +1 -1
- package/dist/_chunks/{index-C5NgBQMb.js → index-DiWo3Pu2.js} +6 -3
- package/dist/_chunks/{index-C5NgBQMb.js.map → index-DiWo3Pu2.js.map} +1 -1
- package/dist/_chunks/{index-DL8-Q4Q5.mjs → index-IZXxuQ4h.mjs} +6 -3
- package/dist/_chunks/{index-DL8-Q4Q5.mjs.map → index-IZXxuQ4h.mjs.map} +1 -1
- package/dist/_chunks/{index-CIGzoVfk.js → index-p25R0AkB.js} +3 -3
- package/dist/_chunks/{index-CIGzoVfk.js.map → index-p25R0AkB.js.map} +1 -1
- package/dist/_chunks/{router-BFr5lHsE.js → router-C8mPPFJk.js} +3 -3
- package/dist/_chunks/{router-BFr5lHsE.js.map → router-C8mPPFJk.js.map} +1 -1
- package/dist/_chunks/{router-DnQKLQOJ.mjs → router-DJCVv74P.mjs} +3 -3
- package/dist/_chunks/{router-DnQKLQOJ.mjs.map → router-DJCVv74P.mjs.map} +1 -1
- 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 +71 -19
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +71 -19
- 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/index.d.ts +13 -0
- package/dist/server/src/index.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 +1 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/metrics/weekly-metrics.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 +6 -6
- 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/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);
|
|
@@ -6607,6 +6608,12 @@ const workflow = {
|
|
|
6607
6608
|
relation: "oneToMany",
|
|
6608
6609
|
mappedBy: "workflow"
|
|
6609
6610
|
},
|
|
6611
|
+
stageRequiredToPublish: {
|
|
6612
|
+
type: "relation",
|
|
6613
|
+
target: "plugin::review-workflows.workflow-stage",
|
|
6614
|
+
relation: "oneToOne",
|
|
6615
|
+
required: false
|
|
6616
|
+
},
|
|
6610
6617
|
contentTypes: {
|
|
6611
6618
|
type: "json",
|
|
6612
6619
|
required: true,
|
|
@@ -6756,6 +6763,7 @@ const bootstrap = async (args) => {
|
|
|
6756
6763
|
const docsMiddlewares = getService("document-service-middlewares");
|
|
6757
6764
|
strapi.documents.use(docsMiddlewares.assignStageOnCreate);
|
|
6758
6765
|
strapi.documents.use(docsMiddlewares.handleStageOnUpdate);
|
|
6766
|
+
strapi.documents.use(docsMiddlewares.checkStageBeforePublish);
|
|
6759
6767
|
};
|
|
6760
6768
|
const destroy = async ({ strapi: strapi2 }) => {
|
|
6761
6769
|
};
|
|
@@ -6988,9 +6996,9 @@ const processFilters = ({ strapi: strapi2 }, filters = {}) => {
|
|
|
6988
6996
|
};
|
|
6989
6997
|
const processPopulate = (populate) => {
|
|
6990
6998
|
if (!populate) {
|
|
6991
|
-
return
|
|
6999
|
+
return WORKFLOW_POPULATE;
|
|
6992
7000
|
}
|
|
6993
|
-
return
|
|
7001
|
+
return populate;
|
|
6994
7002
|
};
|
|
6995
7003
|
const workflows$1 = ({ strapi: strapi2 }) => {
|
|
6996
7004
|
const workflowsContentTypes = workflowsContentTypesFactory({ strapi: strapi2 });
|
|
@@ -7041,6 +7049,15 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7041
7049
|
const stages2 = await getService("stages", { strapi: strapi2 }).createMany(opts.data.stages);
|
|
7042
7050
|
const mapIds = fp.map(fp.get("id"));
|
|
7043
7051
|
createOpts = fp.set("data.stages", mapIds(stages2), createOpts);
|
|
7052
|
+
if (opts.data.stageRequiredToPublishName) {
|
|
7053
|
+
const stageRequiredToPublish = stages2.find(
|
|
7054
|
+
(stage) => stage.name === opts.data.stageRequiredToPublishName
|
|
7055
|
+
);
|
|
7056
|
+
if (!stageRequiredToPublish) {
|
|
7057
|
+
throw new errors.ApplicationError("Stage required to publish does not exist");
|
|
7058
|
+
}
|
|
7059
|
+
createOpts = fp.set("data.stageRequiredToPublish", stageRequiredToPublish.id, createOpts);
|
|
7060
|
+
}
|
|
7044
7061
|
if (opts.data.contentTypes) {
|
|
7045
7062
|
await workflowsContentTypes.migrate({
|
|
7046
7063
|
destContentTypes: opts.data.contentTypes,
|
|
@@ -7061,6 +7078,7 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7061
7078
|
async update(workflow2, opts) {
|
|
7062
7079
|
const stageService = getService("stages", { strapi: strapi2 });
|
|
7063
7080
|
let updateOpts = { ...opts, populate: { ...WORKFLOW_POPULATE } };
|
|
7081
|
+
let updatedStages = [];
|
|
7064
7082
|
let updatedStageIds;
|
|
7065
7083
|
await workflowValidator.validateWorkflowCount();
|
|
7066
7084
|
return strapi2.db.transaction(async () => {
|
|
@@ -7069,9 +7087,28 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7069
7087
|
opts.data.stages.forEach(
|
|
7070
7088
|
(stage) => this.assertStageBelongsToWorkflow(stage.id, workflow2)
|
|
7071
7089
|
);
|
|
7072
|
-
|
|
7090
|
+
updatedStages = await stageService.replaceStages(
|
|
7091
|
+
workflow2.stages,
|
|
7092
|
+
opts.data.stages,
|
|
7093
|
+
workflow2.contentTypes
|
|
7094
|
+
);
|
|
7095
|
+
updatedStageIds = updatedStages.map((stage) => stage.id);
|
|
7073
7096
|
updateOpts = fp.set("data.stages", updatedStageIds, updateOpts);
|
|
7074
7097
|
}
|
|
7098
|
+
if (opts.data.stageRequiredToPublishName !== void 0) {
|
|
7099
|
+
const stages2 = updatedStages ?? workflow2.stages;
|
|
7100
|
+
if (opts.data.stageRequiredToPublishName === null) {
|
|
7101
|
+
updateOpts = fp.set("data.stageRequiredToPublish", null, updateOpts);
|
|
7102
|
+
} else {
|
|
7103
|
+
const stageRequiredToPublish = stages2.find(
|
|
7104
|
+
(stage) => stage.name === opts.data.stageRequiredToPublishName
|
|
7105
|
+
);
|
|
7106
|
+
if (!stageRequiredToPublish) {
|
|
7107
|
+
throw new errors.ApplicationError("Stage required to publish does not exist");
|
|
7108
|
+
}
|
|
7109
|
+
updateOpts = fp.set("data.stageRequiredToPublish", stageRequiredToPublish.id, updateOpts);
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7075
7112
|
if (opts.data.contentTypes) {
|
|
7076
7113
|
await workflowsContentTypes.migrate({
|
|
7077
7114
|
srcContentTypes: workflow2.contentTypes,
|
|
@@ -7607,13 +7644,13 @@ const reviewWorkflowsMetrics = {
|
|
|
7607
7644
|
sendDidSendReviewWorkflowPropertiesOnceAWeek,
|
|
7608
7645
|
sendDidEditAssignee
|
|
7609
7646
|
};
|
|
7610
|
-
function _typeof(
|
|
7647
|
+
function _typeof(obj) {
|
|
7611
7648
|
"@babel/helpers - typeof";
|
|
7612
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(
|
|
7613
|
-
return typeof
|
|
7614
|
-
} : function(
|
|
7615
|
-
return
|
|
7616
|
-
}, _typeof(
|
|
7649
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
7650
|
+
return typeof obj2;
|
|
7651
|
+
} : function(obj2) {
|
|
7652
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
7653
|
+
}, _typeof(obj);
|
|
7617
7654
|
}
|
|
7618
7655
|
function toInteger(dirtyNumber) {
|
|
7619
7656
|
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
@@ -7748,12 +7785,7 @@ const reviewWorkflowsWeeklyMetrics = ({ strapi: strapi2 }) => {
|
|
|
7748
7785
|
},
|
|
7749
7786
|
async registerCron() {
|
|
7750
7787
|
const weeklySchedule = await this.ensureWeeklyStoredCronSchedule();
|
|
7751
|
-
strapi2.cron.add({
|
|
7752
|
-
reviewWorkflowsWeekly: {
|
|
7753
|
-
task: this.sendMetrics.bind(this),
|
|
7754
|
-
options: weeklySchedule
|
|
7755
|
-
}
|
|
7756
|
-
});
|
|
7788
|
+
strapi2.cron.add({ [weeklySchedule]: this.sendMetrics.bind(this) });
|
|
7757
7789
|
}
|
|
7758
7790
|
};
|
|
7759
7791
|
};
|
|
@@ -7835,9 +7867,27 @@ const handleStageOnUpdate = async (ctx, next) => {
|
|
|
7835
7867
|
}
|
|
7836
7868
|
return next();
|
|
7837
7869
|
};
|
|
7870
|
+
const checkStageBeforePublish = async (ctx, next) => {
|
|
7871
|
+
if (ctx.action !== "publish") {
|
|
7872
|
+
return next();
|
|
7873
|
+
}
|
|
7874
|
+
const workflow2 = await getService("workflows").getAssignedWorkflow(ctx.contentType.uid, {
|
|
7875
|
+
populate: "stageRequiredToPublish"
|
|
7876
|
+
});
|
|
7877
|
+
if (!workflow2 || !workflow2.stageRequiredToPublish) {
|
|
7878
|
+
return next();
|
|
7879
|
+
}
|
|
7880
|
+
const { documentId } = ctx.params;
|
|
7881
|
+
const entryStage = await getEntityStage(ctx.contentType.uid, documentId, ctx.params);
|
|
7882
|
+
if (entryStage.id !== workflow2.stageRequiredToPublish.id) {
|
|
7883
|
+
throw new errors.ValidationError("Entry is not at the required stage to publish");
|
|
7884
|
+
}
|
|
7885
|
+
return next();
|
|
7886
|
+
};
|
|
7838
7887
|
const documentServiceMiddleware = () => ({
|
|
7839
7888
|
assignStageOnCreate,
|
|
7840
|
-
handleStageOnUpdate
|
|
7889
|
+
handleStageOnUpdate,
|
|
7890
|
+
checkStageBeforePublish
|
|
7841
7891
|
});
|
|
7842
7892
|
const services = {
|
|
7843
7893
|
workflows: workflows$1,
|
|
@@ -7887,12 +7937,14 @@ const validateContentTypes = yup.array().of(
|
|
|
7887
7937
|
const validateWorkflowCreateSchema = yup.object().shape({
|
|
7888
7938
|
name: yup.string().max(255).min(1, "Workflow name can not be empty").required(),
|
|
7889
7939
|
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
|
|
7940
|
+
contentTypes: validateContentTypes,
|
|
7941
|
+
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7891
7942
|
});
|
|
7892
7943
|
const validateWorkflowUpdateSchema = yup.object().shape({
|
|
7893
7944
|
name: yup.string().max(255).min(1, "Workflow name can not be empty"),
|
|
7894
7945
|
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
|
|
7946
|
+
contentTypes: validateContentTypes,
|
|
7947
|
+
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7896
7948
|
});
|
|
7897
7949
|
const validateUpdateAssigneeOnEntitySchema = yup.object().shape({
|
|
7898
7950
|
id: yup.number().integer().min(1).nullable()
|