Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SASjs

SASjs is a JavaScript adapter for SAS.

Hierarchy

  • SASjs

Constructors

constructor

  • new SASjs(config?: any): SASjs
  • Parameters

    • Optional config: any

    Returns SASjs

Methods

checkSession

  • checkSession(): Promise<object>
  • Checks whether a session is active, or login is required

    Returns Promise<object>

    a promise which resolves with an object containing two values - a boolean isLoggedIn, and a string userName

createFolder

  • createFolder(folderName: string, parentFolderPath: string, parentFolderUri?: undefined | string, accessToken?: undefined | string, sasApiClient?: SASViyaApiClient): Promise<Folder>
  • Parameters

    • folderName: string
    • parentFolderPath: string
    • Optional parentFolderUri: undefined | string
    • Optional accessToken: undefined | string
    • Optional sasApiClient: SASViyaApiClient

    Returns Promise<Folder>

createJobDefinition

  • createJobDefinition(jobName: string, code: string, parentFolderPath?: undefined | string, parentFolderUri?: undefined | string, accessToken?: undefined | string, sasApiClient?: SASViyaApiClient): Promise<object>
  • Parameters

    • jobName: string
    • code: string
    • Optional parentFolderPath: undefined | string
    • Optional parentFolderUri: undefined | string
    • Optional accessToken: undefined | string
    • Optional sasApiClient: SASViyaApiClient

    Returns Promise<object>

createSession

  • createSession(contextName: string, accessToken: string): Promise<Session>
  • Parameters

    • contextName: string
    • accessToken: string

    Returns Promise<Session>

deleteClient

  • deleteClient(clientId: string, accessToken: string): Promise<object>
  • Parameters

    • clientId: string
    • accessToken: string

    Returns Promise<object>

deployServicePack

  • deployServicePack(serviceJson: any, appLoc?: undefined | string, serverUrl?: undefined | string, accessToken?: undefined | string): Promise<void>
  • Creates the folders and services in the provided JSON on the given location (appLoc) on the given server (serverUrl).

    Parameters

    • serviceJson: any

      the JSON specifying the folders and services to be created.

    • Optional appLoc: undefined | string

      the base folder in which to create the new folders and services. If not provided, is taken from SASjsConfig.

    • Optional serverUrl: undefined | string

      the server on which to deploy the folders and services. If not provided, is taken from SASjsConfig.

    • Optional accessToken: undefined | string

      an optional access token to be passed in when using this function from the command line.

    Returns Promise<void>

executeScriptSAS9

  • executeScriptSAS9(linesOfCode: string[], serverName: string, repositoryName: string): Promise<undefined | string>
  • Parameters

    • linesOfCode: string[]
    • serverName: string
    • repositoryName: string

    Returns Promise<undefined | string>

executeScriptSASViya

  • executeScriptSASViya(fileName: string, linesOfCode: string[], contextName: string, accessToken?: undefined | string, sessionId?: string, silent?: boolean): Promise<object>
  • Parameters

    • fileName: string
    • linesOfCode: string[]
    • contextName: string
    • Optional accessToken: undefined | string
    • Default value sessionId: string = ""
    • Default value silent: boolean = false

    Returns Promise<object>

getAccessToken

  • getAccessToken(clientId: string, clientSecret: string, authCode: string): Promise<any>
  • Parameters

    • clientId: string
    • clientSecret: string
    • authCode: string

    Returns Promise<any>

getAllContexts

  • getAllContexts(accessToken: string): Promise<object[]>
  • Parameters

    • accessToken: string

    Returns Promise<object[]>

getAuthCode

  • getAuthCode(clientId: string): Promise<null | string>
  • Parameters

    • clientId: string

    Returns Promise<null | string>

getCsrfApi

  • getCsrfApi(): undefined | string
  • Returns the _csrf token of the current session for the API approach

    Returns undefined | string

getCsrfWeb

  • getCsrfWeb(): undefined | string
  • Returns the _csrf token of the current session for the WEB approach.

    Returns undefined | string

getExecutableContexts

  • getExecutableContexts(accessToken: string): Promise<any[]>
  • Parameters

    • accessToken: string

    Returns Promise<any[]>

getSasRequests

getSasjsConfig

  • Returns the current SASjs configuration.

    Returns SASjsConfig

getUserName

  • getUserName(): string
  • Returns the username of the user currently logged in.

    Returns string

logIn

  • logIn(username: string, password: string): Promise<object>
  • Logs into the SAS server with the supplied credentials

    Parameters

    • username: string

      a string representing the username

    • password: string

      a string representing the password

    Returns Promise<object>

logOut

  • logOut(): Promise<unknown>
  • Logs out of the configured SAS server

    Returns Promise<unknown>

refreshTokens

  • refreshTokens(clientId: string, clientSecret: string, refreshToken: string): Promise<any>
  • Parameters

    • clientId: string
    • clientSecret: string
    • refreshToken: string

    Returns Promise<any>

request

  • request(sasJob: string, data: any, config?: any, loginRequiredCallback?: any, accessToken?: undefined | string): Promise<any>
  • Makes a request to the SAS Service specified in SASjob. The response object will always contain table names in lowercase, and column names in uppercase. Values are returned formatted by default, unformatted values can be configured as an option in the %webout macro.

    Parameters

    • sasJob: string

      The path to the SAS program (ultimately resolves to the SAS _program parameter to run a Job Definition or SAS 9 Stored Process.) Is prepended at runtime with the value of appLoc.

    • data: any

      A JSON object containing one or more tables to be sent to SAS. Can be null if no inputs required.

    • Default value config: any = {}

      Provide any changes to the config here, for instance to enable / disable debug. Any change provided will override the global config, for that particular function call.

    • Optional loginRequiredCallback: any

      provide a function here to be called if the user is not logged in (eg to display a login form). The request will be resubmitted after logon.

    • Optional accessToken: undefined | string

    Returns Promise<any>

setDebugState

  • setDebugState(value: boolean): void
  • Sets the debug state. Turning this on will enable additional logging to be returned to the adapter.

    Parameters

    • value: boolean

      Boolean indicating debug state

    Returns void

setSASjsConfig

  • Sets the SASjs configuration.

    Parameters

    • config: SASjsConfig

      SASjsConfig indicating SASjs Configuration

    Returns Promise<void>

uploadFile

  • uploadFile(sasJob: string, files: UploadFile[], params: any): Promise<unknown>
  • Uploads a file to the given service

    Parameters

    • sasJob: string

      The path to the SAS program (ultimately resolves to the SAS _program parameter to run a Job Definition or SAS 9 Stored Process.) Is prepended at runtime with the value of appLoc.

    • files: UploadFile[]
    • params: any

      Request URL paramaters

    Returns Promise<unknown>

Generated using TypeDoc