@strapi/review-workflows 0.0.0-next.8f63e1055db761e0213cb6610f80c55658196ae1 → 0.0.0-next.973df62640087231761ffaeb1c2b5d0d706346d8
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-C9m07iTY.mjs → Layout-BIIxkAtf.mjs} +3 -3
- package/dist/_chunks/Layout-BIIxkAtf.mjs.map +1 -0
- package/dist/_chunks/{Layout-8i0EXRRs.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-CmtaTf1x.js → id-CaHzMdxL.js} +72 -12
- package/dist/_chunks/id-CaHzMdxL.js.map +1 -0
- package/dist/_chunks/{id-DV0Ndeav.mjs → id-CtcCl3zh.mjs} +72 -12
- package/dist/_chunks/id-CtcCl3zh.mjs.map +1 -0
- package/dist/_chunks/{index-BCUO98DV.js → index-BX5MyocW.js} +3 -3
- package/dist/_chunks/{index-BCUO98DV.js.map → index-BX5MyocW.js.map} +1 -1
- package/dist/_chunks/{index-CqYVkW3E.mjs → index-ByTEmYbc.mjs} +3 -3
- package/dist/_chunks/{index-CqYVkW3E.mjs.map → index-ByTEmYbc.mjs.map} +1 -1
- package/dist/_chunks/{index-CA5Axcoc.mjs → index-CGmh3cED.mjs} +3 -3
- package/dist/_chunks/{index-CA5Axcoc.mjs.map → index-CGmh3cED.mjs.map} +1 -1
- package/dist/_chunks/{index-B8WmHbCU.js → index-DKLk-Z5E.js} +3 -3
- package/dist/_chunks/{index-B8WmHbCU.js.map → index-DKLk-Z5E.js.map} +1 -1
- package/dist/_chunks/{router-BOXlNnrU.js → router-Bt6JHY-e.js} +3 -3
- package/dist/_chunks/{router-BOXlNnrU.js.map → router-Bt6JHY-e.js.map} +1 -1
- package/dist/_chunks/{router-Jdt6SbIA.mjs → router-Cr3nulh9.mjs} +3 -3
- package/dist/_chunks/{router-Jdt6SbIA.mjs.map → router-Cr3nulh9.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 +84 -16
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +84 -16
- 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 +15 -2
- 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 +3 -2
- 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/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 +8 -8
- package/dist/_chunks/Layout-8i0EXRRs.js.map +0 -1
- package/dist/_chunks/Layout-C9m07iTY.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/id-CmtaTf1x.js.map +0 -1
- package/dist/_chunks/id-DV0Ndeav.mjs.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);
|
|
@@ -6639,6 +6640,12 @@ const workflow = {
|
|
|
6639
6640
|
relation: "oneToMany",
|
|
6640
6641
|
mappedBy: "workflow"
|
|
6641
6642
|
},
|
|
6643
|
+
stageRequiredToPublish: {
|
|
6644
|
+
type: "relation",
|
|
6645
|
+
target: "plugin::review-workflows.workflow-stage",
|
|
6646
|
+
relation: "oneToOne",
|
|
6647
|
+
required: false
|
|
6648
|
+
},
|
|
6642
6649
|
contentTypes: {
|
|
6643
6650
|
type: "json",
|
|
6644
6651
|
required: true,
|
|
@@ -6788,6 +6795,7 @@ const bootstrap = async (args) => {
|
|
|
6788
6795
|
const docsMiddlewares = getService("document-service-middlewares");
|
|
6789
6796
|
strapi.documents.use(docsMiddlewares.assignStageOnCreate);
|
|
6790
6797
|
strapi.documents.use(docsMiddlewares.handleStageOnUpdate);
|
|
6798
|
+
strapi.documents.use(docsMiddlewares.checkStageBeforePublish);
|
|
6791
6799
|
};
|
|
6792
6800
|
const destroy = async ({ strapi: strapi2 }) => {
|
|
6793
6801
|
};
|
|
@@ -7020,9 +7028,9 @@ const processFilters = ({ strapi: strapi2 }, filters = {}) => {
|
|
|
7020
7028
|
};
|
|
7021
7029
|
const processPopulate = (populate) => {
|
|
7022
7030
|
if (!populate) {
|
|
7023
|
-
return
|
|
7031
|
+
return WORKFLOW_POPULATE;
|
|
7024
7032
|
}
|
|
7025
|
-
return
|
|
7033
|
+
return populate;
|
|
7026
7034
|
};
|
|
7027
7035
|
const workflows$1 = ({ strapi: strapi2 }) => {
|
|
7028
7036
|
const workflowsContentTypes = workflowsContentTypesFactory({ strapi: strapi2 });
|
|
@@ -7073,14 +7081,27 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7073
7081
|
const stages2 = await getService("stages", { strapi: strapi2 }).createMany(opts.data.stages);
|
|
7074
7082
|
const mapIds = fp.map(fp.get("id"));
|
|
7075
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
|
+
}
|
|
7076
7093
|
if (opts.data.contentTypes) {
|
|
7077
7094
|
await workflowsContentTypes.migrate({
|
|
7078
7095
|
destContentTypes: opts.data.contentTypes,
|
|
7079
7096
|
stageId: stages2[0].id
|
|
7080
7097
|
});
|
|
7081
7098
|
}
|
|
7082
|
-
|
|
7083
|
-
|
|
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;
|
|
7084
7105
|
});
|
|
7085
7106
|
},
|
|
7086
7107
|
/**
|
|
@@ -7093,6 +7114,7 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7093
7114
|
async update(workflow2, opts) {
|
|
7094
7115
|
const stageService = getService("stages", { strapi: strapi2 });
|
|
7095
7116
|
let updateOpts = { ...opts, populate: { ...WORKFLOW_POPULATE } };
|
|
7117
|
+
let updatedStages = [];
|
|
7096
7118
|
let updatedStageIds;
|
|
7097
7119
|
await workflowValidator.validateWorkflowCount();
|
|
7098
7120
|
return strapi2.db.transaction(async () => {
|
|
@@ -7101,9 +7123,28 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7101
7123
|
opts.data.stages.forEach(
|
|
7102
7124
|
(stage) => this.assertStageBelongsToWorkflow(stage.id, workflow2)
|
|
7103
7125
|
);
|
|
7104
|
-
|
|
7126
|
+
updatedStages = await stageService.replaceStages(
|
|
7127
|
+
workflow2.stages,
|
|
7128
|
+
opts.data.stages,
|
|
7129
|
+
workflow2.contentTypes
|
|
7130
|
+
);
|
|
7131
|
+
updatedStageIds = updatedStages.map((stage) => stage.id);
|
|
7105
7132
|
updateOpts = fp.set("data.stages", updatedStageIds, updateOpts);
|
|
7106
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
|
+
}
|
|
7107
7148
|
if (opts.data.contentTypes) {
|
|
7108
7149
|
await workflowsContentTypes.migrate({
|
|
7109
7150
|
srcContentTypes: workflow2.contentTypes,
|
|
@@ -7111,12 +7152,17 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7111
7152
|
stageId: updatedStageIds ? updatedStageIds[0] : workflow2.stages[0].id
|
|
7112
7153
|
});
|
|
7113
7154
|
}
|
|
7114
|
-
metrics.sendDidEditWorkflow();
|
|
7155
|
+
metrics.sendDidEditWorkflow(workflow2.id, !!opts.data.stageRequiredToPublishName);
|
|
7115
7156
|
const query = strapi2.get("query-params").transform(WORKFLOW_MODEL_UID, updateOpts);
|
|
7116
|
-
|
|
7157
|
+
const updatedWorkflow = await strapi2.db.query(WORKFLOW_MODEL_UID).update({
|
|
7117
7158
|
...query,
|
|
7118
7159
|
where: { id: workflow2.id }
|
|
7119
7160
|
});
|
|
7161
|
+
await strapi2.plugin("content-releases").service("release-action").validateActionsByContentTypes([
|
|
7162
|
+
...workflow2.contentTypes,
|
|
7163
|
+
...opts.data.contentTypes || []
|
|
7164
|
+
]);
|
|
7165
|
+
return updatedWorkflow;
|
|
7120
7166
|
});
|
|
7121
7167
|
},
|
|
7122
7168
|
/**
|
|
@@ -7139,10 +7185,12 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7139
7185
|
destContentTypes: []
|
|
7140
7186
|
});
|
|
7141
7187
|
const query = strapi2.get("query-params").transform(WORKFLOW_MODEL_UID, opts);
|
|
7142
|
-
|
|
7188
|
+
const deletedWorkflow = await strapi2.db.query(WORKFLOW_MODEL_UID).delete({
|
|
7143
7189
|
...query,
|
|
7144
7190
|
where: { id: workflow2.id }
|
|
7145
7191
|
});
|
|
7192
|
+
await strapi2.plugin("content-releases").service("release-action").validateActionsByContentTypes(workflow2.contentTypes);
|
|
7193
|
+
return deletedWorkflow;
|
|
7146
7194
|
});
|
|
7147
7195
|
},
|
|
7148
7196
|
/**
|
|
@@ -7612,11 +7660,11 @@ const sendDidDeleteStage = async () => {
|
|
|
7612
7660
|
const sendDidChangeEntryStage = async () => {
|
|
7613
7661
|
strapi.telemetry.send("didChangeEntryStage", {});
|
|
7614
7662
|
};
|
|
7615
|
-
const sendDidCreateWorkflow = async () => {
|
|
7616
|
-
strapi.telemetry.send("didCreateWorkflow", {});
|
|
7663
|
+
const sendDidCreateWorkflow = async (workflowId, hasRequiredStageToPublish) => {
|
|
7664
|
+
strapi.telemetry.send("didCreateWorkflow", { workflowId, hasRequiredStageToPublish });
|
|
7617
7665
|
};
|
|
7618
|
-
const sendDidEditWorkflow = async () => {
|
|
7619
|
-
strapi.telemetry.send("didEditWorkflow", {});
|
|
7666
|
+
const sendDidEditWorkflow = async (workflowId, hasRequiredStageToPublish) => {
|
|
7667
|
+
strapi.telemetry.send("didEditWorkflow", { workflowId, hasRequiredStageToPublish });
|
|
7620
7668
|
};
|
|
7621
7669
|
const sendDidEditAssignee = async (fromId, toId) => {
|
|
7622
7670
|
strapi.telemetry.send("didEditAssignee", { from: fromId, to: toId });
|
|
@@ -7869,9 +7917,27 @@ const handleStageOnUpdate = async (ctx, next) => {
|
|
|
7869
7917
|
}
|
|
7870
7918
|
return next();
|
|
7871
7919
|
};
|
|
7920
|
+
const checkStageBeforePublish = async (ctx, next) => {
|
|
7921
|
+
if (ctx.action !== "publish") {
|
|
7922
|
+
return next();
|
|
7923
|
+
}
|
|
7924
|
+
const workflow2 = await getService("workflows").getAssignedWorkflow(ctx.contentType.uid, {
|
|
7925
|
+
populate: "stageRequiredToPublish"
|
|
7926
|
+
});
|
|
7927
|
+
if (!workflow2 || !workflow2.stageRequiredToPublish) {
|
|
7928
|
+
return next();
|
|
7929
|
+
}
|
|
7930
|
+
const { documentId } = ctx.params;
|
|
7931
|
+
const entryStage = await getEntityStage(ctx.contentType.uid, documentId, ctx.params);
|
|
7932
|
+
if (entryStage.id !== workflow2.stageRequiredToPublish.id) {
|
|
7933
|
+
throw new errors.ValidationError("Entry is not at the required stage to publish");
|
|
7934
|
+
}
|
|
7935
|
+
return next();
|
|
7936
|
+
};
|
|
7872
7937
|
const documentServiceMiddleware = () => ({
|
|
7873
7938
|
assignStageOnCreate,
|
|
7874
|
-
handleStageOnUpdate
|
|
7939
|
+
handleStageOnUpdate,
|
|
7940
|
+
checkStageBeforePublish
|
|
7875
7941
|
});
|
|
7876
7942
|
const services = {
|
|
7877
7943
|
workflows: workflows$1,
|
|
@@ -7921,12 +7987,14 @@ const validateContentTypes = yup.array().of(
|
|
|
7921
7987
|
const validateWorkflowCreateSchema = yup.object().shape({
|
|
7922
7988
|
name: yup.string().max(255).min(1, "Workflow name can not be empty").required(),
|
|
7923
7989
|
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"),
|
|
7924
|
-
contentTypes: validateContentTypes
|
|
7990
|
+
contentTypes: validateContentTypes,
|
|
7991
|
+
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7925
7992
|
});
|
|
7926
7993
|
const validateWorkflowUpdateSchema = yup.object().shape({
|
|
7927
7994
|
name: yup.string().max(255).min(1, "Workflow name can not be empty"),
|
|
7928
7995
|
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"),
|
|
7929
|
-
contentTypes: validateContentTypes
|
|
7996
|
+
contentTypes: validateContentTypes,
|
|
7997
|
+
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7930
7998
|
});
|
|
7931
7999
|
const validateUpdateAssigneeOnEntitySchema = yup.object().shape({
|
|
7932
8000
|
id: yup.number().integer().min(1).nullable()
|