mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-17 09:00:06 +00:00
Merge pull request #713 from sasjs/critical-deps-issues
Fixed critical dependencies issues
This commit is contained in:
4113
package-lock.json
generated
4113
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -64,7 +64,7 @@
|
|||||||
"prettier": "2.7.1",
|
"prettier": "2.7.1",
|
||||||
"process": "0.11.10",
|
"process": "0.11.10",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"semantic-release": "18.0.0",
|
"semantic-release": "19.0.3",
|
||||||
"terser-webpack-plugin": "5.3.1",
|
"terser-webpack-plugin": "5.3.1",
|
||||||
"ts-jest": "27.1.3",
|
"ts-jest": "27.1.3",
|
||||||
"ts-loader": "9.2.6",
|
"ts-loader": "9.2.6",
|
||||||
|
|||||||
30895
sasjs-tests/package-lock.json
generated
30895
sasjs-tests/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sasjs/adapter": "file:../build/sasjs-adapter-5.0.0.tgz",
|
"@sasjs/adapter": "file:../build/sasjs-adapter-5.0.0.tgz",
|
||||||
"@sasjs/test-framework": "^1.4.3",
|
"@sasjs/test-framework": "^1.5.6",
|
||||||
"@types/jest": "^26.0.20",
|
"@types/jest": "^26.0.20",
|
||||||
"@types/node": "^14.14.41",
|
"@types/node": "^14.14.41",
|
||||||
"@types/react": "^17.0.1",
|
"@types/react": "^17.0.1",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"react-scripts": "^4.0.2",
|
"react-scripts": "^5.0.1",
|
||||||
"typescript": "^4.1.3"
|
"typescript": "^4.1.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -43,6 +43,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"node-sass": "^6.0.1"
|
"node-sass": "^7.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ import { fileUploadTests } from './testSuites/FileUpload'
|
|||||||
const App = (): ReactElement<{}> => {
|
const App = (): ReactElement<{}> => {
|
||||||
const { adapter, config } = useContext(AppContext)
|
const { adapter, config } = useContext(AppContext)
|
||||||
const [testSuites, setTestSuites] = useState<TestSuite[]>([])
|
const [testSuites, setTestSuites] = useState<TestSuite[]>([])
|
||||||
|
const appLoc = config.sasJsConfig.appLoc
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (adapter) {
|
if (adapter) {
|
||||||
const testSuites = [
|
const testSuites = [
|
||||||
basicTests(adapter, config.userName, config.password),
|
basicTests(adapter, config.userName, config.password),
|
||||||
sendArrTests(adapter),
|
sendArrTests(adapter, appLoc),
|
||||||
sendObjTests(adapter),
|
sendObjTests(adapter),
|
||||||
specialCaseTests(adapter),
|
specialCaseTests(adapter),
|
||||||
sasjsRequestTests(adapter),
|
sasjsRequestTests(adapter),
|
||||||
@@ -24,12 +25,12 @@ const App = (): ReactElement<{}> => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
if (adapter.getSasjsConfig().serverType === 'SASVIYA') {
|
if (adapter.getSasjsConfig().serverType === 'SASVIYA') {
|
||||||
testSuites.push(computeTests(adapter))
|
testSuites.push(computeTests(adapter, appLoc))
|
||||||
}
|
}
|
||||||
|
|
||||||
setTestSuites(testSuites)
|
setTestSuites(testSuites)
|
||||||
}
|
}
|
||||||
}, [adapter, config])
|
}, [adapter, config, appLoc])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app">
|
<div className="app">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { TestSuite } from '@sasjs/test-framework'
|
|||||||
|
|
||||||
const stringData: any = { table1: [{ col1: 'first col value' }] }
|
const stringData: any = { table1: [{ col1: 'first col value' }] }
|
||||||
|
|
||||||
export const computeTests = (adapter: SASjs): TestSuite => ({
|
export const computeTests = (adapter: SASjs, appLoc: string): TestSuite => ({
|
||||||
name: 'Compute',
|
name: 'Compute',
|
||||||
tests: [
|
tests: [
|
||||||
{
|
{
|
||||||
@@ -35,7 +35,7 @@ export const computeTests = (adapter: SASjs): TestSuite => ({
|
|||||||
description: 'Should start a compute job and return the session',
|
description: 'Should start a compute job and return the session',
|
||||||
test: () => {
|
test: () => {
|
||||||
const data: any = { table1: [{ col1: 'first col value' }] }
|
const data: any = { table1: [{ col1: 'first col value' }] }
|
||||||
return adapter.startComputeJob('/Public/app/common/sendArr', data)
|
return adapter.startComputeJob(`${appLoc}/common/sendArr`, data)
|
||||||
},
|
},
|
||||||
assertion: (res: any) => {
|
assertion: (res: any) => {
|
||||||
const expectedProperties = ['id', 'applicationName', 'attributes']
|
const expectedProperties = ['id', 'applicationName', 'attributes']
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ const getLargeObjectData = () => {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
export const sendArrTests = (adapter: SASjs, appLoc: string): TestSuite => ({
|
||||||
name: 'sendArr',
|
name: 'sendArr',
|
||||||
tests: [
|
tests: [
|
||||||
{
|
{
|
||||||
title: 'Absolute paths',
|
title: 'Absolute paths',
|
||||||
description: 'Should work with absolute paths to SAS jobs',
|
description: 'Should work with absolute paths to SAS jobs',
|
||||||
test: () => {
|
test: () => {
|
||||||
return adapter.request('/Public/app/common/sendArr', stringData)
|
return adapter.request(`${appLoc}/common/sendArr`, stringData)
|
||||||
},
|
},
|
||||||
assertion: (res: any) => {
|
assertion: (res: any) => {
|
||||||
return res.table1[0][0] === stringData.table1[0].col1
|
return res.table1[0][0] === stringData.table1[0].col1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as NodeFormData from 'form-data'
|
import * as NodeFormData from 'form-data'
|
||||||
import { convertToCSV } from '../utils/convertToCsv'
|
import { convertToCSV, isFormatsTable } from '../utils/convertToCsv'
|
||||||
import { splitChunks } from '../utils/splitChunks'
|
import { splitChunks } from '../utils/splitChunks'
|
||||||
|
|
||||||
export const generateTableUploadForm = (
|
export const generateTableUploadForm = (
|
||||||
@@ -13,7 +13,8 @@ export const generateTableUploadForm = (
|
|||||||
for (const tableName in data) {
|
for (const tableName in data) {
|
||||||
tableCounter++
|
tableCounter++
|
||||||
|
|
||||||
sasjsTables.push(tableName)
|
// Formats table should not be sent as part of 'sasjs_tables'
|
||||||
|
if (!isFormatsTable(tableName)) sasjsTables.push(tableName)
|
||||||
|
|
||||||
const csv = convertToCSV(data, tableName)
|
const csv = convertToCSV(data, tableName)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { convertToCSV } from './convertToCsv'
|
import { convertToCSV, isFormatsTable } from './convertToCsv'
|
||||||
|
|
||||||
describe('convertToCsv', () => {
|
describe('convertToCsv', () => {
|
||||||
const tableName = 'testTable'
|
const tableName = 'testTable'
|
||||||
@@ -216,7 +216,9 @@ describe('convertToCsv', () => {
|
|||||||
const data = { [tableName]: [{ var1: 'string' }] }
|
const data = { [tableName]: [{ var1: 'string' }] }
|
||||||
|
|
||||||
expect(() => convertToCSV(data, 'wrongTableName')).toThrow(
|
expect(() => convertToCSV(data, 'wrongTableName')).toThrow(
|
||||||
new Error('No table provided to be converted to CSV')
|
new Error(
|
||||||
|
'Error while converting to CSV. No table provided to be converted to CSV.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -226,3 +228,15 @@ describe('convertToCsv', () => {
|
|||||||
expect(convertToCSV(data, tableName)).toEqual('')
|
expect(convertToCSV(data, tableName)).toEqual('')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('isFormatsTable', () => {
|
||||||
|
const tableName = 'sometable'
|
||||||
|
|
||||||
|
it('should return true if table name match pattern of formats table', () => {
|
||||||
|
expect(isFormatsTable(`$${tableName}`)).toEqual(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false if table name does not match pattern of formats table', () => {
|
||||||
|
expect(isFormatsTable(tableName)).toEqual(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { isSpecialMissing } from '@sasjs/utils/input/validators'
|
import { isSpecialMissing } from '@sasjs/utils/input/validators'
|
||||||
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the given JSON object array to a CSV string.
|
* Converts the given JSON object array to a CSV string.
|
||||||
@@ -9,7 +10,10 @@ export const convertToCSV = (
|
|||||||
tableName: string
|
tableName: string
|
||||||
) => {
|
) => {
|
||||||
if (!data[tableName]) {
|
if (!data[tableName]) {
|
||||||
throw new Error('No table provided to be converted to CSV')
|
throw prefixMessage(
|
||||||
|
'No table provided to be converted to CSV.',
|
||||||
|
'Error while converting to CSV. '
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const table = data[tableName]
|
const table = data[tableName]
|
||||||
@@ -170,6 +174,12 @@ export const convertToCSV = (
|
|||||||
return finalCSV
|
return finalCSV
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if table is table of formats (table name should start from '$' character).
|
||||||
|
* @param tableName - table name.
|
||||||
|
*/
|
||||||
|
export const isFormatsTable = (tableName: string) => /^\$.*/.test(tableName)
|
||||||
|
|
||||||
const getByteSize = (str: string) => {
|
const getByteSize = (str: string) => {
|
||||||
let byteSize = str.length
|
let byteSize = str.length
|
||||||
for (let i = str.length - 1; i >= 0; i--) {
|
for (let i = str.length - 1; i >= 0; i--) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { convertToCSV } from './convertToCsv'
|
import { convertToCSV, isFormatsTable } from './convertToCsv'
|
||||||
import { splitChunks } from './splitChunks'
|
import { splitChunks } from './splitChunks'
|
||||||
|
|
||||||
export const formatDataForRequest = (data: any) => {
|
export const formatDataForRequest = (data: any) => {
|
||||||
@@ -8,7 +8,7 @@ export const formatDataForRequest = (data: any) => {
|
|||||||
|
|
||||||
for (const tableName in data) {
|
for (const tableName in data) {
|
||||||
if (
|
if (
|
||||||
tableName.match(/^\$.*/) &&
|
isFormatsTable(tableName) &&
|
||||||
Object.keys(data).includes(tableName.replace(/^\$/, ''))
|
Object.keys(data).includes(tableName.replace(/^\$/, ''))
|
||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
@@ -16,7 +16,8 @@ export const formatDataForRequest = (data: any) => {
|
|||||||
|
|
||||||
tableCounter++
|
tableCounter++
|
||||||
|
|
||||||
sasjsTables.push(tableName)
|
// Formats table should not be sent as part of 'sasjs_tables'
|
||||||
|
if (!isFormatsTable(tableName)) sasjsTables.push(tableName)
|
||||||
|
|
||||||
const csv = convertToCSV(data, tableName)
|
const csv = convertToCSV(data, tableName)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user