@strapi/review-workflows 0.0.0-experimental.fdacf4285d1cada9d94ab4dcd756c5362cba1b54 → 0.0.0-next.3c5400321681b66eb35ab84c11113a78c1d9386e
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-COeOgRsc.js → Layout-8i0EXRRs.js} +3 -3
- package/dist/_chunks/Layout-8i0EXRRs.js.map +1 -0
- package/dist/_chunks/{Layout-CefL-rfa.mjs → Layout-C9m07iTY.mjs} +3 -3
- package/dist/_chunks/Layout-C9m07iTY.mjs.map +1 -0
- package/dist/_chunks/{en-D9dxziEb.mjs → en-D9ZrQAV6.mjs} +2 -5
- package/dist/_chunks/en-D9ZrQAV6.mjs.map +1 -0
- package/dist/_chunks/{en-CYgjfSep.js → en-xcewH2pC.js} +2 -5
- package/dist/_chunks/en-xcewH2pC.js.map +1 -0
- package/dist/_chunks/{_id-PmPKIqUm.js → id-CmtaTf1x.js} +12 -73
- package/dist/_chunks/id-CmtaTf1x.js.map +1 -0
- package/dist/_chunks/{_id-Dt2oEiro.mjs → id-DV0Ndeav.mjs} +12 -73
- package/dist/_chunks/id-DV0Ndeav.mjs.map +1 -0
- package/dist/_chunks/{index-p25R0AkB.js → index-B8WmHbCU.js} +3 -3
- package/dist/_chunks/{index-p25R0AkB.js.map → index-B8WmHbCU.js.map} +1 -1
- package/dist/_chunks/{index-DiWo3Pu2.js → index-BCUO98DV.js} +3 -6
- package/dist/_chunks/{index-DiWo3Pu2.js.map → index-BCUO98DV.js.map} +1 -1
- package/dist/_chunks/{index-DJtnx2X1.mjs → index-CA5Axcoc.mjs} +3 -3
- package/dist/_chunks/{index-DJtnx2X1.mjs.map → index-CA5Axcoc.mjs.map} +1 -1
- package/dist/_chunks/{index-IZXxuQ4h.mjs → index-CqYVkW3E.mjs} +3 -6
- package/dist/_chunks/{index-IZXxuQ4h.mjs.map → index-CqYVkW3E.mjs.map} +1 -1
- package/dist/_chunks/{router-C8mPPFJk.js → router-BOXlNnrU.js} +3 -3
- package/dist/_chunks/router-BOXlNnrU.js.map +1 -0
- package/dist/_chunks/{router-DJCVv74P.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/settings.d.ts +3 -7
- package/dist/server/index.js +22 -72
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +22 -72
- 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 +0 -1
- package/dist/server/src/constants/workflows.d.ts.map +1 -1
- package/dist/server/src/content-types/index.d.ts +0 -6
- package/dist/server/src/content-types/index.d.ts.map +1 -1
- package/dist/server/src/content-types/workflow/index.d.ts +0 -6
- package/dist/server/src/content-types/workflow/index.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +0 -13
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/document-service-middleware.d.ts +0 -1
- package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +0 -1
- 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/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 +0 -4
- package/dist/server/src/validation/review-workflows.d.ts.map +1 -1
- package/dist/shared/contracts/review-workflows.d.ts +3 -8
- package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/_chunks/Layout-COeOgRsc.js.map +0 -1
- package/dist/_chunks/Layout-CefL-rfa.mjs.map +0 -1
- package/dist/_chunks/_id-Dt2oEiro.mjs.map +0 -1
- package/dist/_chunks/_id-PmPKIqUm.js.map +0 -1
- package/dist/_chunks/en-CYgjfSep.js.map +0 -1
- package/dist/_chunks/en-D9dxziEb.mjs.map +0 -1
- package/dist/_chunks/router-C8mPPFJk.js.map +0 -1
- package/dist/_chunks/router-DJCVv74P.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,8 +6386,7 @@ const WORKFLOW_POPULATE = {
|
|
|
6386
6386
|
}
|
|
6387
6387
|
}
|
|
6388
6388
|
}
|
|
6389
|
-
}
|
|
6390
|
-
stageRequiredToPublish: true
|
|
6389
|
+
}
|
|
6391
6390
|
};
|
|
6392
6391
|
function checkVersionThreshold(startVersion, currentVersion, thresholdVersion) {
|
|
6393
6392
|
return semver$1.gte(currentVersion, thresholdVersion) && semver$1.lt(startVersion, thresholdVersion);
|
|
@@ -6608,12 +6607,6 @@ const workflow = {
|
|
|
6608
6607
|
relation: "oneToMany",
|
|
6609
6608
|
mappedBy: "workflow"
|
|
6610
6609
|
},
|
|
6611
|
-
stageRequiredToPublish: {
|
|
6612
|
-
type: "relation",
|
|
6613
|
-
target: "plugin::review-workflows.workflow-stage",
|
|
6614
|
-
relation: "oneToOne",
|
|
6615
|
-
required: false
|
|
6616
|
-
},
|
|
6617
6610
|
contentTypes: {
|
|
6618
6611
|
type: "json",
|
|
6619
6612
|
required: true,
|
|
@@ -6763,7 +6756,6 @@ const bootstrap = async (args) => {
|
|
|
6763
6756
|
const docsMiddlewares = getService("document-service-middlewares");
|
|
6764
6757
|
strapi.documents.use(docsMiddlewares.assignStageOnCreate);
|
|
6765
6758
|
strapi.documents.use(docsMiddlewares.handleStageOnUpdate);
|
|
6766
|
-
strapi.documents.use(docsMiddlewares.checkStageBeforePublish);
|
|
6767
6759
|
};
|
|
6768
6760
|
const destroy = async ({ strapi: strapi2 }) => {
|
|
6769
6761
|
};
|
|
@@ -6996,9 +6988,9 @@ const processFilters = ({ strapi: strapi2 }, filters = {}) => {
|
|
|
6996
6988
|
};
|
|
6997
6989
|
const processPopulate = (populate) => {
|
|
6998
6990
|
if (!populate) {
|
|
6999
|
-
return
|
|
6991
|
+
return populate;
|
|
7000
6992
|
}
|
|
7001
|
-
return
|
|
6993
|
+
return WORKFLOW_POPULATE;
|
|
7002
6994
|
};
|
|
7003
6995
|
const workflows$1 = ({ strapi: strapi2 }) => {
|
|
7004
6996
|
const workflowsContentTypes = workflowsContentTypesFactory({ strapi: strapi2 });
|
|
@@ -7049,15 +7041,6 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7049
7041
|
const stages2 = await getService("stages", { strapi: strapi2 }).createMany(opts.data.stages);
|
|
7050
7042
|
const mapIds = fp.map(fp.get("id"));
|
|
7051
7043
|
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
|
-
}
|
|
7061
7044
|
if (opts.data.contentTypes) {
|
|
7062
7045
|
await workflowsContentTypes.migrate({
|
|
7063
7046
|
destContentTypes: opts.data.contentTypes,
|
|
@@ -7078,7 +7061,6 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7078
7061
|
async update(workflow2, opts) {
|
|
7079
7062
|
const stageService = getService("stages", { strapi: strapi2 });
|
|
7080
7063
|
let updateOpts = { ...opts, populate: { ...WORKFLOW_POPULATE } };
|
|
7081
|
-
let updatedStages = [];
|
|
7082
7064
|
let updatedStageIds;
|
|
7083
7065
|
await workflowValidator.validateWorkflowCount();
|
|
7084
7066
|
return strapi2.db.transaction(async () => {
|
|
@@ -7087,28 +7069,9 @@ const workflows$1 = ({ strapi: strapi2 }) => {
|
|
|
7087
7069
|
opts.data.stages.forEach(
|
|
7088
7070
|
(stage) => this.assertStageBelongsToWorkflow(stage.id, workflow2)
|
|
7089
7071
|
);
|
|
7090
|
-
|
|
7091
|
-
workflow2.stages,
|
|
7092
|
-
opts.data.stages,
|
|
7093
|
-
workflow2.contentTypes
|
|
7094
|
-
);
|
|
7095
|
-
updatedStageIds = updatedStages.map((stage) => stage.id);
|
|
7072
|
+
updatedStageIds = await stageService.replaceStages(workflow2.stages, opts.data.stages, workflow2.contentTypes).then((stages2) => stages2.map((stage) => stage.id));
|
|
7096
7073
|
updateOpts = fp.set("data.stages", updatedStageIds, updateOpts);
|
|
7097
7074
|
}
|
|
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
|
-
}
|
|
7112
7075
|
if (opts.data.contentTypes) {
|
|
7113
7076
|
await workflowsContentTypes.migrate({
|
|
7114
7077
|
srcContentTypes: workflow2.contentTypes,
|
|
@@ -7368,7 +7331,9 @@ const stages$1 = ({ strapi: strapi2 }) => {
|
|
|
7368
7331
|
const entity = await strapi2.documents(model).update({
|
|
7369
7332
|
documentId,
|
|
7370
7333
|
locale,
|
|
7371
|
-
|
|
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) },
|
|
7372
7337
|
populate: [ENTITY_STAGE_ATTRIBUTE]
|
|
7373
7338
|
});
|
|
7374
7339
|
metrics.sendDidChangeEntryStage();
|
|
@@ -7644,13 +7609,13 @@ const reviewWorkflowsMetrics = {
|
|
|
7644
7609
|
sendDidSendReviewWorkflowPropertiesOnceAWeek,
|
|
7645
7610
|
sendDidEditAssignee
|
|
7646
7611
|
};
|
|
7647
|
-
function _typeof(
|
|
7612
|
+
function _typeof(o) {
|
|
7648
7613
|
"@babel/helpers - typeof";
|
|
7649
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(
|
|
7650
|
-
return typeof
|
|
7651
|
-
} : function(
|
|
7652
|
-
return
|
|
7653
|
-
}, _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);
|
|
7654
7619
|
}
|
|
7655
7620
|
function toInteger(dirtyNumber) {
|
|
7656
7621
|
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
@@ -7785,7 +7750,12 @@ const reviewWorkflowsWeeklyMetrics = ({ strapi: strapi2 }) => {
|
|
|
7785
7750
|
},
|
|
7786
7751
|
async registerCron() {
|
|
7787
7752
|
const weeklySchedule = await this.ensureWeeklyStoredCronSchedule();
|
|
7788
|
-
strapi2.cron.add({
|
|
7753
|
+
strapi2.cron.add({
|
|
7754
|
+
reviewWorkflowsWeekly: {
|
|
7755
|
+
task: this.sendMetrics.bind(this),
|
|
7756
|
+
options: weeklySchedule
|
|
7757
|
+
}
|
|
7758
|
+
});
|
|
7789
7759
|
}
|
|
7790
7760
|
};
|
|
7791
7761
|
};
|
|
@@ -7867,27 +7837,9 @@ const handleStageOnUpdate = async (ctx, next) => {
|
|
|
7867
7837
|
}
|
|
7868
7838
|
return next();
|
|
7869
7839
|
};
|
|
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
|
-
};
|
|
7887
7840
|
const documentServiceMiddleware = () => ({
|
|
7888
7841
|
assignStageOnCreate,
|
|
7889
|
-
handleStageOnUpdate
|
|
7890
|
-
checkStageBeforePublish
|
|
7842
|
+
handleStageOnUpdate
|
|
7891
7843
|
});
|
|
7892
7844
|
const services = {
|
|
7893
7845
|
workflows: workflows$1,
|
|
@@ -7937,14 +7889,12 @@ const validateContentTypes = yup.array().of(
|
|
|
7937
7889
|
const validateWorkflowCreateSchema = yup.object().shape({
|
|
7938
7890
|
name: yup.string().max(255).min(1, "Workflow name can not be empty").required(),
|
|
7939
7891
|
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"),
|
|
7940
|
-
contentTypes: validateContentTypes
|
|
7941
|
-
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7892
|
+
contentTypes: validateContentTypes
|
|
7942
7893
|
});
|
|
7943
7894
|
const validateWorkflowUpdateSchema = yup.object().shape({
|
|
7944
7895
|
name: yup.string().max(255).min(1, "Workflow name can not be empty"),
|
|
7945
7896
|
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"),
|
|
7946
|
-
contentTypes: validateContentTypes
|
|
7947
|
-
stageRequiredToPublishName: yup.string().min(1).nullable()
|
|
7897
|
+
contentTypes: validateContentTypes
|
|
7948
7898
|
});
|
|
7949
7899
|
const validateUpdateAssigneeOnEntitySchema = yup.object().shape({
|
|
7950
7900
|
id: yup.number().integer().min(1).nullable()
|