@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.
Files changed (88) hide show
  1. package/dist/server/audit-logs.js +123 -0
  2. package/dist/server/audit-logs.js.map +1 -0
  3. package/dist/server/audit-logs.mjs +116 -0
  4. package/dist/server/audit-logs.mjs.map +1 -0
  5. package/dist/server/bootstrap.js +7 -0
  6. package/dist/server/bootstrap.js.map +1 -1
  7. package/dist/server/bootstrap.mjs +7 -0
  8. package/dist/server/bootstrap.mjs.map +1 -1
  9. package/dist/server/controllers/workflows.js +8 -6
  10. package/dist/server/controllers/workflows.js.map +1 -1
  11. package/dist/server/controllers/workflows.mjs +8 -6
  12. package/dist/server/controllers/workflows.mjs.map +1 -1
  13. package/dist/server/middlewares/review-workflows.js +7 -3
  14. package/dist/server/middlewares/review-workflows.js.map +1 -1
  15. package/dist/server/middlewares/review-workflows.mjs +7 -3
  16. package/dist/server/middlewares/review-workflows.mjs.map +1 -1
  17. package/dist/server/migrations/handle-deleted-ct-in-workflows.js +2 -2
  18. package/dist/server/migrations/handle-deleted-ct-in-workflows.js.map +1 -1
  19. package/dist/server/migrations/handle-deleted-ct-in-workflows.mjs +2 -2
  20. package/dist/server/migrations/handle-deleted-ct-in-workflows.mjs.map +1 -1
  21. package/dist/server/migrations/multiple-workflows.js +2 -5
  22. package/dist/server/migrations/multiple-workflows.js.map +1 -1
  23. package/dist/server/migrations/multiple-workflows.mjs +2 -5
  24. package/dist/server/migrations/multiple-workflows.mjs.map +1 -1
  25. package/dist/server/register.js +4 -7
  26. package/dist/server/register.js.map +1 -1
  27. package/dist/server/register.mjs +4 -7
  28. package/dist/server/register.mjs.map +1 -1
  29. package/dist/server/services/assignees.js +18 -2
  30. package/dist/server/services/assignees.js.map +1 -1
  31. package/dist/server/services/assignees.mjs +19 -3
  32. package/dist/server/services/assignees.mjs.map +1 -1
  33. package/dist/server/services/document-service-middleware.js +2 -3
  34. package/dist/server/services/document-service-middleware.js.map +1 -1
  35. package/dist/server/services/document-service-middleware.mjs +2 -3
  36. package/dist/server/services/document-service-middleware.mjs.map +1 -1
  37. package/dist/server/services/metrics/weekly-metrics.js +8 -8
  38. package/dist/server/services/metrics/weekly-metrics.js.map +1 -1
  39. package/dist/server/services/metrics/weekly-metrics.mjs +4 -4
  40. package/dist/server/services/metrics/weekly-metrics.mjs.map +1 -1
  41. package/dist/server/services/stage-permissions.js +1 -2
  42. package/dist/server/services/stage-permissions.js.map +1 -1
  43. package/dist/server/services/stage-permissions.mjs +1 -2
  44. package/dist/server/services/stage-permissions.mjs.map +1 -1
  45. package/dist/server/services/stages.js +8 -8
  46. package/dist/server/services/stages.js.map +1 -1
  47. package/dist/server/services/stages.mjs +7 -7
  48. package/dist/server/services/stages.mjs.map +1 -1
  49. package/dist/server/services/validation.js +1 -2
  50. package/dist/server/services/validation.js.map +1 -1
  51. package/dist/server/services/validation.mjs +1 -2
  52. package/dist/server/services/validation.mjs.map +1 -1
  53. package/dist/server/services/workflow-content-types.js +23 -6
  54. package/dist/server/services/workflow-content-types.js.map +1 -1
  55. package/dist/server/services/workflow-content-types.mjs +21 -4
  56. package/dist/server/services/workflow-content-types.mjs.map +1 -1
  57. package/dist/server/services/workflows.js +91 -13
  58. package/dist/server/services/workflows.js.map +1 -1
  59. package/dist/server/services/workflows.mjs +91 -13
  60. package/dist/server/services/workflows.mjs.map +1 -1
  61. package/dist/server/src/audit-logs.d.ts +112 -0
  62. package/dist/server/src/audit-logs.d.ts.map +1 -0
  63. package/dist/server/src/bootstrap.d.ts.map +1 -1
  64. package/dist/server/src/controllers/workflows.d.ts.map +1 -1
  65. package/dist/server/src/index.d.ts +1 -1
  66. package/dist/server/src/index.d.ts.map +1 -1
  67. package/dist/server/src/middlewares/review-workflows.d.ts.map +1 -1
  68. package/dist/server/src/migrations/handle-deleted-ct-in-workflows.d.ts.map +1 -1
  69. package/dist/server/src/migrations/multiple-workflows.d.ts.map +1 -1
  70. package/dist/server/src/register.d.ts.map +1 -1
  71. package/dist/server/src/services/assignees.d.ts.map +1 -1
  72. package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
  73. package/dist/server/src/services/index.d.ts +1 -1
  74. package/dist/server/src/services/index.d.ts.map +1 -1
  75. package/dist/server/src/services/metrics/weekly-metrics.d.ts +1 -1
  76. package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
  77. package/dist/server/src/services/stage-permissions.d.ts.map +1 -1
  78. package/dist/server/src/services/validation.d.ts.map +1 -1
  79. package/dist/server/src/services/workflow-content-types.d.ts +10 -3
  80. package/dist/server/src/services/workflow-content-types.d.ts.map +1 -1
  81. package/dist/server/src/services/workflows.d.ts.map +1 -1
  82. package/dist/server/src/utils/review-workflows.d.ts +12 -8
  83. package/dist/server/src/utils/review-workflows.d.ts.map +1 -1
  84. package/dist/server/utils/review-workflows.js +8 -13
  85. package/dist/server/utils/review-workflows.js.map +1 -1
  86. package/dist/server/utils/review-workflows.mjs +8 -13
  87. package/dist/server/utils/review-workflows.mjs.map +1 -1
  88. 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\nimport { set } from 'lodash/fp';\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 = set('options.reviewWorkflows', reviewWorkflows, contentType);\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","set","server","router","use","next","method"],"mappings":";;;;;;AAKA;;;;;;;;;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;YACxCD,GAAAA,CAAIG,OAAO,CAACC,IAAI,CAACF,WAAW,GAAGG,MAAAA,CAAI,2BAA2BJ,eAAAA,EAAiBC,WAAAA,CAAAA;AACjF,QAAA;AACF,IAAA,CAAA;IACAJ,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
+ {"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 = set('options.reviewWorkflows', reviewWorkflows, 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\nimport { set } from 'lodash/fp';\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 = set('options.reviewWorkflows', reviewWorkflows, contentType);\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","set","server","router","use","next","method"],"mappings":";;AAKA;;;;;;;;;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;YACxCD,GAAAA,CAAIG,OAAO,CAACC,IAAI,CAACF,WAAW,GAAGG,GAAAA,CAAI,2BAA2BJ,eAAAA,EAAiBC,WAAAA,CAAAA;AACjF,QAAA;AACF,IAAA,CAAA;IACAJ,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
+ {"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 fp = require('lodash/fp');
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 = fp.difference(fp.keys(oldContentTypes), fp.keys(contentTypes)) ?? [];
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, keys } from 'lodash/fp';\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 = difference(keys(oldContentTypes), 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","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,sBAAsBC,aAAAA,CAAWC,OAAAA,CAAKJ,eAAAA,CAAAA,EAAkBI,OAAAA,CAAKH,kBAAkB,EAAE;IAEvF,IAAIC,mBAAAA,CAAoBG,MAAM,EAAE;AAC9B,QAAA,MAAMC,WAAAA,CAAMC,GAAG,CAACL,mBAAAA,EAAqB,OAAOM,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;AACLf,oBAAAA,YAAAA,EAAcgB,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;AACJnB,wBAAAA,YAAAA,EAAcQ,SAASR,YAAY,CAACoB,MAAM,CACxC,CAACC,iBAA4BA,cAAAA,KAAmBd,qBAAAA;AAEpD;AACF,iBAAA,CAAA;AACF,YAAA;AACF,QAAA,CAAA,CAAA;AACF,IAAA;AACF;;;;"}
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, keys } from 'lodash/fp';
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, keys } from 'lodash/fp';\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 = difference(keys(oldContentTypes), 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","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,sBAAsBC,UAAAA,CAAWC,IAAAA,CAAKJ,eAAAA,CAAAA,EAAkBI,IAAAA,CAAKH,kBAAkB,EAAE;IAEvF,IAAIC,mBAAAA,CAAoBG,MAAM,EAAE;AAC9B,QAAA,MAAMC,KAAAA,CAAMC,GAAG,CAACL,mBAAAA,EAAqB,OAAOM,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;AACLf,oBAAAA,YAAAA,EAAcgB,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;AACJnB,wBAAAA,YAAAA,EAAcQ,SAASR,YAAY,CAACoB,MAAM,CACxC,CAACC,iBAA4BA,cAAAA,KAAmBd,qBAAAA;AAEpD;AACF,iBAAA,CAAA;AACF,YAAA;AACF,QAAA,CAAA,CAAA;AACF,IAAA;AACF;;;;"}
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 fp = require('lodash/fp');
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 = fp.pipe([
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, keys, pickBy, pipe } from 'lodash/fp';\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 = pipe([pickBy(get('options.reviewWorkflows')), keys])(oldContentTypes);\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","pipe","pickBy","get","keys","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;;AAGlF,QAAA,MAAMA,eAAeU,OAAAA,CAAK;AAACC,YAAAA,SAAAA,CAAOC,MAAAA,CAAI,yBAAA,CAAA,CAAA;AAA6BC,YAAAA;SAAK,CAAA,CAAEd,eAAAA,CAAAA;QAE1E,IAAIC,YAAAA,CAAac,MAAM,EAAE;;;AAGvB,YAAA,MAAMT,OAAOC,EAAE,CACZC,KAAK,CAACL,4BAAAA,CAAAA,CACNa,MAAM,CAAC;gBAAEC,KAAAA,EAAO;oBAAEC,EAAAA,EAAI;wBAAEC,QAAAA,EAAU;AAAK;AAAE,iBAAA;gBAAGT,IAAAA,EAAM;AAAET,oBAAAA;AAAa;AAAE,aAAA,CAAA;AACxE,QAAA;AACF,IAAA;AACF;;;;"}
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 { pipe, keys, pickBy, get } from 'lodash/fp';
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 = pipe([
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, keys, pickBy, pipe } from 'lodash/fp';\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 = pipe([pickBy(get('options.reviewWorkflows')), keys])(oldContentTypes);\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","pipe","pickBy","get","keys","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;;AAGlF,QAAA,MAAMA,eAAeU,IAAAA,CAAK;AAACC,YAAAA,MAAAA,CAAOC,GAAAA,CAAI,yBAAA,CAAA,CAAA;AAA6BC,YAAAA;SAAK,CAAA,CAAEd,eAAAA,CAAAA;QAE1E,IAAIC,YAAAA,CAAac,MAAM,EAAE;;;AAGvB,YAAA,MAAMT,OAAOC,EAAE,CACZC,KAAK,CAACL,kBAAAA,CAAAA,CACNa,MAAM,CAAC;gBAAEC,KAAAA,EAAO;oBAAEC,EAAAA,EAAI;wBAAEC,QAAAA,EAAU;AAAK;AAAE,iBAAA;gBAAGT,IAAAA,EAAM;AAAET,oBAAAA;AAAa;AAAE,aAAA,CAAA;AACxE,QAAA;AACF,IAAA;AACF;;;;"}
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;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
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 = fp.pipe([
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 = fp.defaultsDeep({
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
- }, strapi.ee.features.get('review-workflows'));
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, filter, pipe } from 'lodash/fp';\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 = pipe([\n getVisibleContentTypesUID,\n filter((uid: UID.ContentType) => hasStageAttribute(contentTypes[uid])),\n ])(contentTypes);\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(\n {\n numberOfWorkflows: MAX_WORKFLOWS,\n stagesPerWorkflow: MAX_STAGES_PER_WORKFLOW,\n },\n strapi.ee.features.get('review-workflows')\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","pipe","filter","uid","hasStageAttribute","stageJoinTablesToPersist","map","assigneeJoinTablesToPersist","hook","register","migrateReviewWorkflowStagesColor","migrateReviewWorkflowStagesRoles","migrateReviewWorkflowStagesTransferToRoles","migrateReviewWorkflowName","migrateWorkflowsContentTypes","migrateDeletedCTInWorkflows","reviewWorkflowsMiddlewares","contentTypeMiddleware","reviewWorkflowsOptions","defaultsDeep","numberOfWorkflows","MAX_WORKFLOWS","stagesPerWorkflow","MAX_STAGES_PER_WORKFLOW","ee","features","workflowsValidationService","getService"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAMA,WAAAA,GAAc,CAACC,aAAA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;;AAEvDA,IAAAA,MAAAA,CAAO+B,IAAI,CAAC,iCAAA,CAAA,CAAmCC,QAAQ,CAACtB,oBAAAA,CAAqB;AAAEV,QAAAA;AAAO,KAAA,CAAA,CAAA;AACtFA,IAAAA,MAAAA,CACG+B,IAAI,CAAC,iCAAA,CAAA,CACLC,QAAQ,CAACC,qBAAAA,CAAAA,CACTD,QAAQ,CAACE,cAAAA,CAAAA,CACTF,QAAQ,CAACG,yBAAAA,CAAAA,CACTH,QAAQ,CAACI,sBAAAA,CAAAA,CACTJ,QAAQ,CAACK,iBAAAA,CAAAA,CACTL,QAAQ,CAACM,0BAAAA,CAAAA;;AAGZC,IAAAA,uBAAAA,CAA2BC,qBAAqB,CAACxC,MAAAA,CAAAA;;IAGjDD,gCAAAA,CAAiC;AAAEC,QAAAA;AAAO,KAAA,CAAA;;AAG1C,IAAA,MAAMyC,yBAAyBC,eAAAA,CAC7B;QACEC,iBAAAA,EAAmBC,uBAAAA;QACnBC,iBAAAA,EAAmBC;AACrB,KAAA,EACA9C,OAAO+C,EAAE,CAACC,QAAQ,CAAC3C,GAAG,CAAC,kBAAA,CAAA,CAAA;IAEzB,MAAM4C,0BAAAA,GAA6BC,iBAAW,YAAA,EAAc;AAAElD,QAAAA;AAAO,KAAA,CAAA;AACrEiD,IAAAA,0BAAAA,CAA2BjB,QAAQ,CAACS,sBAAAA,CAAAA;AACtC,CAAA;;;;"}
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,kBAA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AAA,CAAO0C,EAAE,CAACC,QAAQ,CAACtC,GAAG,CAAC,kBAAA,CAAA,EAAqB;QAC1FuC,iBAAAA,EAAmBC,uBAAAA;QACnBC,iBAAAA,EAAmBC;AACrB,KAAA,CAAA;IACA,MAAMC,0BAAAA,GAA6BC,iBAAW,YAAA,EAAc;AAAEjD,QAAAA;AAAO,KAAA,CAAA;AACrEgD,IAAAA,0BAAAA,CAA2BjB,QAAQ,CAACS,sBAAAA,CAAAA;AACtC,CAAA;;;;"}
@@ -1,4 +1,4 @@
1
- import { defaultsDeep, pipe, filter } from 'lodash/fp';
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 = pipe([
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
- }, strapi.ee.features.get('review-workflows'));
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, filter, pipe } from 'lodash/fp';\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 = pipe([\n getVisibleContentTypesUID,\n filter((uid: UID.ContentType) => hasStageAttribute(contentTypes[uid])),\n ])(contentTypes);\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(\n {\n numberOfWorkflows: MAX_WORKFLOWS,\n stagesPerWorkflow: MAX_STAGES_PER_WORKFLOW,\n },\n strapi.ee.features.get('review-workflows')\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","pipe","filter","uid","hasStageAttribute","stageJoinTablesToPersist","map","assigneeJoinTablesToPersist","hook","register","migrateReviewWorkflowStagesColor","migrateReviewWorkflowStagesRoles","migrateReviewWorkflowStagesTransferToRoles","migrateReviewWorkflowName","migrateWorkflowsContentTypes","migrateDeletedCTInWorkflows","reviewWorkflowsMiddlewares","contentTypeMiddleware","reviewWorkflowsOptions","defaultsDeep","numberOfWorkflows","MAX_WORKFLOWS","stagesPerWorkflow","MAX_STAGES_PER_WORKFLOW","ee","features","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,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,MAAAA,CACG+B,IAAI,CAAC,iCAAA,CAAA,CACLC,QAAQ,CAACC,gCAAAA,CAAAA,CACTD,QAAQ,CAACE,gCAAAA,CAAAA,CACTF,QAAQ,CAACG,0CAAAA,CAAAA,CACTH,QAAQ,CAACI,yBAAAA,CAAAA,CACTJ,QAAQ,CAACK,4BAAAA,CAAAA,CACTL,QAAQ,CAACM,2BAAAA,CAAAA;;AAGZC,IAAAA,0BAAAA,CAA2BC,qBAAqB,CAACxC,MAAAA,CAAAA;;IAGjDD,gCAAAA,CAAiC;AAAEC,QAAAA;AAAO,KAAA,CAAA;;AAG1C,IAAA,MAAMyC,yBAAyBC,YAAAA,CAC7B;QACEC,iBAAAA,EAAmBC,aAAAA;QACnBC,iBAAAA,EAAmBC;AACrB,KAAA,EACA9C,OAAO+C,EAAE,CAACC,QAAQ,CAAC3C,GAAG,CAAC,kBAAA,CAAA,CAAA;IAEzB,MAAM4C,0BAAAA,GAA6BC,WAAW,YAAA,EAAc;AAAElD,QAAAA;AAAO,KAAA,CAAA;AACrEiD,IAAAA,0BAAAA,CAA2BjB,QAAQ,CAACS,sBAAAA,CAAAA;AACtC,CAAA;;;;"}
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,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,kBAAkBH,mBAAAA,CAAqB;AAChDD,QAAAA,MAAAA,CAAOK,GAAG,CAAC,eAAA,CAAA,CAAiBC,MAAM,CAACF,gBAAgB,CAAChB,WAAAA,GAAAA;;AAElDH,YAAAA,WAAAA,CAA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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 (!fp.isNil(assigneeId)) {
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 { isNil } from 'lodash/fp';\nimport { ENTITY_ASSIGNEE_ATTRIBUTE } from '../constants/workflows';\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 (!isNil(assigneeId)) {\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 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","isNil","userExists","getAdminService","exists","oldAssigneeId","sendDidEditAssignee","documents","update","data","fields","tableName","metadata","get","connection","updated_at","Date","updatedAt"],"mappings":";;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AAmB,CAACD,aAAAA,EAAeP,UAAAA,IAAc,IAAA,CAAA;AAEzD,YAAA,MAAMV,SAAS,MAAMN,MAAAA,CAAOyB,SAAS,CAACpB,KAAAA,CAAAA,CAAOqB,MAAM,CAAC;AAClDT,gBAAAA,UAAAA;AACAC,gBAAAA,MAAAA;gBACAS,IAAAA,EAAM;oBAAE,CAACf,mCAAAA,GAA4BI,UAAAA,IAAc;AAAK,iBAAA;gBACxDL,QAAAA,EAAU;AAACC,oBAAAA;AAA0B,iBAAA;AACrCgB,gBAAAA,MAAAA,EAAQ;AACV,aAAA,CAAA;;;;YAKA,MAAM,EAAEC,SAAS,EAAE,GAAG7B,MAAAA,CAAOO,EAAE,CAACuB,QAAQ,CAACC,GAAG,CAAC1B,KAAAA,CAAAA;AAC7C,YAAA,MAAML,OAAOO,EAAE,CACZyB,UAAU,CAACH,SAAAA,CAAAA,CACXnB,KAAK,CAAC;AAAEN,gBAAAA,EAAAA,EAAIW,eAAeX;AAAG,aAAA,CAAA,CAC9BsB,MAAM,CAAC;gBACNO,UAAAA,EAAY,IAAIC,IAAAA,CAAKnB,cAAAA,CAAeoB,SAAS;AAC/C,aAAA,CAAA;YAEF,OAAO7B,MAAAA;AACT,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
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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;AACvE,iBAAA,CAAA;AACF,YAAA;YAEA,OAAO7B,MAAAA;AACT,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
@@ -1,6 +1,6 @@
1
- import { errors } from '@strapi/utils';
2
- import { isNil } from 'lodash/fp';
1
+ import { errors, emitAudit } 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 (!isNil(assigneeId)) {
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 { isNil } from 'lodash/fp';\nimport { ENTITY_ASSIGNEE_ATTRIBUTE } from '../constants/workflows';\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 (!isNil(assigneeId)) {\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 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","isNil","userExists","getAdminService","exists","oldAssigneeId","sendDidEditAssignee","documents","update","data","fields","tableName","metadata","get","connection","updated_at","Date","updatedAt"],"mappings":";;;;;AAMA,MAAM,EAAEA,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AAAA,IAAc,IAAA,CAAA;AAEzD,YAAA,MAAMV,SAAS,MAAMN,MAAAA,CAAOyB,SAAS,CAACpB,KAAAA,CAAAA,CAAOqB,MAAM,CAAC;AAClDT,gBAAAA,UAAAA;AACAC,gBAAAA,MAAAA;gBACAS,IAAAA,EAAM;oBAAE,CAACf,yBAAAA,GAA4BI,UAAAA,IAAc;AAAK,iBAAA;gBACxDL,QAAAA,EAAU;AAACC,oBAAAA;AAA0B,iBAAA;AACrCgB,gBAAAA,MAAAA,EAAQ;AACV,aAAA,CAAA;;;;YAKA,MAAM,EAAEC,SAAS,EAAE,GAAG7B,MAAAA,CAAOO,EAAE,CAACuB,QAAQ,CAACC,GAAG,CAAC1B,KAAAA,CAAAA;AAC7C,YAAA,MAAML,OAAOO,EAAE,CACZyB,UAAU,CAACH,SAAAA,CAAAA,CACXnB,KAAK,CAAC;AAAEN,gBAAAA,EAAAA,EAAIW,eAAeX;AAAG,aAAA,CAAA,CAC9BsB,MAAM,CAAC;gBACNO,UAAAA,EAAY,IAAIC,IAAAA,CAAKnB,cAAAA,CAAeoB,SAAS;AAC/C,aAAA,CAAA;YAEF,OAAO7B,MAAAA;AACT,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
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_AS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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 && fp.isNil(data[workflows.ENTITY_STAGE_ATTRIBUTE])) {
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 (fp.isNil(data?.[workflows.ENTITY_STAGE_ATTRIBUTE])) {
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 { isNil } from 'lodash/fp';\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 && isNil(data[ENTITY_STAGE_ATTRIBUTE])) {\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 (isNil(data?.[ENTITY_STAGE_ATTRIBUTE])) {\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","isNil","stages","handleStageOnUpdate","previousStage","result","updatedStage","model","getModel","eventHub","emit","WORKFLOW_UPDATE_STAGE","modelName","locale","from","name","to","checkStageBeforePublish","stageRequiredToPublish","entryStage","errors","ValidationError"],"mappings":";;;;;;;;AAUA;;;;;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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AAA,EAAMT,aAAaS;AACrB;AACF;AACF;AACF,SAAA,CAAA;AACF,IAAA;IAEA,OAAOpB,IAAAA,EAAAA;AACT,CAAA;AAEA;;IAGA,MAAMsB,uBAAAA,GAAsC,OAAOvB,GAAAA,EAAKC,IAAAA,GAAAA;IACtD,IAAID,GAAAA,CAAIE,MAAM,KAAK,SAAA,EAAW;QAC5B,OAAOD,IAAAA,EAAAA;AACT,IAAA;IAEA,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,IAAY,CAACA,QAAAA,CAAS0B,sBAAsB,EAAE;QACjD,OAAOvB,IAAAA,EAAAA;AACT,IAAA;AAEA,IAAA,MAAM,EAAEP,UAAU,EAAE,GAAGM,IAAIX,MAAM;IACjC,MAAMoC,UAAAA,GAAa,MAAMvC,cAAAA,CAAec,GAAAA,CAAIK,WAAW,CAAClB,GAAG,EAAEO,UAAAA,EAAYM,GAAAA,CAAIX,MAAM,CAAA;AAEnF,IAAA,IAAIoC,WAAWrC,EAAE,KAAKU,SAAS0B,sBAAsB,CAACpC,EAAE,EAAE;QACxD,MAAM,IAAIsC,YAAAA,CAAOC,eAAe,CAAC,+CAAA,CAAA;AACnC,IAAA;IAEA,OAAO1B,IAAAA,EAAAA;AACT,CAAA;AAEA,gCAAe,CAAA,KAAO;AACpBF,QAAAA,mBAAAA;AACAU,QAAAA,mBAAAA;AACAc,QAAAA;AACF,KAAA,CAAC;;;;"}
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,CA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