{"version":3,"file":"impl-xIb20rTt.mjs","names":["consentManagersToBusinessEntitiesHelper"],"sources":["../src/commands/inventory/consent-managers-to-business-entities/impl.ts"],"sourcesContent":["import { existsSync, lstatSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { listFiles } from '../../../lib/api-keys/index.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { consentManagersToBusinessEntities as consentManagersToBusinessEntitiesHelper } from '../../../lib/consent-manager/index.js';\nimport { readTranscendYaml, writeTranscendYaml } from '../../../lib/readTranscendYaml.js';\nimport { logger } from '../../../logger.js';\n\nexport interface ConsentManagersToBusinessEntitiesCommandFlags {\n  consentManagerYmlFolder: string;\n  output: string;\n}\n\nexport function consentManagersToBusinessEntities(\n  this: LocalContext,\n  { consentManagerYmlFolder, output }: ConsentManagersToBusinessEntitiesCommandFlags,\n): void {\n  doneInputValidation(this.process.exit);\n\n  // Ensure folder is passed\n  if (!existsSync(consentManagerYmlFolder) || !lstatSync(consentManagerYmlFolder).isDirectory()) {\n    logger.error(colors.red(`Folder does not exist: \"${consentManagerYmlFolder}\"`));\n    this.process.exit(1);\n  }\n\n  // Read in each consent manager configuration\n  const inputs = listFiles(consentManagerYmlFolder).map((directory) => {\n    const { 'consent-manager': consentManager } = readTranscendYaml(\n      join(consentManagerYmlFolder, directory),\n    );\n    return { name: directory, input: consentManager };\n  });\n\n  // Convert to business entities\n  const businessEntities = consentManagersToBusinessEntitiesHelper(inputs);\n\n  // write to disk\n  writeTranscendYaml(output, {\n    'business-entities': businessEntities,\n  });\n\n  logger.info(\n    colors.green(\n      `Successfully wrote ${businessEntities.length} business entities to file \"${output}\"`,\n    ),\n  );\n}\n"],"mappings":"4XAiBA,SAAgB,EAEd,CAAE,0BAAyB,UACrB,CACN,EAAoB,KAAK,QAAQ,KAAK,EAGlC,CAAC,EAAW,EAAwB,EAAI,CAAC,EAAU,EAAwB,CAAC,aAAa,IAC3F,EAAO,MAAM,EAAO,IAAI,2BAA2B,EAAwB,GAAG,CAAC,CAC/E,KAAK,QAAQ,KAAK,EAAE,EAYtB,IAAM,EAAmBA,EARV,EAAU,EAAwB,CAAC,IAAK,GAAc,CACnE,GAAM,CAAE,kBAAmB,GAAmB,EAC5C,EAAK,EAAyB,EAAU,CACzC,CACD,MAAO,CAAE,KAAM,EAAW,MAAO,EAAgB,EAIoB,CAAC,CAGxE,EAAmB,EAAQ,CACzB,oBAAqB,EACtB,CAAC,CAEF,EAAO,KACL,EAAO,MACL,sBAAsB,EAAiB,OAAO,8BAA8B,EAAO,GACpF,CACF"}