mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-10 17:04:36 +00:00
chore(deps): added prettier dev dependency
This commit is contained in:
@@ -3,7 +3,7 @@ const username = Cypress.env('username')
|
||||
const password = Cypress.env('password')
|
||||
const testingFinishTimeout = Cypress.env('testingFinishTimeout')
|
||||
|
||||
context('sasjs-tests', function() {
|
||||
context('sasjs-tests', function () {
|
||||
this.beforeAll(() => {
|
||||
cy.visit(sasjsTestsUrl)
|
||||
})
|
||||
@@ -12,8 +12,8 @@ context('sasjs-tests', function() {
|
||||
cy.reload()
|
||||
})
|
||||
|
||||
it('Should have all tests successfull', done => {
|
||||
cy.get('body').then($body => {
|
||||
it('Should have all tests successfull', (done) => {
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('input[placeholder="User Name"]').length > 0) {
|
||||
cy.get('input[placeholder="User Name"]').type(username)
|
||||
cy.get('input[placeholder="Password"]').type(password)
|
||||
@@ -42,8 +42,8 @@ context('sasjs-tests', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('Should have all tests successfull with debug on', done => {
|
||||
cy.get('body').then($body => {
|
||||
it('Should have all tests successfull with debug on', (done) => {
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('input[placeholder="User Name"]').length > 0) {
|
||||
cy.get('input[placeholder="User Name"]').type(username)
|
||||
cy.get('input[placeholder="Password"]').type(password)
|
||||
|
||||
22
package-lock.json
generated
22
package-lock.json
generated
@@ -34,6 +34,7 @@
|
||||
"node-polyfill-webpack-plugin": "1.1.4",
|
||||
"path": "0.12.7",
|
||||
"pem": "1.14.6",
|
||||
"prettier": "^2.7.1",
|
||||
"process": "0.11.10",
|
||||
"rimraf": "3.0.2",
|
||||
"semantic-release": "18.0.0",
|
||||
@@ -14238,6 +14239,21 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-bytes": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz",
|
||||
@@ -28279,6 +28295,12 @@
|
||||
"integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true
|
||||
},
|
||||
"pretty-bytes": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz",
|
||||
|
||||
@@ -44,18 +44,16 @@
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@cypress/webpack-preprocessor": "5.9.1",
|
||||
"@types/form-data": "2.5.0",
|
||||
"cypress": "7.7.0",
|
||||
"typedoc-neo-theme": "1.1.1",
|
||||
"typedoc-plugin-external-module-name": "4.0.6",
|
||||
"@types/axios": "0.14.0",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/form-data": "2.5.0",
|
||||
"@types/jest": "27.4.0",
|
||||
"@types/mime": "2.0.3",
|
||||
"@types/pem": "1.9.6",
|
||||
"@types/tough-cookie": "4.0.1",
|
||||
"copyfiles": "2.4.1",
|
||||
"cp": "0.2.0",
|
||||
"cypress": "7.7.0",
|
||||
"dotenv": "16.0.0",
|
||||
"express": "4.17.3",
|
||||
"jest": "27.4.7",
|
||||
@@ -63,6 +61,7 @@
|
||||
"node-polyfill-webpack-plugin": "1.1.4",
|
||||
"path": "0.12.7",
|
||||
"pem": "1.14.6",
|
||||
"prettier": "2.7.1",
|
||||
"process": "0.11.10",
|
||||
"rimraf": "3.0.2",
|
||||
"semantic-release": "18.0.0",
|
||||
@@ -72,6 +71,8 @@
|
||||
"tslint": "6.1.3",
|
||||
"tslint-config-prettier": "1.18.0",
|
||||
"typedoc": "0.22.11",
|
||||
"typedoc-neo-theme": "1.1.1",
|
||||
"typedoc-plugin-external-module-name": "4.0.6",
|
||||
"typedoc-plugin-rename-defaults": "0.4.0",
|
||||
"typescript": "4.5.5",
|
||||
"webpack": "5.69.0",
|
||||
|
||||
@@ -9,9 +9,9 @@ const Login = (): ReactElement<{}> => {
|
||||
const appContext = useContext(AppContext)
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
e => {
|
||||
(e) => {
|
||||
e.preventDefault()
|
||||
appContext.adapter.logIn(username, password).then(res => {
|
||||
appContext.adapter.logIn(username, password).then((res) => {
|
||||
appContext.setIsLoggedIn(res.isLoggedIn)
|
||||
})
|
||||
},
|
||||
@@ -28,7 +28,7 @@ const Login = (): ReactElement<{}> => {
|
||||
placeholder="User Name"
|
||||
value={username}
|
||||
required
|
||||
onChange={e => setUsername(e.target.value)}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="row">
|
||||
@@ -38,7 +38,7 @@ const Login = (): ReactElement<{}> => {
|
||||
type="password"
|
||||
value={password}
|
||||
required
|
||||
onChange={e => setPassword(e.target.value)}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" className="submit-button">
|
||||
|
||||
@@ -57,7 +57,7 @@ export function register(config) {
|
||||
function registerValidSW(swUrl, config) {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then(registration => {
|
||||
.then((registration) => {
|
||||
registration.onupdatefound = () => {
|
||||
const installingWorker = registration.installing
|
||||
if (installingWorker == null) {
|
||||
@@ -93,7 +93,7 @@ function registerValidSW(swUrl, config) {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.error('Error during service worker registration:', error)
|
||||
})
|
||||
}
|
||||
@@ -103,7 +103,7 @@ function checkValidServiceWorker(swUrl, config) {
|
||||
fetch(swUrl, {
|
||||
headers: { 'Service-Worker': 'script' }
|
||||
})
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
// Ensure service worker exists, and that we really are getting a JS file.
|
||||
const contentType = response.headers.get('content-type')
|
||||
if (
|
||||
@@ -111,7 +111,7 @@ function checkValidServiceWorker(swUrl, config) {
|
||||
(contentType != null && contentType.indexOf('javascript') === -1)
|
||||
) {
|
||||
// No service worker found. Probably a different app. Reload the page.
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
registration.unregister().then(() => {
|
||||
window.location.reload()
|
||||
})
|
||||
@@ -131,10 +131,10 @@ function checkValidServiceWorker(swUrl, config) {
|
||||
export function unregister() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready
|
||||
.then(registration => {
|
||||
.then((registration) => {
|
||||
registration.unregister()
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.error(error.message)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ const validateLog = (text: string, log: string): boolean => {
|
||||
const validate = (expectedProperties: string[], data: any): boolean => {
|
||||
const actualProperties = Object.keys(data)
|
||||
|
||||
const isValid = expectedProperties.every(property =>
|
||||
const isValid = expectedProperties.every((property) =>
|
||||
actualProperties.includes(property)
|
||||
)
|
||||
return isValid
|
||||
|
||||
@@ -86,7 +86,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
'Should error out with long string values over 32765 characters',
|
||||
test: () => {
|
||||
const data = getLongStringData(32767)
|
||||
return adapter.request('common/sendArr', data).catch(e => e)
|
||||
return adapter.request('common/sendArr', data).catch((e) => e)
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.error && !!error.error.message
|
||||
@@ -182,7 +182,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
const invalidData: any = {
|
||||
'1InvalidTable': [{ col1: 42 }]
|
||||
}
|
||||
return adapter.request('common/sendObj', invalidData).catch(e => e)
|
||||
return adapter.request('common/sendObj', invalidData).catch((e) => e)
|
||||
},
|
||||
assertion: (error: any) =>
|
||||
!!error && !!error.error && !!error.error.message
|
||||
@@ -194,7 +194,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
const invalidData: any = {
|
||||
'an invalidTable': [{ col1: 42 }]
|
||||
}
|
||||
return adapter.request('common/sendObj', invalidData).catch(e => e)
|
||||
return adapter.request('common/sendObj', invalidData).catch((e) => e)
|
||||
},
|
||||
assertion: (error: any) =>
|
||||
!!error && !!error.error && !!error.error.message
|
||||
@@ -206,7 +206,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
const invalidData: any = {
|
||||
'anInvalidTable#': [{ col1: 42 }]
|
||||
}
|
||||
return adapter.request('common/sendObj', invalidData).catch(e => e)
|
||||
return adapter.request('common/sendObj', invalidData).catch((e) => e)
|
||||
},
|
||||
assertion: (error: any) =>
|
||||
!!error && !!error.error && !!error.error.message
|
||||
@@ -219,7 +219,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: [{ col1: 42 }]
|
||||
}
|
||||
|
||||
return adapter.request('common/sendObj', invalidData).catch(e => e)
|
||||
return adapter.request('common/sendObj', invalidData).catch((e) => e)
|
||||
},
|
||||
assertion: (error: any) =>
|
||||
!!error && !!error.error && !!error.error.message
|
||||
@@ -231,7 +231,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
const invalidData: any = {
|
||||
inData: [[{ data: 'value' }]]
|
||||
}
|
||||
return adapter.request('common/sendObj', invalidData).catch(e => e)
|
||||
return adapter.request('common/sendObj', invalidData).catch((e) => e)
|
||||
},
|
||||
assertion: (error: any) =>
|
||||
!!error && !!error.error && !!error.error.message
|
||||
@@ -265,7 +265,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
test: () => {
|
||||
return adapter
|
||||
.request('common/sendObj', getLongStringData(32767))
|
||||
.catch(e => e)
|
||||
.catch((e) => e)
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.error && !!error.error.message
|
||||
|
||||
@@ -31,7 +31,7 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
|
||||
.catch(() => {
|
||||
const sasRequests = adapter.getSasRequests()
|
||||
const makeErrRequest: any =
|
||||
sasRequests.find(req => req.serviceLink.includes('makeErr')) ||
|
||||
sasRequests.find((req) => req.serviceLink.includes('makeErr')) ||
|
||||
null
|
||||
|
||||
if (!makeErrRequest) return false
|
||||
@@ -41,7 +41,7 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
|
||||
)
|
||||
})
|
||||
},
|
||||
assertion: response => {
|
||||
assertion: (response) => {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class ContextManager {
|
||||
`${this.serverUrl}/compute/contexts?limit=10000`,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting compute contexts. ')
|
||||
})
|
||||
|
||||
@@ -63,7 +63,7 @@ export class ContextManager {
|
||||
`${this.serverUrl}/launcher/contexts?limit=10000`,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting launcher contexts. ')
|
||||
})
|
||||
|
||||
@@ -96,7 +96,9 @@ export class ContextManager {
|
||||
|
||||
const existingComputeContexts = await this.getComputeContexts(accessToken)
|
||||
|
||||
if (existingComputeContexts.find(context => context.name === contextName)) {
|
||||
if (
|
||||
existingComputeContexts.find((context) => context.name === contextName)
|
||||
) {
|
||||
throw new Error(`Compute context '${contextName}' already exists.`)
|
||||
}
|
||||
|
||||
@@ -105,7 +107,9 @@ export class ContextManager {
|
||||
const launcherContexts = await this.getLauncherContexts(accessToken)
|
||||
|
||||
if (
|
||||
!launcherContexts.find(context => context.name === launchContextName)
|
||||
!launcherContexts.find(
|
||||
(context) => context.name === launchContextName
|
||||
)
|
||||
) {
|
||||
const description = `The launcher context for ${launchContextName}`
|
||||
const launchType = 'direct'
|
||||
@@ -115,7 +119,7 @@ export class ContextManager {
|
||||
description,
|
||||
launchType,
|
||||
accessToken
|
||||
).catch(err => {
|
||||
).catch((err) => {
|
||||
throw new Error(`Error while creating launcher context. ${err}`)
|
||||
})
|
||||
|
||||
@@ -165,7 +169,7 @@ export class ContextManager {
|
||||
requestBody,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while creating compute context. ')
|
||||
})
|
||||
|
||||
@@ -191,7 +195,7 @@ export class ContextManager {
|
||||
const existingLauncherContexts = await this.getLauncherContexts(accessToken)
|
||||
|
||||
if (
|
||||
existingLauncherContexts.find(context => context.name === contextName)
|
||||
existingLauncherContexts.find((context) => context.name === contextName)
|
||||
) {
|
||||
throw new Error(`Launcher context '${contextName}' already exists.`)
|
||||
}
|
||||
@@ -216,7 +220,7 @@ export class ContextManager {
|
||||
requestBody,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while creating launcher context. ')
|
||||
})
|
||||
|
||||
@@ -257,7 +261,7 @@ export class ContextManager {
|
||||
`${this.serverUrl}/compute/contexts/${originalContext.id}`,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (err && err.status === 404) {
|
||||
throw new Error(
|
||||
`The context '${contextName}' was not found on this server.`
|
||||
@@ -291,7 +295,7 @@ export class ContextManager {
|
||||
`${this.serverUrl}/compute/contexts?filter=eq(name, "${contextName}")`,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(
|
||||
err,
|
||||
'Error while getting compute context by name. '
|
||||
@@ -316,7 +320,7 @@ export class ContextManager {
|
||||
`${this.serverUrl}/compute/contexts/${contextId}`,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting compute context by id. ')
|
||||
})
|
||||
|
||||
@@ -332,7 +336,7 @@ export class ContextManager {
|
||||
`${this.serverUrl}/compute/contexts?limit=10000`,
|
||||
authConfig?.access_token
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while fetching compute contexts.')
|
||||
})
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ export class SAS9ApiClient {
|
||||
'Content-Length': contentLength,
|
||||
Connection: 'keep-alive'
|
||||
}
|
||||
const storedProcessUrl = `${this.jobsPath}/?${'_program=' +
|
||||
codeInjectorPath +
|
||||
'&_debug=log'}`
|
||||
const storedProcessUrl = `${this.jobsPath}/?${
|
||||
'_program=' + codeInjectorPath + '&_debug=log'
|
||||
}`
|
||||
const response = await this.requestClient.post(
|
||||
storedProcessUrl,
|
||||
formData,
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('SASViyaApiClient', () => {
|
||||
.mockImplementation(() => Promise.reject('Not Found'))
|
||||
const error = await sasViyaApiClient
|
||||
.createFolder('test', '/foo')
|
||||
.catch(e => e)
|
||||
.catch((e) => e)
|
||||
expect(error).toBeInstanceOf(RootFolderNotFoundError)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -313,7 +313,7 @@ export class SASViyaApiClient {
|
||||
public async getFolder(folderPath: string, accessToken?: string) {
|
||||
return await this.requestClient
|
||||
.get(`/folders/folders/@item?path=${folderPath}`, accessToken)
|
||||
.then(res => res.result)
|
||||
.then((res) => res.result)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -427,16 +427,15 @@ export class SASViyaApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
const { result: createFolderResponse } = await this.requestClient.post<
|
||||
Folder
|
||||
>(
|
||||
`/folders/folders?parentFolderUri=${parentFolderUri}`,
|
||||
{
|
||||
name: folderName,
|
||||
type: 'folder'
|
||||
},
|
||||
accessToken
|
||||
)
|
||||
const { result: createFolderResponse } =
|
||||
await this.requestClient.post<Folder>(
|
||||
`/folders/folders?parentFolderUri=${parentFolderUri}`,
|
||||
{
|
||||
name: folderName,
|
||||
type: 'folder'
|
||||
},
|
||||
accessToken
|
||||
)
|
||||
|
||||
// update folder map with newly created folder.
|
||||
await this.populateFolderMap(
|
||||
@@ -496,8 +495,8 @@ export class SASViyaApiClient {
|
||||
|
||||
const authCode = await this.requestClient
|
||||
.get<string>(authUrl, undefined, 'text/plain')
|
||||
.then(response => response.result)
|
||||
.then(async response => {
|
||||
.then((response) => response.result)
|
||||
.then(async (response) => {
|
||||
let code = ''
|
||||
if (isAuthorizeFormRequired(response)) {
|
||||
const formResponse: any = await this.requestClient.authorize(response)
|
||||
@@ -626,7 +625,7 @@ export class SASViyaApiClient {
|
||||
? `${this.rootFolderName}/${folderPath}`
|
||||
: folderPath
|
||||
|
||||
await this.populateFolderMap(fullFolderPath, access_token).catch(err => {
|
||||
await this.populateFolderMap(fullFolderPath, access_token).catch((err) => {
|
||||
throw prefixMessage(err, 'Error while populating folder map. ')
|
||||
})
|
||||
|
||||
@@ -638,7 +637,7 @@ export class SASViyaApiClient {
|
||||
)
|
||||
}
|
||||
|
||||
const jobToExecute = jobFolder?.find(item => item.name === jobName)
|
||||
const jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||
|
||||
if (!jobToExecute) {
|
||||
throw new Error(`Job was not found.`)
|
||||
@@ -648,7 +647,7 @@ export class SASViyaApiClient {
|
||||
|
||||
if (!code) {
|
||||
const jobDefinitionLink = jobToExecute?.links.find(
|
||||
l => l.rel === 'getResource'
|
||||
(l) => l.rel === 'getResource'
|
||||
)
|
||||
|
||||
if (!jobDefinitionLink) {
|
||||
@@ -660,7 +659,7 @@ export class SASViyaApiClient {
|
||||
`${this.serverUrl}${jobDefinitionLink.href}`,
|
||||
access_token
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting job definition. ')
|
||||
})
|
||||
|
||||
@@ -729,7 +728,7 @@ export class SASViyaApiClient {
|
||||
)
|
||||
}
|
||||
|
||||
const jobToExecute = jobFolder?.find(item => item.name === jobName)
|
||||
const jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||
|
||||
let files: any[] = []
|
||||
if (data && Object.keys(data).length) {
|
||||
@@ -740,7 +739,7 @@ export class SASViyaApiClient {
|
||||
throw new Error(`Job was not found.`)
|
||||
}
|
||||
const jobDefinitionLink = jobToExecute?.links.find(
|
||||
l => l.rel === 'getResource'
|
||||
(l) => l.rel === 'getResource'
|
||||
)?.href
|
||||
|
||||
const { result: jobDefinition } = await this.requestClient.get<Job>(
|
||||
@@ -784,7 +783,7 @@ export class SASViyaApiClient {
|
||||
access_token
|
||||
)
|
||||
const jobStatus = await this.pollJobState(postedJob, authConfig).catch(
|
||||
err => {
|
||||
(err) => {
|
||||
throw prefixMessage(err, 'Error while polling job status. ')
|
||||
}
|
||||
)
|
||||
@@ -797,7 +796,7 @@ export class SASViyaApiClient {
|
||||
let log
|
||||
|
||||
const resultLink = currentJob.results['_webout.json']
|
||||
const logLink = currentJob.links.find(l => l.rel === 'log')
|
||||
const logLink = currentJob.links.find((l) => l.rel === 'log')
|
||||
if (resultLink) {
|
||||
jobResult = await this.requestClient.get<any>(
|
||||
`${this.serverUrl}${resultLink}/content`,
|
||||
@@ -831,7 +830,7 @@ export class SASViyaApiClient {
|
||||
const url = '/folders/folders/@item?path=' + path
|
||||
const { result: folder } = await this.requestClient
|
||||
.get<Folder>(`${url}`, accessToken)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting folder. ')
|
||||
})
|
||||
|
||||
@@ -846,7 +845,7 @@ export class SASViyaApiClient {
|
||||
}`, // this is a fix for https://github.com/sasjs/adapter/issues/669
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting members. ')
|
||||
})
|
||||
|
||||
@@ -883,7 +882,7 @@ export class SASViyaApiClient {
|
||||
|
||||
const { result: folder } = await this.requestClient
|
||||
.get<Folder>(`${this.serverUrl}${url}`, accessToken)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (err instanceof CertificateError) throw err
|
||||
return { result: null }
|
||||
})
|
||||
@@ -905,7 +904,7 @@ export class SASViyaApiClient {
|
||||
|
||||
const { result: folder } = await this.requestClient
|
||||
.get<Folder>(`${this.serverUrl}${url}`, accessToken)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (err instanceof CertificateError) throw err
|
||||
return { result: null }
|
||||
})
|
||||
@@ -1025,7 +1024,7 @@ export class SASViyaApiClient {
|
||||
},
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (err.code && err.code === 'ENOTFOUND') {
|
||||
const notFoundError = {
|
||||
body: {
|
||||
|
||||
@@ -754,9 +754,7 @@ export default class SASjs {
|
||||
* @param data A json object that contains one or more tables, it can also be null
|
||||
* @returns An object which contains two attributes: 1) status: boolean, 2) msg: string
|
||||
*/
|
||||
private validateInput(
|
||||
data: { [key: string]: any } | null
|
||||
): {
|
||||
private validateInput(data: { [key: string]: any } | null): {
|
||||
status: boolean
|
||||
msg: string
|
||||
} {
|
||||
@@ -980,7 +978,7 @@ export default class SASjs {
|
||||
* @param accessToken - an access token for an authorised user.
|
||||
*/
|
||||
public async fetchLogFileContent(logUrl: string, accessToken?: string) {
|
||||
return await this.requestClient!.get(logUrl, accessToken).then(res => {
|
||||
return await this.requestClient!.get(logUrl, accessToken).then((res) => {
|
||||
if (!res)
|
||||
return Promise.reject(
|
||||
new ErrorResponse(
|
||||
|
||||
@@ -87,7 +87,7 @@ export class SASjsApiClient {
|
||||
.join('\n')
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
parsedSasjsServerLog = err
|
||||
})
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ export class SessionManager {
|
||||
return await this.requestClient
|
||||
.delete<Session>(`/compute/sessions/${id}`, accessToken)
|
||||
.then(() => {
|
||||
this.sessions = this.sessions.filter(s => s.id !== id)
|
||||
this.sessions = this.sessions.filter((s) => s.id !== id)
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while deleting session. ')
|
||||
})
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export class SessionManager {
|
||||
private async createSessions(accessToken?: string) {
|
||||
if (!this.sessions.length) {
|
||||
if (!this.currentContext) {
|
||||
await this.setCurrentContext(accessToken).catch(err => {
|
||||
await this.setCurrentContext(accessToken).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
@@ -76,12 +76,12 @@ export class SessionManager {
|
||||
await asyncForEach(new Array(MAX_SESSION_COUNT), async () => {
|
||||
const createdSession = await this.createAndWaitForSession(
|
||||
accessToken
|
||||
).catch(err => {
|
||||
).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
|
||||
this.sessions.push(createdSession)
|
||||
}).catch(err => {
|
||||
}).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
@@ -96,7 +96,7 @@ export class SessionManager {
|
||||
{},
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw err
|
||||
})
|
||||
|
||||
@@ -113,7 +113,7 @@ export class SessionManager {
|
||||
.get<{
|
||||
items: Context[]
|
||||
}>(`${this.serverUrl}/compute/contexts?limit=10000`, accessToken)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw err
|
||||
})
|
||||
|
||||
@@ -173,16 +173,14 @@ export class SessionManager {
|
||||
this.printedSessionState.printed = true
|
||||
}
|
||||
|
||||
const {
|
||||
result: state,
|
||||
responseStatus: responseStatus
|
||||
} = await this.getSessionState(
|
||||
`${this.serverUrl}${stateLink.href}?wait=30`,
|
||||
etag!,
|
||||
accessToken
|
||||
).catch(err => {
|
||||
throw prefixMessage(err, 'Error while getting session state.')
|
||||
})
|
||||
const { result: state, responseStatus: responseStatus } =
|
||||
await this.getSessionState(
|
||||
`${this.serverUrl}${stateLink.href}?wait=30`,
|
||||
etag!,
|
||||
accessToken
|
||||
).catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting session state.')
|
||||
})
|
||||
|
||||
sessionState = state.trim()
|
||||
|
||||
@@ -234,11 +232,11 @@ export class SessionManager {
|
||||
) {
|
||||
return await this.requestClient
|
||||
.get(url, accessToken, 'text/plain', { 'If-None-Match': etag })
|
||||
.then(res => ({
|
||||
.then((res) => ({
|
||||
result: res.result as string,
|
||||
responseStatus: res.status
|
||||
}))
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
@@ -249,7 +247,7 @@ export class SessionManager {
|
||||
`${this.serverUrl}/compute/sessions/${sessionId}/variables/${variable}`,
|
||||
accessToken
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(
|
||||
err,
|
||||
`Error while fetching session variable '${variable}'.`
|
||||
|
||||
@@ -55,25 +55,24 @@ export async function executeScript(
|
||||
try {
|
||||
let executionSessionId: string
|
||||
|
||||
const session = await sessionManager.getSession(access_token).catch(err => {
|
||||
throw prefixMessage(err, 'Error while getting session. ')
|
||||
})
|
||||
const session = await sessionManager
|
||||
.getSession(access_token)
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting session. ')
|
||||
})
|
||||
|
||||
executionSessionId = session!.id
|
||||
|
||||
if (printPid) {
|
||||
const { result: jobIdVariable } = await sessionManager
|
||||
.getVariable(executionSessionId, 'SYSJOBID', access_token)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting session variable. ')
|
||||
})
|
||||
|
||||
if (jobIdVariable && jobIdVariable.value) {
|
||||
const relativeJobPath = rootFolderName
|
||||
? jobPath
|
||||
.split(rootFolderName)
|
||||
.join('')
|
||||
.replace(/^\//, '')
|
||||
? jobPath.split(rootFolderName).join('').replace(/^\//, '')
|
||||
: jobPath
|
||||
|
||||
const logger = process.logger || console
|
||||
@@ -127,7 +126,7 @@ export async function executeScript(
|
||||
if (data) {
|
||||
if (JSON.stringify(data).includes(';')) {
|
||||
files = await uploadTables(requestClient, data, access_token).catch(
|
||||
err => {
|
||||
(err) => {
|
||||
throw prefixMessage(err, 'Error while uploading tables. ')
|
||||
}
|
||||
)
|
||||
@@ -160,7 +159,7 @@ export async function executeScript(
|
||||
jobRequestBody,
|
||||
access_token
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while posting job. ')
|
||||
})
|
||||
|
||||
@@ -181,7 +180,7 @@ export async function executeScript(
|
||||
debug,
|
||||
authConfig,
|
||||
pollOptions
|
||||
).catch(async err => {
|
||||
).catch(async (err) => {
|
||||
const error = err?.response?.data
|
||||
const result = /err=[0-9]*,/.exec(error)
|
||||
|
||||
@@ -209,14 +208,14 @@ export async function executeScript(
|
||||
`/compute/sessions/${executionSessionId}/jobs/${postedJob.id}`,
|
||||
access_token
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting job. ')
|
||||
})
|
||||
|
||||
let jobResult
|
||||
let log = ''
|
||||
|
||||
const logLink = currentJob.links.find(l => l.rel === 'log')
|
||||
const logLink = currentJob.links.find((l) => l.rel === 'log')
|
||||
|
||||
if (debug && logLink) {
|
||||
const logUrl = `${logLink.href}/content`
|
||||
@@ -241,7 +240,7 @@ export async function executeScript(
|
||||
|
||||
jobResult = await requestClient
|
||||
.get<any>(resultLink, access_token, 'text/plain')
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
if (e instanceof NotFoundError) {
|
||||
if (logLink) {
|
||||
const logUrl = `${logLink.href}/content`
|
||||
@@ -267,7 +266,7 @@ export async function executeScript(
|
||||
|
||||
await sessionManager
|
||||
.clearSession(executionSessionId, access_token)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while clearing session. ')
|
||||
})
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function pollJobState(
|
||||
'',
|
||||
debug,
|
||||
authConfig
|
||||
).catch(err => {
|
||||
).catch((err) => {
|
||||
logger.error(
|
||||
`Error fetching job state from ${stateLink.href}. Starting poll, assuming job to be running.`,
|
||||
err
|
||||
@@ -139,7 +139,7 @@ const getJobState = async (
|
||||
{},
|
||||
debug
|
||||
)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw new JobStatePollError(job.id, err)
|
||||
})
|
||||
|
||||
@@ -192,7 +192,7 @@ const doPoll = async (
|
||||
state,
|
||||
debug,
|
||||
authConfig
|
||||
).catch(err => {
|
||||
).catch((err) => {
|
||||
errorCount++
|
||||
if (pollCount >= maxPollCount || errorCount >= maxErrorCount) {
|
||||
throw err
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function saveLog(
|
||||
}
|
||||
|
||||
const logger = process.logger || console
|
||||
const jobLogUrl = job.links.find(l => l.rel === 'log')
|
||||
const jobLogUrl = job.links.find((l) => l.rel === 'log')
|
||||
|
||||
if (!jobLogUrl) {
|
||||
throw new Error(`Log URL for job ${job.id} was not found.`)
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('executeScript', () => {
|
||||
'test',
|
||||
['%put hello'],
|
||||
'test context'
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while getting session.')
|
||||
})
|
||||
@@ -128,7 +128,7 @@ describe('executeScript', () => {
|
||||
false,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while getting session variable.')
|
||||
})
|
||||
@@ -297,7 +297,7 @@ describe('executeScript', () => {
|
||||
false,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while posting job')
|
||||
})
|
||||
@@ -367,7 +367,7 @@ describe('executeScript', () => {
|
||||
true,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while polling job status.')
|
||||
})
|
||||
@@ -393,12 +393,12 @@ describe('executeScript', () => {
|
||||
true,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(fetchLogsModule.fetchLogByChunks).toHaveBeenCalledWith(
|
||||
requestClient,
|
||||
mockAuthConfig.access_token,
|
||||
mockJob.links.find(l => l.rel === 'up')!.href + '/log',
|
||||
mockJob.links.find((l) => l.rel === 'up')!.href + '/log',
|
||||
1000000
|
||||
)
|
||||
expect(error.log).toEqual('Test Log')
|
||||
@@ -424,7 +424,7 @@ describe('executeScript', () => {
|
||||
expect(fetchLogsModule.fetchLogByChunks).toHaveBeenCalledWith(
|
||||
requestClient,
|
||||
mockAuthConfig.access_token,
|
||||
mockJob.links.find(l => l.rel === 'log')!.href + '/content',
|
||||
mockJob.links.find((l) => l.rel === 'log')!.href + '/content',
|
||||
mockJob.logStatistics.lineCount
|
||||
)
|
||||
})
|
||||
@@ -468,12 +468,12 @@ describe('executeScript', () => {
|
||||
true,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(fetchLogsModule.fetchLogByChunks).toHaveBeenCalledWith(
|
||||
requestClient,
|
||||
mockAuthConfig.access_token,
|
||||
mockJob.links.find(l => l.rel === 'log')!.href + '/content',
|
||||
mockJob.links.find((l) => l.rel === 'log')!.href + '/content',
|
||||
mockJob.logStatistics.lineCount
|
||||
)
|
||||
|
||||
@@ -501,12 +501,12 @@ describe('executeScript', () => {
|
||||
true,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(fetchLogsModule.fetchLogByChunks).toHaveBeenCalledWith(
|
||||
requestClient,
|
||||
mockAuthConfig.access_token,
|
||||
mockJob.links.find(l => l.rel === 'log')!.href + '/content',
|
||||
mockJob.links.find((l) => l.rel === 'log')!.href + '/content',
|
||||
mockJob.logStatistics.lineCount
|
||||
)
|
||||
|
||||
@@ -561,7 +561,7 @@ describe('executeScript', () => {
|
||||
true,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(requestClient.get).toHaveBeenCalledWith(
|
||||
`/compute/sessions/${mockSession.id}/filerefs/_webout/content`,
|
||||
@@ -572,7 +572,7 @@ describe('executeScript', () => {
|
||||
expect(fetchLogsModule.fetchLogByChunks).toHaveBeenCalledWith(
|
||||
requestClient,
|
||||
mockAuthConfig.access_token,
|
||||
mockJob.links.find(l => l.rel === 'log')!.href + '/content',
|
||||
mockJob.links.find((l) => l.rel === 'log')!.href + '/content',
|
||||
mockJob.logStatistics.lineCount
|
||||
)
|
||||
|
||||
@@ -622,7 +622,7 @@ describe('executeScript', () => {
|
||||
true,
|
||||
defaultPollOptions,
|
||||
true
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while clearing session.')
|
||||
})
|
||||
|
||||
@@ -37,5 +37,5 @@ const setupMocks = () => {
|
||||
jest.mock('@sasjs/utils/file/file')
|
||||
jest
|
||||
.spyOn(fileModule, 'createWriteStream')
|
||||
.mockImplementation(() => Promise.resolve(({} as unknown) as WriteStream))
|
||||
.mockImplementation(() => Promise.resolve({} as unknown as WriteStream))
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ describe('pollJobState', () => {
|
||||
it('should throw an error if the job does not have a state link', async () => {
|
||||
const error = await pollJobState(
|
||||
requestClient,
|
||||
{ ...mockJob, links: mockJob.links.filter(l => l.rel !== 'state') },
|
||||
{ ...mockJob, links: mockJob.links.filter((l) => l.rel !== 'state') },
|
||||
false,
|
||||
undefined,
|
||||
defaultPollOptions
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect((error as Error).message).toContain('Job state link was not found.')
|
||||
})
|
||||
@@ -238,7 +238,7 @@ describe('pollJobState', () => {
|
||||
false,
|
||||
undefined,
|
||||
defaultPollOptions
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error.message).toEqual(
|
||||
'Error while polling job state for job j0b: Status Error'
|
||||
@@ -267,13 +267,13 @@ const setupMocks = () => {
|
||||
.mockImplementation(() => Promise.resolve())
|
||||
jest
|
||||
.spyOn(getFileStreamModule, 'getFileStream')
|
||||
.mockImplementation(() => Promise.resolve(({} as unknown) as WriteStream))
|
||||
.mockImplementation(() => Promise.resolve({} as unknown as WriteStream))
|
||||
jest.spyOn(isNodeModule, 'isNode').mockImplementation(() => true)
|
||||
}
|
||||
|
||||
const mockSimplePoll = (runningCount = 2) => {
|
||||
let count = 0
|
||||
jest.spyOn(requestClient, 'get').mockImplementation(url => {
|
||||
jest.spyOn(requestClient, 'get').mockImplementation((url) => {
|
||||
count++
|
||||
if (url.includes('job')) {
|
||||
return Promise.resolve({ result: mockJob, etag: '', status: 200 })
|
||||
@@ -293,7 +293,7 @@ const mockSimplePoll = (runningCount = 2) => {
|
||||
|
||||
const mockRunningPoll = () => {
|
||||
let count = 0
|
||||
jest.spyOn(requestClient, 'get').mockImplementation(url => {
|
||||
jest.spyOn(requestClient, 'get').mockImplementation((url) => {
|
||||
count++
|
||||
if (url.includes('job')) {
|
||||
return Promise.resolve({ result: mockJob, etag: '', status: 200 })
|
||||
@@ -308,7 +308,7 @@ const mockRunningPoll = () => {
|
||||
|
||||
const mockLongPoll = () => {
|
||||
let count = 0
|
||||
jest.spyOn(requestClient, 'get').mockImplementation(url => {
|
||||
jest.spyOn(requestClient, 'get').mockImplementation((url) => {
|
||||
count++
|
||||
if (url.includes('job')) {
|
||||
return Promise.resolve({ result: mockJob, etag: '', status: 200 })
|
||||
@@ -323,7 +323,7 @@ const mockLongPoll = () => {
|
||||
|
||||
const mockPollWithSingleError = () => {
|
||||
let count = 0
|
||||
jest.spyOn(requestClient, 'get').mockImplementation(url => {
|
||||
jest.spyOn(requestClient, 'get').mockImplementation((url) => {
|
||||
count++
|
||||
if (url.includes('job')) {
|
||||
return Promise.resolve({ result: mockJob, etag: '', status: 200 })
|
||||
@@ -340,7 +340,7 @@ const mockPollWithSingleError = () => {
|
||||
}
|
||||
|
||||
const mockErroredPoll = () => {
|
||||
jest.spyOn(requestClient, 'get').mockImplementation(url => {
|
||||
jest.spyOn(requestClient, 'get').mockImplementation((url) => {
|
||||
if (url.includes('job')) {
|
||||
return Promise.resolve({ result: mockJob, etag: '', status: 200 })
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { mockJob } from './mockResponses'
|
||||
import { WriteStream } from '../../../types'
|
||||
|
||||
const requestClient = new (<jest.Mock<RequestClient>>RequestClient)()
|
||||
const stream = ({} as unknown) as WriteStream
|
||||
const stream = {} as unknown as WriteStream
|
||||
|
||||
describe('saveLog', () => {
|
||||
beforeEach(() => {
|
||||
@@ -17,7 +17,7 @@ describe('saveLog', () => {
|
||||
|
||||
it('should throw an error when a valid access token is not provided', async () => {
|
||||
const error = await saveLog(mockJob, requestClient, 0, 100, stream).catch(
|
||||
e => e
|
||||
(e) => e
|
||||
)
|
||||
|
||||
expect(error.message).toContain(
|
||||
@@ -27,13 +27,13 @@ describe('saveLog', () => {
|
||||
|
||||
it('should throw an error when the log URL is not available', async () => {
|
||||
const error = await saveLog(
|
||||
{ ...mockJob, links: mockJob.links.filter(l => l.rel !== 'log') },
|
||||
{ ...mockJob, links: mockJob.links.filter((l) => l.rel !== 'log') },
|
||||
requestClient,
|
||||
0,
|
||||
100,
|
||||
stream,
|
||||
't0k3n'
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error.message).toContain(
|
||||
`Log URL for job ${mockJob.id} was not found.`
|
||||
|
||||
@@ -29,7 +29,9 @@ describe('uploadTables', () => {
|
||||
.spyOn(convertToCsvModule, 'convertToCSV')
|
||||
.mockImplementation(() => 'ERROR: LARGE STRING LENGTH')
|
||||
|
||||
const error = await uploadTables(requestClient, data, 't0k3n').catch(e => e)
|
||||
const error = await uploadTables(requestClient, data, 't0k3n').catch(
|
||||
(e) => e
|
||||
)
|
||||
|
||||
expect(requestClient.uploadFile).not.toHaveBeenCalled()
|
||||
expect(error.message).toEqual(
|
||||
@@ -43,7 +45,9 @@ describe('uploadTables', () => {
|
||||
.spyOn(requestClient, 'uploadFile')
|
||||
.mockImplementation(() => Promise.reject('Upload Error'))
|
||||
|
||||
const error = await uploadTables(requestClient, data, 't0k3n').catch(e => e)
|
||||
const error = await uploadTables(requestClient, data, 't0k3n').catch(
|
||||
(e) => e
|
||||
)
|
||||
|
||||
expect(error).toContain('Error while uploading file.')
|
||||
})
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('writeStream', () => {
|
||||
jest
|
||||
.spyOn(stream, 'write')
|
||||
.mockImplementation((_, callback) => callback(new Error('Test Error')))
|
||||
const error = await writeStream(stream, content).catch(e => e)
|
||||
const error = await writeStream(stream, content).catch((e) => e)
|
||||
|
||||
expect(error.message).toEqual('Test Error')
|
||||
})
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function uploadTables(
|
||||
|
||||
const uploadResponse = await requestClient
|
||||
.uploadFile(`/files/files#rawUpload`, csv, accessToken)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while uploading file. ')
|
||||
})
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ export const writeStream = async (
|
||||
stream: WriteStream,
|
||||
content: string
|
||||
): Promise<void> =>
|
||||
stream.write(content + '\n', e => {
|
||||
stream.write(content + '\n', (e) => {
|
||||
if (e) return Promise.reject(e)
|
||||
|
||||
return Promise.resolve()
|
||||
|
||||
@@ -33,10 +33,8 @@ export class AuthManager {
|
||||
public async redirectedLogIn({
|
||||
onLoggedOut
|
||||
}: LoginOptions): Promise<LoginResult> {
|
||||
const {
|
||||
isLoggedIn: isLoggedInAlready,
|
||||
userName: currentSessionUsername
|
||||
} = await this.fetchUserName()
|
||||
const { isLoggedIn: isLoggedInAlready, userName: currentSessionUsername } =
|
||||
await this.fetchUserName()
|
||||
|
||||
if (isLoggedInAlready) {
|
||||
await this.loginCallback()
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function getAccessTokenForSasjs(
|
||||
|
||||
return await requestClient
|
||||
.post(url, data, undefined)
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
const sasAuth = res.result as {
|
||||
accessToken: string
|
||||
refreshToken: string
|
||||
@@ -30,7 +30,7 @@ export async function getAccessTokenForSasjs(
|
||||
refresh_token: sasAuth.refreshToken
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting access token. ')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ export async function getAccessTokenForViya(
|
||||
|
||||
const authResponse = await requestClient
|
||||
.post(url, data, undefined, 'application/x-www-form-urlencoded', headers)
|
||||
.then(res => res.result as SasAuthResponse)
|
||||
.catch(err => {
|
||||
.then((res) => res.result as SasAuthResponse)
|
||||
.catch((err) => {
|
||||
if (err instanceof CertificateError) throw err
|
||||
throw prefixMessage(err, 'Error while getting access token. ')
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function refreshTokensForSasjs(
|
||||
|
||||
const authResponse = await requestClient
|
||||
.post(url, undefined, undefined, undefined, headers)
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
const sasAuth = res.result as {
|
||||
accessToken: string
|
||||
refreshToken: string
|
||||
@@ -27,7 +27,7 @@ export async function refreshTokensForSasjs(
|
||||
refresh_token: sasAuth.refreshToken
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while refreshing tokens')
|
||||
})
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ export async function refreshTokensForViya(
|
||||
'multipart/form-data; boundary=' + (formData as any)._boundary,
|
||||
headers
|
||||
)
|
||||
.then(res => res.result)
|
||||
.catch(err => {
|
||||
.then((res) => res.result)
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while refreshing tokens')
|
||||
})
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ describe('AuthManager', () => {
|
||||
jest
|
||||
.spyOn(openWebPageModule, 'openWebPage')
|
||||
.mockImplementation(() =>
|
||||
Promise.resolve(({ close: jest.fn() } as unknown) as Window)
|
||||
Promise.resolve({ close: jest.fn() } as unknown as Window)
|
||||
)
|
||||
jest.mock('../verifySasViyaLogin')
|
||||
jest
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('getAccessTokenForSasjs', () => {
|
||||
requestClient,
|
||||
authConfig.client,
|
||||
authConfig.refresh_token
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while getting access token')
|
||||
})
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('getAccessTokenForViya', () => {
|
||||
authConfig.client,
|
||||
authConfig.secret,
|
||||
authConfig.refresh_token
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while getting access token')
|
||||
})
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('getTokens', () => {
|
||||
const expectedError =
|
||||
'Unable to obtain new access token. Your refresh token has expired.'
|
||||
|
||||
const error = await getTokens(requestClient, authConfig).catch(e => e)
|
||||
const error = await getTokens(requestClient, authConfig).catch((e) => e)
|
||||
|
||||
expect(error.message).toEqual(expectedError)
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('openWebPage', () => {
|
||||
describe('window.open is not blocked', () => {
|
||||
const mockedOpen = jest
|
||||
.fn()
|
||||
.mockImplementation(() => (({} as unknown) as Window))
|
||||
.mockImplementation(() => ({} as unknown as Window))
|
||||
const originalOpen = window.open
|
||||
|
||||
beforeAll(() => {
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('refreshTokensForSasjs', () => {
|
||||
const error = await refreshTokensForSasjs(
|
||||
requestClient,
|
||||
refresh_token
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while refreshing tokens')
|
||||
})
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('refreshTokensForViya', () => {
|
||||
authConfig.client,
|
||||
authConfig.secret,
|
||||
authConfig.refresh_token
|
||||
).catch(e => e)
|
||||
).catch((e) => e)
|
||||
|
||||
expect(error).toContain('Error while refreshing tokens')
|
||||
})
|
||||
|
||||
@@ -15,12 +15,12 @@ describe('verifySas9Login', () => {
|
||||
})
|
||||
|
||||
it('should return isLoggedIn true by checking state of popup', async () => {
|
||||
const popup = ({
|
||||
const popup = {
|
||||
window: {
|
||||
location: { href: serverUrl + `/SASLogon/home` },
|
||||
document: { body: { innerText: '<h3>You have signed in.</h3>' } }
|
||||
}
|
||||
} as unknown) as Window
|
||||
} as unknown as Window
|
||||
|
||||
await expect(verifySas9Login(popup)).resolves.toEqual({
|
||||
isLoggedIn: true
|
||||
@@ -28,7 +28,7 @@ describe('verifySas9Login', () => {
|
||||
})
|
||||
|
||||
it('should return isLoggedIn false if user closed popup, already', async () => {
|
||||
const popup: Window = ({ closed: true } as unknown) as Window
|
||||
const popup: Window = { closed: true } as unknown as Window
|
||||
|
||||
await expect(verifySas9Login(popup)).resolves.toEqual({
|
||||
isLoggedIn: false
|
||||
|
||||
@@ -16,12 +16,12 @@ describe('verifySasViyaLogin', () => {
|
||||
})
|
||||
|
||||
it('should return isLoggedIn true by checking state of popup', async () => {
|
||||
const popup = ({
|
||||
const popup = {
|
||||
window: {
|
||||
location: { href: serverUrl + `/SASLogon/home` },
|
||||
document: { body: { innerText: '<h3>You have signed in.</h3>' } }
|
||||
}
|
||||
} as unknown) as Window
|
||||
} as unknown as Window
|
||||
|
||||
await expect(verifySasViyaLogin(popup)).resolves.toEqual({
|
||||
isLoggedIn: true
|
||||
@@ -29,7 +29,7 @@ describe('verifySasViyaLogin', () => {
|
||||
})
|
||||
|
||||
it('should return isLoggedIn false if user closed popup, already', async () => {
|
||||
const popup: Window = ({ closed: true } as unknown) as Window
|
||||
const popup: Window = { closed: true } as unknown as Window
|
||||
|
||||
await expect(verifySasViyaLogin(popup)).resolves.toEqual({
|
||||
isLoggedIn: false
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { delay } from '../utils'
|
||||
|
||||
export async function verifySas9Login(
|
||||
loginPopup: Window
|
||||
): Promise<{
|
||||
export async function verifySas9Login(loginPopup: Window): Promise<{
|
||||
isLoggedIn: boolean
|
||||
}> {
|
||||
let isLoggedIn = false
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { delay } from '../utils'
|
||||
|
||||
export async function verifySasViyaLogin(
|
||||
loginPopup: Window
|
||||
): Promise<{
|
||||
export async function verifySasViyaLogin(loginPopup: Window): Promise<{
|
||||
isLoggedIn: boolean
|
||||
}> {
|
||||
let isLoggedIn = false
|
||||
|
||||
@@ -28,7 +28,7 @@ export const generateTableUploadForm = (
|
||||
const csvChunks = splitChunks(csv)
|
||||
|
||||
// append chunks to form data with same key
|
||||
csvChunks.map(chunk => {
|
||||
csvChunks.map((chunk) => {
|
||||
formData.append(`sasjs${tableCounter}data`, chunk)
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@ export class ComputeJobExecutor extends BaseJobExecutor {
|
||||
waitForResult,
|
||||
expectWebout
|
||||
)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
this.sasViyaApiClient.appendRequest(response, sasJob, config.debug)
|
||||
resolve(response.result)
|
||||
})
|
||||
|
||||
@@ -52,8 +52,9 @@ export class FileUploader extends BaseJobExecutor {
|
||||
const program = config.appLoc
|
||||
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
||||
: sasJob
|
||||
const uploadUrl = `${this.jobsPath}/?${'_program=' +
|
||||
program}${paramsString}`
|
||||
const uploadUrl = `${this.jobsPath}/?${
|
||||
'_program=' + program
|
||||
}${paramsString}`
|
||||
|
||||
const formData = new FormData()
|
||||
|
||||
|
||||
@@ -134,10 +134,8 @@ export class WebJobExecutor extends BaseJobExecutor {
|
||||
} else {
|
||||
// param based approach
|
||||
try {
|
||||
const {
|
||||
formData: newFormData,
|
||||
requestParams: params
|
||||
} = generateTableUploadForm(formData, data)
|
||||
const { formData: newFormData, requestParams: params } =
|
||||
generateTableUploadForm(formData, data)
|
||||
formData = newFormData
|
||||
requestParams = { ...requestParams, ...params }
|
||||
} catch (e) {
|
||||
|
||||
@@ -202,17 +202,17 @@ export class RequestClient implements HttpClient {
|
||||
|
||||
return this.httpClient
|
||||
.get<T>(url, requestConfig)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
|
||||
return this.parseResponse<T>(response)
|
||||
})
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(
|
||||
e,
|
||||
() =>
|
||||
this.get<T>(url, accessToken, contentType, overrideHeaders).catch(
|
||||
err => {
|
||||
(err) => {
|
||||
throw prefixMessage(
|
||||
err,
|
||||
'Error while executing handle error callback. '
|
||||
@@ -243,12 +243,12 @@ export class RequestClient implements HttpClient {
|
||||
withCredentials: true,
|
||||
...additionalSettings
|
||||
})
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
|
||||
return this.parseResponse<T>(response)
|
||||
})
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(e, () =>
|
||||
this.post<T>(url, data, accessToken, contentType, overrideHeaders)
|
||||
)
|
||||
@@ -268,11 +268,11 @@ export class RequestClient implements HttpClient {
|
||||
|
||||
return this.httpClient
|
||||
.put<T>(url, data, { headers, withCredentials: true })
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
})
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(e, () =>
|
||||
this.put<T>(url, data, accessToken, overrideHeaders)
|
||||
)
|
||||
@@ -287,11 +287,11 @@ export class RequestClient implements HttpClient {
|
||||
|
||||
return this.httpClient
|
||||
.delete<T>(url, { headers, withCredentials: true })
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
})
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(e, () => this.delete<T>(url, accessToken))
|
||||
})
|
||||
}
|
||||
@@ -305,11 +305,11 @@ export class RequestClient implements HttpClient {
|
||||
|
||||
return this.httpClient
|
||||
.patch<T>(url, data, { headers, withCredentials: true })
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
})
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(e, () =>
|
||||
this.patch<T>(url, data, accessToken)
|
||||
)
|
||||
@@ -324,15 +324,14 @@ export class RequestClient implements HttpClient {
|
||||
const headers = this.getHeaders(accessToken, 'application/json')
|
||||
|
||||
if (this.fileUploadCsrfToken?.value) {
|
||||
headers[
|
||||
this.fileUploadCsrfToken.headerName
|
||||
] = this.fileUploadCsrfToken.value
|
||||
headers[this.fileUploadCsrfToken.headerName] =
|
||||
this.fileUploadCsrfToken.value
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.httpClient.post(url, content, {
|
||||
headers,
|
||||
transformRequest: requestBody => requestBody
|
||||
transformRequest: (requestBody) => requestBody
|
||||
})
|
||||
|
||||
return {
|
||||
@@ -374,7 +373,7 @@ export class RequestClient implements HttpClient {
|
||||
params[input.name] = input.value
|
||||
}
|
||||
|
||||
const csrfTokenKey = Object.keys(params).find(k =>
|
||||
const csrfTokenKey = Object.keys(params).find((k) =>
|
||||
k?.toLowerCase().includes('csrf')
|
||||
)
|
||||
if (csrfTokenKey) {
|
||||
@@ -399,8 +398,8 @@ export class RequestClient implements HttpClient {
|
||||
responseType: 'text',
|
||||
headers: { Accept: '*/*', 'Content-Type': 'text/plain' }
|
||||
})
|
||||
.then(res => res.data)
|
||||
.catch(error => {
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
const logger = process.logger || console
|
||||
logger.error(error)
|
||||
})
|
||||
@@ -448,9 +447,9 @@ export class RequestClient implements HttpClient {
|
||||
}
|
||||
|
||||
private parseCsrfToken = (response: AxiosResponse): CsrfToken | undefined => {
|
||||
const tokenHeader = (response.headers[
|
||||
'x-csrf-header'
|
||||
] as string)?.toLowerCase()
|
||||
const tokenHeader = (
|
||||
response.headers['x-csrf-header'] as string
|
||||
)?.toLowerCase()
|
||||
|
||||
if (tokenHeader) {
|
||||
const token = response.headers[tokenHeader]
|
||||
@@ -476,12 +475,12 @@ export class RequestClient implements HttpClient {
|
||||
responseType: 'text',
|
||||
headers: { 'Content-Type': 'text/plain', Accept: '*/*' }
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting error confirmUrl. ')
|
||||
})
|
||||
|
||||
if (isAuthorizeFormRequired(res?.data as string)) {
|
||||
await this.authorize(res.data as string).catch(err => {
|
||||
await this.authorize(res.data as string).catch((err) => {
|
||||
throw prefixMessage(err, 'Error while authorizing request. ')
|
||||
})
|
||||
}
|
||||
@@ -506,7 +505,7 @@ export class RequestClient implements HttpClient {
|
||||
.get('/', {
|
||||
withCredentials: true
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while re-fetching CSRF token.')
|
||||
})
|
||||
|
||||
@@ -595,7 +594,7 @@ export class RequestClient implements HttpClient {
|
||||
|
||||
this.httpClient = createAxiosInstance(baseUrl, httpsAgent)
|
||||
|
||||
this.httpClient.defaults.validateStatus = status => {
|
||||
this.httpClient.defaults.validateStatus = (status) => {
|
||||
return status >= 200 && status <= 401
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export class Sas9RequestClient extends RequestClient {
|
||||
constructor(baseUrl: string, httpsAgentOptions?: https.AgentOptions) {
|
||||
super(baseUrl, httpsAgentOptions)
|
||||
this.httpClient.defaults.maxRedirects = 0
|
||||
this.httpClient.defaults.validateStatus = status =>
|
||||
this.httpClient.defaults.validateStatus = (status) =>
|
||||
status >= 200 && status < 303
|
||||
|
||||
if (axiosCookieJarSupport) {
|
||||
@@ -57,7 +57,7 @@ export class Sas9RequestClient extends RequestClient {
|
||||
|
||||
return this.httpClient
|
||||
.get<T>(url, requestConfig)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
if (response.status === 302) {
|
||||
return this.get(
|
||||
response.headers['location'],
|
||||
@@ -68,12 +68,12 @@ export class Sas9RequestClient extends RequestClient {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
})
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(
|
||||
e,
|
||||
() =>
|
||||
this.get<T>(url, accessToken, contentType, overrideHeaders).catch(
|
||||
err => {
|
||||
(err) => {
|
||||
throw prefixMessage(
|
||||
err,
|
||||
'Error while executing handle error callback. '
|
||||
@@ -81,7 +81,7 @@ export class Sas9RequestClient extends RequestClient {
|
||||
}
|
||||
),
|
||||
debug
|
||||
).catch(err => {
|
||||
).catch((err) => {
|
||||
throw prefixMessage(err, 'Error while handling error. ')
|
||||
})
|
||||
})
|
||||
@@ -101,7 +101,7 @@ export class Sas9RequestClient extends RequestClient {
|
||||
|
||||
return this.httpClient
|
||||
.post<T>(url, data, { headers, withCredentials: true })
|
||||
.then(async response => {
|
||||
.then(async (response) => {
|
||||
if (response.status === 302) {
|
||||
return await this.get(
|
||||
response.headers['location'],
|
||||
@@ -113,7 +113,7 @@ export class Sas9RequestClient extends RequestClient {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
})
|
||||
.catch(async e => {
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(e, () =>
|
||||
this.post<T>(url, data, accessToken, contentType, overrideHeaders)
|
||||
)
|
||||
|
||||
@@ -140,7 +140,7 @@ describe('RequestClient', () => {
|
||||
`Error while executing callback in handleError. ${randomError}`
|
||||
)
|
||||
|
||||
error.response.headers = ({} as unknown) as { 'x-csrf-header': string }
|
||||
error.response.headers = {} as unknown as { 'x-csrf-header': string }
|
||||
requestClient['csrfToken'].headerName = ''
|
||||
|
||||
await expect(
|
||||
@@ -262,7 +262,7 @@ const setupSelfSignedServer = async (): Promise<{
|
||||
httpsServer: https.Server
|
||||
keys: pem.CertificateCreationResult
|
||||
}> => {
|
||||
return await new Promise(async resolve => {
|
||||
return await new Promise(async (resolve) => {
|
||||
const keys = await createCertificate()
|
||||
|
||||
const httpsServer = https.createServer(
|
||||
|
||||
@@ -12,11 +12,11 @@ export const mockedAuthResponse = {
|
||||
jti: 'jti'
|
||||
}
|
||||
|
||||
app.get('/', function(req: any, res: any) {
|
||||
app.get('/', function (req: any, res: any) {
|
||||
res.send('Hello World')
|
||||
})
|
||||
|
||||
app.post('/SASLogon/oauth/token', function(req: any, res: any) {
|
||||
app.post('/SASLogon/oauth/token', function (req: any, res: any) {
|
||||
let valid = true
|
||||
|
||||
// capture the encoded form data
|
||||
|
||||
@@ -28,12 +28,12 @@ describe('urlValidator', () => {
|
||||
it('should return false when the URL is null', () => {
|
||||
const url = null
|
||||
|
||||
expect(isUrl((url as unknown) as string)).toEqual(false)
|
||||
expect(isUrl(url as unknown as string)).toEqual(false)
|
||||
})
|
||||
|
||||
it('should return false when the URL is undefined', () => {
|
||||
const url = undefined
|
||||
|
||||
expect(isUrl((url as unknown) as string)).toEqual(false)
|
||||
expect(isUrl(url as unknown as string)).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
export class JobStatePollError extends Error {
|
||||
constructor(id: string, public originalError: Error) {
|
||||
super(
|
||||
`Error while polling job state for job ${id}: ${originalError.message ||
|
||||
originalError}`
|
||||
`Error while polling job state for job ${id}: ${
|
||||
originalError.message || originalError
|
||||
}`
|
||||
)
|
||||
this.name = 'JobStatePollError'
|
||||
Object.setPrototypeOf(this, JobStatePollError.prototype)
|
||||
|
||||
@@ -13,7 +13,7 @@ export class RootFolderNotFoundError extends Error {
|
||||
if (accessToken) {
|
||||
const decodedToken = decodeToken(accessToken)
|
||||
let scope = decodedToken.scope
|
||||
scope = scope.map(element => '* ' + element)
|
||||
scope = scope.map((element) => '* ' + element)
|
||||
message +=
|
||||
`Your access token contains the following scopes:\n` + scope.join('\n')
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ export const convertToCSV = (
|
||||
let invalidString = false
|
||||
|
||||
if (formats) {
|
||||
headers = Object.keys(formats).map(key => `${key}:${formats![key]}`)
|
||||
headers = Object.keys(formats).map((key) => `${key}:${formats![key]}`)
|
||||
}
|
||||
|
||||
const headerFields = Object.keys(table[0])
|
||||
|
||||
headerFields.forEach(field => {
|
||||
headerFields.forEach((field) => {
|
||||
if (!formats || !Object.keys(formats).includes(field)) {
|
||||
let hasNullOrNumber = false
|
||||
let hasSpecialMissingString = false
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export const delay = (ms: number) =>
|
||||
new Promise(resolve => setTimeout(resolve, ms))
|
||||
new Promise((resolve) => setTimeout(resolve, ms))
|
||||
|
||||
@@ -41,13 +41,14 @@ export const fetchLog = async (
|
||||
const loglimit = end < 10000 ? end : 10000
|
||||
do {
|
||||
logger.info(
|
||||
`Fetching logs from line no: ${start + 1} to ${start +
|
||||
loglimit} of ${end}.`
|
||||
`Fetching logs from line no: ${start + 1} to ${
|
||||
start + loglimit
|
||||
} of ${end}.`
|
||||
)
|
||||
const logChunkJson = await requestClient!
|
||||
.get<any>(`${logUrl}?start=${start}&limit=${loglimit}`, accessToken)
|
||||
.then((res: any) => res.result)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
throw prefixMessage(err, 'Error while getting log. ')
|
||||
})
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const classes = {
|
||||
}
|
||||
|
||||
export const openLoginPrompt = (): Promise<boolean> => {
|
||||
return new Promise(async resolve => {
|
||||
return new Promise(async (resolve) => {
|
||||
const style = document.createElement('style')
|
||||
style.id = domIDs.styles
|
||||
style.innerText = cssContent
|
||||
@@ -60,7 +60,7 @@ export const openLoginPrompt = (): Promise<boolean> => {
|
||||
})
|
||||
}
|
||||
const closeLoginPrompt = () => {
|
||||
Object.values(domIDs).forEach(id => {
|
||||
Object.values(domIDs).forEach((id) => {
|
||||
const elem = document.getElementById(id)
|
||||
elem?.parentNode?.removeChild(elem)
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ export const parseSasViyaLog = (logResponse: { items: any[] }) => {
|
||||
let log
|
||||
try {
|
||||
log = logResponse.items
|
||||
? logResponse.items.map(i => i.line).join('\n')
|
||||
? logResponse.items.map((i) => i.line).join('\n')
|
||||
: JSON.stringify(logResponse)
|
||||
} catch (e) {
|
||||
console.error('An error has occurred while parsing the log response', e)
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
export const parseSourceCode = (log: string): string => {
|
||||
const isSourceCodeLine = (line: string) =>
|
||||
line
|
||||
.trim()
|
||||
.substring(0, 10)
|
||||
.trimStart()
|
||||
.match(/^\d/)
|
||||
line.trim().substring(0, 10).trimStart().match(/^\d/)
|
||||
const logLines = log.split('\n').filter(isSourceCodeLine)
|
||||
return logLines.join('\r\n')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user