mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 09:24:35 +00:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c9cce8bf8 | ||
|
|
d5791a75cd | ||
|
|
1f970e1102 | ||
|
|
1552762d28 | ||
|
|
ef39252b0b | ||
|
|
3f3f8f4531 | ||
|
|
33879ee998 | ||
|
|
cc8271438b | ||
|
|
a064bc086d | ||
|
|
d5de6b50a9 | ||
|
|
f1184346d8 | ||
|
|
337fe5e988 | ||
|
|
c23e6352e2 | ||
|
|
57ce0ae35f | ||
|
|
115caec761 | ||
|
|
c626c57662 | ||
|
|
82b14fad14 | ||
|
|
755bf7d07c | ||
|
|
619833db29 | ||
|
|
a587d9f6de | ||
|
|
83fb89f779 | ||
|
|
6b98bbce7c | ||
|
|
3c2487e423 | ||
|
|
0d52af5375 | ||
|
|
d0da343efc | ||
|
|
54f401a319 | ||
|
|
5efcb11b7d | ||
|
|
929d7b993b | ||
|
|
688221c042 | ||
|
|
57d0b30f47 | ||
| 0d5af2487d | |||
| 1ea163fd03 | |||
|
|
f27444bc52 | ||
|
|
de426c9a92 | ||
|
|
a006ead205 | ||
|
|
422c2a1fd5 | ||
|
|
0c6409e402 | ||
|
|
68b864cf75 | ||
|
|
75a11cdff4 | ||
|
|
4e2b6d32cc | ||
|
|
cd9757b383 | ||
|
|
fb727788d0 | ||
|
|
35eb6c4935 | ||
|
|
ea0f338b90 | ||
|
|
b6a17b39b9 | ||
|
|
9ed64e5a2c | ||
|
|
0479a5d651 | ||
|
|
005f10bb47 | ||
|
|
98c9cb78ff | ||
|
|
8192f69f67 | ||
|
|
c28a8ebf15 |
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@@ -21,7 +21,11 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm run package:lib
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
- name: Check code style
|
||||
run: npm run lint
|
||||
- name: Build Package
|
||||
run: npm run package:lib
|
||||
env:
|
||||
CI: true
|
||||
|
||||
2
.github/workflows/npmpublish.yml
vendored
2
.github/workflows/npmpublish.yml
vendored
@@ -16,6 +16,8 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
- name: Check code style
|
||||
run: npm run lint
|
||||
- name: Build Project
|
||||
run: npm run build
|
||||
- name: Semantic Release
|
||||
|
||||
6
.prettierrc
Normal file
6
.prettierrc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"trailingComma": "none",
|
||||
"tabWidth": 2,
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
||||
@@ -1,75 +1,14 @@
|
||||
# Contributing
|
||||
|
||||
Contributions to SASjs are very welcome! When making a PR, test cases should be included. To help in unit testing, be sure to run the following when making changes:
|
||||
Contributions to SASjs are very welcome! When making a PR, test cases should be included.
|
||||
|
||||
```
|
||||
# the following creates a tarball in the build folder of SASjs
|
||||
npm run-script package:lib
|
||||
This repository contains a suite of tests built using [@sasjs/test-framework](https://github.com/sasjs/test-framework).
|
||||
|
||||
# now go to your app and run:
|
||||
npm install ../sasjs/build/<tarball filename>
|
||||
```
|
||||
Detailed instructions for creating and running the tests can be found [here](https://github.com/sasjs/adapter/blob/master/sasjs-tests/README.md).
|
||||
|
||||
Tests are run using cypress. Before running tests, you need to define the following backend services:
|
||||
If you'd like to test your changes in an app that uses the adapter, you can do so as follows:
|
||||
|
||||
# SAS 9
|
||||
|
||||
```
|
||||
|
||||
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
||||
%inc mc;
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to &_webin_file_count; %webout(OBJ,&&_webin_name&i) %end;
|
||||
%mend; %x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mm_createwebservice(path=/Public/app/common,name=sendObj)
|
||||
parmcards4;
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to &_webin_file_count; %webout(ARR,&&_webin_name&i) %end;
|
||||
%mend; %x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mm_createwebservice(path=/Public/app/common,name=sendArr)
|
||||
```
|
||||
|
||||
# Viya
|
||||
|
||||
```
|
||||
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
||||
%inc mc;
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
%webout(FETCH)
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to %sysfunc(countw(&sasjs_tables));
|
||||
%let table=%scan(&sasjs_tables,&i);
|
||||
%webout(OBJ,&table)
|
||||
%end;
|
||||
%mend;
|
||||
%x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mp_createwebservice(path=/Public/app/common,name=sendObj)
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
%webout(FETCH)
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to %sysfunc(countw(&sasjs_tables));
|
||||
%let table=%scan(&sasjs_tables,&i);
|
||||
%webout(ARR,&table)
|
||||
%end;
|
||||
%mend;
|
||||
%x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mp_createwebservice(path=/Public/app/common,name=sendArr)
|
||||
```
|
||||
|
||||
The above services will return anything you send. To run the tests simply launch `npm run cypress`.
|
||||
1. Run `npm run package:lib` from the root folder in this repository.
|
||||
This creates a tarball in the `/build` folder.
|
||||
2. In your app's root folder, run `npm install <path/to/tarball>`.
|
||||
This will install the changed version of the adapter in your app.
|
||||
|
||||
@@ -43,6 +43,6 @@ You now have a simple web app with a backend service!
|
||||
|
||||
# More resources
|
||||
|
||||
For more information specific to this adapter you can check out this [user guide](https://sasjs.io/sasjs-adapter/) or the [technical](http://adapter.sasjs.io/) documentation.
|
||||
For more information and examples specific to this adapter you can check out the [user guide](https://sasjs.io/sasjs-adapter/) or the [technical](http://adapter.sasjs.io/) documentation.
|
||||
|
||||
For more information on building web apps in general, check out these [resources](https://sasjs.io/training/resources/) or contact the [author](https://www.linkedin.com/in/allanbowe/) directly.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@1.0.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@1"></script>
|
||||
<script>
|
||||
var sasJs = new SASjs.default({
|
||||
appLoc: "/Public/app/readme"
|
||||
@@ -106,4 +106,4 @@
|
||||
<canvas id="myChart" style="display: none;"></canvas>
|
||||
</div>
|
||||
</body>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
448
package-lock.json
generated
448
package-lock.json
generated
@@ -1648,9 +1648,9 @@
|
||||
}
|
||||
},
|
||||
"@types/jest": {
|
||||
"version": "26.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.9.tgz",
|
||||
"integrity": "sha512-k4qFfJ5AUKrWok5KYXp2EPm89b0P/KZpl7Vg4XuOTVVQEhLDBDBU3iBFrjjdgd8fLw96aAtmnwhXHl63bWeBQQ==",
|
||||
"version": "26.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.10.tgz",
|
||||
"integrity": "sha512-i2m0oyh8w/Lum7wWK/YOZJakYF8Mx08UaKA1CtbmFeDquVhAEdA7znacsVSf2hJ1OQ/OfVMGN90pw/AtzF8s/Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"jest-diff": "^25.2.1",
|
||||
@@ -3076,13 +3076,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"compare-func": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.4.tgz",
|
||||
"integrity": "sha512-sq2sWtrqKPkEXAC8tEJA1+BqAH9GbFkGBtUOqrUX57VSfwp8xyktctk+uLoRy5eccTdxzDcVIztlYDpKs3Jv1Q==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz",
|
||||
"integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"array-ify": "^1.0.0",
|
||||
"dot-prop": "^3.0.0"
|
||||
"dot-prop": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"component-emitter": {
|
||||
@@ -3122,22 +3122,49 @@
|
||||
"dev": true
|
||||
},
|
||||
"conventional-changelog-angular": {
|
||||
"version": "5.0.10",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.10.tgz",
|
||||
"integrity": "sha512-k7RPPRs0vp8+BtPsM9uDxRl6KcgqtCJmzRD1wRtgqmhQ96g8ifBGo9O/TZBG23jqlXS/rg8BKRDELxfnQQGiaA==",
|
||||
"version": "5.0.11",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.11.tgz",
|
||||
"integrity": "sha512-nSLypht/1yEflhuTogC03i7DX7sOrXGsRn14g131Potqi6cbGbGEE9PSDEHKldabB6N76HiSyw9Ph+kLmC04Qw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"compare-func": "^1.3.1",
|
||||
"compare-func": "^2.0.0",
|
||||
"q": "^1.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"compare-func": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz",
|
||||
"integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"array-ify": "^1.0.0",
|
||||
"dot-prop": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"dot-prop": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz",
|
||||
"integrity": "sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-obj": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"is-obj": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
|
||||
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"conventional-changelog-writer": {
|
||||
"version": "4.0.16",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.16.tgz",
|
||||
"integrity": "sha512-jmU1sDJDZpm/dkuFxBeRXvyNcJQeKhGtVcFFkwTphUAzyYWcwz2j36Wcv+Mv2hU3tpvLMkysOPXJTLO55AUrYQ==",
|
||||
"version": "4.0.17",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.17.tgz",
|
||||
"integrity": "sha512-IKQuK3bib/n032KWaSb8YlBFds+aLmzENtnKtxJy3+HqDq5kohu3g/UdNbIHeJWygfnEbZjnCKFxAW0y7ArZAw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"compare-func": "^1.3.1",
|
||||
"compare-func": "^2.0.0",
|
||||
"conventional-commits-filter": "^2.0.6",
|
||||
"dateformat": "^3.0.0",
|
||||
"handlebars": "^4.7.6",
|
||||
@@ -3580,12 +3607,12 @@
|
||||
}
|
||||
},
|
||||
"dot-prop": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz",
|
||||
"integrity": "sha1-G3CK8JSknJoOfbyteQq6U52sEXc=",
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz",
|
||||
"integrity": "sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-obj": "^1.0.0"
|
||||
"is-obj": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"duplexer2": {
|
||||
@@ -5170,9 +5197,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"is-obj": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
|
||||
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
|
||||
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
|
||||
"dev": true
|
||||
},
|
||||
"is-plain-obj": {
|
||||
@@ -8487,9 +8514,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"npm": {
|
||||
"version": "6.14.6",
|
||||
"resolved": "https://registry.npmjs.org/npm/-/npm-6.14.6.tgz",
|
||||
"integrity": "sha512-axnz6iHFK6WPE0js/+mRp+4IOwpHn5tJEw5KB6FiCU764zmffrhsYHbSHi2kKqNkRBt53XasXjngZfBD3FQzrQ==",
|
||||
"version": "6.14.8",
|
||||
"resolved": "https://registry.npmjs.org/npm/-/npm-6.14.8.tgz",
|
||||
"integrity": "sha512-HBZVBMYs5blsj94GTeQZel7s9odVuuSUHy1+AlZh7rPVux1os2ashvEGLy/STNK7vUjbrCg5Kq9/GXisJgdf6A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"JSONStream": "^1.3.5",
|
||||
@@ -8498,7 +8525,7 @@
|
||||
"ansistyles": "~0.1.3",
|
||||
"aproba": "^2.0.0",
|
||||
"archy": "~1.0.0",
|
||||
"bin-links": "^1.1.7",
|
||||
"bin-links": "^1.1.8",
|
||||
"bluebird": "^3.5.5",
|
||||
"byte-size": "^5.0.1",
|
||||
"cacache": "^12.0.3",
|
||||
@@ -8519,7 +8546,7 @@
|
||||
"find-npm-prefix": "^1.0.2",
|
||||
"fs-vacuum": "~1.2.10",
|
||||
"fs-write-stream-atomic": "~1.0.10",
|
||||
"gentle-fs": "^2.3.0",
|
||||
"gentle-fs": "^2.3.1",
|
||||
"glob": "^7.1.6",
|
||||
"graceful-fs": "^4.2.4",
|
||||
"has-unicode": "~2.0.1",
|
||||
@@ -8534,14 +8561,14 @@
|
||||
"is-cidr": "^3.0.0",
|
||||
"json-parse-better-errors": "^1.0.2",
|
||||
"lazy-property": "~1.0.0",
|
||||
"libcipm": "^4.0.7",
|
||||
"libcipm": "^4.0.8",
|
||||
"libnpm": "^3.0.1",
|
||||
"libnpmaccess": "^3.0.2",
|
||||
"libnpmhook": "^5.0.3",
|
||||
"libnpmorg": "^1.0.1",
|
||||
"libnpmsearch": "^2.0.2",
|
||||
"libnpmteam": "^1.0.2",
|
||||
"libnpx": "^10.2.2",
|
||||
"libnpx": "^10.2.4",
|
||||
"lock-verify": "^2.1.0",
|
||||
"lockfile": "^1.0.4",
|
||||
"lodash._baseindexof": "*",
|
||||
@@ -8556,22 +8583,22 @@
|
||||
"lodash.uniq": "~4.5.0",
|
||||
"lodash.without": "~4.4.0",
|
||||
"lru-cache": "^5.1.1",
|
||||
"meant": "~1.0.1",
|
||||
"meant": "^1.0.2",
|
||||
"mississippi": "^3.0.0",
|
||||
"mkdirp": "^0.5.5",
|
||||
"move-concurrently": "^1.0.1",
|
||||
"node-gyp": "^5.1.0",
|
||||
"nopt": "^4.0.3",
|
||||
"normalize-package-data": "^2.5.0",
|
||||
"npm-audit-report": "^1.3.2",
|
||||
"npm-audit-report": "^1.3.3",
|
||||
"npm-cache-filename": "~1.0.2",
|
||||
"npm-install-checks": "^3.0.2",
|
||||
"npm-lifecycle": "^3.1.4",
|
||||
"npm-lifecycle": "^3.1.5",
|
||||
"npm-package-arg": "^6.1.1",
|
||||
"npm-packlist": "^1.4.8",
|
||||
"npm-pick-manifest": "^3.0.2",
|
||||
"npm-profile": "^4.0.4",
|
||||
"npm-registry-fetch": "^4.0.5",
|
||||
"npm-registry-fetch": "^4.0.7",
|
||||
"npm-user-validate": "~1.0.0",
|
||||
"npmlog": "~4.1.2",
|
||||
"once": "~1.4.0",
|
||||
@@ -8780,7 +8807,7 @@
|
||||
}
|
||||
},
|
||||
"bin-links": {
|
||||
"version": "1.1.7",
|
||||
"version": "1.1.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -8935,26 +8962,41 @@
|
||||
}
|
||||
},
|
||||
"cliui": {
|
||||
"version": "4.1.0",
|
||||
"version": "5.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"string-width": "^2.1.1",
|
||||
"strip-ansi": "^4.0.0",
|
||||
"wrap-ansi": "^2.0.0"
|
||||
"string-width": "^3.1.0",
|
||||
"strip-ansi": "^5.2.0",
|
||||
"wrap-ansi": "^5.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "3.0.0",
|
||||
"version": "4.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "4.0.0",
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"string-width": {
|
||||
"version": "3.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^3.0.0"
|
||||
"emoji-regex": "^7.0.1",
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "5.2.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^4.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9069,11 +9111,11 @@
|
||||
}
|
||||
},
|
||||
"configstore": {
|
||||
"version": "3.1.2",
|
||||
"version": "3.1.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"dot-prop": "^4.1.0",
|
||||
"dot-prop": "^4.2.1",
|
||||
"graceful-fs": "^4.1.2",
|
||||
"make-dir": "^1.0.0",
|
||||
"unique-string": "^1.0.0",
|
||||
@@ -9249,7 +9291,7 @@
|
||||
}
|
||||
},
|
||||
"dot-prop": {
|
||||
"version": "4.2.0",
|
||||
"version": "4.2.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -9316,6 +9358,11 @@
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"emoji-regex": {
|
||||
"version": "7.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"encoding": {
|
||||
"version": "0.1.12",
|
||||
"bundled": true,
|
||||
@@ -9441,14 +9488,6 @@
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"find-up": {
|
||||
"version": "2.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"locate-path": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"flush-write-stream": {
|
||||
"version": "1.0.3",
|
||||
"bundled": true,
|
||||
@@ -9647,7 +9686,7 @@
|
||||
"dev": true
|
||||
},
|
||||
"gentle-fs": {
|
||||
"version": "2.3.0",
|
||||
"version": "2.3.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -9677,7 +9716,7 @@
|
||||
}
|
||||
},
|
||||
"get-caller-file": {
|
||||
"version": "1.0.3",
|
||||
"version": "2.0.5",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
@@ -9901,11 +9940,6 @@
|
||||
"validate-npm-package-name": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"invert-kv": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"ip": {
|
||||
"version": "1.1.5",
|
||||
"bundled": true,
|
||||
@@ -10090,16 +10124,8 @@
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"lcid": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"invert-kv": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"libcipm": {
|
||||
"version": "4.0.7",
|
||||
"version": "4.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -10109,7 +10135,7 @@
|
||||
"find-npm-prefix": "^1.0.2",
|
||||
"graceful-fs": "^4.1.11",
|
||||
"ini": "^1.3.5",
|
||||
"lock-verify": "^2.0.2",
|
||||
"lock-verify": "^2.1.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"npm-lifecycle": "^3.0.0",
|
||||
"npm-logical-tree": "^1.2.1",
|
||||
@@ -10268,7 +10294,7 @@
|
||||
}
|
||||
},
|
||||
"libnpx": {
|
||||
"version": "10.2.2",
|
||||
"version": "10.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -10279,16 +10305,7 @@
|
||||
"update-notifier": "^2.3.0",
|
||||
"which": "^1.3.0",
|
||||
"y18n": "^4.0.0",
|
||||
"yargs": "^11.0.0"
|
||||
}
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-locate": "^2.0.0",
|
||||
"path-exists": "^3.0.0"
|
||||
"yargs": "^14.2.3"
|
||||
}
|
||||
},
|
||||
"lock-verify": {
|
||||
@@ -10419,36 +10436,11 @@
|
||||
"ssri": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"map-age-cleaner": {
|
||||
"version": "0.1.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-defer": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"meant": {
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"mem": {
|
||||
"version": "4.3.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"map-age-cleaner": "^0.1.1",
|
||||
"mimic-fn": "^2.0.0",
|
||||
"p-is-promise": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"mimic-fn": {
|
||||
"version": "2.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.35.0",
|
||||
"bundled": true,
|
||||
@@ -10470,6 +10462,11 @@
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.5",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"minizlib": {
|
||||
"version": "1.3.3",
|
||||
"bundled": true,
|
||||
@@ -10551,11 +10548,6 @@
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"nice-try": {
|
||||
"version": "1.0.5",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"node-fetch-npm": {
|
||||
"version": "2.0.2",
|
||||
"bundled": true,
|
||||
@@ -10615,7 +10607,7 @@
|
||||
}
|
||||
},
|
||||
"npm-audit-report": {
|
||||
"version": "1.3.2",
|
||||
"version": "1.3.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -10645,7 +10637,7 @@
|
||||
}
|
||||
},
|
||||
"npm-lifecycle": {
|
||||
"version": "3.1.4",
|
||||
"version": "3.1.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -10711,7 +10703,7 @@
|
||||
}
|
||||
},
|
||||
"npm-registry-fetch": {
|
||||
"version": "4.0.5",
|
||||
"version": "4.0.7",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -10802,44 +10794,6 @@
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"os-locale": {
|
||||
"version": "3.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"execa": "^1.0.0",
|
||||
"lcid": "^2.0.0",
|
||||
"mem": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-spawn": {
|
||||
"version": "6.0.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"nice-try": "^1.0.4",
|
||||
"path-key": "^2.0.1",
|
||||
"semver": "^5.5.0",
|
||||
"shebang-command": "^1.2.0",
|
||||
"which": "^1.2.9"
|
||||
}
|
||||
},
|
||||
"execa": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cross-spawn": "^6.0.0",
|
||||
"get-stream": "^4.0.0",
|
||||
"is-stream": "^1.1.0",
|
||||
"npm-run-path": "^2.0.0",
|
||||
"p-finally": "^1.0.0",
|
||||
"signal-exit": "^3.0.0",
|
||||
"strip-eof": "^1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"os-tmpdir": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
@@ -10854,42 +10808,11 @@
|
||||
"os-tmpdir": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"p-defer": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"p-finally": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"p-is-promise": {
|
||||
"version": "2.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "1.2.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-try": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"p-locate": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-limit": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"p-try": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"package-json": {
|
||||
"version": "4.0.1",
|
||||
"bundled": true,
|
||||
@@ -11154,13 +11077,6 @@
|
||||
"ini": "~1.3.0",
|
||||
"minimist": "^1.2.0",
|
||||
"strip-json-comments": "~2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.5",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"read": {
|
||||
@@ -11286,7 +11202,7 @@
|
||||
"dev": true
|
||||
},
|
||||
"require-main-filename": {
|
||||
"version": "1.0.1",
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
@@ -11936,22 +11852,41 @@
|
||||
}
|
||||
},
|
||||
"wrap-ansi": {
|
||||
"version": "2.1.0",
|
||||
"version": "5.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"string-width": "^1.0.1",
|
||||
"strip-ansi": "^3.0.1"
|
||||
"ansi-styles": "^3.2.0",
|
||||
"string-width": "^3.0.0",
|
||||
"strip-ansi": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "4.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"version": "3.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
"strip-ansi": "^3.0.0"
|
||||
"emoji-regex": "^7.0.1",
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "5.2.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^4.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11992,37 +11927,105 @@
|
||||
"dev": true
|
||||
},
|
||||
"yargs": {
|
||||
"version": "11.1.1",
|
||||
"version": "14.2.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cliui": "^4.0.0",
|
||||
"decamelize": "^1.1.1",
|
||||
"find-up": "^2.1.0",
|
||||
"get-caller-file": "^1.0.1",
|
||||
"os-locale": "^3.1.0",
|
||||
"cliui": "^5.0.0",
|
||||
"decamelize": "^1.2.0",
|
||||
"find-up": "^3.0.0",
|
||||
"get-caller-file": "^2.0.1",
|
||||
"require-directory": "^2.1.1",
|
||||
"require-main-filename": "^1.0.1",
|
||||
"require-main-filename": "^2.0.0",
|
||||
"set-blocking": "^2.0.0",
|
||||
"string-width": "^2.0.0",
|
||||
"string-width": "^3.0.0",
|
||||
"which-module": "^2.0.0",
|
||||
"y18n": "^3.2.1",
|
||||
"yargs-parser": "^9.0.2"
|
||||
"y18n": "^4.0.0",
|
||||
"yargs-parser": "^15.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"y18n": {
|
||||
"version": "3.2.1",
|
||||
"ansi-regex": {
|
||||
"version": "4.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"find-up": {
|
||||
"version": "3.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"locate-path": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "3.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-locate": "^3.0.0",
|
||||
"path-exists": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "2.3.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-try": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"p-locate": {
|
||||
"version": "3.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-limit": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"p-try": {
|
||||
"version": "2.2.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"string-width": {
|
||||
"version": "3.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"emoji-regex": "^7.0.1",
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "5.2.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^4.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"yargs-parser": {
|
||||
"version": "9.0.2",
|
||||
"version": "15.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"camelcase": "^4.1.0"
|
||||
"camelcase": "^5.0.0",
|
||||
"decamelize": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"camelcase": {
|
||||
"version": "5.3.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12491,12 +12494,6 @@
|
||||
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
|
||||
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
|
||||
"dev": true
|
||||
},
|
||||
"pretty-format": {
|
||||
"version": "25.5.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-25.5.0.tgz",
|
||||
@@ -14255,9 +14252,9 @@
|
||||
}
|
||||
},
|
||||
"ts-loader": {
|
||||
"version": "8.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-8.0.2.tgz",
|
||||
"integrity": "sha512-oYT7wOTUawYXQ8XIDsRhziyW0KUEV38jISYlE+9adP6tDtG+O5GkRe4QKQXrHVH4mJJ88DysvEtvGP65wMLlhg==",
|
||||
"version": "8.0.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-8.0.3.tgz",
|
||||
"integrity": "sha512-wsqfnVdB7xQiqhqbz2ZPLGHLPZbHVV5Qn/MNFZkCFxRU1miDyxKORucDGxKtsQJ63Rfza0udiUxWF5nHY6bpdQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.3.0",
|
||||
@@ -14418,11 +14415,12 @@
|
||||
}
|
||||
},
|
||||
"typedoc-neo-theme": {
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/typedoc-neo-theme/-/typedoc-neo-theme-1.0.9.tgz",
|
||||
"integrity": "sha512-g6ITZAkRBTVyTQnyq8LfYN3Y2fOoLnND3gG3nK7lcRthQ1kU4pTEK711KCEaceSK93qB5EgtLZkjv7NOg7qRTw==",
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/typedoc-neo-theme/-/typedoc-neo-theme-1.0.10.tgz",
|
||||
"integrity": "sha512-PmbqBFNyG8atVHIJ1Wgy8gm+7vR7Anl7cewOxI8qxo7M4Jk7vaY9pqJSnOm9Mfkk7k73Pw3mJVl3jxP4s0r/oA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lunr": "^2.3.8",
|
||||
"typedoc": "~0.17.8"
|
||||
}
|
||||
},
|
||||
|
||||
11
package.json
11
package.json
@@ -5,8 +5,8 @@
|
||||
"build": "rimraf build && webpack",
|
||||
"package:lib": "npm run build && cp ./package.json build && cd build && npm version \"5.0.0\" && npm pack",
|
||||
"publish:lib": "npm run build && cd build && npm publish",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
||||
"lint": "tslint -p tsconfig.json",
|
||||
"lint:fix": "npx prettier --write 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
|
||||
"lint": "npx prettier --check 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
|
||||
"test": "jest",
|
||||
"prepublishOnly": "cp -r ./build/* . && rm -rf ./build",
|
||||
"postpublish": "git clean -fd",
|
||||
@@ -37,19 +37,18 @@
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/isomorphic-fetch": "0.0.35",
|
||||
"@types/jest": "^26.0.9",
|
||||
"@types/jest": "^26.0.10",
|
||||
"cp": "^0.2.0",
|
||||
"jest": "^25.5.4",
|
||||
"path": "^0.12.7",
|
||||
"prettier": "^2.0.5",
|
||||
"rimraf": "^3.0.2",
|
||||
"semantic-release": "^17.1.1",
|
||||
"ts-jest": "^25.5.1",
|
||||
"ts-loader": "^8.0.2",
|
||||
"ts-loader": "^8.0.3",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0",
|
||||
"typedoc": "^0.17.8",
|
||||
"typedoc-neo-theme": "^1.0.9",
|
||||
"typedoc-neo-theme": "^1.0.10",
|
||||
"typedoc-plugin-external-module-name": "^4.0.3",
|
||||
"typescript": "^3.9.7",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
|
||||
6
sasjs-tests/.prettierrc
Normal file
6
sasjs-tests/.prettierrc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"trailingComma": "none",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": false
|
||||
}
|
||||
@@ -1,68 +1,139 @@
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
`sasjs-tests` is a test suite for the SASjs adapter.
|
||||
|
||||
## Available Scripts
|
||||
It is a React app bootstrapped using [Create React App](https://github.com/facebook/create-react-app) and [@sasjs/test-framework](https://github.com/sasjs/test-framework).
|
||||
|
||||
In the project directory, you can run:
|
||||
When developing on `@sasjs/adapter`, it's good practice to run the test suite against your changed version of the adapter to ensure that existing functionality has not been impacted.
|
||||
|
||||
### `npm start`
|
||||
You can use the provided `update:adapter` NPM script for this.
|
||||
|
||||
Runs the app in the development mode.<br />
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
```
|
||||
npm run update:adapter
|
||||
```
|
||||
|
||||
The page will reload if you make edits.<br />
|
||||
You will also see any lint errors in the console.
|
||||
This scripts builds a new version of the adapter and installs it in the `sasjs-tests` project.
|
||||
|
||||
### `npm test`
|
||||
## Running tests
|
||||
|
||||
Launches the test runner in the interactive watch mode.<br />
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
There are three prerequisites to be able to run the tests:
|
||||
|
||||
### `npm run build`
|
||||
1. Correct server configuration for the SASjs adapter.
|
||||
2. `sasjs-tests` deployed to your SAS server.
|
||||
3. The required SAS services created on the same server.
|
||||
|
||||
Builds the app for production to the `build` folder.<br />
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
### 1. Configuring the SASjs adapter
|
||||
|
||||
The build is minified and the filenames include the hashes.<br />
|
||||
Your app is ready to be deployed!
|
||||
There is a `config.json` file in the `/public` folder which specifies the configuration for the SASjs adapter. You can set the values within the `sasjsConfig` property in this file to match your SAS server configuration.
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
### 2. Deploying to your SAS server
|
||||
|
||||
### `npm run eject`
|
||||
There is a `deploy` NPM script provided in the `sasjs-tests` project's `package.json`.
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
It updates `sasjs-tests` to use the latest version of the adapter, and deploys to a specified server via SSH using the `rsync` command.
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
To be able to run the `deploy` script, two environment variables need to be set:
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
- `SSH_ACCOUNT` - your SSH account, this is of the form username@domain.com
|
||||
- `DEPLOY_PATH` - the path on the server where `sasjs-tests` will be deployed to, typically `/var/www/html/<some-subfolder>`.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
So you can run the script like so:
|
||||
|
||||
## Learn More
|
||||
```
|
||||
SSH_ACCOUNT=me@my-sas-server.com DEPLOY_PATH=/var/www/html/my-folder/sasjs-tests npm run deploy
|
||||
```
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
If you'd like to deploy just `sasjs-tests` without changing the adapter version, you can use the `deploy:tests` script, while also setting the same environment variables as above.
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
## 3. Creating the required SAS services
|
||||
|
||||
### Code Splitting
|
||||
The below services need to be created on your SAS server, at the location specified as the `appLoc` in the SASjs configuration.
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
|
||||
### SAS 9
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
```
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
|
||||
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
||||
%inc mc;
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to &_webin_file_count; %webout(OBJ,&&_webin_name&i) %end;
|
||||
%mend; %x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mm_createwebservice(path=/Public/app/common,name=sendObj)
|
||||
parmcards4;
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to &_webin_file_count; %webout(ARR,&&_webin_name&i) %end;
|
||||
%mend; %x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mm_createwebservice(path=/Public/app/common,name=sendArr)
|
||||
```
|
||||
|
||||
### Making a Progressive Web App
|
||||
### SAS Viya
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
|
||||
```
|
||||
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
||||
%inc mc;
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
%webout(FETCH)
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to %sysfunc(countw(&sasjs_tables));
|
||||
%let table=%scan(&sasjs_tables,&i);
|
||||
%webout(OBJ,&table)
|
||||
%end;
|
||||
%mend;
|
||||
%x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mp_createwebservice(path=/Public/app/common,name=sendObj)
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
%webout(FETCH)
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to %sysfunc(countw(&sasjs_tables));
|
||||
%let table=%scan(&sasjs_tables,&i);
|
||||
%webout(ARR,&table)
|
||||
%end;
|
||||
%mend;
|
||||
%x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mp_createwebservice(path=/Public/app/common,name=sendArr)
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
If you can keep your head when all about you
|
||||
Are losing theirs and blaming it on you,
|
||||
If you can trust yourself when all men doubt you,
|
||||
But make allowance for their doubting too;
|
||||
;;;;
|
||||
%mp_createwebservice(path=/Public/app/common,name=makeErr)
|
||||
```
|
||||
|
||||
### Advanced Configuration
|
||||
You should now be able to access the tests in your browser at the deployed path on your server.
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
|
||||
## Creating new tests
|
||||
|
||||
### Deployment
|
||||
The `src/testSuites` folder contains all the test suites currently available.
|
||||
Each suite contains a set of specs, each of which looks like this:
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
|
||||
```javascript
|
||||
{
|
||||
title: "Your test title",
|
||||
description: "A slightly more detailed description",
|
||||
test: async () => {
|
||||
// typically makes a request using the adapter and returns a promise
|
||||
},
|
||||
assertion: (response: any) =>
|
||||
// receives the response when the test promise resolves, runs an assertion and returns a boolean
|
||||
}
|
||||
```
|
||||
|
||||
### `npm run build` fails to minify
|
||||
A test suite is an array of such objects, along with a `name` property.
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
|
||||
You can add your test to one of the existing suites if suitable, or create a new file that specifies a new test suite.
|
||||
|
||||
24
sasjs-tests/package-lock.json
generated
24
sasjs-tests/package-lock.json
generated
@@ -1357,9 +1357,9 @@
|
||||
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
|
||||
},
|
||||
"@sasjs/adapter": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-1.2.0.tgz",
|
||||
"integrity": "sha512-PcQcmb7TsfPJ94tzFnvycm+tMYD3wKx2a6niwHfsV9+g6XHtmwReVV3EPZZ5XB4s565vU6Qc+ZnFbMIAeik8QA==",
|
||||
"version": "1.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-1.3.13.tgz",
|
||||
"integrity": "sha512-dWcDxgY3FB7Yx1I5dPpeQeyJDu4lezhIFrjn6lbdwRhV15aqOt4l9o9qZP+VbgOXqyi9gN0Y+p+vs2chBDFQqg==",
|
||||
"requires": {
|
||||
"es6-promise": "^4.2.8",
|
||||
"form-data": "^3.0.0",
|
||||
@@ -1379,9 +1379,9 @@
|
||||
}
|
||||
},
|
||||
"@sasjs/test-framework": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/test-framework/-/test-framework-1.3.3.tgz",
|
||||
"integrity": "sha512-Ou4UXlxBAVR8jv7boVvJ/eKLHRTQvDi9LouPAasLCO2EC4AD0wX1hLMwVhmydCvsdgVEeXs6InvX3ROHiKSADg==",
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/test-framework/-/test-framework-1.4.0.tgz",
|
||||
"integrity": "sha512-Pd8PUH5B5RO6q4w3OQXX7aWicvA/CJMXA/FCf2xp332ZTKBb/5uV+HphAOFKpCh58y+ykYYVSV0ZaDO/4t1h3A==",
|
||||
"requires": {
|
||||
"@types/react-highlight.js": "^1.0.0",
|
||||
"immer": "^7.0.7",
|
||||
@@ -12234,9 +12234,9 @@
|
||||
}
|
||||
},
|
||||
"semantic-ui-react": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-1.1.1.tgz",
|
||||
"integrity": "sha512-QtzLNkK4MUe1HQo4S7/tIkSp4NFtxSGDzTMKxmvztMJ6jt+nKGmMyjpyxJsrm3ohU8Z3sTyBUyiBsDYW4jNtjw==",
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-1.2.0.tgz",
|
||||
"integrity": "sha512-9tNL94nEy16RdupTQNiURyemWUIxtTpQgFimCbOOHRBOe1ApsFz3FWFsrGjv9zFtE7dQMslLYov9BQOelTCVwA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.10.5",
|
||||
"@semantic-ui-react/event-stack": "^3.1.0",
|
||||
@@ -12260,9 +12260,9 @@
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.19",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
|
||||
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ=="
|
||||
"version": "4.17.20",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
|
||||
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"homepage": ".",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@sasjs/adapter": "^1.2.0",
|
||||
"@sasjs/test-framework": "^1.3.3",
|
||||
"@sasjs/adapter": "^1.3.13",
|
||||
"@sasjs/test-framework": "^1.4.0",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
@@ -25,7 +25,9 @@
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"deploy": "cd .. && npm run package:lib && cd sasjs-tests && npm i ../build/sasjs-adapter-5.0.0.tgz && npm run build && rsync -avhe ssh ./build/* --delete kriaco@sas.analytium.co.uk:/var/www/html/kriaco/sasjs-tests"
|
||||
"update:adapter": "cd .. && npm run package:lib && cd sasjs-tests && npm i ../build/sasjs-adapter-5.0.0.tgz",
|
||||
"deploy:tests": "npm run build && rsync -avhe ssh ./build/* --delete $SSH_ACCOUNT:$DEPLOY_PATH",
|
||||
"deploy": "npm run update:adapter && npm run deploy:tests"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import App from './App';
|
||||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import App from "./App";
|
||||
|
||||
test('renders learn react link', () => {
|
||||
test("renders learn react link", () => {
|
||||
const { getByText } = render(<App />);
|
||||
const linkElement = getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
|
||||
@@ -17,7 +17,7 @@ const App = (): ReactElement<{}> => {
|
||||
sendArrTests(adapter),
|
||||
sendObjTests(adapter),
|
||||
specialCaseTests(adapter),
|
||||
sasjsRequestTests(adapter),
|
||||
sasjsRequestTests(adapter)
|
||||
]);
|
||||
}
|
||||
}, [adapter, config]);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
||||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
||||
sans-serif;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
|
||||
"Droid Sans", "Helvetica Neue", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
background-color: #1f2027;
|
||||
@@ -10,8 +9,7 @@ body {
|
||||
}
|
||||
|
||||
* {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||
monospace;
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||
}
|
||||
|
||||
input {
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
// opt-in, read https://bit.ly/CRA-PWA
|
||||
|
||||
const isLocalhost = Boolean(
|
||||
window.location.hostname === 'localhost' ||
|
||||
window.location.hostname === "localhost" ||
|
||||
// [::1] is the IPv6 localhost address.
|
||||
window.location.hostname === '[::1]' ||
|
||||
window.location.hostname === "[::1]" ||
|
||||
// 127.0.0.0/8 are considered localhost for IPv4.
|
||||
window.location.hostname.match(
|
||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||
@@ -21,7 +21,7 @@ const isLocalhost = Boolean(
|
||||
);
|
||||
|
||||
export function register(config) {
|
||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
|
||||
// The URL constructor is available in all browsers that support SW.
|
||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
||||
if (publicUrl.origin !== window.location.origin) {
|
||||
@@ -31,7 +31,7 @@ export function register(config) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
window.addEventListener("load", () => {
|
||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||
|
||||
if (isLocalhost) {
|
||||
@@ -42,8 +42,8 @@ export function register(config) {
|
||||
// service worker/PWA documentation.
|
||||
navigator.serviceWorker.ready.then(() => {
|
||||
console.log(
|
||||
'This web app is being served cache-first by a service ' +
|
||||
'worker. To learn more, visit https://bit.ly/CRA-PWA'
|
||||
"This web app is being served cache-first by a service " +
|
||||
"worker. To learn more, visit https://bit.ly/CRA-PWA"
|
||||
);
|
||||
});
|
||||
} else {
|
||||
@@ -57,21 +57,21 @@ export function register(config) {
|
||||
function registerValidSW(swUrl, config) {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then(registration => {
|
||||
.then((registration) => {
|
||||
registration.onupdatefound = () => {
|
||||
const installingWorker = registration.installing;
|
||||
if (installingWorker == null) {
|
||||
return;
|
||||
}
|
||||
installingWorker.onstatechange = () => {
|
||||
if (installingWorker.state === 'installed') {
|
||||
if (installingWorker.state === "installed") {
|
||||
if (navigator.serviceWorker.controller) {
|
||||
// At this point, the updated precached content has been fetched,
|
||||
// but the previous service worker will still serve the older
|
||||
// content until all client tabs are closed.
|
||||
console.log(
|
||||
'New content is available and will be used when all ' +
|
||||
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
|
||||
"New content is available and will be used when all " +
|
||||
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
|
||||
);
|
||||
|
||||
// Execute callback
|
||||
@@ -82,7 +82,7 @@ function registerValidSW(swUrl, config) {
|
||||
// At this point, everything has been precached.
|
||||
// It's the perfect time to display a
|
||||
// "Content is cached for offline use." message.
|
||||
console.log('Content is cached for offline use.');
|
||||
console.log("Content is cached for offline use.");
|
||||
|
||||
// Execute callback
|
||||
if (config && config.onSuccess) {
|
||||
@@ -93,25 +93,25 @@ function registerValidSW(swUrl, config) {
|
||||
};
|
||||
};
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error during service worker registration:', error);
|
||||
.catch((error) => {
|
||||
console.error("Error during service worker registration:", error);
|
||||
});
|
||||
}
|
||||
|
||||
function checkValidServiceWorker(swUrl, config) {
|
||||
// Check if the service worker can be found. If it can't reload the page.
|
||||
fetch(swUrl, {
|
||||
headers: { 'Service-Worker': 'script' },
|
||||
headers: { "Service-Worker": "script" }
|
||||
})
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
// Ensure service worker exists, and that we really are getting a JS file.
|
||||
const contentType = response.headers.get('content-type');
|
||||
const contentType = response.headers.get("content-type");
|
||||
if (
|
||||
response.status === 404 ||
|
||||
(contentType != null && contentType.indexOf('javascript') === -1)
|
||||
(contentType != null && contentType.indexOf("javascript") === -1)
|
||||
) {
|
||||
// No service worker found. Probably a different app. Reload the page.
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
registration.unregister().then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
@@ -123,18 +123,18 @@ function checkValidServiceWorker(swUrl, config) {
|
||||
})
|
||||
.catch(() => {
|
||||
console.log(
|
||||
'No internet connection found. App is running in offline mode.'
|
||||
"No internet connection found. App is running in offline mode."
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function unregister() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.ready
|
||||
.then(registration => {
|
||||
.then((registration) => {
|
||||
registration.unregister();
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.error(error.message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
|
||||
@@ -9,7 +9,7 @@ const defaultConfig: SASjsConfig = {
|
||||
serverType: ServerType.SASViya,
|
||||
debug: true,
|
||||
contextName: "SAS Job Execution compute context",
|
||||
useComputeApi: false,
|
||||
useComputeApi: false
|
||||
};
|
||||
|
||||
const customConfig = {
|
||||
@@ -18,7 +18,7 @@ const customConfig = {
|
||||
pathSASViya: "viya",
|
||||
appLoc: "/Public/seedapp",
|
||||
serverType: ServerType.SAS9,
|
||||
debug: false,
|
||||
debug: false
|
||||
};
|
||||
|
||||
export const basicTests = (
|
||||
@@ -35,7 +35,7 @@ export const basicTests = (
|
||||
return adapter.logIn(userName, password);
|
||||
},
|
||||
assertion: (response: any) =>
|
||||
response && response.isLoggedIn && response.userName === userName,
|
||||
response && response.isLoggedIn && response.userName === userName
|
||||
},
|
||||
{
|
||||
title: "Default config",
|
||||
@@ -54,7 +54,7 @@ export const basicTests = (
|
||||
sasjsConfig.serverType === defaultConfig.serverType &&
|
||||
sasjsConfig.debug === defaultConfig.debug
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Custom config",
|
||||
@@ -72,7 +72,7 @@ export const basicTests = (
|
||||
sasjsConfig.serverType === customConfig.serverType &&
|
||||
sasjsConfig.debug === customConfig.debug
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Config overrides",
|
||||
@@ -92,7 +92,7 @@ export const basicTests = (
|
||||
sasjsConfig.serverType === defaultConfig.serverType &&
|
||||
sasjsConfig.debug === false
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { TestSuite } from "@sasjs/test-framework";
|
||||
const stringData: any = { table1: [{ col1: "first col value" }] };
|
||||
const numericData: any = { table1: [{ col1: 3.14159265 }] };
|
||||
const multiColumnData: any = {
|
||||
table1: [{ col1: 42, col2: 1.618, col3: "x", col4: "x" }],
|
||||
table1: [{ col1: 42, col2: 1.618, col3: "x", col4: "x" }]
|
||||
};
|
||||
const multipleRowsWithNulls: any = {
|
||||
table1: [
|
||||
@@ -12,8 +12,8 @@ const multipleRowsWithNulls: any = {
|
||||
{ col1: 42, col2: null, col3: "x", col4: "" },
|
||||
{ col1: 42, col2: null, col3: "x", col4: "" },
|
||||
{ col1: 42, col2: 1.62, col3: "x", col4: "x" },
|
||||
{ col1: 42, col2: 1.62, col3: "x", col4: "x" },
|
||||
],
|
||||
{ col1: 42, col2: 1.62, col3: "x", col4: "x" }
|
||||
]
|
||||
};
|
||||
const multipleColumnsWithNulls: any = {
|
||||
table1: [
|
||||
@@ -21,8 +21,8 @@ const multipleColumnsWithNulls: any = {
|
||||
{ col1: 42, col2: null, col3: "x", col4: null },
|
||||
{ col1: 42, col2: null, col3: "x", col4: null },
|
||||
{ col1: 42, col2: null, col3: "x", col4: "" },
|
||||
{ col1: 42, col2: null, col3: "x", col4: "" },
|
||||
],
|
||||
{ col1: 42, col2: null, col3: "x", col4: "" }
|
||||
]
|
||||
};
|
||||
|
||||
const getLongStringData = (length = 32764) => {
|
||||
@@ -55,7 +55,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
},
|
||||
assertion: (res: any) => {
|
||||
return res.table1[0][0] === stringData.table1[0].col1;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Long string value",
|
||||
@@ -67,7 +67,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
assertion: (res: any) => {
|
||||
const longStringData = getLongStringData();
|
||||
return res.table1[0][0] === longStringData.table1[0].col1;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Overly long string value",
|
||||
@@ -79,7 +79,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.MESSAGE;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Single numeric value",
|
||||
@@ -89,7 +89,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
},
|
||||
assertion: (res: any) => {
|
||||
return res.table1[0][0] === numericData.table1[0].col1;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Multiple columns",
|
||||
@@ -104,7 +104,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table1[0][2] === multiColumnData.table1[0].col3 &&
|
||||
res.table1[0][3] === multiColumnData.table1[0].col4
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Multiple rows with nulls",
|
||||
@@ -129,7 +129,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table1[index][3] === multipleRowsWithNulls.table1[index].col4;
|
||||
});
|
||||
return result;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Multiple columns with nulls",
|
||||
@@ -158,9 +158,9 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
(multipleColumnsWithNulls.table1[index].col4 || "");
|
||||
});
|
||||
return result;
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
@@ -171,11 +171,11 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
description: "Should throw an error",
|
||||
test: async () => {
|
||||
const invalidData: any = {
|
||||
"1 invalid table": [{ col1: 42 }],
|
||||
"1 invalid table": [{ col1: 42 }]
|
||||
};
|
||||
return adapter.request("common/sendObj", invalidData).catch((e) => e);
|
||||
},
|
||||
assertion: (error: any) => !!error && !!error.MESSAGE,
|
||||
assertion: (error: any) => !!error && !!error.MESSAGE
|
||||
},
|
||||
{
|
||||
title: "Single string value",
|
||||
@@ -185,7 +185,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
},
|
||||
assertion: (res: any) => {
|
||||
return res.table1[0].COL1 === stringData.table1[0].col1;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Long string value",
|
||||
@@ -197,7 +197,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
assertion: (res: any) => {
|
||||
const longStringData = getLongStringData();
|
||||
return res.table1[0].COL1 === longStringData.table1[0].col1;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Overly long string value",
|
||||
@@ -210,7 +210,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.MESSAGE;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Single numeric value",
|
||||
@@ -220,7 +220,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
},
|
||||
assertion: (res: any) => {
|
||||
return res.table1[0].COL1 === numericData.table1[0].col1;
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
@@ -232,7 +232,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
assertion: (res: any) => {
|
||||
const data = getLargeObjectData();
|
||||
return res.table1[9000].BIG === data.table1[9000].big;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Multiple columns",
|
||||
@@ -247,7 +247,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table1[0].COL3 === multiColumnData.table1[0].col3 &&
|
||||
res.table1[0].COL4 === multiColumnData.table1[0].col4
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Multiple rows with nulls",
|
||||
@@ -272,7 +272,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table1[index].COL4 === multipleRowsWithNulls.table1[index].col4;
|
||||
});
|
||||
return result;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Multiple columns with nulls",
|
||||
@@ -301,7 +301,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
(multipleColumnsWithNulls.table1[index].col4 || "");
|
||||
});
|
||||
return result;
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -19,7 +19,32 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
|
||||
} else {
|
||||
return requests[0].SASWORK === null;
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
],
|
||||
{
|
||||
title: "Make error and capture log",
|
||||
description: "Should make an error and capture log",
|
||||
test: async () => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
adapter
|
||||
.request("common/makeErr", data)
|
||||
.then((res) => {
|
||||
//no action here, this request must throw error
|
||||
})
|
||||
.catch((err) => {
|
||||
let sasRequests = adapter.getSasRequests();
|
||||
let makeErrRequest =
|
||||
sasRequests.find((req) =>
|
||||
req.serviceLink.includes("makeErr")
|
||||
) || null;
|
||||
|
||||
resolve(!!makeErrRequest);
|
||||
});
|
||||
});
|
||||
},
|
||||
assertion: (response) => {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -13,9 +13,9 @@ const specialCharData: any = {
|
||||
doubleQuote: '"',
|
||||
crlf: "\r\n",
|
||||
euro: "€euro",
|
||||
banghash: "!#banghash",
|
||||
},
|
||||
],
|
||||
banghash: "!#banghash"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const moreSpecialCharData: any = {
|
||||
@@ -31,9 +31,9 @@ const moreSpecialCharData: any = {
|
||||
sigma: "Σsigma",
|
||||
at: "@at",
|
||||
serbian: "Српски",
|
||||
dollar: "$",
|
||||
},
|
||||
],
|
||||
dollar: "$"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const getWideData = () => {
|
||||
@@ -43,7 +43,7 @@ const getWideData = () => {
|
||||
}
|
||||
|
||||
const data: any = {
|
||||
table1: [cols],
|
||||
table1: [cols]
|
||||
};
|
||||
|
||||
return data;
|
||||
@@ -67,7 +67,7 @@ const getLargeDataset = () => {
|
||||
}
|
||||
|
||||
const data: any = {
|
||||
table1: rows,
|
||||
table1: rows
|
||||
};
|
||||
|
||||
return data;
|
||||
@@ -75,7 +75,7 @@ const getLargeDataset = () => {
|
||||
|
||||
const errorAndCsrfData: any = {
|
||||
error: [{ col1: "q", col2: "w", col3: "e", col4: "r" }],
|
||||
_csrf: [{ col1: "q", col2: "w", col3: "e", col4: "r" }],
|
||||
_csrf: [{ col1: "q", col2: "w", col3: "e", col4: "r" }]
|
||||
};
|
||||
|
||||
export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
@@ -100,7 +100,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table1[0][8] === specialCharData.table1[0].euro &&
|
||||
res.table1[0][9] === specialCharData.table1[0].banghash
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Other special characters",
|
||||
@@ -122,7 +122,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table1[0][9] === moreSpecialCharData.table1[0].serbian &&
|
||||
res.table1[0][10] === moreSpecialCharData.table1[0].dollar
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Wide table with sendArr",
|
||||
@@ -138,7 +138,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
result && res.table1[0][i] === data.table1[0]["col" + (i + 1)];
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Wide table with sendObj",
|
||||
@@ -155,7 +155,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table1[0]["COL" + (i + 1)] === data.table1[0]["col" + (i + 1)];
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Multiple tables",
|
||||
@@ -175,7 +175,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
res.table50[0][2] === data.table50[0].col3 &&
|
||||
res.table50[0][3] === data.table50[0].col4
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Large dataset with sendObj",
|
||||
@@ -190,7 +190,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
result = result && res.table1[i][0] === data.table1[i][0];
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Large dataset with sendArr",
|
||||
@@ -206,7 +206,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
result && res.table1[i][0] === Object.values(data.table1[i])[0];
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Error and _csrf tables with sendArr",
|
||||
@@ -225,7 +225,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
res._csrf[0][2] === errorAndCsrfData._csrf[0].col3 &&
|
||||
res._csrf[0][3] === errorAndCsrfData._csrf[0].col4
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Error and _csrf tables with sendObj",
|
||||
@@ -244,7 +244,7 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
res._csrf[0].COL3 === errorAndCsrfData._csrf[0].col3 &&
|
||||
res._csrf[0].COL4 === errorAndCsrfData._csrf[0].col4
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -1,97 +1,100 @@
|
||||
import { isLogInRequired, needsRetry } from "./utils";
|
||||
import { CsrfToken } from "./types/CsrfToken";
|
||||
import { UploadFile } from "./types/UploadFile";
|
||||
import { isLogInRequired, needsRetry } from './utils'
|
||||
import { CsrfToken } from './types/CsrfToken'
|
||||
import { UploadFile } from './types/UploadFile'
|
||||
|
||||
const requestRetryLimit = 5;
|
||||
const requestRetryLimit = 5
|
||||
|
||||
export class FileUploader {
|
||||
constructor(
|
||||
private appLoc: string,
|
||||
private serverUrl: string,
|
||||
private jobsPath: string,
|
||||
private setCsrfTokenWeb: any,
|
||||
private csrfToken: CsrfToken | null = null
|
||||
) {}
|
||||
private retryCount = 0;
|
||||
private retryCount = 0
|
||||
|
||||
public uploadFile(sasJob: string, files: UploadFile[], params: any) {
|
||||
if (files?.length < 1) throw new Error("Atleast one file must be provided");
|
||||
if (files?.length < 1) throw new Error('Atleast one file must be provided')
|
||||
|
||||
let paramsString = "";
|
||||
let paramsString = ''
|
||||
|
||||
for (let param in params) {
|
||||
if (params.hasOwnProperty(param)) {
|
||||
paramsString += `&${param}=${params[param]}`;
|
||||
paramsString += `&${param}=${params[param]}`
|
||||
}
|
||||
}
|
||||
|
||||
const program = this.appLoc
|
||||
? this.appLoc.replace(/\/?$/, "/") + sasJob.replace(/^\//, "")
|
||||
: sasJob;
|
||||
? this.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
||||
: sasJob
|
||||
const uploadUrl = `${this.serverUrl}${this.jobsPath}/?${
|
||||
"_program=" + program
|
||||
}${paramsString}`;
|
||||
'_program=' + program
|
||||
}${paramsString}`
|
||||
|
||||
const headers = {
|
||||
"cache-control": "no-cache",
|
||||
};
|
||||
'cache-control': 'no-cache'
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const formData = new FormData();
|
||||
const formData = new FormData()
|
||||
|
||||
for (let file of files) {
|
||||
formData.append("file", file.file, file.fileName);
|
||||
formData.append('file', file.file, file.fileName)
|
||||
}
|
||||
|
||||
if (this.csrfToken) formData.append("_csrf", this.csrfToken.value);
|
||||
if (this.csrfToken) formData.append('_csrf', this.csrfToken.value)
|
||||
|
||||
fetch(uploadUrl, {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
referrerPolicy: "same-origin",
|
||||
headers,
|
||||
referrerPolicy: 'same-origin',
|
||||
headers
|
||||
})
|
||||
.then(async (response) => {
|
||||
if (!response.ok) {
|
||||
if (response.status === 403) {
|
||||
const tokenHeader = response.headers.get("X-CSRF-HEADER");
|
||||
const tokenHeader = response.headers.get('X-CSRF-HEADER')
|
||||
|
||||
if (tokenHeader) {
|
||||
const token = response.headers.get(tokenHeader);
|
||||
const token = response.headers.get(tokenHeader)
|
||||
this.csrfToken = {
|
||||
headerName: tokenHeader,
|
||||
value: token || "",
|
||||
};
|
||||
value: token || ''
|
||||
}
|
||||
|
||||
this.setCsrfTokenWeb(this.csrfToken)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response.text();
|
||||
return response.text()
|
||||
})
|
||||
.then((responseText) => {
|
||||
if (isLogInRequired(responseText))
|
||||
reject("You must be logged in to upload a fle");
|
||||
reject('You must be logged in to upload a fle')
|
||||
|
||||
if (needsRetry(responseText)) {
|
||||
if (this.retryCount < requestRetryLimit) {
|
||||
this.retryCount++;
|
||||
this.retryCount++
|
||||
this.uploadFile(sasJob, files, params).then(
|
||||
(res: any) => resolve(res),
|
||||
(err: any) => reject(err)
|
||||
);
|
||||
)
|
||||
} else {
|
||||
this.retryCount = 0;
|
||||
reject(responseText);
|
||||
this.retryCount = 0
|
||||
reject(responseText)
|
||||
}
|
||||
} else {
|
||||
this.retryCount = 0;
|
||||
this.retryCount = 0
|
||||
|
||||
try {
|
||||
resolve(JSON.parse(responseText));
|
||||
resolve(JSON.parse(responseText))
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
reject(e)
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ export class SAS9ApiClient {
|
||||
*/
|
||||
public getConfig() {
|
||||
return {
|
||||
serverUrl: this.serverUrl,
|
||||
};
|
||||
serverUrl: this.serverUrl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ export class SAS9ApiClient {
|
||||
* @param serverUrl - the URL of the server.
|
||||
*/
|
||||
public setConfig(serverUrl: string) {
|
||||
if (serverUrl) this.serverUrl = serverUrl;
|
||||
if (serverUrl) this.serverUrl = serverUrl
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,19 +33,19 @@ export class SAS9ApiClient {
|
||||
serverName: string,
|
||||
repositoryName: string
|
||||
) {
|
||||
const requestPayload = linesOfCode.join("\n");
|
||||
const requestPayload = linesOfCode.join('\n')
|
||||
const executeScriptRequest = {
|
||||
method: "PUT",
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
Accept: 'application/json'
|
||||
},
|
||||
body: `command=${requestPayload}`,
|
||||
};
|
||||
body: `command=${requestPayload}`
|
||||
}
|
||||
const executeScriptResponse = await fetch(
|
||||
`${this.serverUrl}/sas/servers/${serverName}/cmd?repositoryName=${repositoryName}`,
|
||||
executeScriptRequest
|
||||
).then((res) => res.text());
|
||||
).then((res) => res.text())
|
||||
|
||||
return executeScriptResponse;
|
||||
return executeScriptResponse
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,36 +1,36 @@
|
||||
import SASjs from "./index";
|
||||
import SASjs from './index'
|
||||
|
||||
const adapter = new SASjs();
|
||||
const adapter = new SASjs()
|
||||
|
||||
it("should parse SAS9 source code", async done => {
|
||||
expect(sampleResponse).toBeTruthy();
|
||||
const parsedSourceCode = (adapter as any).parseSAS9SourceCode(sampleResponse);
|
||||
expect(parsedSourceCode).toBeTruthy();
|
||||
const sourceCodeLines = parsedSourceCode.split("\r\n");
|
||||
expect(sourceCodeLines.length).toEqual(5);
|
||||
expect(sourceCodeLines[0].startsWith("6")).toBeTruthy();
|
||||
expect(sourceCodeLines[1].startsWith("7")).toBeTruthy();
|
||||
expect(sourceCodeLines[2].startsWith("8")).toBeTruthy();
|
||||
expect(sourceCodeLines[3].startsWith("9")).toBeTruthy();
|
||||
expect(sourceCodeLines[4].startsWith("10")).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
it('should parse SAS9 source code', async (done) => {
|
||||
expect(sampleResponse).toBeTruthy()
|
||||
const parsedSourceCode = (adapter as any).parseSAS9SourceCode(sampleResponse)
|
||||
expect(parsedSourceCode).toBeTruthy()
|
||||
const sourceCodeLines = parsedSourceCode.split('\r\n')
|
||||
expect(sourceCodeLines.length).toEqual(5)
|
||||
expect(sourceCodeLines[0].startsWith('6')).toBeTruthy()
|
||||
expect(sourceCodeLines[1].startsWith('7')).toBeTruthy()
|
||||
expect(sourceCodeLines[2].startsWith('8')).toBeTruthy()
|
||||
expect(sourceCodeLines[3].startsWith('9')).toBeTruthy()
|
||||
expect(sourceCodeLines[4].startsWith('10')).toBeTruthy()
|
||||
done()
|
||||
})
|
||||
|
||||
it("should parse generated code", async done => {
|
||||
expect(sampleResponse).toBeTruthy();
|
||||
it('should parse generated code', async (done) => {
|
||||
expect(sampleResponse).toBeTruthy()
|
||||
const parsedGeneratedCode = (adapter as any).parseGeneratedCode(
|
||||
sampleResponse
|
||||
);
|
||||
expect(parsedGeneratedCode).toBeTruthy();
|
||||
const generatedCodeLines = parsedGeneratedCode.split("\r\n");
|
||||
expect(generatedCodeLines.length).toEqual(5);
|
||||
expect(generatedCodeLines[0].startsWith("MPRINT(MM_WEBIN)")).toBeTruthy();
|
||||
expect(generatedCodeLines[1].startsWith("MPRINT(MM_WEBLEFT)")).toBeTruthy();
|
||||
expect(generatedCodeLines[2].startsWith("MPRINT(MM_WEBOUT)")).toBeTruthy();
|
||||
expect(generatedCodeLines[3].startsWith("MPRINT(MM_WEBRIGHT)")).toBeTruthy();
|
||||
expect(generatedCodeLines[4].startsWith("MPRINT(MM_WEBOUT)")).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
)
|
||||
expect(parsedGeneratedCode).toBeTruthy()
|
||||
const generatedCodeLines = parsedGeneratedCode.split('\r\n')
|
||||
expect(generatedCodeLines.length).toEqual(5)
|
||||
expect(generatedCodeLines[0].startsWith('MPRINT(MM_WEBIN)')).toBeTruthy()
|
||||
expect(generatedCodeLines[1].startsWith('MPRINT(MM_WEBLEFT)')).toBeTruthy()
|
||||
expect(generatedCodeLines[2].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy()
|
||||
expect(generatedCodeLines[3].startsWith('MPRINT(MM_WEBRIGHT)')).toBeTruthy()
|
||||
expect(generatedCodeLines[4].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy()
|
||||
done()
|
||||
})
|
||||
|
||||
/* tslint:disable */
|
||||
const sampleResponse = `<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
|
||||
@@ -44,5 +44,5 @@ MPRINT(MM_WEBLEFT): filename _temp temp lrecl=999999;
|
||||
MPRINT(MM_WEBOUT): data _null_;
|
||||
MPRINT(MM_WEBRIGHT): file _temp;
|
||||
MPRINT(MM_WEBOUT): if upcase(symget('_debug'))='LOG' then put '>>weboutBEGIN<<';
|
||||
`;
|
||||
`
|
||||
/* tslint:enable */
|
||||
|
||||
794
src/SASjs.ts
794
src/SASjs.ts
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
import { Session, Context, CsrfToken } from "./types";
|
||||
import { asyncForEach, makeRequest } from "./utils";
|
||||
import { Session, Context, CsrfToken } from './types'
|
||||
import { asyncForEach, makeRequest } from './utils'
|
||||
|
||||
const MAX_SESSION_COUNT = 1;
|
||||
const MAX_SESSION_COUNT = 1
|
||||
|
||||
export class SessionManager {
|
||||
constructor(
|
||||
@@ -9,93 +9,103 @@ export class SessionManager {
|
||||
private contextName: string,
|
||||
private setCsrfToken: (csrfToken: CsrfToken) => void
|
||||
) {}
|
||||
private sessions: Session[] = [];
|
||||
private currentContext: Context | null = null;
|
||||
private csrfToken: CsrfToken | null = null;
|
||||
private sessions: Session[] = []
|
||||
private currentContext: Context | null = null
|
||||
private csrfToken: CsrfToken | null = null
|
||||
|
||||
async getSession(accessToken?: string) {
|
||||
await this.createSessions(accessToken);
|
||||
this.createAndWaitForSession(accessToken);
|
||||
const session = this.sessions.pop();
|
||||
return session;
|
||||
await this.createSessions(accessToken)
|
||||
this.createAndWaitForSession(accessToken)
|
||||
const session = this.sessions.pop()
|
||||
const secondsSinceSessionCreation =
|
||||
(new Date().getTime() - new Date(session!.creationTimeStamp).getTime()) /
|
||||
1000
|
||||
if (
|
||||
secondsSinceSessionCreation >= session!.attributes.sessionInactiveTimeout
|
||||
) {
|
||||
await this.createSessions(accessToken)
|
||||
const freshSession = this.sessions.pop()
|
||||
return freshSession
|
||||
}
|
||||
return session
|
||||
}
|
||||
|
||||
async clearSession(id: string, accessToken?: string) {
|
||||
const deleteSessionRequest = {
|
||||
method: "DELETE",
|
||||
headers: this.getHeaders(accessToken),
|
||||
};
|
||||
method: 'DELETE',
|
||||
headers: this.getHeaders(accessToken)
|
||||
}
|
||||
return await this.request<Session>(
|
||||
`${this.serverUrl}/compute/sessions/${id}`,
|
||||
deleteSessionRequest
|
||||
).then(() => {
|
||||
this.sessions = this.sessions.filter((s) => s.id !== id);
|
||||
});
|
||||
this.sessions = this.sessions.filter((s) => s.id !== id)
|
||||
})
|
||||
}
|
||||
|
||||
private async createSessions(accessToken?: string) {
|
||||
if (!this.sessions.length) {
|
||||
if (!this.currentContext) {
|
||||
await this.setCurrentContext(accessToken);
|
||||
await this.setCurrentContext(accessToken)
|
||||
}
|
||||
await asyncForEach(new Array(MAX_SESSION_COUNT), async () => {
|
||||
const createdSession = await this.createAndWaitForSession(accessToken);
|
||||
this.sessions.push(createdSession);
|
||||
});
|
||||
const createdSession = await this.createAndWaitForSession(accessToken)
|
||||
this.sessions.push(createdSession)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private async createAndWaitForSession(accessToken?: string) {
|
||||
const createSessionRequest = {
|
||||
method: "POST",
|
||||
headers: this.getHeaders(accessToken),
|
||||
};
|
||||
method: 'POST',
|
||||
headers: this.getHeaders(accessToken)
|
||||
}
|
||||
const { result: createdSession, etag } = await this.request<Session>(
|
||||
`${this.serverUrl}/compute/contexts/${this.currentContext!.id}/sessions`,
|
||||
createSessionRequest
|
||||
);
|
||||
)
|
||||
|
||||
await this.waitForSession(createdSession, etag);
|
||||
this.sessions.push(createdSession);
|
||||
return createdSession;
|
||||
await this.waitForSession(createdSession, etag)
|
||||
this.sessions.push(createdSession)
|
||||
return createdSession
|
||||
}
|
||||
|
||||
private async setCurrentContext(accessToken?: string) {
|
||||
if (!this.currentContext) {
|
||||
const { result: contexts } = await this.request<{
|
||||
items: Context[];
|
||||
items: Context[]
|
||||
}>(`${this.serverUrl}/compute/contexts`, {
|
||||
headers: this.getHeaders(accessToken),
|
||||
});
|
||||
headers: this.getHeaders(accessToken)
|
||||
})
|
||||
|
||||
const contextsList =
|
||||
contexts && contexts.items && contexts.items.length
|
||||
? contexts.items
|
||||
: [];
|
||||
: []
|
||||
|
||||
const currentContext = contextsList.find(
|
||||
(c: any) => c.name === this.contextName
|
||||
);
|
||||
)
|
||||
|
||||
if (!currentContext) {
|
||||
throw new Error(
|
||||
`The context ${this.contextName} was not found on the server ${this.serverUrl}`
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
this.currentContext = currentContext;
|
||||
this.currentContext = currentContext
|
||||
}
|
||||
}
|
||||
|
||||
private getHeaders(accessToken?: string) {
|
||||
const headers: any = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
if (accessToken) {
|
||||
headers.Authorization = `Bearer ${accessToken}`;
|
||||
headers.Authorization = `Bearer ${accessToken}`
|
||||
}
|
||||
|
||||
return headers;
|
||||
return headers
|
||||
}
|
||||
|
||||
private async waitForSession(
|
||||
@@ -104,57 +114,57 @@ export class SessionManager {
|
||||
accessToken?: string,
|
||||
silent = false
|
||||
) {
|
||||
let sessionState = session.state;
|
||||
let sessionState = session.state
|
||||
const headers: any = {
|
||||
...this.getHeaders(accessToken),
|
||||
"If-None-Match": etag,
|
||||
};
|
||||
const stateLink = session.links.find((l: any) => l.rel === "state");
|
||||
'If-None-Match': etag
|
||||
}
|
||||
const stateLink = session.links.find((l: any) => l.rel === 'state')
|
||||
return new Promise(async (resolve, _) => {
|
||||
if (sessionState === "pending") {
|
||||
if (sessionState === 'pending') {
|
||||
if (stateLink) {
|
||||
if (!silent) {
|
||||
console.log("Polling session status... \n");
|
||||
console.log('Polling session status... \n')
|
||||
}
|
||||
const { result: state } = await this.request<string>(
|
||||
`${this.serverUrl}${stateLink.href}?wait=30`,
|
||||
{
|
||||
headers,
|
||||
headers
|
||||
},
|
||||
"text"
|
||||
);
|
||||
'text'
|
||||
)
|
||||
|
||||
sessionState = state.trim();
|
||||
sessionState = state.trim()
|
||||
if (!silent) {
|
||||
console.log(`Current state: ${sessionState}\n`);
|
||||
console.log(`Current state: ${sessionState}\n`)
|
||||
}
|
||||
resolve(sessionState);
|
||||
resolve(sessionState)
|
||||
}
|
||||
} else {
|
||||
resolve(sessionState);
|
||||
resolve(sessionState)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
private async request<T>(
|
||||
url: string,
|
||||
options: RequestInit,
|
||||
contentType: "text" | "json" = "json"
|
||||
contentType: 'text' | 'json' = 'json'
|
||||
) {
|
||||
if (this.csrfToken) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
[this.csrfToken.headerName]: this.csrfToken.value,
|
||||
};
|
||||
[this.csrfToken.headerName]: this.csrfToken.value
|
||||
}
|
||||
}
|
||||
return await makeRequest<T>(
|
||||
url,
|
||||
options,
|
||||
(token) => {
|
||||
this.csrfToken = token;
|
||||
this.setCsrfToken(token);
|
||||
this.csrfToken = token
|
||||
this.setCsrfToken(token)
|
||||
},
|
||||
contentType
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
10
src/index.ts
10
src/index.ts
@@ -1,5 +1,5 @@
|
||||
import SASjs from "./SASjs";
|
||||
export * from "./types";
|
||||
export * from "./SASViyaApiClient";
|
||||
export * from "./SAS9ApiClient";
|
||||
export default SASjs;
|
||||
import SASjs from './SASjs'
|
||||
export * from './types'
|
||||
export * from './SASViyaApiClient'
|
||||
export * from './SAS9ApiClient'
|
||||
export default SASjs
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export interface Context {
|
||||
name: string;
|
||||
id: string;
|
||||
createdBy: string;
|
||||
version: number;
|
||||
name: string
|
||||
id: string
|
||||
createdBy: string
|
||||
version: number
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface CsrfToken {
|
||||
headerName: string;
|
||||
value: string;
|
||||
headerName: string
|
||||
value: string
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Link } from "./Link";
|
||||
import { Link } from './Link'
|
||||
|
||||
export interface Folder {
|
||||
id: string;
|
||||
uri: string;
|
||||
links: Link[];
|
||||
id: string
|
||||
uri: string
|
||||
links: Link[]
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { Link } from "./Link";
|
||||
import { JobResult } from "./JobResult";
|
||||
import { Link } from './Link'
|
||||
import { JobResult } from './JobResult'
|
||||
|
||||
export interface Job {
|
||||
id: string;
|
||||
name: string;
|
||||
uri: string;
|
||||
createdBy: string;
|
||||
links: Link[];
|
||||
results: JobResult;
|
||||
error?: any;
|
||||
id: string
|
||||
name: string
|
||||
uri: string
|
||||
createdBy: string
|
||||
code?: string
|
||||
links: Link[]
|
||||
results: JobResult
|
||||
error?: any
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface JobDefinition {
|
||||
code: string;
|
||||
code: string
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface JobResult {
|
||||
"_webout.json": string;
|
||||
'_webout.json': string
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export interface Link {
|
||||
method: string;
|
||||
rel: string;
|
||||
href: string;
|
||||
uri: string;
|
||||
type: string;
|
||||
method: string
|
||||
rel: string
|
||||
href: string
|
||||
uri: string
|
||||
type: string
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ServerType } from "./ServerType";
|
||||
import { ServerType } from './ServerType'
|
||||
|
||||
/**
|
||||
* Specifies the configuration for the SASjs instance.
|
||||
@@ -10,22 +10,22 @@ export class SASjsConfig {
|
||||
* Can be omitted, eg if serving directly from the SAS Web Server or being
|
||||
* streamed.
|
||||
*/
|
||||
serverUrl: string = "";
|
||||
pathSAS9: string = "";
|
||||
pathSASViya: string = "";
|
||||
serverUrl: string = ''
|
||||
pathSAS9: string = ''
|
||||
pathSASViya: string = ''
|
||||
/**
|
||||
* The appLoc is the parent folder under which the SAS services (STPs or Job
|
||||
* Execution Services) are stored.
|
||||
*/
|
||||
appLoc: string = "";
|
||||
appLoc: string = ''
|
||||
/**
|
||||
* Can be SAS9 or SASVIYA
|
||||
*/
|
||||
serverType: ServerType | null = null;
|
||||
serverType: ServerType | null = null
|
||||
/**
|
||||
* Set to `true` to enable additional debugging.
|
||||
*/
|
||||
debug: boolean = true;
|
||||
contextName: string = "";
|
||||
useComputeApi = false;
|
||||
debug: boolean = true
|
||||
contextName: string = ''
|
||||
useComputeApi = false
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
*
|
||||
*/
|
||||
export interface SASjsRequest {
|
||||
serviceLink: string;
|
||||
timestamp: Date;
|
||||
sourceCode: string;
|
||||
generatedCode: string;
|
||||
logFile: string;
|
||||
SASWORK: any;
|
||||
serviceLink: string
|
||||
timestamp: Date
|
||||
sourceCode: string
|
||||
generatedCode: string
|
||||
logFile: string
|
||||
SASWORK: any
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*/
|
||||
export interface SASjsWaitingRequest {
|
||||
requestPromise: {
|
||||
promise: any;
|
||||
resolve: any;
|
||||
reject: any;
|
||||
};
|
||||
SASjob: string;
|
||||
data: any;
|
||||
config?: any;
|
||||
promise: any
|
||||
resolve: any
|
||||
reject: any
|
||||
}
|
||||
SASjob: string
|
||||
data: any
|
||||
config?: any
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*
|
||||
*/
|
||||
export enum ServerType {
|
||||
SASViya = "SASVIYA",
|
||||
SAS9 = "SAS9",
|
||||
SASViya = 'SASVIYA',
|
||||
SAS9 = 'SAS9'
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { Link } from "./Link";
|
||||
import { Link } from './Link'
|
||||
|
||||
export interface Session {
|
||||
id: string;
|
||||
state: string;
|
||||
links: Link[];
|
||||
id: string
|
||||
state: string
|
||||
links: Link[]
|
||||
attributes: {
|
||||
sessionInactiveTimeout: number
|
||||
}
|
||||
creationTimeStamp: string
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
export interface UploadFile {
|
||||
file: File;
|
||||
fileName: string;
|
||||
file: File
|
||||
fileName: string
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export * from "./Context";
|
||||
export * from "./CsrfToken";
|
||||
export * from "./Folder";
|
||||
export * from "./Job";
|
||||
export * from "./Link";
|
||||
export * from "./SASjsConfig";
|
||||
export * from "./SASjsRequest";
|
||||
export * from "./SASjsWaitingRequest";
|
||||
export * from "./ServerType";
|
||||
export * from "./Session";
|
||||
export * from "./UploadFile";
|
||||
export * from './Context'
|
||||
export * from './CsrfToken'
|
||||
export * from './Folder'
|
||||
export * from './Job'
|
||||
export * from './Link'
|
||||
export * from './SASjsConfig'
|
||||
export * from './SASjsRequest'
|
||||
export * from './SASjsWaitingRequest'
|
||||
export * from './ServerType'
|
||||
export * from './Session'
|
||||
export * from './UploadFile'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export async function asyncForEach(array: any[], callback: any) {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
await callback(array[index], index, array);
|
||||
await callback(array[index], index, array)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { SASjsRequest } from "../types/SASjsRequest";
|
||||
import { SASjsRequest } from '../types/SASjsRequest'
|
||||
|
||||
/**
|
||||
* Comparator for SASjs request timestamps
|
||||
*
|
||||
*/
|
||||
export const compareTimestamps = (a: SASjsRequest, b: SASjsRequest) => {
|
||||
return b.timestamp.getTime() - a.timestamp.getTime();
|
||||
};
|
||||
return b.timestamp.getTime() - a.timestamp.getTime()
|
||||
}
|
||||
|
||||
@@ -3,131 +3,131 @@
|
||||
* @param data - the JSON object to convert.
|
||||
*/
|
||||
export const convertToCSV = (data: any) => {
|
||||
const replacer = (key: any, value: any) => (value === null ? "" : value);
|
||||
const headerFields = Object.keys(data[0]);
|
||||
let csvTest;
|
||||
let invalidString = false;
|
||||
const replacer = (key: any, value: any) => (value === null ? '' : value)
|
||||
const headerFields = Object.keys(data[0])
|
||||
let csvTest
|
||||
let invalidString = false
|
||||
const headers = headerFields.map((field) => {
|
||||
let firstFoundType: string | null = null;
|
||||
let hasMixedTypes: boolean = false;
|
||||
let rowNumError: number = -1;
|
||||
let firstFoundType: string | null = null
|
||||
let hasMixedTypes: boolean = false
|
||||
let rowNumError: number = -1
|
||||
|
||||
const longestValueForField = data
|
||||
.map((row: any, index: number) => {
|
||||
if (row[field] || row[field] === "") {
|
||||
if (row[field] || row[field] === '') {
|
||||
if (firstFoundType) {
|
||||
let currentFieldType =
|
||||
row[field] === "" || typeof row[field] === "string"
|
||||
? "chars"
|
||||
: "number";
|
||||
row[field] === '' || typeof row[field] === 'string'
|
||||
? 'chars'
|
||||
: 'number'
|
||||
|
||||
if (!hasMixedTypes) {
|
||||
hasMixedTypes = currentFieldType !== firstFoundType;
|
||||
rowNumError = hasMixedTypes ? index + 1 : -1;
|
||||
hasMixedTypes = currentFieldType !== firstFoundType
|
||||
rowNumError = hasMixedTypes ? index + 1 : -1
|
||||
}
|
||||
} else {
|
||||
if (row[field] === "") {
|
||||
firstFoundType = "chars";
|
||||
if (row[field] === '') {
|
||||
firstFoundType = 'chars'
|
||||
} else {
|
||||
firstFoundType =
|
||||
typeof row[field] === "string" ? "chars" : "number";
|
||||
typeof row[field] === 'string' ? 'chars' : 'number'
|
||||
}
|
||||
}
|
||||
|
||||
let byteSize;
|
||||
let byteSize
|
||||
|
||||
if (typeof row[field] === "string") {
|
||||
if (typeof row[field] === 'string') {
|
||||
let doubleQuotesFound = row[field]
|
||||
.split("")
|
||||
.filter((char: any) => char === '"');
|
||||
.split('')
|
||||
.filter((char: any) => char === '"')
|
||||
|
||||
byteSize = getByteSize(row[field]);
|
||||
byteSize = getByteSize(row[field])
|
||||
|
||||
if (doubleQuotesFound.length > 0) {
|
||||
byteSize += doubleQuotesFound.length;
|
||||
byteSize += doubleQuotesFound.length
|
||||
}
|
||||
}
|
||||
|
||||
return byteSize;
|
||||
return byteSize
|
||||
}
|
||||
})
|
||||
.sort((a: number, b: number) => b - a)[0];
|
||||
.sort((a: number, b: number) => b - a)[0]
|
||||
if (longestValueForField && longestValueForField > 32765) {
|
||||
invalidString = true;
|
||||
invalidString = true
|
||||
}
|
||||
if (hasMixedTypes) {
|
||||
console.error(
|
||||
`Row (${rowNumError}), Column (${field}) has mixed types: ERROR`
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
return `${field}:${firstFoundType === "chars" ? "$" : ""}${
|
||||
return `${field}:${firstFoundType === 'chars' ? '$' : ''}${
|
||||
longestValueForField
|
||||
? longestValueForField
|
||||
: firstFoundType === "chars"
|
||||
? "1"
|
||||
: "best"
|
||||
}.`;
|
||||
});
|
||||
: firstFoundType === 'chars'
|
||||
? '1'
|
||||
: 'best'
|
||||
}.`
|
||||
})
|
||||
|
||||
if (invalidString) {
|
||||
return "ERROR: LARGE STRING LENGTH";
|
||||
return 'ERROR: LARGE STRING LENGTH'
|
||||
}
|
||||
csvTest = data.map((row: any) => {
|
||||
const fields = Object.keys(row).map((fieldName, index) => {
|
||||
let value;
|
||||
let containsSpecialChar = false;
|
||||
const currentCell = row[fieldName];
|
||||
let value
|
||||
let containsSpecialChar = false
|
||||
const currentCell = row[fieldName]
|
||||
|
||||
if (JSON.stringify(currentCell).search(/(\\t|\\n|\\r)/gm) > -1) {
|
||||
value = currentCell.toString();
|
||||
containsSpecialChar = true;
|
||||
value = currentCell.toString()
|
||||
containsSpecialChar = true
|
||||
} else {
|
||||
value = JSON.stringify(currentCell, replacer);
|
||||
value = JSON.stringify(currentCell, replacer)
|
||||
}
|
||||
|
||||
value = value.replace(/\\\\/gm, "\\");
|
||||
value = value.replace(/\\\\/gm, '\\')
|
||||
|
||||
if (containsSpecialChar) {
|
||||
if (value.includes(",") || value.includes('"')) {
|
||||
value = '"' + value + '"';
|
||||
if (value.includes(',') || value.includes('"')) {
|
||||
value = '"' + value + '"'
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
!value.includes(",") &&
|
||||
!value.includes(',') &&
|
||||
value.includes('"') &&
|
||||
!value.includes('\\"')
|
||||
) {
|
||||
value = value.substring(1, value.length - 1);
|
||||
value = value.substring(1, value.length - 1)
|
||||
}
|
||||
|
||||
value = value.replace(/\\"/gm, '""');
|
||||
value = value.replace(/\\"/gm, '""')
|
||||
}
|
||||
|
||||
value = value.replace(/\r\n/gm, "\n");
|
||||
value = value.replace(/\r\n/gm, '\n')
|
||||
|
||||
if (value === "" && headers[index].includes("best")) {
|
||||
value = ".";
|
||||
if (value === '' && headers[index].includes('best')) {
|
||||
value = '.'
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
return fields.join(",");
|
||||
});
|
||||
return value
|
||||
})
|
||||
return fields.join(',')
|
||||
})
|
||||
|
||||
let finalCSV =
|
||||
headers.join(",").replace(/,/g, " ") + "\r\n" + csvTest.join("\r\n");
|
||||
headers.join(',').replace(/,/g, ' ') + '\r\n' + csvTest.join('\r\n')
|
||||
|
||||
return finalCSV;
|
||||
};
|
||||
return finalCSV
|
||||
}
|
||||
|
||||
const getByteSize = (str: string) => {
|
||||
let byteSize = str.length;
|
||||
let byteSize = str.length
|
||||
for (let i = str.length - 1; i >= 0; i--) {
|
||||
const code = str.charCodeAt(i);
|
||||
if (code > 0x7f && code <= 0x7ff) byteSize++;
|
||||
else if (code > 0x7ff && code <= 0xffff) byteSize += 2;
|
||||
if (code >= 0xdc00 && code <= 0xdfff) i--; //trail surrogate
|
||||
const code = str.charCodeAt(i)
|
||||
if (code > 0x7f && code <= 0x7ff) byteSize++
|
||||
else if (code > 0x7ff && code <= 0xffff) byteSize += 2
|
||||
if (code >= 0xdc00 && code <= 0xdfff) i-- //trail surrogate
|
||||
}
|
||||
return byteSize;
|
||||
};
|
||||
return byteSize
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
import { convertToCSV } from "./convertToCsv";
|
||||
import { splitChunks } from "./splitChunks";
|
||||
import { convertToCSV } from './convertToCsv'
|
||||
import { splitChunks } from './splitChunks'
|
||||
|
||||
export const formatDataForRequest = (data: any) => {
|
||||
const sasjsTables = [];
|
||||
let tableCounter = 0;
|
||||
const result: any = {};
|
||||
const sasjsTables = []
|
||||
let tableCounter = 0
|
||||
const result: any = {}
|
||||
|
||||
for (const tableName in data) {
|
||||
tableCounter++;
|
||||
sasjsTables.push(tableName);
|
||||
const csv = convertToCSV(data[tableName]);
|
||||
if (csv === "ERROR: LARGE STRING LENGTH") {
|
||||
tableCounter++
|
||||
sasjsTables.push(tableName)
|
||||
const csv = convertToCSV(data[tableName])
|
||||
if (csv === 'ERROR: LARGE STRING LENGTH') {
|
||||
throw new Error(
|
||||
"The max length of a string value in SASjs is 32765 characters."
|
||||
);
|
||||
'The max length of a string value in SASjs is 32765 characters.'
|
||||
)
|
||||
}
|
||||
// if csv has length more then 16k, send in chunks
|
||||
if (csv.length > 16000) {
|
||||
const csvChunks = splitChunks(csv);
|
||||
const csvChunks = splitChunks(csv)
|
||||
// append chunks to form data with same key
|
||||
result[`sasjs${tableCounter}data0`] = csvChunks.length;
|
||||
result[`sasjs${tableCounter}data0`] = csvChunks.length
|
||||
csvChunks.forEach((chunk, index) => {
|
||||
result[`sasjs${tableCounter}data${index + 1}`] = chunk;
|
||||
});
|
||||
result[`sasjs${tableCounter}data${index + 1}`] = chunk
|
||||
})
|
||||
} else {
|
||||
result[`sasjs${tableCounter}data`] = csv;
|
||||
result[`sasjs${tableCounter}data`] = csv
|
||||
}
|
||||
}
|
||||
result["sasjs_tables"] = sasjsTables.join(" ");
|
||||
result['sasjs_tables'] = sasjsTables.join(' ')
|
||||
|
||||
return result;
|
||||
};
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
export * from "./asyncForEach";
|
||||
export * from "./compareTimestamps";
|
||||
export * from "./convertToCsv";
|
||||
export * from "./isAuthorizeFormRequired";
|
||||
export * from "./isLoginRequired";
|
||||
export * from "./isLoginSuccess";
|
||||
export * from "./makeRequest";
|
||||
export * from "./needsRetry";
|
||||
export * from "./parseAndSubmitAuthorizeForm";
|
||||
export * from "./parseGeneratedCode";
|
||||
export * from "./parseSourceCode";
|
||||
export * from "./parseSasViyaLog";
|
||||
export * from "./serialize";
|
||||
export * from "./splitChunks";
|
||||
export * from "./parseWeboutResponse";
|
||||
export * from './asyncForEach'
|
||||
export * from './compareTimestamps'
|
||||
export * from './convertToCsv'
|
||||
export * from './isAuthorizeFormRequired'
|
||||
export * from './isLoginRequired'
|
||||
export * from './isLoginSuccess'
|
||||
export * from './makeRequest'
|
||||
export * from './needsRetry'
|
||||
export * from './parseAndSubmitAuthorizeForm'
|
||||
export * from './parseGeneratedCode'
|
||||
export * from './parseSourceCode'
|
||||
export * from './parseSasViyaLog'
|
||||
export * from './serialize'
|
||||
export * from './splitChunks'
|
||||
export * from './parseWeboutResponse'
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export const isAuthorizeFormRequired = (response: string): boolean => {
|
||||
return /<form.+action="(.*Logon\/oauth\/authorize[^"]*).*>/gm.test(response);
|
||||
};
|
||||
return /<form.+action="(.*Logon\/oauth\/authorize[^"]*).*>/gm.test(response)
|
||||
}
|
||||
|
||||
@@ -1,31 +1,34 @@
|
||||
export function isIEorEdgeOrOldFirefox() {
|
||||
const ua = window.navigator.userAgent;
|
||||
if (typeof window === 'undefined') {
|
||||
return false
|
||||
}
|
||||
const ua = window.navigator.userAgent
|
||||
|
||||
if (ua.indexOf("Firefox") > 0) {
|
||||
if (ua.indexOf('Firefox') > 0) {
|
||||
const version = parseInt(
|
||||
ua.substring(ua.lastIndexOf("Firefox/") + 8, ua.length),
|
||||
ua.substring(ua.lastIndexOf('Firefox/') + 8, ua.length),
|
||||
10
|
||||
);
|
||||
return version <= 60;
|
||||
)
|
||||
return version <= 60
|
||||
}
|
||||
|
||||
const msie = ua.indexOf("MSIE ");
|
||||
const msie = ua.indexOf('MSIE ')
|
||||
if (msie > 0) {
|
||||
// IE 10 or older => return version number
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
const trident = ua.indexOf("Trident/");
|
||||
const trident = ua.indexOf('Trident/')
|
||||
if (trident > 0) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
const edge = ua.indexOf("Edge/");
|
||||
const edge = ua.indexOf('Edge/')
|
||||
if (edge > 0) {
|
||||
// Edge (IE 12+) => return version number
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
// other browser
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const isLogInRequired = (response: string): boolean => {
|
||||
const pattern: RegExp = /<form.+action="(.*Logon[^"]*).*>/gm;
|
||||
const matches = pattern.test(response);
|
||||
return matches;
|
||||
};
|
||||
const pattern: RegExp = /<form.+action="(.*Logon[^"]*).*>/gm
|
||||
const matches = pattern.test(response)
|
||||
return matches
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export const isLogInSuccess = (response: string): boolean =>
|
||||
/You have signed in/gm.test(response);
|
||||
/You have signed in/gm.test(response)
|
||||
|
||||
@@ -1,107 +1,107 @@
|
||||
import { CsrfToken } from "../types";
|
||||
import { needsRetry } from "./needsRetry";
|
||||
import { CsrfToken } from '../types'
|
||||
import { needsRetry } from './needsRetry'
|
||||
|
||||
let retryCount: number = 0;
|
||||
let retryLimit: number = 5;
|
||||
let retryCount: number = 0
|
||||
let retryLimit: number = 5
|
||||
|
||||
export async function makeRequest<T>(
|
||||
url: string,
|
||||
request: RequestInit,
|
||||
callback: (value: CsrfToken) => any,
|
||||
contentType: "text" | "json" = "json"
|
||||
contentType: 'text' | 'json' = 'json'
|
||||
): Promise<{ result: T; etag: string | null }> {
|
||||
let retryRequest: any = null;
|
||||
let retryRequest: any = null
|
||||
|
||||
const responseTransform =
|
||||
contentType === "json"
|
||||
contentType === 'json'
|
||||
? (res: Response) => res.json()
|
||||
: (res: Response) => res.text();
|
||||
let etag = null;
|
||||
: (res: Response) => res.text()
|
||||
let etag = null
|
||||
const result = await fetch(url, request).then(async (response) => {
|
||||
if (response.redirected && response.url.includes("SASLogon/login")) {
|
||||
return Promise.reject({ status: 401 });
|
||||
if (response.redirected && response.url.includes('SASLogon/login')) {
|
||||
return Promise.reject({ status: 401 })
|
||||
}
|
||||
if (!response.ok) {
|
||||
if (response.status === 403) {
|
||||
const tokenHeader = response.headers.get("X-CSRF-HEADER");
|
||||
const tokenHeader = response.headers.get('X-CSRF-HEADER')
|
||||
|
||||
if (tokenHeader) {
|
||||
const token = response.headers.get(tokenHeader);
|
||||
const token = response.headers.get(tokenHeader)
|
||||
callback({
|
||||
headerName: tokenHeader,
|
||||
value: token || "",
|
||||
});
|
||||
value: token || ''
|
||||
})
|
||||
|
||||
retryRequest = {
|
||||
...request,
|
||||
headers: { ...request.headers, [tokenHeader]: token },
|
||||
};
|
||||
headers: { ...request.headers, [tokenHeader]: token }
|
||||
}
|
||||
return fetch(url, retryRequest).then((res) => {
|
||||
etag = res.headers.get("ETag");
|
||||
return responseTransform(res);
|
||||
});
|
||||
etag = res.headers.get('ETag')
|
||||
return responseTransform(res)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const body = await response.text();
|
||||
const body = await response.text()
|
||||
|
||||
if (needsRetry(body)) {
|
||||
if (retryCount < retryLimit) {
|
||||
retryCount++;
|
||||
retryCount++
|
||||
let retryResponse = await makeRequest(
|
||||
url,
|
||||
retryRequest || request,
|
||||
callback,
|
||||
contentType
|
||||
);
|
||||
retryCount = 0;
|
||||
)
|
||||
retryCount = 0
|
||||
|
||||
etag = retryResponse.etag;
|
||||
return retryResponse.result;
|
||||
etag = retryResponse.etag
|
||||
return retryResponse.result
|
||||
} else {
|
||||
retryCount = 0;
|
||||
retryCount = 0
|
||||
|
||||
throw new Error("Request retry limit exceeded");
|
||||
throw new Error('Request retry limit exceeded')
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject({ status: response.status, body });
|
||||
return Promise.reject({ status: response.status, body })
|
||||
}
|
||||
} else {
|
||||
if (response.status === 204) {
|
||||
return Promise.resolve();
|
||||
return Promise.resolve()
|
||||
}
|
||||
const responseTransformed = await responseTransform(response);
|
||||
let responseText = "";
|
||||
const responseTransformed = await responseTransform(response)
|
||||
let responseText = ''
|
||||
|
||||
if (typeof responseTransformed === "string") {
|
||||
responseText = responseTransformed;
|
||||
if (typeof responseTransformed === 'string') {
|
||||
responseText = responseTransformed
|
||||
} else {
|
||||
responseText = JSON.stringify(responseTransformed);
|
||||
responseText = JSON.stringify(responseTransformed)
|
||||
}
|
||||
|
||||
if (needsRetry(responseText)) {
|
||||
if (retryCount < retryLimit) {
|
||||
retryCount++;
|
||||
retryCount++
|
||||
const retryResponse = await makeRequest(
|
||||
url,
|
||||
retryRequest || request,
|
||||
callback,
|
||||
contentType
|
||||
);
|
||||
retryCount = 0;
|
||||
)
|
||||
retryCount = 0
|
||||
|
||||
etag = retryResponse.etag;
|
||||
return retryResponse.result;
|
||||
etag = retryResponse.etag
|
||||
return retryResponse.result
|
||||
} else {
|
||||
retryCount = 0;
|
||||
retryCount = 0
|
||||
|
||||
throw new Error("Request retry limit exceeded");
|
||||
throw new Error('Request retry limit exceeded')
|
||||
}
|
||||
}
|
||||
|
||||
etag = response.headers.get("ETag");
|
||||
return responseTransformed;
|
||||
etag = response.headers.get('ETag')
|
||||
return responseTransformed
|
||||
}
|
||||
});
|
||||
return { result, etag };
|
||||
})
|
||||
return { result, etag }
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ export const needsRetry = (responseText: string): boolean => {
|
||||
return (
|
||||
!!responseText &&
|
||||
((responseText.includes('"errorCode":403') &&
|
||||
responseText.includes("_csrf") &&
|
||||
responseText.includes("X-CSRF-TOKEN")) ||
|
||||
responseText.includes('_csrf') &&
|
||||
responseText.includes('X-CSRF-TOKEN')) ||
|
||||
(responseText.includes('"status":403') &&
|
||||
responseText.includes('"error":"Forbidden"')) ||
|
||||
(responseText.includes('"status":449') &&
|
||||
responseText.includes(
|
||||
"Authentication success, retry original request"
|
||||
'Authentication success, retry original request'
|
||||
)))
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,48 +2,48 @@ export const parseAndSubmitAuthorizeForm = async (
|
||||
response: string,
|
||||
serverUrl: string
|
||||
) => {
|
||||
let authUrl: string | null = null;
|
||||
const params: any = {};
|
||||
let authUrl: string | null = null
|
||||
const params: any = {}
|
||||
|
||||
const responseBody = response.split("<body>")[1].split("</body>")[0];
|
||||
const bodyElement = document.createElement("div");
|
||||
bodyElement.innerHTML = responseBody;
|
||||
const responseBody = response.split('<body>')[1].split('</body>')[0]
|
||||
const bodyElement = document.createElement('div')
|
||||
bodyElement.innerHTML = responseBody
|
||||
|
||||
const form = bodyElement.querySelector("#application_authorization");
|
||||
authUrl = form ? serverUrl + form.getAttribute("action") : null;
|
||||
const form = bodyElement.querySelector('#application_authorization')
|
||||
authUrl = form ? serverUrl + form.getAttribute('action') : null
|
||||
|
||||
const inputs: any = form?.querySelectorAll("input");
|
||||
const inputs: any = form?.querySelectorAll('input')
|
||||
|
||||
for (const input of inputs) {
|
||||
if (input.name === "user_oauth_approval") {
|
||||
input.value = "true";
|
||||
if (input.name === 'user_oauth_approval') {
|
||||
input.value = 'true'
|
||||
}
|
||||
|
||||
params[input.name] = input.value;
|
||||
params[input.name] = input.value
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
const formData = new FormData()
|
||||
|
||||
for (const key in params) {
|
||||
if (params.hasOwnProperty(key)) {
|
||||
formData.append(key, params[key]);
|
||||
formData.append(key, params[key])
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (authUrl) {
|
||||
fetch(authUrl, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
body: formData,
|
||||
referrerPolicy: "same-origin",
|
||||
referrerPolicy: 'same-origin'
|
||||
})
|
||||
.then((res) => res.text())
|
||||
.then((res) => {
|
||||
resolve(res);
|
||||
});
|
||||
resolve(res)
|
||||
})
|
||||
} else {
|
||||
reject("Auth form url is null");
|
||||
reject('Auth form url is null')
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const parseGeneratedCode = (log: string) => {
|
||||
const startsWith = "MPRINT";
|
||||
const startsWith = 'MPRINT'
|
||||
const isGeneratedCodeLine = (line: string) =>
|
||||
line.trim().startsWith(startsWith);
|
||||
const logLines = log.split("\n").filter(isGeneratedCodeLine);
|
||||
return logLines.join("\r\n");
|
||||
};
|
||||
line.trim().startsWith(startsWith)
|
||||
const logLines = log.split('\n').filter(isGeneratedCodeLine)
|
||||
return logLines.join('\r\n')
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
export const parseSasViyaLog = (logResponse: { items: any[] }) => {
|
||||
let log;
|
||||
let log
|
||||
try {
|
||||
log = logResponse.items
|
||||
? logResponse.items.map((i) => i.line).join("\n")
|
||||
: JSON.stringify(logResponse);
|
||||
? logResponse.items.map((i) => i.line).join('\n')
|
||||
: JSON.stringify(logResponse)
|
||||
} catch (e) {
|
||||
console.error("An error has occurred while parsing the log response", e);
|
||||
log = logResponse;
|
||||
console.error('An error has occurred while parsing the log response', e)
|
||||
log = logResponse
|
||||
}
|
||||
return log;
|
||||
};
|
||||
return log
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const parseSourceCode = (log: string): string => {
|
||||
const isSourceCodeLine = (line: string) =>
|
||||
line.trim().substring(0, 10).trimStart().match(/^\d/);
|
||||
const logLines = log.split("\n").filter(isSourceCodeLine);
|
||||
return logLines.join("\r\n");
|
||||
};
|
||||
line.trim().substring(0, 10).trimStart().match(/^\d/)
|
||||
const logLines = log.split('\n').filter(isSourceCodeLine)
|
||||
return logLines.join('\r\n')
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
export const parseWeboutResponse = (response: string) => {
|
||||
let sasResponse = "";
|
||||
let sasResponse = ''
|
||||
|
||||
if (response.includes(">>weboutBEGIN<<")) {
|
||||
try {
|
||||
sasResponse = response
|
||||
.split(">>weboutBEGIN<<")[1]
|
||||
.split(">>weboutEND<<")[0];
|
||||
} catch (e) {
|
||||
sasResponse = "";
|
||||
console.error(e);
|
||||
}
|
||||
if (response.includes('>>weboutBEGIN<<')) {
|
||||
try {
|
||||
sasResponse = response
|
||||
.split('>>weboutBEGIN<<')[1]
|
||||
.split('>>weboutEND<<')[0]
|
||||
} catch (e) {
|
||||
sasResponse = ''
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
return sasResponse;
|
||||
}
|
||||
return sasResponse
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
export const serialize = (obj: any) => {
|
||||
const str: any[] = [];
|
||||
const str: any[] = []
|
||||
for (const p in obj) {
|
||||
if (obj.hasOwnProperty(p)) {
|
||||
if (obj[p] instanceof Array) {
|
||||
for (let i = 0, n = obj[p].length; i < n; i++) {
|
||||
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p][i]));
|
||||
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p][i]))
|
||||
}
|
||||
} else {
|
||||
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
|
||||
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]))
|
||||
}
|
||||
}
|
||||
}
|
||||
return str.join("&");
|
||||
};
|
||||
return str.join('&')
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
export const splitChunks = (content: string) => {
|
||||
const size = 16000;
|
||||
const size = 16000
|
||||
|
||||
const numChunks = Math.ceil(content.length / size);
|
||||
const chunks = new Array(numChunks);
|
||||
const numChunks = Math.ceil(content.length / size)
|
||||
const chunks = new Array(numChunks)
|
||||
|
||||
for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
|
||||
chunks[i] = content.substr(o, size);
|
||||
chunks[i] = content.substr(o, size)
|
||||
}
|
||||
|
||||
return chunks;
|
||||
};
|
||||
return chunks
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user