@sassoftware/viya-serverjs 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +6 -6
- package/.dockerignore +2 -2
- package/.env +42 -28
- package/.env.server +32 -30
- package/.eslintignore +3 -3
- package/.eslintrc.json +42 -42
- package/Dockerfile +44 -44
- package/README.md +67 -99
- package/cli.js +9 -9
- package/lib/config.js +16 -16
- package/lib/handlers/appCallback.js +23 -24
- package/lib/handlers/codeAuth.js +17 -18
- package/lib/handlers/decodeJwt.js +3 -3
- package/lib/handlers/favicon.js +22 -25
- package/lib/handlers/getApp.js +20 -21
- package/lib/handlers/getApp2.js +22 -25
- package/lib/handlers/getUser.js +14 -17
- package/lib/handlers/index.js +3 -3
- package/lib/handlers/keepAlive.js +28 -31
- package/lib/handlers/keepAlive2.js +9 -12
- package/lib/handlers/logon.js +12 -15
- package/lib/handlers/logout.js +24 -28
- package/lib/handlers/proxyMapUri.js +6 -11
- package/lib/handlers/proxyOnResponse.js +6 -7
- package/lib/handlers/reactDev.js +22 -25
- package/lib/handlers/setCookies.js +51 -53
- package/lib/iService.js +105 -103
- package/lib/index.js +25 -30
- package/lib/parseDocker.js +3 -3
- package/lib/plugins/SASauth.js +34 -34
- package/lib/plugins/appCookie.js +35 -38
- package/lib/plugins/setContext.js +22 -25
- package/lib/plugins/setDefaultRoutes.js +71 -59
- package/lib/plugins/setupAuth.js +35 -38
- package/lib/plugins/setupUserRoutes.js +17 -16
- package/lib/plugins/token.js +9 -10
- package/lib/schemes/SASTokenScheme.js +24 -27
- package/mcpServer.js +364 -0
- package/package.json +85 -79
- package/public/data/Cluster_SDOH1.sas +181 -181
- package/public/data/Cluster_SDOH6.sas +179 -179
- package/public/data/NeuralNetwork_High_med.sas +2408 -2408
- package/public/data/NeuralNetwork_high_med1.sas +2408 -2408
- package/public/data/cars.csv +429 -429
- package/public/data/cmdList.txt +15 -15
- package/public/data/iris.csv +151 -151
- package/public/index.html +360 -350
- package/public/indexProxy.html +351 -351
- package/public/simplesubmit.html +233 -0
- package/server.js +363 -362
- package/src/config.js +90 -90
- package/src/handlers/appCallback.js +40 -40
- package/src/handlers/codeAuth.js +31 -31
- package/src/handlers/decodeJwt.js +10 -10
- package/src/handlers/favicon.js +23 -23
- package/src/handlers/getApp.js +52 -52
- package/src/handlers/getApp2.js +25 -25
- package/src/handlers/getUser.js +20 -20
- package/src/handlers/index.js +36 -36
- package/src/handlers/keepAlive.js +53 -53
- package/src/handlers/keepAlive2.js +12 -12
- package/src/handlers/logon.js +23 -23
- package/src/handlers/logout.js +42 -42
- package/src/handlers/proxyMapUri.js +25 -25
- package/src/handlers/proxyOnResponse.js +11 -11
- package/src/handlers/reactDev.js +29 -29
- package/src/handlers/setCookies.js +80 -79
- package/src/iService.js +360 -345
- package/src/index.js +247 -249
- package/src/parseDocker.js +32 -32
- package/src/plugins/SASauth.js +82 -78
- package/src/plugins/appCookie.js +50 -49
- package/src/plugins/setContext.js +33 -33
- package/src/plugins/setDefaultRoutes.js +261 -253
- package/src/plugins/setupAuth.js +49 -49
- package/src/plugins/setupUserRoutes.js +48 -47
- package/src/plugins/token.js +10 -10
- package/src/schemes/SASTokenScheme.js +43 -43
- package/src/visionIndex.html +23 -23
- package/start.sh +14 -14
- package/.env.proxy +0 -32
- package/tls/viyatls.sh +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
function
|
|
3
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
4
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
5
5
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
6
6
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
7
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -10,22 +10,22 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
10
10
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
11
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
12
12
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
13
|
-
/*
|
|
14
|
-
* ------------------------------------------------------------------------------------
|
|
15
|
-
* Copyright (c) SAS Institute Inc.
|
|
16
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
-
* you may not use this file except in compliance with the License.
|
|
18
|
-
* You may obtain a copy of the License at
|
|
19
|
-
*
|
|
20
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
-
*
|
|
22
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
23
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
24
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25
|
-
* See the License for the specific language governing permissions and
|
|
26
|
-
* limitations under the License.
|
|
27
|
-
* ---------------------------------------------------------------------------------------
|
|
28
|
-
*
|
|
13
|
+
/*
|
|
14
|
+
* ------------------------------------------------------------------------------------
|
|
15
|
+
* Copyright (c) SAS Institute Inc.
|
|
16
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License.
|
|
18
|
+
* You may obtain a copy of the License at
|
|
19
|
+
*
|
|
20
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
23
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
24
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25
|
+
* See the License for the specific language governing permissions and
|
|
26
|
+
* limitations under the License.
|
|
27
|
+
* ---------------------------------------------------------------------------------------
|
|
28
|
+
*
|
|
29
29
|
*/
|
|
30
30
|
// lean code to handle of incoming tokens if present
|
|
31
31
|
// designed to used with appCookie and SASauth
|
|
@@ -34,30 +34,27 @@ var Boom = require('@hapi/boom');
|
|
|
34
34
|
module.exports = function SASTokenScheme(server, options) {
|
|
35
35
|
var scheme = {
|
|
36
36
|
authenticate: function () {
|
|
37
|
-
var _authenticate = _asyncToGenerator(/*#__PURE__*/
|
|
37
|
+
var _authenticate = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(request, h) {
|
|
38
38
|
var authorization, _authorization$split, _authorization$split2, tokenType, token, credentials;
|
|
39
|
-
return
|
|
40
|
-
while (1) switch (_context.
|
|
39
|
+
return _regenerator().w(function (_context) {
|
|
40
|
+
while (1) switch (_context.n) {
|
|
41
41
|
case 0:
|
|
42
42
|
authorization = request.headers.authorization;
|
|
43
43
|
server.log('SASToken', authorization);
|
|
44
44
|
if (authorization) {
|
|
45
|
-
_context.
|
|
45
|
+
_context.n = 1;
|
|
46
46
|
break;
|
|
47
47
|
}
|
|
48
48
|
throw Boom.unauthorized(null, 'session');
|
|
49
|
-
case
|
|
49
|
+
case 1:
|
|
50
50
|
_authorization$split = authorization.split(' '), _authorization$split2 = _slicedToArray(_authorization$split, 2), tokenType = _authorization$split2[0], token = _authorization$split2[1];
|
|
51
51
|
credentials = {
|
|
52
52
|
token: token,
|
|
53
53
|
tokenType: tokenType
|
|
54
54
|
};
|
|
55
|
-
return _context.
|
|
55
|
+
return _context.a(2, h.authenticated({
|
|
56
56
|
credentials: credentials
|
|
57
57
|
}));
|
|
58
|
-
case 7:
|
|
59
|
-
case "end":
|
|
60
|
-
return _context.stop();
|
|
61
58
|
}
|
|
62
59
|
}, _callee);
|
|
63
60
|
}));
|
package/mcpServer.js
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
let core = require('./lib/index.js');
|
|
6
|
+
debugger;
|
|
7
|
+
core(getCustomHandler, true, 'app', null);
|
|
8
|
+
|
|
9
|
+
function getCustomHandler() {
|
|
10
|
+
let appName = `/${process.env.APPNAME}`; /* does not have to be this - your choice */
|
|
11
|
+
debugger;
|
|
12
|
+
let routes = [
|
|
13
|
+
{
|
|
14
|
+
method: ["GET"],
|
|
15
|
+
path: "/help",
|
|
16
|
+
options: {
|
|
17
|
+
files: {
|
|
18
|
+
relativeTo: "./public",
|
|
19
|
+
},
|
|
20
|
+
handler: async (req, h) => {
|
|
21
|
+
debugger;
|
|
22
|
+
let hf = 'help.html';
|
|
23
|
+
return h.file(hf);
|
|
24
|
+
},
|
|
25
|
+
auth: false,
|
|
26
|
+
description: "Help",
|
|
27
|
+
notes: "Help",
|
|
28
|
+
tags: ["app"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
method: ["GET"],
|
|
33
|
+
path: `${appName}/new`,
|
|
34
|
+
options: {
|
|
35
|
+
files: {
|
|
36
|
+
relativeTo: "./public",
|
|
37
|
+
},
|
|
38
|
+
handler: async (req, h) => {
|
|
39
|
+
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>in new');
|
|
40
|
+
return h.file('index.html');
|
|
41
|
+
},
|
|
42
|
+
// auth: 'logon',
|
|
43
|
+
description: "Create new application",
|
|
44
|
+
notes: "Index file created from env data",
|
|
45
|
+
tags: ["app"],
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
];
|
|
50
|
+
return routes;
|
|
51
|
+
}
|
|
52
|
+
function customize(key, options) {
|
|
53
|
+
let info = {
|
|
54
|
+
swaggerOptions: {
|
|
55
|
+
info: {
|
|
56
|
+
title: "Test API",
|
|
57
|
+
version: "0.0.1",
|
|
58
|
+
description: "This document was auto-generated at run time",
|
|
59
|
+
},
|
|
60
|
+
documentationPage: true,
|
|
61
|
+
documentationPath: `/${process.env.APPNAME}/documentation`,
|
|
62
|
+
swaggerUI: true,
|
|
63
|
+
swaggerUIPath: `/${process.env.APPNAME}/swaggerui`,
|
|
64
|
+
schemes: ["https", "http"],
|
|
65
|
+
cors: true,
|
|
66
|
+
auth: options.authDefault,
|
|
67
|
+
},
|
|
68
|
+
APPENV: {
|
|
69
|
+
x: 1,
|
|
70
|
+
y: 2,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
let r = info[key];
|
|
74
|
+
return r == null ? {} : r;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getIndex() {
|
|
78
|
+
|
|
79
|
+
let template = `
|
|
80
|
+
<html lang="en">
|
|
81
|
+
<head>
|
|
82
|
+
<meta charset="UTF-8" />
|
|
83
|
+
|
|
84
|
+
<script
|
|
85
|
+
crossorigin
|
|
86
|
+
src="https://unpkg.com/react@16/umd/react.production.min.js"
|
|
87
|
+
></script>
|
|
88
|
+
<script
|
|
89
|
+
crossorigin
|
|
90
|
+
src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"
|
|
91
|
+
></script>
|
|
92
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
|
|
93
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js"></script>
|
|
94
|
+
<script src="https://unpkg.com/@sassoftware/restaf@5.2.4/dist/restaf.js"></script>
|
|
95
|
+
<script src="https://unpkg.com/@sassoftware/restaflib@5.2.4/dist/restaflib.js"></script>
|
|
96
|
+
|
|
97
|
+
<style>
|
|
98
|
+
.container {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
flex-wrap: nowrap;
|
|
102
|
+
min-height: 800px;
|
|
103
|
+
}
|
|
104
|
+
.elabel {
|
|
105
|
+
display: inline-block;
|
|
106
|
+
|
|
107
|
+
clear: left;
|
|
108
|
+
width: 250px;
|
|
109
|
+
text-align: right;
|
|
110
|
+
}
|
|
111
|
+
.einput {
|
|
112
|
+
display: inline-block;
|
|
113
|
+
}
|
|
114
|
+
.div1 {
|
|
115
|
+
border: 1px solid black;
|
|
116
|
+
background: lightskyblue;
|
|
117
|
+
}
|
|
118
|
+
.div2 {
|
|
119
|
+
border: 1px solid black;
|
|
120
|
+
background: lightskyblue;
|
|
121
|
+
height: 200px;
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
124
|
+
|
|
125
|
+
<script>
|
|
126
|
+
let LOGONPAYLOAD = {
|
|
127
|
+
host: "${process.env.VIYA_SERVER}",
|
|
128
|
+
authType: "server",
|
|
129
|
+
appName: "${process.env.APPNAME}",
|
|
130
|
+
};
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<script>
|
|
134
|
+
debugger;
|
|
135
|
+
let store = restaf.initStore({
|
|
136
|
+
casProxy: true});
|
|
137
|
+
debugger; console.log(store.config);
|
|
138
|
+
|
|
139
|
+
let session = null;
|
|
140
|
+
let servers = null;
|
|
141
|
+
let services = null;
|
|
142
|
+
let files = null;
|
|
143
|
+
let reports = null;
|
|
144
|
+
let compute = null;
|
|
145
|
+
|
|
146
|
+
function setup() {
|
|
147
|
+
debugger;
|
|
148
|
+
document.getElementById('output').innerHTML = '...initializing';
|
|
149
|
+
|
|
150
|
+
initSession()
|
|
151
|
+
.then(r => {
|
|
152
|
+
document.getElementById('output').innerHTML = 'ready';
|
|
153
|
+
keepAlive();
|
|
154
|
+
})
|
|
155
|
+
.catch(e => {
|
|
156
|
+
|
|
157
|
+
console.log(e);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
async function initSession() {
|
|
163
|
+
|
|
164
|
+
console.log(LOGONPAYLOAD);
|
|
165
|
+
debugger;
|
|
166
|
+
let msg = await store.logon(LOGONPAYLOAD);
|
|
167
|
+
console.log(msg);
|
|
168
|
+
|
|
169
|
+
// let { identities } = await store.addServices('identities');
|
|
170
|
+
let name = 'user';
|
|
171
|
+
// if (identities.links('currentUser') != null) {
|
|
172
|
+
// let c = await store.apiCall(identities.links('currentUser'));
|
|
173
|
+
// name = c.items('id');
|
|
174
|
+
// }
|
|
175
|
+
console.log(name);
|
|
176
|
+
debugger;
|
|
177
|
+
/*
|
|
178
|
+
services = await store.addServices(
|
|
179
|
+
'files', 'compute', 'casManagement'
|
|
180
|
+
);
|
|
181
|
+
console.log(services.casManagement.links().toJS())
|
|
182
|
+
*/
|
|
183
|
+
debugger;
|
|
184
|
+
return 'done';
|
|
185
|
+
}
|
|
186
|
+
function runit(type) {
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
document.getElementById('output').innerHTML = '...running';
|
|
190
|
+
let testcase;
|
|
191
|
+
switch (type) {
|
|
192
|
+
case 'files': {
|
|
193
|
+
testcase = SASfileService;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case 'compute': {
|
|
197
|
+
testcase = dsCompute;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case 'cas': {
|
|
201
|
+
testcase = runCas;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
case 'spre': {
|
|
206
|
+
testcase= spre;
|
|
207
|
+
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
default: {
|
|
211
|
+
testcase = SASfileService;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
testcase(store)
|
|
217
|
+
.then(r => {
|
|
218
|
+
document.getElementById(
|
|
219
|
+
'output'
|
|
220
|
+
).innerHTML = JSON.stringify(r, null, 4);
|
|
221
|
+
})
|
|
222
|
+
.catch(err => {
|
|
223
|
+
|
|
224
|
+
document.getElementById(
|
|
225
|
+
'output'
|
|
226
|
+
).innerHTML = JSON.stringify(err, null, 4);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async function noaction() {
|
|
230
|
+
r = {msg: 'redirects completed'};
|
|
231
|
+
return r;
|
|
232
|
+
}
|
|
233
|
+
async function spre(store) {
|
|
234
|
+
let p = {
|
|
235
|
+
method: 'GET',
|
|
236
|
+
url : 'http://localhost:3000/api/test',
|
|
237
|
+
withCredentials: true
|
|
238
|
+
}
|
|
239
|
+
let r = await store.request(p);
|
|
240
|
+
return r.data;
|
|
241
|
+
}
|
|
242
|
+
async function runCas(store) {
|
|
243
|
+
|
|
244
|
+
let {casManagement} = await store.addServices('casManagement');
|
|
245
|
+
let servers = await store.apiCall(
|
|
246
|
+
casManagement.links('servers')
|
|
247
|
+
);
|
|
248
|
+
let serverName = servers.itemsList(0);
|
|
249
|
+
let session = await store.apiCall(
|
|
250
|
+
servers.itemsCmd(serverName, 'createSession')
|
|
251
|
+
);
|
|
252
|
+
let payload = {
|
|
253
|
+
action: 'builtins.echo',
|
|
254
|
+
data: { code: { x: 1 } }
|
|
255
|
+
};
|
|
256
|
+
console.log(JSON.stringify(session.links("execute"), null, 4));
|
|
257
|
+
let r = await store.runAction(session, payload);
|
|
258
|
+
console.log('echo completed');
|
|
259
|
+
await store.apiCall(session.links('delete'));
|
|
260
|
+
return r.items();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function SASfileService(store) {
|
|
264
|
+
debugger;
|
|
265
|
+
let content;
|
|
266
|
+
try {
|
|
267
|
+
debugger;
|
|
268
|
+
let {files} = await store.addServices('files');
|
|
269
|
+
debugger;
|
|
270
|
+
console.log(JSON.stringify(files.links(), null, 4));
|
|
271
|
+
//console.log('items - should be an array of files(empty array is ok)')
|
|
272
|
+
// console.log(files.items().toJS());
|
|
273
|
+
let payload = {
|
|
274
|
+
data: { x: 1, y: 'This was saved earlier in the step' },
|
|
275
|
+
headers: { 'content-type': 'application/json' }
|
|
276
|
+
};
|
|
277
|
+
let createCmd = files.links('create');
|
|
278
|
+
let newFile = await store.apiCall(createCmd, payload);
|
|
279
|
+
debugger;
|
|
280
|
+
console.log(JSON.stringify(newFile.links('content'), null, 4));
|
|
281
|
+
content = await store.apiCall(newFile.links('content'));
|
|
282
|
+
|
|
283
|
+
} catch(err) {
|
|
284
|
+
console.log(JSON.stringify(err, null, 4));
|
|
285
|
+
debugger;
|
|
286
|
+
}
|
|
287
|
+
console.log(content);
|
|
288
|
+
return content.items();
|
|
289
|
+
}
|
|
290
|
+
async function dsCompute(store) {
|
|
291
|
+
let log = null;
|
|
292
|
+
debugger;
|
|
293
|
+
let {compute} = await store.addServices('compute');
|
|
294
|
+
let servers = await store.apiCall(compute.links('servers'));
|
|
295
|
+
|
|
296
|
+
let contexts = await store.apiCall(compute.links('contexts'));
|
|
297
|
+
|
|
298
|
+
// lookup the name of the first context and then use it to get the associated createSession restafLink
|
|
299
|
+
let createSession = contexts.itemsCmd(
|
|
300
|
+
contexts.itemsList(0),
|
|
301
|
+
'createSession'
|
|
302
|
+
);
|
|
303
|
+
let session = await store.apiCall(createSession);
|
|
304
|
+
|
|
305
|
+
// Now run a simple data step in that session
|
|
306
|
+
let payload = {
|
|
307
|
+
data: {
|
|
308
|
+
code: ["data _null_; do i = 1 to 100; x=1; end; run; "]
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// Now execute the data step and wait for completion
|
|
313
|
+
let job = await store.apiCall(
|
|
314
|
+
session.links('execute'),
|
|
315
|
+
payload
|
|
316
|
+
);
|
|
317
|
+
let status = await store.jobState(job, null, 5, 2);
|
|
318
|
+
|
|
319
|
+
if (status.data === 'running') {
|
|
320
|
+
throw "ERROR: Job did not complete in allotted time";
|
|
321
|
+
} else {
|
|
322
|
+
switch (status.data) {
|
|
323
|
+
case 'warning':
|
|
324
|
+
console.log("Warning: check your log for warnings");
|
|
325
|
+
break;
|
|
326
|
+
case 'error':
|
|
327
|
+
throw "Please correct errors and rerun program";
|
|
328
|
+
default:
|
|
329
|
+
log = await store.apiCall(status.job.links('log'));
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return log === null ? status : log.items();
|
|
334
|
+
}
|
|
335
|
+
</script>
|
|
336
|
+
</head>
|
|
337
|
+
<body onload="setup()">
|
|
338
|
+
<h1 id="head">Hi</h1>
|
|
339
|
+
<div>
|
|
340
|
+
|
|
341
|
+
<button onclick="runit('files')">
|
|
342
|
+
Press to make a call to file service
|
|
343
|
+
</button>
|
|
344
|
+
<br />
|
|
345
|
+
<br />
|
|
346
|
+
<button onclick="runit('compute')">
|
|
347
|
+
Press to make a call compute service
|
|
348
|
+
</button>
|
|
349
|
+
<br />
|
|
350
|
+
<br />
|
|
351
|
+
<button onclick="runit('cas')">
|
|
352
|
+
Press to make a call to cas echo
|
|
353
|
+
</button>
|
|
354
|
+
<br />
|
|
355
|
+
<br />
|
|
356
|
+
|
|
357
|
+
<div>
|
|
358
|
+
<pre id="output"></pre>
|
|
359
|
+
</div>
|
|
360
|
+
</body>
|
|
361
|
+
</html>
|
|
362
|
+
`;
|
|
363
|
+
return template;
|
|
364
|
+
}
|
package/package.json
CHANGED
|
@@ -1,79 +1,85 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sassoftware/viya-serverjs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Easy to use app server for SAS Viya applications",
|
|
5
|
-
"author": "Deva Kumaraswamy <deva.kumar@sas.com>",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
|
-
"bin": {
|
|
9
|
-
"@sassoftware/viya-
|
|
10
|
-
},
|
|
11
|
-
"keywords": [
|
|
12
|
-
"restaf",
|
|
13
|
-
"Viya",
|
|
14
|
-
"SAS",
|
|
15
|
-
"server",
|
|
16
|
-
"RESTAPI"
|
|
17
|
-
],
|
|
18
|
-
"engines": {
|
|
19
|
-
"node": ">=20.4.0"
|
|
20
|
-
},
|
|
21
|
-
"homepage": "https://github.com/sassoftware/viya-server#readme",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "https://github.com/sassoftware/viya-server.git"
|
|
25
|
-
},
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/sassoftware/viya-server/issues"
|
|
28
|
-
},
|
|
29
|
-
"unpkg": "./lib/index.js",
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "rimraf lib && babel src --out-dir lib",
|
|
32
|
-
"test": "
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"@hapi/
|
|
42
|
-
"@hapi/
|
|
43
|
-
"@hapi/
|
|
44
|
-
"@hapi/
|
|
45
|
-
"@hapi/
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"@babel/
|
|
69
|
-
"@babel/
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@sassoftware/viya-serverjs",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Easy to use app server for SAS Viya applications",
|
|
5
|
+
"author": "Deva Kumaraswamy <deva.kumar@sas.com>",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./lib/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"@sassoftware/viya-serverjs": "cli.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"restaf",
|
|
13
|
+
"Viya",
|
|
14
|
+
"SAS",
|
|
15
|
+
"server",
|
|
16
|
+
"RESTAPI"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20.4.0"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/sassoftware/viya-server#readme",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/sassoftware/viya-server.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/sassoftware/viya-server/issues"
|
|
28
|
+
},
|
|
29
|
+
"unpkg": "./lib/index.js",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "rimraf lib && babel src --out-dir lib",
|
|
32
|
+
"test": "node cli --env=./.env --docker=./Dockerfile",
|
|
33
|
+
"submit": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 APPENTRY=simplesubmit.html node cli --env=./.env --docker=./Dockerfile",
|
|
34
|
+
"server": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node server.js --env=./.env.server --docker=./Dockerfile",
|
|
35
|
+
"debug": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node --inspect-brk server.js --env=./.env.server --docker=./Dockerfile",
|
|
36
|
+
"proxy": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node cli --env=./.env.proxy --docker=./Dockerfile",
|
|
37
|
+
"pub": "npm publish --tag dev --access public",
|
|
38
|
+
"lint": "npx eslint --fix src/*.js"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@hapi/bell": "^13.1.0",
|
|
42
|
+
"@hapi/boom": "^10.0.1",
|
|
43
|
+
"@hapi/cookie": "^12.0.1",
|
|
44
|
+
"@hapi/h2o2": "^10.0.4",
|
|
45
|
+
"@hapi/hapi": "^21.4.4",
|
|
46
|
+
"@hapi/inert": "^7.1.0",
|
|
47
|
+
"@hapi/vision": "^7.0.3",
|
|
48
|
+
"axios": "^1.13.2",
|
|
49
|
+
"core-js": "^3.47.0",
|
|
50
|
+
"cross-spawn": "^7.0.6",
|
|
51
|
+
"debug": "^4.4.3",
|
|
52
|
+
"docker-file-parser": "^1.0.7",
|
|
53
|
+
"eslint-config-prettier": "^10.1.8",
|
|
54
|
+
"handlebars": "^4.7.8",
|
|
55
|
+
"hapi-require-https": "^6.0.0",
|
|
56
|
+
"joi": "^18.0.2",
|
|
57
|
+
"jwt-decode": "^4.0.0",
|
|
58
|
+
"node-cache-promise": "^1.0.2",
|
|
59
|
+
"only": "0.0.2",
|
|
60
|
+
"qs": "^6.14.0",
|
|
61
|
+
"regenerator-runtime": "^0.14.1",
|
|
62
|
+
"request-debug": "^0.2.0",
|
|
63
|
+
"selfsigned": "^5.4.0",
|
|
64
|
+
"uuid": "^13.0.0",
|
|
65
|
+
"yargs": "18.0.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@babel/cli": "^7.28.3",
|
|
69
|
+
"@babel/core": "^7.28.5",
|
|
70
|
+
"@babel/eslint-parser": "7.28.5",
|
|
71
|
+
"@babel/preset-env": "^7.28.5",
|
|
72
|
+
"cross-env": "^10.1.0",
|
|
73
|
+
"eslint": "^9.39.2",
|
|
74
|
+
"prettier": "^3.7.4",
|
|
75
|
+
"rimraf": "^6.1.2",
|
|
76
|
+
"shx": "^0.4.0"
|
|
77
|
+
},
|
|
78
|
+
"resolutions": {
|
|
79
|
+
"@babel/traverse": "7.26.10"
|
|
80
|
+
},
|
|
81
|
+
"overrides": {
|
|
82
|
+
"gopd": "1.2.0",
|
|
83
|
+
"get-intrinsic": "1.2.7"
|
|
84
|
+
}
|
|
85
|
+
}
|