mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-08 13:00:05 +00:00
chore: temp fix for InternalAxiosRequestConfig
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
AxiosError,
|
||||
AxiosHeaders,
|
||||
AxiosInstance,
|
||||
AxiosRequestConfig,
|
||||
AxiosRequestHeaders,
|
||||
AxiosResponse
|
||||
} from 'axios'
|
||||
import axios from 'axios'
|
||||
@@ -424,13 +424,13 @@ export class RequestClient implements HttpClient {
|
||||
const parsedResBody = this.parseInterceptedBody(data)
|
||||
|
||||
process.logger?.info(`HTTP Request (first 50 lines):
|
||||
${reqHeaders}${this.parseInterceptedBody(config.data)}
|
||||
|
||||
HTTP Response Code: ${this.prettifyString(status)}
|
||||
|
||||
HTTP Response (first 50 lines):
|
||||
${resHeaders}${parsedResBody ? `\n\n${parsedResBody}` : ''}
|
||||
`)
|
||||
${reqHeaders}${this.parseInterceptedBody(config.data)}
|
||||
|
||||
HTTP Response Code: ${this.prettifyString(status)}
|
||||
|
||||
HTTP Response (first 50 lines):
|
||||
${resHeaders}${parsedResBody ? `\n\n${parsedResBody}` : ''}
|
||||
`)
|
||||
|
||||
return response
|
||||
}
|
||||
@@ -444,7 +444,7 @@ export class RequestClient implements HttpClient {
|
||||
// _header is not present in responses with status 1**
|
||||
// rawHeaders are not present in responses with status 1**
|
||||
let fallbackRequest = {
|
||||
_header: noValueMessage,
|
||||
_header: `${noValueMessage}\n`,
|
||||
res: { rawHeaders: [noValueMessage] }
|
||||
}
|
||||
|
||||
@@ -460,7 +460,10 @@ export class RequestClient implements HttpClient {
|
||||
let fallbackResponse = response || {
|
||||
status: noValueMessage,
|
||||
request: fallbackRequest,
|
||||
config: config || { data: noValueMessage, headers: new AxiosHeaders() },
|
||||
config: config || {
|
||||
data: noValueMessage,
|
||||
headers: {} as AxiosRequestHeaders
|
||||
},
|
||||
data: noValueMessage
|
||||
}
|
||||
|
||||
@@ -471,13 +474,13 @@ export class RequestClient implements HttpClient {
|
||||
const parsedResBody = this.parseInterceptedBody(resData)
|
||||
|
||||
process.logger?.info(`HTTP Request (first 50 lines):
|
||||
${reqHeaders}${this.parseInterceptedBody(config?.data)}
|
||||
|
||||
HTTP Response Code: ${this.prettifyString(status)}
|
||||
|
||||
HTTP Response (first 50 lines):
|
||||
${resHeaders}${parsedResBody ? `\n\n${parsedResBody}` : ''}
|
||||
`)
|
||||
${reqHeaders}${this.parseInterceptedBody(config?.data)}
|
||||
|
||||
HTTP Response Code: ${this.prettifyString(status)}
|
||||
|
||||
HTTP Response (first 50 lines):
|
||||
${resHeaders}${parsedResBody ? `\n\n${parsedResBody}` : ''}
|
||||
`)
|
||||
|
||||
return error
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SASJS_LOGS_SEPARATOR, SasjsRequestClient } from '../SasjsRequestClient'
|
||||
import { SasjsParsedResponse } from '../../types'
|
||||
import { AxiosHeaders, AxiosResponse } from 'axios'
|
||||
import { AxiosRequestHeaders, AxiosResponse } from 'axios'
|
||||
|
||||
describe('SasjsRequestClient', () => {
|
||||
const requestClient = new SasjsRequestClient('')
|
||||
@@ -37,7 +37,9 @@ ${SASJS_LOGS_SEPARATOR}`,
|
||||
status,
|
||||
statusText: 'ok',
|
||||
headers: { etag },
|
||||
config: { headers: new AxiosHeaders() }
|
||||
config: {
|
||||
headers: {} as AxiosRequestHeaders
|
||||
}
|
||||
}
|
||||
|
||||
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
||||
@@ -65,7 +67,9 @@ ${printOutput}`,
|
||||
status,
|
||||
statusText: 'ok',
|
||||
headers: { etag },
|
||||
config: { headers: new AxiosHeaders() }
|
||||
config: {
|
||||
headers: {} as AxiosRequestHeaders
|
||||
}
|
||||
}
|
||||
|
||||
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
||||
@@ -100,7 +104,9 @@ ${SASJS_LOGS_SEPARATOR}`,
|
||||
status,
|
||||
statusText: 'ok',
|
||||
headers: { etag },
|
||||
config: { headers: new AxiosHeaders() }
|
||||
config: {
|
||||
headers: {} as AxiosRequestHeaders
|
||||
}
|
||||
}
|
||||
|
||||
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
||||
@@ -139,7 +145,9 @@ ${printOutput}`,
|
||||
status,
|
||||
statusText: 'ok',
|
||||
headers: { etag },
|
||||
config: { headers: new AxiosHeaders() }
|
||||
config: {
|
||||
headers: {} as AxiosRequestHeaders
|
||||
}
|
||||
}
|
||||
|
||||
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { app, mockedAuthResponse } from './SAS_server_app'
|
||||
import { ServerType } from '@sasjs/utils/types'
|
||||
import SASjs from '../SASjs'
|
||||
import * as axiosModules from '../utils/createAxiosInstance'
|
||||
import axios, { AxiosHeaders } from 'axios'
|
||||
import axios, { AxiosRequestHeaders } from 'axios'
|
||||
import {
|
||||
LoginRequiredError,
|
||||
AuthorizeError,
|
||||
@@ -165,10 +165,6 @@ Connection: close
|
||||
})
|
||||
|
||||
it('should log parsed response with status 1**', () => {
|
||||
const spyIsAxiosError = jest
|
||||
.spyOn(axios, 'isAxiosError')
|
||||
.mockImplementation(() => true)
|
||||
|
||||
const mockedAxiosError = {
|
||||
config: {
|
||||
data: reqData
|
||||
@@ -195,8 +191,6 @@ ${noValueMessage}
|
||||
`
|
||||
|
||||
expect((process as any).logger.info).toHaveBeenCalledWith(expectedLog)
|
||||
|
||||
spyIsAxiosError.mockReset()
|
||||
})
|
||||
|
||||
it('should log parsed response with status 2**', () => {
|
||||
@@ -209,7 +203,10 @@ ${noValueMessage}
|
||||
status,
|
||||
statusText: '',
|
||||
headers: {},
|
||||
config: { data: reqData, headers: new AxiosHeaders() },
|
||||
config: {
|
||||
data: reqData,
|
||||
headers: {} as AxiosRequestHeaders
|
||||
},
|
||||
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
||||
}
|
||||
|
||||
@@ -278,7 +275,10 @@ ${noValueMessage}
|
||||
status,
|
||||
statusText: '',
|
||||
headers: {},
|
||||
config: { data: reqData, headers: new AxiosHeaders() },
|
||||
config: {
|
||||
data: reqData,
|
||||
headers: {} as AxiosRequestHeaders
|
||||
},
|
||||
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
||||
}
|
||||
const mockedAxiosError = {
|
||||
@@ -328,7 +328,10 @@ ${resHeaders[0]}: ${resHeaders[1]}${
|
||||
status,
|
||||
statusText: '',
|
||||
headers: {},
|
||||
config: { data: reqData, headers: new AxiosHeaders() },
|
||||
config: {
|
||||
data: reqData,
|
||||
headers: {} as AxiosRequestHeaders
|
||||
},
|
||||
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
||||
}
|
||||
const mockedAxiosError = {
|
||||
|
||||
Reference in New Issue
Block a user