mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-05 11:40:06 +00:00
Merge branch 'master' into issue-84
This commit is contained in:
@@ -918,22 +918,26 @@ export class SASViyaApiClient {
|
|||||||
const jobName = sasJob.split('/')[1]
|
const jobName = sasJob.split('/')[1]
|
||||||
const jobFolder = this.rootFolderMap.get(folderName)
|
const jobFolder = this.rootFolderMap.get(folderName)
|
||||||
const jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
const jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||||
|
|
||||||
if (!jobToExecute) {
|
if (!jobToExecute) {
|
||||||
throw new Error('Job was not found.')
|
throw new Error('Job was not found.')
|
||||||
}
|
}
|
||||||
|
|
||||||
let code = jobToExecute?.code
|
let code = jobToExecute?.code
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
const jobDefinitionLink = jobToExecute?.links.find(
|
const jobDefinitionLink = jobToExecute?.links.find(
|
||||||
(l) => l.rel === 'getResource'
|
(l) => l.rel === 'getResource'
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!jobDefinitionLink) {
|
if (!jobDefinitionLink) {
|
||||||
console.error('Job definition URI was not found.')
|
console.error('Job definition URI was not found.')
|
||||||
throw new Error('Job definition URI was not found.')
|
throw new Error('Job definition URI was not found.')
|
||||||
}
|
}
|
||||||
|
|
||||||
const { result: jobDefinition } = await this.request<JobDefinition>(
|
const { result: jobDefinition } = await this.request<JobDefinition>(
|
||||||
`${this.serverUrl}${jobDefinitionLink.href}`,
|
`${this.serverUrl}${jobDefinitionLink.href}`,
|
||||||
headers
|
{ headers }
|
||||||
)
|
)
|
||||||
|
|
||||||
code = jobDefinition.code
|
code = jobDefinition.code
|
||||||
@@ -941,6 +945,7 @@ export class SASViyaApiClient {
|
|||||||
// Add code to existing job definition
|
// Add code to existing job definition
|
||||||
jobToExecute.code = code
|
jobToExecute.code = code
|
||||||
}
|
}
|
||||||
|
|
||||||
const linesToExecute = code.replace(/\r\n/g, '\n').split('\n')
|
const linesToExecute = code.replace(/\r\n/g, '\n').split('\n')
|
||||||
return await this.executeScript(
|
return await this.executeScript(
|
||||||
sasJob,
|
sasJob,
|
||||||
@@ -993,6 +998,7 @@ export class SASViyaApiClient {
|
|||||||
const jobName = path.basename(sasJob)
|
const jobName = path.basename(sasJob)
|
||||||
const jobFolder = sasJob.replace(`/${jobName}`, '')
|
const jobFolder = sasJob.replace(`/${jobName}`, '')
|
||||||
const allJobsInFolder = this.rootFolderMap.get(jobFolder.replace('/', ''))
|
const allJobsInFolder = this.rootFolderMap.get(jobFolder.replace('/', ''))
|
||||||
|
|
||||||
if (allJobsInFolder) {
|
if (allJobsInFolder) {
|
||||||
const jobSpec = allJobsInFolder.find((j: Job) => j.name === jobName)
|
const jobSpec = allJobsInFolder.find((j: Job) => j.name === jobName)
|
||||||
const jobDefinitionLink = jobSpec?.links.find(
|
const jobDefinitionLink = jobSpec?.links.find(
|
||||||
@@ -1002,10 +1008,13 @@ export class SASViyaApiClient {
|
|||||||
method: 'GET'
|
method: 'GET'
|
||||||
}
|
}
|
||||||
const headers: any = { 'Content-Type': 'application/json' }
|
const headers: any = { 'Content-Type': 'application/json' }
|
||||||
|
|
||||||
if (!!accessToken) {
|
if (!!accessToken) {
|
||||||
headers.Authorization = `Bearer ${accessToken}`
|
headers.Authorization = `Bearer ${accessToken}`
|
||||||
}
|
}
|
||||||
|
|
||||||
requestInfo.headers = headers
|
requestInfo.headers = headers
|
||||||
|
|
||||||
const { result: jobDefinition } = await this.request<Job>(
|
const { result: jobDefinition } = await this.request<Job>(
|
||||||
`${this.serverUrl}${jobDefinitionLink}`,
|
`${this.serverUrl}${jobDefinitionLink}`,
|
||||||
requestInfo
|
requestInfo
|
||||||
|
|||||||
@@ -728,7 +728,7 @@ export default class SASjs {
|
|||||||
async (resolve, reject) => {
|
async (resolve, reject) => {
|
||||||
const session = await this.checkSession()
|
const session = await this.checkSession()
|
||||||
|
|
||||||
if (!session.isLoggedIn) {
|
if (!session.isLoggedIn && !accessToken) {
|
||||||
if (loginRequiredCallback) loginRequiredCallback(true)
|
if (loginRequiredCallback) loginRequiredCallback(true)
|
||||||
sasjsWaitingRequest.requestPromise.resolve = resolve
|
sasjsWaitingRequest.requestPromise.resolve = resolve
|
||||||
sasjsWaitingRequest.requestPromise.reject = reject
|
sasjsWaitingRequest.requestPromise.reject = reject
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export async function makeRequest<T>(
|
|||||||
? (res: Response) => res.json()
|
? (res: Response) => res.json()
|
||||||
: (res: Response) => res.text()
|
: (res: Response) => res.text()
|
||||||
let etag = null
|
let etag = null
|
||||||
|
|
||||||
const result = await fetch(url, request).then(async (response) => {
|
const result = await fetch(url, request).then(async (response) => {
|
||||||
if (response.redirected && response.url.includes('SASLogon/login')) {
|
if (response.redirected && response.url.includes('SASLogon/login')) {
|
||||||
return Promise.reject({ status: 401 })
|
return Promise.reject({ status: 401 })
|
||||||
|
|||||||
Reference in New Issue
Block a user