mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-05 03:30:05 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0badae973 | ||
|
|
524c561390 | ||
| e7ceac1b78 | |||
|
|
72ddd424a5 | ||
| 85f771d1ed | |||
|
|
1a781c3a56 |
4
.github/workflows/npmpublish.yml
vendored
4
.github/workflows/npmpublish.yml
vendored
@@ -34,10 +34,10 @@ jobs:
|
|||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Semantic Release
|
- name: Semantic Release
|
||||||
uses: cycjimmy/semantic-release-action@v2
|
uses: cycjimmy/semantic-release-action@v3
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
- name: Send Matrix message
|
- name: Send Matrix message
|
||||||
run: curl -XPOST -d "{\"msgtype\":\"m.text\", \"body\":\"New version of @sasjs/adapter has been released! \n Please deploy and run 'dctests' with new adapter to make sure everything is still in place.\"}" https://matrix.4gl.io/_matrix/client/r0/rooms/!BDUPBPEGVvRLKLQUxY:4gl.io/send/m.room.message?access_token=${{ secrets.MATRIX_TOKEN }}
|
run: curl -XPOST -d "{\"msgtype\":\"m.text\", \"body\":\"New version of @sasjs/adapter has been released! \n Please deploy and run 'dctests' with new adapter to make sure everything is still in place.\"}" https://matrix.4gl.io/_matrix/client/r0/rooms/!jRebyiGmHZlpfDwYXN:4gl.io/send/m.room.message?access_token=${{ secrets.MATRIX_TOKEN }}
|
||||||
|
|||||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -8,7 +8,7 @@
|
|||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sasjs/utils": "2.48.2",
|
"@sasjs/utils": "2.52.0",
|
||||||
"axios": "0.26.0",
|
"axios": "0.26.0",
|
||||||
"axios-cookiejar-support": "1.0.1",
|
"axios-cookiejar-support": "1.0.1",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
@@ -1575,9 +1575,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@sasjs/utils": {
|
"node_modules/@sasjs/utils": {
|
||||||
"version": "2.48.2",
|
"version": "2.52.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.48.2.tgz",
|
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.52.0.tgz",
|
||||||
"integrity": "sha512-FdKtHw7uVNChDB6Ym3LqqMo7sR2vBc40M68LrS/ud1PpFJrXbJjNO8qL4MXAUo+2Gt0ZRZIjDvSEEv5smebUnA==",
|
"integrity": "sha512-UbmYCdfCvjRpmoKRnbmKEcE2YZJh9zHjjGyuZ5BIDxThDtOsGZUOiZrW1J7WcrzjAwQiRBzYoV7xF5MiZqtgiQ==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/fs-extra": "9.0.13",
|
"@types/fs-extra": "9.0.13",
|
||||||
@@ -16627,9 +16627,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@sasjs/utils": {
|
"@sasjs/utils": {
|
||||||
"version": "2.48.2",
|
"version": "2.52.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.48.2.tgz",
|
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.52.0.tgz",
|
||||||
"integrity": "sha512-FdKtHw7uVNChDB6Ym3LqqMo7sR2vBc40M68LrS/ud1PpFJrXbJjNO8qL4MXAUo+2Gt0ZRZIjDvSEEv5smebUnA==",
|
"integrity": "sha512-UbmYCdfCvjRpmoKRnbmKEcE2YZJh9zHjjGyuZ5BIDxThDtOsGZUOiZrW1J7WcrzjAwQiRBzYoV7xF5MiZqtgiQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/fs-extra": "9.0.13",
|
"@types/fs-extra": "9.0.13",
|
||||||
"@types/prompts": "2.0.13",
|
"@types/prompts": "2.0.13",
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sasjs/utils": "2.48.2",
|
"@sasjs/utils": "2.52.0",
|
||||||
"axios": "0.26.0",
|
"axios": "0.26.0",
|
||||||
"axios-cookiejar-support": "1.0.1",
|
"axios-cookiejar-support": "1.0.1",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import * as NodeFormData from 'form-data'
|
||||||
import { AuthConfig, ServerType, ServicePackSASjs } from '@sasjs/utils/types'
|
import { AuthConfig, ServerType, ServicePackSASjs } from '@sasjs/utils/types'
|
||||||
import { ExecutionQuery } from './types'
|
import { ExecutionQuery } from './types'
|
||||||
import { RequestClient } from './request/RequestClient'
|
import { RequestClient } from './request/RequestClient'
|
||||||
@@ -8,6 +9,18 @@ import { getTokens } from './auth/getTokens'
|
|||||||
export class SASjsApiClient {
|
export class SASjsApiClient {
|
||||||
constructor(private requestClient: RequestClient) {}
|
constructor(private requestClient: RequestClient) {}
|
||||||
|
|
||||||
|
private async getAccessTokenForRequest(authConfig?: AuthConfig) {
|
||||||
|
if (authConfig) {
|
||||||
|
const { access_token } = await getTokens(
|
||||||
|
this.requestClient,
|
||||||
|
authConfig,
|
||||||
|
ServerType.Sasjs
|
||||||
|
)
|
||||||
|
|
||||||
|
return access_token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the folders and services at the given location `appLoc` on the given server `serverUrl`.
|
* 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
|
* @param dataJson - the JSON specifying the folders and files to be created, can also includes
|
||||||
@@ -20,15 +33,7 @@ export class SASjsApiClient {
|
|||||||
appLoc: string,
|
appLoc: string,
|
||||||
authConfig?: AuthConfig
|
authConfig?: AuthConfig
|
||||||
) {
|
) {
|
||||||
let access_token = (authConfig || {}).access_token
|
const access_token = await this.getAccessTokenForRequest(authConfig)
|
||||||
if (authConfig) {
|
|
||||||
;({ access_token } = await getTokens(
|
|
||||||
this.requestClient,
|
|
||||||
authConfig,
|
|
||||||
ServerType.Sasjs
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
dataJson.appLoc = dataJson.appLoc || appLoc
|
dataJson.appLoc = dataJson.appLoc || appLoc
|
||||||
|
|
||||||
const { result } = await this.requestClient.post<{
|
const { result } = await this.requestClient.post<{
|
||||||
@@ -48,6 +53,40 @@ export class SASjsApiClient {
|
|||||||
return Promise.resolve(result)
|
return Promise.resolve(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public async deployZipFile(zipFilePath: string, authConfig?: AuthConfig) {
|
||||||
|
const { createReadStream } = require('@sasjs/utils/file')
|
||||||
|
const access_token = await this.getAccessTokenForRequest(authConfig)
|
||||||
|
|
||||||
|
const file = await createReadStream(zipFilePath)
|
||||||
|
const formData = new NodeFormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
|
||||||
|
const contentType = `multipart/form-data; boundary=${formData.getBoundary()}`
|
||||||
|
|
||||||
|
const { result } = await this.requestClient.post<{
|
||||||
|
status: string
|
||||||
|
message: string
|
||||||
|
streamServiceName?: string
|
||||||
|
example?: {}
|
||||||
|
}>(
|
||||||
|
'SASjsApi/drive/deploy/upload',
|
||||||
|
formData,
|
||||||
|
access_token,
|
||||||
|
contentType,
|
||||||
|
{},
|
||||||
|
{ maxContentLength: Infinity, maxBodyLength: Infinity }
|
||||||
|
)
|
||||||
|
|
||||||
|
return Promise.resolve(result)
|
||||||
|
}
|
||||||
|
|
||||||
public async executeJob(
|
public async executeJob(
|
||||||
query: ExecutionQuery,
|
query: ExecutionQuery,
|
||||||
appLoc: string,
|
appLoc: string,
|
||||||
@@ -80,14 +119,7 @@ export class SASjsApiClient {
|
|||||||
runTime: string = 'sas',
|
runTime: string = 'sas',
|
||||||
authConfig?: AuthConfig
|
authConfig?: AuthConfig
|
||||||
) {
|
) {
|
||||||
let access_token = (authConfig || {}).access_token
|
const access_token = await this.getAccessTokenForRequest(authConfig)
|
||||||
if (authConfig) {
|
|
||||||
;({ access_token } = await getTokens(
|
|
||||||
this.requestClient,
|
|
||||||
authConfig,
|
|
||||||
ServerType.Sasjs
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
let parsedSasjsServerLog = ''
|
let parsedSasjsServerLog = ''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user