{"version":3,"sources":["../../src/utils/http.ts","../../src/utils/logger.ts"],"sourcesContent":["import got, { ExtendOptions, Got, HTTPError, Response as GotResponse } from 'got'\n\nconst config = {\n  prefixUrl: process.env.BASE_URL || 'https://api.contentful.com',\n  retry: { limit: 3 },\n}\n\nexport const createHttpClient = (configOverride: ExtendOptions = {}) => {\n  return got.extend({ ...config, ...configOverride })\n}\n\nexport const createValidateStatusCode = (allowedStatusCodes: number[]) => (response: Response) => {\n  if (!allowedStatusCodes.includes(response.statusCode)) {\n    console.log(response.body)\n    throw new HTTPError(response)\n  }\n  return response\n}\n\nexport { HTTPError as HttpError }\n\nexport type HttpClient = Got\nexport type Response = GotResponse\n","import debug from 'debug'\n\nconst APP_NAME = '@contentful/node-apps-toolkit'\n\nconst getNamespaceFromFilename = (filename: string) => {\n  return filename.slice(0, -3)\n}\n\n/**\n * @internal\n */\nexport const createLogger = (opts: { namespace: string } | { filename: string }) => {\n  const ns = 'namespace' in opts ? opts.namespace : getNamespaceFromFilename(opts.filename)\n\n  return debug(APP_NAME).extend(ns)\n}\n\nexport type Logger = debug.Debugger\n"],"mappings":";AAAA,OAAO,OAA2B,iBAA0C;AAE5E,IAAM,SAAS;AAAA,EACb,WAAW,QAAQ,IAAI,YAAY;AAAA,EACnC,OAAO,EAAE,OAAO,EAAE;AACpB;AAEO,IAAM,mBAAmB,CAAC,iBAAgC,CAAC,MAAM;AACtE,SAAO,IAAI,OAAO,EAAE,GAAG,QAAQ,GAAG,eAAe,CAAC;AACpD;AAEO,IAAM,2BAA2B,CAAC,uBAAiC,CAAC,aAAuB;AAChG,MAAI,CAAC,mBAAmB,SAAS,SAAS,UAAU,GAAG;AACrD,YAAQ,IAAI,SAAS,IAAI;AACzB,UAAM,IAAI,UAAU,QAAQ;AAAA,EAC9B;AACA,SAAO;AACT;;;ACjBA,OAAO,WAAW;AAElB,IAAM,WAAW;AAEjB,IAAM,2BAA2B,CAAC,aAAqB;AACrD,SAAO,SAAS,MAAM,GAAG,EAAE;AAC7B;AAKO,IAAM,eAAe,CAAC,SAAuD;AAClF,QAAM,KAAK,eAAe,OAAO,KAAK,YAAY,yBAAyB,KAAK,QAAQ;AAExF,SAAO,MAAM,QAAQ,EAAE,OAAO,EAAE;AAClC;","names":[]}