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