@sasjs/adapter
Version:
JavaScript adapter for SAS
66 lines (65 loc) • 2.96 kB
TypeScript
import { AuthConfig, ServicePackSASjs } from '@sasjs/utils/types';
import { ExecutionQuery } from './types';
import { RequestClient } from './request/RequestClient';
export interface SASjsAuthResponse {
access_token: string;
refresh_token: string;
}
export interface ScriptExecutionResult {
log: string;
webout?: string;
printOutput?: string;
}
export declare class SASjsApiClient {
private requestClient;
constructor(requestClient: RequestClient);
private getAccessTokenForRequest;
/**
* Creates the folders and services at the given location `appLoc` on the given server `serverUrl`.
* @param dataJson - the JSON specifying the folders and files to be created, can also includes
* appLoc, streamServiceName, streamWebFolder, streamLogo
* @param appLoc - the base folder in which to create the new folders and services.
* @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
*/
deploy(dataJson: ServicePackSASjs, appLoc: string, authConfig?: AuthConfig): Promise<{
status: string;
message: string;
streamServiceName?: string | undefined;
example?: {} | undefined;
}>;
/**
* Creates/updates files within SASjs drive using uploaded json compressed file.
* @param zipFilePath - Compressed file path; file should only contain one JSON file and
* should have same name as of compressed file e.g. deploy.JSON should be compressed to deploy.JSON.zip
* Any other file or JSON file in zipped will be ignored!
* @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
*/
deployZipFile(zipFilePath: string, authConfig?: AuthConfig): Promise<{
status: string;
message: string;
streamServiceName?: string | undefined;
example?: {} | undefined;
}>;
executeJob(query: ExecutionQuery, appLoc: string, authConfig?: AuthConfig): Promise<{
result: any;
log: any;
}>;
/**
* Executes code on a SASJS server.
* @param code - a string of code to execute.
* @param runTime - a string to representing runTime for code execution
* @param authConfig - an object for authentication.
*/
executeScript(code: string, runTime?: string, authConfig?: AuthConfig): Promise<ScriptExecutionResult>;
/**
* Exchanges the auth code for an access token for the given client.
* @param clientId - the client ID to authenticate with.
* @param authCode - the auth code received from the server.
*/
getAccessToken(clientId: string, authCode: string): Promise<SASjsAuthResponse>;
/**
* Exchanges the refresh token for an access token.
* @param refreshToken - the refresh token received from the server.
*/
refreshTokens(refreshToken: string): Promise<SASjsAuthResponse>;
}