mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-08 21:10:05 +00:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fef65bbfd2 | ||
|
|
efeba71612 | ||
|
|
8f54002b1e | ||
|
|
9d6882799d | ||
|
|
73a3acee68 | ||
|
|
0a88220e04 | ||
|
|
c8e1779272 | ||
|
|
8bd3580e23 | ||
|
|
f732b32873 | ||
|
|
65b18f9148 | ||
|
|
10b1676a35 | ||
|
|
b9bd09d3e8 | ||
|
|
537f687b94 | ||
|
|
bfd532f813 | ||
|
|
4f2b4f46a8 | ||
|
|
077cc9458d | ||
|
|
0a7ab394a4 | ||
|
|
f873febfde | ||
|
|
55e8ce359b | ||
|
|
99d7c8f119 | ||
|
|
b3c90f09d6 | ||
|
|
2401962c53 | ||
|
|
362b4d4db3 | ||
|
|
8aea325139 | ||
|
|
bb370061a2 | ||
|
|
48442f7769 | ||
|
|
e67a8531ce | ||
|
|
ef4f020e2a | ||
|
|
2feceeb2f9 | ||
|
|
eaec922fea | ||
|
|
de94777fff | ||
|
|
0aa0ae65e0 | ||
|
|
4b0d62d59b | ||
|
|
b3ef50e9eb |
3445
package-lock.json
generated
3445
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -36,31 +36,31 @@
|
|||||||
},
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.20",
|
"@types/jest": "^26.0.22",
|
||||||
"cp": "^0.2.0",
|
"cp": "^0.2.0",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"jest-extended": "^0.11.5",
|
"jest-extended": "^0.11.5",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"semantic-release": "^17.4.1",
|
"semantic-release": "^17.4.2",
|
||||||
"terser-webpack-plugin": "^4.2.3",
|
"terser-webpack-plugin": "^4.2.3",
|
||||||
"ts-jest": "^25.5.1",
|
"ts-jest": "^25.5.1",
|
||||||
"ts-loader": "^8.0.17",
|
"ts-loader": "^8.1.0",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0",
|
"tslint-config-prettier": "^1.18.0",
|
||||||
"typedoc": "^0.20.30",
|
"typedoc": "^0.20.35",
|
||||||
"typedoc-neo-theme": "^1.1.0",
|
"typedoc-neo-theme": "^1.1.0",
|
||||||
"typedoc-plugin-external-module-name": "^4.0.6",
|
"typedoc-plugin-external-module-name": "^4.0.6",
|
||||||
"typescript": "^3.9.9",
|
"typescript": "^3.9.9",
|
||||||
"webpack": "^5.24.4",
|
"webpack": "^5.33.2",
|
||||||
"webpack-cli": "^4.5.0"
|
"webpack-cli": "^4.5.0"
|
||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sasjs/utils": "^2.6.3",
|
"@sasjs/utils": "^2.10.2",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"form-data": "^3.0.0",
|
"form-data": "^4.0.0",
|
||||||
"https": "^1.0.0"
|
"https": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/SASjs.ts
23
src/SASjs.ts
@@ -12,6 +12,7 @@ import {
|
|||||||
ComputeJobExecutor,
|
ComputeJobExecutor,
|
||||||
JesJobExecutor
|
JesJobExecutor
|
||||||
} from './job-execution'
|
} from './job-execution'
|
||||||
|
import { ErrorResponse } from './types/errors'
|
||||||
|
|
||||||
const defaultConfig: SASjsConfig = {
|
const defaultConfig: SASjsConfig = {
|
||||||
serverUrl: '',
|
serverUrl: '',
|
||||||
@@ -709,9 +710,27 @@ export default class SASjs {
|
|||||||
* @param accessToken - an access token for an authorized user.
|
* @param accessToken - an access token for an authorized user.
|
||||||
*/
|
*/
|
||||||
public async fetchLogFileContent(logUrl: string, accessToken?: string) {
|
public async fetchLogFileContent(logUrl: string, accessToken?: string) {
|
||||||
return await this.requestClient!.get(logUrl, accessToken).then((res) =>
|
return await this.requestClient!.get(logUrl, accessToken).then((res) => {
|
||||||
JSON.stringify(res.result)
|
if (!res)
|
||||||
|
return Promise.reject(
|
||||||
|
new ErrorResponse(
|
||||||
|
'Error while fetching log. Response was not provided.'
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = JSON.stringify(res.result)
|
||||||
|
|
||||||
|
return result
|
||||||
|
} catch (err) {
|
||||||
|
return Promise.reject(
|
||||||
|
new ErrorResponse(
|
||||||
|
'Error while fetching log. The result is not valid.',
|
||||||
|
err
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSasRequests() {
|
public getSasRequests() {
|
||||||
|
|||||||
39
src/test/utils/isUrl.spec.ts
Normal file
39
src/test/utils/isUrl.spec.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { isUrl } from '../../utils/isUrl'
|
||||||
|
|
||||||
|
describe('urlValidator', () => {
|
||||||
|
it('should return true with an HTTP URL', () => {
|
||||||
|
const url = 'http://google.com'
|
||||||
|
|
||||||
|
expect(isUrl(url)).toEqual(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return true with an HTTPS URL', () => {
|
||||||
|
const url = 'https://google.com'
|
||||||
|
|
||||||
|
expect(isUrl(url)).toEqual(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return true when the URL is blank', () => {
|
||||||
|
const url = ''
|
||||||
|
|
||||||
|
expect(isUrl(url)).toEqual(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false when the URL has not supported protocol', () => {
|
||||||
|
const url = 'htpps://google.com'
|
||||||
|
|
||||||
|
expect(isUrl(url)).toEqual(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false when the URL is null', () => {
|
||||||
|
const url = null
|
||||||
|
|
||||||
|
expect(isUrl((url as unknown) as string)).toEqual(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false when the URL is undefined', () => {
|
||||||
|
const url = undefined
|
||||||
|
|
||||||
|
expect(isUrl((url as unknown) as string)).toEqual(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* Checks if string is in URL format.
|
* Checks if string is in URL format.
|
||||||
* @param url - string to check.
|
* @param str - string to check.
|
||||||
*/
|
*/
|
||||||
export const isUrl = (url: string): boolean => {
|
export const isUrl = (str: string): boolean => {
|
||||||
const pattern = new RegExp(
|
const supportedProtocols = ['http:', 'https:']
|
||||||
'^(http://|https://)[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$',
|
|
||||||
'gi'
|
|
||||||
)
|
|
||||||
|
|
||||||
if (pattern.test(url)) return true
|
try {
|
||||||
else
|
const url = new URL(str)
|
||||||
throw new Error(
|
|
||||||
`'${url}' is not a valid url. An example of a valid url is 'http://valid-url.com'.`
|
if (!supportedProtocols.includes(url.protocol)) return false
|
||||||
)
|
} catch (_) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user