mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-16 08:30:07 +00:00
chore(git): Merge remote-tracking branch 'origin/master' into cli-issue-1108
This commit is contained in:
23
src/SASjs.ts
23
src/SASjs.ts
@@ -5,9 +5,8 @@ import {
|
|||||||
EditContextInput,
|
EditContextInput,
|
||||||
PollOptions,
|
PollOptions,
|
||||||
LoginMechanism,
|
LoginMechanism,
|
||||||
FolderMember,
|
ExecutionQuery,
|
||||||
ServiceMember,
|
FileTree
|
||||||
ExecutionQuery
|
|
||||||
} from './types'
|
} from './types'
|
||||||
import { SASViyaApiClient } from './SASViyaApiClient'
|
import { SASViyaApiClient } from './SASViyaApiClient'
|
||||||
import { SAS9ApiClient } from './SAS9ApiClient'
|
import { SAS9ApiClient } from './SAS9ApiClient'
|
||||||
@@ -865,8 +864,22 @@ export default class SASjs {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deployToSASjs(members: [FolderMember, ServiceMember]) {
|
/**
|
||||||
return await this.sasJSApiClient?.deploy(members, this.sasjsConfig.appLoc)
|
* Creates the folders and services at the given location `appLoc` on the given server `serverUrl`.
|
||||||
|
* @param members - the JSON specifying the folders and services to be created.
|
||||||
|
* @param appLoc - the base folder in which to create the new folders and
|
||||||
|
* services. If not provided, is taken from SASjsConfig.
|
||||||
|
* @param authConfig - a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
|
||||||
|
*/
|
||||||
|
public async deployToSASjs(
|
||||||
|
members: FileTree,
|
||||||
|
appLoc?: string,
|
||||||
|
authConfig?: AuthConfig
|
||||||
|
) {
|
||||||
|
if (!appLoc) {
|
||||||
|
appLoc = this.sasjsConfig.appLoc
|
||||||
|
}
|
||||||
|
return await this.sasJSApiClient?.deploy(members, appLoc, authConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async executeJobSASjs(query: ExecutionQuery) {
|
public async executeJobSASjs(query: ExecutionQuery) {
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { FolderMember, ServiceMember, ExecutionQuery } from './types'
|
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
||||||
|
import { FileTree, ExecutionQuery } from './types'
|
||||||
import { RequestClient } from './request/RequestClient'
|
import { RequestClient } from './request/RequestClient'
|
||||||
import { getAccessTokenForSasjs } from './auth/getAccessTokenForSasjs'
|
import { getAccessTokenForSasjs } from './auth/getAccessTokenForSasjs'
|
||||||
import { refreshTokensForSasjs } from './auth/refreshTokensForSasjs'
|
import { refreshTokensForSasjs } from './auth/refreshTokensForSasjs'
|
||||||
import { getAuthCodeForSasjs } from './auth/getAuthCodeForSasjs'
|
import { getAuthCodeForSasjs } from './auth/getAuthCodeForSasjs'
|
||||||
import { parseWeboutResponse } from './utils'
|
import { parseWeboutResponse } from './utils'
|
||||||
|
import { getTokens } from './auth/getTokens'
|
||||||
|
|
||||||
export class SASjsApiClient {
|
export class SASjsApiClient {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -15,7 +17,19 @@ export class SASjsApiClient {
|
|||||||
if (serverUrl) this.serverUrl = serverUrl
|
if (serverUrl) this.serverUrl = serverUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deploy(members: [FolderMember, ServiceMember], appLoc: string) {
|
public async deploy(
|
||||||
|
members: FileTree,
|
||||||
|
appLoc: string,
|
||||||
|
authConfig?: AuthConfig
|
||||||
|
) {
|
||||||
|
let access_token = (authConfig || {}).access_token
|
||||||
|
if (authConfig) {
|
||||||
|
;({ access_token } = await getTokens(
|
||||||
|
this.requestClient,
|
||||||
|
authConfig,
|
||||||
|
ServerType.Sasjs
|
||||||
|
))
|
||||||
|
}
|
||||||
const { result } = await this.requestClient.post<{
|
const { result } = await this.requestClient.post<{
|
||||||
status: string
|
status: string
|
||||||
message: string
|
message: string
|
||||||
@@ -23,7 +37,7 @@ export class SASjsApiClient {
|
|||||||
}>(
|
}>(
|
||||||
'SASjsApi/drive/deploy',
|
'SASjsApi/drive/deploy',
|
||||||
{ fileTree: members, appLoc: appLoc },
|
{ fileTree: members, appLoc: appLoc },
|
||||||
undefined
|
access_token
|
||||||
)
|
)
|
||||||
|
|
||||||
return Promise.resolve(result)
|
return Promise.resolve(result)
|
||||||
|
|||||||
Reference in New Issue
Block a user