mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-03 10:40:06 +00:00
Compare commits
15 Commits
v3.9.1
...
snyk-upgra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59195e6379 | ||
|
|
72ed5e3fab | ||
|
|
6bfd7024ce | ||
| fdc3e1cce8 | |||
| fc47222830 | |||
|
|
0a5de21386 | ||
|
|
1cbe57d512 | ||
| 936e4f8c0a | |||
|
|
4ebf949912 | ||
| c00c8007e5 | |||
|
|
3a820c56a9 | ||
| 54516665bf | |||
| ecec2e77c0 | |||
| 9bf3885868 | |||
| caa5aa47dc |
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.42.0",
|
"@sasjs/utils": "2.44.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",
|
||||||
@@ -1142,9 +1142,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@sasjs/utils": {
|
"node_modules/@sasjs/utils": {
|
||||||
"version": "2.42.0",
|
"version": "2.44.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.42.0.tgz",
|
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.44.0.tgz",
|
||||||
"integrity": "sha512-Y69l89PYNF/h9xvVH72om/39xA+cY80bhiVLzp/fJb3BlvzCf4RNswBBanUOv2I5JNa7gPpJuE7mEiXOlhD3eg==",
|
"integrity": "sha512-hpC4erHYA8Mcb38mzxFEP0cXehfa0iKeqSW2d9MmxZ9g2qpy0BU6xyZJohN9kOiafXo5H359ndNKsg4DOq5YgA==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/fs-extra": "9.0.13",
|
"@types/fs-extra": "9.0.13",
|
||||||
@@ -13870,9 +13870,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@sasjs/utils": {
|
"@sasjs/utils": {
|
||||||
"version": "2.42.0",
|
"version": "2.44.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.42.0.tgz",
|
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.44.0.tgz",
|
||||||
"integrity": "sha512-Y69l89PYNF/h9xvVH72om/39xA+cY80bhiVLzp/fJb3BlvzCf4RNswBBanUOv2I5JNa7gPpJuE7mEiXOlhD3eg==",
|
"integrity": "sha512-hpC4erHYA8Mcb38mzxFEP0cXehfa0iKeqSW2d9MmxZ9g2qpy0BU6xyZJohN9kOiafXo5H359ndNKsg4DOq5YgA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/fs-extra": "9.0.13",
|
"@types/fs-extra": "9.0.13",
|
||||||
"@types/prompts": "2.0.13",
|
"@types/prompts": "2.0.13",
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sasjs/utils": "2.42.0",
|
"@sasjs/utils": "2.44.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",
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ The below services need to be created on your SAS server, at the location specif
|
|||||||
```sas
|
```sas
|
||||||
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
||||||
%inc mc;
|
%inc mc;
|
||||||
filename ft15f001 temp;
|
filename ft15f001 temp lrecl=1000;
|
||||||
parmcards4;
|
parmcards4;
|
||||||
%webout(FETCH)
|
%webout(FETCH)
|
||||||
%webout(OPEN)
|
%webout(OPEN)
|
||||||
@@ -113,7 +113,7 @@ data _null_;
|
|||||||
```sas
|
```sas
|
||||||
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
||||||
%inc mc;
|
%inc mc;
|
||||||
filename ft15f001 temp;
|
filename ft15f001 temp lrecl=1000;
|
||||||
parmcards4;
|
parmcards4;
|
||||||
%webout(FETCH)
|
%webout(FETCH)
|
||||||
%webout(OPEN)
|
%webout(OPEN)
|
||||||
|
|||||||
@@ -916,8 +916,8 @@ export default class SASjs {
|
|||||||
return await this.sasJSApiClient?.deploy(dataJson, appLoc, authConfig)
|
return await this.sasJSApiClient?.deploy(dataJson, appLoc, authConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async executeJobSASjs(query: ExecutionQuery) {
|
public async executeJobSASjs(query: ExecutionQuery, authConfig?: AuthConfig) {
|
||||||
return await this.sasJSApiClient?.executeJob(query)
|
return await this.sasJSApiClient?.executeJob(query, authConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ export class SASjsApiClient {
|
|||||||
return Promise.resolve(result)
|
return Promise.resolve(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async executeJob(query: ExecutionQuery) {
|
public async executeJob(query: ExecutionQuery, authConfig?: AuthConfig) {
|
||||||
|
const access_token = authConfig ? authConfig.access_token : undefined
|
||||||
|
|
||||||
const { result } = await this.requestClient.post<{
|
const { result } = await this.requestClient.post<{
|
||||||
status: string
|
status: string
|
||||||
message: string
|
message: string
|
||||||
@@ -51,7 +53,7 @@ export class SASjsApiClient {
|
|||||||
logPath?: string
|
logPath?: string
|
||||||
error?: {}
|
error?: {}
|
||||||
_webout?: string
|
_webout?: string
|
||||||
}>('SASjsApi/stp/execute', query, undefined)
|
}>('SASjsApi/stp/execute', query, access_token)
|
||||||
|
|
||||||
if (Object.keys(result).includes('_webout')) {
|
if (Object.keys(result).includes('_webout')) {
|
||||||
result._webout = parseWeboutResponse(result._webout!)
|
result._webout = parseWeboutResponse(result._webout!)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { BaseJobExecutor } from './JobExecutor'
|
import { BaseJobExecutor } from './JobExecutor'
|
||||||
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
|
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
|
||||||
|
import { Server } from 'https'
|
||||||
|
|
||||||
export interface WaitingRequstPromise {
|
export interface WaitingRequstPromise {
|
||||||
promise: Promise<any> | null
|
promise: Promise<any> | null
|
||||||
@@ -46,7 +47,7 @@ export class WebJobExecutor extends BaseJobExecutor {
|
|||||||
authConfig?: AuthConfig,
|
authConfig?: AuthConfig,
|
||||||
extraResponseAttributes: ExtraResponseAttributes[] = []
|
extraResponseAttributes: ExtraResponseAttributes[] = []
|
||||||
) {
|
) {
|
||||||
const loginCallback = loginRequiredCallback || (() => Promise.resolve())
|
const loginCallback = loginRequiredCallback
|
||||||
const program = isRelativePath(sasJob)
|
const program = isRelativePath(sasJob)
|
||||||
? config.appLoc
|
? config.appLoc
|
||||||
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
||||||
@@ -79,7 +80,7 @@ export class WebJobExecutor extends BaseJobExecutor {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
await loginCallback()
|
if (loginCallback) await loginCallback()
|
||||||
} else {
|
} else {
|
||||||
reject(new ErrorResponse(e?.message, e))
|
reject(new ErrorResponse(e?.message, e))
|
||||||
}
|
}
|
||||||
@@ -220,6 +221,15 @@ export class WebJobExecutor extends BaseJobExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e instanceof LoginRequiredError) {
|
if (e instanceof LoginRequiredError) {
|
||||||
|
if (!loginRequiredCallback) {
|
||||||
|
reject(
|
||||||
|
new ErrorResponse(
|
||||||
|
'Request is not authenticated. Make sure .env file exists with valid credentials.',
|
||||||
|
e
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
this.appendWaitingRequest(() => {
|
this.appendWaitingRequest(() => {
|
||||||
return this.execute(
|
return this.execute(
|
||||||
sasJob,
|
sasJob,
|
||||||
@@ -238,7 +248,7 @@ export class WebJobExecutor extends BaseJobExecutor {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
await loginCallback()
|
if (loginCallback) await loginCallback()
|
||||||
} else {
|
} else {
|
||||||
reject(new ErrorResponse(e?.message, e))
|
reject(new ErrorResponse(e?.message, e))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ describe('formatDataForRequest', () => {
|
|||||||
|
|
||||||
expect(() => formatDataForRequest(tableWithMissingValues)).toThrow(
|
expect(() => formatDataForRequest(tableWithMissingValues)).toThrow(
|
||||||
new Error(
|
new Error(
|
||||||
'Special missing value can only be a single character from A to Z or _'
|
`A Special missing value can only be a single character from 'A' to 'Z', '_', '.[a-z]', '._'`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { isSpecialMissing } from '@sasjs/utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the given JSON object array to a CSV string.
|
* Converts the given JSON object array to a CSV string.
|
||||||
* @param data - the array of JSON objects to convert.
|
* @param data - the array of JSON objects to convert.
|
||||||
@@ -18,7 +20,6 @@ export const convertToCSV = (
|
|||||||
let headers: string[] = []
|
let headers: string[] = []
|
||||||
let csvTest
|
let csvTest
|
||||||
let invalidString = false
|
let invalidString = false
|
||||||
const specialMissingValueRegExp = /^[a-z_]{1}$/i
|
|
||||||
|
|
||||||
if (formats) {
|
if (formats) {
|
||||||
headers = Object.keys(formats).map((key) => `${key}:${formats![key]}`)
|
headers = Object.keys(formats).map((key) => `${key}:${formats![key]}`)
|
||||||
@@ -36,7 +37,7 @@ export const convertToCSV = (
|
|||||||
hasNullOrNumber = true
|
hasNullOrNumber = true
|
||||||
} else if (
|
} else if (
|
||||||
typeof row[field] === 'string' &&
|
typeof row[field] === 'string' &&
|
||||||
specialMissingValueRegExp.test(row[field])
|
isSpecialMissing(row[field])
|
||||||
) {
|
) {
|
||||||
hasSpecialMissingString = true
|
hasSpecialMissingString = true
|
||||||
}
|
}
|
||||||
@@ -130,10 +131,9 @@ export const convertToCSV = (
|
|||||||
value = currentCell === null ? '' : currentCell
|
value = currentCell === null ? '' : currentCell
|
||||||
|
|
||||||
if (formats && formats[fieldName] === 'best.') {
|
if (formats && formats[fieldName] === 'best.') {
|
||||||
if (value && !specialMissingValueRegExp.test(value)) {
|
if (value && !isSpecialMissing(value)) {
|
||||||
console.log(`🤖[value]🤖`, value)
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Special missing value can only be a single character from A to Z or _'
|
`A Special missing value can only be a single character from 'A' to 'Z', '_', '.[a-z]', '._'`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user