{"version":3,"file":"review-workflows.mjs","sources":["../../../server/src/utils/review-workflows.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport { getOr, keys, pickBy, pipe, has, clamp } from 'lodash/fp';\nimport {\n  ENTITY_STAGE_ATTRIBUTE,\n  MAX_WORKFLOWS,\n  MAX_STAGES_PER_WORKFLOW,\n} from '../constants/workflows';\n\nexport const getVisibleContentTypesUID = pipe([\n  // Pick only content-types visible in the content-manager and option is not false\n  pickBy(\n    (value) =>\n      getOr(true, 'pluginOptions.content-manager.visible', value) &&\n      !getOr(false, 'options.noStageAttribute', value)\n  ),\n  // Get UIDs\n  keys,\n]);\n\nexport const hasStageAttribute = has(['attributes', ENTITY_STAGE_ATTRIBUTE]);\n\nexport const getWorkflowContentTypeFilter = (\n  { strapi }: { strapi: Core.Strapi },\n  contentType: any\n) => {\n  if (strapi.db.dialect.supportsOperator('$jsonSupersetOf')) {\n    return { $jsonSupersetOf: JSON.stringify([contentType]) };\n  }\n  return { $contains: `\"${contentType}\"` };\n};\n\nexport const clampMaxWorkflows = clamp(1, MAX_WORKFLOWS);\nexport const clampMaxStagesPerWorkflow = clamp(1, MAX_STAGES_PER_WORKFLOW);\n\nexport default {\n  clampMaxWorkflows,\n  clampMaxStagesPerWorkflow,\n  getVisibleContentTypesUID,\n  hasStageAttribute,\n  getWorkflowContentTypeFilter,\n};\n"],"names":["getVisibleContentTypesUID","pipe","pickBy","value","getOr","keys","hasStageAttribute","has","ENTITY_STAGE_ATTRIBUTE","getWorkflowContentTypeFilter","strapi","contentType","db","dialect","supportsOperator","$jsonSupersetOf","JSON","stringify","$contains","clampMaxWorkflows","clamp","MAX_WORKFLOWS","clampMaxStagesPerWorkflow","MAX_STAGES_PER_WORKFLOW"],"mappings":";;;AAQO,MAAMA,4BAA4BC,IAAAA,CAAK;;IAE5CC,MAAAA,CACE,CAACC,QACCC,KAAAA,CAAM,IAAA,EAAM,yCAAyCD,KAAAA,CAAAA,IACrD,CAACC,KAAAA,CAAM,KAAA,EAAO,0BAAA,EAA4BD,KAAAA,CAAAA,CAAAA;;AAG9CE,IAAAA;CACD;AAEM,MAAMC,oBAAoBC,GAAAA,CAAI;AAAC,IAAA,YAAA;AAAcC,IAAAA;CAAuB;MAE9DC,4BAAAA,GAA+B,CAC1C,EAAEC,MAAM,EAA2B,EACnCC,WAAAA,GAAAA;AAEA,IAAA,IAAID,OAAOE,EAAE,CAACC,OAAO,CAACC,gBAAgB,CAAC,iBAAA,CAAA,EAAoB;QACzD,OAAO;YAAEC,eAAAA,EAAiBC,IAAAA,CAAKC,SAAS,CAAC;AAACN,gBAAAA;AAAY,aAAA;AAAE,SAAA;AAC1D,IAAA;IACA,OAAO;AAAEO,QAAAA,SAAAA,EAAW,CAAC,CAAC,EAAEP,WAAAA,CAAY,CAAC;AAAE,KAAA;AACzC;AAEO,MAAMQ,iBAAAA,GAAoBC,KAAAA,CAAM,CAAA,EAAGC,aAAAA;AACnC,MAAMC,yBAAAA,GAA4BF,KAAAA,CAAM,CAAA,EAAGG,uBAAAA;;;;"}