{"version":3,"file":"config.mjs","names":[],"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"],"mappings":";;;;AA2BA,IAAa,kBAAb,MAAyD;CACvD;CAEA,IAAI,2BAA2B;EAC7B,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,SAAS;EACX,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,QAAQ;EACV,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,cAAc;EAChB,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,WAAW;EACb,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,oBAAoB;EACtB,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,iBAAiB;EACnB,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,SAAS;EACX,OAAO,KAAK,OAAO;CACrB;;;;;;CAOA,UAAU,kBAA4B;EACpC,IAAI,kBACF,OAAO;EAGT,OAAO,KAAK;CACd;;;;;CAMA,UAAU,QAAuB;EAC/B,MAAM,WAAW,KAAK,OAAO;EAC7B,IAAI;GACF,KAAK,OAAO,QAAQ;GACpB,OAAO;EACT,UAAU;GACR,KAAK,OAAO,QAAQ;EACtB;CACF;CAEA,cAAc;EACZ,KAAK,SAAS;GACZ,QAAQ;GACR,OAAO;GACP,aAAa;GACb,UAAU;GACV,mBAAmB;GACnB,gBAAgB;GAChB,0BAA0B;GAC1B,QAAQ,IAAI,kBAAkB;EAChC;CACF;;;;;CAMA,UAAU,WAA4B;EACpC,KAAK,SAAS;GAAE,GAAG,KAAK;GAAQ,GAAG;EAAU;CAC/C;AACF"}