1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-22 13:31:19 +00:00

Compare commits

..

32 Commits

Author SHA1 Message Date
Krishna Acondy
0ac7f8892e fix(build): switch default branch to master 2020-07-15 12:25:20 +01:00
Krishna Acondy
68f5e5bec5 Merge pull request #10 from sasjs/main
Merge main into master
2020-07-15 12:21:45 +01:00
Krishna Acondy
69a14ff6d7 Merge branch 'master' into main 2020-07-15 12:20:08 +01:00
Krishna Acondy
70e461224a Merge pull request #8 from sasjs/allanbowe-patch-1
Update npmpublish.yml
2020-07-15 12:18:46 +01:00
Krishna Acondy
4da22ee6b4 Merge pull request #9 from sasjs/dependabot/npm_and_yarn/ts-loader-8.0.1
chore(deps-dev): bump ts-loader from 7.0.5 to 8.0.1
2020-07-15 12:18:22 +01:00
Allan Bowe
2c8ba09578 docs: viya test routine in CONTRIBUTING.md 2020-07-15 11:12:46 +02:00
dependabot-preview[bot]
c12d6f1c9c chore(deps-dev): bump ts-loader from 7.0.5 to 8.0.1
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 7.0.5 to 8.0.1.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v7.0.5...v8.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-15 08:35:48 +00:00
Allan Bowe
e5fb7a7698 Update npmpublish.yml 2020-07-11 18:23:19 +02:00
Krishna Acondy
c22b9066d8 chore(sasjs-tests): update package version 2020-07-11 11:39:59 +01:00
Krishna Acondy
77d7e03de5 fix(*): switch to file upload approach with large datasets and special characters 2020-07-11 11:27:45 +01:00
Krishna Acondy
b614bafd03 chore(*): update references to master 2020-07-09 08:14:50 +01:00
Krishna Acondy
34cabcde2d fix(ci): change target branch for build action 2020-07-09 08:13:53 +01:00
Krishna Acondy
de82058850 fix(deps-ci): update build, remove unnecessary dependencies 2020-07-09 08:13:28 +01:00
Krishna Acondy
327be9e141 Merge pull request #2 from sasjs/dependabot/npm_and_yarn/npm-6.14.6
chore(deps): [security] bump npm from 6.14.5 to 6.14.6
2020-07-09 08:09:16 +01:00
dependabot-preview[bot]
f1502c0773 chore(deps): [security] bump npm from 6.14.5 to 6.14.6
Bumps [npm](https://github.com/npm/cli) from 6.14.5 to 6.14.6. **This update includes a security fix.**
- [Release notes](https://github.com/npm/cli/releases)
- [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
- [Commits](https://github.com/npm/cli/compare/v6.14.5...v6.14.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-09 07:08:09 +00:00
Krishna Acondy
c8a2df2d1f Merge pull request #3 from sasjs/dependabot/npm_and_yarn/types/jest-26.0.4
chore(deps-dev): bump @types/jest from 26.0.3 to 26.0.4
2020-07-09 08:04:09 +01:00
Krishna Acondy
2be6200b90 Merge branch 'master' into dependabot/npm_and_yarn/types/jest-26.0.4 2020-07-09 07:56:47 +01:00
Krishna Acondy
333289cd20 Merge pull request #4 from sasjs/dependabot/npm_and_yarn/npm-registry-fetch-4.0.5
chore(deps): [security] bump npm-registry-fetch from 4.0.4 to 4.0.5
2020-07-09 07:56:31 +01:00
Krishna Acondy
204139cd01 Merge branch 'master' into dependabot/npm_and_yarn/npm-registry-fetch-4.0.5 2020-07-09 07:55:28 +01:00
Krishna Acondy
2a38b68e69 Merge pull request #5 from sasjs/dependabot/npm_and_yarn/typedoc-neo-theme-1.0.9
chore(deps-dev): bump typedoc-neo-theme from 1.0.8 to 1.0.9
2020-07-09 07:55:13 +01:00
Krishna Acondy
39cc20b680 Merge branch 'master' into dependabot/npm_and_yarn/typedoc-neo-theme-1.0.9 2020-07-09 07:53:48 +01:00
Allan Bowe
8b3c9746fc Merge pull request #6 from sasjs/allanbowe-patch-1
Update README.md
2020-07-08 23:35:59 +02:00
Allan Bowe
7a76f5f343 Merge branch 'master' into allanbowe-patch-1 2020-07-08 23:35:49 +02:00
Allan Bowe
2bbcd7dee7 Update README.md 2020-07-08 23:35:20 +02:00
Allan Bowe
b02ce07ddf Update README.md 2020-07-08 23:34:59 +02:00
dependabot-preview[bot]
41400bea86 chore(deps-dev): bump typedoc-neo-theme from 1.0.8 to 1.0.9
Bumps [typedoc-neo-theme](https://github.com/google/typedoc-neo-theme) from 1.0.8 to 1.0.9.
- [Release notes](https://github.com/google/typedoc-neo-theme/releases)
- [Commits](https://github.com/google/typedoc-neo-theme/compare/v1.0.8...v1.0.9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-07 20:07:49 +00:00
dependabot-preview[bot]
991ac100f6 chore(deps): [security] bump npm-registry-fetch from 4.0.4 to 4.0.5
Bumps [npm-registry-fetch](https://github.com/npm/registry-fetch) from 4.0.4 to 4.0.5. **This update includes a security fix.**
- [Release notes](https://github.com/npm/registry-fetch/releases)
- [Changelog](https://github.com/npm/npm-registry-fetch/blob/latest/CHANGELOG.md)
- [Commits](https://github.com/npm/registry-fetch/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-07 20:07:02 +00:00
dependabot-preview[bot]
66c156d299 chore(deps-dev): bump @types/jest from 26.0.3 to 26.0.4
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.3 to 26.0.4.
- [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>
2020-07-07 20:06:44 +00:00
Krishna Acondy
7d0d830391 Set theme jekyll-theme-minimal 2020-07-07 21:00:20 +01:00
Krishna Acondy
0b038380c7 chore(doc): update documentation 2020-07-07 20:51:44 +01:00
Krishna Acondy
162ba5e837 chore(example): update adapter import in example 2020-07-07 20:47:28 +01:00
Krishna Acondy
f217b3eb04 fix(doc): update readme references 2020-07-07 20:44:15 +01:00
37 changed files with 5790 additions and 2690 deletions

View File

@@ -1,6 +1,6 @@
# Contributing
Contributions to SASjs are very welcome! When making a PR, test cases should be included. To help in unit testing, be sure to run the following when making changes:
Contributions to SASjs are very welcome! When making a PR, test cases should be included. To help in unit testing, be sure to run the following when making changes:
```
# the following creates a tarball in the build folder of SASjs
@@ -10,12 +10,13 @@ npm run-script package:lib
npm install ../sasjs/build/<tarball filename>
```
Tests are run using cypress. Before running tests, you need to define the following backend services:
Tests are run using cypress. Before running tests, you need to define the following backend services:
# SAS 9
```
filename mc url "https://raw.githubusercontent.com/macropeople/macrocore/master/mc_all.sas?_=1";
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc;
filename ft15f001 temp;
parmcards4;
@@ -37,19 +38,15 @@ parmcards4;
```
# Viya
```
filename mc url "https://raw.githubusercontent.com/macropeople/macrocore/master/mc_all.sas";
%inc mc;
```
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc;
filename ft15f001 temp;
parmcards4;
%webout(FETCH)
%webout(OPEN)
%global sasjs_tables;
%let sasjs_tables=&sasjs_tables;
%put &=sasjs_tables;
%let sasjs_tables=&sasjs_tables;
%macro x();
%global sasjs_tables;
%do i=1 %to %sysfunc(countw(&sasjs_tables));
%let table=%scan(&sasjs_tables,&i);
%webout(OBJ,&table)
@@ -58,13 +55,11 @@ parmcards4;
%x()
%webout(CLOSE)
;;;;
%mv_createwebservice(path=/Public/app/common,name=sendObj)
%mp_createwebservice(path=/Public/app/common,name=sendObj)
filename ft15f001 temp;
parmcards4;
%webout(FETCH)
%webout(OPEN)
%global sasjs_tables;
%let sasjs_tables=&sasjs_tables;
%put &=sasjs_tables;
%macro x();
%do i=1 %to %sysfunc(countw(&sasjs_tables));
%let table=%scan(&sasjs_tables,&i);
@@ -74,7 +69,7 @@ parmcards4;
%x()
%webout(CLOSE)
;;;;
%mv_createwebservice(path=/Public/app/common,name=sendArr)
%mp_createwebservice(path=/Public/app/common,name=sendArr)
```
The above services will return anything you send. To run the tests simply launch `npm run cypress`.
The above services will return anything you send. To run the tests simply launch `npm run cypress`.

View File

@@ -1,14 +1,14 @@
[![](https://data.jsdelivr.com/v1/package/npm/sasjs/badge)](https://www.jsdelivr.com/package/npm/sasjs)
[![](https://data.jsdelivr.com/v1/package/npm/@sasjs/adapter/badge)](https://www.jsdelivr.com/package/npm/@sasjs/adapter)
# SASjs
# @sasjs/adapter
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` - 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/index.js) and use a copy of the latest JS file
2 - [Download](https://cdn.jsdelivr.net/npm/@sasjs/adapter@1/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?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.
If you are short on time and just need to build an app quickly, then check out [this video](https://vimeo.com/393161794) and the [react-seed-app](https://github.com/macropeople/react-seed-app) which provides some boilerplate.
@@ -16,15 +16,14 @@ For more information on building web apps with SAS, check out [sasjs.io](https:/
## None of this makes sense. How do I build an app with it?
Ok ok. Deploy this [example.html](https://github.com/sasjs/adapter/blob/master/example.html) file to your web server, and update `servertype` to `SAS9` or `SASVIYA` depending on your backend.
Ok ok. Deploy this [example.html](https://github.com/sasjs/adapter/blob/main/example.html) file to your web server, and update `servertype` to `SAS9` or `SASVIYA` depending on your backend.
The backend part can be deployed as follows:
```
%let appLoc=/Public/app/readme; /* Metadata or Viya Folder location as per SASjs config */
/* compile macros (can also be downloaded & compiled seperately) */
filename mc url "https://raw.githubusercontent.com/macropeople/macrocore/master/mc_all.sas";
%inc mc;
%let appLoc=/Public/app/readme; /* Metadata or Viya Folder per SASjs config */
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc; /* compile macros (can also be downloaded & compiled seperately) */
filename ft15f001 temp;
parmcards4;
%webout(FETCH) /* receive all data as SAS datasets */

1
docs/_config.yml Normal file
View File

@@ -0,0 +1 @@
theme: jekyll-theme-minimal

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

160
docs/modules/types.html Normal file

File diff suppressed because one or more lines are too long

549
docs/modules/utils.html Normal file

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/sasjs@2.11.0"></script>
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@1"></script>
<script>
var sasJs = new SASjs.default({appLoc: "/Products/demo/readme"
,serverType:"SAS9", debug: "false"

2329
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -36,22 +36,20 @@
},
"license": "ISC",
"devDependencies": {
"@cypress/webpack-preprocessor": "^4.1.5",
"@types/isomorphic-fetch": "0.0.35",
"@types/jest": "^26.0.3",
"@types/jest": "^26.0.4",
"cp": "^0.2.0",
"cypress": "^4.9.0",
"jest": "^25.5.4",
"path": "^0.12.7",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"semantic-release": "^17.1.1",
"ts-jest": "^25.5.1",
"ts-loader": "^7.0.5",
"ts-loader": "^8.0.1",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"typedoc": "^0.17.8",
"typedoc-neo-theme": "^1.0.8",
"typedoc-neo-theme": "^1.0.9",
"typedoc-plugin-external-module-name": "^4.0.3",
"typescript": "^3.9.6",
"uglifyjs-webpack-plugin": "^2.2.0",

View File

@@ -1,6 +1,6 @@
{
"name": "sasjs-tests",
"version": "0.1.0",
"name": "@sasjs/tests",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -1356,6 +1356,28 @@
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz",
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
},
"@sasjs/adapter": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-1.0.5.tgz",
"integrity": "sha512-54gQZD7QdNmQu77axOqr0vMS7hUVXO5hPbUtwXXocMIi3kRQDbROYjC3kuiFM9FrxqiZWbLRcyOqmFv3W/N36w==",
"requires": {
"es6-promise": "^4.2.8",
"form-data": "^3.0.0",
"isomorphic-fetch": "^2.2.1"
},
"dependencies": {
"form-data": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz",
"integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
},
"@sheerun/mutationobserver-shim": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.3.tgz",
@@ -4912,11 +4934,21 @@
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
},
"encoding": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
"integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"requires": {
"iconv-lite": "~0.4.13"
"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": {
@@ -11950,27 +11982,6 @@
"resolved": "https://registry.npmjs.org/sanitize.css/-/sanitize.css-10.0.0.tgz",
"integrity": "sha512-vTxrZz4dX5W86M6oVWVdOVe72ZiPs41Oi7Z6Km4W5Turyz28mrXSJhhEBZoRtzJWIv3833WKVwLSDWWkEfupMg=="
},
"sasjs": {
"version": "file:../build/sasjs-5.0.0.tgz",
"integrity": "sha512-8Ez2iS8BKzu2GG1Cwf/pe5PgNvdhowFodQNCTHIxMlDYgLqmg1mcpwRjJjnXF9A73gX0NkR65olYYAesp8cMMA==",
"requires": {
"es6-promise": "^4.2.8",
"form-data": "^3.0.0",
"isomorphic-fetch": "^2.2.1"
},
"dependencies": {
"form-data": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz",
"integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
},
"sass-graph": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz",

View File

@@ -1,9 +1,10 @@
{
"name": "sasjs-tests",
"version": "0.1.0",
"name": "@sasjs/tests",
"version": "1.0.0",
"homepage": ".",
"private": true,
"dependencies": {
"@sasjs/adapter": "^1.0.5",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
@@ -16,7 +17,6 @@
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"sasjs": "file:../build/sasjs-5.0.0.tgz",
"typescript": "^3.9.6"
},
"scripts": {
@@ -24,7 +24,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"deploy": "rsync -avhe ssh ./build/* --delete kriaco@sas.analytium.co.uk:/var/www/html/kriaco/sasjs-tests"
"deploy": "npm run build && rsync -avhe ssh ./build/* --delete kriaco@sas.analytium.co.uk:/var/www/html/kriaco/sasjs-tests"
},
"eslintConfig": {
"extends": "react-app"

View File

@@ -4,7 +4,7 @@ import TestSuiteCard from "./components/TestSuiteCard";
import { TestSuite, Test } from "./types";
import { basicTests } from "./testSuites/Basic";
import "./TestSuiteRunner.scss";
import SASjs from "sasjs";
import SASjs from "@sasjs/adapter";
import { AppContext } from "./context/AppContext";
import { sendArrTests, sendObjTests } from "./testSuites/RequestData";
import { specialCaseTests } from "./testSuites/SpecialCases";
@@ -38,11 +38,11 @@ const TestSuiteRunner = (
useEffect(() => {
if (adapter) {
setTestSuites([
// basicTests(adapter, config.userName, config.password),
// sendArrTests(adapter),
// sendObjTests(adapter),
basicTests(adapter, config.userName, config.password),
sendArrTests(adapter),
sendObjTests(adapter),
specialCaseTests(adapter),
// sasjsRequestTests(adapter),
sasjsRequestTests(adapter),
]);
setCompletedTestSuites([]);
}

View File

@@ -1,5 +1,5 @@
import React, { createContext, useState, useEffect, ReactNode } from "react";
import SASjs from "sasjs";
import SASjs from "@sasjs/adapter";
export const AppContext = createContext<{
config: any;

View File

@@ -1,4 +1,4 @@
import SASjs, { ServerType, SASjsConfig } from "sasjs";
import SASjs, { ServerType, SASjsConfig } from "@sasjs/adapter";
import { TestSuite } from "../types";
const defaultConfig: SASjsConfig = {

View File

@@ -1,4 +1,4 @@
import SASjs from "sasjs";
import SASjs from "@sasjs/adapter";
import { TestSuite } from "../types";
const stringData: any = { table1: [{ col1: "first col value" }] };

View File

@@ -1,4 +1,4 @@
import SASjs from "sasjs";
import SASjs from "@sasjs/adapter";
import { TestSuite } from "../types";
const data: any = { table1: [{ col1: "first col value" }] };
@@ -12,7 +12,7 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
test: async () => {
return adapter.request("common/sendArr", data);
},
assertion: (res: any) => {
assertion: () => {
const requests = adapter.getSasRequests();
if (adapter.getSasjsConfig().debug) {
return requests[0].SASWORK !== null;

View File

@@ -1,4 +1,4 @@
import SASjs from "sasjs";
import SASjs from "@sasjs/adapter";
import { TestSuite } from "../types";
const specialCharData: any = {
@@ -102,86 +102,86 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
);
},
},
// {
// title: "Other special characters",
// description: "Should handle other special characters",
// test: () => {
// return adapter.request("common/sendArr", moreSpecialCharData);
// },
// assertion: (res: any) => {
// return (
// res.table1[0][0] === moreSpecialCharData.table1[0].speech0 &&
// res.table1[0][1] === moreSpecialCharData.table1[0].pct &&
// res.table1[0][2] === moreSpecialCharData.table1[0].speech &&
// res.table1[0][3] === moreSpecialCharData.table1[0].slash &&
// res.table1[0][4] === moreSpecialCharData.table1[0].slashWithSpecial &&
// res.table1[0][5] === moreSpecialCharData.table1[0].macvar &&
// res.table1[0][6] === moreSpecialCharData.table1[0].chinese &&
// res.table1[0][7] === moreSpecialCharData.table1[0].sigma &&
// res.table1[0][8] === moreSpecialCharData.table1[0].at &&
// res.table1[0][9] === moreSpecialCharData.table1[0].serbian &&
// res.table1[0][10] === moreSpecialCharData.table1[0].dollar
// );
// },
// },
// {
// title: "Wide table with sendArr",
// description: "Should handle data with 10000 columns",
// test: () => {
// return adapter.request("common/sendArr", getWideData());
// },
// assertion: (res: any) => {
// const data = getWideData();
// let result = true;
// for (let i = 0; i <= 10; i++) {
// result =
// result && res.table1[0][i] === data.table1[0]["col" + (i + 1)];
// }
// return result;
// },
// },
// {
// title: "Wide table with sendObj",
// description: "Should handle data with 10000 columns",
// test: () => {
// return adapter.request("common/sendObj", getWideData());
// },
// assertion: (res: any) => {
// const data = getWideData();
// let result = true;
// for (let i = 0; i <= 10; i++) {
// result =
// result &&
// res.table1[0]["COL" + (i + 1)] === data.table1[0]["col" + (i + 1)];
// }
// return result;
// },
// },
// {
// title: "Multiple tables",
// description: "Should handle data with 100 tables",
// test: () => {
// return adapter.request("common/sendArr", getTables());
// },
// assertion: (res: any) => {
// const data = getTables();
// return (
// res.table1[0][0] === data.table1[0].col1 &&
// res.table1[0][1] === data.table1[0].col2 &&
// res.table1[0][2] === data.table1[0].col3 &&
// res.table1[0][3] === data.table1[0].col4 &&
// res.table50[0][0] === data.table50[0].col1 &&
// res.table50[0][1] === data.table50[0].col2 &&
// res.table50[0][2] === data.table50[0].col3 &&
// res.table50[0][3] === data.table50[0].col4
// );
// },
// },
{
title: "Large dataset",
title: "Other special characters",
description: "Should handle other special characters",
test: () => {
return adapter.request("common/sendArr", moreSpecialCharData);
},
assertion: (res: any) => {
return (
res.table1[0][0] === moreSpecialCharData.table1[0].speech0 &&
res.table1[0][1] === moreSpecialCharData.table1[0].pct &&
res.table1[0][2] === moreSpecialCharData.table1[0].speech &&
res.table1[0][3] === moreSpecialCharData.table1[0].slash &&
res.table1[0][4] === moreSpecialCharData.table1[0].slashWithSpecial &&
res.table1[0][5] === moreSpecialCharData.table1[0].macvar &&
res.table1[0][6] === moreSpecialCharData.table1[0].chinese &&
res.table1[0][7] === moreSpecialCharData.table1[0].sigma &&
res.table1[0][8] === moreSpecialCharData.table1[0].at &&
res.table1[0][9] === moreSpecialCharData.table1[0].serbian &&
res.table1[0][10] === moreSpecialCharData.table1[0].dollar
);
},
},
{
title: "Wide table with sendArr",
description: "Should handle data with 10000 columns",
test: () => {
return adapter.request("common/sendArr", getWideData());
},
assertion: (res: any) => {
const data = getWideData();
let result = true;
for (let i = 0; i <= 10; i++) {
result =
result && res.table1[0][i] === data.table1[0]["col" + (i + 1)];
}
return result;
},
},
{
title: "Wide table with sendObj",
description: "Should handle data with 10000 columns",
test: () => {
return adapter.request("common/sendObj", getWideData());
},
assertion: (res: any) => {
const data = getWideData();
let result = true;
for (let i = 0; i <= 10; i++) {
result =
result &&
res.table1[0]["COL" + (i + 1)] === data.table1[0]["col" + (i + 1)];
}
return result;
},
},
{
title: "Multiple tables",
description: "Should handle data with 100 tables",
test: () => {
return adapter.request("common/sendArr", getTables());
},
assertion: (res: any) => {
const data = getTables();
return (
res.table1[0][0] === data.table1[0].col1 &&
res.table1[0][1] === data.table1[0].col2 &&
res.table1[0][2] === data.table1[0].col3 &&
res.table1[0][3] === data.table1[0].col4 &&
res.table50[0][0] === data.table50[0].col1 &&
res.table50[0][1] === data.table50[0].col2 &&
res.table50[0][2] === data.table50[0].col3 &&
res.table50[0][3] === data.table50[0].col4
);
},
},
{
title: "Large dataset with sendObj",
description: "Should handle 5mb of data",
test: () => {
return adapter.request("common/sendArr", getLargeDataset());
return adapter.request("common/sendObj", getLargeDataset());
},
assertion: (res: any) => {
const data = getLargeDataset();
@@ -192,44 +192,59 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
return result;
},
},
// {
// title: "Error and _csrf tables with sendArr",
// description: "Should handle error and _csrf tables",
// test: () => {
// return adapter.request("common/sendArr", errorAndCsrfData);
// },
// assertion: (res: any) => {
// return (
// res.error[0][0] === errorAndCsrfData.error[0].col1 &&
// res.error[0][1] === errorAndCsrfData.error[0].col2 &&
// res.error[0][2] === errorAndCsrfData.error[0].col3 &&
// res.error[0][3] === errorAndCsrfData.error[0].col4 &&
// res._csrf[0][0] === errorAndCsrfData._csrf[0].col1 &&
// res._csrf[0][1] === errorAndCsrfData._csrf[0].col2 &&
// res._csrf[0][2] === errorAndCsrfData._csrf[0].col3 &&
// res._csrf[0][3] === errorAndCsrfData._csrf[0].col4
// );
// },
// },
// {
// title: "Error and _csrf tables with sendObj",
// description: "Should handle error and _csrf tables",
// test: () => {
// return adapter.request("common/sendObj", errorAndCsrfData);
// },
// assertion: (res: any) => {
// return (
// res.error[0].COL1 === errorAndCsrfData.error[0].col1 &&
// res.error[0].COL2 === errorAndCsrfData.error[0].col2 &&
// res.error[0].COL3 === errorAndCsrfData.error[0].col3 &&
// res.error[0].COL4 === errorAndCsrfData.error[0].col4 &&
// res._csrf[0].COL1 === errorAndCsrfData._csrf[0].col1 &&
// res._csrf[0].COL2 === errorAndCsrfData._csrf[0].col2 &&
// res._csrf[0].COL3 === errorAndCsrfData._csrf[0].col3 &&
// res._csrf[0].COL4 === errorAndCsrfData._csrf[0].col4
// );
// },
// },
{
title: "Large dataset with sendArr",
description: "Should handle 5mb of data",
test: () => {
return adapter.request("common/sendArr", getLargeDataset());
},
assertion: (res: any) => {
const data = getLargeDataset();
let result = true;
for (let i = 0; i <= 10; i++) {
result =
result && res.table1[i][0] === Object.values(data.table1[i])[0];
}
return result;
},
},
{
title: "Error and _csrf tables with sendArr",
description: "Should handle error and _csrf tables",
test: () => {
return adapter.request("common/sendArr", errorAndCsrfData);
},
assertion: (res: any) => {
return (
res.error[0][0] === errorAndCsrfData.error[0].col1 &&
res.error[0][1] === errorAndCsrfData.error[0].col2 &&
res.error[0][2] === errorAndCsrfData.error[0].col3 &&
res.error[0][3] === errorAndCsrfData.error[0].col4 &&
res._csrf[0][0] === errorAndCsrfData._csrf[0].col1 &&
res._csrf[0][1] === errorAndCsrfData._csrf[0].col2 &&
res._csrf[0][2] === errorAndCsrfData._csrf[0].col3 &&
res._csrf[0][3] === errorAndCsrfData._csrf[0].col4
);
},
},
{
title: "Error and _csrf tables with sendObj",
description: "Should handle error and _csrf tables",
test: () => {
return adapter.request("common/sendObj", errorAndCsrfData);
},
assertion: (res: any) => {
return (
res.error[0].COL1 === errorAndCsrfData.error[0].col1 &&
res.error[0].COL2 === errorAndCsrfData.error[0].col2 &&
res.error[0].COL3 === errorAndCsrfData.error[0].col3 &&
res.error[0].COL4 === errorAndCsrfData.error[0].col4 &&
res._csrf[0].COL1 === errorAndCsrfData._csrf[0].col1 &&
res._csrf[0].COL2 === errorAndCsrfData._csrf[0].col2 &&
res._csrf[0].COL3 === errorAndCsrfData._csrf[0].col3 &&
res._csrf[0].COL4 === errorAndCsrfData._csrf[0].col4
);
},
},
],
});

View File

@@ -479,38 +479,37 @@ export default class SASjs {
formData.append(name, file, `${name}.csv`);
}
} else {
// param based approach
const sasjsTables = [];
let tableCounter = 0;
for (const tableName in data) {
if (isError) {
return;
}
tableCounter++;
sasjsTables.push(tableName);
const csv = convertToCSV(data[tableName]);
if (csv === "ERROR: LARGE STRING LENGTH") {
isError = true;
errorMsg =
"The max length of a string value in SASjs is 32765 characters.";
}
// if csv has length more then 16k, send in chunks
if (csv.length > 16000) {
const csvChunks = splitChunks(csv);
// append chunks to form data with same key
csvChunks.map((chunk) => {
formData.append(`sasjs${tableCounter}data`, chunk);
});
} else {
requestParams[`sasjs${tableCounter}data`] = csv;
}
}
requestParams["sasjs_tables"] = sasjsTables.join(" ");
}
// param based approach
const sasjsTables = [];
let tableCounter = 0;
for (const tableName in data) {
if (isError) {
return;
}
tableCounter++;
sasjsTables.push(tableName);
const csv = convertToCSV(data[tableName]);
if (csv === "ERROR: LARGE STRING LENGTH") {
isError = true;
errorMsg =
"The max length of a string value in SASjs is 32765 characters.";
}
// if csv has length more then 16k, send in chunks
if (csv.length > 16000) {
const csvChunks = splitChunks(csv);
// append chunks to form data with same key
csvChunks.map((chunk) => {
formData.append(`sasjs${tableCounter}data`, chunk);
});
} else {
requestParams[`sasjs${tableCounter}data`] = csv;
}
}
requestParams["sasjs_tables"] = sasjsTables.join(" ");
}
console.log("Request params", requestParams);
for (const key in requestParams) {
if (requestParams.hasOwnProperty(key)) {
formData.append(key, requestParams[key]);
@@ -526,9 +525,7 @@ export default class SASjs {
if (isError) {
reject({ MESSAGE: errorMsg });
}
const headers: any = {
"Content-Type": "application/x-www-form-urlencoded",
};
const headers: any = {};
if (this._csrfHeader && this._csrf) {
headers[this._csrfHeader] = this._csrf;
}
@@ -720,9 +717,9 @@ export default class SASjs {
private getRequestParams(): any {
const requestParams: any = {};
// if (this._csrf) {
// requestParams["_csrf"] = this._csrf;
// }
if (this._csrf) {
requestParams["_csrf"] = this._csrf;
}
if (this.sasjsConfig.debug) {
requestParams["_omittextlog"] = "false";

View File

@@ -24,7 +24,7 @@
"links": [
{
"label": "SASjs on Github",
"url": "https://github.com/macropeople/sasjs"
"url": "https://github.com/sasjs/adapter"
},
{
"label": "SASjs.io",
@@ -32,11 +32,11 @@
},
{
"label": "SASjs CLI",
"url": "https://github.com/macropeople/sasjs-cli"
"url": "https://github.com/sasjs/cli"
},
{
"label": "React Seed App",
"url": "https://github.com/macropeople/react-seed-app"
"url": "https://github.com/sasjs/react-seed-app"
}
]
}