{"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,4BAA6B,CAAA,EAAEC,eAAe,EAAEC,YAAY,EAAO,EAAA;;AAEhF,IAAA,MAAMC,kBAAkB,CAAC,CAACF,kBAAkBG,kBAAAA,CAAmB,EAAEC,UAAYH,EAAAA,YAAAA;AAC7E,IAAA,MAAMI,kBAAkB,CAAC,CAACJ,eAAeE,kBAAAA,CAAmB,EAAEC,UAAYH,EAAAA,YAAAA;IAE1E,IAAI,CAACC,mBAAmBG,eAAiB,EAAA;;;AAGvC,QAAA,MAAMC,OAAOC,EAAE,CAACC,KAAK,CAACL,kBAAAA,CAAAA,CAAoBM,UAAU,CAAC;YAAEC,IAAM,EAAA;AAAET,gBAAAA,YAAAA,EAAc;AAAG;AAAE,SAAA,CAAA;;AAGlF,QAAA,MAAMA,eAAeU,IAAK,CAAA;AAACC,YAAAA,MAAAA,CAAOC,GAAI,CAAA,yBAAA,CAAA,CAAA;AAA6BC,YAAAA;SAAK,CAAEd,CAAAA,eAAAA,CAAAA;QAE1E,IAAIC,YAAAA,CAAac,MAAM,EAAE;;;AAGvB,YAAA,MAAMT,OAAOC,EAAE,CACZC,KAAK,CAACL,kBAAAA,CAAAA,CACNa,MAAM,CAAC;gBAAEC,KAAO,EAAA;oBAAEC,EAAI,EAAA;wBAAEC,QAAU,EAAA;AAAK;AAAE,iBAAA;gBAAGT,IAAM,EAAA;AAAET,oBAAAA;AAAa;AAAE,aAAA,CAAA;AACxE;AACF;AACF;;;;"}