{"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,IAAK,CAAA;;IAE5CC,MACE,CAAA,CAACC,QACCC,KAAM,CAAA,IAAA,EAAM,yCAAyCD,KACrD,CAAA,IAAA,CAACC,KAAM,CAAA,KAAA,EAAO,0BAA4BD,EAAAA,KAAAA,CAAAA,CAAAA;;AAG9CE,IAAAA;CACD;AAEM,MAAMC,oBAAoBC,GAAI,CAAA;AAAC,IAAA,YAAA;AAAcC,IAAAA;CAAuB;MAE9DC,4BAA+B,GAAA,CAC1C,EAAEC,MAAM,EAA2B,EACnCC,WAAAA,GAAAA;AAEA,IAAA,IAAID,OAAOE,EAAE,CAACC,OAAO,CAACC,gBAAgB,CAAC,iBAAoB,CAAA,EAAA;QACzD,OAAO;YAAEC,eAAiBC,EAAAA,IAAAA,CAAKC,SAAS,CAAC;AAACN,gBAAAA;AAAY,aAAA;AAAE,SAAA;AAC1D;IACA,OAAO;AAAEO,QAAAA,SAAAA,EAAW,CAAC,CAAC,EAAEP,WAAAA,CAAY,CAAC;AAAE,KAAA;AACzC;AAEaQ,MAAAA,iBAAAA,GAAoBC,KAAM,CAAA,CAAA,EAAGC,aAAe;AAC5CC,MAAAA,yBAAAA,GAA4BF,KAAM,CAAA,CAAA,EAAGG,uBAAyB;;;;"}