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B,EAAM,kBAAoB,iBAAiB,kBAC7D,SAAU,EAAM,SAAS,WACzB,SAAU,EAAM,SAChB,WACA,SAAU,EAAM,UAAY,SAAS,OACrC,oBAAqB,EAAM,oBAC3B,yBAA0B,EAAM,2BAGlC,KAAK,WAAa,EAAM,WACxB,KAAK,UAAY,cAAA,MAAM,GAAG,MAAM,UAAU,CACxC,QAAS,MACT,SAAU,mBACV,aAAc,KAAK,YAEvB,E,0GA9GW,QAAA","file":"/npm/@automatedna/cdk-aws-cur@0.0.2/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@automatedna/cdk-aws-cur@0.0.2/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import {\n  aws_cur as cur,\n  IResource,\n  Resource,\n  aws_s3 as s3,\n  Stack,\n  Arn,\n  ArnFormat,\n} from 'aws-cdk-lib';\nimport { Construct } from 'constructs';\n\nexport interface IReportDefinition extends IResource {\n  readonly reportName: string;\n  readonly reportArn: string;\n}\n\nabstract class ReportDefinitionBase extends Resource implements IReportDefinition {\n  public abstract readonly reportName: string;\n  public abstract readonly reportArn: string;\n}\n\nexport enum AdditionalSchemaElements {\n  RESOURCES = 'RESOURCES',\n  SPLIT_COST_ALLOCATION_DATA = 'SPLIT_COST_ALLOCATION_DATA',\n}\n\nexport enum Compression {\n  GZIP = 'GZIP',\n  ZIP = 'ZIP',\n  PARQUET = 'Parquet',\n}\n\nexport enum Format {\n  TEXT_OR_CSV = 'textORcsv',\n  PARQUET = 'Parquet',\n}\n\nexport enum TimeUnit {\n  DAILY = 'DAILY',\n  HOURLY = 'HOURLY',\n  MONTHLY = 'MONTHLY',\n}\n\nexport enum AdditionalArtifacts {\n  REDSHIFT = 'REDSHIFT',\n  QUICKSIGHT = 'QUICKSIGHT',\n  ATHENA = 'ATHENA',\n}\n\nexport enum ReportVersioning {\n  CREATE_NEW_REPORT = 'CREATE_NEW_REPORT',\n  OVERWRITE_REPORT = 'OVERWRITE_REPORT',\n}\n\nexport interface ReportAttributes {\n  /**\n   * The name of the report that you want to create.\n   */\n  readonly reportName?: string;\n  /**\n   * The ARN of the report.\n   */\n  readonly reportArn?: string;\n}\n\nexport interface ReportDefinitionProps {\n  /**\n   * A list that indicates additional content that AWS includes in the report, such as individual resource IDs.\n   *\n   * @default - No additional schema elements\n   */\n  readonly additionalSchemaElements?: AdditionalSchemaElements[];\n  /**\n   * The compression format that Amazon Web Services uses for the report.\n   *\n   * @default - Compression.GZIP\n   */\n  readonly compression?: Compression;\n  /**\n   * The format that Amazon Web Services uses for the report.\n   *\n   * @default - Format.TEXT_OR_CSV\n   */\n  readonly format?: Format;\n  /**\n   * The name of the report that you want to create.\n   */\n  readonly reportName: string;\n  /**\n   * The granularity of the line items in the report.\n   *\n   * @default - TimeUnit.HOURLY\n   */\n  readonly timeUnit?: TimeUnit;\n  /**\n   * A list of manifests that you want AWS to create for this report.\n   *\n   * @default - No additional artifacts\n   */\n  readonly additionalArtifacts?: AdditionalArtifacts[];\n  /**\n   * Whether you want AWS to update your reports after they have been\n   * finalized if AWS detects charges related to previous months. These\n   * charges can include refunds, credits, or support fees.\n   *\n   * @default - true\n   */\n  readonly refreshClosedReports?: boolean;\n  /**\n   * Whether you want AWS to overwrite the previous version of each report\n   * or to deliver the report in addition to the previous versions.\n   *\n   * @default - ReportVersioning.CREATE_NEW_REPORT\n   */\n  readonly reportVersioning?: ReportVersioning;\n  /**\n   * The prefix that Amazon Web Services adds to the report name when Amazon\n   * Web Services delivers the report. Your prefix can't include spaces.\n   */\n  readonly s3Prefix: string;\n  /**\n   * The Amazon S3 bucket where AWS delivers the report.\n   */\n  readonly s3Bucket: s3.IBucket;\n}\n\nexport class ReportDefinition extends ReportDefinitionBase {\n  public static fromReportDefinitionArn(scope: Construct, id: string, reportDefinitionArn: string): IReportDefinition {\n    return ReportDefinition.fromReportDefinitionAttributes(scope, id, { reportArn: reportDefinitionArn });\n  }\n\n  public static fromReportDefinitionName(scope: Construct, id: string, reportName: string): IReportDefinition {\n    return ReportDefinition.fromReportDefinitionAttributes(scope, id, { reportName });\n  }\n\n  public static fromReportDefinitionAttributes(scope: Construct, id: string, attrs: ReportAttributes): IReportDefinition {\n    if (!attrs.reportName && !attrs.reportArn) {\n      throw new Error('Either ReportName or ReportArn is required to import a ReportDefinition');\n    }\n\n    class Import extends ReportDefinitionBase {\n      reportName = attrs.reportName ?? '';\n      reportArn = attrs.reportArn ?? '';\n    }\n\n    const report = new Import(scope, id);\n\n    const stack = Stack.of(scope);\n\n    if (attrs.reportArn && !attrs.reportName) {\n      report.reportName = Arn.split(attrs.reportArn, ArnFormat.SLASH_RESOURCE_NAME).resourceName as string;\n    }\n\n    if (attrs.reportName && !attrs.reportArn) {\n      report.reportArn = stack.formatArn({\n        service: 'cur',\n        resource: 'ReportDefinition',\n        resourceName: report.reportName,\n      });\n    }\n\n    return report;\n  }\n\n  /**\n   * The name of the report.\n   */\n  public readonly reportName: string;\n  /**\n   * The ARN of the report.\n   */\n  public readonly reportArn: string;\n\n  constructor(scope: Construct, id: string, props: ReportDefinitionProps) {\n    super(scope, id, { physicalName: props.reportName });\n\n    if (props.additionalArtifacts?.includes(AdditionalArtifacts.ATHENA)) {\n      if (props.reportVersioning !== ReportVersioning.OVERWRITE_REPORT) {\n        throw new Error('If ATHENA is chosen for additionalArtifacts, reportVersioning must be OVERWRITE_REPORT');\n      }\n    }\n\n    if (props.format === Format.PARQUET || props.compression === Compression.PARQUET) {\n      if (props.format !== Format.PARQUET || props.compression !== Compression.PARQUET) {\n        throw new Error('If format or compression is Parquet, they must both be Parquet');\n      }\n    }\n\n    if (props.s3Prefix && props.s3Prefix.includes(' ')) {\n      throw new Error('s3Prefix must not contain spaces');\n    }\n\n    if (!props.reportName.match(/^[0-9A-Za-z!\\-_.*'()]+$/) || props.reportName.length > 256) {\n      throw new Error('reportName must match the regex ^[0-9A-Za-z!\\-_.*\\'()]+$ and be no longer than 256 characters');\n    }\n\n    if (props.additionalArtifacts != undefined) {\n      if ((props.additionalArtifacts.includes(AdditionalArtifacts.QUICKSIGHT) ||\n        props.additionalArtifacts.includes(AdditionalArtifacts.REDSHIFT)) &&\n        props.compression !== Compression.GZIP) {\n        throw new Error('If QuickSight or Redshift artifacts are selected you must select GZIP compression');\n      }\n\n      if (props.additionalArtifacts.includes(AdditionalArtifacts.ATHENA) &&\n        (props.additionalArtifacts.length > 1)) {\n        throw new Error('If Athena artifact is selected you cant select any other artifact type at the same time');\n      }\n\n      if (props.additionalArtifacts.includes(AdditionalArtifacts.ATHENA) &&\n        props.reportVersioning !== ReportVersioning.OVERWRITE_REPORT) {\n        throw new Error('If Athena artifact is selected report versioning must use OVERWRITE_REPORT');\n      }\n    }\n\n    const s3Region = Stack.of(props.s3Bucket).region;\n\n    new cur.CfnReportDefinition(this, 'ReportDefinition', {\n      compression: props.compression ?? Compression.GZIP,\n      format: props.format ?? Format.TEXT_OR_CSV,\n      refreshClosedReports: props.refreshClosedReports ?? true,\n      reportName: props.reportName,\n      reportVersioning: props.reportVersioning ?? ReportVersioning.CREATE_NEW_REPORT,\n      s3Bucket: props.s3Bucket.bucketName,\n      s3Prefix: props.s3Prefix,\n      s3Region,\n      timeUnit: props.timeUnit ?? TimeUnit.HOURLY,\n      additionalArtifacts: props.additionalArtifacts,\n      additionalSchemaElements: props.additionalSchemaElements,\n    });\n\n    this.reportName = props.reportName;\n    this.reportArn = Stack.of(this).formatArn({\n      service: 'cur',\n      resource: 'ReportDefinition',\n      resourceName: this.reportName,\n    });\n  }\n}\n"]}