1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-03 10:40:06 +00:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Allan Bowe
e0badae973 fix: bumping semantic release package 2023-01-26 13:51:22 +00:00
Allan Bowe
524c561390 Merge pull request #775 from sasjs/import-node-env
fix: createReadStream import where needed
2023-01-26 13:46:39 +00:00
e7ceac1b78 fix: createReadStream import where needed
It's node specific util and othervise adapter was failing on browser environment
2023-01-09 13:07:51 +01:00
Allan Bowe
72ddd424a5 Merge pull request #772 from sasjs/add-deployZipFile
feat: add a new method deployZipFile in sasjsAPiClient class
2022-12-06 11:25:48 +00:00
85f771d1ed feat: add a new method deployZipFile in sasjsAPiClient class 2022-12-06 14:51:34 +05:00
Allan Bowe
1a781c3a56 chore: adding matrix room link in action 2022-10-24 21:25:52 +00:00
4 changed files with 59 additions and 27 deletions

View File

@@ -34,10 +34,10 @@ jobs:
run: npm run build
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- 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
View File

@@ -8,7 +8,7 @@
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
"@sasjs/utils": "2.48.2",
"@sasjs/utils": "2.52.0",
"axios": "0.26.0",
"axios-cookiejar-support": "1.0.1",
"form-data": "4.0.0",
@@ -1575,9 +1575,9 @@
}
},
"node_modules/@sasjs/utils": {
"version": "2.48.2",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.48.2.tgz",
"integrity": "sha512-FdKtHw7uVNChDB6Ym3LqqMo7sR2vBc40M68LrS/ud1PpFJrXbJjNO8qL4MXAUo+2Gt0ZRZIjDvSEEv5smebUnA==",
"version": "2.52.0",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.52.0.tgz",
"integrity": "sha512-UbmYCdfCvjRpmoKRnbmKEcE2YZJh9zHjjGyuZ5BIDxThDtOsGZUOiZrW1J7WcrzjAwQiRBzYoV7xF5MiZqtgiQ==",
"hasInstallScript": true,
"dependencies": {
"@types/fs-extra": "9.0.13",
@@ -16627,9 +16627,9 @@
}
},
"@sasjs/utils": {
"version": "2.48.2",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.48.2.tgz",
"integrity": "sha512-FdKtHw7uVNChDB6Ym3LqqMo7sR2vBc40M68LrS/ud1PpFJrXbJjNO8qL4MXAUo+2Gt0ZRZIjDvSEEv5smebUnA==",
"version": "2.52.0",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.52.0.tgz",
"integrity": "sha512-UbmYCdfCvjRpmoKRnbmKEcE2YZJh9zHjjGyuZ5BIDxThDtOsGZUOiZrW1J7WcrzjAwQiRBzYoV7xF5MiZqtgiQ==",
"requires": {
"@types/fs-extra": "9.0.13",
"@types/prompts": "2.0.13",

View File

@@ -79,7 +79,7 @@
},
"main": "index.js",
"dependencies": {
"@sasjs/utils": "2.48.2",
"@sasjs/utils": "2.52.0",
"axios": "0.26.0",
"axios-cookiejar-support": "1.0.1",
"form-data": "4.0.0",

View File

@@ -1,3 +1,4 @@
import * as NodeFormData from 'form-data'
import { AuthConfig, ServerType, ServicePackSASjs } from '@sasjs/utils/types'
import { ExecutionQuery } from './types'
import { RequestClient } from './request/RequestClient'
@@ -8,6 +9,18 @@ import { getTokens } from './auth/getTokens'
export class SASjsApiClient {
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`.
* @param dataJson - the JSON specifying the folders and files to be created, can also includes
@@ -20,15 +33,7 @@ export class SASjsApiClient {
appLoc: string,
authConfig?: AuthConfig
) {
let access_token = (authConfig || {}).access_token
if (authConfig) {
;({ access_token } = await getTokens(
this.requestClient,
authConfig,
ServerType.Sasjs
))
}
const access_token = await this.getAccessTokenForRequest(authConfig)
dataJson.appLoc = dataJson.appLoc || appLoc
const { result } = await this.requestClient.post<{
@@ -48,6 +53,40 @@ export class SASjsApiClient {
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(
query: ExecutionQuery,
appLoc: string,
@@ -80,14 +119,7 @@ export class SASjsApiClient {
runTime: string = 'sas',
authConfig?: AuthConfig
) {
let access_token = (authConfig || {}).access_token
if (authConfig) {
;({ access_token } = await getTokens(
this.requestClient,
authConfig,
ServerType.Sasjs
))
}
const access_token = await this.getAccessTokenForRequest(authConfig)
let parsedSasjsServerLog = ''