{"version":3,"sources":["jsdelivr-header.js","/npm/@churchill/http@1.0.0/http.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,QAAU,QAAQ,0BAClB,UAAY,QAAQ,wBAM1B,MAAM,aAAa,UAYjB,WAAA,CAAY,GACV,MAAM,OAAE,EAAM,SAAE,EAAQ,QAAE,EAAU,UAAW,GAAS,EACxD,MAAM,CAAE,SAAQ,aAChB,KAAK,QAAU,EACf,KAAK,eAAiB,CACxB,CAQA,SAAM,CAAI,EAAM,EAAQ,GACtB,MAAM,EAAM,KAAK,OAAO,EAAM,EAAQ,IAChC,QAAE,EAAO,eAAE,GAAmB,KACpC,IAAI,EACJ,IACE,QAAY,QAAQ,CAClB,CAAC,GAAU,KACR,GAEP,CAAE,MAAO,GAEP,OADA,KAAK,KAAK,QAAS,GACZ,IACT,CACA,OAAO,CACT,EAcF,KAAK,OAAS,GACL,IAAI,KAAK,GAGlB,OAAO,QAAU","file":"/npm/@churchill/http@1.0.0/http.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@churchill/http@1.0.0/http.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const request = require(\"request-promise-native\");\nconst Transport = require(\"@churchill/transport\");\n\n/**\n * @typedef {import(\"@churchill/core\")} Logger\n */\n\nclass HTTP extends Transport {\n  /**\n   * HTTP Transport\n   * @param {Object} opts Options\n   * @param {Function} [opts.format] Formatting function\n   * @param {String} [opts.maxLevel] Max logging level\n   * @param {String} opts.method Method\n   * @param {String} opts.url URL\n   * @param {Object} [opts.auth] Auth\n   * @param {Object} [opts.headers] Headers\n   * @param {String} [opts.dataKey=\"json\"] Data key (e.g. body, qs, json, form, formData)\n   */\n  constructor(opts) {\n    const { format, maxLevel, dataKey = \"json\", ...rest } = opts;\n    super({ format, maxLevel });\n    this.dataKey = dataKey;\n    this.requestOptions = rest;\n  }\n\n  /**\n   * Log a Message\n   * @param {Object} info Message\n   * @param {*} [output] Output of the global formatting function\n   * @param {Logger} logger Logger\n   */\n  async log(info, output, logger) {\n    const out = this.format(info, output, logger);\n    const { dataKey, requestOptions } = this;\n    let res;\n    try {\n      res = await request({\n        [dataKey]: out,\n        ...requestOptions\n      });\n    } catch (err) {\n      this.emit(\"error\", err);\n      return null;\n    }\n    return res;\n  }\n}\n\n/**\n * HTTP Transport\n * @param {Object} opts Options\n * @param {Function} [opts.format] Formatting function\n * @param {String} [opts.maxLevel] Max logging level\n * @param {String} opts.method Method\n * @param {String} opts.url URL\n * @param {Object} [opts.auth] Auth\n * @param {Object} [opts.headers] Headers\n * @param {String} [opts.dataKey] Data key (e.g. body, qs, json, form, formData)\n */\nHTTP.create = opts => {\n  return new HTTP(opts);\n};\n\nmodule.exports = HTTP;\n"]}