import "isomorphic-fetch"; import { SASjsConfig, SASjsRequest } from "./types"; import { SASViyaApiClient } from "./SASViyaApiClient"; /** * SASjs is a JavaScript adapter for SAS. * */ export default class SASjs { private sasjsConfig; private jobsPath; private logoutUrl; private loginUrl; private _csrf; private retryCount; private sasjsRequests; private sasjsWaitingRequests; private userName; private sasViyaApiClient; private sas9ApiClient; constructor(config?: any); executeScriptSAS9(linesOfCode: string[], serverName: string, repositoryName: string): Promise; getAllContexts(accessToken: string): Promise<{ createdBy: any; id: any; name: any; version: any; attributes: {}; }[]>; getExecutableContexts(accessToken: string): Promise; createSession(contextName: string, accessToken: string): Promise; executeScriptSASViya(fileName: string, linesOfCode: string[], contextName: string, accessToken?: string, sessionId?: string, silent?: boolean): Promise<{ jobStatus: unknown; log: unknown; } | undefined>; createFolder(folderName: string, parentFolderPath: string, parentFolderUri?: string, accessToken?: string, sasApiClient?: SASViyaApiClient): Promise; createJobDefinition(jobName: string, code: string, parentFolderPath?: string, parentFolderUri?: string, accessToken?: string, sasApiClient?: SASViyaApiClient): Promise; getAuthCode(clientId: string): Promise; getAccessToken(clientId: string, clientSecret: string, authCode: string): Promise; refreshTokens(clientId: string, clientSecret: string, refreshToken: string): Promise; deleteClient(clientId: string, accessToken: string): Promise; /** * Returns the current SASjs configuration. * */ getSasjsConfig(): SASjsConfig; /** * Returns the username of the user currently logged in. * */ getUserName(): string; /** * Returns the _csrf token of the current session. * */ getCsrf(): string | null; /** * Sets the SASjs configuration. * @param config - SASjsConfig indicating SASjs Configuration */ setSASjsConfig(config: SASjsConfig): Promise; /** * Sets the debug state. Turning this on will enable additional logging to * be returned to the adapter. * @param value - Boolean indicating debug state */ setDebugState(value: boolean): void; /** * Checks whether a session is active, or login is required * @returns a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName` */ checkSession(): Promise<{ isLoggedIn: boolean; userName: string; }>; /** * Logs into the SAS server with the supplied credentials * @param username - a string representing the username * @param password - a string representing the password */ logIn(username: string, password: string): Promise<{ isLoggedIn: boolean; userName: string; }>; /** * Logs out of the configured SAS server */ logOut(): Promise; /** * 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. * * @param sasJob - 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`. * @param data - A JSON object containing one or more tables to be sent to * SAS. Can be `null` if no inputs required. * @param params - Provide any changes to the config here, for instance to * enable / disable `debug`. * @param loginRequiredCallback - 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. */ request(sasJob: string, data: any, params?: any, loginRequiredCallback?: any, accessToken?: string): Promise; /** * Creates the folders and services in the provided JSON on the given location * (appLoc) on the given server (serverUrl). * @param serviceJson - 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 serverUrl - the server on which to deploy the folders and services. * If not provided, is taken from SASjsConfig. * @param accessToken - an optional access token to be passed in when * using this function from the command line. */ deployServicePack(serviceJson: any, appLoc?: string, serverUrl?: string, accessToken?: string): Promise; private resendWaitingRequests; private getRequestParams; private updateUsername; private parseSASVIYADebugResponse; private getJobUri; private parseSAS9Response; private parseSAS9ErrorResponse; private parseLogFromResponse; private fetchLogFileContent; private appendSasjsRequest; private parseSasWork; getSasRequests(): SASjsRequest[]; private setupConfiguration; private setLoginUrl; private getLoginForm; private createFoldersAndServices; }