mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-22 13:31:19 +00:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ac7f8892e | ||
|
|
68f5e5bec5 | ||
|
|
69a14ff6d7 | ||
|
|
70e461224a | ||
|
|
4da22ee6b4 | ||
|
|
2c8ba09578 | ||
|
|
c12d6f1c9c | ||
|
|
e5fb7a7698 | ||
|
|
c22b9066d8 | ||
|
|
77d7e03de5 | ||
|
|
b614bafd03 | ||
|
|
34cabcde2d | ||
|
|
de82058850 | ||
|
|
327be9e141 | ||
|
|
f1502c0773 | ||
|
|
c8a2df2d1f | ||
|
|
2be6200b90 | ||
|
|
333289cd20 | ||
|
|
204139cd01 | ||
|
|
2a38b68e69 | ||
|
|
39cc20b680 | ||
|
|
8b3c9746fc | ||
|
|
7a76f5f343 | ||
|
|
2bbcd7dee7 | ||
|
|
b02ce07ddf | ||
|
|
41400bea86 | ||
|
|
991ac100f6 | ||
|
|
66c156d299 | ||
|
|
7d0d830391 | ||
|
|
0b038380c7 | ||
|
|
162ba5e837 | ||
|
|
f217b3eb04 |
@@ -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`.
|
||||
|
||||
19
README.md
19
README.md
@@ -1,14 +1,14 @@
|
||||
[](https://www.jsdelivr.com/package/npm/sasjs)
|
||||
[](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
1
docs/_config.yml
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-minimal
|
||||
File diff suppressed because one or more lines are too long
287
docs/classes/reflection-445.reflection-1.sas9apiclient.html
Normal file
287
docs/classes/reflection-445.reflection-1.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
919
docs/classes/reflection-445.reflection-1.sasjs.html
Normal file
919
docs/classes/reflection-445.reflection-1.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
782
docs/classes/reflection-445.reflection-1.sasviyaapiclient.html
Normal file
782
docs/classes/reflection-445.reflection-1.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
280
docs/classes/types.sasjsconfig.html
Normal file
280
docs/classes/types.sasjsconfig.html
Normal file
File diff suppressed because one or more lines are too long
183
docs/enums/types.servertype.html
Normal file
183
docs/enums/types.servertype.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
341
docs/index.html
341
docs/index.html
File diff suppressed because one or more lines are too long
215
docs/interfaces/types.context.html
Normal file
215
docs/interfaces/types.context.html
Normal file
File diff suppressed because one or more lines are too long
187
docs/interfaces/types.csrftoken.html
Normal file
187
docs/interfaces/types.csrftoken.html
Normal file
File diff suppressed because one or more lines are too long
201
docs/interfaces/types.folder.html
Normal file
201
docs/interfaces/types.folder.html
Normal file
File diff suppressed because one or more lines are too long
243
docs/interfaces/types.job.html
Normal file
243
docs/interfaces/types.job.html
Normal file
File diff suppressed because one or more lines are too long
173
docs/interfaces/types.jobresult.html
Normal file
173
docs/interfaces/types.jobresult.html
Normal file
File diff suppressed because one or more lines are too long
229
docs/interfaces/types.link.html
Normal file
229
docs/interfaces/types.link.html
Normal file
File diff suppressed because one or more lines are too long
247
docs/interfaces/types.sasjsrequest.html
Normal file
247
docs/interfaces/types.sasjsrequest.html
Normal file
File diff suppressed because one or more lines are too long
233
docs/interfaces/types.sasjswaitingrequest.html
Normal file
233
docs/interfaces/types.sasjswaitingrequest.html
Normal file
File diff suppressed because one or more lines are too long
173
docs/interfaces/types.session.html
Normal file
173
docs/interfaces/types.session.html
Normal file
File diff suppressed because one or more lines are too long
107
docs/modules/reflection-445.html
Normal file
107
docs/modules/reflection-445.html
Normal file
File diff suppressed because one or more lines are too long
121
docs/modules/reflection-445.reflection-1.html
Normal file
121
docs/modules/reflection-445.reflection-1.html
Normal file
File diff suppressed because one or more lines are too long
160
docs/modules/types.html
Normal file
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
549
docs/modules/utils.html
Normal file
File diff suppressed because one or more lines are too long
@@ -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
2329
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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",
|
||||
|
||||
65
sasjs-tests/package-lock.json
generated
65
sasjs-tests/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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([]);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SASjs, { ServerType, SASjsConfig } from "sasjs";
|
||||
import SASjs, { ServerType, SASjsConfig } from "@sasjs/adapter";
|
||||
import { TestSuite } from "../types";
|
||||
|
||||
const defaultConfig: SASjsConfig = {
|
||||
|
||||
@@ -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" }] };
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
67
src/SASjs.ts
67
src/SASjs.ts
@@ -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";
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user