@strapi/review-workflows 5.56.0 → 5.57.0
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/server/audit-logs.js +123 -0
- package/dist/server/audit-logs.js.map +1 -0
- package/dist/server/audit-logs.mjs +116 -0
- package/dist/server/audit-logs.mjs.map +1 -0
- package/dist/server/bootstrap.js +7 -0
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +7 -0
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/controllers/workflows.js +8 -6
- package/dist/server/controllers/workflows.js.map +1 -1
- package/dist/server/controllers/workflows.mjs +8 -6
- package/dist/server/controllers/workflows.mjs.map +1 -1
- package/dist/server/middlewares/review-workflows.js +7 -3
- package/dist/server/middlewares/review-workflows.js.map +1 -1
- package/dist/server/middlewares/review-workflows.mjs +7 -3
- package/dist/server/middlewares/review-workflows.mjs.map +1 -1
- package/dist/server/migrations/handle-deleted-ct-in-workflows.js +2 -2
- package/dist/server/migrations/handle-deleted-ct-in-workflows.js.map +1 -1
- package/dist/server/migrations/handle-deleted-ct-in-workflows.mjs +2 -2
- package/dist/server/migrations/handle-deleted-ct-in-workflows.mjs.map +1 -1
- package/dist/server/migrations/multiple-workflows.js +2 -5
- package/dist/server/migrations/multiple-workflows.js.map +1 -1
- package/dist/server/migrations/multiple-workflows.mjs +2 -5
- package/dist/server/migrations/multiple-workflows.mjs.map +1 -1
- package/dist/server/register.js +4 -7
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +4 -7
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/services/assignees.js +18 -2
- package/dist/server/services/assignees.js.map +1 -1
- package/dist/server/services/assignees.mjs +19 -3
- package/dist/server/services/assignees.mjs.map +1 -1
- package/dist/server/services/document-service-middleware.js +2 -3
- package/dist/server/services/document-service-middleware.js.map +1 -1
- package/dist/server/services/document-service-middleware.mjs +2 -3
- package/dist/server/services/document-service-middleware.mjs.map +1 -1
- package/dist/server/services/metrics/weekly-metrics.js +8 -8
- package/dist/server/services/metrics/weekly-metrics.js.map +1 -1
- package/dist/server/services/metrics/weekly-metrics.mjs +4 -4
- package/dist/server/services/metrics/weekly-metrics.mjs.map +1 -1
- package/dist/server/services/stage-permissions.js +1 -2
- package/dist/server/services/stage-permissions.js.map +1 -1
- package/dist/server/services/stage-permissions.mjs +1 -2
- package/dist/server/services/stage-permissions.mjs.map +1 -1
- package/dist/server/services/stages.js +8 -8
- package/dist/server/services/stages.js.map +1 -1
- package/dist/server/services/stages.mjs +7 -7
- package/dist/server/services/stages.mjs.map +1 -1
- package/dist/server/services/validation.js +1 -2
- package/dist/server/services/validation.js.map +1 -1
- package/dist/server/services/validation.mjs +1 -2
- package/dist/server/services/validation.mjs.map +1 -1
- package/dist/server/services/workflow-content-types.js +23 -6
- package/dist/server/services/workflow-content-types.js.map +1 -1
- package/dist/server/services/workflow-content-types.mjs +21 -4
- package/dist/server/services/workflow-content-types.mjs.map +1 -1
- package/dist/server/services/workflows.js +91 -13
- package/dist/server/services/workflows.js.map +1 -1
- package/dist/server/services/workflows.mjs +91 -13
- package/dist/server/services/workflows.mjs.map +1 -1
- package/dist/server/src/audit-logs.d.ts +112 -0
- package/dist/server/src/audit-logs.d.ts.map +1 -0
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/workflows.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -1
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/middlewares/review-workflows.d.ts.map +1 -1
- package/dist/server/src/migrations/handle-deleted-ct-in-workflows.d.ts.map +1 -1
- package/dist/server/src/migrations/multiple-workflows.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/assignees.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/index.d.ts.map +1 -1
- package/dist/server/src/services/metrics/weekly-metrics.d.ts +1 -1
- package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
- package/dist/server/src/services/stage-permissions.d.ts.map +1 -1
- package/dist/server/src/services/validation.d.ts.map +1 -1
- package/dist/server/src/services/workflow-content-types.d.ts +10 -3
- package/dist/server/src/services/workflow-content-types.d.ts.map +1 -1
- package/dist/server/src/services/workflows.d.ts.map +1 -1
- package/dist/server/src/utils/review-workflows.d.ts +12 -8
- package/dist/server/src/utils/review-workflows.d.ts.map +1 -1
- package/dist/server/utils/review-workflows.js +8 -13
- package/dist/server/utils/review-workflows.js.map +1 -1
- package/dist/server/utils/review-workflows.mjs +8 -13
- package/dist/server/utils/review-workflows.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-workflows.js","sources":["../../../server/src/middlewares/review-workflows.ts"],"sourcesContent":["import type { Context } from 'koa';\nimport type { Core } from '@strapi/types';\n\
|
|
1
|
+
{"version":3,"file":"review-workflows.js","sources":["../../../server/src/middlewares/review-workflows.ts"],"sourcesContent":["import type { Context } from 'koa';\nimport type { Core } from '@strapi/types';\n\n/**\n * A Strapi middleware function that adds support for review workflows.\n *\n * Why is it needed ?\n * For now, the admin panel cannot have anything but top-level attributes in the content-type for options.\n * But we need the CE part to be agnostics from Review Workflow (which is an EE feature).\n * CE handle the `options` object, that's why we move the reviewWorkflows boolean to the options object.\n *\n * @param {object} strapi - The Strapi instance.\n */\nexport function contentTypeMiddleware(strapi: Core.Strapi) {\n /**\n * A middleware function that moves the `reviewWorkflows` attribute from the top level of\n * the request body to the `options` object within the request body.\n *\n * @param {object} ctx - The Koa context object.\n */\n const moveReviewWorkflowOption = (ctx: Context) => {\n // Move reviewWorkflows to options.reviewWorkflows\n const { reviewWorkflows, ...contentType } = ctx.request.body.contentType;\n\n if (typeof reviewWorkflows === 'boolean') {\n ctx.request.body.contentType = {\n ...contentType,\n options: { ...contentType.options, reviewWorkflows },\n };\n }\n };\n strapi.server.router.use('/content-type-builder/content-types/:uid?', (ctx, next) => {\n if (ctx.method === 'PUT' || ctx.method === 'POST') {\n moveReviewWorkflowOption(ctx);\n }\n return next();\n });\n}\n\nexport default {\n contentTypeMiddleware,\n};\n"],"names":["contentTypeMiddleware","strapi","moveReviewWorkflowOption","ctx","reviewWorkflows","contentType","request","body","options","server","router","use","next","method"],"mappings":";;;;AAGA;;;;;;;;;IAUO,SAASA,qBAAAA,CAAsBC,MAAmB,EAAA;AACvD;;;;;MAMA,MAAMC,2BAA2B,CAACC,GAAAA,GAAAA;;QAEhC,MAAM,EAAEC,eAAe,EAAE,GAAGC,WAAAA,EAAa,GAAGF,GAAAA,CAAIG,OAAO,CAACC,IAAI,CAACF,WAAW;QAExE,IAAI,OAAOD,oBAAoB,SAAA,EAAW;AACxCD,YAAAA,GAAAA,CAAIG,OAAO,CAACC,IAAI,CAACF,WAAW,GAAG;AAC7B,gBAAA,GAAGA,WAAW;gBACdG,OAAAA,EAAS;AAAE,oBAAA,GAAGH,YAAYG,OAAO;AAAEJ,oBAAAA;AAAgB;AACrD,aAAA;AACF,QAAA;AACF,IAAA,CAAA;IACAH,MAAAA,CAAOQ,MAAM,CAACC,MAAM,CAACC,GAAG,CAAC,2CAAA,EAA6C,CAACR,GAAAA,EAAKS,IAAAA,GAAAA;AAC1E,QAAA,IAAIT,IAAIU,MAAM,KAAK,SAASV,GAAAA,CAAIU,MAAM,KAAK,MAAA,EAAQ;YACjDX,wBAAAA,CAAyBC,GAAAA,CAAAA;AAC3B,QAAA;QACA,OAAOS,IAAAA,EAAAA;AACT,IAAA,CAAA,CAAA;AACF;AAEA,iCAAe;AACbZ,IAAAA;AACF,CAAA;;;;;"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { set } from 'lodash/fp';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* A Strapi middleware function that adds support for review workflows.
|
|
5
3
|
*
|
|
@@ -19,7 +17,13 @@ import { set } from 'lodash/fp';
|
|
|
19
17
|
// Move reviewWorkflows to options.reviewWorkflows
|
|
20
18
|
const { reviewWorkflows, ...contentType } = ctx.request.body.contentType;
|
|
21
19
|
if (typeof reviewWorkflows === 'boolean') {
|
|
22
|
-
ctx.request.body.contentType =
|
|
20
|
+
ctx.request.body.contentType = {
|
|
21
|
+
...contentType,
|
|
22
|
+
options: {
|
|
23
|
+
...contentType.options,
|
|
24
|
+
reviewWorkflows
|
|
25
|
+
}
|
|
26
|
+
};
|
|
23
27
|
}
|
|
24
28
|
};
|
|
25
29
|
strapi.server.router.use('/content-type-builder/content-types/:uid?', (ctx, next)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-workflows.mjs","sources":["../../../server/src/middlewares/review-workflows.ts"],"sourcesContent":["import type { Context } from 'koa';\nimport type { Core } from '@strapi/types';\n\
|
|
1
|
+
{"version":3,"file":"review-workflows.mjs","sources":["../../../server/src/middlewares/review-workflows.ts"],"sourcesContent":["import type { Context } from 'koa';\nimport type { Core } from '@strapi/types';\n\n/**\n * A Strapi middleware function that adds support for review workflows.\n *\n * Why is it needed ?\n * For now, the admin panel cannot have anything but top-level attributes in the content-type for options.\n * But we need the CE part to be agnostics from Review Workflow (which is an EE feature).\n * CE handle the `options` object, that's why we move the reviewWorkflows boolean to the options object.\n *\n * @param {object} strapi - The Strapi instance.\n */\nexport function contentTypeMiddleware(strapi: Core.Strapi) {\n /**\n * A middleware function that moves the `reviewWorkflows` attribute from the top level of\n * the request body to the `options` object within the request body.\n *\n * @param {object} ctx - The Koa context object.\n */\n const moveReviewWorkflowOption = (ctx: Context) => {\n // Move reviewWorkflows to options.reviewWorkflows\n const { reviewWorkflows, ...contentType } = ctx.request.body.contentType;\n\n if (typeof reviewWorkflows === 'boolean') {\n ctx.request.body.contentType = {\n ...contentType,\n options: { ...contentType.options, reviewWorkflows },\n };\n }\n };\n strapi.server.router.use('/content-type-builder/content-types/:uid?', (ctx, next) => {\n if (ctx.method === 'PUT' || ctx.method === 'POST') {\n moveReviewWorkflowOption(ctx);\n }\n return next();\n });\n}\n\nexport default {\n contentTypeMiddleware,\n};\n"],"names":["contentTypeMiddleware","strapi","moveReviewWorkflowOption","ctx","reviewWorkflows","contentType","request","body","options","server","router","use","next","method"],"mappings":"AAGA;;;;;;;;;IAUO,SAASA,qBAAAA,CAAsBC,MAAmB,EAAA;AACvD;;;;;MAMA,MAAMC,2BAA2B,CAACC,GAAAA,GAAAA;;QAEhC,MAAM,EAAEC,eAAe,EAAE,GAAGC,WAAAA,EAAa,GAAGF,GAAAA,CAAIG,OAAO,CAACC,IAAI,CAACF,WAAW;QAExE,IAAI,OAAOD,oBAAoB,SAAA,EAAW;AACxCD,YAAAA,GAAAA,CAAIG,OAAO,CAACC,IAAI,CAACF,WAAW,GAAG;AAC7B,gBAAA,GAAGA,WAAW;gBACdG,OAAAA,EAAS;AAAE,oBAAA,GAAGH,YAAYG,OAAO;AAAEJ,oBAAAA;AAAgB;AACrD,aAAA;AACF,QAAA;AACF,IAAA,CAAA;IACAH,MAAAA,CAAOQ,MAAM,CAACC,MAAM,CAACC,GAAG,CAAC,2CAAA,EAA6C,CAACR,GAAAA,EAAKS,IAAAA,GAAAA;AAC1E,QAAA,IAAIT,IAAIU,MAAM,KAAK,SAASV,GAAAA,CAAIU,MAAM,KAAK,MAAA,EAAQ;YACjDX,wBAAAA,CAAyBC,GAAAA,CAAAA;AAC3B,QAAA;QACA,OAAOS,IAAAA,EAAAA;AACT,IAAA,CAAA,CAAA;AACF;AAEA,iCAAe;AACbZ,IAAAA;AACF,CAAA;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var lodash = require('lodash');
|
|
4
4
|
var utils = require('@strapi/utils');
|
|
5
5
|
var workflows = require('../constants/workflows.js');
|
|
6
6
|
var reviewWorkflows = require('../utils/review-workflows.js');
|
|
@@ -8,7 +8,7 @@ var reviewWorkflows = require('../utils/review-workflows.js');
|
|
|
8
8
|
/**
|
|
9
9
|
* Remove CT references from workflows if the CT is deleted
|
|
10
10
|
*/ async function migrateDeletedCTInWorkflows({ oldContentTypes, contentTypes }) {
|
|
11
|
-
const deletedContentTypes =
|
|
11
|
+
const deletedContentTypes = lodash.difference(Object.keys(oldContentTypes ?? {}), Object.keys(contentTypes ?? {})) ?? [];
|
|
12
12
|
if (deletedContentTypes.length) {
|
|
13
13
|
await utils.async.map(deletedContentTypes, async (deletedContentTypeUID)=>{
|
|
14
14
|
const workflow = await strapi.db.query(workflows.WORKFLOW_MODEL_UID).findOne({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-deleted-ct-in-workflows.js","sources":["../../../server/src/migrations/handle-deleted-ct-in-workflows.ts"],"sourcesContent":["import { difference
|
|
1
|
+
{"version":3,"file":"handle-deleted-ct-in-workflows.js","sources":["../../../server/src/migrations/handle-deleted-ct-in-workflows.ts"],"sourcesContent":["import { difference } from 'lodash';\nimport { async } from '@strapi/utils';\nimport { WORKFLOW_MODEL_UID } from '../constants/workflows';\nimport { getWorkflowContentTypeFilter } from '../utils/review-workflows';\n\n/**\n * Remove CT references from workflows if the CT is deleted\n */\nasync function migrateDeletedCTInWorkflows({ oldContentTypes, contentTypes }: any) {\n const deletedContentTypes =\n difference(Object.keys(oldContentTypes ?? {}), Object.keys(contentTypes ?? {})) ?? [];\n\n if (deletedContentTypes.length) {\n await async.map(deletedContentTypes, async (deletedContentTypeUID: unknown) => {\n const workflow = await strapi.db.query(WORKFLOW_MODEL_UID).findOne({\n select: ['id', 'contentTypes'],\n where: {\n contentTypes: getWorkflowContentTypeFilter({ strapi }, deletedContentTypeUID),\n },\n });\n\n if (workflow) {\n await strapi.db.query(WORKFLOW_MODEL_UID).update({\n where: { id: workflow.id },\n data: {\n contentTypes: workflow.contentTypes.filter(\n (contentTypeUID: unknown) => contentTypeUID !== deletedContentTypeUID\n ),\n },\n });\n }\n });\n }\n}\n\nexport default migrateDeletedCTInWorkflows;\n"],"names":["migrateDeletedCTInWorkflows","oldContentTypes","contentTypes","deletedContentTypes","difference","Object","keys","length","async","map","deletedContentTypeUID","workflow","strapi","db","query","WORKFLOW_MODEL_UID","findOne","select","where","getWorkflowContentTypeFilter","update","id","data","filter","contentTypeUID"],"mappings":";;;;;;;AAKA;;AAEC,IACD,eAAeA,2BAAAA,CAA4B,EAAEC,eAAe,EAAEC,YAAY,EAAO,EAAA;AAC/E,IAAA,MAAMC,mBAAAA,GACJC,iBAAAA,CAAWC,MAAAA,CAAOC,IAAI,CAACL,eAAAA,IAAmB,EAAC,CAAA,EAAII,MAAAA,CAAOC,IAAI,CAACJ,YAAAA,IAAgB,QAAQ,EAAE;IAEvF,IAAIC,mBAAAA,CAAoBI,MAAM,EAAE;AAC9B,QAAA,MAAMC,WAAAA,CAAMC,GAAG,CAACN,mBAAAA,EAAqB,OAAOO,qBAAAA,GAAAA;YAC1C,MAAMC,QAAAA,GAAW,MAAMC,MAAAA,CAAOC,EAAE,CAACC,KAAK,CAACC,4BAAAA,CAAAA,CAAoBC,OAAO,CAAC;gBACjEC,MAAAA,EAAQ;AAAC,oBAAA,IAAA;AAAM,oBAAA;AAAe,iBAAA;gBAC9BC,KAAAA,EAAO;AACLhB,oBAAAA,YAAAA,EAAciB,4CAAAA,CAA6B;AAAEP,wBAAAA;qBAAO,EAAGF,qBAAAA;AACzD;AACF,aAAA,CAAA;AAEA,YAAA,IAAIC,QAAAA,EAAU;AACZ,gBAAA,MAAMC,OAAOC,EAAE,CAACC,KAAK,CAACC,4BAAAA,CAAAA,CAAoBK,MAAM,CAAC;oBAC/CF,KAAAA,EAAO;AAAEG,wBAAAA,EAAAA,EAAIV,SAASU;AAAG,qBAAA;oBACzBC,IAAAA,EAAM;AACJpB,wBAAAA,YAAAA,EAAcS,SAAST,YAAY,CAACqB,MAAM,CACxC,CAACC,iBAA4BA,cAAAA,KAAmBd,qBAAAA;AAEpD;AACF,iBAAA,CAAA;AACF,YAAA;AACF,QAAA,CAAA,CAAA;AACF,IAAA;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { difference
|
|
1
|
+
import { difference } from 'lodash';
|
|
2
2
|
import { async } from '@strapi/utils';
|
|
3
3
|
import { WORKFLOW_MODEL_UID } from '../constants/workflows.mjs';
|
|
4
4
|
import { getWorkflowContentTypeFilter } from '../utils/review-workflows.mjs';
|
|
@@ -6,7 +6,7 @@ import { getWorkflowContentTypeFilter } from '../utils/review-workflows.mjs';
|
|
|
6
6
|
/**
|
|
7
7
|
* Remove CT references from workflows if the CT is deleted
|
|
8
8
|
*/ async function migrateDeletedCTInWorkflows({ oldContentTypes, contentTypes }) {
|
|
9
|
-
const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes)) ?? [];
|
|
9
|
+
const deletedContentTypes = difference(Object.keys(oldContentTypes ?? {}), Object.keys(contentTypes ?? {})) ?? [];
|
|
10
10
|
if (deletedContentTypes.length) {
|
|
11
11
|
await async.map(deletedContentTypes, async (deletedContentTypeUID)=>{
|
|
12
12
|
const workflow = await strapi.db.query(WORKFLOW_MODEL_UID).findOne({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-deleted-ct-in-workflows.mjs","sources":["../../../server/src/migrations/handle-deleted-ct-in-workflows.ts"],"sourcesContent":["import { difference
|
|
1
|
+
{"version":3,"file":"handle-deleted-ct-in-workflows.mjs","sources":["../../../server/src/migrations/handle-deleted-ct-in-workflows.ts"],"sourcesContent":["import { difference } from 'lodash';\nimport { async } from '@strapi/utils';\nimport { WORKFLOW_MODEL_UID } from '../constants/workflows';\nimport { getWorkflowContentTypeFilter } from '../utils/review-workflows';\n\n/**\n * Remove CT references from workflows if the CT is deleted\n */\nasync function migrateDeletedCTInWorkflows({ oldContentTypes, contentTypes }: any) {\n const deletedContentTypes =\n difference(Object.keys(oldContentTypes ?? {}), Object.keys(contentTypes ?? {})) ?? [];\n\n if (deletedContentTypes.length) {\n await async.map(deletedContentTypes, async (deletedContentTypeUID: unknown) => {\n const workflow = await strapi.db.query(WORKFLOW_MODEL_UID).findOne({\n select: ['id', 'contentTypes'],\n where: {\n contentTypes: getWorkflowContentTypeFilter({ strapi }, deletedContentTypeUID),\n },\n });\n\n if (workflow) {\n await strapi.db.query(WORKFLOW_MODEL_UID).update({\n where: { id: workflow.id },\n data: {\n contentTypes: workflow.contentTypes.filter(\n (contentTypeUID: unknown) => contentTypeUID !== deletedContentTypeUID\n ),\n },\n });\n }\n });\n }\n}\n\nexport default migrateDeletedCTInWorkflows;\n"],"names":["migrateDeletedCTInWorkflows","oldContentTypes","contentTypes","deletedContentTypes","difference","Object","keys","length","async","map","deletedContentTypeUID","workflow","strapi","db","query","WORKFLOW_MODEL_UID","findOne","select","where","getWorkflowContentTypeFilter","update","id","data","filter","contentTypeUID"],"mappings":";;;;;AAKA;;AAEC,IACD,eAAeA,2BAAAA,CAA4B,EAAEC,eAAe,EAAEC,YAAY,EAAO,EAAA;AAC/E,IAAA,MAAMC,mBAAAA,GACJC,UAAAA,CAAWC,MAAAA,CAAOC,IAAI,CAACL,eAAAA,IAAmB,EAAC,CAAA,EAAII,MAAAA,CAAOC,IAAI,CAACJ,YAAAA,IAAgB,QAAQ,EAAE;IAEvF,IAAIC,mBAAAA,CAAoBI,MAAM,EAAE;AAC9B,QAAA,MAAMC,KAAAA,CAAMC,GAAG,CAACN,mBAAAA,EAAqB,OAAOO,qBAAAA,GAAAA;YAC1C,MAAMC,QAAAA,GAAW,MAAMC,MAAAA,CAAOC,EAAE,CAACC,KAAK,CAACC,kBAAAA,CAAAA,CAAoBC,OAAO,CAAC;gBACjEC,MAAAA,EAAQ;AAAC,oBAAA,IAAA;AAAM,oBAAA;AAAe,iBAAA;gBAC9BC,KAAAA,EAAO;AACLhB,oBAAAA,YAAAA,EAAciB,4BAAAA,CAA6B;AAAEP,wBAAAA;qBAAO,EAAGF,qBAAAA;AACzD;AACF,aAAA,CAAA;AAEA,YAAA,IAAIC,QAAAA,EAAU;AACZ,gBAAA,MAAMC,OAAOC,EAAE,CAACC,KAAK,CAACC,kBAAAA,CAAAA,CAAoBK,MAAM,CAAC;oBAC/CF,KAAAA,EAAO;AAAEG,wBAAAA,EAAAA,EAAIV,SAASU;AAAG,qBAAA;oBACzBC,IAAAA,EAAM;AACJpB,wBAAAA,YAAAA,EAAcS,SAAST,YAAY,CAACqB,MAAM,CACxC,CAACC,iBAA4BA,cAAAA,KAAmBd,qBAAAA;AAEpD;AACF,iBAAA,CAAA;AACF,YAAA;AACF,QAAA,CAAA,CAAA;AACF,IAAA;AACF;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var lodash = require('lodash');
|
|
4
4
|
var workflows = require('../constants/workflows.js');
|
|
5
5
|
|
|
6
6
|
async function migrateWorkflowsContentTypes({ oldContentTypes, contentTypes }) {
|
|
@@ -16,10 +16,7 @@ async function migrateWorkflowsContentTypes({ oldContentTypes, contentTypes }) {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
// Find Content Types which were using Review Workflow before
|
|
19
|
-
const contentTypes =
|
|
20
|
-
fp.pickBy(fp.get('options.reviewWorkflows')),
|
|
21
|
-
fp.keys
|
|
22
|
-
])(oldContentTypes);
|
|
19
|
+
const contentTypes = Object.keys(lodash.pickBy(oldContentTypes, (contentType)=>lodash.get(contentType, 'options.reviewWorkflows')));
|
|
23
20
|
if (contentTypes.length) {
|
|
24
21
|
// Update only one workflow with the contentTypes
|
|
25
22
|
// Before this release there was only one workflow, so this operation is safe.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiple-workflows.js","sources":["../../../server/src/migrations/multiple-workflows.ts"],"sourcesContent":["import { get,
|
|
1
|
+
{"version":3,"file":"multiple-workflows.js","sources":["../../../server/src/migrations/multiple-workflows.ts"],"sourcesContent":["import { get, pickBy } from 'lodash';\nimport { WORKFLOW_MODEL_UID } from '../constants/workflows';\n\nasync function migrateWorkflowsContentTypes({ oldContentTypes, contentTypes }: any) {\n // Look for RW contentTypes attribute\n const hadContentTypes = !!oldContentTypes?.[WORKFLOW_MODEL_UID]?.attributes?.contentTypes;\n const hasContentTypes = !!contentTypes?.[WORKFLOW_MODEL_UID]?.attributes?.contentTypes;\n\n if (!hadContentTypes && hasContentTypes) {\n // Initialize contentTypes with an empty array and assign only to one\n // workflow the Content Types which were using Review Workflow before.\n await strapi.db.query(WORKFLOW_MODEL_UID).updateMany({ data: { contentTypes: [] } });\n\n // Find Content Types which were using Review Workflow before\n const contentTypes = Object.keys(\n pickBy(oldContentTypes, (contentType) => get(contentType, 'options.reviewWorkflows'))\n );\n\n if (contentTypes.length) {\n // Update only one workflow with the contentTypes\n // Before this release there was only one workflow, so this operation is safe.\n await strapi.db\n .query(WORKFLOW_MODEL_UID)\n .update({ where: { id: { $notNull: true } }, data: { contentTypes } });\n }\n }\n}\n\nexport default migrateWorkflowsContentTypes;\n"],"names":["migrateWorkflowsContentTypes","oldContentTypes","contentTypes","hadContentTypes","WORKFLOW_MODEL_UID","attributes","hasContentTypes","strapi","db","query","updateMany","data","Object","keys","pickBy","contentType","get","length","update","where","id","$notNull"],"mappings":";;;;;AAGA,eAAeA,4BAAAA,CAA6B,EAAEC,eAAe,EAAEC,YAAY,EAAO,EAAA;;AAEhF,IAAA,MAAMC,kBAAkB,CAAC,CAACF,kBAAkBG,4BAAAA,CAAmB,EAAEC,UAAAA,EAAYH,YAAAA;AAC7E,IAAA,MAAMI,kBAAkB,CAAC,CAACJ,eAAeE,4BAAAA,CAAmB,EAAEC,UAAAA,EAAYH,YAAAA;IAE1E,IAAI,CAACC,mBAAmBG,eAAAA,EAAiB;;;AAGvC,QAAA,MAAMC,OAAOC,EAAE,CAACC,KAAK,CAACL,4BAAAA,CAAAA,CAAoBM,UAAU,CAAC;YAAEC,IAAAA,EAAM;AAAET,gBAAAA,YAAAA,EAAc;AAAG;AAAE,SAAA,CAAA;;QAGlF,MAAMA,YAAAA,GAAeU,OAAOC,IAAI,CAC9BC,cAAOb,eAAAA,EAAiB,CAACc,WAAAA,GAAgBC,UAAAA,CAAID,WAAAA,EAAa,yBAAA,CAAA,CAAA,CAAA;QAG5D,IAAIb,YAAAA,CAAae,MAAM,EAAE;;;AAGvB,YAAA,MAAMV,OAAOC,EAAE,CACZC,KAAK,CAACL,4BAAAA,CAAAA,CACNc,MAAM,CAAC;gBAAEC,KAAAA,EAAO;oBAAEC,EAAAA,EAAI;wBAAEC,QAAAA,EAAU;AAAK;AAAE,iBAAA;gBAAGV,IAAAA,EAAM;AAAET,oBAAAA;AAAa;AAAE,aAAA,CAAA;AACxE,QAAA;AACF,IAAA;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pickBy, get } from 'lodash';
|
|
2
2
|
import { WORKFLOW_MODEL_UID } from '../constants/workflows.mjs';
|
|
3
3
|
|
|
4
4
|
async function migrateWorkflowsContentTypes({ oldContentTypes, contentTypes }) {
|
|
@@ -14,10 +14,7 @@ async function migrateWorkflowsContentTypes({ oldContentTypes, contentTypes }) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
// Find Content Types which were using Review Workflow before
|
|
17
|
-
const contentTypes =
|
|
18
|
-
pickBy(get('options.reviewWorkflows')),
|
|
19
|
-
keys
|
|
20
|
-
])(oldContentTypes);
|
|
17
|
+
const contentTypes = Object.keys(pickBy(oldContentTypes, (contentType)=>get(contentType, 'options.reviewWorkflows')));
|
|
21
18
|
if (contentTypes.length) {
|
|
22
19
|
// Update only one workflow with the contentTypes
|
|
23
20
|
// Before this release there was only one workflow, so this operation is safe.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiple-workflows.mjs","sources":["../../../server/src/migrations/multiple-workflows.ts"],"sourcesContent":["import { get,
|
|
1
|
+
{"version":3,"file":"multiple-workflows.mjs","sources":["../../../server/src/migrations/multiple-workflows.ts"],"sourcesContent":["import { get, pickBy } from 'lodash';\nimport { WORKFLOW_MODEL_UID } from '../constants/workflows';\n\nasync function migrateWorkflowsContentTypes({ oldContentTypes, contentTypes }: any) {\n // Look for RW contentTypes attribute\n const hadContentTypes = !!oldContentTypes?.[WORKFLOW_MODEL_UID]?.attributes?.contentTypes;\n const hasContentTypes = !!contentTypes?.[WORKFLOW_MODEL_UID]?.attributes?.contentTypes;\n\n if (!hadContentTypes && hasContentTypes) {\n // Initialize contentTypes with an empty array and assign only to one\n // workflow the Content Types which were using Review Workflow before.\n await strapi.db.query(WORKFLOW_MODEL_UID).updateMany({ data: { contentTypes: [] } });\n\n // Find Content Types which were using Review Workflow before\n const contentTypes = Object.keys(\n pickBy(oldContentTypes, (contentType) => get(contentType, 'options.reviewWorkflows'))\n );\n\n if (contentTypes.length) {\n // Update only one workflow with the contentTypes\n // Before this release there was only one workflow, so this operation is safe.\n await strapi.db\n .query(WORKFLOW_MODEL_UID)\n .update({ where: { id: { $notNull: true } }, data: { contentTypes } });\n }\n }\n}\n\nexport default migrateWorkflowsContentTypes;\n"],"names":["migrateWorkflowsContentTypes","oldContentTypes","contentTypes","hadContentTypes","WORKFLOW_MODEL_UID","attributes","hasContentTypes","strapi","db","query","updateMany","data","Object","keys","pickBy","contentType","get","length","update","where","id","$notNull"],"mappings":";;;AAGA,eAAeA,4BAAAA,CAA6B,EAAEC,eAAe,EAAEC,YAAY,EAAO,EAAA;;AAEhF,IAAA,MAAMC,kBAAkB,CAAC,CAACF,kBAAkBG,kBAAAA,CAAmB,EAAEC,UAAAA,EAAYH,YAAAA;AAC7E,IAAA,MAAMI,kBAAkB,CAAC,CAACJ,eAAeE,kBAAAA,CAAmB,EAAEC,UAAAA,EAAYH,YAAAA;IAE1E,IAAI,CAACC,mBAAmBG,eAAAA,EAAiB;;;AAGvC,QAAA,MAAMC,OAAOC,EAAE,CAACC,KAAK,CAACL,kBAAAA,CAAAA,CAAoBM,UAAU,CAAC;YAAEC,IAAAA,EAAM;AAAET,gBAAAA,YAAAA,EAAc;AAAG;AAAE,SAAA,CAAA;;QAGlF,MAAMA,YAAAA,GAAeU,OAAOC,IAAI,CAC9BC,OAAOb,eAAAA,EAAiB,CAACc,WAAAA,GAAgBC,GAAAA,CAAID,WAAAA,EAAa,yBAAA,CAAA,CAAA,CAAA;QAG5D,IAAIb,YAAAA,CAAae,MAAM,EAAE;;;AAGvB,YAAA,MAAMV,OAAOC,EAAE,CACZC,KAAK,CAACL,kBAAAA,CAAAA,CACNc,MAAM,CAAC;gBAAEC,KAAAA,EAAO;oBAAEC,EAAAA,EAAI;wBAAEC,QAAAA,EAAU;AAAK;AAAE,iBAAA;gBAAGV,IAAAA,EAAM;AAAET,oBAAAA;AAAa;AAAE,aAAA,CAAA;AACxE,QAAA;AACF,IAAA;AACF;;;;"}
|
package/dist/server/register.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var lodash = require('lodash');
|
|
4
4
|
var index = require('./utils/index.js');
|
|
5
5
|
var setStagesDefaultColor = require('./migrations/set-stages-default-color.js');
|
|
6
6
|
var setStagesRoles = require('./migrations/set-stages-roles.js');
|
|
@@ -74,10 +74,7 @@ const setRelation = (attributeName, target, contentType)=>{
|
|
|
74
74
|
]
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
-
const enabledRWContentTypes =
|
|
78
|
-
reviewWorkflows$1.getVisibleContentTypesUID,
|
|
79
|
-
fp.filter((uid)=>reviewWorkflows$1.hasStageAttribute(contentTypes[uid]))
|
|
80
|
-
])(contentTypes);
|
|
77
|
+
const enabledRWContentTypes = reviewWorkflows$1.getVisibleContentTypesUID(contentTypes).filter((uid)=>reviewWorkflows$1.hasStageAttribute(contentTypes[uid]));
|
|
81
78
|
// Remove previously created join tables and persist the new ones
|
|
82
79
|
const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);
|
|
83
80
|
await removePersistedTablesWithSuffix('_strapi_stage_lnk');
|
|
@@ -101,10 +98,10 @@ var register = (async ({ strapi })=>{
|
|
|
101
98
|
strapi
|
|
102
99
|
});
|
|
103
100
|
// License limits
|
|
104
|
-
const reviewWorkflowsOptions =
|
|
101
|
+
const reviewWorkflowsOptions = lodash.defaultsDeep({}, strapi.ee.features.get('review-workflows'), {
|
|
105
102
|
numberOfWorkflows: workflows.MAX_WORKFLOWS,
|
|
106
103
|
stagesPerWorkflow: workflows.MAX_STAGES_PER_WORKFLOW
|
|
107
|
-
}
|
|
104
|
+
});
|
|
108
105
|
const workflowsValidationService = index.getService('validation', {
|
|
109
106
|
strapi
|
|
110
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import { defaultsDeep
|
|
1
|
+
{"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import { defaultsDeep } from 'lodash';\n\nimport type { Core, UID } from '@strapi/types';\n\nimport { getService, getAdminService } from './utils';\nimport migrateReviewWorkflowStagesColor from './migrations/set-stages-default-color';\nimport migrateReviewWorkflowStagesRoles from './migrations/set-stages-roles';\nimport migrateReviewWorkflowStagesTransferToRoles from './migrations/setup-stage-transfer-to-roles';\nimport migrateReviewWorkflowName from './migrations/set-workflow-default-name';\nimport migrateWorkflowsContentTypes from './migrations/multiple-workflows';\nimport migrateDeletedCTInWorkflows from './migrations/handle-deleted-ct-in-workflows';\nimport reviewWorkflowsMiddlewares from './middlewares/review-workflows';\n\nimport { getVisibleContentTypesUID, hasStageAttribute } from './utils/review-workflows';\n\nimport {\n ENTITY_STAGE_ATTRIBUTE,\n ENTITY_ASSIGNEE_ATTRIBUTE,\n STAGE_MODEL_UID,\n MAX_WORKFLOWS,\n MAX_STAGES_PER_WORKFLOW,\n} from './constants/workflows';\n\nconst setRelation = (attributeName: any, target: any, contentType: any) => {\n Object.assign(contentType.attributes, {\n [attributeName]: {\n writable: true,\n private: false,\n configurable: false,\n visible: false,\n useJoinTable: true, // We want a join table to persist data when downgrading to CE\n type: 'relation',\n relation: 'oneToOne',\n target,\n },\n });\n\n return contentType;\n};\n\n/**\n * Add the stage and assignee attributes to content types\n */\nfunction extendReviewWorkflowContentTypes({ strapi }: { strapi: Core.Strapi }) {\n const contentTypeToExtend = getVisibleContentTypesUID(strapi.contentTypes);\n\n for (const contentTypeUID of contentTypeToExtend) {\n strapi.get('content-types').extend(contentTypeUID, (contentType: any) => {\n // Set Stage attribute\n setRelation(ENTITY_STAGE_ATTRIBUTE, STAGE_MODEL_UID, contentType);\n // Set Assignee attribute\n setRelation(ENTITY_ASSIGNEE_ATTRIBUTE, 'admin::user', contentType);\n });\n }\n}\n\n/**\n * Persist the stage & assignee attributes so they are not removed when downgrading to CE.\n *\n * TODO: V6 - Instead of persisting the join tables, always create the stage & assignee attributes, even in CE mode\n * It was decided in V4 & V5 to not expose them in CE (as they pollute the CTs) but it's not worth given the complexity this needs\n */\nfunction persistRWOnDowngrade({ strapi }: { strapi: Core.Strapi }) {\n const { removePersistedTablesWithSuffix, persistTables } = getAdminService('persist-tables');\n\n return async ({ contentTypes }: { contentTypes: Record<UID.ContentType, any> }) => {\n const getStageTableToPersist = (contentTypeUID: UID.ContentType) => {\n // Persist the stage join table\n const { attributes, tableName } = strapi.db.metadata.get(contentTypeUID) as any;\n const joinTableName = attributes[ENTITY_STAGE_ATTRIBUTE].joinTable.name;\n return {\n name: joinTableName,\n dependsOn: [{ name: tableName }],\n };\n };\n\n const getAssigneeTableToPersist = (contentTypeUID: UID.ContentType) => {\n // Persist the assignee join table\n const { attributes, tableName } = strapi.db.metadata.get(contentTypeUID) as any;\n const joinTableName = attributes[ENTITY_ASSIGNEE_ATTRIBUTE].joinTable.name;\n return {\n name: joinTableName,\n dependsOn: [{ name: tableName }],\n };\n };\n\n const enabledRWContentTypes = getVisibleContentTypesUID(contentTypes).filter((uid) =>\n hasStageAttribute(contentTypes[uid])\n );\n\n // Remove previously created join tables and persist the new ones\n const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);\n await removePersistedTablesWithSuffix('_strapi_stage_lnk');\n await persistTables(stageJoinTablesToPersist);\n\n // Remove previously created join tables and persist the new ones\n const assigneeJoinTablesToPersist = enabledRWContentTypes.map(getAssigneeTableToPersist);\n await removePersistedTablesWithSuffix('_strapi_assignee_lnk');\n await persistTables(assigneeJoinTablesToPersist);\n };\n}\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n // Data Migrations\n strapi.hook('strapi::content-types.afterSync').register(persistRWOnDowngrade({ strapi }));\n strapi\n .hook('strapi::content-types.afterSync')\n .register(migrateReviewWorkflowStagesColor)\n .register(migrateReviewWorkflowStagesRoles)\n .register(migrateReviewWorkflowStagesTransferToRoles)\n .register(migrateReviewWorkflowName)\n .register(migrateWorkflowsContentTypes)\n .register(migrateDeletedCTInWorkflows);\n\n // Middlewares\n reviewWorkflowsMiddlewares.contentTypeMiddleware(strapi);\n\n // Schema customization\n extendReviewWorkflowContentTypes({ strapi });\n\n // License limits\n const reviewWorkflowsOptions = defaultsDeep({}, strapi.ee.features.get('review-workflows'), {\n numberOfWorkflows: MAX_WORKFLOWS,\n stagesPerWorkflow: MAX_STAGES_PER_WORKFLOW,\n });\n const workflowsValidationService = getService('validation', { strapi });\n workflowsValidationService.register(reviewWorkflowsOptions);\n};\n"],"names":["setRelation","attributeName","target","contentType","Object","assign","attributes","writable","private","configurable","visible","useJoinTable","type","relation","extendReviewWorkflowContentTypes","strapi","contentTypeToExtend","getVisibleContentTypesUID","contentTypes","contentTypeUID","get","extend","ENTITY_STAGE_ATTRIBUTE","STAGE_MODEL_UID","ENTITY_ASSIGNEE_ATTRIBUTE","persistRWOnDowngrade","removePersistedTablesWithSuffix","persistTables","getAdminService","getStageTableToPersist","tableName","db","metadata","joinTableName","joinTable","name","dependsOn","getAssigneeTableToPersist","enabledRWContentTypes","filter","uid","hasStageAttribute","stageJoinTablesToPersist","map","assigneeJoinTablesToPersist","hook","register","migrateReviewWorkflowStagesColor","migrateReviewWorkflowStagesRoles","migrateReviewWorkflowStagesTransferToRoles","migrateReviewWorkflowName","migrateWorkflowsContentTypes","migrateDeletedCTInWorkflows","reviewWorkflowsMiddlewares","contentTypeMiddleware","reviewWorkflowsOptions","defaultsDeep","ee","features","numberOfWorkflows","MAX_WORKFLOWS","stagesPerWorkflow","MAX_STAGES_PER_WORKFLOW","workflowsValidationService","getService"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAMA,WAAAA,GAAc,CAACC,aAAAA,EAAoBC,MAAAA,EAAaC,WAAAA,GAAAA;AACpDC,IAAAA,MAAAA,CAAOC,MAAM,CAACF,WAAAA,CAAYG,UAAU,EAAE;AACpC,QAAA,CAACL,gBAAgB;YACfM,QAAAA,EAAU,IAAA;YACVC,OAAAA,EAAS,KAAA;YACTC,YAAAA,EAAc,KAAA;YACdC,OAAAA,EAAS,KAAA;YACTC,YAAAA,EAAc,IAAA;YACdC,IAAAA,EAAM,UAAA;YACNC,QAAAA,EAAU,UAAA;AACVX,YAAAA;AACF;AACF,KAAA,CAAA;IAEA,OAAOC,WAAAA;AACT,CAAA;AAEA;;AAEC,IACD,SAASW,gCAAAA,CAAiC,EAAEC,MAAM,EAA2B,EAAA;IAC3E,MAAMC,mBAAAA,GAAsBC,2CAAAA,CAA0BF,MAAAA,CAAOG,YAAY,CAAA;IAEzE,KAAK,MAAMC,kBAAkBH,mBAAAA,CAAqB;AAChDD,QAAAA,MAAAA,CAAOK,GAAG,CAAC,eAAA,CAAA,CAAiBC,MAAM,CAACF,gBAAgB,CAAChB,WAAAA,GAAAA;;AAElDH,YAAAA,WAAAA,CAAYsB,kCAAwBC,yBAAAA,EAAiBpB,WAAAA,CAAAA;;AAErDH,YAAAA,WAAAA,CAAYwB,qCAA2B,aAAA,EAAerB,WAAAA,CAAAA;AACxD,QAAA,CAAA,CAAA;AACF,IAAA;AACF;AAEA;;;;;AAKC,IACD,SAASsB,oBAAAA,CAAqB,EAAEV,MAAM,EAA2B,EAAA;AAC/D,IAAA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
|
1
|
+
import { defaultsDeep } from 'lodash';
|
|
2
2
|
import { getService, getAdminService } from './utils/index.mjs';
|
|
3
3
|
import migrateReviewWorkflowStagesColor from './migrations/set-stages-default-color.mjs';
|
|
4
4
|
import migrateReviewWorkflowStagesRoles from './migrations/set-stages-roles.mjs';
|
|
@@ -72,10 +72,7 @@ const setRelation = (attributeName, target, contentType)=>{
|
|
|
72
72
|
]
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
|
-
const enabledRWContentTypes =
|
|
76
|
-
getVisibleContentTypesUID,
|
|
77
|
-
filter((uid)=>hasStageAttribute(contentTypes[uid]))
|
|
78
|
-
])(contentTypes);
|
|
75
|
+
const enabledRWContentTypes = getVisibleContentTypesUID(contentTypes).filter((uid)=>hasStageAttribute(contentTypes[uid]));
|
|
79
76
|
// Remove previously created join tables and persist the new ones
|
|
80
77
|
const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);
|
|
81
78
|
await removePersistedTablesWithSuffix('_strapi_stage_lnk');
|
|
@@ -99,10 +96,10 @@ var register = (async ({ strapi })=>{
|
|
|
99
96
|
strapi
|
|
100
97
|
});
|
|
101
98
|
// License limits
|
|
102
|
-
const reviewWorkflowsOptions = defaultsDeep({
|
|
99
|
+
const reviewWorkflowsOptions = defaultsDeep({}, strapi.ee.features.get('review-workflows'), {
|
|
103
100
|
numberOfWorkflows: MAX_WORKFLOWS,
|
|
104
101
|
stagesPerWorkflow: MAX_STAGES_PER_WORKFLOW
|
|
105
|
-
}
|
|
102
|
+
});
|
|
106
103
|
const workflowsValidationService = getService('validation', {
|
|
107
104
|
strapi
|
|
108
105
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["import { defaultsDeep
|
|
1
|
+
{"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["import { defaultsDeep } from 'lodash';\n\nimport type { Core, UID } from '@strapi/types';\n\nimport { getService, getAdminService } from './utils';\nimport migrateReviewWorkflowStagesColor from './migrations/set-stages-default-color';\nimport migrateReviewWorkflowStagesRoles from './migrations/set-stages-roles';\nimport migrateReviewWorkflowStagesTransferToRoles from './migrations/setup-stage-transfer-to-roles';\nimport migrateReviewWorkflowName from './migrations/set-workflow-default-name';\nimport migrateWorkflowsContentTypes from './migrations/multiple-workflows';\nimport migrateDeletedCTInWorkflows from './migrations/handle-deleted-ct-in-workflows';\nimport reviewWorkflowsMiddlewares from './middlewares/review-workflows';\n\nimport { getVisibleContentTypesUID, hasStageAttribute } from './utils/review-workflows';\n\nimport {\n ENTITY_STAGE_ATTRIBUTE,\n ENTITY_ASSIGNEE_ATTRIBUTE,\n STAGE_MODEL_UID,\n MAX_WORKFLOWS,\n MAX_STAGES_PER_WORKFLOW,\n} from './constants/workflows';\n\nconst setRelation = (attributeName: any, target: any, contentType: any) => {\n Object.assign(contentType.attributes, {\n [attributeName]: {\n writable: true,\n private: false,\n configurable: false,\n visible: false,\n useJoinTable: true, // We want a join table to persist data when downgrading to CE\n type: 'relation',\n relation: 'oneToOne',\n target,\n },\n });\n\n return contentType;\n};\n\n/**\n * Add the stage and assignee attributes to content types\n */\nfunction extendReviewWorkflowContentTypes({ strapi }: { strapi: Core.Strapi }) {\n const contentTypeToExtend = getVisibleContentTypesUID(strapi.contentTypes);\n\n for (const contentTypeUID of contentTypeToExtend) {\n strapi.get('content-types').extend(contentTypeUID, (contentType: any) => {\n // Set Stage attribute\n setRelation(ENTITY_STAGE_ATTRIBUTE, STAGE_MODEL_UID, contentType);\n // Set Assignee attribute\n setRelation(ENTITY_ASSIGNEE_ATTRIBUTE, 'admin::user', contentType);\n });\n }\n}\n\n/**\n * Persist the stage & assignee attributes so they are not removed when downgrading to CE.\n *\n * TODO: V6 - Instead of persisting the join tables, always create the stage & assignee attributes, even in CE mode\n * It was decided in V4 & V5 to not expose them in CE (as they pollute the CTs) but it's not worth given the complexity this needs\n */\nfunction persistRWOnDowngrade({ strapi }: { strapi: Core.Strapi }) {\n const { removePersistedTablesWithSuffix, persistTables } = getAdminService('persist-tables');\n\n return async ({ contentTypes }: { contentTypes: Record<UID.ContentType, any> }) => {\n const getStageTableToPersist = (contentTypeUID: UID.ContentType) => {\n // Persist the stage join table\n const { attributes, tableName } = strapi.db.metadata.get(contentTypeUID) as any;\n const joinTableName = attributes[ENTITY_STAGE_ATTRIBUTE].joinTable.name;\n return {\n name: joinTableName,\n dependsOn: [{ name: tableName }],\n };\n };\n\n const getAssigneeTableToPersist = (contentTypeUID: UID.ContentType) => {\n // Persist the assignee join table\n const { attributes, tableName } = strapi.db.metadata.get(contentTypeUID) as any;\n const joinTableName = attributes[ENTITY_ASSIGNEE_ATTRIBUTE].joinTable.name;\n return {\n name: joinTableName,\n dependsOn: [{ name: tableName }],\n };\n };\n\n const enabledRWContentTypes = getVisibleContentTypesUID(contentTypes).filter((uid) =>\n hasStageAttribute(contentTypes[uid])\n );\n\n // Remove previously created join tables and persist the new ones\n const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);\n await removePersistedTablesWithSuffix('_strapi_stage_lnk');\n await persistTables(stageJoinTablesToPersist);\n\n // Remove previously created join tables and persist the new ones\n const assigneeJoinTablesToPersist = enabledRWContentTypes.map(getAssigneeTableToPersist);\n await removePersistedTablesWithSuffix('_strapi_assignee_lnk');\n await persistTables(assigneeJoinTablesToPersist);\n };\n}\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n // Data Migrations\n strapi.hook('strapi::content-types.afterSync').register(persistRWOnDowngrade({ strapi }));\n strapi\n .hook('strapi::content-types.afterSync')\n .register(migrateReviewWorkflowStagesColor)\n .register(migrateReviewWorkflowStagesRoles)\n .register(migrateReviewWorkflowStagesTransferToRoles)\n .register(migrateReviewWorkflowName)\n .register(migrateWorkflowsContentTypes)\n .register(migrateDeletedCTInWorkflows);\n\n // Middlewares\n reviewWorkflowsMiddlewares.contentTypeMiddleware(strapi);\n\n // Schema customization\n extendReviewWorkflowContentTypes({ strapi });\n\n // License limits\n const reviewWorkflowsOptions = defaultsDeep({}, strapi.ee.features.get('review-workflows'), {\n numberOfWorkflows: MAX_WORKFLOWS,\n stagesPerWorkflow: MAX_STAGES_PER_WORKFLOW,\n });\n const workflowsValidationService = getService('validation', { strapi });\n workflowsValidationService.register(reviewWorkflowsOptions);\n};\n"],"names":["setRelation","attributeName","target","contentType","Object","assign","attributes","writable","private","configurable","visible","useJoinTable","type","relation","extendReviewWorkflowContentTypes","strapi","contentTypeToExtend","getVisibleContentTypesUID","contentTypes","contentTypeUID","get","extend","ENTITY_STAGE_ATTRIBUTE","STAGE_MODEL_UID","ENTITY_ASSIGNEE_ATTRIBUTE","persistRWOnDowngrade","removePersistedTablesWithSuffix","persistTables","getAdminService","getStageTableToPersist","tableName","db","metadata","joinTableName","joinTable","name","dependsOn","getAssigneeTableToPersist","enabledRWContentTypes","filter","uid","hasStageAttribute","stageJoinTablesToPersist","map","assigneeJoinTablesToPersist","hook","register","migrateReviewWorkflowStagesColor","migrateReviewWorkflowStagesRoles","migrateReviewWorkflowStagesTransferToRoles","migrateReviewWorkflowName","migrateWorkflowsContentTypes","migrateDeletedCTInWorkflows","reviewWorkflowsMiddlewares","contentTypeMiddleware","reviewWorkflowsOptions","defaultsDeep","ee","features","numberOfWorkflows","MAX_WORKFLOWS","stagesPerWorkflow","MAX_STAGES_PER_WORKFLOW","workflowsValidationService","getService"],"mappings":";;;;;;;;;;;;AAuBA,MAAMA,WAAAA,GAAc,CAACC,aAAAA,EAAoBC,MAAAA,EAAaC,WAAAA,GAAAA;AACpDC,IAAAA,MAAAA,CAAOC,MAAM,CAACF,WAAAA,CAAYG,UAAU,EAAE;AACpC,QAAA,CAACL,gBAAgB;YACfM,QAAAA,EAAU,IAAA;YACVC,OAAAA,EAAS,KAAA;YACTC,YAAAA,EAAc,KAAA;YACdC,OAAAA,EAAS,KAAA;YACTC,YAAAA,EAAc,IAAA;YACdC,IAAAA,EAAM,UAAA;YACNC,QAAAA,EAAU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K,4BAAAA,CAAAA,CACTL,QAAQ,CAACM,2BAAAA,CAAAA;;AAGZC,IAAAA,0BAAAA,CAA2BC,qBAAqB,CAACvC,MAAAA,CAAAA;;IAGjDD,gCAAAA,CAAiC;AAAEC,QAAAA;AAAO,KAAA,CAAA;;IAG1C,MAAMwC,sBAAAA,GAAyBC,YAAAA,CAAa,EAAC,EAAGzC,MAAAA,CAAO0C,EAAE,CAACC,QAAQ,CAACtC,GAAG,CAAC,kBAAA,CAAA,EAAqB;QAC1FuC,iBAAAA,EAAmBC,aAAAA;QACnBC,iBAAAA,EAAmBC;AACrB,KAAA,CAAA;IACA,MAAMC,0BAAAA,GAA6BC,WAAW,YAAA,EAAc;AAAEjD,QAAAA;AAAO,KAAA,CAAA;AACrEgD,IAAAA,0BAAAA,CAA2BjB,QAAQ,CAACS,sBAAAA,CAAAA;AACtC,CAAA;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('@strapi/utils');
|
|
4
|
-
var fp = require('lodash/fp');
|
|
5
4
|
var workflows = require('../constants/workflows.js');
|
|
5
|
+
var auditLogs = require('../audit-logs.js');
|
|
6
6
|
var index = require('../utils/index.js');
|
|
7
7
|
|
|
8
8
|
const { ApplicationError } = utils.errors;
|
|
@@ -27,7 +27,7 @@ var assignees = (({ strapi })=>{
|
|
|
27
27
|
* Update the assignee of an entity
|
|
28
28
|
*/ async updateEntityAssignee (entityToUpdate, model, assigneeId) {
|
|
29
29
|
const { documentId, locale } = entityToUpdate;
|
|
30
|
-
if (
|
|
30
|
+
if (assigneeId != null) {
|
|
31
31
|
const userExists = await index.getAdminService('user', {
|
|
32
32
|
strapi
|
|
33
33
|
}).exists({
|
|
@@ -59,6 +59,22 @@ var assignees = (({ strapi })=>{
|
|
|
59
59
|
}).update({
|
|
60
60
|
updated_at: new Date(entityToUpdate.updatedAt)
|
|
61
61
|
});
|
|
62
|
+
const newAssigneeId = entity?.[workflows.ENTITY_ASSIGNEE_ATTRIBUTE]?.id ?? null;
|
|
63
|
+
if (oldAssigneeId !== newAssigneeId) {
|
|
64
|
+
await utils.emitAudit({
|
|
65
|
+
strapi
|
|
66
|
+
}, auditLogs.AUDITED_EVENTS.ENTRY_ASSIGNEE_UPDATE, {
|
|
67
|
+
uid: model,
|
|
68
|
+
documentId,
|
|
69
|
+
locale: locale ?? null,
|
|
70
|
+
changes: {
|
|
71
|
+
assignee: {
|
|
72
|
+
before: oldAssigneeId,
|
|
73
|
+
after: newAssigneeId
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
62
78
|
return entity;
|
|
63
79
|
}
|
|
64
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignees.js","sources":["../../../server/src/services/assignees.ts"],"sourcesContent":["import type { Core, UID } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport {
|
|
1
|
+
{"version":3,"file":"assignees.js","sources":["../../../server/src/services/assignees.ts"],"sourcesContent":["import type { Core, UID } from '@strapi/types';\nimport { errors, emitAudit } from '@strapi/utils';\nimport { ENTITY_ASSIGNEE_ATTRIBUTE } from '../constants/workflows';\nimport { AUDITED_EVENTS } from '../audit-logs';\nimport { getService, getAdminService } from '../utils';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const metrics = getService('workflow-metrics', { strapi });\n\n return {\n async findEntityAssigneeId(id: string | number, model: UID.ContentType) {\n const entity = await strapi.db.query(model).findOne({\n where: { id },\n populate: [ENTITY_ASSIGNEE_ATTRIBUTE],\n select: [],\n });\n\n return entity?.[ENTITY_ASSIGNEE_ATTRIBUTE]?.id ?? null;\n },\n\n /**\n * Update the assignee of an entity\n */\n async updateEntityAssignee(\n entityToUpdate: {\n id: number | string;\n documentId: string;\n locale: string;\n updatedAt: string;\n },\n model: UID.ContentType,\n assigneeId: string | null\n ) {\n const { documentId, locale } = entityToUpdate;\n\n if (assigneeId != null) {\n const userExists = await getAdminService('user', { strapi }).exists({ id: assigneeId });\n\n if (!userExists) {\n throw new ApplicationError(`Selected user does not exist`);\n }\n }\n\n const oldAssigneeId = await this.findEntityAssigneeId(entityToUpdate.id, model);\n metrics.sendDidEditAssignee(oldAssigneeId, assigneeId || null);\n\n const entity = await strapi.documents(model).update({\n documentId,\n locale,\n data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: assigneeId || null },\n populate: [ENTITY_ASSIGNEE_ATTRIBUTE],\n fields: [],\n });\n\n // Update the `updated_at` field of the entity, so that the `status` is not considered `Modified`\n // NOTE: `updatedAt` is a protected attribute that can not be modified directly from the query layer\n // hence the knex query builder is used here.\n const { tableName } = strapi.db.metadata.get(model);\n await strapi.db\n .connection(tableName)\n .where({ id: entityToUpdate.id })\n .update({\n updated_at: new Date(entityToUpdate.updatedAt),\n });\n\n const newAssigneeId = entity?.[ENTITY_ASSIGNEE_ATTRIBUTE]?.id ?? null;\n\n if (oldAssigneeId !== newAssigneeId) {\n await emitAudit({ strapi }, AUDITED_EVENTS.ENTRY_ASSIGNEE_UPDATE, {\n uid: model,\n documentId,\n locale: locale ?? null,\n changes: { assignee: { before: oldAssigneeId, after: newAssigneeId } },\n });\n }\n\n return entity;\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","metrics","getService","findEntityAssigneeId","id","model","entity","db","query","findOne","where","populate","ENTITY_ASSIGNEE_ATTRIBUTE","select","updateEntityAssignee","entityToUpdate","assigneeId","documentId","locale","userExists","getAdminService","exists","oldAssigneeId","sendDidEditAssignee","documents","update","data","fields","tableName","metadata","get","connection","updated_at","Date","updatedAt","newAssigneeId","emitAudit","AUDITED_EVENTS","ENTRY_ASSIGNEE_UPDATE","uid","changes","assignee","before","after"],"mappings":";;;;;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,gBAAe,CAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;IACjD,MAAMC,OAAAA,GAAUC,iBAA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} from '@strapi/utils';
|
|
3
2
|
import { ENTITY_ASSIGNEE_ATTRIBUTE } from '../constants/workflows.mjs';
|
|
3
|
+
import { AUDITED_EVENTS } from '../audit-logs.mjs';
|
|
4
4
|
import { getService, getAdminService } from '../utils/index.mjs';
|
|
5
5
|
|
|
6
6
|
const { ApplicationError } = errors;
|
|
@@ -25,7 +25,7 @@ var assignees = (({ strapi })=>{
|
|
|
25
25
|
* Update the assignee of an entity
|
|
26
26
|
*/ async updateEntityAssignee (entityToUpdate, model, assigneeId) {
|
|
27
27
|
const { documentId, locale } = entityToUpdate;
|
|
28
|
-
if (
|
|
28
|
+
if (assigneeId != null) {
|
|
29
29
|
const userExists = await getAdminService('user', {
|
|
30
30
|
strapi
|
|
31
31
|
}).exists({
|
|
@@ -57,6 +57,22 @@ var assignees = (({ strapi })=>{
|
|
|
57
57
|
}).update({
|
|
58
58
|
updated_at: new Date(entityToUpdate.updatedAt)
|
|
59
59
|
});
|
|
60
|
+
const newAssigneeId = entity?.[ENTITY_ASSIGNEE_ATTRIBUTE]?.id ?? null;
|
|
61
|
+
if (oldAssigneeId !== newAssigneeId) {
|
|
62
|
+
await emitAudit({
|
|
63
|
+
strapi
|
|
64
|
+
}, AUDITED_EVENTS.ENTRY_ASSIGNEE_UPDATE, {
|
|
65
|
+
uid: model,
|
|
66
|
+
documentId,
|
|
67
|
+
locale: locale ?? null,
|
|
68
|
+
changes: {
|
|
69
|
+
assignee: {
|
|
70
|
+
before: oldAssigneeId,
|
|
71
|
+
after: newAssigneeId
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
60
76
|
return entity;
|
|
61
77
|
}
|
|
62
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignees.mjs","sources":["../../../server/src/services/assignees.ts"],"sourcesContent":["import type { Core, UID } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport {
|
|
1
|
+
{"version":3,"file":"assignees.mjs","sources":["../../../server/src/services/assignees.ts"],"sourcesContent":["import type { Core, UID } from '@strapi/types';\nimport { errors, emitAudit } from '@strapi/utils';\nimport { ENTITY_ASSIGNEE_ATTRIBUTE } from '../constants/workflows';\nimport { AUDITED_EVENTS } from '../audit-logs';\nimport { getService, getAdminService } from '../utils';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const metrics = getService('workflow-metrics', { strapi });\n\n return {\n async findEntityAssigneeId(id: string | number, model: UID.ContentType) {\n const entity = await strapi.db.query(model).findOne({\n where: { id },\n populate: [ENTITY_ASSIGNEE_ATTRIBUTE],\n select: [],\n });\n\n return entity?.[ENTITY_ASSIGNEE_ATTRIBUTE]?.id ?? null;\n },\n\n /**\n * Update the assignee of an entity\n */\n async updateEntityAssignee(\n entityToUpdate: {\n id: number | string;\n documentId: string;\n locale: string;\n updatedAt: string;\n },\n model: UID.ContentType,\n assigneeId: string | null\n ) {\n const { documentId, locale } = entityToUpdate;\n\n if (assigneeId != null) {\n const userExists = await getAdminService('user', { strapi }).exists({ id: assigneeId });\n\n if (!userExists) {\n throw new ApplicationError(`Selected user does not exist`);\n }\n }\n\n const oldAssigneeId = await this.findEntityAssigneeId(entityToUpdate.id, model);\n metrics.sendDidEditAssignee(oldAssigneeId, assigneeId || null);\n\n const entity = await strapi.documents(model).update({\n documentId,\n locale,\n data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: assigneeId || null },\n populate: [ENTITY_ASSIGNEE_ATTRIBUTE],\n fields: [],\n });\n\n // Update the `updated_at` field of the entity, so that the `status` is not considered `Modified`\n // NOTE: `updatedAt` is a protected attribute that can not be modified directly from the query layer\n // hence the knex query builder is used here.\n const { tableName } = strapi.db.metadata.get(model);\n await strapi.db\n .connection(tableName)\n .where({ id: entityToUpdate.id })\n .update({\n updated_at: new Date(entityToUpdate.updatedAt),\n });\n\n const newAssigneeId = entity?.[ENTITY_ASSIGNEE_ATTRIBUTE]?.id ?? null;\n\n if (oldAssigneeId !== newAssigneeId) {\n await emitAudit({ strapi }, AUDITED_EVENTS.ENTRY_ASSIGNEE_UPDATE, {\n uid: model,\n documentId,\n locale: locale ?? null,\n changes: { assignee: { before: oldAssigneeId, after: newAssigneeId } },\n });\n }\n\n return entity;\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","metrics","getService","findEntityAssigneeId","id","model","entity","db","query","findOne","where","populate","ENTITY_ASSIGNEE_ATTRIBUTE","select","updateEntityAssignee","entityToUpdate","assigneeId","documentId","locale","userExists","getAdminService","exists","oldAssigneeId","sendDidEditAssignee","documents","update","data","fields","tableName","metadata","get","connection","updated_at","Date","updatedAt","newAssigneeId","emitAudit","AUDITED_EVENTS","ENTRY_ASSIGNEE_UPDATE","uid","changes","assignee","before","after"],"mappings":";;;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,gBAAe,CAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;IACjD,MAAMC,OAAAA,GAAUC,WAAW,kBAAA,EAAoB;AAAEF,QAAAA;AAAO,KAAA,CAAA;IAExD,OAAO;QACL,MAAMG,oBAAAA,CAAAA,CAAqBC,EAAmB,EAAEC,KAAsB,EAAA;YACpE,MAAMC,MAAAA,GAAS,MAAMN,MAAAA,CAAOO,EAAE,CAACC,KAAK,CAACH,KAAAA,CAAAA,CAAOI,OAAO,CAAC;gBAClDC,KAAAA,EAAO;AAAEN,oBAAAA;AAAG,iBAAA;gBACZO,QAAAA,EAAU;AAACC,oBAAAA;AAA0B,iBAAA;AACrCC,gBAAAA,MAAAA,EAAQ;AACV,aAAA,CAAA;AAEA,YAAA,OAAOP,MAAAA,GAASM,yBAAAA,CAA0B,EAAER,EAAAA,IAAM,IAAA;AACpD,QAAA,CAAA;AAEA;;AAEC,QACD,MAAMU,oBAAAA,CAAAA,CACJC,cAKC,EACDV,KAAsB,EACtBW,UAAyB,EAAA;AAEzB,YAAA,MAAM,EAAEC,UAAU,EAAEC,MAAM,EAAE,GAAGH,cAA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AAAA,GAASM,yBAAAA,CAA0B,EAAER,EAAAA,IAAM,IAAA;AAEjE,YAAA,IAAIkB,kBAAkBa,aAAAA,EAAe;AACnC,gBAAA,MAAMC,SAAAA,CAAU;AAAEpC,oBAAAA;iBAAO,EAAGqC,cAAAA,CAAeC,qBAAqB,EAAE;oBAChEC,GAAAA,EAAKlC,KAAAA;AACLY,oBAAAA,UAAAA;AACAC,oBAAAA,MAAAA,EAAQA,MAAAA,IAAU,IAAA;oBAClBsB,OAAAA,EAAS;wBAAEC,QAAAA,EAAU;4BAAEC,MAAAA,EAAQpB,aAAAA;4BAAeqB,KAAAA,EAAOR;AAAc;AAAE;AACvE,iBAAA,CAAA;AACF,YAAA;YAEA,OAAO7B,MAAAA;AACT,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('@strapi/utils');
|
|
4
|
-
var fp = require('lodash/fp');
|
|
5
4
|
var workflows = require('../constants/workflows.js');
|
|
6
5
|
var webhookEvents = require('../constants/webhook-events.js');
|
|
7
6
|
var index = require('../utils/index.js');
|
|
@@ -43,7 +42,7 @@ var index = require('../utils/index.js');
|
|
|
43
42
|
}
|
|
44
43
|
const data = ctx.params.data;
|
|
45
44
|
// Assign the default stage if the entity doesn't have one
|
|
46
|
-
if (ctx.params?.data &&
|
|
45
|
+
if (ctx.params?.data && data[workflows.ENTITY_STAGE_ATTRIBUTE] == null) {
|
|
47
46
|
data[workflows.ENTITY_STAGE_ATTRIBUTE] = {
|
|
48
47
|
id: workflow.stages[0].id
|
|
49
48
|
};
|
|
@@ -56,7 +55,7 @@ const handleStageOnUpdate = async (ctx, next)=>{
|
|
|
56
55
|
}
|
|
57
56
|
const { documentId } = ctx.params;
|
|
58
57
|
const data = ctx.params.data;
|
|
59
|
-
if (
|
|
58
|
+
if (data?.[workflows.ENTITY_STAGE_ATTRIBUTE] == null) {
|
|
60
59
|
delete data?.[workflows.ENTITY_STAGE_ATTRIBUTE];
|
|
61
60
|
return next();
|
|
62
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-service-middleware.js","sources":["../../../server/src/services/document-service-middleware.ts"],"sourcesContent":["import type { Modules } from '@strapi/types';\nimport { errors } from '@strapi/utils';\n\nimport {
|
|
1
|
+
{"version":3,"file":"document-service-middleware.js","sources":["../../../server/src/services/document-service-middleware.ts"],"sourcesContent":["import type { Modules } from '@strapi/types';\nimport { errors } from '@strapi/utils';\n\nimport { ENTITY_STAGE_ATTRIBUTE } from '../constants/workflows';\nimport { WORKFLOW_UPDATE_STAGE } from '../constants/webhook-events';\nimport { getService } from '../utils';\n\ntype Middleware = Modules.Documents.Middleware.Middleware;\n\n/**\n * Get the stage information of an entity\n * @param {String} uid\n * @param {Number} id\n * @returns {Object}\n */\nconst getEntityStage = async (uid: any, id: any, params: any) => {\n const entity = await strapi.documents(uid).findOne({\n ...params,\n documentId: id,\n status: 'draft',\n populate: {\n [ENTITY_STAGE_ATTRIBUTE]: {\n populate: {\n workflow: true,\n },\n },\n },\n });\n\n return entity?.[ENTITY_STAGE_ATTRIBUTE] ?? {};\n};\n\n/**\n * Ensures the entity is assigned to the default workflow stage\n */\nconst assignStageOnCreate: Middleware = async (ctx, next) => {\n if (ctx.action !== 'create' && ctx.action !== 'clone') {\n return next();\n }\n\n /**\n * Content types can have assigned workflows,\n * if the CT has one, assign a default value to the stage attribute if it's not present\n */\n const workflow = await getService('workflows').getAssignedWorkflow(ctx.contentType.uid, {\n populate: 'stages',\n });\n\n if (!workflow) {\n return next();\n }\n\n const data = ctx.params.data as Record<string, any>;\n\n // Assign the default stage if the entity doesn't have one\n if (ctx.params?.data && data[ENTITY_STAGE_ATTRIBUTE] == null) {\n data[ENTITY_STAGE_ATTRIBUTE] = { id: workflow.stages[0].id };\n }\n\n return next();\n};\n\nconst handleStageOnUpdate: Middleware = async (ctx, next) => {\n if (ctx.action !== 'update') {\n return next();\n }\n\n const { documentId } = ctx.params;\n const data = ctx.params.data as any;\n\n if (data?.[ENTITY_STAGE_ATTRIBUTE] == null) {\n delete data?.[ENTITY_STAGE_ATTRIBUTE];\n return next();\n }\n\n /**\n * Get last stage of the entity\n */\n const previousStage = await getEntityStage(ctx.contentType.uid, documentId, ctx.params);\n\n const result = await next();\n\n if (!result) {\n return result;\n }\n\n // @ts-expect-error - Property 'strapi_stage' does not exist on type ...\n const updatedStage = result?.[ENTITY_STAGE_ATTRIBUTE];\n\n // Stage might be null if field is not populated\n if (updatedStage && previousStage?.id && previousStage.id !== updatedStage.id) {\n const model = strapi.getModel(ctx.contentType.uid);\n\n strapi.eventHub.emit(WORKFLOW_UPDATE_STAGE, {\n model: model.modelName,\n uid: model.uid,\n // TODO v6: Rename to \"entry\", which is what is used for regular CRUD updates\n entity: {\n // @ts-expect-error - Property 'id' does not exist on type 'number'\n id: result?.id,\n documentId,\n // @ts-expect-error - Property 'locale' does not exist on type 'number'\n locale: result?.locale,\n status: 'draft',\n },\n workflow: {\n id: previousStage.workflow.id,\n stages: {\n from: {\n id: previousStage.id,\n name: previousStage.name,\n },\n to: {\n id: updatedStage.id,\n name: updatedStage.name,\n },\n },\n },\n });\n }\n\n return next();\n};\n\n/**\n * Check if the entity is at the required stage before publish\n */\nconst checkStageBeforePublish: Middleware = async (ctx, next) => {\n if (ctx.action !== 'publish') {\n return next();\n }\n\n const workflow = await getService('workflows').getAssignedWorkflow(ctx.contentType.uid, {\n populate: 'stageRequiredToPublish',\n });\n\n if (!workflow || !workflow.stageRequiredToPublish) {\n return next();\n }\n\n const { documentId } = ctx.params;\n const entryStage = await getEntityStage(ctx.contentType.uid, documentId, ctx.params);\n\n if (entryStage.id !== workflow.stageRequiredToPublish.id) {\n throw new errors.ValidationError('Entry is not at the required stage to publish');\n }\n\n return next();\n};\n\nexport default () => ({\n assignStageOnCreate,\n handleStageOnUpdate,\n checkStageBeforePublish,\n});\n"],"names":["getEntityStage","uid","id","params","entity","strapi","documents","findOne","documentId","status","populate","ENTITY_STAGE_ATTRIBUTE","workflow","assignStageOnCreate","ctx","next","action","getService","getAssignedWorkflow","contentType","data","stages","handleStageOnUpdate","previousStage","result","updatedStage","model","getModel","eventHub","emit","WORKFLOW_UPDATE_STAGE","modelName","locale","from","name","to","checkStageBeforePublish","stageRequiredToPublish","entryStage","errors","ValidationError"],"mappings":";;;;;;;AASA;;;;;AAKC,IACD,MAAMA,cAAAA,GAAiB,OAAOC,GAAAA,EAAUC,EAAAA,EAASC,MAAAA,GAAAA;AAC/C,IAAA,MAAMC,SAAS,MAAMC,MAAAA,CAAOC,SAAS,CAACL,GAAAA,CAAAA,CAAKM,OAAO,CAAC;AACjD,QAAA,GAAGJ,MAAM;QACTK,UAAAA,EAAYN,EAAAA;QACZO,MAAAA,EAAQ,OAAA;QACRC,QAAAA,EAAU;AACR,YAAA,CAACC,mCAAyB;gBACxBD,QAAAA,EAAU;oBACRE,QAAAA,EAAU;AACZ;AACF;AACF;AACF,KAAA,CAAA;AAEA,IAAA,OAAOR,MAAAA,GAASO,gCAAAA,CAAuB,IAAI,EAAC;AAC9C,CAAA;AAEA;;IAGA,MAAME,mBAAAA,GAAkC,OAAOC,GAAAA,EAAKC,IAAAA,GAAAA;AAClD,IAAA,IAAID,IAAIE,MAAM,KAAK,YAAYF,GAAAA,CAAIE,MAAM,KAAK,OAAA,EAAS;QACrD,OAAOD,IAAAA,EAAAA;AACT,IAAA;AAEA;;;MAIA,MAAMH,QAAAA,GAAW,MAAMK,gBAAAA,CAAW,WAAA,CAAA,CAAaC,mBAAmB,CAACJ,GAAAA,CAAIK,WAAW,CAAClB,GAAG,EAAE;QACtFS,QAAAA,EAAU;AACZ,KAAA,CAAA;AAEA,IAAA,IAAI,CAACE,QAAAA,EAAU;QACb,OAAOG,IAAAA,EAAAA;AACT,IAAA;AAEA,IAAA,MAAMK,IAAAA,GAAON,GAAAA,CAAIX,MAAM,CAACiB,IAAI;;IAG5B,IAAIN,GAAAA,CAAIX,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