@strapi/review-workflows 5.56.0 → 5.58.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/entitlements.js +29 -0
- package/dist/server/entitlements.js.map +1 -0
- package/dist/server/entitlements.mjs +27 -0
- package/dist/server/entitlements.mjs.map +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +5 -0
- package/dist/server/index.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 +6 -7
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +6 -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/entitlements.d.ts +7 -0
- package/dist/server/src/entitlements.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +17 -14
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.js","sources":["../../server/src/entitlements.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { MAX_WORKFLOWS, MAX_STAGES_PER_WORKFLOW } from './constants/workflows';\nimport { clampMaxWorkflows, clampMaxStagesPerWorkflow } from './utils/review-workflows';\n\ntype Feature = Parameters<\n Parameters<Core.Strapi['ee']['entitlements']['register']>[0]['limits'][number]['get']\n>[0];\n\nconst optionsOf = (feature: Feature) => (typeof feature === 'object' ? feature.options : undefined);\n\n/**\n * Exposes the clamped workflow limits to the Plan card and the debug dump. Registered whatever\n * the boot-time license says, so a lapsed or later-renewed license still resolves.\n */\nexport const registerReviewWorkflowsEntitlements = (strapi: Core.Strapi) => {\n strapi.ee.entitlements.register({\n feature: 'review-workflows',\n limits: [\n {\n key: 'numberOfWorkflows',\n unit: 'count',\n get: (feature) =>\n clampMaxWorkflows(Number(optionsOf(feature)?.numberOfWorkflows) || MAX_WORKFLOWS),\n },\n {\n key: 'stagesPerWorkflow',\n unit: 'count',\n get: (feature) =>\n clampMaxStagesPerWorkflow(\n Number(optionsOf(feature)?.stagesPerWorkflow) || MAX_STAGES_PER_WORKFLOW\n ),\n },\n ],\n });\n};\n"],"names":["optionsOf","feature","options","undefined","registerReviewWorkflowsEntitlements","strapi","ee","entitlements","register","limits","key","unit","get","clampMaxWorkflows","Number","numberOfWorkflows","MAX_WORKFLOWS","clampMaxStagesPerWorkflow","stagesPerWorkflow","MAX_STAGES_PER_WORKFLOW"],"mappings":";;;;;AASA,MAAMA,SAAAA,GAAY,CAACC,OAAAA,GAAsB,OAAOA,YAAY,QAAA,GAAWA,OAAAA,CAAQC,OAAO,GAAGC,SAAAA;AAEzF;;;IAIO,MAAMC,mCAAAA,GAAsC,CAACC,MAAAA,GAAAA;AAClDA,IAAAA,MAAAA,CAAOC,EAAE,CAACC,YAAY,CAACC,QAAQ,CAAC;QAC9BP,OAAAA,EAAS,kBAAA;QACTQ,MAAAA,EAAQ;AACN,YAAA;gBACEC,GAAAA,EAAK,mBAAA;gBACLC,IAAAA,EAAM,OAAA;AACNC,gBAAAA,GAAAA,EAAK,CAACX,OAAAA,GACJY,iCAAAA,CAAkBC,MAAAA,CAAOd,SAAAA,CAAUC,UAAUc,iBAAAA,CAAAA,IAAsBC,uBAAAA;AACvE,aAAA;AACA,YAAA;gBACEN,GAAAA,EAAK,mBAAA;gBACLC,IAAAA,EAAM,OAAA;AACNC,gBAAAA,GAAAA,EAAK,CAACX,OAAAA,GACJgB,yCAAAA,CACEH,MAAAA,CAAOd,SAAAA,CAAUC,UAAUiB,iBAAAA,CAAAA,IAAsBC,iCAAAA;AAEvD;AACD;AACH,KAAA,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MAX_WORKFLOWS, MAX_STAGES_PER_WORKFLOW } from './constants/workflows.mjs';
|
|
2
|
+
import { clampMaxWorkflows, clampMaxStagesPerWorkflow } from './utils/review-workflows.mjs';
|
|
3
|
+
|
|
4
|
+
const optionsOf = (feature)=>typeof feature === 'object' ? feature.options : undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Exposes the clamped workflow limits to the Plan card and the debug dump. Registered whatever
|
|
7
|
+
* the boot-time license says, so a lapsed or later-renewed license still resolves.
|
|
8
|
+
*/ const registerReviewWorkflowsEntitlements = (strapi)=>{
|
|
9
|
+
strapi.ee.entitlements.register({
|
|
10
|
+
feature: 'review-workflows',
|
|
11
|
+
limits: [
|
|
12
|
+
{
|
|
13
|
+
key: 'numberOfWorkflows',
|
|
14
|
+
unit: 'count',
|
|
15
|
+
get: (feature)=>clampMaxWorkflows(Number(optionsOf(feature)?.numberOfWorkflows) || MAX_WORKFLOWS)
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
key: 'stagesPerWorkflow',
|
|
19
|
+
unit: 'count',
|
|
20
|
+
get: (feature)=>clampMaxStagesPerWorkflow(Number(optionsOf(feature)?.stagesPerWorkflow) || MAX_STAGES_PER_WORKFLOW)
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { registerReviewWorkflowsEntitlements };
|
|
27
|
+
//# sourceMappingURL=entitlements.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.mjs","sources":["../../server/src/entitlements.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { MAX_WORKFLOWS, MAX_STAGES_PER_WORKFLOW } from './constants/workflows';\nimport { clampMaxWorkflows, clampMaxStagesPerWorkflow } from './utils/review-workflows';\n\ntype Feature = Parameters<\n Parameters<Core.Strapi['ee']['entitlements']['register']>[0]['limits'][number]['get']\n>[0];\n\nconst optionsOf = (feature: Feature) => (typeof feature === 'object' ? feature.options : undefined);\n\n/**\n * Exposes the clamped workflow limits to the Plan card and the debug dump. Registered whatever\n * the boot-time license says, so a lapsed or later-renewed license still resolves.\n */\nexport const registerReviewWorkflowsEntitlements = (strapi: Core.Strapi) => {\n strapi.ee.entitlements.register({\n feature: 'review-workflows',\n limits: [\n {\n key: 'numberOfWorkflows',\n unit: 'count',\n get: (feature) =>\n clampMaxWorkflows(Number(optionsOf(feature)?.numberOfWorkflows) || MAX_WORKFLOWS),\n },\n {\n key: 'stagesPerWorkflow',\n unit: 'count',\n get: (feature) =>\n clampMaxStagesPerWorkflow(\n Number(optionsOf(feature)?.stagesPerWorkflow) || MAX_STAGES_PER_WORKFLOW\n ),\n },\n ],\n });\n};\n"],"names":["optionsOf","feature","options","undefined","registerReviewWorkflowsEntitlements","strapi","ee","entitlements","register","limits","key","unit","get","clampMaxWorkflows","Number","numberOfWorkflows","MAX_WORKFLOWS","clampMaxStagesPerWorkflow","stagesPerWorkflow","MAX_STAGES_PER_WORKFLOW"],"mappings":";;;AASA,MAAMA,SAAAA,GAAY,CAACC,OAAAA,GAAsB,OAAOA,YAAY,QAAA,GAAWA,OAAAA,CAAQC,OAAO,GAAGC,SAAAA;AAEzF;;;IAIO,MAAMC,mCAAAA,GAAsC,CAACC,MAAAA,GAAAA;AAClDA,IAAAA,MAAAA,CAAOC,EAAE,CAACC,YAAY,CAACC,QAAQ,CAAC;QAC9BP,OAAAA,EAAS,kBAAA;QACTQ,MAAAA,EAAQ;AACN,YAAA;gBACEC,GAAAA,EAAK,mBAAA;gBACLC,IAAAA,EAAM,OAAA;AACNC,gBAAAA,GAAAA,EAAK,CAACX,OAAAA,GACJY,iBAAAA,CAAkBC,MAAAA,CAAOd,SAAAA,CAAUC,UAAUc,iBAAAA,CAAAA,IAAsBC,aAAAA;AACvE,aAAA;AACA,YAAA;gBACEN,GAAAA,EAAK,mBAAA;gBACLC,IAAAA,EAAM,OAAA;AACNC,gBAAAA,GAAAA,EAAK,CAACX,OAAAA,GACJgB,yBAAAA,CACEH,MAAAA,CAAOd,SAAAA,CAAUC,UAAUiB,iBAAAA,CAAAA,IAAsBC,uBAAAA;AAEvD;AACD;AACH,KAAA,CAAA;AACF;;;;"}
|
package/dist/server/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var destroy = require('./destroy.js');
|
|
|
7
7
|
var index$1 = require('./routes/index.js');
|
|
8
8
|
var index$3 = require('./services/index.js');
|
|
9
9
|
var index$2 = require('./controllers/index.js');
|
|
10
|
+
var entitlements = require('./entitlements.js');
|
|
10
11
|
|
|
11
12
|
const getPlugin = ()=>{
|
|
12
13
|
if (strapi.ee.features.isEnabled('review-workflows')) {
|
|
@@ -21,6 +22,10 @@ const getPlugin = ()=>{
|
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
return {
|
|
25
|
+
// Keeps the limits resolvable for a license that lapsed before boot
|
|
26
|
+
register ({ strapi: strapi1 }) {
|
|
27
|
+
entitlements.registerReviewWorkflowsEntitlements(strapi1);
|
|
28
|
+
},
|
|
24
29
|
// Always return contentTypes to avoid losing data when the feature is disabled
|
|
25
30
|
// or downgrading the license
|
|
26
31
|
contentTypes: index$4
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import register from './register';\nimport contentTypes from './content-types';\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport routes from './routes';\nimport services from './services';\nimport controllers from './controllers';\n\nconst getPlugin = () => {\n if (strapi.ee.features.isEnabled('review-workflows')) {\n return {\n register,\n bootstrap,\n destroy,\n contentTypes,\n services,\n controllers,\n routes,\n };\n }\n\n return {\n // Always return contentTypes to avoid losing data when the feature is disabled\n // or downgrading the license\n contentTypes,\n };\n};\n\nexport default getPlugin();\n"],"names":["getPlugin","strapi","ee","features","isEnabled","register","bootstrap","destroy","contentTypes","services","controllers","routes"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport register from './register';\nimport contentTypes from './content-types';\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport routes from './routes';\nimport services from './services';\nimport controllers from './controllers';\nimport { registerReviewWorkflowsEntitlements } from './entitlements';\n\nconst getPlugin = () => {\n if (strapi.ee.features.isEnabled('review-workflows')) {\n return {\n register,\n bootstrap,\n destroy,\n contentTypes,\n services,\n controllers,\n routes,\n };\n }\n\n return {\n // Keeps the limits resolvable for a license that lapsed before boot\n register({ strapi }: { strapi: Core.Strapi }) {\n registerReviewWorkflowsEntitlements(strapi);\n },\n // Always return contentTypes to avoid losing data when the feature is disabled\n // or downgrading the license\n contentTypes,\n };\n};\n\nexport default getPlugin();\n"],"names":["getPlugin","strapi","ee","features","isEnabled","register","bootstrap","destroy","contentTypes","services","controllers","routes","registerReviewWorkflowsEntitlements"],"mappings":";;;;;;;;;;;AAWA,MAAMA,SAAAA,GAAY,IAAA;AAChB,IAAA,IAAIC,OAAOC,EAAE,CAACC,QAAQ,CAACC,SAAS,CAAC,kBAAA,CAAA,EAAqB;QACpD,OAAO;AACLC,YAAAA,QAAAA;AACAC,YAAAA,SAAAA;AACAC,YAAAA,OAAAA;AACAC,0BAAAA,OAAAA;AACAC,sBAAAA,OAAAA;AACAC,yBAAAA,OAAAA;AACAC,oBAAAA;AACF,SAAA;AACF,IAAA;IAEA,OAAO;;QAELN,QAAAA,CAAAA,CAAS,EAAEJ,MAAAA,EAAAA,OAAM,EAA2B,EAAA;YAC1CW,gDAAAA,CAAoCX,OAAAA,CAAAA;AACtC,QAAA,CAAA;;;AAGAO,sBAAAA;AACF,KAAA;AACF,CAAA;AAEA,YAAeR,SAAAA,EAAAA;;;;"}
|
package/dist/server/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import destroy from './destroy.mjs';
|
|
|
5
5
|
import routes from './routes/index.mjs';
|
|
6
6
|
import services from './services/index.mjs';
|
|
7
7
|
import controllers from './controllers/index.mjs';
|
|
8
|
+
import { registerReviewWorkflowsEntitlements } from './entitlements.mjs';
|
|
8
9
|
|
|
9
10
|
const getPlugin = ()=>{
|
|
10
11
|
if (strapi.ee.features.isEnabled('review-workflows')) {
|
|
@@ -19,6 +20,10 @@ const getPlugin = ()=>{
|
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
return {
|
|
23
|
+
// Keeps the limits resolvable for a license that lapsed before boot
|
|
24
|
+
register ({ strapi: strapi1 }) {
|
|
25
|
+
registerReviewWorkflowsEntitlements(strapi1);
|
|
26
|
+
},
|
|
22
27
|
// Always return contentTypes to avoid losing data when the feature is disabled
|
|
23
28
|
// or downgrading the license
|
|
24
29
|
contentTypes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import register from './register';\nimport contentTypes from './content-types';\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport routes from './routes';\nimport services from './services';\nimport controllers from './controllers';\n\nconst getPlugin = () => {\n if (strapi.ee.features.isEnabled('review-workflows')) {\n return {\n register,\n bootstrap,\n destroy,\n contentTypes,\n services,\n controllers,\n routes,\n };\n }\n\n return {\n // Always return contentTypes to avoid losing data when the feature is disabled\n // or downgrading the license\n contentTypes,\n };\n};\n\nexport default getPlugin();\n"],"names":["getPlugin","strapi","ee","features","isEnabled","register","bootstrap","destroy","contentTypes","services","controllers","routes"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport register from './register';\nimport contentTypes from './content-types';\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport routes from './routes';\nimport services from './services';\nimport controllers from './controllers';\nimport { registerReviewWorkflowsEntitlements } from './entitlements';\n\nconst getPlugin = () => {\n if (strapi.ee.features.isEnabled('review-workflows')) {\n return {\n register,\n bootstrap,\n destroy,\n contentTypes,\n services,\n controllers,\n routes,\n };\n }\n\n return {\n // Keeps the limits resolvable for a license that lapsed before boot\n register({ strapi }: { strapi: Core.Strapi }) {\n registerReviewWorkflowsEntitlements(strapi);\n },\n // Always return contentTypes to avoid losing data when the feature is disabled\n // or downgrading the license\n contentTypes,\n };\n};\n\nexport default getPlugin();\n"],"names":["getPlugin","strapi","ee","features","isEnabled","register","bootstrap","destroy","contentTypes","services","controllers","routes","registerReviewWorkflowsEntitlements"],"mappings":";;;;;;;;;AAWA,MAAMA,SAAAA,GAAY,IAAA;AAChB,IAAA,IAAIC,OAAOC,EAAE,CAACC,QAAQ,CAACC,SAAS,CAAC,kBAAA,CAAA,EAAqB;QACpD,OAAO;AACLC,YAAAA,QAAAA;AACAC,YAAAA,SAAAA;AACAC,YAAAA,OAAAA;AACAC,YAAAA,YAAAA;AACAC,YAAAA,QAAAA;AACAC,YAAAA,WAAAA;AACAC,YAAAA;AACF,SAAA;AACF,IAAA;IAEA,OAAO;;QAELN,QAAAA,CAAAA,CAAS,EAAEJ,MAAAA,EAAAA,OAAM,EAA2B,EAAA;YAC1CW,mCAAAA,CAAoCX,OAAAA,CAAAA;AACtC,QAAA,CAAA;;;AAGAO,QAAAA;AACF,KAAA;AACF,CAAA;AAEA,YAAeR,SAAAA,EAAAA;;;;"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var fp = require('lodash/fp');
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* A Strapi middleware function that adds support for review workflows.
|
|
9
7
|
*
|
|
@@ -23,7 +21,13 @@ var fp = require('lodash/fp');
|
|
|
23
21
|
// Move reviewWorkflows to options.reviewWorkflows
|
|
24
22
|
const { reviewWorkflows, ...contentType } = ctx.request.body.contentType;
|
|
25
23
|
if (typeof reviewWorkflows === 'boolean') {
|
|
26
|
-
ctx.request.body.contentType =
|
|
24
|
+
ctx.request.body.contentType = {
|
|
25
|
+
...contentType,
|
|
26
|
+
options: {
|
|
27
|
+
...contentType.options,
|
|
28
|
+
reviewWorkflows
|
|
29
|
+
}
|
|
30
|
+
};
|
|
27
31
|
}
|
|
28
32
|
};
|
|
29
33
|
strapi.server.router.use('/content-type-builder/content-types/:uid?', (ctx, next)=>{
|
|
@@ -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');
|
|
@@ -10,6 +10,7 @@ var multipleWorkflows = require('./migrations/multiple-workflows.js');
|
|
|
10
10
|
var handleDeletedCtInWorkflows = require('./migrations/handle-deleted-ct-in-workflows.js');
|
|
11
11
|
var reviewWorkflows = require('./middlewares/review-workflows.js');
|
|
12
12
|
var reviewWorkflows$1 = require('./utils/review-workflows.js');
|
|
13
|
+
var entitlements = require('./entitlements.js');
|
|
13
14
|
var workflows = require('./constants/workflows.js');
|
|
14
15
|
|
|
15
16
|
const setRelation = (attributeName, target, contentType)=>{
|
|
@@ -74,10 +75,7 @@ const setRelation = (attributeName, target, contentType)=>{
|
|
|
74
75
|
]
|
|
75
76
|
};
|
|
76
77
|
};
|
|
77
|
-
const enabledRWContentTypes =
|
|
78
|
-
reviewWorkflows$1.getVisibleContentTypesUID,
|
|
79
|
-
fp.filter((uid)=>reviewWorkflows$1.hasStageAttribute(contentTypes[uid]))
|
|
80
|
-
])(contentTypes);
|
|
78
|
+
const enabledRWContentTypes = reviewWorkflows$1.getVisibleContentTypesUID(contentTypes).filter((uid)=>reviewWorkflows$1.hasStageAttribute(contentTypes[uid]));
|
|
81
79
|
// Remove previously created join tables and persist the new ones
|
|
82
80
|
const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);
|
|
83
81
|
await removePersistedTablesWithSuffix('_strapi_stage_lnk');
|
|
@@ -101,14 +99,15 @@ var register = (async ({ strapi })=>{
|
|
|
101
99
|
strapi
|
|
102
100
|
});
|
|
103
101
|
// License limits
|
|
104
|
-
const reviewWorkflowsOptions =
|
|
102
|
+
const reviewWorkflowsOptions = lodash.defaultsDeep({}, strapi.ee.features.get('review-workflows'), {
|
|
105
103
|
numberOfWorkflows: workflows.MAX_WORKFLOWS,
|
|
106
104
|
stagesPerWorkflow: workflows.MAX_STAGES_PER_WORKFLOW
|
|
107
|
-
}
|
|
105
|
+
});
|
|
108
106
|
const workflowsValidationService = index.getService('validation', {
|
|
109
107
|
strapi
|
|
110
108
|
});
|
|
111
109
|
workflowsValidationService.register(reviewWorkflowsOptions);
|
|
110
|
+
entitlements.registerReviewWorkflowsEntitlements(strapi);
|
|
112
111
|
});
|
|
113
112
|
|
|
114
113
|
module.exports = register;
|
|
@@ -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';\nimport { registerReviewWorkflowsEntitlements } from './entitlements';\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 registerReviewWorkflowsEntitlements(strapi);\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","registerReviewWorkflowsEntitlements"],"mappings":";;;;;;;;;;;;;;;AAwBA,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,YAAA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KAAA,CAAA;IACA,MAAMC,0BAAAA,GAA6BC,iBAAW,YAAA,EAAc;AAAEjD,QAAAA;AAAO,KAAA,CAAA;AACrEgD,IAAAA,0BAAAA,CAA2BjB,QAAQ,CAACS,sBAAAA,CAAAA;IAEpCU,gDAAAA,CAAoClD,MAAAA,CAAAA;AACtC,CAAA;;;;"}
|
package/dist/server/register.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultsDeep
|
|
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';
|
|
@@ -8,6 +8,7 @@ import migrateWorkflowsContentTypes from './migrations/multiple-workflows.mjs';
|
|
|
8
8
|
import migrateDeletedCTInWorkflows from './migrations/handle-deleted-ct-in-workflows.mjs';
|
|
9
9
|
import reviewWorkflowsMiddlewares from './middlewares/review-workflows.mjs';
|
|
10
10
|
import { getVisibleContentTypesUID, hasStageAttribute } from './utils/review-workflows.mjs';
|
|
11
|
+
import { registerReviewWorkflowsEntitlements } from './entitlements.mjs';
|
|
11
12
|
import { MAX_STAGES_PER_WORKFLOW, MAX_WORKFLOWS, ENTITY_STAGE_ATTRIBUTE, ENTITY_ASSIGNEE_ATTRIBUTE, STAGE_MODEL_UID } from './constants/workflows.mjs';
|
|
12
13
|
|
|
13
14
|
const setRelation = (attributeName, target, contentType)=>{
|
|
@@ -72,10 +73,7 @@ const setRelation = (attributeName, target, contentType)=>{
|
|
|
72
73
|
]
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
|
-
const enabledRWContentTypes =
|
|
76
|
-
getVisibleContentTypesUID,
|
|
77
|
-
filter((uid)=>hasStageAttribute(contentTypes[uid]))
|
|
78
|
-
])(contentTypes);
|
|
76
|
+
const enabledRWContentTypes = getVisibleContentTypesUID(contentTypes).filter((uid)=>hasStageAttribute(contentTypes[uid]));
|
|
79
77
|
// Remove previously created join tables and persist the new ones
|
|
80
78
|
const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);
|
|
81
79
|
await removePersistedTablesWithSuffix('_strapi_stage_lnk');
|
|
@@ -99,14 +97,15 @@ var register = (async ({ strapi })=>{
|
|
|
99
97
|
strapi
|
|
100
98
|
});
|
|
101
99
|
// License limits
|
|
102
|
-
const reviewWorkflowsOptions = defaultsDeep({
|
|
100
|
+
const reviewWorkflowsOptions = defaultsDeep({}, strapi.ee.features.get('review-workflows'), {
|
|
103
101
|
numberOfWorkflows: MAX_WORKFLOWS,
|
|
104
102
|
stagesPerWorkflow: MAX_STAGES_PER_WORKFLOW
|
|
105
|
-
}
|
|
103
|
+
});
|
|
106
104
|
const workflowsValidationService = getService('validation', {
|
|
107
105
|
strapi
|
|
108
106
|
});
|
|
109
107
|
workflowsValidationService.register(reviewWorkflowsOptions);
|
|
108
|
+
registerReviewWorkflowsEntitlements(strapi);
|
|
110
109
|
});
|
|
111
110
|
|
|
112
111
|
export { register as default };
|
|
@@ -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';\nimport { registerReviewWorkflowsEntitlements } from './entitlements';\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 registerReviewWorkflowsEntitlements(strapi);\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","registerReviewWorkflowsEntitlements"],"mappings":";;;;;;;;;;;;;AAwBA,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,yBAAAA,CAA0BF,MAAAA,CAAOG,YAAY,CAAA;IAEzE,KAAK,MAAMC,kBAAkB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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;IAEpCU,mCAAAA,CAAoClD,MAAAA,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
|
};
|