mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 01:14:36 +00:00
fix: usage and typings, axios, nodeFormData, cookiejar...
This commit is contained in:
@@ -142,6 +142,8 @@ module.exports = {
|
|||||||
// Options that will be passed to the testEnvironment
|
// Options that will be passed to the testEnvironment
|
||||||
// testEnvironmentOptions: {},
|
// testEnvironmentOptions: {},
|
||||||
|
|
||||||
|
testEnvironment: 'jest-environment-jsdom',
|
||||||
|
|
||||||
// Adds a location field to test results
|
// Adds a location field to test results
|
||||||
// testLocationInResults: false,
|
// testLocationInResults: false,
|
||||||
|
|
||||||
|
|||||||
1849
package-lock.json
generated
1849
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -46,7 +46,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cypress/webpack-preprocessor": "5.9.1",
|
"@cypress/webpack-preprocessor": "5.9.1",
|
||||||
"@types/express": "4.17.13",
|
"@types/express": "4.17.13",
|
||||||
"@types/jest": "27.4.0",
|
"@types/jest": "29.5.14",
|
||||||
"@types/mime": "2.0.3",
|
"@types/mime": "2.0.3",
|
||||||
"@types/pem": "1.9.6",
|
"@types/pem": "1.9.6",
|
||||||
"@types/tough-cookie": "4.0.2",
|
"@types/tough-cookie": "4.0.2",
|
||||||
@@ -55,8 +55,9 @@
|
|||||||
"cypress": "7.7.0",
|
"cypress": "7.7.0",
|
||||||
"dotenv": "16.0.0",
|
"dotenv": "16.0.0",
|
||||||
"express": "4.17.3",
|
"express": "4.17.3",
|
||||||
"jest": "27.4.7",
|
"jest": "29.7.0",
|
||||||
"jest-extended": "2.0.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
|
"jest-extended": "4.0.2",
|
||||||
"node-polyfill-webpack-plugin": "1.1.4",
|
"node-polyfill-webpack-plugin": "1.1.4",
|
||||||
"path": "0.12.7",
|
"path": "0.12.7",
|
||||||
"pem": "1.14.5",
|
"pem": "1.14.5",
|
||||||
@@ -64,13 +65,13 @@
|
|||||||
"process": "0.11.10",
|
"process": "0.11.10",
|
||||||
"semantic-release": "19.0.3",
|
"semantic-release": "19.0.3",
|
||||||
"terser-webpack-plugin": "5.3.6",
|
"terser-webpack-plugin": "5.3.6",
|
||||||
"ts-jest": "27.1.3",
|
"ts-jest": "29.2.6",
|
||||||
"ts-loader": "9.4.0",
|
"ts-loader": "9.4.0",
|
||||||
"tslint": "6.1.3",
|
"tslint": "6.1.3",
|
||||||
"tslint-config-prettier": "1.18.0",
|
"tslint-config-prettier": "1.18.0",
|
||||||
"typedoc": "0.23.24",
|
"typedoc": "0.23.24",
|
||||||
"typedoc-plugin-rename-defaults": "0.6.4",
|
"typedoc-plugin-rename-defaults": "0.6.4",
|
||||||
"typescript": "4.8.3",
|
"typescript": "4.9.5",
|
||||||
"webpack": "5.76.2",
|
"webpack": "5.76.2",
|
||||||
"webpack-cli": "4.9.2"
|
"webpack-cli": "4.9.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as https from 'https'
|
import * as https from 'https'
|
||||||
import { generateTimestamp } from '@sasjs/utils/time'
|
import { generateTimestamp } from '@sasjs/utils/time'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { Sas9RequestClient } from './request/Sas9RequestClient'
|
import { Sas9RequestClient } from './request/Sas9RequestClient'
|
||||||
import { isUrl } from './utils'
|
import { isUrl } from './utils'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { isRelativePath, isUri, isUrl } from './utils'
|
import { isRelativePath, isUri, isUrl } from './utils'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import {
|
import {
|
||||||
Job,
|
Job,
|
||||||
Session,
|
Session,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { AuthConfig, ServerType, ServicePackSASjs } from '@sasjs/utils/types'
|
import { AuthConfig, ServerType, ServicePackSASjs } from '@sasjs/utils/types'
|
||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
import { ExecutionQuery } from './types'
|
import { ExecutionQuery } from './types'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { SasAuthResponse, ServerType } from '@sasjs/utils/types'
|
import { SasAuthResponse, ServerType } from '@sasjs/utils/types'
|
||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { RequestClient } from '../request/RequestClient'
|
import { RequestClient } from '../request/RequestClient'
|
||||||
import { isNode } from '../utils'
|
import { isNode } from '../utils'
|
||||||
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { AuthConfig } from '@sasjs/utils/types'
|
import { AuthConfig } from '@sasjs/utils/types'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { generateToken, mockAuthResponse } from './mockResponses'
|
import { generateToken, mockAuthResponse } from './mockResponses'
|
||||||
import { RequestClient } from '../../request/RequestClient'
|
import { RequestClient } from '../../request/RequestClient'
|
||||||
import { getAccessTokenForViya } from '../getAccessTokenForViya'
|
import { getAccessTokenForViya } from '../getAccessTokenForViya'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { generateToken, mockAuthResponse } from './mockResponses'
|
import { generateToken, mockAuthResponse } from './mockResponses'
|
||||||
import { RequestClient } from '../../request/RequestClient'
|
import { RequestClient } from '../../request/RequestClient'
|
||||||
import { refreshTokensForViya } from '../refreshTokensForViya'
|
import { refreshTokensForViya } from '../refreshTokensForViya'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { convertToCSV } from '../utils/convertToCsv'
|
import { convertToCSV } from '../utils/convertToCsv'
|
||||||
import { isNode } from '../utils'
|
import { isNode } from '../utils'
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { convertToCSV, isFormatsTable } from '../utils/convertToCsv'
|
import { convertToCSV, isFormatsTable } from '../utils/convertToCsv'
|
||||||
import { splitChunks } from '../utils/splitChunks'
|
import { splitChunks } from '../utils/splitChunks'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { generateFileUploadForm } from '../generateFileUploadForm'
|
import { generateFileUploadForm } from '../generateFileUploadForm'
|
||||||
import { convertToCSV } from '../../utils/convertToCsv'
|
import { convertToCSV } from '../../utils/convertToCsv'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import * as isNodeModule from '../../utils/isNode'
|
import * as isNodeModule from '../../utils/isNode'
|
||||||
|
|
||||||
describe('generateFileUploadForm', () => {
|
describe('generateFileUploadForm', () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as https from 'https'
|
import * as https from 'https'
|
||||||
import { ServerType } from '@sasjs/utils/types'
|
import { ServerType } from '@sasjs/utils/types'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import { ErrorResponse } from '../types/errors'
|
import { ErrorResponse } from '../types/errors'
|
||||||
import { convertToCSV, isRelativePath } from '../utils'
|
import { convertToCSV, isRelativePath } from '../utils'
|
||||||
import { BaseJobExecutor } from './JobExecutor'
|
import { BaseJobExecutor } from './JobExecutor'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import {
|
import {
|
||||||
AuthConfig,
|
AuthConfig,
|
||||||
ExtraResponseAttributes,
|
ExtraResponseAttributes,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
import {
|
import {
|
||||||
AuthConfig,
|
AuthConfig,
|
||||||
ExtraResponseAttributes,
|
ExtraResponseAttributes,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as https from 'https'
|
import * as https from 'https'
|
||||||
import { AxiosRequestConfig } from 'axios'
|
import { AxiosRequestConfig } from 'axios'
|
||||||
import axiosCookieJarSupport from 'axios-cookiejar-support'
|
import { wrapper } from 'axios-cookiejar-support'
|
||||||
import * as tough from 'tough-cookie'
|
import * as tough from 'tough-cookie'
|
||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
import { RequestClient, throwIfError } from './RequestClient'
|
import { RequestClient, throwIfError } from './RequestClient'
|
||||||
@@ -17,8 +17,8 @@ export class Sas9RequestClient extends RequestClient {
|
|||||||
this.httpClient.defaults.validateStatus = (status) =>
|
this.httpClient.defaults.validateStatus = (status) =>
|
||||||
status >= 200 && status < 303
|
status >= 200 && status < 303
|
||||||
|
|
||||||
if (axiosCookieJarSupport) {
|
if (wrapper) {
|
||||||
axiosCookieJarSupport(this.httpClient)
|
wrapper(this.httpClient)
|
||||||
this.httpClient.defaults.jar = new tough.CookieJar()
|
this.httpClient.defaults.jar = new tough.CookieJar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 { AxiosResponse } from 'axios'
|
import { AxiosHeaders, AxiosResponse } from 'axios'
|
||||||
|
|
||||||
describe('SasjsRequestClient', () => {
|
describe('SasjsRequestClient', () => {
|
||||||
const requestClient = new SasjsRequestClient('')
|
const requestClient = new SasjsRequestClient('')
|
||||||
@@ -37,7 +37,7 @@ ${SASJS_LOGS_SEPARATOR}`,
|
|||||||
status,
|
status,
|
||||||
statusText: 'ok',
|
statusText: 'ok',
|
||||||
headers: { etag },
|
headers: { etag },
|
||||||
config: {}
|
config: { headers: new AxiosHeaders() }
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
||||||
@@ -65,7 +65,7 @@ ${printOutput}`,
|
|||||||
status,
|
status,
|
||||||
statusText: 'ok',
|
statusText: 'ok',
|
||||||
headers: { etag },
|
headers: { etag },
|
||||||
config: {}
|
config: { headers: new AxiosHeaders() }
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
||||||
@@ -100,7 +100,7 @@ ${SASJS_LOGS_SEPARATOR}`,
|
|||||||
status,
|
status,
|
||||||
statusText: 'ok',
|
statusText: 'ok',
|
||||||
headers: { etag },
|
headers: { etag },
|
||||||
config: {}
|
config: { headers: new AxiosHeaders() }
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
const expectedParsedResponse: SasjsParsedResponse<string> = {
|
||||||
@@ -139,7 +139,7 @@ ${printOutput}`,
|
|||||||
status,
|
status,
|
||||||
statusText: 'ok',
|
statusText: 'ok',
|
||||||
headers: { etag },
|
headers: { etag },
|
||||||
config: {}
|
config: { headers: new AxiosHeaders() }
|
||||||
}
|
}
|
||||||
|
|
||||||
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 from 'axios'
|
import axios, { AxiosHeaders } from 'axios'
|
||||||
import {
|
import {
|
||||||
LoginRequiredError,
|
LoginRequiredError,
|
||||||
AuthorizeError,
|
AuthorizeError,
|
||||||
@@ -209,7 +209,7 @@ ${noValueMessage}
|
|||||||
status,
|
status,
|
||||||
statusText: '',
|
statusText: '',
|
||||||
headers: {},
|
headers: {},
|
||||||
config: { data: reqData },
|
config: { data: reqData, headers: new AxiosHeaders() },
|
||||||
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ ${noValueMessage}
|
|||||||
status,
|
status,
|
||||||
statusText: '',
|
statusText: '',
|
||||||
headers: {},
|
headers: {},
|
||||||
config: { data: reqData },
|
config: { data: reqData, headers: new AxiosHeaders() },
|
||||||
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
||||||
}
|
}
|
||||||
const mockedAxiosError = {
|
const mockedAxiosError = {
|
||||||
@@ -328,7 +328,7 @@ ${resHeaders[0]}: ${resHeaders[1]}${
|
|||||||
status,
|
status,
|
||||||
statusText: '',
|
statusText: '',
|
||||||
headers: {},
|
headers: {},
|
||||||
config: { data: reqData },
|
config: { data: reqData, headers: new AxiosHeaders() },
|
||||||
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
request: { _header: reqHeaders, res: { rawHeaders: resHeaders } }
|
||||||
}
|
}
|
||||||
const mockedAxiosError = {
|
const mockedAxiosError = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { isNode } from './'
|
import { isNode } from './'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
|
|
||||||
export const getFormData = () =>
|
export const getFormData = () =>
|
||||||
isNode() ? new NodeFormData() : new FormData()
|
isNode() ? new NodeFormData() : new FormData()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { getFormData } from '..'
|
import { getFormData } from '..'
|
||||||
import * as isNodeModule from '../isNode'
|
import * as isNodeModule from '../isNode'
|
||||||
import * as NodeFormData from 'form-data'
|
import NodeFormData from 'form-data'
|
||||||
|
|
||||||
describe('getFormData', () => {
|
describe('getFormData', () => {
|
||||||
it('should return NodeFormData if environment is Node', () => {
|
it('should return NodeFormData if environment is Node', () => {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["ES2018", "DOM", "ES2019.String"],
|
"lib": ["ES2018", "DOM", "ES2019.String"],
|
||||||
"target": "es5",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"outDir": "./build",
|
"outDir": "./build",
|
||||||
|
"esModuleInterop": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"typeRoots": ["./node_modules/@types", "./src/types/system"]
|
"typeRoots": ["./node_modules/@types", "./src/types/system"]
|
||||||
|
|||||||
Reference in New Issue
Block a user