1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-03 18:50:05 +00:00

Compare commits

...

255 Commits

Author SHA1 Message Date
Krishna Acondy
bfe5ac0ff7 Merge pull request #417 from sasjs/force-sas9-webout
fix(sas9): force webout output when executing arbitrary code on SAS9
2021-06-14 09:17:32 +01:00
Krishna Acondy
d50f5a030a chore(lint): fix formatting 2021-06-14 09:12:11 +01:00
Krishna Acondy
c320caec99 fix(sas9): force webout output when executing arbitrary code on SAS9 2021-06-14 09:10:26 +01:00
Allan Bowe
16a5b2b012 Merge pull request #414 from sasjs/issue-276
fix: Issue 276
2021-06-13 21:20:18 +03:00
Allan Bowe
2951e0cc2d Merge branch 'master' into issue-276 2021-06-13 21:04:56 +03:00
Allan Bowe
6bb4a7ea18 Update SASjs.ts
fix grammar
2021-06-13 21:01:15 +03:00
Allan Bowe
2827978fe5 Merge pull request #390 from sasjs/service-pack-with-file-resource
feat: create file resource while deploying service pack for viya
2021-06-13 14:52:09 +03:00
Saad Jutt
541c19c1a4 chore(merge): Merge branch 'service-pack-with-file-resource' of github.com:sasjs/adapter into service-pack-with-file-resource 2021-06-13 16:26:27 +05:00
Saad Jutt
c5e995f8d6 chore: TSDoc comments updated 2021-06-13 16:25:04 +05:00
Allan Bowe
8bf36da566 Merge branch 'master' into service-pack-with-file-resource 2021-06-13 11:56:54 +03:00
ccb4ec6e03 chore: code refactored for better readability 2021-06-11 22:53:06 +05:00
06ebb52bc9 chore(merge): merge master into issue-276 2021-06-10 22:12:36 +05:00
Yury Shkoda
6e23a0362f Merge pull request #411 from sasjs/issue-408
feat: select extra attributes in JES response
2021-06-10 19:38:16 +03:00
a59d78bcf7 chore(git): Merge branch 'master' into issue-408 2021-06-10 15:06:10 +02:00
33d4ee92a7 chore: updated utils and comment 2021-06-10 15:03:51 +02:00
dadce3d4c9 chore: added extra attributes type from @sasjs/utils 2021-06-10 14:22:31 +02:00
Saad Jutt
b61cf34723 chore(merge): Merge branch 'master' into service-pack-with-file-resource 2021-06-10 16:55:35 +05:00
Saad Jutt
22445d1268 fix: uploading file Buffer with FormData 2021-06-10 16:49:20 +05:00
Allan Bowe
cba9dacb37 Merge branch 'master' into issue-276 2021-06-10 14:03:14 +03:00
Yury Shkoda
a055b36c5c Merge pull request #389 from sasjs/issue-381
fix: sas fails with verifying credentials
2021-06-10 13:42:21 +03:00
06895cc9f8 style: lint 2021-06-10 12:08:56 +02:00
24496a997a chore: addressing comments 2021-06-10 12:08:16 +02:00
6419686269 chore: lint fixes 2021-06-09 17:28:27 +00:00
Sabir Hassan
4554c9100c Merge branch 'master' into issue-276 2021-06-09 16:51:49 +05:00
919c83c143 chore: lint fixes 2021-06-09 16:40:29 +05:00
00ba2957fb Merge branch 'master' into issue-381 2021-06-09 13:10:06 +02:00
5beda6547a Merge branch 'master' into issue-408 2021-06-09 13:09:59 +02:00
bd49b3757a chore(git): Merge branch 'master' into issue-408 2021-06-09 13:05:48 +02:00
Yury Shkoda
b32352a369 Merge pull request #413 from sasjs/webpack-fix
fix(webpack): removed process plugin from nodeConfig
2021-06-09 14:04:47 +03:00
b306f11148 chore(git): Merge branch 'master' into issue-381 2021-06-09 13:04:47 +02:00
Yury Shkoda
8c4955cb65 chore(git): merge branch 'master' of https://github.com/sasjs/adapter into webpack-fix 2021-06-09 13:58:59 +03:00
Yury Shkoda
155f2bb0e8 fix(webpack): removed process plugin from nodeConfig 2021-06-09 13:53:27 +03:00
3ca971134a Merge pull request #366 from sasjs/snyk-upgrade-0c3cac4dc7e5009cbff727c995cc3ebe
[Snyk] Upgrade @types/node from 14.14.25 to 14.14.41
2021-06-09 11:06:22 +02:00
488d8b9316 chore(git): Merge branch 'master' into issue-381 2021-06-09 10:38:25 +02:00
c20bdba4ae Merge branch 'master' into snyk-upgrade-0c3cac4dc7e5009cbff727c995cc3ebe 2021-06-09 10:36:10 +02:00
0be2d69aee Merge pull request #404 from sasjs/dependabot/npm_and_yarn/ts-jest-27.0.3
chore(deps-dev): bump ts-jest from 27.0.2 to 27.0.3
2021-06-09 10:33:18 +02:00
a6e67c3478 chore(merge): branch 'master' into dependabot/npm_and_yarn/ts-jest-27.0.3 2021-06-09 10:28:05 +02:00
5968988984 Merge pull request #405 from sasjs/dependabot/npm_and_yarn/webpack-cli-4.7.2
chore(deps-dev): bump webpack-cli from 4.7.0 to 4.7.2
2021-06-09 10:24:12 +02:00
31cd01610a Merge branch 'master' into dependabot/npm_and_yarn/webpack-cli-4.7.2 2021-06-09 10:21:58 +02:00
a67824762c Merge pull request #412 from sasjs/dependabot/npm_and_yarn/sasjs/utils-2.18.0
chore(deps): bump @sasjs/utils from 2.17.1 to 2.18.0
2021-06-09 10:21:37 +02:00
dependabot-preview[bot]
0336541d40 chore(deps-dev): bump webpack-cli from 4.7.0 to 4.7.2
Bumps [webpack-cli](https://github.com/webpack/webpack-cli) from 4.7.0 to 4.7.2.
- [Release notes](https://github.com/webpack/webpack-cli/releases)
- [Changelog](https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.7.0...webpack-cli@4.7.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-09 08:01:57 +00:00
dependabot-preview[bot]
01de3836d7 chore(deps): bump @sasjs/utils from 2.17.1 to 2.18.0
Bumps [@sasjs/utils](https://github.com/sasjs/utils) from 2.17.1 to 2.18.0.
- [Release notes](https://github.com/sasjs/utils/releases)
- [Commits](https://github.com/sasjs/utils/compare/v2.17.1...v2.18.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-09 08:01:54 +00:00
Krishna Acondy
c571bb8490 Merge pull request #342 from sasjs/dependabot/add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-06-09 08:59:58 +01:00
Krishna Acondy
5b4d354ea2 chore(*): remove ignores 2021-06-09 08:53:57 +01:00
Krishna Acondy
b0ce0dc40a Merge branch 'master' into dependabot/add-v2-config-file 2021-06-09 08:53:24 +01:00
88f70a7966 chore: merge 2021-06-08 17:01:41 +02:00
89ff323206 style: lint 2021-06-08 16:55:10 +02:00
d4357d939e test: extra attributes on JES 2021-06-08 16:54:46 +02:00
Allan Bowe
6cb76f0b5c chore: merge fix 2021-06-08 13:18:16 +00:00
Allan Bowe
ba2baa36c0 chore: updating merge conflicts 2021-06-08 13:14:29 +00:00
Yury Shkoda
e36cd785e8 Merge pull request #410 from sasjs/macro-vars
feat(variables): added macro variables to executeComputeJob method
2021-06-08 14:50:33 +03:00
2fa3a353fa feat: select extra attributes in JES response 2021-06-08 13:25:08 +02:00
Yury Shkoda
bdb1ffb2ef chore(cleanup): removed console.log 2021-06-08 13:40:35 +03:00
Yury Shkoda
84090661cf chore(git): Merge branch 'master' of https://github.com/sasjs/adapter into macro-vars 2021-06-08 13:31:46 +03:00
Yury Shkoda
68e14bbf05 feat(variables): added macro variables to executeComputeJob method 2021-06-08 13:03:02 +03:00
Allan Bowe
e4f23334d3 Merge pull request #407 from sasjs/fix-built-package
fix(build): provide process module for compatibility with browser
2021-06-08 11:03:46 +03:00
Krishna Acondy
5593963b89 fix(build): provide process module for compatibility with browser 2021-06-08 08:42:48 +01:00
Krishna Acondy
81c9138b93 Merge branch 'master' into dependabot/npm_and_yarn/ts-jest-27.0.3 2021-06-07 09:09:13 +01:00
Krishna Acondy
83fa82108b Merge pull request #401 from sasjs/dependabot/npm_and_yarn/sasjs/utils-2.17.1
chore(deps): bump @sasjs/utils from 2.10.2 to 2.17.1
2021-06-07 09:08:59 +01:00
dependabot-preview[bot]
76039c3ec7 chore(deps-dev): bump ts-jest from 27.0.2 to 27.0.3
Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 27.0.2 to 27.0.3.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v27.0.2...v27.0.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-07 08:07:47 +00:00
Krishna Acondy
9b57c9ca1c Merge branch 'master' into snyk-upgrade-0c3cac4dc7e5009cbff727c995cc3ebe 2021-06-07 09:05:35 +01:00
dependabot-preview[bot]
4018cf95ba chore(deps): bump @sasjs/utils from 2.10.2 to 2.17.1
Bumps [@sasjs/utils](https://github.com/sasjs/utils) from 2.10.2 to 2.17.1.
- [Release notes](https://github.com/sasjs/utils/releases)
- [Commits](https://github.com/sasjs/utils/compare/v2.10.2...v2.17.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-07 07:58:28 +00:00
Krishna Acondy
173b6e3e8d Merge pull request #400 from sasjs/sas9-execute-code
feat(sas9-support): execute arbitrary code on SAS9 servers
2021-06-07 08:56:56 +01:00
Krishna Acondy
0ed5447aff chore(sas9-api): fix filename 2021-06-07 08:45:50 +01:00
Krishna Acondy
6344a906d8 chore(tests): fix tests - remove done callback 2021-06-07 08:37:44 +01:00
Allan Bowe
b2c135ae61 Merge branch 'master' into issue-381 2021-06-07 10:34:16 +03:00
Krishna Acondy
2032aacba3 chore(deps): update package versions 2021-06-04 08:59:15 +01:00
Krishna Acondy
fadccfc94c chore(refactor): upgrade utils, refactor to use timestamp generator 2021-06-04 08:40:27 +01:00
Krishna Acondy
551e4e43c1 feat(sas9-support): execute arbitrary code on SAS9 using SASjs runner 2021-06-04 08:37:50 +01:00
sabir_hassan
1867658cde fix: add validations for table name and table structure #276 2021-06-03 15:08:48 +05:00
3fff4f9c4d Merge pull request #395 from sasjs/makeErr
fix: adding makeErr for SAS 9 in sajss-tests
2021-06-02 15:46:39 +02:00
Allan Bowe
3f119432db fix: adding makeErr for SAS 9 in sajss-tests 2021-06-02 16:44:09 +03:00
0b18fddc3e chore: merge 2021-06-02 11:06:34 +02:00
19503e0b31 style: lint 2021-06-02 11:01:19 +02:00
d8bdc02f09 chore: sasjs-tests compute only on viya, login order fix 2021-06-02 11:00:08 +02:00
2d0833061f chore: merge branch 'master' into issue-381 2021-06-01 11:52:52 +02:00
Yury Shkoda
5dfc4e4086 Merge branch 'master' into issue-381 2021-05-31 08:03:44 +03:00
Saad Jutt
c5824a8a8d fix: using mime package to determine content-type 2021-05-30 23:47:31 +05:00
Allan Bowe
2147c59314 Merge pull request #388 from sasjs/sas9-auth-error
fix(sas9-support): Throw error when invalid credentials are supplied
2021-05-30 08:51:24 +03:00
Saad Jutt
56a1960fff feat: create file resource while deploying service pack for viya 2021-05-30 05:58:17 +05:00
b8c9522a55 chore: packages 2021-05-28 16:58:56 +02:00
b461cff731 Merge branch 'master' into issue-381 2021-05-28 15:24:01 +02:00
728167fd71 test: fix 2021-05-28 15:22:57 +02:00
460575b462 fix: when sas fails with verifying credentials, resend request with new csrf token 2021-05-28 15:05:44 +02:00
Krishna Acondy
b247da249a chore(git-hooks): allow numbers in commit message 2021-05-28 08:52:18 +01:00
Krishna Acondy
e79089b880 fix(sas9-support): throw error with invalid credentials 2021-05-28 08:52:00 +01:00
Krishna Acondy
fe907e1c43 Merge pull request #384 from sasjs/sas9-support
feat(sas9-support): add support for SAS9 job execution outside of the browser
2021-05-28 07:46:47 +01:00
Allan Bowe
e95e894365 Merge branch 'master' into sas9-support 2021-05-27 12:29:30 +03:00
Allan Bowe
82414d8b8b Merge pull request #379 from sasjs/dependabot/npm_and_yarn/sasjs/utils-2.14.0
chore(deps): bump @sasjs/utils from 2.10.2 to 2.14.0
2021-05-27 12:29:13 +03:00
Allan Bowe
456fa68f0f Merge branch 'master' into dependabot/npm_and_yarn/sasjs/utils-2.14.0 2021-05-27 11:55:31 +03:00
Allan Bowe
076adc1f6a Merge pull request #334 from sasjs/dependabot/npm_and_yarn/typedoc-0.20.36
chore(deps-dev): bump typedoc from 0.20.35 to 0.20.36
2021-05-27 11:54:52 +03:00
Krishna Acondy
9676488ff2 chore(refactor): remove unnecessary variables, use jobs path from config 2021-05-27 08:40:50 +01:00
Krishna Acondy
e9affb862d chore(merge): update branch 2021-05-27 08:32:11 +01:00
Krishna Acondy
e04371510e chore(update): update branch with changes from master 2021-05-27 08:30:20 +01:00
dependabot-preview[bot]
19657a1c12 chore(deps-dev): bump typedoc from 0.20.35 to 0.20.36
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.20.35 to 0.20.36.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.20.35...v0.20.36)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-27 07:22:22 +00:00
dependabot-preview[bot]
6424c82ac9 chore(deps): bump @sasjs/utils from 2.10.2 to 2.14.0
Bumps [@sasjs/utils](https://github.com/sasjs/utils) from 2.10.2 to 2.14.0.
- [Release notes](https://github.com/sasjs/utils/releases)
- [Commits](https://github.com/sasjs/utils/compare/v2.10.2...v2.14.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-27 07:22:21 +00:00
Allan Bowe
fcab18191f Merge pull request #382 from sasjs/dependabot/npm_and_yarn/browserslist-4.16.6
chore(deps): [security] bump browserslist from 4.16.4 to 4.16.6
2021-05-27 10:20:21 +03:00
Krishna Acondy
f157612a0e Merge branch 'master' into sas9-support 2021-05-27 08:16:49 +01:00
Krishna Acondy
b8cb7d52e7 chore(*): remove unused loader 2021-05-27 08:08:47 +01:00
Krishna Acondy
d8d1968162 chore(*): fix formatting 2021-05-27 08:06:21 +01:00
Krishna Acondy
0e1d1f1d99 chore(dep): remove unused dependency 2021-05-27 08:04:19 +01:00
Krishna Acondy
0b055dd05f feat(sas9-support): add support for SAS9 via username/password login 2021-05-27 08:00:15 +01:00
dependabot-preview[bot]
ba91c29ba8 chore(deps): [security] bump browserslist from 4.16.4 to 4.16.6
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.4 to 4.16.6. **This update includes a security fix.**
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.16.4...4.16.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-26 08:24:56 +00:00
Allan Bowe
bd19457c2a Merge branch 'master' of github.com:sasjs/adapter 2021-05-26 11:23:13 +03:00
Allan Bowe
b0570e1cd9 chore: automated commit 2021-05-26 11:23:08 +03:00
Allan Bowe
a5f1b59f7b Merge pull request #374 from sasjs/git-hooks
feat(git): enabled git hook enforcing conventional commits
2021-05-20 09:23:25 +03:00
Yury Shkoda
01ca29fc01 feat(git): enabled git hook enforcing conventional commits 2021-05-20 08:22:40 +03:00
Allan Bowe
ed9648fdf9 chore: automated commit 2021-05-16 22:02:23 +03:00
Allan Bowe
7e17aa6eb3 chore: automated commit 2021-05-16 22:00:10 +03:00
Allan Bowe
9caee9941a Merge pull request #371 from sasjs/qualityfixes
fix: readme badges
2021-05-16 21:59:15 +03:00
Allan Bowe
e309e7a4f4 fix: readme badges 2021-05-16 21:56:26 +03:00
Allan Bowe
c47441d6d4 Merge pull request #370 from sasjs/qualityfixes
fix: metadata in package.json
2021-05-16 21:41:11 +03:00
Allan Bowe
1844bc48ac Merge branch 'master' into qualityfixes 2021-05-16 21:40:40 +03:00
Allan Bowe
7a5adebdb5 fix: metadata in package.json 2021-05-16 21:40:14 +03:00
Allan Bowe
b39f0c577b Merge pull request #369 from sasjs/qualityfixes
Qualityfixes
2021-05-16 21:34:55 +03:00
Allan Bowe
15f4065cd8 fix: metadata updates (readme, changelog, url in package.json) 2021-05-16 20:25:56 +03:00
Allan Bowe
4c67665b4d fix: adding npmignore (should reduce the bundle size from 8.88mb) 2021-05-16 13:52:13 +03:00
snyk-bot
55e64ae9d6 fix: upgrade @types/node from 14.14.25 to 14.14.41
Snyk has created this PR to upgrade @types/node from 14.14.25 to 14.14.41.

See this package in npm:
https://www.npmjs.com/package/@types/node

See this project in Snyk:
https://app.snyk.io/org/allanbowe/project/acbafb55-1a7a-485d-a36b-42650bb03cf6?utm_source=github&utm_medium=upgrade-pr
2021-05-15 21:55:56 +00:00
Allan Bowe
76d0b82b4c Merge pull request #363 from sasjs/allanbowe-patch-1
Create CODE_OF_CONDUCT.md
2021-05-15 15:15:04 +03:00
Allan Bowe
95d65d270d Merge branch 'master' into allanbowe-patch-1 2021-05-15 15:10:33 +03:00
Allan Bowe
4e5c9c1ccd Merge pull request #354 from sasjs/dependabot/npm_and_yarn/hosted-git-info-2.8.9
chore(deps): [security] bump hosted-git-info from 2.8.8 to 2.8.9
2021-05-15 15:10:18 +03:00
Allan Bowe
3267af0724 Merge branch 'master' into dependabot/npm_and_yarn/hosted-git-info-2.8.9 2021-05-15 15:07:06 +03:00
Allan Bowe
75120424d0 Create CODE_OF_CONDUCT.md 2021-05-15 15:05:49 +03:00
Yury Shkoda
f13c7e5cf1 Merge pull request #362 from sasjs/request-fix
fix(request): returned response with log
2021-05-13 18:40:50 +03:00
Yury Shkoda
53a7b1c9e6 fix(request): returned response with log 2021-05-13 17:29:48 +03:00
Allan Bowe
8c30cbff13 Merge pull request #359 from sasjs/retry-state-error
fix(job-state-poll): Continue poll regardless of errors
2021-05-11 12:26:16 +03:00
Krishna Acondy
8f3a7f33f8 chore(*): reduce max error count 2021-05-11 10:23:47 +01:00
Krishna Acondy
67ec27bab7 chore(*): increment error count 2021-05-11 10:20:28 +01:00
Krishna Acondy
c1b200b0d8 fix(job-state-poll): error out after max consecutive errors 2021-05-11 10:12:11 +01:00
Krishna Acondy
e03ec996d6 chore(*): fix formatting 2021-05-11 09:25:17 +01:00
Krishna Acondy
ad8dbfd4ec chore(*): add URL to logs 2021-05-11 08:57:35 +01:00
Krishna Acondy
15a774ff81 chore(*): print URL when polling job state 2021-05-11 08:29:15 +01:00
Krishna Acondy
98114c5591 fix(job-state-poll): Continue polling for job state despite errored requests 2021-05-11 08:23:40 +01:00
Krishna Acondy
f8c6318a88 chore(*): attempt SAS9 job executor 2021-05-11 08:15:48 +01:00
Muhammad Saad
dffcb66d54 Merge pull request #356 from sasjs/issue657
fix: increasing timeout, closes #657
2021-05-10 16:17:14 +05:00
Allan Bowe
67c7147e62 fix: lint updates 2021-05-10 11:13:39 +00:00
Allan Bowe
50d1b4d824 fix: increasing timeout, closes #657 2021-05-10 11:05:53 +00:00
dependabot-preview[bot]
dc98ce3b0b chore(deps): [security] bump hosted-git-info from 2.8.8 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. **This update includes a security fix.**
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-07 19:37:13 +00:00
Krishna Acondy
cf1e3f3835 Merge pull request #350 from sasjs/dependabot/npm_and_yarn/ts-loader-9.1.2
chore(deps-dev): bump ts-loader from 8.1.0 to 9.1.2
2021-05-07 08:54:25 +01:00
Krishna Acondy
2f913e9363 Merge branch 'master' into dependabot/npm_and_yarn/ts-loader-9.1.2 2021-05-07 08:52:16 +01:00
Krishna Acondy
05a9864df8 Merge pull request #353 from sasjs/dependabot/npm_and_yarn/webpack-cli-4.7.0
chore(deps-dev): bump webpack-cli from 4.5.0 to 4.7.0
2021-05-07 08:51:53 +01:00
dependabot-preview[bot]
3a0d764dfa chore(deps-dev): bump webpack-cli from 4.5.0 to 4.7.0
Bumps [webpack-cli](https://github.com/webpack/webpack-cli) from 4.5.0 to 4.7.0.
- [Release notes](https://github.com/webpack/webpack-cli/releases)
- [Changelog](https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.5.0...webpack-cli@4.7.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-07 07:41:45 +00:00
dependabot-preview[bot]
310087b895 chore(deps-dev): bump ts-loader from 8.1.0 to 9.1.2
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 8.1.0 to 9.1.2.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v8.1.0...v9.1.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-07 07:41:36 +00:00
Yury Shkoda
dc39ecd4a8 Merge pull request #352 from sasjs/csv-fix
fix(convert-to-csv): fix bug with escaping quoted string
2021-05-07 10:39:34 +03:00
Yury Shkoda
99e192c5de test(csv-convert): fixed expected output 2021-05-07 10:36:43 +03:00
Yury Shkoda
b86658ef9b fix(csv-convert): fixed data convertion 2021-05-07 10:30:27 +03:00
Saad Jutt
88f08e8864 fix: removed extra slash + added tests 2021-05-07 05:26:08 +05:00
Saad Jutt
80e5de5d65 fix: master tests fixed 2021-05-06 22:28:06 +05:00
Krishna Acondy
665734b168 chore(*): add tests 2021-05-06 13:59:33 +01:00
Krishna Acondy
5543f467e6 chore(*): add more test cases 2021-05-06 13:21:49 +01:00
Krishna Acondy
a32c0879b3 fix(convert-to-csv): fix bug with escaping quoted string 2021-05-06 12:44:08 +01:00
Yury Shkoda
bb2ad5bb9a Merge pull request #344 from sasjs/fix-fetch-session-log
fix: fetch session log for session failed/stopped state
2021-05-04 08:34:18 +03:00
Saad Jutt
6f2f11d112 fix: fetch session log for session failed/stopped state 2021-05-03 18:26:22 +05:00
dependabot-preview[bot]
9b32b28aa7 Upgrade to GitHub-native Dependabot 2021-04-29 15:44:24 +00:00
Krishna Acondy
fef65bbfd2 Merge pull request #326 from sasjs/isUrl-fix 2021-04-22 14:39:01 +01:00
Yury Shkoda
efeba71612 Merge branch 'isUrl-fix' of https://github.com/sasjs/adapter into isUrl-fix 2021-04-22 14:48:02 +03:00
Yury Shkoda
8f54002b1e Merge branch 'master' of https://github.com/sasjs/adapter into isUrl-fix 2021-04-22 14:46:47 +03:00
Yury Shkoda
9d6882799d test(isUrl): covered isUrl utility with unit tests 2021-04-22 14:45:56 +03:00
Yury Shkoda
73a3acee68 Merge branch 'master' into isUrl-fix 2021-04-22 07:55:39 +03:00
Krishna Acondy
0a88220e04 Merge pull request #307 from sasjs/dependabot/npm_and_yarn/types/jest-26.0.22
chore(deps-dev): bump @types/jest from 26.0.20 to 26.0.22
2021-04-21 17:24:54 +01:00
Krishna Acondy
c8e1779272 Merge branch 'master' into dependabot/npm_and_yarn/types/jest-26.0.22 2021-04-21 17:24:46 +01:00
dependabot-preview[bot]
8bd3580e23 chore(deps-dev): bump @types/jest from 26.0.20 to 26.0.22
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.20 to 26.0.22.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-21 16:24:07 +00:00
Krishna Acondy
f732b32873 Merge pull request #317 from sasjs/dependabot/npm_and_yarn/sasjs/utils-2.10.2
chore(deps): bump @sasjs/utils from 2.6.3 to 2.10.2
2021-04-21 17:23:18 +01:00
Krishna Acondy
65b18f9148 Merge branch 'master' into dependabot/npm_and_yarn/sasjs/utils-2.10.2 2021-04-21 17:23:10 +01:00
Krishna Acondy
10b1676a35 Merge pull request #323 from sasjs/dependabot/npm_and_yarn/webpack-5.33.2
chore(deps-dev): bump webpack from 5.24.4 to 5.33.2
2021-04-21 17:22:08 +01:00
Krishna Acondy
b9bd09d3e8 Merge branch 'master' into dependabot/npm_and_yarn/webpack-5.33.2 2021-04-21 17:20:48 +01:00
Krishna Acondy
537f687b94 Merge pull request #288 from sasjs/dependabot/npm_and_yarn/semantic-release-17.4.2
chore(deps-dev): bump semantic-release from 17.4.1 to 17.4.2
2021-04-21 17:17:20 +01:00
Krishna Acondy
bfd532f813 Merge branch 'master' into dependabot/npm_and_yarn/semantic-release-17.4.2 2021-04-21 17:17:14 +01:00
Krishna Acondy
4f2b4f46a8 Merge pull request #311 from sasjs/dependabot/npm_and_yarn/ts-loader-8.1.0
chore(deps-dev): bump ts-loader from 8.0.17 to 8.1.0
2021-04-21 17:17:04 +01:00
Krishna Acondy
077cc9458d Merge branch 'master' into dependabot/npm_and_yarn/ts-loader-8.1.0 2021-04-21 17:16:53 +01:00
dependabot-preview[bot]
0a7ab394a4 chore(deps-dev): bump semantic-release from 17.4.1 to 17.4.2
Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 17.4.1 to 17.4.2.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](https://github.com/semantic-release/semantic-release/compare/v17.4.1...v17.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-21 16:16:18 +00:00
Krishna Acondy
f873febfde Merge pull request #316 from sasjs/dependabot/npm_and_yarn/typedoc-0.20.35
chore(deps-dev): bump typedoc from 0.20.30 to 0.20.35
2021-04-21 17:14:09 +01:00
dependabot-preview[bot]
55e8ce359b chore(deps-dev): bump typedoc from 0.20.30 to 0.20.35
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.20.30 to 0.20.35.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.20.30...v0.20.35)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-21 16:12:13 +00:00
Krishna Acondy
99d7c8f119 Merge pull request #254 from sasjs/dependabot/npm_and_yarn/form-data-4.0.0
chore(deps): bump form-data from 3.0.0 to 4.0.0
2021-04-21 17:09:59 +01:00
Krishna Acondy
b3c90f09d6 Merge branch 'master' into dependabot/npm_and_yarn/form-data-4.0.0 2021-04-21 17:08:17 +01:00
dependabot-preview[bot]
2401962c53 chore(deps): bump form-data from 3.0.0 to 4.0.0
Bumps [form-data](https://github.com/form-data/form-data) from 3.0.0 to 4.0.0.
- [Release notes](https://github.com/form-data/form-data/releases)
- [Commits](https://github.com/form-data/form-data/compare/v3.0.0...v4.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-21 15:59:47 +00:00
Krishna Acondy
362b4d4db3 Merge pull request #319 from sasjs/dependabot/npm_and_yarn/y18n-4.0.3
chore(deps): [security] bump y18n from 4.0.0 to 4.0.3
2021-04-21 16:59:24 +01:00
Krishna Acondy
8aea325139 Merge branch 'master' into dependabot/npm_and_yarn/y18n-4.0.3 2021-04-21 16:57:51 +01:00
Krishna Acondy
bb370061a2 Merge pull request #324 from sasjs/dependabot/npm_and_yarn/ssri-6.0.2
chore(deps): [security] bump ssri from 6.0.1 to 6.0.2
2021-04-21 16:57:33 +01:00
Yury Shkoda
48442f7769 fix(utility): improved 'isUrl' utility 2021-04-21 08:11:13 +03:00
dependabot-preview[bot]
e67a8531ce chore(deps): [security] bump ssri from 6.0.1 to 6.0.2
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2. **This update includes a security fix.**
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](https://github.com/npm/ssri/compare/v6.0.1...v6.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-16 22:04:40 +00:00
dependabot-preview[bot]
ef4f020e2a chore(deps-dev): bump webpack from 5.24.4 to 5.33.2
Bumps [webpack](https://github.com/webpack/webpack) from 5.24.4 to 5.33.2.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.24.4...v5.33.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-15 09:07:24 +00:00
dependabot-preview[bot]
2feceeb2f9 chore(deps): [security] bump y18n from 4.0.0 to 4.0.3
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.3. **This update includes a security fix.**
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/compare/v4.0.0...y18n-v4.0.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-08 09:21:54 +00:00
dependabot-preview[bot]
eaec922fea chore(deps): bump @sasjs/utils from 2.6.3 to 2.10.2
Bumps [@sasjs/utils](https://github.com/sasjs/utils) from 2.6.3 to 2.10.2.
- [Release notes](https://github.com/sasjs/utils/releases)
- [Commits](https://github.com/sasjs/utils/compare/v2.6.3...v2.10.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-05 08:40:34 +00:00
dependabot-preview[bot]
de94777fff chore(deps-dev): bump ts-loader from 8.0.17 to 8.1.0
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 8.0.17 to 8.1.0.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v8.0.17...v8.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-30 08:14:56 +00:00
Yury Shkoda
0aa0ae65e0 Merge pull request #313 from sasjs/response-parsing-fix
fix(fetch-log): fixed response parsing
2021-03-30 11:12:40 +03:00
Yury Shkoda
4b0d62d59b Merge branch 'master' into response-parsing-fix 2021-03-30 11:07:37 +03:00
Yury Shkoda
b3ef50e9eb fix(fetch-log): fixed response parsing 2021-03-30 11:04:18 +03:00
Krishna Acondy
d30a1890a1 chore(*): update typedoc docs 2021-03-30 07:57:27 +01:00
Krishna Acondy
f1c2569de3 fix(request): update typings and documentation for request method 2021-03-30 07:57:11 +01:00
Muhammad Saad
4826388cdd Merge pull request #310 from sasjs/issue-309
Issue 309
2021-03-29 18:07:51 +05:00
e88736056a test: fix 2021-03-29 13:43:51 +02:00
9da2a29a72 chore: for VIYA calling API endpoint 2021-03-28 21:55:47 +02:00
dce8a08a86 lint: fix 2021-03-28 19:27:57 +02:00
1fabb9e610 test: fix 2021-03-28 19:04:10 +02:00
23db0ac80d style: lint 2021-03-28 18:40:22 +02:00
28370341d8 fix: login checkSession improved mechanism 2021-03-28 18:40:04 +02:00
Muhammad Saad
a023ffe850 Merge pull request #300 from sasjs/fix-log-by-chunks
fix: after job executing get complete log
2021-03-23 14:33:57 +05:00
Muhammad Saad
a4e77ecf6e Merge branch 'master' into fix-log-by-chunks 2021-03-23 13:04:39 +05:00
Allan Bowe
7efc0a1fb2 Merge pull request #275 from sasjs/allanbowe-patch-1
Update README.md
2021-03-22 22:37:16 +01:00
Allan Bowe
c3e2b2ce70 chore: updates to README 2021-03-22 20:56:18 +00:00
Saad Jutt
dde1228b1d fix: function renamed fetchLogByChunks 2021-03-23 00:50:33 +05:00
Saad Jutt
b3474b6dfb fix: after job executing get complete log 2021-03-22 19:21:01 +05:00
Allan Bowe
179a04ae31 Merge branch 'master' into allanbowe-patch-1 2021-03-16 17:02:47 +01:00
Yury Shkoda
2bdcbda54c Merge pull request #285 from sasjs/error-handling
fix(error-handling): added InternalServerError
2021-03-12 08:57:01 +03:00
Yury Shkoda
a123392c56 Merge branch 'master' into error-handling 2021-03-10 14:50:51 +03:00
Yury Shkoda
719135e366 fix(error-handling): added InternalServerError 2021-03-10 14:43:47 +03:00
Allan Bowe
ba619554b7 Merge branch 'master' into allanbowe-patch-1 2021-03-09 23:47:18 +01:00
Yury Shkoda
6a3ab7032f Merge pull request #284 from sasjs/error-handling
fix(error-handling): fixed console.log
2021-03-09 18:07:53 +03:00
Yury Shkoda
d818d14cb4 Merge branch 'master' into error-handling 2021-03-09 18:07:46 +03:00
Yury Shkoda
599c130395 fix(error-handling): fixed console.log 2021-03-09 18:06:27 +03:00
Yury Shkoda
9ef2759e27 Merge pull request #283 from sasjs/error-handling
fix(error-handling): catching unhandled promise rejection
2021-03-09 17:15:10 +03:00
Yury Shkoda
43355c88d4 Merge branch 'master' into error-handling 2021-03-09 17:12:45 +03:00
Yury Shkoda
15e1acaf4f fix(error-handling): catching unhandled promise rejection 2021-03-09 17:11:29 +03:00
Yury Shkoda
ec77ffdd88 Merge pull request #282 from sasjs/error-handling
fix(error-handling): console logged error
2021-03-09 15:55:39 +03:00
Yury Shkoda
9797c1ca84 Merge branch 'master' into error-handling 2021-03-09 15:53:40 +03:00
Yury Shkoda
bbe9633dc8 fix(error-handling): console logged error 2021-03-09 15:52:00 +03:00
Muhammad Saad
6f60ac5cc7 Merge branch 'master' into allanbowe-patch-1 2021-03-09 15:33:41 +05:00
Muhammad Saad
e7ba09793c Merge pull request #272 from sasjs/dependabot/npm_and_yarn/semantic-release-17.4.1
chore(deps-dev): bump semantic-release from 17.3.9 to 17.4.1
2021-03-09 15:32:57 +05:00
Muhammad Saad
c0c0800e61 Merge branch 'master' into dependabot/npm_and_yarn/semantic-release-17.4.1 2021-03-09 15:31:46 +05:00
Muhammad Saad
0bd9d8f93f Merge pull request #278 from sasjs/dependabot/npm_and_yarn/webpack-5.24.4
chore(deps-dev): bump webpack from 5.21.2 to 5.24.4
2021-03-09 15:31:37 +05:00
dependabot-preview[bot]
214fc2d5cd chore(deps-dev): bump semantic-release from 17.3.9 to 17.4.1
Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 17.3.9 to 17.4.1.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](https://github.com/semantic-release/semantic-release/compare/v17.3.9...v17.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-09 10:30:56 +00:00
Muhammad Saad
55b0e2f934 Merge branch 'master' into dependabot/npm_and_yarn/webpack-5.24.4 2021-03-09 15:30:18 +05:00
Muhammad Saad
609cd4ed6d Merge pull request #280 from sasjs/dependabot/npm_and_yarn/typedoc-0.20.30
chore(deps-dev): bump typedoc from 0.19.2 to 0.20.30
2021-03-09 15:29:36 +05:00
dependabot-preview[bot]
2b20bbdcc8 chore(deps-dev): bump typedoc from 0.19.2 to 0.20.30
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.19.2 to 0.20.30.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.19.2...v0.20.30)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-09 10:27:54 +00:00
dependabot-preview[bot]
946a95bea1 chore(deps-dev): bump webpack from 5.21.2 to 5.24.4
Bumps [webpack](https://github.com/webpack/webpack) from 5.21.2 to 5.24.4.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.21.2...v5.24.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-09 10:27:51 +00:00
Muhammad Saad
7ec1c152e3 Merge pull request #279 from sasjs/dependabot/npm_and_yarn/sasjs/utils-2.6.3
chore(deps): bump @sasjs/utils from 2.5.0 to 2.6.3
2021-03-09 15:26:27 +05:00
dependabot-preview[bot]
0cf1110018 chore(deps): bump @sasjs/utils from 2.5.0 to 2.6.3
Bumps [@sasjs/utils](https://github.com/sasjs/utils) from 2.5.0 to 2.6.3.
- [Release notes](https://github.com/sasjs/utils/releases)
- [Commits](https://github.com/sasjs/utils/compare/v2.5.0...v2.6.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-09 07:52:39 +00:00
Yury Shkoda
9c5ada6fa1 Merge pull request #277 from sasjs/error-handling
fix(error-handling): added catch block to poll job state
2021-03-09 10:24:14 +03:00
Yury Shkoda
0f5702e21b fix(lint): used latest version of prettier 2021-03-09 10:21:52 +03:00
Yury Shkoda
f10d6ec80a fix(lint): updated dependencies 2021-03-09 09:55:43 +03:00
Yury Shkoda
490215df90 fix(lint): fixed code style 2021-03-09 09:53:35 +03:00
Yury Shkoda
9d27451813 fix(lint): fixed code style 2021-03-09 09:44:10 +03:00
Yury Shkoda
a977f59675 fix(error-handling): added catch block to poll job state 2021-03-09 09:35:01 +03:00
Allan Bowe
51a09d049c Update README.md 2021-03-08 11:27:05 +01:00
Krishna Acondy
47be5e77e5 Merge pull request #269 from sasjs/tests-258
test: issue 258
2021-03-02 12:24:46 +00:00
Mihajlo Medjedovic
d517e79ec0 chore: cleanup 2021-03-02 13:13:03 +01:00
Mihajlo Medjedovic
8714ecdde8 test: issue 258 2021-02-26 14:40:07 +01:00
Muhammad Saad
2cffc57209 Merge pull request #259 from sasjs/issue-258
Issue 258
2021-02-25 18:41:21 +05:00
Muhammad Saad
4e43687de2 Merge branch 'master' into issue-258 2021-02-25 18:37:35 +05:00
Muhammad Saad
f8dab83e37 Merge pull request #267 from sasjs/error-handling
chore(error-handling): removed redundant catch block
2021-02-25 18:36:19 +05:00
Yury Shkoda
655af03cf3 chore(error-handling): removed redundant catch block 2021-02-25 15:20:35 +03:00
Yury Shkoda
0a4dd00edb Merge pull request #266 from sasjs/error-handling
fix(RequestClient): add catch block to authorize method
2021-02-25 12:59:47 +03:00
Yury Shkoda
55b4929c54 Merge branch 'master' into error-handling 2021-02-25 12:58:25 +03:00
Yury Shkoda
8eb73a6b3c fix(RequestClient): add catch block to authorize method 2021-02-25 12:55:34 +03:00
Krishna Acondy
0aeb201625 Merge branch 'master' into issue-258 2021-02-25 07:59:43 +00:00
Mihajlo Medjedovic
349612a065 Merge branch 'issue-258' of github.com:sasjs/adapter into issue-258 2021-02-24 14:11:12 +01:00
Mihajlo Medjedovic
e48b22128d chore: small fix, error was not beign returned 2021-02-24 14:11:00 +01:00
Krishna Acondy
14dfe4ec51 Merge branch 'master' into issue-258 2021-02-24 12:47:16 +00:00
Mihajlo Medjedovic
e0051bf276 chore: test fixing 2021-02-24 13:15:14 +01:00
Mihajlo Medjedovic
7b72998e1c Merge branches 'issue-258' and 'master' of github.com:sasjs/adapter 2021-02-24 12:57:24 +01:00
Mihajlo Medjedovic
66d02cf1d1 style: lint 2021-02-23 23:01:08 +01:00
Mihajlo Medjedovic
f2c8e40430 chore: cleanup, parseResponse optimization 2021-02-23 22:58:48 +01:00
Mihajlo Medjedovic
4b28ee8e73 style: lint 2021-02-23 22:36:32 +01:00
Mihajlo Medjedovic
c7e54cfe9f fix: web approach login callback and debug issue 2021-02-23 22:36:11 +01:00
119 changed files with 8475 additions and 6304 deletions

18
.git-hooks/commit-msg Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
RED="\033[1;31m"
GREEN="\033[1;32m"
# Get the commit message (the parameter we're given is just the path to the
# temporary file which holds the message).
commit_message=$(cat "$1")
if (echo "$commit_message" | grep -Eq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9 \-]+\))?!?: .+$") then
echo "${GREEN} ✔ Commit message meets Conventional Commit standards"
exit 0
fi
echo "${RED}❌ Commit message does not meet the Conventional Commit standard!"
echo "An example of a valid message is:"
echo " feat(login): add the 'remember me' button"
echo " More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary"
exit 1

7
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

4
.npmignore Normal file
View File

@@ -0,0 +1,4 @@
sasjs-tests/
docs/
.github/
CONTRIBUTING.md

View File

@@ -1,5 +1,9 @@
# Change Log # Change Log
Since March 2020 the changelog is managed by github releases - see [https://github.com/sasjs/adapter/releases](https://github.com/sasjs/adapter/releases).
## Changes up to 5th March 2020
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="1.9.0"></a> <a name="1.9.0"></a>

View File

@@ -2,75 +2,127 @@
## Our Pledge ## Our Pledge
In the interest of fostering an open and welcoming environment, we as We as members, contributors, and leaders pledge to make participation in our
contributors and maintainers pledge to making participation in our project and community a harassment-free experience for everyone, regardless of age, body
our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender
size, disability, ethnicity, sex characteristics, gender identity and expression, identity and expression, level of experience, education, socio-economic status,
level of experience, education, socio-economic status, nationality, personal nationality, personal appearance, race, religion, or sexual identity
appearance, race, religion, or sexual identity and orientation. and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards ## Our Standards
Examples of behavior that contributes to creating a positive environment Examples of behavior that contributes to a positive environment for our
include: community include:
* Using welcoming and inclusive language * Demonstrating empathy and kindness toward other people
* Being respectful of differing viewpoints and experiences * Being respectful of differing opinions, viewpoints, and experiences
* Gracefully accepting constructive criticism * Giving and gracefully accepting constructive feedback
* Focusing on what is best for the community * Accepting responsibility and apologizing to those affected by our mistakes,
* Showing empathy towards other community members and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior by participants include: Examples of unacceptable behavior include:
* The use of sexualized language or imagery and unwelcome sexual attention or * The use of sexualized language or imagery, and sexual attention or
advances advances of any kind
* Trolling, insulting/derogatory comments, and personal or political attacks * Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment * Public or private harassment
* Publishing others' private information, such as a physical or electronic * Publishing others' private information, such as a physical or email
address, without explicit permission address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a * Other conduct which could reasonably be considered inappropriate in a
professional setting professional setting
## Our Responsibilities ## Enforcement Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable Community leaders are responsible for clarifying and enforcing our standards of
behavior and are expected to take appropriate and fair corrective action in acceptable behavior and will take appropriate and fair corrective action in
response to any instances of unacceptable behavior. response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Project maintainers have the right and responsibility to remove, edit, or Community leaders have the right and responsibility to remove, edit, or reject
reject comments, commits, code, wiki edits, issues, and other contributions comments, commits, code, wiki edits, issues, and other contributions that are
that are not aligned to this Code of Conduct, or to ban temporarily or not aligned to this Code of Conduct, and will communicate reasons for moderation
permanently any contributor for other behaviors that they deem inappropriate, decisions when appropriate.
threatening, offensive, or harmful.
## Scope ## Scope
This Code of Conduct applies both within project spaces and in public spaces This Code of Conduct applies within all community spaces, and also applies when
when an individual is representing the project or its community. Examples of an individual is officially representing the community in public spaces.
representing a project or community include using an official project e-mail Examples of representing our community include using an official e-mail address,
address, posting via an official social media account, or acting as an appointed posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be representative at an online or offline event.
further defined and clarified by project maintainers.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at support@macropeople.com. All reported to the community leaders responsible for enforcement at
complaints will be reviewed and investigated and will result in a response that https://sasapps.io/contact-us.
is deemed necessary and appropriate to the circumstances. The project team is All complaints will be reviewed and investigated promptly and fairly.
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good All community leaders are obligated to respect the privacy and security of the
faith may face temporary or permanent repercussions as determined by other reporter of any incident.
members of the project's leadership.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution ## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, This Code of Conduct is adapted from the [Contributor Covenant][homepage],
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org [homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020 Macro People Copyright (c) 2021 Macro People
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

186
README.md
View File

@@ -1,12 +1,28 @@
[![](https://data.jsdelivr.com/v1/package/npm/@sasjs/adapter/badge)](https://www.jsdelivr.com/package/npm/@sasjs/adapter)
# @sasjs/adapter # @sasjs/adapter
[![npm package][npm-image]][npm-url]
[![Github Workflow][githubworkflow-image]][githubworkflow-url]
[![Dependency Status][dependency-image]][dependency-url]
[![npm](https://img.shields.io/npm/dt/@sasjs/adapter)]()
![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@sasjs/adapter)
[![License](https://img.shields.io/apm/l/atomic-design-ui.svg)](/LICENSE)
![GitHub top language](https://img.shields.io/github/languages/top/sasjs/adapter)
![GitHub issues](https://img.shields.io/github/issues/sasjs/adapter)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/sasjs/adapter)
[npm-image]:https://img.shields.io/npm/v/@sasjs/adapter.svg
[npm-url]:http://npmjs.org/package/@sasjs/adapter
[githubworkflow-image]:https://github.com/sasjs/adapter/actions/workflows/build.yml/badge.svg
[githubworkflow-url]:https://github.com/sasjs/adapter/blob/main/.github/workflows/build.yml
[dependency-image]:https://david-dm.org/sasjs/adapter.svg
[dependency-url]:https://github.com/sasjs/adapter/blob/main/package.json
SASjs is a open-source framework for building Web Apps on SAS® platforms. You can use as much or as little of it as you like. This repository contains the JS adapter, the part that handles the to/from SAS communication on the client side. There are 3 ways to install it: SASjs is a open-source framework for building Web Apps on SAS® platforms. You can use as much or as little of it as you like. This repository contains the JS adapter, the part that handles the to/from SAS communication on the client side. There are 3 ways to install it:
1 - `npm install @sasjs/adapter` - for use in a node project 1 - `npm install @sasjs/adapter` - for use in a node project
2 - [Download](https://cdn.jsdelivr.net/npm/@sasjs/adapter@1/index.js) and use a copy of the latest JS file 2 - [Download](https://cdn.jsdelivr.net/npm/@sasjs/adapter@2/index.js) and use a copy of the latest JS file
3 - Reference directly from the CDN - in which case click [here](https://www.jsdelivr.com/package/npm/@sasjs/adapter?tab=collection) and select "SRI" to get the script tag with the integrity hash. 3 - Reference directly from the CDN - in which case click [here](https://www.jsdelivr.com/package/npm/@sasjs/adapter?tab=collection) and select "SRI" to get the script tag with the integrity hash.
@@ -41,8 +57,172 @@ parmcards4;
You now have a simple web app with a backend service! You now have a simple web app with a backend service!
## Detailed Overview
The SASjs adapter is a JS library and a set of SAS Macros that handle the communication between the frontend app and backend SAS services.
There are three parts to consider:
1. JS request / response
2. SAS inputs / outputs
3. Configuration
### JS Request / Response
To install the library you can simply run `npm i @sasjs/adapter` or include a `<script>` tag with a reference to our [CDN](https://www.jsdelivr.com/package/npm/@sasjs/adapter).
Full technical documentation is available [here](https://adapter.sasjs.io). The main parts are:
### Instantiation
The following code will instantiate an instance of the adapter:
```javascript
let sasJs = new SASjs.default(
{
appLoc: "/Your/SAS/Folder",
serverType:"SAS9"
}
);
```
If you've installed it via NPM, you can import it as a default import like so:
```
import SASjs from '@sasjs/adapter';
```
You can then instantiate it with:
```
const sasJs = new SASjs({your config})
```
More on the config later.
### SAS Logon
The login process can be handled directly, as below, or as a callback function to a SAS request.
```javascript
sasJs.logIn('USERNAME','PASSWORD'
).then((response) => {
if (response.isLoggedIn === true) {
console.log('do stuff')
} else {
console.log('do other stuff')
}
}
```
### Request / Response
A simple request can be sent to SAS in the following fashion:
```javascript
sasJs.request("/path/to/my/service", dataObject)
.then((response) => {
// all tables are in the response object, eg:
console.log(response.tablewith2cols1row[0].COL1.value)
})
```
We supply the path to the SAS service, and a data object. The data object can be null (for services with no input), or can contain one or more tables in the following format:
```javascript
let dataObject={
"tablewith2cols1row": [{
"col1": "val1",
"col2": 42
}],
"tablewith1col2rows": [{
"col": "row1"
}, {
"col": "row2"
}]
};
```
There are optional parameters such as a config object and a callback login function.
The response object will contain returned tables and columns. Table names are always lowercase, and column names uppercase.
The adapter will also cache the logs (if debug enabled) and even the work tables. For performance, it is best to keep debug mode off.
## SAS Inputs / Outputs
The SAS side is handled by a number of macros in the [macro core](https://github.com/sasjs/core) library.
The following snippet shows the process of SAS tables arriving / leaving:
```sas
/* fetch all input tables sent from frontend - they arrive as work tables */
%webout(FETCH)
/* some sas code */
data some sas tables;
set from js;
run;
%webout(OPEN) /* open the JSON to be returned */
%webout(OBJ,some) /* `some` table is sent in object format */
%webout(ARR,sas) /* `sas` table is sent in array format, smaller filesize */
%webout(OBJ,tables,fmt=N) /* unformatted (raw) data */
%webout(OBJ,tables,label=newtable) /* rename tables on export */
%webout(CLOSE) /* close the JSON and send some extra useful variables too */
```
## Configuration
Configuration on the client side involves passing an object on startup, which can also be passed with each request. Technical documentation on the SASjsConfig class is available [here](https://adapter.sasjs.io/classes/types.sasjsconfig.html). The main config items are:
* `appLoc` - this is the folder under which the SAS services will be created.
* `serverType` - either `SAS9` or `SASVIYA`.
* `serverUrl` - the location (including http protocol and port) of the SAS Server. Can be omitted, eg if serving directly from the SAS Web Server, or in streaming mode.
* `debug` - if `true` then SAS Logs and extra debug information is returned.
* `useComputeApi` - if `true` and the serverType is `SASVIYA` then the REST APIs will be called directly (rather than using the JES web service).
* `contextName` - if missing or blank, and `useComputeApi` is `true` and `serverType` is `SASVIYA` then the JES API will be used.
The adapter supports a number of approaches for interfacing with Viya (`serverType` is `SASVIYA`). For maximum performance, be sure to [configure your compute context](https://sasjs.io/guide-viya/#shared-account-and-server-re-use) with `reuseServerProcesses` as `true` and a system account in `runServerAs`. This functionality is available since Viya 3.5. This configuration is supported when [creating contexts using the CLI](https://sasjs.io/sasjs-cli-context/#sasjs-context-create).
### Using JES Web App
In this setup, all requests are routed through the JES web app, at `YOURSERVER/SASJobExecution`. This is the most reliable method, and also the slowest. One request is made to the JES app, and remaining requests (getting job uri, session spawning, passing parameters, running the program, fetching the log) are made on the SAS server by the JES app.
```
{
appLoc:"/Your/Path",
serverType:"SASVIYA"
}
```
### Using the JES API
Here we are running Jobs using the Job Execution Service except this time we are making the requests directly using the REST API instead of through the JES Web App. This is helpful when we need to call web services outside of a browser (eg with the SASjs CLI or other commandline tools). To save one network request, the adapter prefetches the JOB URIs and passes them in the `__job` parameter.
```
{
appLoc:"/Your/Path",
serverType:"SASVIYA",
useComputeApi: true
}
```
### Using the Compute API
This approach is by far the fastest, as a result of the optimisations we have built into the adapter. With this configuration, in the first sasjs request, we take a URI map of the services in the target folder, and create a session manager - which spawns an extra session. The next time a request is made, the adapter will use the 'hot' session. Sessions are deleted after every use, which actually makes this _less_ resource intensive than a typical JES web app, in which all sessions are kept alive by default for 15 minutes.
```
{
appLoc:"/Your/Path",
serverType:"SASVIYA",
useComputeApi: true,
contextName: 'yourComputeContext'
}
```
# More resources # More resources
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 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. 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.
If you are a SAS 9 or SAS Viya customer you can also request a copy of [Data Controller](https://datacontroller.io) - free for up to 5 users, this tool makes use of all parts of the SASjs framework.
## Star Gazing
If you find this library useful, help us grow our star graph!
![](https://starchart.cc/sasjs/adapter.svg)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7888
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,19 @@
{ {
"name": "@sasjs/adapter", "name": "@sasjs/adapter",
"description": "JavaScript adapter for SAS", "description": "JavaScript adapter for SAS",
"homepage": "https://adapter.sasjs.io",
"scripts": { "scripts": {
"build": "rimraf build && rimraf node && mkdir node && cp -r src/* node && webpack && rimraf build/src && rimraf node", "build": "rimraf build && rimraf node && mkdir node && cp -r src/* node && webpack && rimraf build/src && rimraf node",
"package:lib": "npm run build && cp ./package.json build && cd build && npm version \"5.0.0\" && npm pack", "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", "publish:lib": "npm run build && cd build && npm publish",
"lint:fix": "npx prettier --write 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'", "lint:fix": "npx prettier --write 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}' && npx prettier --write 'sasjs-tests/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}'", "lint": "npx prettier --check 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}' && npx prettier --check 'sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
"test": "jest --silent --coverage", "test": "jest --silent --coverage",
"prepublishOnly": "cp -r ./build/* . && rm -rf ./build", "prepublishOnly": "cp -r ./build/* . && rm -rf ./build",
"postpublish": "git clean -fd", "postpublish": "git clean -fd",
"semantic-release": "semantic-release", "semantic-release": "semantic-release",
"typedoc": "typedoc" "typedoc": "typedoc",
"postinstall": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
@@ -36,31 +38,38 @@
}, },
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.20", "@types/jest": "^26.0.23",
"@types/mime": "^2.0.3",
"@types/tough-cookie": "^4.0.0",
"cp": "^0.2.0", "cp": "^0.2.0",
"dotenv": "^8.2.0", "dotenv": "^10.0.0",
"jest": "^26.6.3", "jest": "^27.0.4",
"jest-extended": "^0.11.5", "jest-extended": "^0.11.5",
"mime": "^2.5.2",
"path": "^0.12.7", "path": "^0.12.7",
"process": "^0.11.10",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"semantic-release": "^17.3.9", "semantic-release": "^17.4.3",
"terser-webpack-plugin": "^4.2.3", "terser-webpack-plugin": "^5.1.3",
"ts-jest": "^25.5.1", "ts-jest": "^27.0.3",
"ts-loader": "^8.0.17", "ts-loader": "^9.2.2",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0", "tslint-config-prettier": "^1.18.0",
"typedoc": "^0.19.2", "typedoc": "^0.20.36",
"typedoc-neo-theme": "^1.1.0", "typedoc-neo-theme": "^1.1.1",
"typedoc-plugin-external-module-name": "^4.0.6", "typedoc-plugin-external-module-name": "^4.0.6",
"typescript": "^3.9.9", "typescript": "^4.3.2",
"webpack": "^5.21.2", "webpack": "^5.38.1",
"webpack-cli": "^4.5.0" "webpack-cli": "^4.7.2"
}, },
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"@sasjs/utils": "^2.20.1",
"axios": "^0.21.1", "axios": "^0.21.1",
"@sasjs/utils": "^2.5.0", "axios-cookiejar-support": "^1.0.1",
"form-data": "^3.0.0", "form-data": "^4.0.0",
"https": "^1.0.0" "https": "^1.0.0",
"tough-cookie": "^4.0.0",
"url": "^0.11.0"
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"trailingComma": "none", "trailingComma": "none",
"tabWidth": 2, "tabWidth": 2,
"semi": true, "semi": false,
"singleQuote": false "singleQuote": true
} }

View File

@@ -55,6 +55,7 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc; %inc mc;
filename ft15f001 temp; filename ft15f001 temp;
parmcards4; parmcards4;
%webout(FETCH)
%webout(OPEN) %webout(OPEN)
%macro x(); %macro x();
%do i=1 %to &_webin_file_count; %webout(OBJ,&&_webin_name&i) %end; %do i=1 %to &_webin_file_count; %webout(OBJ,&&_webin_name&i) %end;
@@ -63,6 +64,7 @@ parmcards4;
;;;; ;;;;
%mm_createwebservice(path=/Public/app/common,name=sendObj) %mm_createwebservice(path=/Public/app/common,name=sendObj)
parmcards4; parmcards4;
%webout(FETCH)
%webout(OPEN) %webout(OPEN)
%macro x(); %macro x();
%do i=1 %to &_webin_file_count; %webout(ARR,&&_webin_name&i) %end; %do i=1 %to &_webin_file_count; %webout(ARR,&&_webin_name&i) %end;
@@ -70,6 +72,10 @@ parmcards4;
%webout(CLOSE) %webout(CLOSE)
;;;; ;;;;
%mm_createwebservice(path=/Public/app/common,name=sendArr) %mm_createwebservice(path=/Public/app/common,name=sendArr)
parmcards4;
let he who hath understanding, reckon the number of the beast
;;;;
%mm_createwebservice(path=/Public/app/common,name=makeErr)
``` ```
### SAS Viya ### SAS Viya

View File

@@ -2004,26 +2004,42 @@
} }
}, },
"@sasjs/adapter": { "@sasjs/adapter": {
"version": "2.1.0", "version": "file:../build/sasjs-adapter-5.0.0.tgz",
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-2.1.0.tgz", "integrity": "sha512-nP9O64IslMipxSKAG8PV/X2fRr+0E4/RqwD8jXP2bqZ/QraiKZG0bQPC5hSKqEp7bho8+XpZ4HaXW3Vr9kEZ8Q==",
"integrity": "sha512-FdvxAPzXHHwCurH5B1RxSGeO6h+lVqDGAtrTAQDByT7HhsikAMFi6mW5dJR/1CKcI2rLOdE/479yYqjwfX8nwg==",
"requires": { "requires": {
"@sasjs/utils": "^2.0.2", "@sasjs/utils": "^2.14.0",
"es6-promise": "^4.2.8", "axios": "^0.21.1",
"form-data": "^3.0.0", "axios-cookiejar-support": "^1.0.1",
"form-data": "^4.0.0",
"https": "^1.0.0", "https": "^1.0.0",
"isomorphic-fetch": "^2.2.1" "tough-cookie": "^4.0.0",
"url": "^0.11.0"
}, },
"dependencies": { "dependencies": {
"form-data": { "form-data": {
"version": "3.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": { "requires": {
"asynckit": "^0.4.0", "asynckit": "^0.4.0",
"combined-stream": "^1.0.8", "combined-stream": "^1.0.8",
"mime-types": "^2.1.12" "mime-types": "^2.1.12"
} }
},
"tough-cookie": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
"integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==",
"requires": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.1.2"
}
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
} }
} }
}, },
@@ -2048,13 +2064,81 @@
} }
}, },
"@sasjs/utils": { "@sasjs/utils": {
"version": "2.2.0", "version": "2.15.5",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.2.0.tgz", "resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.15.5.tgz",
"integrity": "sha512-T01TYAFU+WQ1uAUaunZXg0MotQe5jn3auVuMPPbY5RU5VhIn4oVhr6qz3EHyNsYYKD1aj5pP7w2elnBzkgWhGw==", "integrity": "sha512-5HSWX5fy8D0Zy+Le+LgeRZG4vb5quLqhNiHw3dl0MS2hpsWACSRKia060jZk9LNHayKwBuusjlz5Ba0SyyaiEQ==",
"requires": { "requires": {
"@types/prompts": "^2.0.11",
"chalk": "^4.1.1",
"cli-table": "^0.3.6",
"consola": "^2.15.0", "consola": "^2.15.0",
"prompts": "^2.4.0", "fs-extra": "^10.0.0",
"prompts": "^2.4.1",
"valid-url": "^1.0.9" "valid-url": "^1.0.9"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
"integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"fs-extra": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
"integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
}
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"prompts": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.1.tgz",
"integrity": "sha512-EQyfIuO2hPDsX1L/blblV+H7I0knhgAd82cVneCwcdND9B8AuCDuRcBH6yIcG4dFzlOUqbazQqwGjx5xmsNLuQ==",
"requires": {
"kleur": "^3.0.3",
"sisteransi": "^1.0.5"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"requires": {
"has-flag": "^4.0.0"
}
}
} }
}, },
"@semantic-ui-react/event-stack": { "@semantic-ui-react/event-stack": {
@@ -2347,9 +2431,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
}, },
"@types/node": { "@types/node": {
"version": "14.14.25", "version": "14.14.41",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.25.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.41.tgz",
"integrity": "sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ==" "integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g=="
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
"version": "2.4.0", "version": "2.4.0",
@@ -2366,6 +2450,14 @@
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.1.6.tgz", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.1.6.tgz",
"integrity": "sha512-6gOkRe7OIioWAXfnO/2lFiv+SJichKVSys1mSsgyrYHSEjk8Ctv4tSR/Odvnu+HWlH2C8j53dahU03XmQdd5fA==" "integrity": "sha512-6gOkRe7OIioWAXfnO/2lFiv+SJichKVSys1mSsgyrYHSEjk8Ctv4tSR/Odvnu+HWlH2C8j53dahU03XmQdd5fA=="
}, },
"@types/prompts": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/@types/prompts/-/prompts-2.0.12.tgz",
"integrity": "sha512-Hr6osqfNg3IcQT3pJDXCsSnb0KnldY/hXeJCKJriwbZLnedN9n1e8kcZwLc25GIWULDb6h5aEyOBbf33XpZBXQ==",
"requires": {
"@types/node": "*"
}
},
"@types/prop-types": { "@types/prop-types": {
"version": "15.7.3", "version": "15.7.3",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
@@ -3396,6 +3488,30 @@
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.1.1.tgz", "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.1.1.tgz",
"integrity": "sha512-5Kgy8Cz6LPC9DJcNb3yjAXTu3XihQgEdnIg50c//zOC/MyLP0Clg+Y8Sh9ZjjnvBrDZU4DgXS9C3T9r4/scGZQ==" "integrity": "sha512-5Kgy8Cz6LPC9DJcNb3yjAXTu3XihQgEdnIg50c//zOC/MyLP0Clg+Y8Sh9ZjjnvBrDZU4DgXS9C3T9r4/scGZQ=="
}, },
"axios": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
"requires": {
"follow-redirects": "^1.10.0"
}
},
"axios-cookiejar-support": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/axios-cookiejar-support/-/axios-cookiejar-support-1.0.1.tgz",
"integrity": "sha512-IZJxnAJ99XxiLqNeMOqrPbfR7fRyIfaoSLdPUf4AMQEGkH8URs0ghJK/xtqBsD+KsSr3pKl4DEQjCn834pHMig==",
"requires": {
"is-redirect": "^1.0.0",
"pify": "^5.0.0"
},
"dependencies": {
"pify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz",
"integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA=="
}
}
},
"axobject-query": { "axobject-query": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
@@ -4445,6 +4561,14 @@
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==" "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A=="
}, },
"cli-table": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.6.tgz",
"integrity": "sha512-ZkNZbnZjKERTY5NwC2SeMeLeifSPq/pubeRoTpdr3WchLlnZg6hEgvHkK5zL7KNFdd9PmHN8lxrENUwI3cE8vQ==",
"requires": {
"colors": "1.0.3"
}
},
"cliui": { "cliui": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
@@ -4553,6 +4677,11 @@
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw=="
}, },
"colors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
"integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs="
},
"combined-stream": { "combined-stream": {
"version": "1.0.8", "version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@@ -4677,9 +4806,9 @@
"integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==" "integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg=="
}, },
"consola": { "consola": {
"version": "2.15.2", "version": "2.15.3",
"resolved": "https://registry.npmjs.org/consola/-/consola-2.15.2.tgz", "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz",
"integrity": "sha512-VxqWw5C8O/mQpZYtfaaSCDJcVK3AxyvQ26rhgvyAI4j/QJISh8DLwFS8GQU+9154u4ngyCsSlnyIAYJme9kQug==" "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw=="
}, },
"console-browserify": { "console-browserify": {
"version": "1.2.0", "version": "1.2.0",
@@ -5722,24 +5851,6 @@
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
}, },
"encoding": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"requires": {
"iconv-lite": "^0.6.2"
},
"dependencies": {
"iconv-lite": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz",
"integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==",
"requires": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
}
}
}
},
"end-of-stream": { "end-of-stream": {
"version": "1.4.4", "version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
@@ -5882,11 +5993,6 @@
"es6-symbol": "^3.1.1" "es6-symbol": "^3.1.1"
} }
}, },
"es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
},
"es6-symbol": { "es6-symbol": {
"version": "3.1.3", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
@@ -8496,6 +8602,11 @@
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz",
"integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=" "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c="
}, },
"is-redirect": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz",
"integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ="
},
"is-regex": { "is-regex": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz",
@@ -8584,15 +8695,6 @@
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
}, },
"isomorphic-fetch": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
"integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=",
"requires": {
"node-fetch": "^1.0.1",
"whatwg-fetch": ">=0.10.0"
}
},
"isstream": { "isstream": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
@@ -11423,15 +11525,6 @@
} }
} }
}, },
"node-fetch": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
"requires": {
"encoding": "^0.1.11",
"is-stream": "^1.0.1"
}
},
"node-forge": { "node-forge": {
"version": "0.10.0", "version": "0.10.0",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",

View File

@@ -4,10 +4,10 @@
"homepage": ".", "homepage": ".",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@sasjs/adapter": "^2.1.0", "@sasjs/adapter": "file:../build/sasjs-adapter-5.0.0.tgz",
"@sasjs/test-framework": "^1.4.0", "@sasjs/test-framework": "^1.4.0",
"@types/jest": "^26.0.20", "@types/jest": "^26.0.20",
"@types/node": "^14.14.25", "@types/node": "^14.14.41",
"@types/react": "^17.0.1", "@types/react": "^17.0.1",
"@types/react-dom": "^17.0.0", "@types/react-dom": "^17.0.0",
"@types/react-router-dom": "^5.1.7", "@types/react-router-dom": "^5.1.7",
@@ -23,8 +23,8 @@
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"update:adapter": "cd .. && npm run package:lib && cd sasjs-tests && npm i ../build/sasjs-adapter-5.0.0.tgz", "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:tests": "rsync -avhe ssh ./build/* --delete $SSH_ACCOUNT:$DEPLOY_PATH",
"deploy": "npm run update:adapter && npm run deploy:tests" "deploy": "npm run update:adapter && npm run build && npm run deploy:tests"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"

View File

@@ -6,7 +6,7 @@
"appLoc": "/Public/app", "appLoc": "/Public/app",
"serverType": "SASVIYA", "serverType": "SASVIYA",
"debug": false, "debug": false,
"contextName": "SharedCompute", "contextName": "sasjs adapter compute context",
"useComputeApi": true "useComputeApi": true
} }
} }

View File

@@ -1,34 +1,39 @@
import React, { ReactElement, useState, useContext, useEffect } from "react"; import React, { ReactElement, useState, useContext, useEffect } from 'react'
import { TestSuiteRunner, TestSuite, AppContext } from "@sasjs/test-framework"; import { TestSuiteRunner, TestSuite, AppContext } from '@sasjs/test-framework'
import { basicTests } from "./testSuites/Basic"; import { basicTests } from './testSuites/Basic'
import { sendArrTests, sendObjTests } from "./testSuites/RequestData"; import { sendArrTests, sendObjTests } from './testSuites/RequestData'
import { specialCaseTests } from "./testSuites/SpecialCases"; import { specialCaseTests } from './testSuites/SpecialCases'
import { sasjsRequestTests } from "./testSuites/SasjsRequests"; import { sasjsRequestTests } from './testSuites/SasjsRequests'
import "@sasjs/test-framework/dist/index.css"; import '@sasjs/test-framework/dist/index.css'
import { computeTests } from "./testSuites/Compute"; import { computeTests } from './testSuites/Compute'
const App = (): ReactElement<{}> => { const App = (): ReactElement<{}> => {
const { adapter, config } = useContext(AppContext); const { adapter, config } = useContext(AppContext)
const [testSuites, setTestSuites] = useState<TestSuite[]>([]); const [testSuites, setTestSuites] = useState<TestSuite[]>([])
useEffect(() => { useEffect(() => {
if (adapter) { if (adapter) {
setTestSuites([ const testSuites = [
basicTests(adapter, config.userName, config.password), basicTests(adapter, config.userName, config.password),
sendArrTests(adapter), sendArrTests(adapter),
sendObjTests(adapter), sendObjTests(adapter),
specialCaseTests(adapter), specialCaseTests(adapter),
sasjsRequestTests(adapter), sasjsRequestTests(adapter)
computeTests(adapter) ]
]);
if (adapter.getSasjsConfig().serverType === 'SASVIYA') {
testSuites.push(computeTests(adapter))
}
setTestSuites(testSuites)
} }
}, [adapter, config]); }, [adapter, config])
return ( return (
<div className="app"> <div className="app">
{adapter && testSuites && <TestSuiteRunner testSuites={testSuites} />} {adapter && testSuites && <TestSuiteRunner testSuites={testSuites} />}
</div> </div>
); )
}; }
export default App; export default App

View File

@@ -1,22 +1,22 @@
import React, { ReactElement, useState, useCallback, useContext } from "react"; import React, { ReactElement, useState, useCallback, useContext } from 'react'
import "./Login.scss"; import './Login.scss'
import { AppContext } from "@sasjs/test-framework"; import { AppContext } from '@sasjs/test-framework'
import { Redirect } from "react-router-dom"; import { Redirect } from 'react-router-dom'
const Login = (): ReactElement<{}> => { const Login = (): ReactElement<{}> => {
const [username, setUsername] = useState(""); const [username, setUsername] = useState('')
const [password, setPassword] = useState(""); const [password, setPassword] = useState('')
const appContext = useContext(AppContext); const appContext = useContext(AppContext)
const handleSubmit = useCallback( const handleSubmit = useCallback(
(e) => { (e) => {
e.preventDefault(); e.preventDefault()
appContext.adapter.logIn(username, password).then((res) => { appContext.adapter.logIn(username, password).then((res) => {
appContext.setIsLoggedIn(res.isLoggedIn); appContext.setIsLoggedIn(res.isLoggedIn)
}); })
}, },
[username, password, appContext] [username, password, appContext]
); )
return !appContext.isLoggedIn ? ( return !appContext.isLoggedIn ? (
<div className="login-container"> <div className="login-container">
@@ -48,7 +48,7 @@ const Login = (): ReactElement<{}> => {
</div> </div>
) : ( ) : (
<Redirect to="/" /> <Redirect to="/" />
); )
}; }
export default Login; export default Login

View File

@@ -1,23 +1,23 @@
import React, { ReactElement, useContext, FunctionComponent } from "react"; import React, { ReactElement, useContext, FunctionComponent } from 'react'
import { Redirect, Route } from "react-router-dom"; import { Redirect, Route } from 'react-router-dom'
import { AppContext } from "@sasjs/test-framework"; import { AppContext } from '@sasjs/test-framework'
interface PrivateRouteProps { interface PrivateRouteProps {
component: FunctionComponent; component: FunctionComponent
exact?: boolean; exact?: boolean
path: string; path: string
} }
const PrivateRoute = ( const PrivateRoute = (
props: PrivateRouteProps props: PrivateRouteProps
): ReactElement<PrivateRouteProps> => { ): ReactElement<PrivateRouteProps> => {
const { component, path, exact } = props; const { component, path, exact } = props
const appContext = useContext(AppContext); const appContext = useContext(AppContext)
return appContext.isLoggedIn ? ( return appContext.isLoggedIn ? (
<Route component={component} path={path} exact={exact} /> <Route component={component} path={path} exact={exact} />
) : ( ) : (
<Redirect to="/login" /> <Redirect to="/login" />
); )
}; }
export default PrivateRoute; export default PrivateRoute

View File

@@ -1,12 +1,12 @@
import React from "react"; import React from 'react'
import ReactDOM from "react-dom"; import ReactDOM from 'react-dom'
import { Route, HashRouter, Switch } from "react-router-dom"; import { Route, HashRouter, Switch } from 'react-router-dom'
import "./index.scss"; import './index.scss'
import * as serviceWorker from "./serviceWorker"; import * as serviceWorker from './serviceWorker'
import { AppProvider } from "@sasjs/test-framework"; import { AppProvider } from '@sasjs/test-framework'
import PrivateRoute from "./PrivateRoute"; import PrivateRoute from './PrivateRoute'
import Login from "./Login"; import Login from './Login'
import App from "./App"; import App from './App'
ReactDOM.render( ReactDOM.render(
<AppProvider> <AppProvider>
@@ -17,10 +17,10 @@ ReactDOM.render(
</Switch> </Switch>
</HashRouter> </HashRouter>
</AppProvider>, </AppProvider>,
document.getElementById("root") document.getElementById('root')
); )
// If you want your app to work offline and load faster, you can change // If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls. // unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA // Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister(); serviceWorker.unregister()

View File

@@ -11,46 +11,46 @@
// opt-in, read https://bit.ly/CRA-PWA // opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean( const isLocalhost = Boolean(
window.location.hostname === "localhost" || window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address. // [::1] is the IPv6 localhost address.
window.location.hostname === "[::1]" || window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4. // 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match( window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
) )
); )
export function register(config) { 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. // The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
if (publicUrl.origin !== window.location.origin) { if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin // Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to // from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374 // serve assets; see https://github.com/facebook/create-react-app/issues/2374
return; return
} }
window.addEventListener("load", () => { window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
if (isLocalhost) { if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not. // This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config); checkValidServiceWorker(swUrl, config)
// Add some additional logging to localhost, pointing developers to the // Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation. // service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => { navigator.serviceWorker.ready.then(() => {
console.log( console.log(
"This web app is being served cache-first by a service " + 'This web app is being served cache-first by a service ' +
"worker. To learn more, visit https://bit.ly/CRA-PWA" 'worker. To learn more, visit https://bit.ly/CRA-PWA'
); )
}); })
} else { } else {
// Is not localhost. Just register service worker // Is not localhost. Just register service worker
registerValidSW(swUrl, config); registerValidSW(swUrl, config)
} }
}); })
} }
} }
@@ -59,83 +59,83 @@ function registerValidSW(swUrl, config) {
.register(swUrl) .register(swUrl)
.then((registration) => { .then((registration) => {
registration.onupdatefound = () => { registration.onupdatefound = () => {
const installingWorker = registration.installing; const installingWorker = registration.installing
if (installingWorker == null) { if (installingWorker == null) {
return; return
} }
installingWorker.onstatechange = () => { installingWorker.onstatechange = () => {
if (installingWorker.state === "installed") { if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) { if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched, // At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older // but the previous service worker will still serve the older
// content until all client tabs are closed. // content until all client tabs are closed.
console.log( console.log(
"New content is available and will be used when all " + 'New content is available and will be used when all ' +
"tabs for this page are closed. See https://bit.ly/CRA-PWA." 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
); )
// Execute callback // Execute callback
if (config && config.onUpdate) { if (config && config.onUpdate) {
config.onUpdate(registration); config.onUpdate(registration)
} }
} else { } else {
// At this point, everything has been precached. // At this point, everything has been precached.
// It's the perfect time to display a // It's the perfect time to display a
// "Content is cached for offline use." message. // "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 // Execute callback
if (config && config.onSuccess) { if (config && config.onSuccess) {
config.onSuccess(registration); config.onSuccess(registration)
} }
} }
} }
}; }
}; }
}) })
.catch((error) => { .catch((error) => {
console.error("Error during service worker registration:", error); console.error('Error during service worker registration:', error)
}); })
} }
function checkValidServiceWorker(swUrl, config) { function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page. // Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, { 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. // 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 ( if (
response.status === 404 || 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. // No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => { navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => { registration.unregister().then(() => {
window.location.reload(); window.location.reload()
}); })
}); })
} else { } else {
// Service worker found. Proceed as normal. // Service worker found. Proceed as normal.
registerValidSW(swUrl, config); registerValidSW(swUrl, config)
} }
}) })
.catch(() => { .catch(() => {
console.log( 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() { export function unregister() {
if ("serviceWorker" in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready navigator.serviceWorker.ready
.then((registration) => { .then((registration) => {
registration.unregister(); registration.unregister()
}) })
.catch((error) => { .catch((error) => {
console.error(error.message); console.error(error.message)
}); })
} }
} }

View File

@@ -2,4 +2,4 @@
// allows you to do things like: // allows you to do things like:
// expect(element).toHaveTextContent(/react/i) // expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom // learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom/extend-expect"; import '@testing-library/jest-dom/extend-expect'

View File

@@ -1,65 +1,102 @@
import SASjs, { SASjsConfig } from "@sasjs/adapter"; import SASjs, { SASjsConfig } from '@sasjs/adapter'
import { TestSuite } from "@sasjs/test-framework"; import { TestSuite } from '@sasjs/test-framework'
import { ServerType } from "@sasjs/utils/types"; import { ServerType } from '@sasjs/utils/types'
const stringData: any = { table1: [{ col1: 'first col value' }] }
const defaultConfig: SASjsConfig = { const defaultConfig: SASjsConfig = {
serverUrl: window.location.origin, serverUrl: window.location.origin,
pathSAS9: "/SASStoredProcess/do", pathSAS9: '/SASStoredProcess/do',
pathSASViya: "/SASJobExecution", pathSASViya: '/SASJobExecution',
appLoc: "/Public/seedapp", appLoc: '/Public/seedapp',
serverType: ServerType.SasViya, serverType: ServerType.SasViya,
debug: false, debug: false,
contextName: "SAS Job Execution compute context", contextName: 'SAS Job Execution compute context',
useComputeApi: false, useComputeApi: false,
allowInsecureRequests: false allowInsecureRequests: false
}; }
const customConfig = { const customConfig = {
serverUrl: "http://url.com", serverUrl: 'http://url.com',
pathSAS9: "sas9", pathSAS9: 'sas9',
pathSASViya: "viya", pathSASViya: 'viya',
appLoc: "/Public/seedapp", appLoc: '/Public/seedapp',
serverType: ServerType.Sas9, serverType: ServerType.Sas9,
debug: false debug: false
}; }
export const basicTests = ( export const basicTests = (
adapter: SASjs, adapter: SASjs,
userName: string, userName: string,
password: string password: string
): TestSuite => ({ ): TestSuite => ({
name: "Basic Tests", name: 'Basic Tests',
tests: [ tests: [
{ {
title: "Log in", title: 'Log in',
description: "Should log the user in", description: 'Should log the user in',
test: async () => { test: async () => {
return adapter.logIn(userName, password); return adapter.logIn(userName, password)
}, },
assertion: (response: any) => assertion: (response: any) =>
response && response.isLoggedIn && response.userName === userName response && response.isLoggedIn && response.userName === userName
}, },
{ {
title: "Multiple Log in attempts", title: 'Multiple Log in attempts',
description: description:
"Should fail on first attempt and should log the user in on second attempt", 'Should fail on first attempt and should log the user in on second attempt',
test: async () => { test: async () => {
await adapter.logOut(); await adapter.logOut()
await adapter.logIn("invalid", "invalid"); await adapter.logIn('invalid', 'invalid')
return adapter.logIn(userName, password); return adapter.logIn(userName, password)
}, },
assertion: (response: any) => assertion: (response: any) =>
response && response.isLoggedIn && response.userName === userName response && response.isLoggedIn && response.userName === userName
}, },
{ {
title: "Default config", title: 'Trigger login callback',
description: description:
"Should instantiate with default config when none is provided", 'Should trigger required login callback and after successful login, it should finish the request',
test: async () => { test: async () => {
return Promise.resolve(new SASjs()); await adapter.logOut()
return await adapter.request(
'common/sendArr',
stringData,
undefined,
() => {
adapter.logIn(userName, password)
}
)
},
assertion: (response: any) => {
return response.table1[0][0] === stringData.table1[0].col1
}
},
{
title: 'Request with debug on',
description:
'Should complete successful request with debugging switched on',
test: async () => {
const config = {
debug: true
}
return await adapter.request('common/sendArr', stringData, config)
},
assertion: (response: any) => {
return response.table1[0][0] === stringData.table1[0].col1
}
},
{
title: 'Default config',
description:
'Should instantiate with default config when none is provided',
test: async () => {
return Promise.resolve(new SASjs())
}, },
assertion: (sasjsInstance: SASjs) => { assertion: (sasjsInstance: SASjs) => {
const sasjsConfig = sasjsInstance.getSasjsConfig(); const sasjsConfig = sasjsInstance.getSasjsConfig()
return ( return (
sasjsConfig.serverUrl === defaultConfig.serverUrl && sasjsConfig.serverUrl === defaultConfig.serverUrl &&
@@ -68,17 +105,17 @@ export const basicTests = (
sasjsConfig.appLoc === defaultConfig.appLoc && sasjsConfig.appLoc === defaultConfig.appLoc &&
sasjsConfig.serverType === defaultConfig.serverType && sasjsConfig.serverType === defaultConfig.serverType &&
sasjsConfig.debug === defaultConfig.debug sasjsConfig.debug === defaultConfig.debug
); )
} }
}, },
{ {
title: "Custom config", title: 'Custom config',
description: "Should use fully custom config whenever supplied", description: 'Should use fully custom config whenever supplied',
test: async () => { test: async () => {
return Promise.resolve(new SASjs(customConfig)); return Promise.resolve(new SASjs(customConfig))
}, },
assertion: (sasjsInstance: SASjs) => { assertion: (sasjsInstance: SASjs) => {
const sasjsConfig = sasjsInstance.getSasjsConfig(); const sasjsConfig = sasjsInstance.getSasjsConfig()
return ( return (
sasjsConfig.serverUrl === customConfig.serverUrl && sasjsConfig.serverUrl === customConfig.serverUrl &&
sasjsConfig.pathSAS9 === customConfig.pathSAS9 && sasjsConfig.pathSAS9 === customConfig.pathSAS9 &&
@@ -86,28 +123,55 @@ export const basicTests = (
sasjsConfig.appLoc === customConfig.appLoc && sasjsConfig.appLoc === customConfig.appLoc &&
sasjsConfig.serverType === customConfig.serverType && sasjsConfig.serverType === customConfig.serverType &&
sasjsConfig.debug === customConfig.debug sasjsConfig.debug === customConfig.debug
); )
} }
}, },
{ {
title: "Config overrides", title: 'Config overrides',
description: "Should override default config with supplied properties", description: 'Should override default config with supplied properties',
test: async () => { test: async () => {
return Promise.resolve( return Promise.resolve(
new SASjs({ serverUrl: "http://test.com", debug: false }) new SASjs({ serverUrl: 'http://test.com', debug: false })
); )
}, },
assertion: (sasjsInstance: SASjs) => { assertion: (sasjsInstance: SASjs) => {
const sasjsConfig = sasjsInstance.getSasjsConfig(); const sasjsConfig = sasjsInstance.getSasjsConfig()
return ( return (
sasjsConfig.serverUrl === "http://test.com" && sasjsConfig.serverUrl === 'http://test.com' &&
sasjsConfig.pathSAS9 === defaultConfig.pathSAS9 && sasjsConfig.pathSAS9 === defaultConfig.pathSAS9 &&
sasjsConfig.pathSASViya === defaultConfig.pathSASViya && sasjsConfig.pathSASViya === defaultConfig.pathSASViya &&
sasjsConfig.appLoc === defaultConfig.appLoc && sasjsConfig.appLoc === defaultConfig.appLoc &&
sasjsConfig.serverType === defaultConfig.serverType && sasjsConfig.serverType === defaultConfig.serverType &&
sasjsConfig.debug === false sasjsConfig.debug === false
); )
}
},
{
title: 'Request with extra attributes on JES approach',
description:
'Should complete successful request with extra attributes present in response',
test: async () => {
const config = {
useComputeApi: false
}
return await adapter.request(
'common/sendArr',
stringData,
config,
undefined,
undefined,
['output', 'file', 'data']
)
},
assertion: (response: any) => {
const responseKeys: any = Object.keys(response)
return (
responseKeys.includes('file') &&
responseKeys.includes('output') &&
responseKeys.includes('data')
)
} }
} }
] ]
}); })

View File

@@ -1,106 +1,100 @@
import SASjs from "@sasjs/adapter"; import SASjs from '@sasjs/adapter'
import { TestSuite } from "@sasjs/test-framework"; import { TestSuite } from '@sasjs/test-framework'
export const computeTests = (adapter: SASjs): TestSuite => ({ export const computeTests = (adapter: SASjs): TestSuite => ({
name: "Compute", name: 'Compute',
tests: [ tests: [
{ {
title: "Start Compute Job - not waiting for result", title: 'Start Compute Job - not waiting for result',
description: "Should start a compute job and return the session", description: 'Should start a compute job and return the session',
test: () => { test: () => {
const data: any = { table1: [{ col1: "first col value" }] }; const data: any = { table1: [{ col1: 'first col value' }] }
return adapter.startComputeJob("/Public/app/common/sendArr", data); return adapter.startComputeJob('/Public/app/common/sendArr', data)
}, },
assertion: (res: any) => { assertion: (res: any) => {
const expectedProperties = ["id", "applicationName", "attributes"]; const expectedProperties = ['id', 'applicationName', 'attributes']
return validate(expectedProperties, res); return validate(expectedProperties, res)
} }
}, },
{ {
title: "Start Compute Job - waiting for result", title: 'Start Compute Job - waiting for result',
description: "Should start a compute job and return the job", description: 'Should start a compute job and return the job',
test: () => { test: () => {
const data: any = { table1: [{ col1: "first col value" }] }; const data: any = { table1: [{ col1: 'first col value' }] }
return adapter.startComputeJob( return adapter.startComputeJob(
"/Public/app/common/sendArr", '/Public/app/common/sendArr',
data, data,
{}, {},
"", '',
true true
); )
}, },
assertion: (res: any) => { assertion: (res: any) => {
const expectedProperties = [ const expectedProperties = [
"id", 'id',
"state", 'state',
"creationTimeStamp", 'creationTimeStamp',
"jobConditionCode" 'jobConditionCode'
]; ]
return validate(expectedProperties, res.job); return validate(expectedProperties, res.job)
} }
}, },
{ {
title: "Execute Script Viya - complete job", title: 'Execute Script Viya - complete job',
description: "Should execute sas file and return log", description: 'Should execute sas file and return log',
test: () => { test: () => {
const fileLines = [ const fileLines = [`data;`, `do x=1 to 100;`, `output;`, `end;`, `run;`]
`data;`,
`do x=1 to 100;`,
`output;`,
`end;`,
`run;`
];
return adapter.executeScriptSASViya( return adapter.executeScriptSASViya(
"sasCode.sas", 'sasCode.sas',
fileLines, fileLines,
"SAS Studio compute context", 'SAS Studio compute context',
undefined, undefined,
true true
); )
}, },
assertion: (res: any) => { assertion: (res: any) => {
const expectedLogContent = `1 data;\\n2 do x=1 to 100;\\n3 output;\\n4 end;\\n5 run;\\n\\n`; const expectedLogContent = `1 data;\\n2 do x=1 to 100;\\n3 output;\\n4 end;\\n5 run;\\n\\n`
return validateLog(expectedLogContent, res.log); return validateLog(expectedLogContent, res.log)
} }
}, },
{ {
title: "Execute Script Viya - failed job", title: 'Execute Script Viya - failed job',
description: "Should execute sas file and return log", description: 'Should execute sas file and return log',
test: () => { test: () => {
const fileLines = [`%abort;`]; const fileLines = [`%abort;`]
return adapter return adapter
.executeScriptSASViya( .executeScriptSASViya(
"sasCode.sas", 'sasCode.sas',
fileLines, fileLines,
"SAS Studio compute context", 'SAS Studio compute context',
undefined, undefined,
true true
) )
.catch((err: any) => err); .catch((err: any) => err)
}, },
assertion: (res: any) => { assertion: (res: any) => {
const expectedLogContent = `1 %abort;\\nERROR: The %ABORT statement is not valid in open code.\\n`; const expectedLogContent = `1 %abort;\\nERROR: The %ABORT statement is not valid in open code.\\n`
return validateLog(expectedLogContent, res.log); return validateLog(expectedLogContent, res.log)
} }
} }
] ]
}); })
const validateLog = (text: string, log: string): boolean => { const validateLog = (text: string, log: string): boolean => {
const isValid = JSON.stringify(log).includes(text); const isValid = JSON.stringify(log).includes(text)
return isValid; return isValid
}; }
const validate = (expectedProperties: string[], data: any): boolean => { const validate = (expectedProperties: string[], data: any): boolean => {
const actualProperties = Object.keys(data); const actualProperties = Object.keys(data)
const isValid = expectedProperties.every((property) => const isValid = expectedProperties.every((property) =>
actualProperties.includes(property) actualProperties.includes(property)
); )
return isValid; return isValid
}; }

View File

@@ -1,111 +1,112 @@
import SASjs from "@sasjs/adapter"; import SASjs from '@sasjs/adapter'
import { TestSuite } from "@sasjs/test-framework"; import { TestSuite } from '@sasjs/test-framework'
const stringData: any = { table1: [{ col1: "first col value" }] }; const stringData: any = { table1: [{ col1: 'first col value' }] }
const numericData: any = { table1: [{ col1: 3.14159265 }] }; const numericData: any = { table1: [{ col1: 3.14159265 }] }
const multiColumnData: any = { 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 = { const multipleRowsWithNulls: any = {
table1: [ table1: [
{ col1: 42, col2: null, col3: "x", col4: "" }, { col1: 42, col2: null, col3: 'x', col4: '' },
{ col1: 42, col2: null, col3: "x", col4: "" }, { col1: 42, col2: null, col3: 'x', col4: '' },
{ 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" } { col1: 42, col2: 1.62, col3: 'x', col4: 'x' }
] ]
}; }
const multipleColumnsWithNulls: any = { const multipleColumnsWithNulls: any = {
table1: [ table1: [
{ col1: 42, col2: null, col3: "x", col4: null }, { col1: 42, col2: null, col3: 'x', col4: null },
{ col1: 42, col2: null, col3: "x", col4: null }, { col1: 42, col2: null, col3: 'x', col4: null },
{ 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: "" } { col1: 42, col2: null, col3: 'x', col4: '' }
] ]
}; }
const getLongStringData = (length = 32764) => { const getLongStringData = (length = 32764) => {
let x = "X"; let x = 'X'
for (let i = 1; i <= length; i++) { for (let i = 1; i <= length; i++) {
x = x + "X"; x = x + 'X'
} }
const data: any = { table1: [{ col1: x }] }; const data: any = { table1: [{ col1: x }] }
return data; return data
}; }
const getLargeObjectData = () => { const getLargeObjectData = () => {
const data = { table1: [{ big: "data" }] }; const data = { table1: [{ big: 'data' }] }
for (let i = 1; i < 10000; i++) { for (let i = 1; i < 10000; i++) {
data.table1.push(data.table1[0]); data.table1.push(data.table1[0])
} }
return data; return data
}; }
export const sendArrTests = (adapter: SASjs): TestSuite => ({ export const sendArrTests = (adapter: SASjs): TestSuite => ({
name: "sendArr", name: 'sendArr',
tests: [ tests: [
{ {
title: "Absolute paths", title: 'Absolute paths',
description: "Should work with absolute paths to SAS jobs", description: 'Should work with absolute paths to SAS jobs',
test: () => { test: () => {
return adapter.request("/Public/app/common/sendArr", stringData); return adapter.request('/Public/app/common/sendArr', stringData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return res.table1[0][0] === stringData.table1[0].col1; return res.table1[0][0] === stringData.table1[0].col1
} }
}, },
{ {
title: "Single string value", title: 'Single string value',
description: "Should send an array with a single string value", description: 'Should send an array with a single string value',
test: () => { test: () => {
return adapter.request("common/sendArr", stringData); return adapter.request('common/sendArr', stringData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return res.table1[0][0] === stringData.table1[0].col1; return res.table1[0][0] === stringData.table1[0].col1
} }
}, },
{ {
title: "Long string value", title: 'Long string value',
description: description:
"Should send an array with a long string value under 32765 characters", 'Should send an array with a long string value under 32765 characters',
test: () => { test: () => {
return adapter.request("common/sendArr", getLongStringData()); return adapter.request('common/sendArr', getLongStringData())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const longStringData = getLongStringData(); const longStringData = getLongStringData()
return res.table1[0][0] === longStringData.table1[0].col1; return res.table1[0][0] === longStringData.table1[0].col1
} }
}, },
{ {
title: "Overly long string value", title: 'Overly long string value',
description: description:
"Should error out with long string values over 32765 characters", 'Should error out with long string values over 32765 characters',
test: () => { test: () => {
const data = getLongStringData(32767); const data = getLongStringData(32767)
return adapter.request("common/sendArr", data).catch((e) => e); return adapter.request('common/sendArr', data).catch((e) => e)
}, },
assertion: (error: any) => { assertion: (error: any) => {
return !!error && !!error.error && !!error.error.message; return !!error && !!error.error && !!error.error.message
} }
}, },
{ {
title: "Single numeric value", title: 'Single numeric value',
description: "Should send an array with a single numeric value", description: 'Should send an array with a single numeric value',
test: () => { test: () => {
return adapter.request("common/sendArr", numericData); return adapter.request('common/sendArr', numericData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return res.table1[0][0] === numericData.table1[0].col1; return res.table1[0][0] === numericData.table1[0].col1
} }
}, },
{ {
title: "Multiple columns", title: 'Multiple columns',
description: "Should handle data with multiple columns", description: 'Should handle data with multiple columns',
test: () => { test: () => {
return adapter.request("common/sendArr", multiColumnData); return adapter.request('common/sendArr', multiColumnData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return ( return (
@@ -113,143 +114,189 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
res.table1[0][1] === multiColumnData.table1[0].col2 && res.table1[0][1] === multiColumnData.table1[0].col2 &&
res.table1[0][2] === multiColumnData.table1[0].col3 && res.table1[0][2] === multiColumnData.table1[0].col3 &&
res.table1[0][3] === multiColumnData.table1[0].col4 res.table1[0][3] === multiColumnData.table1[0].col4
); )
} }
}, },
{ {
title: "Multiple rows with nulls", title: 'Multiple rows with nulls',
description: "Should handle data with multiple rows with null values", description: 'Should handle data with multiple rows with null values',
test: () => { test: () => {
return adapter.request("common/sendArr", multipleRowsWithNulls); return adapter.request('common/sendArr', multipleRowsWithNulls)
}, },
assertion: (res: any) => { assertion: (res: any) => {
let result = true; let result = true
multipleRowsWithNulls.table1.forEach((_: any, index: number) => { multipleRowsWithNulls.table1.forEach((_: any, index: number) => {
result = result =
result && result &&
res.table1[index][0] === multipleRowsWithNulls.table1[index].col1; res.table1[index][0] === multipleRowsWithNulls.table1[index].col1
result = result =
result && result &&
res.table1[index][1] === multipleRowsWithNulls.table1[index].col2; res.table1[index][1] === multipleRowsWithNulls.table1[index].col2
result = result =
result && result &&
res.table1[index][2] === multipleRowsWithNulls.table1[index].col3; res.table1[index][2] === multipleRowsWithNulls.table1[index].col3
result =
result &&
res.table1[index][3] === multipleRowsWithNulls.table1[index].col4;
});
return result;
}
},
{
title: "Multiple columns with nulls",
description: "Should handle data with multiple columns with null values",
test: () => {
return adapter.request("common/sendArr", multipleColumnsWithNulls);
},
assertion: (res: any) => {
let result = true;
multipleColumnsWithNulls.table1.forEach((_: any, index: number) => {
result =
result &&
res.table1[index][0] ===
multipleColumnsWithNulls.table1[index].col1;
result =
result &&
res.table1[index][1] ===
multipleColumnsWithNulls.table1[index].col2;
result =
result &&
res.table1[index][2] ===
multipleColumnsWithNulls.table1[index].col3;
result = result =
result && result &&
res.table1[index][3] === res.table1[index][3] ===
(multipleColumnsWithNulls.table1[index].col4 || ""); (multipleRowsWithNulls.table1[index].col4 || ' ')
}); })
return result; return result
}
},
{
title: 'Multiple columns with nulls',
description: 'Should handle data with multiple columns with null values',
test: () => {
return adapter.request('common/sendArr', multipleColumnsWithNulls)
},
assertion: (res: any) => {
let result = true
multipleColumnsWithNulls.table1.forEach((_: any, index: number) => {
result =
result &&
res.table1[index][0] === multipleColumnsWithNulls.table1[index].col1
result =
result &&
res.table1[index][1] === multipleColumnsWithNulls.table1[index].col2
result =
result &&
res.table1[index][2] === multipleColumnsWithNulls.table1[index].col3
result =
result &&
res.table1[index][3] ===
(multipleColumnsWithNulls.table1[index].col4 || ' ')
})
return result
} }
} }
] ]
}); })
export const sendObjTests = (adapter: SASjs): TestSuite => ({ export const sendObjTests = (adapter: SASjs): TestSuite => ({
name: "sendObj", name: 'sendObj',
tests: [ tests: [
{ {
title: "Invalid column name", title: 'Table name starts with numeric',
description: "Should throw an error", description: 'Should throw an error',
test: async () => { test: async () => {
const invalidData: any = { const invalidData: any = {
"1 invalid table": [{ col1: 42 }] '1InvalidTable': [{ col1: 42 }]
}; }
return adapter.request("common/sendObj", invalidData).catch((e) => e); return adapter.request('common/sendObj', invalidData).catch((e) => e)
}, },
assertion: (error: any) => assertion: (error: any) =>
!!error && !!error.error && !!error.error.message !!error && !!error.error && !!error.error.message
}, },
{ {
title: "Single string value", title: 'Table name contains a space',
description: "Should send an object with a single string value", description: 'Should throw an error',
test: async () => {
const invalidData: any = {
'an invalidTable': [{ col1: 42 }]
}
return adapter.request('common/sendObj', invalidData).catch((e) => e)
},
assertion: (error: any) =>
!!error && !!error.error && !!error.error.message
},
{
title: 'Table name contains a special character',
description: 'Should throw an error',
test: async () => {
const invalidData: any = {
'anInvalidTable#': [{ col1: 42 }]
}
return adapter.request('common/sendObj', invalidData).catch((e) => e)
},
assertion: (error: any) =>
!!error && !!error.error && !!error.error.message
},
{
title: 'Table name exceeds max length of 32 characters',
description: 'Should throw an error',
test: async () => {
const invalidData: any = {
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: [{ col1: 42 }]
}
return adapter.request('common/sendObj', invalidData).catch((e) => e)
},
assertion: (error: any) =>
!!error && !!error.error && !!error.error.message
},
{
title: "Invalid data object's structure",
description: 'Should throw an error',
test: async () => {
const invalidData: any = {
inData: [[{ data: 'value' }]]
}
return adapter.request('common/sendObj', invalidData).catch((e) => e)
},
assertion: (error: any) =>
!!error && !!error.error && !!error.error.message
},
{
title: 'Single string value',
description: 'Should send an object with a single string value',
test: () => { test: () => {
return adapter.request("common/sendObj", stringData); return adapter.request('common/sendObj', stringData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return res.table1[0].COL1 === stringData.table1[0].col1; return res.table1[0].COL1 === stringData.table1[0].col1
} }
}, },
{ {
title: "Long string value", title: 'Long string value',
description: description:
"Should send an object with a long string value under 32765 characters", 'Should send an object with a long string value under 32765 characters',
test: () => { test: () => {
return adapter.request("common/sendObj", getLongStringData()); return adapter.request('common/sendObj', getLongStringData())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const longStringData = getLongStringData(); const longStringData = getLongStringData()
return res.table1[0].COL1 === longStringData.table1[0].col1; return res.table1[0].COL1 === longStringData.table1[0].col1
} }
}, },
{ {
title: "Overly long string value", title: 'Overly long string value',
description: description:
"Should error out with long string values over 32765 characters", 'Should error out with long string values over 32765 characters',
test: () => { test: () => {
return adapter return adapter
.request("common/sendObj", getLongStringData(32767)) .request('common/sendObj', getLongStringData(32767))
.catch((e) => e); .catch((e) => e)
}, },
assertion: (error: any) => { assertion: (error: any) => {
return !!error && !!error.error && !!error.error.message; return !!error && !!error.error && !!error.error.message
} }
}, },
{ {
title: "Single numeric value", title: 'Single numeric value',
description: "Should send an object with a single numeric value", description: 'Should send an object with a single numeric value',
test: () => { test: () => {
return adapter.request("common/sendObj", numericData); return adapter.request('common/sendObj', numericData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return res.table1[0].COL1 === numericData.table1[0].col1; return res.table1[0].COL1 === numericData.table1[0].col1
} }
}, },
{ {
title: "Large data volume", title: 'Large data volume',
description: "Should send an object with a large amount of data", description: 'Should send an object with a large amount of data',
test: () => { test: () => {
return adapter.request("common/sendObj", getLargeObjectData()); return adapter.request('common/sendObj', getLargeObjectData())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const data = getLargeObjectData(); const data = getLargeObjectData()
return res.table1[9000].BIG === data.table1[9000].big; return res.table1[9000].BIG === data.table1[9000].big
} }
}, },
{ {
title: "Multiple columns", title: 'Multiple columns',
description: "Should handle data with multiple columns", description: 'Should handle data with multiple columns',
test: () => { test: () => {
return adapter.request("common/sendObj", multiColumnData); return adapter.request('common/sendObj', multiColumnData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return ( return (
@@ -257,62 +304,63 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
res.table1[0].COL2 === multiColumnData.table1[0].col2 && res.table1[0].COL2 === multiColumnData.table1[0].col2 &&
res.table1[0].COL3 === multiColumnData.table1[0].col3 && res.table1[0].COL3 === multiColumnData.table1[0].col3 &&
res.table1[0].COL4 === multiColumnData.table1[0].col4 res.table1[0].COL4 === multiColumnData.table1[0].col4
); )
} }
}, },
{ {
title: "Multiple rows with nulls", title: 'Multiple rows with nulls',
description: "Should handle data with multiple rows with null values", description: 'Should handle data with multiple rows with null values',
test: () => { test: () => {
return adapter.request("common/sendObj", multipleRowsWithNulls); return adapter.request('common/sendObj', multipleRowsWithNulls)
}, },
assertion: (res: any) => { assertion: (res: any) => {
let result = true; let result = true
multipleRowsWithNulls.table1.forEach((_: any, index: number) => { multipleRowsWithNulls.table1.forEach((_: any, index: number) => {
result = result =
result && result &&
res.table1[index].COL1 === multipleRowsWithNulls.table1[index].col1; res.table1[index].COL1 === multipleRowsWithNulls.table1[index].col1
result = result =
result && result &&
res.table1[index].COL2 === multipleRowsWithNulls.table1[index].col2; res.table1[index].COL2 === multipleRowsWithNulls.table1[index].col2
result = result =
result && result &&
res.table1[index].COL3 === multipleRowsWithNulls.table1[index].col3; res.table1[index].COL3 === multipleRowsWithNulls.table1[index].col3
result = result =
result && result &&
res.table1[index].COL4 === multipleRowsWithNulls.table1[index].col4; res.table1[index].COL4 ===
}); (multipleRowsWithNulls.table1[index].col4 || ' ')
return result; })
return result
} }
}, },
{ {
title: "Multiple columns with nulls", title: 'Multiple columns with nulls',
description: "Should handle data with multiple columns with null values", description: 'Should handle data with multiple columns with null values',
test: () => { test: () => {
return adapter.request("common/sendObj", multipleColumnsWithNulls); return adapter.request('common/sendObj', multipleColumnsWithNulls)
}, },
assertion: (res: any) => { assertion: (res: any) => {
let result = true; let result = true
multipleColumnsWithNulls.table1.forEach((_: any, index: number) => { multipleColumnsWithNulls.table1.forEach((_: any, index: number) => {
result = result =
result && result &&
res.table1[index].COL1 === res.table1[index].COL1 ===
multipleColumnsWithNulls.table1[index].col1; multipleColumnsWithNulls.table1[index].col1
result = result =
result && result &&
res.table1[index].COL2 === res.table1[index].COL2 ===
multipleColumnsWithNulls.table1[index].col2; multipleColumnsWithNulls.table1[index].col2
result = result =
result && result &&
res.table1[index].COL3 === res.table1[index].COL3 ===
multipleColumnsWithNulls.table1[index].col3; multipleColumnsWithNulls.table1[index].col3
result = result =
result && result &&
res.table1[index].COL4 === res.table1[index].COL4 ===
(multipleColumnsWithNulls.table1[index].col4 || ""); (multipleColumnsWithNulls.table1[index].col4 || ' ')
}); })
return result; return result
} }
} }
] ]
}); })

View File

@@ -1,49 +1,49 @@
import SASjs from "@sasjs/adapter"; import SASjs from '@sasjs/adapter'
import { TestSuite } from "@sasjs/test-framework"; import { TestSuite } from '@sasjs/test-framework'
const data: any = { table1: [{ col1: "first col value" }] }; const data: any = { table1: [{ col1: 'first col value' }] }
export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
name: "SASjs Requests", name: 'SASjs Requests',
tests: [ tests: [
{ {
title: "WORK tables", title: 'WORK tables',
description: "Should get WORK tables after request", description: 'Should get WORK tables after request',
test: async () => { test: async () => {
return adapter.request("common/sendArr", data); return adapter.request('common/sendArr', data)
}, },
assertion: () => { assertion: () => {
const requests = adapter.getSasRequests(); const requests = adapter.getSasRequests()
if (adapter.getSasjsConfig().debug) { if (adapter.getSasjsConfig().debug) {
return requests[0].SASWORK !== null; return requests[0].SASWORK !== null
} else { } else {
return requests[0].SASWORK === null; return requests[0].SASWORK === null
} }
} }
}, },
{ {
title: "Make error and capture log", title: 'Make error and capture log',
description: description:
"Should make an error and capture log, in the same time it is testing if debug override is working", 'Should make an error and capture log, in the same time it is testing if debug override is working',
test: async () => { test: async () => {
return adapter return adapter
.request("common/makeErr", data, { debug: true }) .request('common/makeErr', data, { debug: true })
.catch(() => { .catch(() => {
const sasRequests = adapter.getSasRequests(); const sasRequests = adapter.getSasRequests()
const makeErrRequest: any = const makeErrRequest: any =
sasRequests.find((req) => req.serviceLink.includes("makeErr")) || sasRequests.find((req) => req.serviceLink.includes('makeErr')) ||
null; null
if (!makeErrRequest) return false; if (!makeErrRequest) return false
return !!( return !!(
makeErrRequest.logFile && makeErrRequest.logFile.length > 0 makeErrRequest.logFile && makeErrRequest.logFile.length > 0
); )
}); })
}, },
assertion: (response) => { assertion: (response) => {
return response; return response
} }
} }
] ]
}); })

View File

@@ -1,91 +1,92 @@
import SASjs from "@sasjs/adapter"; import SASjs from '@sasjs/adapter'
import { TestSuite } from "@sasjs/test-framework"; import { TestSuite } from '@sasjs/test-framework'
const specialCharData: any = { const specialCharData: any = {
table1: [ table1: [
{ {
tab: "\t", tab: '\t',
lf: "\n", lf: '\n',
cr: "\r", cr: '\r',
semicolon: ";semi", semicolon: ';semi',
percent: "%", percent: '%',
singleQuote: "'", singleQuote: "'",
doubleQuote: '"', doubleQuote: '"',
crlf: "\r\n", crlf: '\r\n',
euro: "€euro", euro: '€euro',
banghash: "!#banghash" banghash: '!#banghash',
dot: '.'
} }
] ]
}; }
const moreSpecialCharData: any = { const moreSpecialCharData: any = {
table1: [ table1: [
{ {
speech0: '"speech', speech0: '"speech',
pct: "%percent", pct: '%percent',
speech: '"speech', speech: '"speech',
slash: "\\slash", slash: '\\slash',
slashWithSpecial: "\\\tslash", slashWithSpecial: '\\\tslash',
macvar: "&sysuserid", macvar: '&sysuserid',
chinese: "传/傳chinese", chinese: '传/傳chinese',
sigma: "Σsigma", sigma: 'Σsigma',
at: "@at", at: '@at',
serbian: "Српски", serbian: 'Српски',
dollar: "$" dollar: '$'
} }
] ]
}; }
const getWideData = () => { const getWideData = () => {
const cols: any = {}; const cols: any = {}
for (let i = 1; i <= 10000; i++) { for (let i = 1; i <= 10000; i++) {
cols["col" + i] = "test" + i; cols['col' + i] = 'test' + i
} }
const data: any = { const data: any = {
table1: [cols] table1: [cols]
}; }
return data; return data
}; }
const getTables = () => { const getTables = () => {
const tables: any = {}; const tables: any = {}
for (let i = 1; i <= 100; i++) { for (let i = 1; i <= 100; i++) {
tables["table" + i] = [{ col1: "x", col2: "x", col3: "x", col4: "x" }]; tables['table' + i] = [{ col1: 'x', col2: 'x', col3: 'x', col4: 'x' }]
} }
return tables; return tables
}; }
const getLargeDataset = () => { const getLargeDataset = () => {
const rows: any = []; const rows: any = []
const colData: string = const colData: string =
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
for (let i = 1; i <= 10000; i++) { for (let i = 1; i <= 10000; i++) {
rows.push({ col1: colData, col2: colData, col3: colData, col4: colData }); rows.push({ col1: colData, col2: colData, col3: colData, col4: colData })
} }
const data: any = { const data: any = {
table1: rows table1: rows
}; }
return data; return data
}; }
const errorAndCsrfData: any = { const errorAndCsrfData: any = {
error: [{ col1: "q", col2: "w", col3: "e", col4: "r" }], 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 => ({ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
name: "Special Cases", name: 'Special Cases',
tests: [ tests: [
{ {
title: "Common special characters", title: 'Common special characters',
description: "Should handle common special characters", description: 'Should handle common special characters',
test: () => { test: () => {
return adapter.request("common/sendArr", specialCharData); return adapter.request('common/sendArr', specialCharData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return ( return (
@@ -96,17 +97,18 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
res.table1[0][4] === specialCharData.table1[0].percent && res.table1[0][4] === specialCharData.table1[0].percent &&
res.table1[0][5] === specialCharData.table1[0].singleQuote && res.table1[0][5] === specialCharData.table1[0].singleQuote &&
res.table1[0][6] === specialCharData.table1[0].doubleQuote && res.table1[0][6] === specialCharData.table1[0].doubleQuote &&
res.table1[0][7] === "\n" && res.table1[0][7] === '\n' &&
res.table1[0][8] === specialCharData.table1[0].euro && res.table1[0][8] === specialCharData.table1[0].euro &&
res.table1[0][9] === specialCharData.table1[0].banghash res.table1[0][9] === specialCharData.table1[0].banghash &&
); res.table1[0][10] === specialCharData.table1[0].dot
)
} }
}, },
{ {
title: "Other special characters", title: 'Other special characters',
description: "Should handle other special characters", description: 'Should handle other special characters',
test: () => { test: () => {
return adapter.request("common/sendArr", moreSpecialCharData); return adapter.request('common/sendArr', moreSpecialCharData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return ( return (
@@ -121,50 +123,50 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
res.table1[0][8] === moreSpecialCharData.table1[0].at && res.table1[0][8] === moreSpecialCharData.table1[0].at &&
res.table1[0][9] === moreSpecialCharData.table1[0].serbian && res.table1[0][9] === moreSpecialCharData.table1[0].serbian &&
res.table1[0][10] === moreSpecialCharData.table1[0].dollar res.table1[0][10] === moreSpecialCharData.table1[0].dollar
); )
} }
}, },
{ {
title: "Wide table with sendArr", title: 'Wide table with sendArr',
description: "Should handle data with 10000 columns", description: 'Should handle data with 10000 columns',
test: () => { test: () => {
return adapter.request("common/sendArr", getWideData()); return adapter.request('common/sendArr', getWideData())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const data = getWideData(); const data = getWideData()
let result = true; let result = true
for (let i = 0; i <= 10; i++) { for (let i = 0; i <= 10; i++) {
result = result =
result && res.table1[0][i] === data.table1[0]["col" + (i + 1)]; result && res.table1[0][i] === data.table1[0]['col' + (i + 1)]
} }
return result; return result
} }
}, },
{ {
title: "Wide table with sendObj", title: 'Wide table with sendObj',
description: "Should handle data with 10000 columns", description: 'Should handle data with 10000 columns',
test: () => { test: () => {
return adapter.request("common/sendObj", getWideData()); return adapter.request('common/sendObj', getWideData())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const data = getWideData(); const data = getWideData()
let result = true; let result = true
for (let i = 0; i <= 10; i++) { for (let i = 0; i <= 10; i++) {
result = result =
result && result &&
res.table1[0]["COL" + (i + 1)] === data.table1[0]["col" + (i + 1)]; res.table1[0]['COL' + (i + 1)] === data.table1[0]['col' + (i + 1)]
} }
return result; return result
} }
}, },
{ {
title: "Multiple tables", title: 'Multiple tables',
description: "Should handle data with 100 tables", description: 'Should handle data with 100 tables',
test: () => { test: () => {
return adapter.request("common/sendArr", getTables()); return adapter.request('common/sendArr', getTables())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const data = getTables(); const data = getTables()
return ( return (
res.table1[0][0] === data.table1[0].col1 && res.table1[0][0] === data.table1[0].col1 &&
res.table1[0][1] === data.table1[0].col2 && res.table1[0][1] === data.table1[0].col2 &&
@@ -174,45 +176,45 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
res.table50[0][1] === data.table50[0].col2 && res.table50[0][1] === data.table50[0].col2 &&
res.table50[0][2] === data.table50[0].col3 && res.table50[0][2] === data.table50[0].col3 &&
res.table50[0][3] === data.table50[0].col4 res.table50[0][3] === data.table50[0].col4
); )
} }
}, },
{ {
title: "Large dataset with sendObj", title: 'Large dataset with sendObj',
description: "Should handle 5mb of data", description: 'Should handle 5mb of data',
test: () => { test: () => {
return adapter.request("common/sendObj", getLargeDataset()); return adapter.request('common/sendObj', getLargeDataset())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const data = getLargeDataset(); const data = getLargeDataset()
let result = true; let result = true
for (let i = 0; i <= 10; i++) { for (let i = 0; i <= 10; i++) {
result = result && res.table1[i][0] === data.table1[i][0]; result = result && res.table1[i][0] === data.table1[i][0]
} }
return result; return result
} }
}, },
{ {
title: "Large dataset with sendArr", title: 'Large dataset with sendArr',
description: "Should handle 5mb of data", description: 'Should handle 5mb of data',
test: () => { test: () => {
return adapter.request("common/sendArr", getLargeDataset()); return adapter.request('common/sendArr', getLargeDataset())
}, },
assertion: (res: any) => { assertion: (res: any) => {
const data = getLargeDataset(); const data = getLargeDataset()
let result = true; let result = true
for (let i = 0; i <= 10; i++) { for (let i = 0; i <= 10; i++) {
result = result =
result && res.table1[i][0] === Object.values(data.table1[i])[0]; result && res.table1[i][0] === Object.values(data.table1[i])[0]
} }
return result; return result
} }
}, },
{ {
title: "Error and _csrf tables with sendArr", title: 'Error and _csrf tables with sendArr',
description: "Should handle error and _csrf tables", description: 'Should handle error and _csrf tables',
test: () => { test: () => {
return adapter.request("common/sendArr", errorAndCsrfData); return adapter.request('common/sendArr', errorAndCsrfData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return ( return (
@@ -224,14 +226,14 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
res._csrf[0][1] === errorAndCsrfData._csrf[0].col2 && res._csrf[0][1] === errorAndCsrfData._csrf[0].col2 &&
res._csrf[0][2] === errorAndCsrfData._csrf[0].col3 && res._csrf[0][2] === errorAndCsrfData._csrf[0].col3 &&
res._csrf[0][3] === errorAndCsrfData._csrf[0].col4 res._csrf[0][3] === errorAndCsrfData._csrf[0].col4
); )
} }
}, },
{ {
title: "Error and _csrf tables with sendObj", title: 'Error and _csrf tables with sendObj',
description: "Should handle error and _csrf tables", description: 'Should handle error and _csrf tables',
test: () => { test: () => {
return adapter.request("common/sendObj", errorAndCsrfData); return adapter.request('common/sendObj', errorAndCsrfData)
}, },
assertion: (res: any) => { assertion: (res: any) => {
return ( return (
@@ -243,8 +245,8 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
res._csrf[0].COL2 === errorAndCsrfData._csrf[0].col2 && res._csrf[0].COL2 === errorAndCsrfData._csrf[0].col2 &&
res._csrf[0].COL3 === errorAndCsrfData._csrf[0].col3 && res._csrf[0].COL3 === errorAndCsrfData._csrf[0].col3 &&
res._csrf[0].COL4 === errorAndCsrfData._csrf[0].col4 res._csrf[0].COL4 === errorAndCsrfData._csrf[0].col4
); )
} }
} }
] ]
}); })

View File

@@ -1,22 +1,22 @@
export const assert = ( export const assert = (
expression: boolean | (() => boolean), expression: boolean | (() => boolean),
message = "Assertion failed" message = 'Assertion failed'
) => { ) => {
let result; let result
try { try {
if (typeof expression === "boolean") { if (typeof expression === 'boolean') {
result = expression; result = expression
} else { } else {
result = expression(); result = expression()
} }
} catch (e) { } catch (e) {
console.error(message); console.error(message)
throw new Error(message); throw new Error(message)
} }
if (!!result) { if (!!result) {
return; return
} else { } else {
console.error(message); console.error(message)
throw new Error(message); throw new Error(message)
} }
}; }

View File

@@ -314,9 +314,7 @@ export class ContextManager {
contextId: string, contextId: string,
accessToken?: string accessToken?: string
): Promise<ContextAllAttributes> { ): Promise<ContextAllAttributes> {
const { const { result: context } = await this.requestClient
result: context
} = await this.requestClient
.get<ContextAllAttributes>( .get<ContextAllAttributes>(
`${this.serverUrl}/compute/contexts/${contextId}`, `${this.serverUrl}/compute/contexts/${contextId}`,
accessToken accessToken

View File

@@ -1,6 +1,6 @@
import { isUrl } from './utils' import { isUrl } from './utils'
import { UploadFile } from './types/UploadFile' import { UploadFile } from './types/UploadFile'
import { ErrorResponse, LoginRequiredError } from './types' import { ErrorResponse, LoginRequiredError } from './types/errors'
import { RequestClient } from './request/RequestClient' import { RequestClient } from './request/RequestClient'
export class FileUploader { export class FileUploader {

View File

@@ -1,4 +1,6 @@
import axios, { AxiosInstance } from 'axios' import { generateTimestamp } from '@sasjs/utils/time'
import * as NodeFormData from 'form-data'
import { Sas9RequestClient } from './request/Sas9RequestClient'
import { isUrl } from './utils' import { isUrl } from './utils'
/** /**
@@ -6,11 +8,11 @@ import { isUrl } from './utils'
* *
*/ */
export class SAS9ApiClient { export class SAS9ApiClient {
private httpClient: AxiosInstance private requestClient: Sas9RequestClient
constructor(private serverUrl: string) { constructor(private serverUrl: string, private jobsPath: string) {
if (serverUrl) isUrl(serverUrl) if (serverUrl) isUrl(serverUrl)
this.httpClient = axios.create({ baseURL: this.serverUrl }) this.requestClient = new Sas9RequestClient(serverUrl, false)
} }
/** /**
@@ -33,27 +35,61 @@ export class SAS9ApiClient {
/** /**
* Executes code on a SAS9 server. * Executes code on a SAS9 server.
* @param linesOfCode - an array of code lines to execute. * @param linesOfCode - an array of code lines to execute.
* @param serverName - the server to execute the code on. * @param userName - the user name to log into the current SAS server.
* @param repositoryName - the repository to execute the code in. * @param password - the password to log into the current SAS server.
*/ */
public async executeScript( public async executeScript(
linesOfCode: string[], linesOfCode: string[],
serverName: string, userName: string,
repositoryName: string password: string
) { ) {
const requestPayload = linesOfCode.join('\n') await this.requestClient.login(userName, password, this.jobsPath)
const executeScriptResponse = await this.httpClient.put( // This piece of code forces a webout to prevent Stored Process Errors.
`/sas/servers/${serverName}/cmd?repositoryName=${repositoryName}`, const forceOutputCode = [
`command=${requestPayload}`, 'data _null_;',
{ 'file _webout;',
headers: { `put 'Executed sasjs run';`,
Accept: 'application/json' 'run;'
}, ]
responseType: 'text' const formData = generateFileUploadForm(
} [...linesOfCode, ...forceOutputCode].join('\n')
) )
return executeScriptResponse.data const codeInjectorPath = `/User Folders/${userName}/My Folder/sasjs/runner`
const contentType =
'multipart/form-data; boundary=' + formData.getBoundary()
const contentLength = formData.getLengthSync()
const headers = {
'cache-control': 'no-cache',
Accept: '*/*',
'Content-Type': contentType,
'Content-Length': contentLength,
Connection: 'keep-alive'
}
const storedProcessUrl = `${this.jobsPath}/?${
'_program=' + codeInjectorPath + '&_debug=log'
}`
const response = await this.requestClient.post(
storedProcessUrl,
formData,
undefined,
contentType,
headers
)
return response.result as string
} }
} }
const generateFileUploadForm = (data: any): NodeFormData => {
const formData = new NodeFormData()
const filename = `sasjs-execute-sas9-${generateTimestamp('')}.sas`
formData.append(filename, data, {
filename,
contentType: 'text/plain'
})
return formData
}

View File

@@ -1,4 +1,10 @@
import { convertToCSV, isRelativePath, isUri, isUrl } from './utils' import {
convertToCSV,
isRelativePath,
isUri,
isUrl,
fetchLogByChunks
} from './utils'
import * as NodeFormData from 'form-data' import * as NodeFormData from 'form-data'
import { import {
Job, Job,
@@ -6,12 +12,16 @@ import {
Context, Context,
ContextAllAttributes, ContextAllAttributes,
Folder, Folder,
File,
EditContextInput, EditContextInput,
JobDefinition, JobDefinition,
PollOptions, PollOptions
ComputeJobExecutionError,
JobExecutionError
} from './types' } from './types'
import {
ComputeJobExecutionError,
JobExecutionError,
NotFoundError
} from './types/errors'
import { formatDataForRequest } from './utils/formatDataForRequest' import { formatDataForRequest } from './utils/formatDataForRequest'
import { SessionManager } from './SessionManager' import { SessionManager } from './SessionManager'
import { ContextManager } from './ContextManager' import { ContextManager } from './ContextManager'
@@ -19,9 +29,9 @@ import { timestampToYYYYMMDDHHMMSS } from '@sasjs/utils/time'
import { Logger, LogLevel } from '@sasjs/utils/logger' import { Logger, LogLevel } from '@sasjs/utils/logger'
import { isAuthorizeFormRequired } from './auth/isAuthorizeFormRequired' import { isAuthorizeFormRequired } from './auth/isAuthorizeFormRequired'
import { RequestClient } from './request/RequestClient' import { RequestClient } from './request/RequestClient'
import { NotFoundError } from './types/NotFoundError' import { SasAuthResponse, MacroVar } from '@sasjs/utils/types'
import { SasAuthResponse } from '@sasjs/utils/types'
import { prefixMessage } from '@sasjs/utils/error' import { prefixMessage } from '@sasjs/utils/error'
import * as mime from 'mime'
/** /**
* A client for interfacing with the SAS Viya REST API. * A client for interfacing with the SAS Viya REST API.
@@ -263,6 +273,7 @@ export class SASViyaApiClient {
* @param waitForResult - when set to true, function will return the session * @param waitForResult - when set to true, function will return the session
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }. * @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }.
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job. * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
* @param variables - an object that represents macro variables.
*/ */
public async executeScript( public async executeScript(
jobPath: string, jobPath: string,
@@ -274,7 +285,8 @@ export class SASViyaApiClient {
expectWebout = false, expectWebout = false,
waitForResult = true, waitForResult = true,
pollOptions?: PollOptions, pollOptions?: PollOptions,
printPid = false printPid = false,
variables?: MacroVar
): Promise<any> { ): Promise<any> {
try { try {
const headers: any = { const headers: any = {
@@ -348,6 +360,8 @@ export class SASViyaApiClient {
: jobPath : jobPath
} }
if (variables) jobVariables = { ...jobVariables, ...variables }
let files: any[] = [] let files: any[] = []
if (data) { if (data) {
@@ -404,7 +418,22 @@ export class SASViyaApiClient {
etag, etag,
accessToken, accessToken,
pollOptions pollOptions
).catch((err) => { ).catch(async (err) => {
const error = err?.response?.data
const result = /err=[0-9]*,/.exec(error)
const errorCode = '5113'
if (result?.[0]?.slice(4, -1) === errorCode) {
const sessionLogUrl =
postedJob.links.find((l: any) => l.rel === 'up')!.href + '/log'
const logCount = 1000000
err.log = await fetchLogByChunks(
this.requestClient,
accessToken!,
sessionLogUrl,
logCount
)
}
throw prefixMessage(err, 'Error while polling job status. ') throw prefixMessage(err, 'Error while polling job status. ')
}) })
@@ -418,19 +447,19 @@ export class SASViyaApiClient {
}) })
let jobResult let jobResult
let log let log = ''
const logLink = currentJob.links.find((l) => l.rel === 'log') const logLink = currentJob.links.find((l) => l.rel === 'log')
if (debug && logLink) { if (debug && logLink) {
log = await this.requestClient const logUrl = `${logLink.href}/content`
.get<any>(`${logLink.href}/content?limit=10000`, accessToken) const logCount = currentJob.logStatistics?.lineCount ?? 1000000
.then((res: any) => log = await fetchLogByChunks(
res.result.items.map((i: any) => i.line).join('\n') this.requestClient,
) accessToken!,
.catch((err) => { logUrl,
throw prefixMessage(err, 'Error while getting log. ') logCount
}) )
} }
if (jobStatus === 'failed' || jobStatus === 'error') { if (jobStatus === 'failed' || jobStatus === 'error') {
@@ -451,14 +480,14 @@ export class SASViyaApiClient {
.catch(async (e) => { .catch(async (e) => {
if (e instanceof NotFoundError) { if (e instanceof NotFoundError) {
if (logLink) { if (logLink) {
log = await this.requestClient const logUrl = `${logLink.href}/content`
.get<any>(`${logLink.href}/content?limit=10000`, accessToken) const logCount = currentJob.logStatistics?.lineCount ?? 1000000
.then((res: any) => log = await fetchLogByChunks(
res.result.items.map((i: any) => i.line).join('\n') this.requestClient,
) accessToken!,
.catch((err) => { logUrl,
throw prefixMessage(err, 'Error while getting log. ') logCount
}) )
return Promise.reject({ return Promise.reject({
status: 500, status: 500,
@@ -509,6 +538,53 @@ export class SASViyaApiClient {
.then((res) => res.result) .then((res) => res.result)
} }
/**
* Creates a file. Path to or URI of the parent folder is required.
* @param fileName - the name of the new file.
* @param contentBuffer - the content of the new file in Buffer.
* @param parentFolderPath - the full path to the parent folder. If not
* provided, the parentFolderUri must be provided.
* @param parentFolderUri - the URI (eg /folders/folders/UUID) of the parent
* folder. If not provided, the parentFolderPath must be provided.
* @param accessToken - an access token for authorizing the request.
*/
public async createFile(
fileName: string,
contentBuffer: Buffer,
parentFolderPath?: string,
parentFolderUri?: string,
accessToken?: string
): Promise<File> {
if (!parentFolderPath && !parentFolderUri) {
throw new Error('Path or URI of the parent folder is required.')
}
if (!parentFolderUri && parentFolderPath) {
parentFolderUri = await this.getFolderUri(parentFolderPath, accessToken)
}
const headers = {
Accept: 'application/vnd.sas.file+json',
'Content-Disposition': `filename="${fileName}";`
}
const formData = new NodeFormData()
formData.append('file', contentBuffer, fileName)
const mimeType =
mime.getType(fileName.match(/\.[0-9a-z]+$/i)?.[0] || '') ?? 'text/plain'
return (
await this.requestClient.post<File>(
`/files/files?parentFolderUri=${parentFolderUri}&typeDefName=file#rawUpload`,
formData,
accessToken,
'multipart/form-data; boundary=' + (formData as any)._boundary,
headers
)
).result
}
/** /**
* Creates a folder. Path to or URI of the parent folder is required. * Creates a folder. Path to or URI of the parent folder is required.
* @param folderName - the name of the new folder. * @param folderName - the name of the new folder.
@@ -571,16 +647,15 @@ export class SASViyaApiClient {
} }
} }
const { const { result: createFolderResponse } =
result: createFolderResponse await this.requestClient.post<Folder>(
} = await this.requestClient.post<Folder>( `/folders/folders?parentFolderUri=${parentFolderUri}`,
`/folders/folders?parentFolderUri=${parentFolderUri}`, {
{ name: folderName,
name: folderName, type: 'folder'
type: 'folder' },
}, accessToken
accessToken )
)
// update folder map with newly created folder. // update folder map with newly created folder.
await this.populateFolderMap( await this.populateFolderMap(
@@ -697,13 +772,11 @@ export class SASViyaApiClient {
let formData let formData
if (typeof FormData === 'undefined') { if (typeof FormData === 'undefined') {
formData = new NodeFormData() formData = new NodeFormData()
formData.append('grant_type', 'authorization_code')
formData.append('code', authCode)
} else { } else {
formData = new FormData() formData = new FormData()
formData.append('grant_type', 'authorization_code')
formData.append('code', authCode)
} }
formData.append('grant_type', 'authorization_code')
formData.append('code', authCode)
const authResponse = await this.requestClient const authResponse = await this.requestClient
.post( .post(
@@ -792,6 +865,7 @@ export class SASViyaApiClient {
* @param expectWebout - a boolean indicating whether to expect a _webout response. * @param expectWebout - a boolean indicating whether to expect a _webout response.
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }. * @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }.
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job. * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
* @param variables - an object that represents macro variables.
*/ */
public async executeComputeJob( public async executeComputeJob(
sasJob: string, sasJob: string,
@@ -802,7 +876,8 @@ export class SASViyaApiClient {
waitForResult = true, waitForResult = true,
expectWebout = false, expectWebout = false,
pollOptions?: PollOptions, pollOptions?: PollOptions,
printPid = false printPid = false,
variables?: MacroVar
) { ) {
if (isRelativePath(sasJob) && !this.rootFolderName) { if (isRelativePath(sasJob) && !this.rootFolderName) {
throw new Error( throw new Error(
@@ -852,9 +927,7 @@ export class SASViyaApiClient {
throw new Error(`URI of job definition was not found.`) throw new Error(`URI of job definition was not found.`)
} }
const { const { result: jobDefinition } = await this.requestClient
result: jobDefinition
} = await this.requestClient
.get<JobDefinition>( .get<JobDefinition>(
`${this.serverUrl}${jobDefinitionLink.href}`, `${this.serverUrl}${jobDefinitionLink.href}`,
accessToken accessToken
@@ -883,10 +956,9 @@ export class SASViyaApiClient {
expectWebout, expectWebout,
waitForResult, waitForResult,
pollOptions, pollOptions,
printPid printPid,
).catch((err) => { variables
throw prefixMessage(err, 'Error while executing script. ') )
})
} }
/** /**
@@ -979,7 +1051,13 @@ export class SASViyaApiClient {
postJobRequestBody, postJobRequestBody,
accessToken accessToken
) )
const jobStatus = await this.pollJobState(postedJob, etag, accessToken) const jobStatus = await this.pollJobState(
postedJob,
etag,
accessToken
).catch((err) => {
throw prefixMessage(err, 'Error while polling job status. ')
})
const { result: currentJob } = await this.requestClient.get<Job>( const { result: currentJob } = await this.requestClient.get<Job>(
`${this.serverUrl}/jobExecution/jobs/${postedJob.id}`, `${this.serverUrl}/jobExecution/jobs/${postedJob.id}`,
accessToken accessToken
@@ -1054,6 +1132,7 @@ export class SASViyaApiClient {
) { ) {
let POLL_INTERVAL = 300 let POLL_INTERVAL = 300
let MAX_POLL_COUNT = 1000 let MAX_POLL_COUNT = 1000
let MAX_ERROR_COUNT = 5
if (pollOptions) { if (pollOptions) {
POLL_INTERVAL = pollOptions.POLL_INTERVAL || POLL_INTERVAL POLL_INTERVAL = pollOptions.POLL_INTERVAL || POLL_INTERVAL
@@ -1062,6 +1141,7 @@ export class SASViyaApiClient {
let postedJobState = '' let postedJobState = ''
let pollCount = 0 let pollCount = 0
let errorCount = 0
const headers: any = { const headers: any = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'If-None-Match': etag 'If-None-Match': etag
@@ -1076,12 +1156,18 @@ export class SASViyaApiClient {
const { result: state } = await this.requestClient const { result: state } = await this.requestClient
.get<string>( .get<string>(
`${this.serverUrl}${stateLink.href}?_action=wait&wait=30`, `${this.serverUrl}${stateLink.href}?_action=wait&wait=300`,
accessToken, accessToken,
'text/plain' 'text/plain',
{},
this.debug
) )
.catch((err) => { .catch((err) => {
throw prefixMessage(err, 'Error while getting job state. ') console.error(
`Error fetching job state from ${this.serverUrl}${stateLink.href}. Starting poll, assuming job to be running.`,
err
)
return { result: 'unavailable' }
}) })
const currentState = state.trim() const currentState = state.trim()
@@ -1096,20 +1182,40 @@ export class SASViyaApiClient {
if ( if (
postedJobState === 'running' || postedJobState === 'running' ||
postedJobState === '' || postedJobState === '' ||
postedJobState === 'pending' postedJobState === 'pending' ||
postedJobState === 'unavailable'
) { ) {
if (stateLink) { if (stateLink) {
const { result: jobState } = await this.requestClient const { result: jobState } = await this.requestClient
.get<string>( .get<string>(
`${this.serverUrl}${stateLink.href}?_action=wait&wait=30`, `${this.serverUrl}${stateLink.href}?_action=wait&wait=300`,
accessToken, accessToken,
'text/plain' 'text/plain',
{},
this.debug
) )
.catch((err) => { .catch((err) => {
throw prefixMessage(err, 'Error while getting job state. ') errorCount++
if (
pollCount >= MAX_POLL_COUNT ||
errorCount >= MAX_ERROR_COUNT
) {
throw prefixMessage(
err,
'Error while getting job state after interval. '
)
}
console.error(
`Error fetching job state from ${this.serverUrl}${stateLink.href}. Resuming poll, assuming job to be running.`,
err
)
return { result: 'unavailable' }
}) })
postedJobState = jobState.trim() postedJobState = jobState.trim()
if (postedJobState != 'unavailable' && errorCount > 0) {
errorCount = 0
}
if (this.debug && printedState !== postedJobState) { if (this.debug && printedState !== postedJobState) {
console.log('Polling job status...') console.log('Polling job status...')

View File

@@ -4,14 +4,17 @@ import { SASViyaApiClient } from './SASViyaApiClient'
import { SAS9ApiClient } from './SAS9ApiClient' import { SAS9ApiClient } from './SAS9ApiClient'
import { FileUploader } from './FileUploader' import { FileUploader } from './FileUploader'
import { AuthManager } from './auth' import { AuthManager } from './auth'
import { ServerType } from '@sasjs/utils/types' import { ServerType, MacroVar } from '@sasjs/utils/types'
import { RequestClient } from './request/RequestClient' import { RequestClient } from './request/RequestClient'
import { import {
JobExecutor, JobExecutor,
WebJobExecutor, WebJobExecutor,
ComputeJobExecutor, ComputeJobExecutor,
JesJobExecutor JesJobExecutor,
Sas9JobExecutor
} from './job-execution' } from './job-execution'
import { ErrorResponse } from './types/errors'
import { ExtraResponseAttributes } from '@sasjs/utils/types'
const defaultConfig: SASjsConfig = { const defaultConfig: SASjsConfig = {
serverUrl: '', serverUrl: '',
@@ -40,6 +43,7 @@ export default class SASjs {
private webJobExecutor: JobExecutor | null = null private webJobExecutor: JobExecutor | null = null
private computeJobExecutor: JobExecutor | null = null private computeJobExecutor: JobExecutor | null = null
private jesJobExecutor: JobExecutor | null = null private jesJobExecutor: JobExecutor | null = null
private sas9JobExecutor: JobExecutor | null = null
constructor(config?: any) { constructor(config?: any) {
this.sasjsConfig = { this.sasjsConfig = {
@@ -56,15 +60,15 @@ export default class SASjs {
public async executeScriptSAS9( public async executeScriptSAS9(
linesOfCode: string[], linesOfCode: string[],
serverName: string, userName: string,
repositoryName: string password: string
) { ) {
this.isMethodSupported('executeScriptSAS9', ServerType.Sas9) this.isMethodSupported('executeScriptSAS9', ServerType.Sas9)
return await this.sas9ApiClient?.executeScript( return await this.sas9ApiClient?.executeScript(
linesOfCode, linesOfCode,
serverName, userName,
repositoryName password
) )
} }
@@ -264,7 +268,7 @@ export default class SASjs {
} }
/** /**
* Creates a folder at SAS file system. * Creates a folder in the logical SAS folder tree
* @param folderName - name of the folder to be created. * @param folderName - name of the folder to be created.
* @param parentFolderPath - the full path (eg `/Public/example/myFolder`) of the parent folder. * @param parentFolderPath - the full path (eg `/Public/example/myFolder`) of the parent folder.
* @param parentFolderUri - the URI of the parent folder. * @param parentFolderUri - the URI of the parent folder.
@@ -296,6 +300,40 @@ export default class SASjs {
) )
} }
/**
* Creates a file in the logical SAS folder tree
* @param fileName - name of the file to be created.
* @param content - content of the file to be created.
* @param parentFolderPath - the full path (eg `/Public/example/myFolder`) of the parent folder.
* @param parentFolderUri - the URI of the parent folder.
* @param accessToken - the access token to authorizing the request.
* @param sasApiClient - a client for interfacing with SAS API.
*/
public async createFile(
fileName: string,
content: Buffer,
parentFolderPath: string,
parentFolderUri?: string,
accessToken?: string,
sasApiClient?: SASViyaApiClient
) {
if (sasApiClient)
return await sasApiClient.createFile(
fileName,
content,
parentFolderPath,
parentFolderUri,
accessToken
)
return await this.sasViyaApiClient!.createFile(
fileName,
content,
parentFolderPath,
parentFolderUri,
accessToken
)
}
/** /**
* Fetches a folder from the SAS file system. * Fetches a folder from the SAS file system.
* @param folderPath - path of the folder to be fetched. * @param folderPath - path of the folder to be fetched.
@@ -530,47 +568,133 @@ export default class SASjs {
* @param config - provide any changes to the config here, for instance to * @param config - provide any changes to the config here, for instance to
* enable/disable `debug`. Any change provided will override the global config, * enable/disable `debug`. Any change provided will override the global config,
* for that particular function call. * for that particular function call.
* @param loginRequiredCallback - provide a function here to be called if the * @param loginRequiredCallback - a function that is called if the
* user is not logged in (eg to display a login form). The request will be * user is not logged in (eg to display a login form). The request will be
* resubmitted after logon. * resubmitted after successful login.
* When using a `loginRequiredCallback`, the call to the request will look, for example, like so:
* `await request(sasJobPath, data, config, () => setIsLoggedIn(false))`
* If you are not passing in any data and configuration, it will look like so:
* `await request(sasJobPath, {}, {}, () => setIsLoggedIn(false))`
* @param extraResponseAttributes - a array of predefined values that are used
* to provide extra attributes (same names as those values) to be added in response
* Supported values are declared in ExtraResponseAttributes type.
*/ */
public async request( public async request(
sasJob: string, sasJob: string,
data: any, data: { [key: string]: any } | null,
config: any = {}, config: { [key: string]: any } = {},
loginRequiredCallback?: any, loginRequiredCallback?: () => any,
accessToken?: string accessToken?: string,
extraResponseAttributes: ExtraResponseAttributes[] = []
) { ) {
config = { config = {
...this.sasjsConfig, ...this.sasjsConfig,
...config ...config
} }
if (config.serverType === ServerType.SasViya && config.contextName) { const validationResult = this.validateInput(data)
if (config.useComputeApi) {
return await this.computeJobExecutor!.execute( if (validationResult.status) {
sasJob, if (config.serverType === ServerType.SasViya && config.contextName) {
data, if (config.useComputeApi) {
config, return await this.computeJobExecutor!.execute(
loginRequiredCallback, sasJob,
accessToken data,
) config,
loginRequiredCallback,
accessToken
)
} else {
return await this.jesJobExecutor!.execute(
sasJob,
data,
config,
loginRequiredCallback,
accessToken,
extraResponseAttributes
)
}
} else if (
config.serverType === ServerType.Sas9 &&
config.username &&
config.password
) {
return await this.sas9JobExecutor!.execute(sasJob, data, config)
} else { } else {
return await this.jesJobExecutor!.execute( return await this.webJobExecutor!.execute(
sasJob, sasJob,
data, data,
config, config,
loginRequiredCallback, loginRequiredCallback,
accessToken accessToken,
extraResponseAttributes
) )
} }
} else { } else {
return await this.webJobExecutor!.execute( return Promise.reject(new ErrorResponse(validationResult.msg))
sasJob, }
data, }
config,
loginRequiredCallback /**
) * This function validates the input data structure and table naming convention
*
* @param data A json object that contains one or more tables, it can also be null
* @returns An object which contains two attributes: 1) status: boolean, 2) msg: string
*/
private validateInput(data: { [key: string]: any } | null): {
status: boolean
msg: string
} {
if (data === null) return { status: true, msg: '' }
for (const key in data) {
if (!key.match(/^[a-zA-Z_]/)) {
return {
status: false,
msg: 'First letter of table should be alphabet or underscore.'
}
}
if (!key.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/)) {
return { status: false, msg: 'Table name should be alphanumeric.' }
}
if (key.length > 32) {
return {
status: false,
msg: 'Maximum length for table name could be 32 characters.'
}
}
if (this.getType(data[key]) !== 'Array') {
return {
status: false,
msg: 'Parameter data contains invalid table structure.'
}
}
for (let i = 0; i < data[key].length; i++) {
if (this.getType(data[key][i]) !== 'object') {
return {
status: false,
msg: `Table ${key} contains invalid structure.`
}
}
}
}
return { status: true, msg: '' }
}
/**
* this function returns the type of variable
*
* @param data it could be anything, like string, array, object etc.
* @returns a string which tells the type of input parameter
*/
private getType(data: any): string {
if (Array.isArray(data)) {
return 'Array'
} else {
return typeof data
} }
} }
@@ -611,7 +735,7 @@ export default class SASjs {
) )
sasApiClient.debug = this.sasjsConfig.debug sasApiClient.debug = this.sasjsConfig.debug
} else if (this.sasjsConfig.serverType === ServerType.Sas9) { } else if (this.sasjsConfig.serverType === ServerType.Sas9) {
sasApiClient = new SAS9ApiClient(serverUrl) sasApiClient = new SAS9ApiClient(serverUrl, this.jobsPath)
} }
} else { } else {
let sasClientConfig: any = null let sasClientConfig: any = null
@@ -658,6 +782,7 @@ export default class SASjs {
* @param waitForResult - a boolean that indicates whether the function needs to wait for execution to complete. * @param waitForResult - a boolean that indicates whether the function needs to wait for execution to complete.
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }. * @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }.
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job. * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
* @param variables - an object that represents macro variables.
*/ */
public async startComputeJob( public async startComputeJob(
sasJob: string, sasJob: string,
@@ -666,7 +791,8 @@ export default class SASjs {
accessToken?: string, accessToken?: string,
waitForResult?: boolean, waitForResult?: boolean,
pollOptions?: PollOptions, pollOptions?: PollOptions,
printPid = false printPid = false,
variables?: MacroVar
) { ) {
config = { config = {
...this.sasjsConfig, ...this.sasjsConfig,
@@ -689,7 +815,8 @@ export default class SASjs {
!!waitForResult, !!waitForResult,
false, false,
pollOptions, pollOptions,
printPid printPid,
variables
) )
} }
@@ -705,9 +832,27 @@ export default class SASjs {
* @param accessToken - an access token for an authorized user. * @param accessToken - an access token for an authorized user.
*/ */
public async fetchLogFileContent(logUrl: string, accessToken?: string) { public async fetchLogFileContent(logUrl: string, accessToken?: string) {
return await this.requestClient!.get(logUrl, accessToken).then((res) => return await this.requestClient!.get(logUrl, accessToken).then((res) => {
JSON.stringify(res.result) if (!res)
) return Promise.reject(
new ErrorResponse(
'Error while fetching log. Response was not provided.'
)
)
try {
const result = JSON.stringify(res.result)
return result
} catch (err) {
return Promise.reject(
new ErrorResponse(
'Error while fetching log. The result is not valid.',
err
)
)
}
})
} }
public getSasRequests() { public getSasRequests() {
@@ -782,7 +927,11 @@ export default class SASjs {
if (this.sasjsConfig.serverType === ServerType.Sas9) { if (this.sasjsConfig.serverType === ServerType.Sas9) {
if (this.sas9ApiClient) if (this.sas9ApiClient)
this.sas9ApiClient!.setConfig(this.sasjsConfig.serverUrl) this.sas9ApiClient!.setConfig(this.sasjsConfig.serverUrl)
else this.sas9ApiClient = new SAS9ApiClient(this.sasjsConfig.serverUrl) else
this.sas9ApiClient = new SAS9ApiClient(
this.sasjsConfig.serverUrl,
this.jobsPath
)
} }
this.fileUploader = new FileUploader( this.fileUploader = new FileUploader(
@@ -800,6 +949,12 @@ export default class SASjs {
this.sasViyaApiClient! this.sasViyaApiClient!
) )
this.sas9JobExecutor = new Sas9JobExecutor(
this.sasjsConfig.serverUrl,
this.sasjsConfig.serverType!,
this.jobsPath
)
this.computeJobExecutor = new ComputeJobExecutor( this.computeJobExecutor = new ComputeJobExecutor(
this.sasjsConfig.serverUrl, this.sasjsConfig.serverUrl,
this.sasViyaApiClient! this.sasViyaApiClient!
@@ -830,6 +985,16 @@ export default class SASjs {
isForced isForced
) )
break break
case 'file':
await this.createFile(
member.name,
member.code,
parentFolder,
undefined,
accessToken,
sasApiClient
)
break
case 'service': case 'service':
await this.createJobDefinition( await this.createJobDefinition(
member.name, member.name,

View File

@@ -91,10 +91,7 @@ export class SessionManager {
} }
private async createAndWaitForSession(accessToken?: string) { private async createAndWaitForSession(accessToken?: string) {
const { const { result: createdSession, etag } = await this.requestClient
result: createdSession,
etag
} = await this.requestClient
.post<Session>( .post<Session>(
`${this.serverUrl}/compute/contexts/${ `${this.serverUrl}/compute/contexts/${
this.currentContext!.id this.currentContext!.id

View File

@@ -35,6 +35,7 @@ export class AuthManager {
this.userName = loginParams.username this.userName = loginParams.username
const { isLoggedIn, loginForm } = await this.checkSession() const { isLoggedIn, loginForm } = await this.checkSession()
if (isLoggedIn) { if (isLoggedIn) {
await this.loginCallback() await this.loginCallback()
@@ -44,6 +45,35 @@ export class AuthManager {
} }
} }
let loginResponse = await this.sendLoginRequest(loginForm, loginParams)
let loggedIn = isLogInSuccess(loginResponse)
if (!loggedIn) {
if (isCredentialsVerifyError(loginResponse)) {
const newLoginForm = await this.getLoginForm(loginResponse)
loginResponse = await this.sendLoginRequest(newLoginForm, loginParams)
}
const currentSession = await this.checkSession()
loggedIn = currentSession.isLoggedIn
}
if (loggedIn) {
this.loginCallback()
}
return {
isLoggedIn: !!loggedIn,
userName: this.userName
}
}
private async sendLoginRequest(
loginForm: { [key: string]: any },
loginParams: { [key: string]: any }
) {
for (const key in loginForm) { for (const key in loginForm) {
loginParams[key] = loginForm[key] loginParams[key] = loginForm[key]
} }
@@ -60,21 +90,7 @@ export class AuthManager {
} }
) )
let loggedIn = isLogInSuccess(loginResponse) return loginResponse
if (!loggedIn) {
const currentSession = await this.checkSession()
loggedIn = currentSession.isLoggedIn
}
if (loggedIn) {
this.loginCallback()
}
return {
isLoggedIn: !!loggedIn,
userName: this.userName
}
} }
/** /**
@@ -82,17 +98,33 @@ export class AuthManager {
* @returns - a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName`. * @returns - a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName`.
*/ */
public async checkSession() { public async checkSession() {
const { result: loginResponse } = await this.requestClient.get<string>( //For VIYA we will send request on API endpoint. Which is faster then pinging SASJobExecution.
this.loginUrl.replace('.do', ''), //For SAS9 we will send request on SASStoredProcess
undefined, const url =
'text/plain' this.serverType === 'SASVIYA'
) ? `${this.serverUrl}/identities`
const responseText = loginResponse : `${this.serverUrl}/SASStoredProcess`
const isLoggedIn = /<button.+onClick.+logout/gm.test(responseText)
let loginForm: any = null const { result: loginResponse } = await this.requestClient
.get<string>(url, undefined, 'text/plain')
.catch((err: any) => {
return { result: 'authErr' }
})
const isLoggedIn = loginResponse !== 'authErr'
let loginForm = null
if (!isLoggedIn) { if (!isLoggedIn) {
loginForm = await this.getLoginForm(responseText) //We will logout to make sure cookies are removed and login form is presented
this.logOut()
const { result: formResponse } = await this.requestClient.get<string>(
this.loginUrl.replace('.do', ''),
undefined,
'text/plain'
)
loginForm = await this.getLoginForm(formResponse)
} }
return Promise.resolve({ return Promise.resolve({
@@ -152,5 +184,10 @@ export class AuthManager {
} }
} }
const isCredentialsVerifyError = (response: string): boolean =>
/An error occurred while the system was verifying your credentials. Please enter your credentials again./gm.test(
response
)
const isLogInSuccess = (response: string): boolean => const isLogInSuccess = (response: string): boolean =>
/You have signed in/gm.test(response) /You have signed in/gm.test(response)

View File

@@ -57,7 +57,7 @@ describe('AuthManager', () => {
expect((authManager as any).logoutUrl).toEqual('/SASLogon/logout?') expect((authManager as any).logoutUrl).toEqual('/SASLogon/logout?')
}) })
it('should call the auth callback and return when already logged in', async (done) => { it('should call the auth callback and return when already logged in', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -77,10 +77,9 @@ describe('AuthManager', () => {
expect(loginResponse.isLoggedIn).toBeTruthy() expect(loginResponse.isLoggedIn).toBeTruthy()
expect(loginResponse.userName).toEqual(userName) expect(loginResponse.userName).toEqual(userName)
expect(authCallback).toHaveBeenCalledTimes(1) expect(authCallback).toHaveBeenCalledTimes(1)
done()
}) })
it('should post a login request to the server if not logged in', async (done) => { it('should post a login request to the server if not logged in', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -121,10 +120,9 @@ describe('AuthManager', () => {
} }
) )
expect(authCallback).toHaveBeenCalledTimes(1) expect(authCallback).toHaveBeenCalledTimes(1)
done()
}) })
it('should parse and submit the authorisation form when necessary', async (done) => { it('should parse and submit the authorisation form when necessary', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -160,10 +158,9 @@ describe('AuthManager', () => {
expect(requestClient.authorize).toHaveBeenCalledWith( expect(requestClient.authorize).toHaveBeenCalledWith(
mockLoginAuthoriseRequiredResponse mockLoginAuthoriseRequiredResponse
) )
done()
}) })
it('should check and return session information if logged in', async (done) => { it('should check and return session information if logged in', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -176,42 +173,18 @@ describe('AuthManager', () => {
const response = await authManager.checkSession() const response = await authManager.checkSession()
expect(response.isLoggedIn).toBeTruthy() expect(response.isLoggedIn).toBeTruthy()
expect(mockedAxios.get).toHaveBeenNthCalledWith(1, `/SASLogon/login`, { expect(mockedAxios.get).toHaveBeenNthCalledWith(
withCredentials: true, 1,
responseType: 'text', `http://test-server.com/identities`,
transformResponse: undefined, {
headers: { withCredentials: true,
Accept: '*/*', responseType: 'text',
'Content-Type': 'text/plain' transformResponse: undefined,
headers: {
Accept: '*/*',
'Content-Type': 'text/plain'
}
} }
})
done()
})
it('should check and return session information if logged in', async (done) => {
const authManager = new AuthManager(
serverUrl,
serverType,
requestClient,
authCallback
) )
mockedAxios.get.mockImplementation(() =>
Promise.resolve({ data: '<button onClick="logout">' })
)
const response = await authManager.checkSession()
expect(response.isLoggedIn).toBeTruthy()
expect(mockedAxios.get).toHaveBeenNthCalledWith(1, `/SASLogon/login`, {
withCredentials: true,
responseType: 'text',
transformResponse: undefined,
headers: {
Accept: '*/*',
'Content-Type': 'text/plain'
}
})
done()
}) })
}) })

View File

@@ -1,5 +1,6 @@
import SASjs from './SASjs' import SASjs from './SASjs'
export * from './types' export * from './types'
export * from './types/errors'
export * from './SASViyaApiClient' export * from './SASViyaApiClient'
export * from './SAS9ApiClient' export * from './SAS9ApiClient'
export default SASjs export default SASjs

View File

@@ -1,7 +1,10 @@
import { ServerType } from '@sasjs/utils/types' import { ServerType } from '@sasjs/utils/types'
import { ErrorResponse } from '..'
import { SASViyaApiClient } from '../SASViyaApiClient' import { SASViyaApiClient } from '../SASViyaApiClient'
import { ComputeJobExecutionError, LoginRequiredError } from '../types' import {
ErrorResponse,
ComputeJobExecutionError,
LoginRequiredError
} from '../types/errors'
import { BaseJobExecutor } from './JobExecutor' import { BaseJobExecutor } from './JobExecutor'
export class ComputeJobExecutor extends BaseJobExecutor { export class ComputeJobExecutor extends BaseJobExecutor {
@@ -20,35 +23,52 @@ export class ComputeJobExecutor extends BaseJobExecutor {
const waitForResult = true const waitForResult = true
const expectWebout = true const expectWebout = true
return this.sasViyaApiClient const requestPromise = new Promise((resolve, reject) => {
?.executeComputeJob( this.sasViyaApiClient
sasJob, ?.executeComputeJob(
config.contextName, sasJob,
config.debug, config.contextName,
data, config.debug,
accessToken, data,
waitForResult, accessToken,
expectWebout waitForResult,
) expectWebout
.then((response) => { )
this.appendRequest(response, sasJob, config.debug) .then((response) => {
let responseJson this.appendRequest(response, sasJob, config.debug)
return response.result resolve(response.result)
})
.catch(async (e: Error) => {
if (e instanceof ComputeJobExecutionError) {
this.appendRequest(e, sasJob, config.debug)
return responseJson reject(new ErrorResponse(e?.message, e))
}) }
.catch(async (e: Error) => {
if (e instanceof ComputeJobExecutionError) { if (e instanceof LoginRequiredError) {
this.appendRequest(e, sasJob, config.debug) await loginCallback()
} this.appendWaitingRequest(() => {
if (e instanceof LoginRequiredError) { return this.execute(
await loginCallback() sasJob,
this.appendWaitingRequest(() => data,
this.execute(sasJob, data, config, loginRequiredCallback) config,
) loginRequiredCallback
} ).then(
return Promise.reject(new ErrorResponse(e?.message, e)) (res: any) => {
}) resolve(res)
},
(err: any) => {
reject(err)
}
)
})
} else {
reject(new ErrorResponse(e?.message, e))
}
})
})
return requestPromise
} }
} }

View File

@@ -1,7 +1,11 @@
import { ServerType } from '@sasjs/utils/types' import { ServerType } from '@sasjs/utils/types'
import { ErrorResponse } from '..'
import { SASViyaApiClient } from '../SASViyaApiClient' import { SASViyaApiClient } from '../SASViyaApiClient'
import { JobExecutionError, LoginRequiredError } from '../types' import {
ErrorResponse,
JobExecutionError,
LoginRequiredError
} from '../types/errors'
import { ExtraResponseAttributes } from '@sasjs/utils/types'
import { BaseJobExecutor } from './JobExecutor' import { BaseJobExecutor } from './JobExecutor'
export class JesJobExecutor extends BaseJobExecutor { export class JesJobExecutor extends BaseJobExecutor {
@@ -14,27 +18,74 @@ export class JesJobExecutor extends BaseJobExecutor {
data: any, data: any,
config: any, config: any,
loginRequiredCallback?: any, loginRequiredCallback?: any,
accessToken?: string accessToken?: string,
extraResponseAttributes: ExtraResponseAttributes[] = []
) { ) {
const loginCallback = loginRequiredCallback || (() => Promise.resolve()) const loginCallback = loginRequiredCallback || (() => Promise.resolve())
return await this.sasViyaApiClient
?.executeJob(sasJob, config.contextName, config.debug, data, accessToken)
.then((response) => {
this.appendRequest(response, sasJob, config.debug)
return response.result const requestPromise = new Promise((resolve, reject) => {
}) this.sasViyaApiClient
.catch(async (e: Error) => { ?.executeJob(
if (e instanceof JobExecutionError) { sasJob,
this.appendRequest(e, sasJob, config.debug) config.contextName,
} config.debug,
if (e instanceof LoginRequiredError) { data,
await loginCallback() accessToken
this.appendWaitingRequest(() => )
this.execute(sasJob, data, config, loginRequiredCallback) .then((response: any) => {
) this.appendRequest(response, sasJob, config.debug)
}
return Promise.reject(new ErrorResponse(e?.message, e)) let responseObject = {}
})
if (extraResponseAttributes && extraResponseAttributes.length > 0) {
const extraAttributes = extraResponseAttributes.reduce(
(map: any, obj: any) => ((map[obj] = response[obj]), map),
{}
)
responseObject = {
result: response.result,
...extraAttributes
}
} else {
responseObject = response.result
}
resolve(responseObject)
})
.catch(async (e: Error) => {
if (e instanceof JobExecutionError) {
this.appendRequest(e, sasJob, config.debug)
reject(new ErrorResponse(e?.message, e))
}
if (e instanceof LoginRequiredError) {
await loginCallback()
this.appendWaitingRequest(() => {
return this.execute(
sasJob,
data,
config,
loginRequiredCallback,
accessToken,
extraResponseAttributes
).then(
(res: any) => {
resolve(res)
},
(err: any) => {
reject(err)
}
)
})
} else {
reject(new ErrorResponse(e?.message, e))
}
})
})
return requestPromise
} }
} }

View File

@@ -1,5 +1,6 @@
import { ServerType } from '@sasjs/utils/types' import { ServerType } from '@sasjs/utils/types'
import { SASjsRequest } from '../types' import { SASjsRequest } from '../types'
import { ExtraResponseAttributes } from '@sasjs/utils/types'
import { asyncForEach, parseGeneratedCode, parseSourceCode } from '../utils' import { asyncForEach, parseGeneratedCode, parseSourceCode } from '../utils'
export type ExecuteFunction = () => Promise<any> export type ExecuteFunction = () => Promise<any>
@@ -10,7 +11,8 @@ export interface JobExecutor {
data: any, data: any,
config: any, config: any,
loginRequiredCallback?: any, loginRequiredCallback?: any,
accessToken?: string accessToken?: string,
extraResponseAttributes?: ExtraResponseAttributes[]
) => Promise<any> ) => Promise<any>
resendWaitingRequests: () => Promise<void> resendWaitingRequests: () => Promise<void>
getRequests: () => SASjsRequest[] getRequests: () => SASjsRequest[]
@@ -28,7 +30,8 @@ export abstract class BaseJobExecutor implements JobExecutor {
data: any, data: any,
config: any, config: any,
loginRequiredCallback?: any, loginRequiredCallback?: any,
accessToken?: string | undefined accessToken?: string | undefined,
extraResponseAttributes?: ExtraResponseAttributes[]
): Promise<any> ): Promise<any>
resendWaitingRequests = async () => { resendWaitingRequests = async () => {

View File

@@ -0,0 +1,110 @@
import { ServerType } from '@sasjs/utils/types'
import * as NodeFormData from 'form-data'
import { ErrorResponse } from '../types/errors'
import { convertToCSV, isRelativePath } from '../utils'
import { BaseJobExecutor } from './JobExecutor'
import { Sas9RequestClient } from '../request/Sas9RequestClient'
/**
* Job executor for SAS9 servers for use in Node.js environments.
* Initiates login with the provided username and password from the config
* The cookies are stored in the request client and used in subsequent
* job execution requests.
*/
export class Sas9JobExecutor extends BaseJobExecutor {
private requestClient: Sas9RequestClient
constructor(
serverUrl: string,
serverType: ServerType,
private jobsPath: string
) {
super(serverUrl, serverType)
this.requestClient = new Sas9RequestClient(serverUrl, false)
}
async execute(sasJob: string, data: any, config: any) {
const program = isRelativePath(sasJob)
? config.appLoc
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
: sasJob
: sasJob
let apiUrl = `${config.serverUrl}${this.jobsPath}?${'_program=' + program}`
apiUrl = `${apiUrl}${
config.username && config.password
? '&_username=' + config.username + '&_password=' + config.password
: ''
}`
let requestParams = {
...this.getRequestParams(config)
}
let formData = new NodeFormData()
if (data) {
try {
formData = generateFileUploadForm(formData, data)
} catch (e) {
return Promise.reject(new ErrorResponse(e?.message, e))
}
}
for (const key in requestParams) {
if (requestParams.hasOwnProperty(key)) {
formData.append(key, requestParams[key])
}
}
await this.requestClient.login(
config.username,
config.password,
this.jobsPath
)
const contentType =
data && Object.keys(data).length
? 'multipart/form-data; boundary=' + (formData as any)._boundary
: 'text/plain'
return await this.requestClient!.post(
apiUrl,
formData,
undefined,
contentType,
{
Accept: '*/*',
Connection: 'Keep-Alive'
}
)
}
private getRequestParams(config: any): any {
const requestParams: any = {}
if (config.debug) {
requestParams['_debug'] = 131
}
return requestParams
}
}
const generateFileUploadForm = (
formData: NodeFormData,
data: any
): NodeFormData => {
for (const tableName in data) {
const name = 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.'
)
}
formData.append(name, csv, {
filename: `${name}.csv`,
contentType: 'application/csv'
})
}
return formData
}

View File

@@ -1,5 +1,9 @@
import { ServerType } from '@sasjs/utils/types' import { ServerType } from '@sasjs/utils/types'
import { ErrorResponse, JobExecutionError, LoginRequiredError } from '..' import {
ErrorResponse,
JobExecutionError,
LoginRequiredError
} from '../types/errors'
import { generateFileUploadForm } from '../file/generateFileUploadForm' import { generateFileUploadForm } from '../file/generateFileUploadForm'
import { generateTableUploadForm } from '../file/generateTableUploadForm' import { generateTableUploadForm } from '../file/generateTableUploadForm'
import { RequestClient } from '../request/RequestClient' import { RequestClient } from '../request/RequestClient'
@@ -7,6 +11,11 @@ import { SASViyaApiClient } from '../SASViyaApiClient'
import { isRelativePath } from '../utils' import { isRelativePath } from '../utils'
import { BaseJobExecutor } from './JobExecutor' import { BaseJobExecutor } from './JobExecutor'
export interface WaitingRequstPromise {
promise: Promise<any> | null
resolve: any
reject: any
}
export class WebJobExecutor extends BaseJobExecutor { export class WebJobExecutor extends BaseJobExecutor {
constructor( constructor(
serverUrl: string, serverUrl: string,
@@ -62,10 +71,8 @@ export class WebJobExecutor extends BaseJobExecutor {
} else { } else {
// param based approach // param based approach
try { try {
const { const { formData: newFormData, requestParams: params } =
formData: newFormData, generateTableUploadForm(formData, data)
requestParams: params
} = generateTableUploadForm(formData, data)
formData = newFormData formData = newFormData
requestParams = { ...requestParams, ...params } requestParams = { ...requestParams, ...params }
} catch (e) { } catch (e) {
@@ -80,30 +87,51 @@ export class WebJobExecutor extends BaseJobExecutor {
} }
} }
return this.requestClient!.post(apiUrl, formData, undefined) const requestPromise = new Promise((resolve, reject) => {
.then(async (res) => { this.requestClient!.post(apiUrl, formData, undefined)
if (this.serverType === ServerType.SasViya && config.debug) { .then(async (res) => {
const jsonResponse = await this.parseSasViyaDebugResponse( if (this.serverType === ServerType.SasViya && config.debug) {
res.result as string const jsonResponse = await this.parseSasViyaDebugResponse(
) res.result as string
)
this.appendRequest(res, sasJob, config.debug)
resolve(jsonResponse)
}
this.appendRequest(res, sasJob, config.debug) this.appendRequest(res, sasJob, config.debug)
return jsonResponse resolve(res.result)
} })
this.appendRequest(res, sasJob, config.debug) .catch(async (e: Error) => {
return res.result if (e instanceof JobExecutionError) {
}) this.appendRequest(e, sasJob, config.debug)
.catch(async (e: Error) => {
if (e instanceof JobExecutionError) { reject(new ErrorResponse(e?.message, e))
this.appendRequest(e, sasJob, config.debug) }
}
if (e instanceof LoginRequiredError) { if (e instanceof LoginRequiredError) {
await loginCallback() await loginCallback()
this.appendWaitingRequest(() =>
this.execute(sasJob, data, config, loginRequiredCallback) this.appendWaitingRequest(() => {
) return this.execute(
} sasJob,
return Promise.reject(new ErrorResponse(e?.message, e)) data,
}) config,
loginRequiredCallback
).then(
(res: any) => {
resolve(res)
},
(err: any) => {
reject(err)
}
)
})
} else {
reject(new ErrorResponse(e?.message, e))
}
})
})
return requestPromise
} }
private parseSasViyaDebugResponse = async (response: string) => { private parseSasViyaDebugResponse = async (response: string) => {

View File

@@ -1,4 +1,5 @@
export * from './ComputeJobExecutor' export * from './ComputeJobExecutor'
export * from './JesJobExecutor' export * from './JesJobExecutor'
export * from './JobExecutor' export * from './JobExecutor'
export * from './Sas9JobExecutor'
export * from './WebJobExecutor' export * from './WebJobExecutor'

View File

@@ -1,11 +1,16 @@
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios' import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
import { CsrfToken, JobExecutionError } from '..' import { CsrfToken } from '..'
import { isAuthorizeFormRequired, isLogInRequired } from '../auth' import { isAuthorizeFormRequired, isLogInRequired } from '../auth'
import { LoginRequiredError } from '../types' import {
import { AuthorizeError } from '../types/AuthorizeError' AuthorizeError,
import { NotFoundError } from '../types/NotFoundError' LoginRequiredError,
NotFoundError,
InternalServerError,
JobExecutionError
} from '../types/errors'
import { parseWeboutResponse } from '../utils/parseWeboutResponse' import { parseWeboutResponse } from '../utils/parseWeboutResponse'
import { prefixMessage } from '@sasjs/utils/error' import { prefixMessage } from '@sasjs/utils/error'
import { SAS9AuthError } from '../types/errors/SAS9AuthError'
export interface HttpClient { export interface HttpClient {
get<T>( get<T>(
@@ -40,11 +45,11 @@ export interface HttpClient {
} }
export class RequestClient implements HttpClient { export class RequestClient implements HttpClient {
private csrfToken: CsrfToken = { headerName: '', value: '' } protected csrfToken: CsrfToken = { headerName: '', value: '' }
private fileUploadCsrfToken: CsrfToken | undefined protected fileUploadCsrfToken: CsrfToken | undefined
private httpClient: AxiosInstance protected httpClient: AxiosInstance
constructor(private baseUrl: string, allowInsecure = false) { constructor(protected baseUrl: string, allowInsecure = false) {
const https = require('https') const https = require('https')
if (allowInsecure && https.Agent) { if (allowInsecure && https.Agent) {
this.httpClient = axios.create({ this.httpClient = axios.create({
@@ -73,7 +78,8 @@ export class RequestClient implements HttpClient {
url: string, url: string,
accessToken: string | undefined, accessToken: string | undefined,
contentType: string = 'application/json', contentType: string = 'application/json',
overrideHeaders: { [key: string]: string | number } = {} overrideHeaders: { [key: string]: string | number } = {},
debug: boolean = false
): Promise<{ result: T; etag: string }> { ): Promise<{ result: T; etag: string }> {
const headers = { const headers = {
...this.getHeaders(accessToken, contentType), ...this.getHeaders(accessToken, contentType),
@@ -93,11 +99,22 @@ export class RequestClient implements HttpClient {
.get<T>(url, requestConfig) .get<T>(url, requestConfig)
.then((response) => { .then((response) => {
throwIfError(response) throwIfError(response)
return this.parseResponse<T>(response) return this.parseResponse<T>(response)
}) })
.catch(async (e) => { .catch(async (e) => {
return await this.handleError(e, () => return await this.handleError(
this.get<T>(url, accessToken, contentType, overrideHeaders) e,
() =>
this.get<T>(url, accessToken, contentType, overrideHeaders).catch(
(err) => {
throw prefixMessage(
err,
'Error while executing handle error callback. '
)
}
),
debug
).catch((err) => { ).catch((err) => {
throw prefixMessage(err, 'Error while handling error. ') throw prefixMessage(err, 'Error while handling error. ')
}) })
@@ -198,9 +215,8 @@ export class RequestClient implements HttpClient {
const headers = this.getHeaders(accessToken, 'application/json') const headers = this.getHeaders(accessToken, 'application/json')
if (this.fileUploadCsrfToken?.value) { if (this.fileUploadCsrfToken?.value) {
headers[ headers[this.fileUploadCsrfToken.headerName] =
this.fileUploadCsrfToken.headerName this.fileUploadCsrfToken.value
] = this.fileUploadCsrfToken.value
} }
try { try {
@@ -275,7 +291,7 @@ export class RequestClient implements HttpClient {
}) })
} }
private getHeaders = ( protected getHeaders = (
accessToken: string | undefined, accessToken: string | undefined,
contentType: string contentType: string
) => { ) => {
@@ -300,7 +316,7 @@ export class RequestClient implements HttpClient {
return headers return headers
} }
private parseAndSetFileUploadCsrfToken = (response: AxiosResponse) => { protected parseAndSetFileUploadCsrfToken = (response: AxiosResponse) => {
const token = this.parseCsrfToken(response) const token = this.parseCsrfToken(response)
if (token) { if (token) {
@@ -308,7 +324,7 @@ export class RequestClient implements HttpClient {
} }
} }
private parseAndSetCsrfToken = (response: AxiosResponse) => { protected parseAndSetCsrfToken = (response: AxiosResponse) => {
const token = this.parseCsrfToken(response) const token = this.parseCsrfToken(response)
if (token) { if (token) {
@@ -317,9 +333,9 @@ export class RequestClient implements HttpClient {
} }
private parseCsrfToken = (response: AxiosResponse): CsrfToken | undefined => { private parseCsrfToken = (response: AxiosResponse): CsrfToken | undefined => {
const tokenHeader = (response.headers[ const tokenHeader = (
'x-csrf-header' response.headers['x-csrf-header'] as string
] as string)?.toLowerCase() )?.toLowerCase()
if (tokenHeader) { if (tokenHeader) {
const token = response.headers[tokenHeader] const token = response.headers[tokenHeader]
@@ -332,7 +348,11 @@ export class RequestClient implements HttpClient {
} }
} }
private handleError = async (e: any, callback: any) => { protected handleError = async (
e: any,
callback: any,
debug: boolean = false
) => {
const response = e.response as AxiosResponse const response = e.response as AxiosResponse
if (e instanceof AuthorizeError) { if (e instanceof AuthorizeError) {
@@ -346,7 +366,9 @@ export class RequestClient implements HttpClient {
}) })
if (isAuthorizeFormRequired(res?.data as string)) { if (isAuthorizeFormRequired(res?.data as string)) {
await this.authorize(res.data as string) await this.authorize(res.data as string).catch((err) => {
throw prefixMessage(err, 'Error while authorizing request. ')
})
} }
return await callback().catch((err: any) => { return await callback().catch((err: any) => {
@@ -376,14 +398,18 @@ export class RequestClient implements HttpClient {
throw e throw e
} else if (response?.status === 404) { } else if (response?.status === 404) {
throw new NotFoundError(response.config.url!) throw new NotFoundError(response.config.url!)
} else if (response?.status === 502) {
if (debug) throw new InternalServerError()
else return
} }
throw e throw e
} }
private parseResponse<T>(response: AxiosResponse<any>) { protected parseResponse<T>(response: AxiosResponse<any>) {
const etag = response?.headers ? response.headers['etag'] : '' const etag = response?.headers ? response.headers['etag'] : ''
let parsedResponse let parsedResponse
let includeSAS9Log: boolean = false
try { try {
if (typeof response.data === 'string') { if (typeof response.data === 'string') {
@@ -397,15 +423,24 @@ export class RequestClient implements HttpClient {
} catch { } catch {
parsedResponse = response.data parsedResponse = response.data
} }
includeSAS9Log = true
} }
return {
let responseToReturn: { result: T; etag: any; log?: string } = {
result: parsedResponse as T, result: parsedResponse as T,
etag etag
} }
if (includeSAS9Log) {
responseToReturn.log = response.data
}
return responseToReturn
} }
} }
const throwIfError = (response: AxiosResponse) => { export const throwIfError = (response: AxiosResponse) => {
if (response.status === 401) { if (response.status === 401) {
throw new LoginRequiredError() throw new LoginRequiredError()
} }
@@ -436,7 +471,12 @@ const throwIfError = (response: AxiosResponse) => {
throw new AuthorizeError(response.data.message, authorizeRequestUrl) throw new AuthorizeError(response.data.message, authorizeRequestUrl)
} }
if (response.config?.url?.includes('sasAuthError')) {
throw new SAS9AuthError()
}
const error = parseError(response.data as string) const error = parseError(response.data as string)
if (error) { if (error) {
throw error throw error
} }

View File

@@ -0,0 +1,121 @@
import { AxiosRequestConfig } from 'axios'
import axiosCookieJarSupport from 'axios-cookiejar-support'
import * as tough from 'tough-cookie'
import { prefixMessage } from '@sasjs/utils/error'
import { RequestClient, throwIfError } from './RequestClient'
/**
* Specific request client for SAS9 in Node.js environments.
* Handles redirects and cookie management.
*/
export class Sas9RequestClient extends RequestClient {
constructor(baseUrl: string, allowInsecure = false) {
super(baseUrl, allowInsecure)
this.httpClient.defaults.maxRedirects = 0
this.httpClient.defaults.validateStatus = (status) =>
status >= 200 && status < 303
if (axiosCookieJarSupport) {
axiosCookieJarSupport(this.httpClient)
this.httpClient.defaults.jar = new tough.CookieJar()
}
}
public async login(username: string, password: string, jobsPath: string) {
const codeInjectorPath = `/User Folders/${username}/My Folder/sasjs/runner`
if (this.httpClient.defaults.jar) {
;(this.httpClient.defaults.jar as tough.CookieJar).removeAllCookies()
await this.get(
`${jobsPath}?_program=${codeInjectorPath}&_username=${username}&_password=${password}`,
undefined,
'text/plain'
)
}
}
public async get<T>(
url: string,
accessToken: string | undefined,
contentType: string = 'application/json',
overrideHeaders: { [key: string]: string | number } = {},
debug: boolean = false
): Promise<{ result: T; etag: string }> {
const headers = {
...this.getHeaders(accessToken, contentType),
...overrideHeaders
}
const requestConfig: AxiosRequestConfig = {
headers,
responseType: contentType === 'text/plain' ? 'text' : 'json',
withCredentials: true
}
if (contentType === 'text/plain') {
requestConfig.transformResponse = undefined
}
return this.httpClient
.get<T>(url, requestConfig)
.then((response) => {
if (response.status === 302) {
return this.get(
response.headers['location'],
accessToken,
contentType
)
}
throwIfError(response)
return this.parseResponse<T>(response)
})
.catch(async (e) => {
return await this.handleError(
e,
() =>
this.get<T>(url, accessToken, contentType, overrideHeaders).catch(
(err) => {
throw prefixMessage(
err,
'Error while executing handle error callback. '
)
}
),
debug
).catch((err) => {
throw prefixMessage(err, 'Error while handling error. ')
})
})
}
public post<T>(
url: string,
data: any,
accessToken: string | undefined,
contentType = 'application/json',
overrideHeaders: { [key: string]: string | number } = {}
): Promise<{ result: T; etag: string }> {
const headers = {
...this.getHeaders(accessToken, contentType),
...overrideHeaders
}
return this.httpClient
.post<T>(url, data, { headers, withCredentials: true })
.then(async (response) => {
if (response.status === 302) {
return await this.get(
response.headers['location'],
undefined,
contentType,
overrideHeaders
)
}
throwIfError(response)
return this.parseResponse<T>(response)
})
.catch(async (e) => {
return await this.handleError(e, () =>
this.post<T>(url, data, accessToken, contentType, overrideHeaders)
)
})
}
}

View File

@@ -1,3 +1,7 @@
/**
* @jest-environment jsdom
*/
import { FileUploader } from '../FileUploader' import { FileUploader } from '../FileUploader'
import { UploadFile } from '../types' import { UploadFile } from '../types'
import { RequestClient } from '../request/RequestClient' import { RequestClient } from '../request/RequestClient'
@@ -35,41 +39,40 @@ describe('FileUploader', () => {
new RequestClient('https://sample.server.com') new RequestClient('https://sample.server.com')
) )
it('should upload successfully', async (done) => { it('should upload successfully', async () => {
const sasJob = 'test/upload' const sasJob = 'test/upload'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.resolve({ data: sampleResponse }) Promise.resolve({ data: sampleResponse })
) )
fileUploader.uploadFile(sasJob, files, params).then((res: any) => { const res = await fileUploader.uploadFile(sasJob, files, params)
expect(res).toEqual(JSON.parse(sampleResponse))
done() expect(res).toEqual(JSON.parse(sampleResponse))
})
}) })
it('should an error when no files are provided', async (done) => { it('should an error when no files are provided', async () => {
const sasJob = 'test/upload' const sasJob = 'test/upload'
const files: UploadFile[] = [] const files: UploadFile[] = []
const params = { table: 'libtable' } const params = { table: 'libtable' }
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('At least one file must be provided.') .uploadFile(sasJob, files, params)
done() .catch((err: any) => err)
}) expect(err.error.message).toEqual('At least one file must be provided.')
}) })
it('should throw an error when no sasJob is provided', async (done) => { it('should throw an error when no sasJob is provided', async () => {
const sasJob = '' const sasJob = ''
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('sasJob must be provided.') .uploadFile(sasJob, files, params)
done() .catch((err: any) => err)
}) expect(err.error.message).toEqual('sasJob must be provided.')
}) })
it('should throw an error when login is required', async (done) => { it('should throw an error when login is required', async () => {
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.resolve({ data: '<form action="Logon">' }) Promise.resolve({ data: '<form action="Logon">' })
) )
@@ -77,15 +80,13 @@ describe('FileUploader', () => {
const sasJob = 'test' const sasJob = 'test'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual( .uploadFile(sasJob, files, params)
'You must be logged in to upload a file.' .catch((err: any) => err)
) expect(err.error.message).toEqual('You must be logged in to upload a file.')
done()
})
}) })
it('should throw an error when invalid JSON is returned by the server', async (done) => { it('should throw an error when invalid JSON is returned by the server', async () => {
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.resolve({ data: '{invalid: "json"' }) Promise.resolve({ data: '{invalid: "json"' })
) )
@@ -93,13 +94,13 @@ describe('FileUploader', () => {
const sasJob = 'test' const sasJob = 'test'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('File upload request failed.') .uploadFile(sasJob, files, params)
done() .catch((err: any) => err)
}) expect(err.error.message).toEqual('File upload request failed.')
}) })
it('should throw an error when the server request fails', async (done) => { it('should throw an error when the server request fails', async () => {
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.reject({ data: '{message: "Server error"}' }) Promise.reject({ data: '{message: "Server error"}' })
) )
@@ -107,10 +108,9 @@ describe('FileUploader', () => {
const sasJob = 'test' const sasJob = 'test'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('File upload request failed.') .uploadFile(sasJob, files, params)
.catch((err: any) => err)
done() expect(err.error.message).toEqual('File upload request failed.')
})
}) })
}) })

View File

@@ -14,7 +14,7 @@ describe('FolderOperations', () => {
beforeEach(() => {}) beforeEach(() => {})
it('should move and rename folder', async (done) => { it('should move and rename folder', async () => {
mockFetchResponse(false) mockFetchResponse(false)
let res: any = await sasViyaApiClient.moveFolder( let res: any = await sasViyaApiClient.moveFolder(
@@ -26,11 +26,9 @@ describe('FolderOperations', () => {
expect(res.folder.name).toEqual('newName') expect(res.folder.name).toEqual('newName')
expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder') expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder')
done()
}) })
it('should move and keep the name of folder', async (done) => { it('should move and keep the name of folder', async () => {
mockFetchResponse(true) mockFetchResponse(true)
let res: any = await sasViyaApiClient.moveFolder( let res: any = await sasViyaApiClient.moveFolder(
@@ -42,11 +40,9 @@ describe('FolderOperations', () => {
expect(res.folder.name).toEqual('oldName') expect(res.folder.name).toEqual('oldName')
expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder') expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder')
done()
}) })
it('should only rename folder', async (done) => { it('should only rename folder', async () => {
mockFetchResponse(false) mockFetchResponse(false)
let res: any = await sasViyaApiClient.moveFolder( let res: any = await sasViyaApiClient.moveFolder(
@@ -58,8 +54,6 @@ describe('FolderOperations', () => {
expect(res.folder.name).toEqual('newName') expect(res.folder.name).toEqual('newName')
expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder') expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder')
done()
}) })
}) })

View File

@@ -29,7 +29,10 @@ describe('SessionManager', () => {
Promise.resolve({ data: sampleResponse }) Promise.resolve({ data: sampleResponse })
) )
const expectedResponse = { etag: '', result: sampleResponse } const expectedResponse = {
etag: '',
result: sampleResponse
}
await expect( await expect(
sessionManager.getVariable( sessionManager.getVariable(

View File

@@ -0,0 +1,39 @@
import { isUrl } from '../../utils/isUrl'
describe('urlValidator', () => {
it('should return true with an HTTP URL', () => {
const url = 'http://google.com'
expect(isUrl(url)).toEqual(true)
})
it('should return true with an HTTPS URL', () => {
const url = 'https://google.com'
expect(isUrl(url)).toEqual(true)
})
it('should return true when the URL is blank', () => {
const url = ''
expect(isUrl(url)).toEqual(false)
})
it('should return false when the URL has not supported protocol', () => {
const url = 'htpps://google.com'
expect(isUrl(url)).toEqual(false)
})
it('should return false when the URL is null', () => {
const url = null
expect(isUrl(url as unknown as string)).toEqual(false)
})
it('should return false when the URL is undefined', () => {
const url = undefined
expect(isUrl(url as unknown as string)).toEqual(false)
})
})

View File

@@ -1,6 +1,6 @@
import { parseGeneratedCode } from '../../utils/index' import { parseGeneratedCode } from '../../utils/index'
it('should parse generated code', async (done) => { it('should parse generated code', () => {
expect(sampleResponse).toBeTruthy() expect(sampleResponse).toBeTruthy()
const parsedGeneratedCode = parseGeneratedCode(sampleResponse) const parsedGeneratedCode = parseGeneratedCode(sampleResponse)
@@ -15,8 +15,6 @@ it('should parse generated code', async (done) => {
expect(generatedCodeLines[2].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy() expect(generatedCodeLines[2].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy()
expect(generatedCodeLines[3].startsWith('MPRINT(MM_WEBRIGHT)')).toBeTruthy() expect(generatedCodeLines[3].startsWith('MPRINT(MM_WEBRIGHT)')).toBeTruthy()
expect(generatedCodeLines[4].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy() expect(generatedCodeLines[4].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy()
done()
}) })
/* tslint:disable */ /* tslint:disable */

View File

@@ -1,6 +1,6 @@
import { parseSourceCode } from '../../utils/index' import { parseSourceCode } from '../../utils/index'
it('should parse SAS9 source code', async (done) => { it('should parse SAS9 source code', async () => {
expect(sampleResponse).toBeTruthy() expect(sampleResponse).toBeTruthy()
const parsedSourceCode = parseSourceCode(sampleResponse) const parsedSourceCode = parseSourceCode(sampleResponse)
@@ -15,8 +15,6 @@ it('should parse SAS9 source code', async (done) => {
expect(sourceCodeLines[2].startsWith('8')).toBeTruthy() expect(sourceCodeLines[2].startsWith('8')).toBeTruthy()
expect(sourceCodeLines[3].startsWith('9')).toBeTruthy() expect(sourceCodeLines[3].startsWith('9')).toBeTruthy()
expect(sourceCodeLines[4].startsWith('10')).toBeTruthy() expect(sourceCodeLines[4].startsWith('10')).toBeTruthy()
done()
}) })
/* tslint:disable */ /* tslint:disable */

Some files were not shown because too many files have changed in this diff Show More