{"version":3,"sources":["../../src/ssl/get.ts","../../src/utils/axios/index.ts"],"sourcesContent":["import {\n  IGetFromSwaggerRootHtml,\n  IGetSwaggerDefenitions,\n  ISwaggerRootHtml,\n  Spec,\n} from '../types.ts';\nimport ora from 'ora';\nimport chalk from 'chalk';\nimport Axios from '../utils/axios/index.ts';\n\nexport async function getFromSwaggerRootHtml({\n  baseUrl,\n  sslConfiguredAgent,\n}: IGetFromSwaggerRootHtml): Promise<ISwaggerRootHtml> {\n  const info = ora('get Swagger defination lists').info().start();\n\n  const {data} = await Axios.request<string>({\n    url: baseUrl,\n    method: 'get',\n    headers: {\n      'content-type': 'application/json',\n    },\n    httpsAgent: sslConfiguredAgent,\n  });\n\n  try {\n    const regex = /\"urls\":\\[.*\\]/g;\n    const listRegExpMatchArray = data.match(regex);\n    const result = '{' + listRegExpMatchArray + '}';\n    info.text = '└ get Swagger defination lists';\n    info.succeed();\n    return JSON.parse(result);\n  } catch (error) {\n    info.fail();\n    info.text = '└ get Swagger defination lists';\n    throw new Error('can not done \"get Swagger defination lists\"! ');\n  }\n}\n\nexport async function getSwaggerSchemaJsons({\n  requests,\n  sslConfiguredAgent,\n}: IGetSwaggerDefenitions) {\n  const REQ_Header = {\n    headers: {\n      'content-type': 'application/json',\n    },\n    httpsAgent: sslConfiguredAgent,\n  };\n\n  const spinner = ora('get Swagger definations Schemas').info();\n  spinner.start();\n  try {\n    const responses = await Axios.all<Spec>(\n      requests.map(endpoint =>\n        Axios.get(endpoint, REQ_Header)\n          .then(res => {\n            if (res.data.paths) {\n              return res.data;\n            } else {\n              console.warn(\n                chalk.yellow(\n                  ' └ Warning: checking endpoint:' +\n                    endpoint +\n                    ' !! is it empty?'\n                )\n              );\n              return res.data;\n            }\n          })\n          .catch(() => {\n            throw new Error('error geting json with address:' + endpoint);\n          })\n      )\n    );\n    if (responses) {\n      spinner.text = '└ get Swagger definations Schemas';\n      spinner.succeed();\n      return responses;\n    } else {\n      throw new Error('no responses');\n    }\n  } catch (error) {\n    spinner.text = '└ get Swagger definations Schemas';\n    spinner.fail();\n    throw new Error(\n      chalk.bgRedBright(\n        error ? error : 'can not done \"get Swagger definations Schemas\"! '\n      )\n    );\n  }\n}\n","import axios, {\n  AxiosError,\n  AxiosResponse,\n  InternalAxiosRequestConfig,\n} from 'axios';\nimport ora from 'ora';\nimport chalk from 'chalk';\nimport {Spec, Spins} from '../../types.ts';\n\naxios.defaults.paramsSerializer = {\n  indexes: null,\n};\n\nconst spins: Spins[] = [];\n\n/** configration for api request like header authorization  */\nconst configAxiosRequest = (\n  config: InternalAxiosRequestConfig<unknown>\n): InternalAxiosRequestConfig<unknown> => {\n  const spinner = ora('axios get');\n  spinner.text = '├ axios get :' + config.url;\n  spinner.start();\n  spins.push({id: config.url, spinner: spinner});\n  return config;\n};\n\n/** this situation happen when request does not even send to network or internet */\nconst onAxiosRequestError = (error: AxiosError): Promise<AxiosError> => {\n  const spinner = spins.find(\n    spinObj => spinObj.id === error?.config?.url\n  )?.spinner;\n  spinner?.fail();\n  return Promise.reject(error);\n};\n\n/** handle Response of api response  */\nconst onAxiosResponse = (response: AxiosResponse<Spec>): AxiosResponse => {\n  const spinner = spins.find(\n    spinObj => spinObj.id === response.config.url\n  )?.spinner;\n  spinner?.succeed();\n  return response;\n};\n\n/** handle api response errors */\nconst onAxiosResponseError = (error: AxiosError): Promise<AxiosError> => {\n  try {\n    const spinner = spins.find(\n      spinObj => spinObj.id === error?.config?.url\n    )?.spinner;\n    spinner?.fail();\n    if (error.response) {\n      console.warn(\n        chalk.redBright(\n          ' └ Error axios get with code :' + error.response.status\n        )\n      );\n      /** this situation happen when request return a response with error object that contain a status code */\n      // responseHandler(error.response.status)(error);\n    } else if (error.request) {\n      /** this situation happen when request does not return means that request fail duo to network error or sth like that */\n      console.warn(chalk.redBright(' └ check your network Connection'));\n    } else {\n      console.error(chalk.redBright(' └ Error axios get ', error.message));\n    }\n    throw new Error(error.message);\n  } catch (error) {\n    console.error(chalk.redBright(' └ Error axios get:', error));\n    return Promise.reject(error);\n  }\n};\n\n/** handle axios response for errors and etc.. */\naxios.interceptors.response.use(onAxiosResponse, onAxiosResponseError);\n/** set axios request's header configration like autorization */\naxios.interceptors.request.use(configAxiosRequest, onAxiosRequestError);\n\nexport default axios;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,IAAAA,cAAgB;AAChB,IAAAC,gBAAkB;;;ACPlB,mBAIO;AACP,iBAAgB;AAChB,mBAAkB;AAGlB,aAAAC,QAAM,SAAS,mBAAmB;AAAA,EAChC,SAAS;AACX;AAEA,IAAM,QAAiB,CAAC;AAGxB,IAAM,qBAAqB,CACzB,WACwC;AACxC,QAAM,cAAU,WAAAC,SAAI,WAAW;AAC/B,UAAQ,OAAO,uBAAkB,OAAO;AACxC,UAAQ,MAAM;AACd,QAAM,KAAK,EAAC,IAAI,OAAO,KAAK,QAAgB,CAAC;AAC7C,SAAO;AACT;AAGA,IAAM,sBAAsB,CAAC,UAA2C;AA3BxE;AA4BE,QAAM,WAAU,WAAM;AAAA,IACpB,aAAQ;AA7BZ,UAAAC;AA6Be,qBAAQ,SAAOA,MAAA,+BAAO,WAAP,gBAAAA,IAAe;AAAA;AAAA,EAC3C,MAFgB,mBAEb;AACH,qCAAS;AACT,SAAO,QAAQ,OAAO,KAAK;AAC7B;AAGA,IAAM,kBAAkB,CAAC,aAAiD;AApC1E;AAqCE,QAAM,WAAU,WAAM;AAAA,IACpB,aAAW,QAAQ,OAAO,SAAS,OAAO;AAAA,EAC5C,MAFgB,mBAEb;AACH,qCAAS;AACT,SAAO;AACT;AAGA,IAAM,uBAAuB,CAAC,UAA2C;AA7CzE;AA8CE,MAAI;AACF,UAAM,WAAU,WAAM;AAAA,MACpB,aAAQ;AAhDd,YAAAA;AAgDiB,uBAAQ,SAAOA,MAAA,+BAAO,WAAP,gBAAAA,IAAe;AAAA;AAAA,IAC3C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