{"version":3,"file":"impl-DubeNRWl.mjs","names":[],"sources":["../src/commands/consent/update-consent-manager/impl.ts"],"sourcesContent":["import { ConsentBundleType } from '@transcend-io/privacy-types';\nimport { mapSeries } from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { validateTranscendAuth } from '../../../lib/api-keys/index.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { updateConsentManagerVersionToLatest } from '../../../lib/consent-manager/index.js';\nimport { logger } from '../../../logger.js';\n\nexport interface UpdateConsentManagerCommandFlags {\n  auth: string;\n  bundleTypes: ConsentBundleType[];\n  deploy: boolean;\n  transcendUrl: string;\n}\n\nexport async function updateConsentManager(\n  this: LocalContext,\n  {\n    auth,\n    bundleTypes = [ConsentBundleType.Production, ConsentBundleType.Test],\n    deploy,\n    transcendUrl,\n  }: UpdateConsentManagerCommandFlags,\n): Promise<void> {\n  doneInputValidation(this.process.exit);\n\n  // Parse authentication as API key or path to list of API keys\n  const apiKeyOrList = await validateTranscendAuth(auth);\n\n  // Handle single update\n  if (typeof apiKeyOrList === 'string') {\n    // Update consent manager\n    await updateConsentManagerVersionToLatest({\n      deploy,\n      transcendUrl,\n      auth: apiKeyOrList,\n      bundleTypes,\n    });\n    logger.info(colors.green('Successfully updated Consent Manager!'));\n  } else {\n    await mapSeries(apiKeyOrList, async (apiKey) => {\n      logger.info(\n        colors.magenta(`Updating Consent Manager for organization \"${apiKey.organizationName}\"...`),\n      );\n\n      await updateConsentManagerVersionToLatest({\n        deploy,\n        transcendUrl,\n        auth: apiKey.apiKey,\n        bundleTypes,\n      });\n\n      logger.info(\n        colors.green(\n          `Successfully updated Consent Manager for organization \"${apiKey.organizationName}\"!`,\n        ),\n      );\n    });\n    logger.info(colors.green('Successfully updated Consent Managers!'));\n  }\n}\n"],"mappings":"oWAiBA,eAAsB,EAEpB,CACE,OACA,cAAc,CAAC,EAAkB,WAAY,EAAkB,KAAK,CACpE,SACA,gBAEa,CACf,EAAoB,KAAK,QAAQ,KAAK,CAGtC,IAAM,EAAe,MAAM,EAAsB,EAAK,CAGlD,OAAO,GAAiB,UAE1B,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EACN,cACD,CAAC,CACF,EAAO,KAAK,EAAO,MAAM,wCAAwC,CAAC,GAElE,MAAM,EAAU,EAAc,KAAO,IAAW,CAC9C,EAAO,KACL,EAAO,QAAQ,8CAA8C,EAAO,iBAAiB,MAAM,CAC5F,CAED,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EAAO,OACb,cACD,CAAC,CAEF,EAAO,KACL,EAAO,MACL,0DAA0D,EAAO,iBAAiB,IACnF,CACF,EACD,CACF,EAAO,KAAK,EAAO,MAAM,yCAAyC,CAAC"}