mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 12:30:06 +00:00
feat(job-execution): support absolute job paths for JES and web approaches
This commit is contained in:
@@ -47,12 +47,15 @@ export class SASViyaApiClient {
|
|||||||
* Returns a list of jobs in the currently set root folder.
|
* Returns a list of jobs in the currently set root folder.
|
||||||
*/
|
*/
|
||||||
public async getJobsInFolder(folderPath: string) {
|
public async getJobsInFolder(folderPath: string) {
|
||||||
if (this.folderMap.get(folderPath)) {
|
const path = isRelativePath(folderPath)
|
||||||
return this.folderMap.get(folderPath)
|
? `${this.rootFolderName}/${folderPath}`
|
||||||
|
: folderPath
|
||||||
|
if (this.folderMap.get(path)) {
|
||||||
|
return this.folderMap.get(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.populateFolderMap(folderPath)
|
await this.populateFolderMap(path)
|
||||||
return this.folderMap.get(folderPath)
|
return this.folderMap.get(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1136,11 +1139,14 @@ export class SASViyaApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async populateFolderMap(folderPath: string, accessToken?: string) {
|
private async populateFolderMap(folderPath: string, accessToken?: string) {
|
||||||
if (this.folderMap.get(folderPath)) {
|
const path = isRelativePath(folderPath)
|
||||||
|
? `${this.rootFolderName}/${folderPath}`
|
||||||
|
: folderPath
|
||||||
|
if (this.folderMap.get(path)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = '/folders/folders/@item?path=' + folderPath
|
const url = '/folders/folders/@item?path=' + path
|
||||||
const requestInfo: any = {
|
const requestInfo: any = {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
}
|
}
|
||||||
@@ -1152,9 +1158,7 @@ export class SASViyaApiClient {
|
|||||||
requestInfo
|
requestInfo
|
||||||
)
|
)
|
||||||
if (!folder) {
|
if (!folder) {
|
||||||
throw new Error(
|
throw new Error(`The path ${path} does not exist on ${this.serverUrl}`)
|
||||||
`The path ${folderPath} does not exist on ${this.serverUrl}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
const { result: members } = await this.request<{ items: any[] }>(
|
const { result: members } = await this.request<{ items: any[] }>(
|
||||||
`${this.serverUrl}/folders/folders/${folder.id}/members`,
|
`${this.serverUrl}/folders/folders/${folder.id}/members`,
|
||||||
@@ -1162,7 +1166,7 @@ export class SASViyaApiClient {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const itemsAtRoot = members.items
|
const itemsAtRoot = members.items
|
||||||
this.folderMap.set(folderPath, itemsAtRoot)
|
this.folderMap.set(path, itemsAtRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async pollJobState(
|
private async pollJobState(
|
||||||
|
|||||||
22
src/SASjs.ts
22
src/SASjs.ts
@@ -21,7 +21,8 @@ import {
|
|||||||
parseGeneratedCode,
|
parseGeneratedCode,
|
||||||
parseWeboutResponse,
|
parseWeboutResponse,
|
||||||
needsRetry,
|
needsRetry,
|
||||||
asyncForEach
|
asyncForEach,
|
||||||
|
isRelativePath
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import {
|
import {
|
||||||
SASjsConfig,
|
SASjsConfig,
|
||||||
@@ -791,7 +792,9 @@ export default class SASjs {
|
|||||||
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
||||||
: sasJob
|
: sasJob
|
||||||
const jobUri =
|
const jobUri =
|
||||||
config.serverType === 'SASVIYA' ? await this.getJobUri(sasJob) : ''
|
config.serverType === ServerType.SASViya
|
||||||
|
? await this.getJobUri(sasJob)
|
||||||
|
: ''
|
||||||
const apiUrl = `${config.serverUrl}${this.jobsPath}/?${
|
const apiUrl = `${config.serverUrl}${this.jobsPath}/?${
|
||||||
jobUri.length > 0
|
jobUri.length > 0
|
||||||
? '__program=' + program + '&_job=' + jobUri
|
? '__program=' + program + '&_job=' + jobUri
|
||||||
@@ -1063,10 +1066,18 @@ export default class SASjs {
|
|||||||
if (!this.sasViyaApiClient) return ''
|
if (!this.sasViyaApiClient) return ''
|
||||||
let uri = ''
|
let uri = ''
|
||||||
|
|
||||||
const jobKey = sasJob.split('/')[0]
|
let folderPath
|
||||||
const jobName = sasJob.split('/')[1]
|
let jobName: string
|
||||||
|
if (isRelativePath(sasJob)) {
|
||||||
|
folderPath = sasJob.split('/')[0]
|
||||||
|
jobName = sasJob.split('/')[1]
|
||||||
|
} else {
|
||||||
|
const folderPathParts = sasJob.split('/')
|
||||||
|
jobName = folderPathParts.pop() || ''
|
||||||
|
folderPath = folderPathParts.join('/')
|
||||||
|
}
|
||||||
|
|
||||||
const locJobs = await this.sasViyaApiClient.getJobsInFolder(jobKey)
|
const locJobs = await this.sasViyaApiClient.getJobsInFolder(folderPath)
|
||||||
if (locJobs) {
|
if (locJobs) {
|
||||||
const job = locJobs.find(
|
const job = locJobs.find(
|
||||||
(el: any) => el.name === jobName && el.contentType === 'jobDefinition'
|
(el: any) => el.name === jobName && el.contentType === 'jobDefinition'
|
||||||
@@ -1075,6 +1086,7 @@ export default class SASjs {
|
|||||||
uri = job.uri
|
uri = job.uri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('URI', uri)
|
||||||
return uri
|
return uri
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user