{"version":3,"file":"config.mjs","sources":["../../src/types/config.ts"],"sourcesContent":["import { AsyncEventEmitter } from './async-event-emitter'\nimport { Logger, consoleLogger, nullLogger } from './logging'\n\n/** The AlgoKit configuration type */\nexport interface Config {\n  /** Logger */\n  logger: Logger\n  /** Whether or not debug mode is enabled */\n  debug: boolean\n  /** The path to the project root directory */\n  projectRoot: string | null\n  /** Indicates whether to trace all operations */\n  traceAll: boolean\n  /** The size of the trace buffer in megabytes */\n  traceBufferSizeMb: number\n  /** The maximum depth to search for a specific file */\n  maxSearchDepth: number\n  /**\n   * Whether to enable populateAppCallResources in sendParams by default.\n   * Default value is false.\n   */\n  populateAppCallResources: boolean\n\n  events: AsyncEventEmitter\n}\n\n/** Updatable AlgoKit config */\nexport class UpdatableConfig implements Readonly<Config> {\n  private config: Config\n\n  get populateAppCallResources() {\n    return this.config.populateAppCallResources\n  }\n\n  get logger() {\n    return this.config.logger\n  }\n\n  get debug() {\n    return this.config.debug\n  }\n\n  get projectRoot() {\n    return this.config.projectRoot\n  }\n\n  get traceAll() {\n    return this.config.traceAll\n  }\n\n  get traceBufferSizeMb() {\n    return this.config.traceBufferSizeMb\n  }\n\n  get maxSearchDepth() {\n    return this.config.maxSearchDepth\n  }\n\n  get events() {\n    return this.config.events\n  }\n\n  /**\n   * Returns the current logger, or the null logger if true is passed in to `returnNullLogger`\n   * @param returnNullLogger Whether or not to return the null logger\n   * @returns The requested logger\n   */\n  getLogger(returnNullLogger?: boolean) {\n    if (returnNullLogger) {\n      return nullLogger\n    }\n\n    return this.logger\n  }\n\n  /**\n   * Temporarily run with debug set to true.\n   * @param lambda A lambda expression with code to run with debug config set to true\n   */\n  withDebug(lambda: () => unknown) {\n    const original = this.config.debug\n    try {\n      this.config.debug = true\n      lambda()\n    } finally {\n      this.config.debug = original\n    }\n  }\n\n  constructor() {\n    this.config = {\n      logger: consoleLogger,\n      debug: false,\n      projectRoot: null,\n      traceAll: false,\n      traceBufferSizeMb: 256,\n      maxSearchDepth: 10,\n      populateAppCallResources: true,\n      events: new AsyncEventEmitter(),\n    }\n  }\n\n  /**\n   * Update the AlgoKit configuration with your own configuration settings\n   * @param newConfig Partial or complete config to replace\n   */\n  configure(newConfig: Partial<Config>) {\n    this.config = { ...this.config, ...newConfig }\n  }\n}\n"],"names":[],"mappings":";;;AA0BA;MACa,eAAe,CAAA;AAG1B,IAAA,IAAI,wBAAwB,GAAA;AAC1B,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,wBAAwB;;AAG7C,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM;;AAG3B,IAAA,IAAI,KAAK,GAAA;AACP,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;;AAG1B,IAAA,IAAI,WAAW,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW;;AAGhC,IAAA,IAAI,QAAQ,GAAA;AACV,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ;;AAG7B,IAAA,IAAI,iBAAiB,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB;;AAGtC,IAAA,IAAI,cAAc,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc;;AAGnC,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM;;AAG3B;;;;AAIG;AACH,IAAA,SAAS,CAAC,gBAA0B,EAAA;QAClC,IAAI,gBAAgB,EAAE;AACpB,YAAA,OAAO,UAAU;;QAGnB,OAAO,IAAI,CAAC,MAAM;;AAGpB;;;AAGG;AACH,IAAA,SAAS,CAAC,MAAqB,EAAA;AAC7B,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK;AAClC,QAAA,IAAI;AACF,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI;AACxB,YAAA,MAAM,EAAE;;gBACA;AACR,YA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