Skip to content

Commit

Permalink
Merge pull request #681 from sasjs/sasjs-deploy-with-streaming-app
Browse files Browse the repository at this point in the history
feat(deploy): stream app deployment on SASJS server
  • Loading branch information
allanbowe authored Mar 21, 2022
2 parents 804e78c + 6a6dfc5 commit 256e4ef
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 25 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
"main": "index.js",
"dependencies": {
"@sasjs/utils": "2.36.1",
"@sasjs/utils": "2.40.0",
"axios": "0.26.0",
"axios-cookiejar-support": "1.0.1",
"form-data": "4.0.0",
Expand Down
38 changes: 23 additions & 15 deletions src/SASjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
MacroVar,
AuthConfig,
ExtraResponseAttributes,
SasAuthResponse
SasAuthResponse,
StreamConfig
} from '@sasjs/utils/types'
import { RequestClient } from './request/RequestClient'
import { SasjsRequestClient } from './request/SasjsRequestClient'
Expand Down Expand Up @@ -134,7 +135,7 @@ export default class SASjs {

/**
* Gets compute contexts.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async getComputeContexts(accessToken: string) {
this.isMethodSupported('getComputeContexts', [ServerType.SasViya])
Expand All @@ -144,7 +145,7 @@ export default class SASjs {

/**
* Gets launcher contexts.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async getLauncherContexts(accessToken: string) {
this.isMethodSupported('getLauncherContexts', [ServerType.SasViya])
Expand All @@ -163,7 +164,7 @@ export default class SASjs {

/**
* Gets executable compute contexts.
* @param authConfig - an access token, refresh token, client and secret for an authorized user.
* @param authConfig - an access token, refresh token, client and secret for an authorised user.
*/
public async getExecutableContexts(authConfig: AuthConfig) {
this.isMethodSupported('getExecutableContexts', [ServerType.SasViya])
Expand All @@ -177,16 +178,16 @@ export default class SASjs {
* @param launchContextName - the name of the launcher context used by the compute service.
* @param sharedAccountId - the ID of the account to run the servers for this context as.
* @param autoExecLines - the lines of code to execute during session initialization.
* @param accessToken - an access token for an authorized user.
* @param authorizedUsers - an optional list of authorized user IDs.
* @param accessToken - an access token for an authorised user.
* @param authorisedUsers - an optional list of authorised user IDs.
*/
public async createComputeContext(
contextName: string,
launchContextName: string,
sharedAccountId: string,
autoExecLines: string[],
accessToken: string,
authorizedUsers?: string[]
authorisedUsers?: string[]
) {
this.isMethodSupported('createComputeContext', [ServerType.SasViya])

Expand All @@ -196,7 +197,7 @@ export default class SASjs {
sharedAccountId,
autoExecLines,
accessToken,
authorizedUsers
authorisedUsers
)
}

Expand All @@ -205,7 +206,7 @@ export default class SASjs {
* @param contextName - the name of the context to be created.
* @param description - the description of the context to be created.
* @param launchType - launch type of the context to be created.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async createLauncherContext(
contextName: string,
Expand All @@ -227,7 +228,7 @@ export default class SASjs {
* Updates a compute context on the given server.
* @param contextName - the original name of the context to be deleted.
* @param editedContext - an object with the properties to be updated.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async editComputeContext(
contextName: string,
Expand All @@ -246,7 +247,7 @@ export default class SASjs {
/**
* Deletes a compute context on the given server.
* @param contextName - the name of the context to be deleted.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async deleteComputeContext(contextName: string, accessToken?: string) {
this.isMethodSupported('deleteComputeContext', [ServerType.SasViya])
Expand All @@ -261,7 +262,7 @@ export default class SASjs {
* Returns a JSON representation of a compute context.
* @example: { "createdBy": "admin", "links": [...], "id": "ID", "version": 2, "name": "context1" }
* @param contextName - the name of the context to return.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async getComputeContextByName(
contextName: string,
Expand All @@ -278,7 +279,7 @@ export default class SASjs {
/**
* Returns a JSON representation of a compute context.
* @param contextId - an id of the context to return.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async getComputeContextById(contextId: string, accessToken?: string) {
this.isMethodSupported('getComputeContextById', [ServerType.SasViya])
Expand Down Expand Up @@ -891,17 +892,24 @@ export default class SASjs {
* @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 streamConfig - optional configuration object of StreamConfig for deploying streaming app.
* @param authConfig - a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
*/
public async deployToSASjs(
members: FileTree,
appLoc?: string,
streamConfig?: StreamConfig,
authConfig?: AuthConfig
) {
if (!appLoc) {
appLoc = this.sasjsConfig.appLoc
}
return await this.sasJSApiClient?.deploy(members, appLoc, authConfig)
return await this.sasJSApiClient?.deploy(
members,
appLoc,
streamConfig,
authConfig
)
}

public async executeJobSASjs(query: ExecutionQuery) {
Expand Down Expand Up @@ -972,7 +980,7 @@ export default class SASjs {
/**
* Fetches content of the log file
* @param logUrl - url of the log file.
* @param accessToken - an access token for an authorized user.
* @param accessToken - an access token for an authorised user.
*/
public async fetchLogFileContent(logUrl: string, accessToken?: string) {
return await this.requestClient!.get(logUrl, accessToken).then((res) => {
Expand Down
12 changes: 10 additions & 2 deletions src/SASjsApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthConfig, ServerType } from '@sasjs/utils/types'
import { AuthConfig, ServerType, StreamConfig } from '@sasjs/utils/types'
import { FileTree, ExecutionQuery } from './types'
import { RequestClient } from './request/RequestClient'
import { getAccessTokenForSasjs } from './auth/getAccessTokenForSasjs'
Expand All @@ -20,6 +20,7 @@ export class SASjsApiClient {
public async deploy(
members: FileTree,
appLoc: string,
streamConfig?: StreamConfig,
authConfig?: AuthConfig
) {
let access_token = (authConfig || {}).access_token
Expand All @@ -33,10 +34,17 @@ export class SASjsApiClient {
const { result } = await this.requestClient.post<{
status: string
message: string
streamServiceName?: string
example?: {}
}>(
'SASjsApi/drive/deploy',
{ fileTree: members, appLoc: appLoc },
{
fileTree: members,
appLoc: appLoc,
streamServiceName: streamConfig?.streamServiceName,
streamWebFolder: streamConfig?.streamWebFolder,
streamLogo: streamConfig?.streamLogo
},
access_token,
undefined,
{},
Expand Down

1 comment on commit 256e4ef

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

Total coverage

Status Category Percentage Covered / Total
🟡 Statements 60.02% 1761/2934
🔴 Branches 40.71% 618/1518
🔴 Functions 46.98% 249/530
🟡 Lines 68.71% 2808/4087

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Report generated by 🧪jest coverage report action from 256e4ef

Please sign in to comment.