@sassoftware/restaflib 4.10.3 → 4.10.4
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/dist/restaflib.js +1 -1
- package/dist/restaflib.min.js +1 -1
- package/lib/restaflib.js +1 -1
- package/package.json +1 -1
package/dist/restaflib.js
CHANGED
|
@@ -1255,7 +1255,7 @@ eval("/*\r\n* Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights
|
|
|
1255
1255
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1256
1256
|
|
|
1257
1257
|
"use strict";
|
|
1258
|
-
eval("/*\r\n* Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\r\n* SPDX-License-Identifier: Apache-2.0\r\n*/\n\nfunction commonCasl() {\n var casl = \"\\n \\n /*------------------------------------------------*/\\n /*Does the tables exist and if not try to load it */\\n /*\\n Typical usage:\\n rc = checkAndLoadTable(caslib, name);\\n if ( rc ne true) then do;\\n ...handle errors...\\n end; \\n else do;\\n ...your stuff...\\n end;\\n rc = true - the data is ready for use\\n rc = false - the table could not be found\\n rc = -1 - the caslib does not exist\\n */\\n /*------------------------------------------------*/\\n\\n\\n\\n function checkAndLoadTable(caslib, name); \\n\\n /* verify caslib is there */\\n table.queryCaslib status=status result=result/\\n caslib = caslib;\\n do k,v over result; /* to handle casuser[user] */ \\n rc = v;\\n end;\\n if ( rc eq false ) then \\n return -1;\\n /* \\n * Check to see if table is already loaded \\n */ \\n action table.tableExists r=result/ \\n caslib = caslib \\n name = name; \\n /* \\n * if not loaded then try to load it \\n */ \\n rc = true;\\n if (result.exists eq 0) then do; \\n path = lookupPath(caslib, name);\\n if (path eq '*') then do;\\n rc = false;\\n end;\\n else do;\\n\\t action table.loadTable status=status/ \\n\\t caslib = caslib \\n\\t source = path \\n\\t casout={caslib= caslib name=name}; \\n\\t if (status.statusCode ne 0 ) then rc = false;\\n end; \\n end; \\n return rc; \\n end; \\n\\n function saveAndLoadTable(caslib, source, targetlib, targetname);\\n\\n /* load source */\\n r = checkAndLoadTable(caslib, source);\\n\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= targetlib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n \\n table.droptable /\\n caslib=targetlib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\\n path=sashdat;\\n \\n return r;\\n\\n end;\\n function saveAndPromoteTable(caslib, target, source);\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= caslib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n\\n table.droptable /\\n caslib=caslib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=caslib casout={caslib=caslib name=target promote=TRUE}\\n path=sashdat;\\n\\n return r;\\n end;\\n/*\\n * return path to table\\n */\\n\\nfunction lookupPath(caslib, name ) ; \\n table.fileInfo r = result/ \\n caslib=caslib; \\n\\n names = result.fileInfo[,4]; \\n nameu = upcase(name)||'.SASHDAT'; \\n cpath = '*'; \\n count = 0; \\n\\n do n over names; \\n\\t if (upcase(n) eq nameu) then do; \\n\\t count = count + 1; \\n\\t if ( cpath eq '*') then do; \\n\\t cpath = n; \\n\\t end; \\n\\t end; \\n end; \\n \\n if (count GT 1 ) then do; \\n print 'Warning: ' count 'Files with names only different in case exist - First one chosen';\\n print 'Path: ' cpath ' will be used****'; \\n end; \\n r = cpath; \\n return r; \\nend; \\n\\n /*-----------------------------------------*/ \\n /* isModel: is it model table */ \\n /*-----------------------------------------*/ \\n \\n function isModel(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n validTable = false; \\n mtype = 'bad'; \\n do c over result.columninfo; \\n cu = upCase(c.Column); \\n if ( cu eq 'DATASTEPSRC') then do; \\n mtype = 'ds'; \\n end; \\n else if ( cu eq '_STATE_' ) then do; \\n mtype = 'astore'; \\n end; \\n else if (cu eq 'MODELMETADATA') then do; \\n mtype = 'ds2'; \\n end; \\n end; \\n print 'Specified model type: ' || mtype; \\n return mtype; \\n end; \\n \\n /*-----------------------------------------*/ \\n /* Returns contents of the specified table */ \\n /*-----------------------------------------*/ \\n \\n function contents(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n /* columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}}; */ \\n i = 1; \\n columns = {}; \\n do c over result.columninfo; \\n columns[i] = c; \\n i = i + 1; \\n end; \\n return {describe = columns, table = {}}; \\n end; \\n \\n /*------------------------------------------*/ \\n /* Returns unique values */ \\n /*-----------------------------------------*/ \\n \\n function selectionLists(idvars,caslib, name, where); \\n \\n s = checkAndLoadTable(caslib, name); \\n if ( s ne true) then do; \\n results = {Errors= 'Unable to access ' ||caslib||'.'||name, statusCode = s}; \\n \\n end; \\n print idvars;\\n do k over idvars; \\n r = _getValues(k, caslib, name, where); \\n results[k] = r; \\n end; \\n return { data=results, statusCode=0}; \\n end; \\n \\n function _getValues(id, caslib, name, where) ; \\n \\n action table.dropTable/ \\n caslib='casuser' name='dtemp1' quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib='casuser' source= 'dtemp1.sashdat' quiet=TRUE; \\n \\n action simple.groupby result=r status=rc/ \\n aggregator = 'N' \\n inputs = {id} \\n table = {caslib=caslib name=name, where=where} \\n casout = {caslib='casuser' name='dtemp1'} \\n ; \\n action table.fetch result=r/ \\n table={caslib='casuser' name='dtemp1'} \\n sortby={{name=id, order='ascending'}}; \\n result = r.Fetch[,2]; \\n return result; \\n end; \\n \\n /*------------------------------------------*/ \\n /* get a record */ \\n /*------------------------------------------*/ \\n \\n function _fetchData(filter, table); \\n s = checkAndLoadTable(table.caslib, table.name); \\n if ( s ne 0 ) then do; \\n results = {Errors= 'Unable to access ' ||table.caslib||'.'||table.name}; \\n return results; \\n end; \\n wherex = dictTowhere(filter); \\n /* wherex = table.caslib||'.'||table.name||'(where=('||wherex||'));'; \\n \\n destroyTable('casuser', 'input'); \\n \\n action datastep.runCode r=result status=rc/ \\n single='yes' \\n code = 'data casuser.input; set ' || wherex||'run;'; \\n */ \\n \\n action table.fetch r = result / \\n table={caslib=table.caslib name=table.name where=wherex}; \\n \\n rows = resultsToDict(result.Fetch); \\n return {scenario = rows, table = result.Fetch}; \\n \\n end; \\n\\n function destroyTable(caslib,name); \\n action table.dropTable/ \\n caslib=caslib name=name quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib=caslib source= name||'.sashdat' quiet=TRUE; \\n \\n return true; \\n end; \\n \\n \\n function dictToWhere(filter); \\n where =''; \\n andbit=' '; \\n do k,v over filter; \\n if (isString(v) ) then do; \\n where = where || andbit || k || ' eq ' || '\\\"'||v||'\\\"'; \\n end; \\n else do; \\n where = where || andbit || k || ' eq ' || v ; \\n end; \\n andbit =' and '; \\n end; \\n return where; \\n end; \\n \\n function resultsToDict(r); \\n casResults = {}; \\n i = 1; \\n do row over r; \\n casResults[i] = row; \\n i = i + 1; \\n end; \\n return casResults; \\n end; \\n \\n function argsToTable(_arg_, caslib, name ); \\n action table.droptable/ \\n caslib=caslib name=name quiet=TRUE; \\n i = 1; \\n do key,obj over _arg_; \\n columns[i] = key; \\n row[i] = obj; \\n if ( isString(obj) ) then \\n type[i] = 'varchar'; \\n else if ( isInteger(obj) ) then \\n type[i] = 'int'; \\n else type[i] = 'double'; \\n i = i + 1; \\n end; \\n \\n data1 = newTable('data1', columns, type, row ); \\n \\n saveresult data1 casout=name caslib=caslib replace; \\n end; \\n\\n \";\n return casl;\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (commonCasl);\n\n//# sourceURL=webpack://restaflib/./programs/commonCasl.js?");
|
|
1258
|
+
eval("/*\r\n* Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\r\n* SPDX-License-Identifier: Apache-2.0\r\n*/\n\nfunction commonCasl() {\n var casl = \"\\n \\n /*------------------------------------------------*/\\n /*Does the tables exist and if not try to load it */\\n /*\\n Typical usage:\\n rc = checkAndLoadTable(caslib, name);\\n if ( rc ne true) then do;\\n ...handle errors...\\n end; \\n else do;\\n ...your stuff...\\n end;\\n rc = true - the data is ready for use\\n rc = false - the table could not be found\\n rc = -1 - the caslib does not exist\\n */\\n /*------------------------------------------------*/\\n\\n\\n\\n function checkAndLoadTable(caslib, name); \\n\\n /* verify caslib is there */\\n table.queryCaslib status=status result=result/\\n caslib = caslib;\\n do k,v over result; /* to handle casuser[user] */ \\n rc = v;\\n end;\\n if ( rc eq false ) then \\n return -1;\\n /* \\n * Check to see if table is already loaded \\n */ \\n action table.tableExists r=result/ \\n caslib = caslib \\n name = name; \\n /* \\n * if not loaded then try to load it \\n */ \\n rc = true;\\n if (result.exists eq 0 or result.exists eq 2) then do; \\n path = lookupPath(caslib, name);\\n if (path eq '*') then do;\\n rc = false;\\n end;\\n else do;\\n\\t action table.loadTable status=status/ \\n\\t caslib = caslib \\n\\t source = path \\n\\t casout={caslib= caslib name=name}; \\n\\t if (status.statusCode ne 0 ) then rc = false;\\n end; \\n end; \\n return rc; \\n end; \\n\\n function saveAndLoadTable(caslib, source, targetlib, targetname);\\n\\n /* load source */\\n r = checkAndLoadTable(caslib, source);\\n\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= targetlib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n \\n table.droptable /\\n caslib=targetlib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\\n path=sashdat;\\n \\n return r;\\n\\n end;\\n function saveAndPromoteTable(caslib, target, source);\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= caslib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n\\n table.droptable /\\n caslib=caslib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=caslib casout={caslib=caslib name=target promote=TRUE}\\n path=sashdat;\\n\\n return r;\\n end;\\n/*\\n * return path to table\\n */\\n\\nfunction lookupPath(caslib, name ) ; \\n table.fileInfo r = result/ \\n caslib=caslib; \\n\\n names = result.fileInfo[,4]; \\n nameu = upcase(name)||'.SASHDAT'; \\n cpath = '*'; \\n count = 0; \\n\\n do n over names; \\n\\t if (upcase(n) eq nameu) then do; \\n\\t count = count + 1; \\n\\t if ( cpath eq '*') then do; \\n\\t cpath = n; \\n\\t end; \\n\\t end; \\n end; \\n \\n if (count GT 1 ) then do; \\n print 'Warning: ' count 'Files with names only different in case exist - First one chosen';\\n print 'Path: ' cpath ' will be used****'; \\n end; \\n r = cpath; \\n return r; \\nend; \\n\\n /*-----------------------------------------*/ \\n /* isModel: is it model table */ \\n /*-----------------------------------------*/ \\n \\n function isModel(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n validTable = false; \\n mtype = 'bad'; \\n do c over result.columninfo; \\n cu = upCase(c.Column); \\n if ( cu eq 'DATASTEPSRC') then do; \\n mtype = 'ds'; \\n end; \\n else if ( cu eq '_STATE_' ) then do; \\n mtype = 'astore'; \\n end; \\n else if (cu eq 'MODELMETADATA') then do; \\n mtype = 'ds2'; \\n end; \\n end; \\n print 'Specified model type: ' || mtype; \\n return mtype; \\n end; \\n \\n /*-----------------------------------------*/ \\n /* Returns contents of the specified table */ \\n /*-----------------------------------------*/ \\n \\n function contents(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n /* columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}}; */ \\n i = 1; \\n columns = {}; \\n do c over result.columninfo; \\n columns[i] = c; \\n i = i + 1; \\n end; \\n return {describe = columns, table = {}}; \\n end; \\n \\n /*------------------------------------------*/ \\n /* Returns unique values */ \\n /*-----------------------------------------*/ \\n \\n function selectionLists(idvars,caslib, name, where); \\n \\n s = checkAndLoadTable(caslib, name); \\n if ( s ne true) then do; \\n results = {Errors= 'Unable to access ' ||caslib||'.'||name, statusCode = s}; \\n \\n end; \\n print idvars;\\n do k over idvars; \\n r = _getValues(k, caslib, name, where); \\n results[k] = r; \\n end; \\n return { data=results, statusCode=0}; \\n end; \\n \\n function _getValues(id, caslib, name, where) ; \\n \\n action table.dropTable/ \\n caslib='casuser' name='dtemp1' quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib='casuser' source= 'dtemp1.sashdat' quiet=TRUE; \\n \\n action simple.groupby result=r status=rc/ \\n aggregator = 'N' \\n inputs = {id} \\n table = {caslib=caslib name=name, where=where} \\n casout = {caslib='casuser' name='dtemp1'} \\n ; \\n action table.fetch result=r/ \\n table={caslib='casuser' name='dtemp1'} \\n sortby={{name=id, order='ascending'}}; \\n result = r.Fetch[,2]; \\n return result; \\n end; \\n \\n /*------------------------------------------*/ \\n /* get a record */ \\n /*------------------------------------------*/ \\n \\n function _fetchData(filter, table); \\n s = checkAndLoadTable(table.caslib, table.name); \\n if ( s ne 0 ) then do; \\n results = {Errors= 'Unable to access ' ||table.caslib||'.'||table.name}; \\n return results; \\n end; \\n wherex = dictTowhere(filter); \\n /* wherex = table.caslib||'.'||table.name||'(where=('||wherex||'));'; \\n \\n destroyTable('casuser', 'input'); \\n \\n action datastep.runCode r=result status=rc/ \\n single='yes' \\n code = 'data casuser.input; set ' || wherex||'run;'; \\n */ \\n \\n action table.fetch r = result / \\n table={caslib=table.caslib name=table.name where=wherex}; \\n \\n rows = resultsToDict(result.Fetch); \\n return {scenario = rows, table = result.Fetch}; \\n \\n end; \\n\\n function destroyTable(caslib,name); \\n action table.dropTable/ \\n caslib=caslib name=name quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib=caslib source= name||'.sashdat' quiet=TRUE; \\n \\n return true; \\n end; \\n \\n \\n function dictToWhere(filter); \\n where =''; \\n andbit=' '; \\n do k,v over filter; \\n if (isString(v) ) then do; \\n where = where || andbit || k || ' eq ' || '\\\"'||v||'\\\"'; \\n end; \\n else do; \\n where = where || andbit || k || ' eq ' || v ; \\n end; \\n andbit =' and '; \\n end; \\n return where; \\n end; \\n \\n function resultsToDict(r); \\n casResults = {}; \\n i = 1; \\n do row over r; \\n casResults[i] = row; \\n i = i + 1; \\n end; \\n return casResults; \\n end; \\n \\n function argsToTable(_arg_, caslib, name ); \\n action table.droptable/ \\n caslib=caslib name=name quiet=TRUE; \\n i = 1; \\n do key,obj over _arg_; \\n columns[i] = key; \\n row[i] = obj; \\n if ( isString(obj) ) then \\n type[i] = 'varchar'; \\n else if ( isInteger(obj) ) then \\n type[i] = 'int'; \\n else type[i] = 'double'; \\n i = i + 1; \\n end; \\n \\n data1 = newTable('data1', columns, type, row ); \\n \\n saveresult data1 casout=name caslib=caslib replace; \\n end; \\n\\n \";\n return casl;\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (commonCasl);\n\n//# sourceURL=webpack://restaflib/./programs/commonCasl.js?");
|
|
1259
1259
|
|
|
1260
1260
|
/***/ }),
|
|
1261
1261
|
|
package/dist/restaflib.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("restaflib",[],e):"object"==typeof exports?exports.restaflib=e():t.restaflib=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=15)}([function(t,e,n){var r=n(16)();t.exports=r;try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(t,e){function n(t,e,n,r,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,o)}t.exports=function(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function s(t){n(a,o,i,s,u,"next",t)}function u(t){n(a,o,i,s,u,"throw",t)}s(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){function n(e){return t.exports=n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){"use strict";var r=n(13),o=n.n(r);var i=function(){return"\n print _args_;\n\n results = casFetchRows(_args_.table.caslib, _args_.table.name , _args_.start + 1, _args_.limit, _args_.format, _args_.where); \n send_response({casResults = results}); \n \n function casFetchRows(caslib, name, from, count, format, where) ; \n \n rc = checkAndLoadTable(caslib, name);\n \n if (rc ne true) then do;\n text = 'Unable to access ' ||caslib||'.'||name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n exit(rx); \n end; \n\n /*\n * get tableoinfo to get rowCount\n */\n\n action table.tableinfo r= result/ \n caslib = caslib \n name = name; \n \n rowCount = result.TableInfo[1, 'rows'];\n to = from + count - 1;\n\n \n /*\n * get column information\n */\n\n action table.columninfo r=infoResult /\n table = {caslib=caslib name=name};\n\n columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}};\n i = 2;\n do c over inforesult.columninfo;\n columns[i] = c;\n i = i + 1;\n end;\n \n /*\n * Fetch the current set of rows\n */\n\n rows = {};\n if (from <= rowCount) then do;\n action table.fetch r = result status=rcx/ \n table = {caslib=caslib, name=name where=where} \n from= from to=to format=format sastypes=true\n ;\n if (rcx.severity eq 2) then do;\n exit(rcx);\n end;\n /* \n * create payload to return\n */\n\n i = 1;\n rows ={};\n do row over result.fetch;\n rr = {};\n j = 1;\n do key,v over row;\n rr[j] = override(columns[j].Type, v);\n j = j + 1;\n end;\n rows[i] = rr;\n i = i + 1;\n end;\n end;\n\n currentCount = DIM(rows);\n pagination = {}; \n table = {caslib=caslib, name=name};\n\n pagination = setPagination(from, count, format, where, currentCount, rowCount, table);\n \n lastRequest={start=from-1, limit=count, format=format, currentCount=currentCount, \n rowCount=rowCount, where=where, table=table, version='3'};\n scrollOptions = getKeys(pagination);\n return( \n {pagination = pagination, data = {schema=columns, rows=rows , scrollOptions=scrollOptions}, lasRequest=lastRequest}\n );\n end; \n \n \n /*\n * For non-primary column types set new content\n */\n\n function setPagination(from, count, format, where, currentCount, rowCount, table);\n\n\n prevStart = max(from - count - 1, 0);\n\n if (currentCount lt count) then do; \n pagination.prev = {start=prevStart, limit=count, format=format, where=' ', table=table};\n if (prevStart ne 0) then do;\n pagination.first = {start=0, limit=count, format=format, where=' ', table=table};\n end; \n return pagination;\n end;\n currentStart = from -1;\n if (currentStart eq 0) then do;\n pagination.next = {start=count, limit=count, format=format, where=' ', table=table};\n return pagination;\n end;\n\n nextStart = currentStart + count;\n pagination.next = {start=nextStart, limit=count, format=format, where=' ', table=table};\n pagination.prev = {start=prevStart, limit=count, format=format, where=' ', table=table};\n if (prevStart ne 0) then do;\n pagination.first = {start=0, limit=count, format=format, where=' ', table=table};\n end; \n return pagination;\n end;\n\n\n\n\n function override(type, iv);\n if (type EQ 'varbinary') then v = '...varbinary';\n else if (type EQ 'blob') then v = '...blob';\n else if (type EQ 'table') then v = '...table';\n else if (type EQ 'dictionary') then v = '...dictionary';\n else if (type EQ 'list') then v = '...list';\n else if (type EQ 'isArray') then v = '...array';\n else v = iv;\n return v;\n end;\n\n \n "};var a=function(){return"\n \n /*------------------------------------------------*/\n /*Does the tables exist and if not try to load it */\n /*\n Typical usage:\n rc = checkAndLoadTable(caslib, name);\n if ( rc ne true) then do;\n ...handle errors...\n end; \n else do;\n ...your stuff...\n end;\n rc = true - the data is ready for use\n rc = false - the table could not be found\n rc = -1 - the caslib does not exist\n */\n /*------------------------------------------------*/\n\n\n\n function checkAndLoadTable(caslib, name); \n\n /* verify caslib is there */\n table.queryCaslib status=status result=result/\n caslib = caslib;\n do k,v over result; /* to handle casuser[user] */ \n rc = v;\n end;\n if ( rc eq false ) then \n return -1;\n /* \n * Check to see if table is already loaded \n */ \n action table.tableExists r=result/ \n caslib = caslib \n name = name; \n /* \n * if not loaded then try to load it \n */ \n rc = true;\n if (result.exists eq 0) then do; \n path = lookupPath(caslib, name);\n if (path eq '*') then do;\n rc = false;\n end;\n else do;\n\t action table.loadTable status=status/ \n\t caslib = caslib \n\t source = path \n\t casout={caslib= caslib name=name}; \n\t if (status.statusCode ne 0 ) then rc = false;\n end; \n end; \n return rc; \n end; \n\n function saveAndLoadTable(caslib, source, targetlib, targetname);\n\n /* load source */\n r = checkAndLoadTable(caslib, source);\n\n sashdat = target||\".sashdat\";\n table.save /\n caslib= targetlib name=sashdat\n table = {caslib=caslib name=source} replace=true;\n \n table.droptable /\n caslib=targetlib name=target quiet=true;\n \n table.loadtable result=r/\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\n path=sashdat;\n \n return r;\n\n end;\n function saveAndPromoteTable(caslib, target, source);\n sashdat = target||\".sashdat\";\n table.save /\n caslib= caslib name=sashdat\n table = {caslib=caslib name=source} replace=true;\n\n table.droptable /\n caslib=caslib name=target quiet=true;\n \n table.loadtable result=r/\n caslib=caslib casout={caslib=caslib name=target promote=TRUE}\n path=sashdat;\n\n return r;\n end;\n/*\n * return path to table\n */\n\nfunction lookupPath(caslib, name ) ; \n table.fileInfo r = result/ \n caslib=caslib; \n\n names = result.fileInfo[,4]; \n nameu = upcase(name)||'.SASHDAT'; \n cpath = '*'; \n count = 0; \n\n do n over names; \n\t if (upcase(n) eq nameu) then do; \n\t count = count + 1; \n\t if ( cpath eq '*') then do; \n\t cpath = n; \n\t end; \n\t end; \n end; \n \n if (count GT 1 ) then do; \n print 'Warning: ' count 'Files with names only different in case exist - First one chosen';\n print 'Path: ' cpath ' will be used****'; \n end; \n r = cpath; \n return r; \nend; \n\n /*-----------------------------------------*/ \n /* isModel: is it model table */ \n /*-----------------------------------------*/ \n \n function isModel(caslib, name) ; \n table.columnInfo r = result / \n table = {caslib=caslib , name=name}; \n validTable = false; \n mtype = 'bad'; \n do c over result.columninfo; \n cu = upCase(c.Column); \n if ( cu eq 'DATASTEPSRC') then do; \n mtype = 'ds'; \n end; \n else if ( cu eq '_STATE_' ) then do; \n mtype = 'astore'; \n end; \n else if (cu eq 'MODELMETADATA') then do; \n mtype = 'ds2'; \n end; \n end; \n print 'Specified model type: ' || mtype; \n return mtype; \n end; \n \n /*-----------------------------------------*/ \n /* Returns contents of the specified table */ \n /*-----------------------------------------*/ \n \n function contents(caslib, name) ; \n table.columnInfo r = result / \n table = {caslib=caslib , name=name}; \n /* columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}}; */ \n i = 1; \n columns = {}; \n do c over result.columninfo; \n columns[i] = c; \n i = i + 1; \n end; \n return {describe = columns, table = {}}; \n end; \n \n /*------------------------------------------*/ \n /* Returns unique values */ \n /*-----------------------------------------*/ \n \n function selectionLists(idvars,caslib, name, where); \n \n s = checkAndLoadTable(caslib, name); \n if ( s ne true) then do; \n results = {Errors= 'Unable to access ' ||caslib||'.'||name, statusCode = s}; \n \n end; \n print idvars;\n do k over idvars; \n r = _getValues(k, caslib, name, where); \n results[k] = r; \n end; \n return { data=results, statusCode=0}; \n end; \n \n function _getValues(id, caslib, name, where) ; \n \n action table.dropTable/ \n caslib='casuser' name='dtemp1' quiet=TRUE; \n \n action table.deleteSource status=src / \n caslib='casuser' source= 'dtemp1.sashdat' quiet=TRUE; \n \n action simple.groupby result=r status=rc/ \n aggregator = 'N' \n inputs = {id} \n table = {caslib=caslib name=name, where=where} \n casout = {caslib='casuser' name='dtemp1'} \n ; \n action table.fetch result=r/ \n table={caslib='casuser' name='dtemp1'} \n sortby={{name=id, order='ascending'}}; \n result = r.Fetch[,2]; \n return result; \n end; \n \n /*------------------------------------------*/ \n /* get a record */ \n /*------------------------------------------*/ \n \n function _fetchData(filter, table); \n s = checkAndLoadTable(table.caslib, table.name); \n if ( s ne 0 ) then do; \n results = {Errors= 'Unable to access ' ||table.caslib||'.'||table.name}; \n return results; \n end; \n wherex = dictTowhere(filter); \n /* wherex = table.caslib||'.'||table.name||'(where=('||wherex||'));'; \n \n destroyTable('casuser', 'input'); \n \n action datastep.runCode r=result status=rc/ \n single='yes' \n code = 'data casuser.input; set ' || wherex||'run;'; \n */ \n \n action table.fetch r = result / \n table={caslib=table.caslib name=table.name where=wherex}; \n \n rows = resultsToDict(result.Fetch); \n return {scenario = rows, table = result.Fetch}; \n \n end; \n\n function destroyTable(caslib,name); \n action table.dropTable/ \n caslib=caslib name=name quiet=TRUE; \n \n action table.deleteSource status=src / \n caslib=caslib source= name||'.sashdat' quiet=TRUE; \n \n return true; \n end; \n \n \n function dictToWhere(filter); \n where =''; \n andbit=' '; \n do k,v over filter; \n if (isString(v) ) then do; \n where = where || andbit || k || ' eq ' || '\"'||v||'\"'; \n end; \n else do; \n where = where || andbit || k || ' eq ' || v ; \n end; \n andbit =' and '; \n end; \n return where; \n end; \n \n function resultsToDict(r); \n casResults = {}; \n i = 1; \n do row over r; \n casResults[i] = row; \n i = i + 1; \n end; \n return casResults; \n end; \n \n function argsToTable(_arg_, caslib, name ); \n action table.droptable/ \n caslib=caslib name=name quiet=TRUE; \n i = 1; \n do key,obj over _arg_; \n columns[i] = key; \n row[i] = obj; \n if ( isString(obj) ) then \n type[i] = 'varchar'; \n else if ( isInteger(obj) ) then \n type[i] = 'int'; \n else type[i] = 'double'; \n i = i + 1; \n end; \n \n data1 = newTable('data1', columns, type, row ); \n \n saveresult data1 casout=name caslib=caslib replace; \n end; \n\n "};var s=function(){return"\n results = casFetchRows(_args_.table.caslib, _args_.table.name , _args_.from, _args_.count, _args_.format, _args_.where); \n send_response({casResults = results}); \n \n function casFetchRows(caslib, name, from, count, format, where) ; \n \n rc = checkAndLoadTable(caslib, name);\n \n if (rc ne true) then do;\n text = 'Unable to access ' ||caslib||'.'||name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n exit(rx); \n end; \n\n /*\n * get all table to get rowCount\n */\n\n action table.tableinfo r= result/ \n caslib = caslib \n name = name; \n \n rowCount = result.TableInfo[1, 'rows']; \n \n to = from + count - 1; \n \n /*\n * get column information\n */\n\n action table.columninfo r=infoResult /\n table = {caslib=caslib name=name};\n\n columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}};\n i = 2;\n do c over inforesult.columninfo;\n columns[i] = c;\n i = i + 1;\n end;\n \n /*\n * Fetch the current set of rows\n */\n /* wherex = dictTowhere(where); let user send in the where clause */\n print where;\n\n action table.fetch r = result / \n table = {caslib=caslib, name=name where=where} \n from= from to=to format=format sastypes=true\n ;\n\n /* \n * create payload to return\n */\n\n i = 1;\n rows ={};\n do row over result.fetch;\n rr = {};\n j = 1;\n do key,v over row;\n rr[j] = override(columns[j].Type, v);\n j = j + 1;\n end;\n rows[i] = rr;\n i = i + 1;\n end;\n\n pagePrev = max(from - count, 1);\n \n if ( to eq rowCount ) then do; \n pageNext = -1; \n end; \n else do ; \n pageNext = min(to + 1, rowCount); \n end; \n table = {caslib=caslib, name=name};\n pagination = {next= {from=pageNext, count=count, format=format, where=where table=table}, prev={from=pagePrev, count=count, format=format, where=where, table=table}};\n pagination.current = {from = from, to=to, rowCount=rowCount, version=1};\n return( \n {pagination = pagination, data = {schema=columns, rows=rows }}\n );\n end; \n \n \n /*\n * For non-primary column types set new content\n */\n\n function override(type, iv);\n if (type EQ 'varbinary') then v = '...varbinary';\n else if (type EQ 'blob') then v = '...blob';\n else if (type EQ 'table') then v = '...table';\n else if (type EQ 'dictionary') then v = '...dictionary';\n else if (type EQ 'list') then v = '...list';\n else if (type EQ 'isArray') then v = '...array';\n else v = iv;\n return v;\n end;\n\n \n "};var u=function(){return"\n rc = checkAndLoadTable(_args_.masterTable.caslib, _args_.masterTable.name);\n\n if (rc ne true) then do;\n text = 'Unable to access ' ||_args_.masterTable.caslib||'.'||_args_.masterTable.name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n exit(rx); \n end; \n \n rc = checkAndLoadTable(_args_.setTable.caslib, _args_.setTable.name);\n if (rc ne true) then do;\n text = 'Unable to access ' ||_args_.setTable.caslib||'.'||_args_.setTable.name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n return rx;\n end;\n\n\n setdata = _args_.setTable.caslib ||'.'||_args_.setTable.name;\n masterdata = _args_.masterTable.caslib ||'.'||_args_.masterTable.name;\n\n action datastep.runCode r=result status=rc/\n code='data ' ||masterdata||'(append=YES);set ' || setdata ||'; run;';\n\n if (rc.statusCode ne 0) then do;\n exit(rc);\n end; \n else do;\n results = {msg= 'Append succeeded', statusCode=true};\n end;\n \n send_response({casResults = results});\n "};e.a={commonCasl:a,casFetchData:i,casFetchRows:s,scoreCasl:o.a,casAppendTable:u,casRowSets:i}},function(t,e,n){"use strict";var r=n(1),o=n.n(r),i=n(0),a=n.n(i),s=n(7);function u(){return(u=o()(a.a.mark((function t(e,n,r,o){var i,u,c,f,l,p,h,d=arguments;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i=Object(s.a)(null!==o?o:{},"_args_"),u=(u=i+" "+r).replace(/\r?\n|\r/g,""),c={action:"sccasl.runcasl",data:{code:u}},f=d.length,l=new Array(f>4?f-4:0),p=4;p<f;p++)l[p-4]=d[p];return t.next=7,e.runAction.apply(e,[n,c].concat(l));case 7:return h=t.sent,t.abrupt("return",h);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}e.a=function(t,e,n,r){return u.apply(this,arguments)}},function(t,e,n){"use strict";var r=n(1),o=n.n(r),i=n(0),a=n.n(i),s=n(4),u=n(3);function c(){return(c=o()(a.a.mark((function t(e,n,r,o,i){var c,f,l,p,h,d=arguments;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(c=r,!0===i&&(c=r+" "+u.a.commonCasl()),f=d.length,l=new Array(f>5?f-5:0),p=5;p<f;p++)l[p-5]=d[p];return t.next=5,s.a.apply(void 0,[e,n,c,o].concat(l));case 5:return h=t.sent,t.abrupt("return",h.items().toJS());case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}e.a=function(t,e,n,r,o){return c.apply(this,arguments)}},function(t,e,n){var r=n(17);t.exports=function(t,e,n){return(e=r(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){"use strict";var r=n(2),o=n.n(r);function i(t){var e="{ ",n=" ";for(var r in t){if(!0===Array.isArray(t[r])){var s=a(t[r]);e=e+n+"".concat(r,"=")+s}else{var u=o()(t[r]);if("object"===u){var c=i(t[r]);e=e+n+"".concat(r,"=")+c}else e=e+n+"".concat(r,"=")+("string"===u?' "'.concat(t[r],'" '):"".concat(t[r]," "))}n=","}return e+="} "}function a(t){for(var e="{",n=" ",r=t.length,s=0;s<r;s++)if(!0===Array.isArray(t[s])){var u=a(t[s]);e=e+n+"".concat(s,"=")+u}else{var c=o()(t[s]);if("object"===c)e=e+n+i(t[s]);else e=e+n+("string"===c?' "'.concat(t[s],'" '):"".concat(t[s]," "));n=","}return e+="}"}e.a=function(t,e){var n;return n=null===t?"{}":!0===Array.isArray(t)?a(t):i(t),"".concat(e," = ").concat(n,";")}},function(t,e,n){"use strict";n.d(e,"b",(function(){return u})),n.d(e,"c",(function(){return h})),n.d(e,"a",(function(){return y}));var r=n(1),o=n.n(r),i=n(0),a=n.n(i);function s(){return(s=o()(a.a.mark((function t(e,n,r,o){var i,s,u,c,f;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=o.output,s=i.caslib,null!=(u=i.name)){t.next=3;break}throw"Please specify table as caslib.name";case 3:return u=u.toLowerCase(u),c="\n action table.droptable /\n caslib= '".concat(s,"' name= '").concat(u,"' quiet=true;\n\n action table.deleteSource/\n caslib= '").concat(s,"' source= '").concat(u,".sashdat' quiet=true; \n "),f={action:"sccasl.runcasl",data:{code:c}},t.next=8,e.runAction(n,f);case 8:return f={action:"astore.upload",data:{rstore:{name:"".concat(u),caslib:"".concat(s),replace:!0},store:r}},t.next=11,e.runAction(n,f);case 11:return t.sent,t.abrupt("return","Upload of ".concat(o.source," to ").concat(s,".").concat(u," completed"));case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var u=function(t,e,n,r){return s.apply(this,arguments)},c=n(5);function f(){return(f=o()(a.a.mark((function t(e,n,r,o,i){var s,u,f,p,h,d,y;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=o.output,u=s.caslib,null!=(f=s.name)){t.next=3;break}throw"Please specify table as caslib.name";case 3:return t.next=5,l(e,n,u,f);case 5:return p={casout:{caslib:u,name:f},importOptions:{fileType:o.fileType}},"sas"!==o.fileExt&&"ds2"!==o.fileExt||(p.importOptions.delimiter="\\"),h={headers:{"JSON-Parameters":p,"Content-Type":"binary/octet-stream"},data:r,action:"table.upload"},t.next=10,e.runAction(n,h);case 10:if(t.sent,!0!==i){t.next=16;break}return d="\n\t\t\taction table.save r = result / \n\t\t\ttable = {caslib='".concat(u,"' name='").concat(f,"'} replace=true\n\t\t\tcaslib='").concat(u,"' name='").concat(f,"';\n\n\t\t\tsend_response(result);\n\t\t\t"),t.next=15,Object(c.a)(e,n,d,null,!0);case 15:t.sent;case 16:return y=null==o.source?"inline source":o.source,t.abrupt("return","Upload of ".concat(y," to ").concat((o.output,u),".").concat(o.output.name," completed"));case 18:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function l(t,e,n,r){return p.apply(this,arguments)}function p(){return(p=o()(a.a.mark((function t(e,n,r,o){var i,s;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i="".concat(r,".").concat(o),s="\n\t\taction table.dropTable/ \n caslib='".concat(r,"' name='").concat(o,"' quiet=TRUE; \n \n action table.deleteSource status=src / \n caslib='casuser' source= '").concat(i,"' quiet=TRUE; \n\t\tsend_response({csResults = {results= 'data deleted'}})\n\t\t"),t.next=4,Object(c.a)(e,n,s);case 4:t.sent;case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var h=function(t,e,n,r,o){return f.apply(this,arguments)};function d(){return(d=o()(a.a.mark((function t(e,n,r,o){var i;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={action:"table.save",data:{name:"".concat(o),caslib:"".concat(r),replace:!0,table:{name:"".concat(o),caslib:"".concat(r)}}},t.next=3,e.runAction(n,i);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var y=function(t,e,n,r){return d.apply(this,arguments)}},function(t,e,n){"use strict";var r=n(12),o=n(43),i=/[^\w\s\n\r\v\t\.,]/i;e.version=n(44).version;var a=function(t,e){return void 0!==t||e.renderUndefined},s=function(t,e,n){return"boolean"==typeof t||"number"==typeof t||"function"==typeof t||null==t||t instanceof Date||("string"==typeof t&&-1===t.indexOf("\n")||!(!n.inlineArrays||e||!Array.isArray(t)||!s(t[0],!0,n)))},u=function(t,e){if(e.noColor)return t;if("string"==typeof t)return e.stringColor?r[e.stringColor](t):t;var n=t+"";return!0===t?r.green(n):!1===t?r.red(n):null==t?r.grey(n):"number"==typeof t?t>=0?r[e.positiveNumberColor](n):r[e.negativeNumberColor](n):"function"==typeof t?"function() {}":Array.isArray(t)?t.join(", "):n},c=function(t,e){return null===t.multilineStringColor||t.noColor?e:r[t.multilineStringColor](e)},f=function(t,e,n){var r=t.split("\n");return(r=r.map((function(t){return o.indent(e)+c(n,t)}))).join("\n")},l=function(t,e,n){if("string"==typeof t&&t.match(i)&&e.escape&&(t=JSON.stringify(t)),!a(t,e))return[];if(s(t,!1,e))return[o.indent(n)+u(t,e)];if("string"==typeof t)return[o.indent(n)+c(e,'"""'),f(t,n+e.defaultIndentation,e),o.indent(n)+c(e,'"""')];if(Array.isArray(t)){if(0===t.length)return[o.indent(n)+e.emptyArrayMsg];var p=[];return t.forEach((function(t){if(a(t,e)){var i="- ";e.noColor||(i=r[e.dashColor](i)),i=o.indent(n)+i,s(t,!1,e)?(i+=l(t,e,0)[0],p.push(i)):(p.push(i),p.push.apply(p,l(t,e,n+e.defaultIndentation)))}})),p}if(t instanceof Error)return l({message:t.message,stack:t.stack.split("\n")},e,n);var h,d=e.noAlign?0:o.getMaxIndexLength(t),y=[];return Object.getOwnPropertyNames(t).forEach((function(i){if(a(t[i],e))if(h=i+": ",e.noColor||(h=r[e.keysColor](h)),h=o.indent(n)+h,s(t[i],!1,e)){var u=e.noAlign?0:d-i.length;h+=l(t[i],e,u)[0],y.push(h)}else y.push(h),y.push.apply(y,l(t[i],e,n+e.defaultIndentation))})),y};e.render=function(t,e,n){return n=n||0,(e=e||{}).emptyArrayMsg=e.emptyArrayMsg||"(empty array)",e.keysColor=e.keysColor||"green",e.dashColor=e.dashColor||"green",e.numberColor=e.numberColor||"blue",e.positiveNumberColor=e.positiveNumberColor||e.numberColor,e.negativeNumberColor=e.negativeNumberColor||e.numberColor,e.defaultIndentation=e.defaultIndentation||2,e.noColor=!!e.noColor,e.noAlign=!!e.noAlign,e.escape=!!e.escape,e.renderUndefined=!!e.renderUndefined,e.stringColor=e.stringColor||null,e.multilineStringColor=e.multilineStringColor||null,l(t,e,n).join("\n")},e.renderString=function(t,n,o){var i,a,s="";if("string"!=typeof t||""===t)return"";"{"!==t[0]&&"["!==t[0]&&(a=-1===t.indexOf("{")?t.indexOf("["):-1===t.indexOf("[")||t.indexOf("{")<t.indexOf("[")?t.indexOf("{"):t.indexOf("["),s+=t.substr(0,a)+"\n",t=t.substr(a));try{i=JSON.parse(t)}catch(t){return r.red("Error:")+" Not valid JSON!"}return s+=e.render(i,n,o)}},function(t,e,n){var r=n(19),o=n(20),i=n(21),a=n(23);t.exports=function(t,e){return r(t)||o(t,e)||i(t,e)||a()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var u,c=[],f=!1,l=-1;function p(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&h())}function h(){if(!f){var t=s(p);f=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new d(t,e)),1!==c.length||f||s(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,n){var r=n(29);t.exports=r},function(t,e){t.exports=function(){return"\n result = runMain(_args_); \n send_response(result); \n /* print result; */\n \n \n function runMain(_args_) ; \n r = {Error= 'No path'}; \n if ( _args_.path eq '/selectors') then do; \n r = selectionLists(_args_.selectors, _args_.table.caslib, _args_.table.name); \n end; \n else if ( _args_.path eq '/contents') then do; \n r = contents(_args_.table.caslib, _args_.table.name); \n end; \n else if (_args_.path eq '/describe') then do; \n r = describeModel(_args_); \n end; \n else if (_args_.path eq '/scenario' ) then do;\n r = fetchData(_args_.filter, _args_.table);\n end;\n else if (_args_.path eq '/score') then do; \n if( exists(_args_, 'modelName') eq false ) then\n modelname = '';\n else modelName =_args_.modelName;\n r = runScoreCode(_args_.model, _args_.scenario, modelName); \n end; \n else do; \n r = {icasResults={Errors = 'Invalid action option specified' || _args_.path}, statusCode=404}; \n end; \n print r;\n if ( r.statusCode ne 0) then do;\n print r.icasResults;\n exit({severity=2,reason=6, status=r.iCasResults.Errors,statusCode=r.statusCode});\n end;\n result = {casResults = r.icasResults}; \n print '***************************************************************'; \n print result; \n print '***************************************************************'; \n return result; \n end; \n \n /*-----------------------------------------*/ \n /* describeModel */ \n /*-----------------------------------------*/ \n \n function describeModel(_args_) ; \n s = checkAndLoadTable(_args_.model.caslib, _args_.model.name); \n if ( s ne true) then do; \n results = {Errors= 'Unable to access ' ||_args_.model.caslib||'.'||_args_.model.name}; \n return {icasResults=results, statusCode=404}; \n end; \n \n mtype = isModel(_args_.model.caslib, _args_.model.name); \n if ( mtype EQ 'astore' ) then do; \n r = astoreDescribe(_args_.model); \n end; \n else if (mtype EQ 'ds' or mtype EQ 'ds2') then do;\n s = checkAndLoadTable(_args_.table.caslib, _args_.table.name); \n if ( s ne true ) then do; \n results = {Errors= 'Unable to access ' ||_args_.table.caslib||'.'||_args_.table.name}; \n return {icasResults=results, statusCode=404}; \n end; \n r = contents( _args_.table.caslib, _args_.table.name); \n end; \n return {icasResults= r, statusCode=0} ;\n end; \n \n /*------------------------------------------*/ \n /* astoreDescribe */ \n /*------------------------------------------*/ \n \n function astoreDescribe(model); \n action astore.describe r=result/ \n rstore = { caslib= model.caslib name = model.name }; \n rows = resultsToDict(result.InputVariables); \n return {describe = rows, table = result.InputVariables}; \n end; \n \n /*------------------------------------------*/ \n /* score */ \n /*------------------------------------------*/ \n function runScoreCode( model, scenario, modelName); \n print model; \n s = checkAndLoadTable(model.caslib, model.name); \n if ( s ne true ) then do; \n results = {Errors= 'Unable to access ' ||model.caslib||'.'||model.name}; \n return {icasResults=results, statusCode=404}; \n end;\n \n mtype = isModel(model.caslib, model.name); \n \n if ( mtype eq 'bad' ) then do; \n results = {Error= model.caslib||'.'||model.name || ' is not recognized as a valid supported model. Please check your values'};\n return {icasResults=results, statusCode=400};\n end; \n destroyTable('casuser', 'input'); \n argsToTable(scenario, 'casuser', 'input'); \n \n destroyTable('casuser', 'output'); \n \n if (mtype eq 'astore') then do; \n print 'Scoring with astore'; \n action astore.score r = result/ \n rstore = {caslib=model.caslib name=model.name} \n out = {caslib='casuser' name='output'} \n table = {caslib='casuser' name='input'}; \n end; \n else if (mtype eq 'ds') then do; \n print 'scoring with datastep code'; \n action datastep.runcodetable r = result/ \n single='YES' \n codeTable= {caslib=model.caslib name=model.name} \n casout = {caslib='casuser' name='output'} \n table = {caslib='casuser' name='input'}; \n end; \n else if (mtype eq 'ds2' ) then do; \n print 'Scoring with d2'; \n if ( missing(modelName) eq true) then do;\n results = {Error= 'modelName is missing. Please check your values'};\n return {icasResults=results, statusCode=400};\n end;\n\n action ds2.runModel r = result/ \n modelTable = {caslib=model.caslib, name=model.name} \n modelName = modelName \n table = {caslib= 'casuser', name='input'} \n casOut = {caslib= 'casuser' name='output'}; \n end; \n \n \n action table.fetch r = result / \n table={caslib='casuser' name='output'}; \n \n rows = resultsToDict(result.Fetch); \n \n return {icasResults= rows, statusCode=0} ;\n end; \n \n \n "}},function(t,e,n){"use strict";(function(t){var r=n(10),o=n.n(r),i=n(8);e.a=function(e,n){var r,a,s=null,u=i.c,c=function(t){return t};switch(a=null==e?"csv":e.split(".").pop().toLowerCase()){case"sas7bdat":r="basesas";break;case"sashdat":r="hdat";break;case"csv":r=a,s="UTF8";break;case"xslx":case"xsl":r=a;break;case"astore":case"sasast":r=a,u=i.b,c=function(e){return new t.from(e).toString("base64")};break;case"ds2":case"sas":r="csv",s="UTF8",u=i.c,c=function(t,e){var n=t.replace(/[^\x00-\x7F]/g,"").replace(/\r?\n/g,""),r=e.fileExt;return"modelName\\"+("sas"===r?"dataStepSrc":"ds2"===r?"ds2Src":"casl"===r?"caslSrc":"dataStepsrc")+"\n"+e.output.name+"\\ "+n+"\n"};break;default:throw"Currently file type of ".concat(a," is not supported")}var f=n.split("."),l=o()(f,2);return{source:e,output:{caslib:l[0],name:l[1].toLowerCase()},fileType:r,fileExt:a,fileOptions:s,transform:c,contentType:"binary/octet-stream",handler:u}}}).call(this,n(25).Buffer)},function(t,e,n){t.exports=n(46)},function(t,e,n){var r=n(2).default;function o(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t.exports=o=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function p(t,e,n,r){var o=e&&e.prototype instanceof y?e:y,i=Object.create(o.prototype),s=new j(r||[]);return a(i,"_invoke",{value:E(t,n,s)}),i}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var d={};function y(){}function v(){}function _(){}var m={};l(m,u,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(C([])));g&&g!==n&&i.call(g,u)&&(m=g);var w=_.prototype=y.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){var n;a(this,"_invoke",{value:function(o,a){function s(){return new e((function(n,s){!function n(o,a,s,u){var c=h(t[o],t,a);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==r(l)&&i.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}(o,a,n,s)}))}return n=n?n.then(s,s):s()}})}function E(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=O(a,n);if(s){if(s===d)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function O(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var o=h(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function C(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(i.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return r.next=r}}return{next:T}}function T(){return{value:void 0,done:!0}}return v.prototype=_,a(w,"constructor",{value:_,configurable:!0}),a(_,"constructor",{value:v,configurable:!0}),v.displayName=l(_,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,f,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(S.prototype),l(S.prototype,c,(function(){return this})),e.AsyncIterator=S,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new S(p(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),l(w,f,"Generator"),l(w,u,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=C,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;A(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:C(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){var r=n(2).default,o=n(18);t.exports=function(t){var e=o(t,"string");return"symbol"===r(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){var r=n(2).default;t.exports=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){var r=n(22);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){},function(t,e,n){"use strict";
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("restaflib",[],e):"object"==typeof exports?exports.restaflib=e():t.restaflib=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=15)}([function(t,e,n){var r=n(16)();t.exports=r;try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(t,e){function n(t,e,n,r,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,o)}t.exports=function(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function s(t){n(a,o,i,s,u,"next",t)}function u(t){n(a,o,i,s,u,"throw",t)}s(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){function n(e){return t.exports=n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){"use strict";var r=n(13),o=n.n(r);var i=function(){return"\n print _args_;\n\n results = casFetchRows(_args_.table.caslib, _args_.table.name , _args_.start + 1, _args_.limit, _args_.format, _args_.where); \n send_response({casResults = results}); \n \n function casFetchRows(caslib, name, from, count, format, where) ; \n \n rc = checkAndLoadTable(caslib, name);\n \n if (rc ne true) then do;\n text = 'Unable to access ' ||caslib||'.'||name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n exit(rx); \n end; \n\n /*\n * get tableoinfo to get rowCount\n */\n\n action table.tableinfo r= result/ \n caslib = caslib \n name = name; \n \n rowCount = result.TableInfo[1, 'rows'];\n to = from + count - 1;\n\n \n /*\n * get column information\n */\n\n action table.columninfo r=infoResult /\n table = {caslib=caslib name=name};\n\n columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}};\n i = 2;\n do c over inforesult.columninfo;\n columns[i] = c;\n i = i + 1;\n end;\n \n /*\n * Fetch the current set of rows\n */\n\n rows = {};\n if (from <= rowCount) then do;\n action table.fetch r = result status=rcx/ \n table = {caslib=caslib, name=name where=where} \n from= from to=to format=format sastypes=true\n ;\n if (rcx.severity eq 2) then do;\n exit(rcx);\n end;\n /* \n * create payload to return\n */\n\n i = 1;\n rows ={};\n do row over result.fetch;\n rr = {};\n j = 1;\n do key,v over row;\n rr[j] = override(columns[j].Type, v);\n j = j + 1;\n end;\n rows[i] = rr;\n i = i + 1;\n end;\n end;\n\n currentCount = DIM(rows);\n pagination = {}; \n table = {caslib=caslib, name=name};\n\n pagination = setPagination(from, count, format, where, currentCount, rowCount, table);\n \n lastRequest={start=from-1, limit=count, format=format, currentCount=currentCount, \n rowCount=rowCount, where=where, table=table, version='3'};\n scrollOptions = getKeys(pagination);\n return( \n {pagination = pagination, data = {schema=columns, rows=rows , scrollOptions=scrollOptions}, lasRequest=lastRequest}\n );\n end; \n \n \n /*\n * For non-primary column types set new content\n */\n\n function setPagination(from, count, format, where, currentCount, rowCount, table);\n\n\n prevStart = max(from - count - 1, 0);\n\n if (currentCount lt count) then do; \n pagination.prev = {start=prevStart, limit=count, format=format, where=' ', table=table};\n if (prevStart ne 0) then do;\n pagination.first = {start=0, limit=count, format=format, where=' ', table=table};\n end; \n return pagination;\n end;\n currentStart = from -1;\n if (currentStart eq 0) then do;\n pagination.next = {start=count, limit=count, format=format, where=' ', table=table};\n return pagination;\n end;\n\n nextStart = currentStart + count;\n pagination.next = {start=nextStart, limit=count, format=format, where=' ', table=table};\n pagination.prev = {start=prevStart, limit=count, format=format, where=' ', table=table};\n if (prevStart ne 0) then do;\n pagination.first = {start=0, limit=count, format=format, where=' ', table=table};\n end; \n return pagination;\n end;\n\n\n\n\n function override(type, iv);\n if (type EQ 'varbinary') then v = '...varbinary';\n else if (type EQ 'blob') then v = '...blob';\n else if (type EQ 'table') then v = '...table';\n else if (type EQ 'dictionary') then v = '...dictionary';\n else if (type EQ 'list') then v = '...list';\n else if (type EQ 'isArray') then v = '...array';\n else v = iv;\n return v;\n end;\n\n \n "};var a=function(){return"\n \n /*------------------------------------------------*/\n /*Does the tables exist and if not try to load it */\n /*\n Typical usage:\n rc = checkAndLoadTable(caslib, name);\n if ( rc ne true) then do;\n ...handle errors...\n end; \n else do;\n ...your stuff...\n end;\n rc = true - the data is ready for use\n rc = false - the table could not be found\n rc = -1 - the caslib does not exist\n */\n /*------------------------------------------------*/\n\n\n\n function checkAndLoadTable(caslib, name); \n\n /* verify caslib is there */\n table.queryCaslib status=status result=result/\n caslib = caslib;\n do k,v over result; /* to handle casuser[user] */ \n rc = v;\n end;\n if ( rc eq false ) then \n return -1;\n /* \n * Check to see if table is already loaded \n */ \n action table.tableExists r=result/ \n caslib = caslib \n name = name; \n /* \n * if not loaded then try to load it \n */ \n rc = true;\n if (result.exists eq 0 or result.exists eq 2) then do; \n path = lookupPath(caslib, name);\n if (path eq '*') then do;\n rc = false;\n end;\n else do;\n\t action table.loadTable status=status/ \n\t caslib = caslib \n\t source = path \n\t casout={caslib= caslib name=name}; \n\t if (status.statusCode ne 0 ) then rc = false;\n end; \n end; \n return rc; \n end; \n\n function saveAndLoadTable(caslib, source, targetlib, targetname);\n\n /* load source */\n r = checkAndLoadTable(caslib, source);\n\n sashdat = target||\".sashdat\";\n table.save /\n caslib= targetlib name=sashdat\n table = {caslib=caslib name=source} replace=true;\n \n table.droptable /\n caslib=targetlib name=target quiet=true;\n \n table.loadtable result=r/\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\n path=sashdat;\n \n return r;\n\n end;\n function saveAndPromoteTable(caslib, target, source);\n sashdat = target||\".sashdat\";\n table.save /\n caslib= caslib name=sashdat\n table = {caslib=caslib name=source} replace=true;\n\n table.droptable /\n caslib=caslib name=target quiet=true;\n \n table.loadtable result=r/\n caslib=caslib casout={caslib=caslib name=target promote=TRUE}\n path=sashdat;\n\n return r;\n end;\n/*\n * return path to table\n */\n\nfunction lookupPath(caslib, name ) ; \n table.fileInfo r = result/ \n caslib=caslib; \n\n names = result.fileInfo[,4]; \n nameu = upcase(name)||'.SASHDAT'; \n cpath = '*'; \n count = 0; \n\n do n over names; \n\t if (upcase(n) eq nameu) then do; \n\t count = count + 1; \n\t if ( cpath eq '*') then do; \n\t cpath = n; \n\t end; \n\t end; \n end; \n \n if (count GT 1 ) then do; \n print 'Warning: ' count 'Files with names only different in case exist - First one chosen';\n print 'Path: ' cpath ' will be used****'; \n end; \n r = cpath; \n return r; \nend; \n\n /*-----------------------------------------*/ \n /* isModel: is it model table */ \n /*-----------------------------------------*/ \n \n function isModel(caslib, name) ; \n table.columnInfo r = result / \n table = {caslib=caslib , name=name}; \n validTable = false; \n mtype = 'bad'; \n do c over result.columninfo; \n cu = upCase(c.Column); \n if ( cu eq 'DATASTEPSRC') then do; \n mtype = 'ds'; \n end; \n else if ( cu eq '_STATE_' ) then do; \n mtype = 'astore'; \n end; \n else if (cu eq 'MODELMETADATA') then do; \n mtype = 'ds2'; \n end; \n end; \n print 'Specified model type: ' || mtype; \n return mtype; \n end; \n \n /*-----------------------------------------*/ \n /* Returns contents of the specified table */ \n /*-----------------------------------------*/ \n \n function contents(caslib, name) ; \n table.columnInfo r = result / \n table = {caslib=caslib , name=name}; \n /* columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}}; */ \n i = 1; \n columns = {}; \n do c over result.columninfo; \n columns[i] = c; \n i = i + 1; \n end; \n return {describe = columns, table = {}}; \n end; \n \n /*------------------------------------------*/ \n /* Returns unique values */ \n /*-----------------------------------------*/ \n \n function selectionLists(idvars,caslib, name, where); \n \n s = checkAndLoadTable(caslib, name); \n if ( s ne true) then do; \n results = {Errors= 'Unable to access ' ||caslib||'.'||name, statusCode = s}; \n \n end; \n print idvars;\n do k over idvars; \n r = _getValues(k, caslib, name, where); \n results[k] = r; \n end; \n return { data=results, statusCode=0}; \n end; \n \n function _getValues(id, caslib, name, where) ; \n \n action table.dropTable/ \n caslib='casuser' name='dtemp1' quiet=TRUE; \n \n action table.deleteSource status=src / \n caslib='casuser' source= 'dtemp1.sashdat' quiet=TRUE; \n \n action simple.groupby result=r status=rc/ \n aggregator = 'N' \n inputs = {id} \n table = {caslib=caslib name=name, where=where} \n casout = {caslib='casuser' name='dtemp1'} \n ; \n action table.fetch result=r/ \n table={caslib='casuser' name='dtemp1'} \n sortby={{name=id, order='ascending'}}; \n result = r.Fetch[,2]; \n return result; \n end; \n \n /*------------------------------------------*/ \n /* get a record */ \n /*------------------------------------------*/ \n \n function _fetchData(filter, table); \n s = checkAndLoadTable(table.caslib, table.name); \n if ( s ne 0 ) then do; \n results = {Errors= 'Unable to access ' ||table.caslib||'.'||table.name}; \n return results; \n end; \n wherex = dictTowhere(filter); \n /* wherex = table.caslib||'.'||table.name||'(where=('||wherex||'));'; \n \n destroyTable('casuser', 'input'); \n \n action datastep.runCode r=result status=rc/ \n single='yes' \n code = 'data casuser.input; set ' || wherex||'run;'; \n */ \n \n action table.fetch r = result / \n table={caslib=table.caslib name=table.name where=wherex}; \n \n rows = resultsToDict(result.Fetch); \n return {scenario = rows, table = result.Fetch}; \n \n end; \n\n function destroyTable(caslib,name); \n action table.dropTable/ \n caslib=caslib name=name quiet=TRUE; \n \n action table.deleteSource status=src / \n caslib=caslib source= name||'.sashdat' quiet=TRUE; \n \n return true; \n end; \n \n \n function dictToWhere(filter); \n where =''; \n andbit=' '; \n do k,v over filter; \n if (isString(v) ) then do; \n where = where || andbit || k || ' eq ' || '\"'||v||'\"'; \n end; \n else do; \n where = where || andbit || k || ' eq ' || v ; \n end; \n andbit =' and '; \n end; \n return where; \n end; \n \n function resultsToDict(r); \n casResults = {}; \n i = 1; \n do row over r; \n casResults[i] = row; \n i = i + 1; \n end; \n return casResults; \n end; \n \n function argsToTable(_arg_, caslib, name ); \n action table.droptable/ \n caslib=caslib name=name quiet=TRUE; \n i = 1; \n do key,obj over _arg_; \n columns[i] = key; \n row[i] = obj; \n if ( isString(obj) ) then \n type[i] = 'varchar'; \n else if ( isInteger(obj) ) then \n type[i] = 'int'; \n else type[i] = 'double'; \n i = i + 1; \n end; \n \n data1 = newTable('data1', columns, type, row ); \n \n saveresult data1 casout=name caslib=caslib replace; \n end; \n\n "};var s=function(){return"\n results = casFetchRows(_args_.table.caslib, _args_.table.name , _args_.from, _args_.count, _args_.format, _args_.where); \n send_response({casResults = results}); \n \n function casFetchRows(caslib, name, from, count, format, where) ; \n \n rc = checkAndLoadTable(caslib, name);\n \n if (rc ne true) then do;\n text = 'Unable to access ' ||caslib||'.'||name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n exit(rx); \n end; \n\n /*\n * get all table to get rowCount\n */\n\n action table.tableinfo r= result/ \n caslib = caslib \n name = name; \n \n rowCount = result.TableInfo[1, 'rows']; \n \n to = from + count - 1; \n \n /*\n * get column information\n */\n\n action table.columninfo r=infoResult /\n table = {caslib=caslib name=name};\n\n columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}};\n i = 2;\n do c over inforesult.columninfo;\n columns[i] = c;\n i = i + 1;\n end;\n \n /*\n * Fetch the current set of rows\n */\n /* wherex = dictTowhere(where); let user send in the where clause */\n print where;\n\n action table.fetch r = result / \n table = {caslib=caslib, name=name where=where} \n from= from to=to format=format sastypes=true\n ;\n\n /* \n * create payload to return\n */\n\n i = 1;\n rows ={};\n do row over result.fetch;\n rr = {};\n j = 1;\n do key,v over row;\n rr[j] = override(columns[j].Type, v);\n j = j + 1;\n end;\n rows[i] = rr;\n i = i + 1;\n end;\n\n pagePrev = max(from - count, 1);\n \n if ( to eq rowCount ) then do; \n pageNext = -1; \n end; \n else do ; \n pageNext = min(to + 1, rowCount); \n end; \n table = {caslib=caslib, name=name};\n pagination = {next= {from=pageNext, count=count, format=format, where=where table=table}, prev={from=pagePrev, count=count, format=format, where=where, table=table}};\n pagination.current = {from = from, to=to, rowCount=rowCount, version=1};\n return( \n {pagination = pagination, data = {schema=columns, rows=rows }}\n );\n end; \n \n \n /*\n * For non-primary column types set new content\n */\n\n function override(type, iv);\n if (type EQ 'varbinary') then v = '...varbinary';\n else if (type EQ 'blob') then v = '...blob';\n else if (type EQ 'table') then v = '...table';\n else if (type EQ 'dictionary') then v = '...dictionary';\n else if (type EQ 'list') then v = '...list';\n else if (type EQ 'isArray') then v = '...array';\n else v = iv;\n return v;\n end;\n\n \n "};var u=function(){return"\n rc = checkAndLoadTable(_args_.masterTable.caslib, _args_.masterTable.name);\n\n if (rc ne true) then do;\n text = 'Unable to access ' ||_args_.masterTable.caslib||'.'||_args_.masterTable.name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n exit(rx); \n end; \n \n rc = checkAndLoadTable(_args_.setTable.caslib, _args_.setTable.name);\n if (rc ne true) then do;\n text = 'Unable to access ' ||_args_.setTable.caslib||'.'||_args_.setTable.name; \n rx = {severity=2,reason=6, status='error',statusCode=2, formatted=text};\n return rx;\n end;\n\n\n setdata = _args_.setTable.caslib ||'.'||_args_.setTable.name;\n masterdata = _args_.masterTable.caslib ||'.'||_args_.masterTable.name;\n\n action datastep.runCode r=result status=rc/\n code='data ' ||masterdata||'(append=YES);set ' || setdata ||'; run;';\n\n if (rc.statusCode ne 0) then do;\n exit(rc);\n end; \n else do;\n results = {msg= 'Append succeeded', statusCode=true};\n end;\n \n send_response({casResults = results});\n "};e.a={commonCasl:a,casFetchData:i,casFetchRows:s,scoreCasl:o.a,casAppendTable:u,casRowSets:i}},function(t,e,n){"use strict";var r=n(1),o=n.n(r),i=n(0),a=n.n(i),s=n(7);function u(){return(u=o()(a.a.mark((function t(e,n,r,o){var i,u,c,f,l,p,h,d=arguments;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i=Object(s.a)(null!==o?o:{},"_args_"),u=(u=i+" "+r).replace(/\r?\n|\r/g,""),c={action:"sccasl.runcasl",data:{code:u}},f=d.length,l=new Array(f>4?f-4:0),p=4;p<f;p++)l[p-4]=d[p];return t.next=7,e.runAction.apply(e,[n,c].concat(l));case 7:return h=t.sent,t.abrupt("return",h);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}e.a=function(t,e,n,r){return u.apply(this,arguments)}},function(t,e,n){"use strict";var r=n(1),o=n.n(r),i=n(0),a=n.n(i),s=n(4),u=n(3);function c(){return(c=o()(a.a.mark((function t(e,n,r,o,i){var c,f,l,p,h,d=arguments;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(c=r,!0===i&&(c=r+" "+u.a.commonCasl()),f=d.length,l=new Array(f>5?f-5:0),p=5;p<f;p++)l[p-5]=d[p];return t.next=5,s.a.apply(void 0,[e,n,c,o].concat(l));case 5:return h=t.sent,t.abrupt("return",h.items().toJS());case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}e.a=function(t,e,n,r,o){return c.apply(this,arguments)}},function(t,e,n){var r=n(17);t.exports=function(t,e,n){return(e=r(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){"use strict";var r=n(2),o=n.n(r);function i(t){var e="{ ",n=" ";for(var r in t){if(!0===Array.isArray(t[r])){var s=a(t[r]);e=e+n+"".concat(r,"=")+s}else{var u=o()(t[r]);if("object"===u){var c=i(t[r]);e=e+n+"".concat(r,"=")+c}else e=e+n+"".concat(r,"=")+("string"===u?' "'.concat(t[r],'" '):"".concat(t[r]," "))}n=","}return e+="} "}function a(t){for(var e="{",n=" ",r=t.length,s=0;s<r;s++)if(!0===Array.isArray(t[s])){var u=a(t[s]);e=e+n+"".concat(s,"=")+u}else{var c=o()(t[s]);if("object"===c)e=e+n+i(t[s]);else e=e+n+("string"===c?' "'.concat(t[s],'" '):"".concat(t[s]," "));n=","}return e+="}"}e.a=function(t,e){var n;return n=null===t?"{}":!0===Array.isArray(t)?a(t):i(t),"".concat(e," = ").concat(n,";")}},function(t,e,n){"use strict";n.d(e,"b",(function(){return u})),n.d(e,"c",(function(){return h})),n.d(e,"a",(function(){return y}));var r=n(1),o=n.n(r),i=n(0),a=n.n(i);function s(){return(s=o()(a.a.mark((function t(e,n,r,o){var i,s,u,c,f;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=o.output,s=i.caslib,null!=(u=i.name)){t.next=3;break}throw"Please specify table as caslib.name";case 3:return u=u.toLowerCase(u),c="\n action table.droptable /\n caslib= '".concat(s,"' name= '").concat(u,"' quiet=true;\n\n action table.deleteSource/\n caslib= '").concat(s,"' source= '").concat(u,".sashdat' quiet=true; \n "),f={action:"sccasl.runcasl",data:{code:c}},t.next=8,e.runAction(n,f);case 8:return f={action:"astore.upload",data:{rstore:{name:"".concat(u),caslib:"".concat(s),replace:!0},store:r}},t.next=11,e.runAction(n,f);case 11:return t.sent,t.abrupt("return","Upload of ".concat(o.source," to ").concat(s,".").concat(u," completed"));case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var u=function(t,e,n,r){return s.apply(this,arguments)},c=n(5);function f(){return(f=o()(a.a.mark((function t(e,n,r,o,i){var s,u,f,p,h,d,y;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=o.output,u=s.caslib,null!=(f=s.name)){t.next=3;break}throw"Please specify table as caslib.name";case 3:return t.next=5,l(e,n,u,f);case 5:return p={casout:{caslib:u,name:f},importOptions:{fileType:o.fileType}},"sas"!==o.fileExt&&"ds2"!==o.fileExt||(p.importOptions.delimiter="\\"),h={headers:{"JSON-Parameters":p,"Content-Type":"binary/octet-stream"},data:r,action:"table.upload"},t.next=10,e.runAction(n,h);case 10:if(t.sent,!0!==i){t.next=16;break}return d="\n\t\t\taction table.save r = result / \n\t\t\ttable = {caslib='".concat(u,"' name='").concat(f,"'} replace=true\n\t\t\tcaslib='").concat(u,"' name='").concat(f,"';\n\n\t\t\tsend_response(result);\n\t\t\t"),t.next=15,Object(c.a)(e,n,d,null,!0);case 15:t.sent;case 16:return y=null==o.source?"inline source":o.source,t.abrupt("return","Upload of ".concat(y," to ").concat((o.output,u),".").concat(o.output.name," completed"));case 18:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function l(t,e,n,r){return p.apply(this,arguments)}function p(){return(p=o()(a.a.mark((function t(e,n,r,o){var i,s;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i="".concat(r,".").concat(o),s="\n\t\taction table.dropTable/ \n caslib='".concat(r,"' name='").concat(o,"' quiet=TRUE; \n \n action table.deleteSource status=src / \n caslib='casuser' source= '").concat(i,"' quiet=TRUE; \n\t\tsend_response({csResults = {results= 'data deleted'}})\n\t\t"),t.next=4,Object(c.a)(e,n,s);case 4:t.sent;case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var h=function(t,e,n,r,o){return f.apply(this,arguments)};function d(){return(d=o()(a.a.mark((function t(e,n,r,o){var i;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={action:"table.save",data:{name:"".concat(o),caslib:"".concat(r),replace:!0,table:{name:"".concat(o),caslib:"".concat(r)}}},t.next=3,e.runAction(n,i);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var y=function(t,e,n,r){return d.apply(this,arguments)}},function(t,e,n){"use strict";var r=n(12),o=n(43),i=/[^\w\s\n\r\v\t\.,]/i;e.version=n(44).version;var a=function(t,e){return void 0!==t||e.renderUndefined},s=function(t,e,n){return"boolean"==typeof t||"number"==typeof t||"function"==typeof t||null==t||t instanceof Date||("string"==typeof t&&-1===t.indexOf("\n")||!(!n.inlineArrays||e||!Array.isArray(t)||!s(t[0],!0,n)))},u=function(t,e){if(e.noColor)return t;if("string"==typeof t)return e.stringColor?r[e.stringColor](t):t;var n=t+"";return!0===t?r.green(n):!1===t?r.red(n):null==t?r.grey(n):"number"==typeof t?t>=0?r[e.positiveNumberColor](n):r[e.negativeNumberColor](n):"function"==typeof t?"function() {}":Array.isArray(t)?t.join(", "):n},c=function(t,e){return null===t.multilineStringColor||t.noColor?e:r[t.multilineStringColor](e)},f=function(t,e,n){var r=t.split("\n");return(r=r.map((function(t){return o.indent(e)+c(n,t)}))).join("\n")},l=function(t,e,n){if("string"==typeof t&&t.match(i)&&e.escape&&(t=JSON.stringify(t)),!a(t,e))return[];if(s(t,!1,e))return[o.indent(n)+u(t,e)];if("string"==typeof t)return[o.indent(n)+c(e,'"""'),f(t,n+e.defaultIndentation,e),o.indent(n)+c(e,'"""')];if(Array.isArray(t)){if(0===t.length)return[o.indent(n)+e.emptyArrayMsg];var p=[];return t.forEach((function(t){if(a(t,e)){var i="- ";e.noColor||(i=r[e.dashColor](i)),i=o.indent(n)+i,s(t,!1,e)?(i+=l(t,e,0)[0],p.push(i)):(p.push(i),p.push.apply(p,l(t,e,n+e.defaultIndentation)))}})),p}if(t instanceof Error)return l({message:t.message,stack:t.stack.split("\n")},e,n);var h,d=e.noAlign?0:o.getMaxIndexLength(t),y=[];return Object.getOwnPropertyNames(t).forEach((function(i){if(a(t[i],e))if(h=i+": ",e.noColor||(h=r[e.keysColor](h)),h=o.indent(n)+h,s(t[i],!1,e)){var u=e.noAlign?0:d-i.length;h+=l(t[i],e,u)[0],y.push(h)}else y.push(h),y.push.apply(y,l(t[i],e,n+e.defaultIndentation))})),y};e.render=function(t,e,n){return n=n||0,(e=e||{}).emptyArrayMsg=e.emptyArrayMsg||"(empty array)",e.keysColor=e.keysColor||"green",e.dashColor=e.dashColor||"green",e.numberColor=e.numberColor||"blue",e.positiveNumberColor=e.positiveNumberColor||e.numberColor,e.negativeNumberColor=e.negativeNumberColor||e.numberColor,e.defaultIndentation=e.defaultIndentation||2,e.noColor=!!e.noColor,e.noAlign=!!e.noAlign,e.escape=!!e.escape,e.renderUndefined=!!e.renderUndefined,e.stringColor=e.stringColor||null,e.multilineStringColor=e.multilineStringColor||null,l(t,e,n).join("\n")},e.renderString=function(t,n,o){var i,a,s="";if("string"!=typeof t||""===t)return"";"{"!==t[0]&&"["!==t[0]&&(a=-1===t.indexOf("{")?t.indexOf("["):-1===t.indexOf("[")||t.indexOf("{")<t.indexOf("[")?t.indexOf("{"):t.indexOf("["),s+=t.substr(0,a)+"\n",t=t.substr(a));try{i=JSON.parse(t)}catch(t){return r.red("Error:")+" Not valid JSON!"}return s+=e.render(i,n,o)}},function(t,e,n){var r=n(19),o=n(20),i=n(21),a=n(23);t.exports=function(t,e){return r(t)||o(t,e)||i(t,e)||a()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var u,c=[],f=!1,l=-1;function p(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&h())}function h(){if(!f){var t=s(p);f=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new d(t,e)),1!==c.length||f||s(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,n){var r=n(29);t.exports=r},function(t,e){t.exports=function(){return"\n result = runMain(_args_); \n send_response(result); \n /* print result; */\n \n \n function runMain(_args_) ; \n r = {Error= 'No path'}; \n if ( _args_.path eq '/selectors') then do; \n r = selectionLists(_args_.selectors, _args_.table.caslib, _args_.table.name); \n end; \n else if ( _args_.path eq '/contents') then do; \n r = contents(_args_.table.caslib, _args_.table.name); \n end; \n else if (_args_.path eq '/describe') then do; \n r = describeModel(_args_); \n end; \n else if (_args_.path eq '/scenario' ) then do;\n r = fetchData(_args_.filter, _args_.table);\n end;\n else if (_args_.path eq '/score') then do; \n if( exists(_args_, 'modelName') eq false ) then\n modelname = '';\n else modelName =_args_.modelName;\n r = runScoreCode(_args_.model, _args_.scenario, modelName); \n end; \n else do; \n r = {icasResults={Errors = 'Invalid action option specified' || _args_.path}, statusCode=404}; \n end; \n print r;\n if ( r.statusCode ne 0) then do;\n print r.icasResults;\n exit({severity=2,reason=6, status=r.iCasResults.Errors,statusCode=r.statusCode});\n end;\n result = {casResults = r.icasResults}; \n print '***************************************************************'; \n print result; \n print '***************************************************************'; \n return result; \n end; \n \n /*-----------------------------------------*/ \n /* describeModel */ \n /*-----------------------------------------*/ \n \n function describeModel(_args_) ; \n s = checkAndLoadTable(_args_.model.caslib, _args_.model.name); \n if ( s ne true) then do; \n results = {Errors= 'Unable to access ' ||_args_.model.caslib||'.'||_args_.model.name}; \n return {icasResults=results, statusCode=404}; \n end; \n \n mtype = isModel(_args_.model.caslib, _args_.model.name); \n if ( mtype EQ 'astore' ) then do; \n r = astoreDescribe(_args_.model); \n end; \n else if (mtype EQ 'ds' or mtype EQ 'ds2') then do;\n s = checkAndLoadTable(_args_.table.caslib, _args_.table.name); \n if ( s ne true ) then do; \n results = {Errors= 'Unable to access ' ||_args_.table.caslib||'.'||_args_.table.name}; \n return {icasResults=results, statusCode=404}; \n end; \n r = contents( _args_.table.caslib, _args_.table.name); \n end; \n return {icasResults= r, statusCode=0} ;\n end; \n \n /*------------------------------------------*/ \n /* astoreDescribe */ \n /*------------------------------------------*/ \n \n function astoreDescribe(model); \n action astore.describe r=result/ \n rstore = { caslib= model.caslib name = model.name }; \n rows = resultsToDict(result.InputVariables); \n return {describe = rows, table = result.InputVariables}; \n end; \n \n /*------------------------------------------*/ \n /* score */ \n /*------------------------------------------*/ \n function runScoreCode( model, scenario, modelName); \n print model; \n s = checkAndLoadTable(model.caslib, model.name); \n if ( s ne true ) then do; \n results = {Errors= 'Unable to access ' ||model.caslib||'.'||model.name}; \n return {icasResults=results, statusCode=404}; \n end;\n \n mtype = isModel(model.caslib, model.name); \n \n if ( mtype eq 'bad' ) then do; \n results = {Error= model.caslib||'.'||model.name || ' is not recognized as a valid supported model. Please check your values'};\n return {icasResults=results, statusCode=400};\n end; \n destroyTable('casuser', 'input'); \n argsToTable(scenario, 'casuser', 'input'); \n \n destroyTable('casuser', 'output'); \n \n if (mtype eq 'astore') then do; \n print 'Scoring with astore'; \n action astore.score r = result/ \n rstore = {caslib=model.caslib name=model.name} \n out = {caslib='casuser' name='output'} \n table = {caslib='casuser' name='input'}; \n end; \n else if (mtype eq 'ds') then do; \n print 'scoring with datastep code'; \n action datastep.runcodetable r = result/ \n single='YES' \n codeTable= {caslib=model.caslib name=model.name} \n casout = {caslib='casuser' name='output'} \n table = {caslib='casuser' name='input'}; \n end; \n else if (mtype eq 'ds2' ) then do; \n print 'Scoring with d2'; \n if ( missing(modelName) eq true) then do;\n results = {Error= 'modelName is missing. Please check your values'};\n return {icasResults=results, statusCode=400};\n end;\n\n action ds2.runModel r = result/ \n modelTable = {caslib=model.caslib, name=model.name} \n modelName = modelName \n table = {caslib= 'casuser', name='input'} \n casOut = {caslib= 'casuser' name='output'}; \n end; \n \n \n action table.fetch r = result / \n table={caslib='casuser' name='output'}; \n \n rows = resultsToDict(result.Fetch); \n \n return {icasResults= rows, statusCode=0} ;\n end; \n \n \n "}},function(t,e,n){"use strict";(function(t){var r=n(10),o=n.n(r),i=n(8);e.a=function(e,n){var r,a,s=null,u=i.c,c=function(t){return t};switch(a=null==e?"csv":e.split(".").pop().toLowerCase()){case"sas7bdat":r="basesas";break;case"sashdat":r="hdat";break;case"csv":r=a,s="UTF8";break;case"xslx":case"xsl":r=a;break;case"astore":case"sasast":r=a,u=i.b,c=function(e){return new t.from(e).toString("base64")};break;case"ds2":case"sas":r="csv",s="UTF8",u=i.c,c=function(t,e){var n=t.replace(/[^\x00-\x7F]/g,"").replace(/\r?\n/g,""),r=e.fileExt;return"modelName\\"+("sas"===r?"dataStepSrc":"ds2"===r?"ds2Src":"casl"===r?"caslSrc":"dataStepsrc")+"\n"+e.output.name+"\\ "+n+"\n"};break;default:throw"Currently file type of ".concat(a," is not supported")}var f=n.split("."),l=o()(f,2);return{source:e,output:{caslib:l[0],name:l[1].toLowerCase()},fileType:r,fileExt:a,fileOptions:s,transform:c,contentType:"binary/octet-stream",handler:u}}}).call(this,n(25).Buffer)},function(t,e,n){t.exports=n(46)},function(t,e,n){var r=n(2).default;function o(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t.exports=o=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function p(t,e,n,r){var o=e&&e.prototype instanceof y?e:y,i=Object.create(o.prototype),s=new j(r||[]);return a(i,"_invoke",{value:E(t,n,s)}),i}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var d={};function y(){}function v(){}function _(){}var m={};l(m,u,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(C([])));g&&g!==n&&i.call(g,u)&&(m=g);var w=_.prototype=y.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){var n;a(this,"_invoke",{value:function(o,a){function s(){return new e((function(n,s){!function n(o,a,s,u){var c=h(t[o],t,a);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==r(l)&&i.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}(o,a,n,s)}))}return n=n?n.then(s,s):s()}})}function E(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=O(a,n);if(s){if(s===d)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function O(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var o=h(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function C(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(i.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return r.next=r}}return{next:T}}function T(){return{value:void 0,done:!0}}return v.prototype=_,a(w,"constructor",{value:_,configurable:!0}),a(_,"constructor",{value:v,configurable:!0}),v.displayName=l(_,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,f,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(S.prototype),l(S.prototype,c,(function(){return this})),e.AsyncIterator=S,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new S(p(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),l(w,f,"Generator"),l(w,u,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=C,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;A(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:C(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){var r=n(2).default,o=n(18);t.exports=function(t){var e=o(t,"string");return"symbol"===r(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){var r=n(2).default;t.exports=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,n){var r=n(22);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){},function(t,e,n){"use strict";
|
|
2
2
|
/*!
|
|
3
3
|
* The buffer module from node.js, for the browser.
|
|
4
4
|
*
|
package/lib/restaflib.js
CHANGED
|
@@ -1314,7 +1314,7 @@ eval("/*\r\n* Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights
|
|
|
1314
1314
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1315
1315
|
|
|
1316
1316
|
"use strict";
|
|
1317
|
-
eval("/*\r\n* Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\r\n* SPDX-License-Identifier: Apache-2.0\r\n*/\n\nfunction commonCasl() {\n var casl = \"\\n \\n /*------------------------------------------------*/\\n /*Does the tables exist and if not try to load it */\\n /*\\n Typical usage:\\n rc = checkAndLoadTable(caslib, name);\\n if ( rc ne true) then do;\\n ...handle errors...\\n end; \\n else do;\\n ...your stuff...\\n end;\\n rc = true - the data is ready for use\\n rc = false - the table could not be found\\n rc = -1 - the caslib does not exist\\n */\\n /*------------------------------------------------*/\\n\\n\\n\\n function checkAndLoadTable(caslib, name); \\n\\n /* verify caslib is there */\\n table.queryCaslib status=status result=result/\\n caslib = caslib;\\n do k,v over result; /* to handle casuser[user] */ \\n rc = v;\\n end;\\n if ( rc eq false ) then \\n return -1;\\n /* \\n * Check to see if table is already loaded \\n */ \\n action table.tableExists r=result/ \\n caslib = caslib \\n name = name; \\n /* \\n * if not loaded then try to load it \\n */ \\n rc = true;\\n if (result.exists eq 0) then do; \\n path = lookupPath(caslib, name);\\n if (path eq '*') then do;\\n rc = false;\\n end;\\n else do;\\n\\t action table.loadTable status=status/ \\n\\t caslib = caslib \\n\\t source = path \\n\\t casout={caslib= caslib name=name}; \\n\\t if (status.statusCode ne 0 ) then rc = false;\\n end; \\n end; \\n return rc; \\n end; \\n\\n function saveAndLoadTable(caslib, source, targetlib, targetname);\\n\\n /* load source */\\n r = checkAndLoadTable(caslib, source);\\n\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= targetlib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n \\n table.droptable /\\n caslib=targetlib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\\n path=sashdat;\\n \\n return r;\\n\\n end;\\n function saveAndPromoteTable(caslib, target, source);\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= caslib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n\\n table.droptable /\\n caslib=caslib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=caslib casout={caslib=caslib name=target promote=TRUE}\\n path=sashdat;\\n\\n return r;\\n end;\\n/*\\n * return path to table\\n */\\n\\nfunction lookupPath(caslib, name ) ; \\n table.fileInfo r = result/ \\n caslib=caslib; \\n\\n names = result.fileInfo[,4]; \\n nameu = upcase(name)||'.SASHDAT'; \\n cpath = '*'; \\n count = 0; \\n\\n do n over names; \\n\\t if (upcase(n) eq nameu) then do; \\n\\t count = count + 1; \\n\\t if ( cpath eq '*') then do; \\n\\t cpath = n; \\n\\t end; \\n\\t end; \\n end; \\n \\n if (count GT 1 ) then do; \\n print 'Warning: ' count 'Files with names only different in case exist - First one chosen';\\n print 'Path: ' cpath ' will be used****'; \\n end; \\n r = cpath; \\n return r; \\nend; \\n\\n /*-----------------------------------------*/ \\n /* isModel: is it model table */ \\n /*-----------------------------------------*/ \\n \\n function isModel(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n validTable = false; \\n mtype = 'bad'; \\n do c over result.columninfo; \\n cu = upCase(c.Column); \\n if ( cu eq 'DATASTEPSRC') then do; \\n mtype = 'ds'; \\n end; \\n else if ( cu eq '_STATE_' ) then do; \\n mtype = 'astore'; \\n end; \\n else if (cu eq 'MODELMETADATA') then do; \\n mtype = 'ds2'; \\n end; \\n end; \\n print 'Specified model type: ' || mtype; \\n return mtype; \\n end; \\n \\n /*-----------------------------------------*/ \\n /* Returns contents of the specified table */ \\n /*-----------------------------------------*/ \\n \\n function contents(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n /* columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}}; */ \\n i = 1; \\n columns = {}; \\n do c over result.columninfo; \\n columns[i] = c; \\n i = i + 1; \\n end; \\n return {describe = columns, table = {}}; \\n end; \\n \\n /*------------------------------------------*/ \\n /* Returns unique values */ \\n /*-----------------------------------------*/ \\n \\n function selectionLists(idvars,caslib, name, where); \\n \\n s = checkAndLoadTable(caslib, name); \\n if ( s ne true) then do; \\n results = {Errors= 'Unable to access ' ||caslib||'.'||name, statusCode = s}; \\n \\n end; \\n print idvars;\\n do k over idvars; \\n r = _getValues(k, caslib, name, where); \\n results[k] = r; \\n end; \\n return { data=results, statusCode=0}; \\n end; \\n \\n function _getValues(id, caslib, name, where) ; \\n \\n action table.dropTable/ \\n caslib='casuser' name='dtemp1' quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib='casuser' source= 'dtemp1.sashdat' quiet=TRUE; \\n \\n action simple.groupby result=r status=rc/ \\n aggregator = 'N' \\n inputs = {id} \\n table = {caslib=caslib name=name, where=where} \\n casout = {caslib='casuser' name='dtemp1'} \\n ; \\n action table.fetch result=r/ \\n table={caslib='casuser' name='dtemp1'} \\n sortby={{name=id, order='ascending'}}; \\n result = r.Fetch[,2]; \\n return result; \\n end; \\n \\n /*------------------------------------------*/ \\n /* get a record */ \\n /*------------------------------------------*/ \\n \\n function _fetchData(filter, table); \\n s = checkAndLoadTable(table.caslib, table.name); \\n if ( s ne 0 ) then do; \\n results = {Errors= 'Unable to access ' ||table.caslib||'.'||table.name}; \\n return results; \\n end; \\n wherex = dictTowhere(filter); \\n /* wherex = table.caslib||'.'||table.name||'(where=('||wherex||'));'; \\n \\n destroyTable('casuser', 'input'); \\n \\n action datastep.runCode r=result status=rc/ \\n single='yes' \\n code = 'data casuser.input; set ' || wherex||'run;'; \\n */ \\n \\n action table.fetch r = result / \\n table={caslib=table.caslib name=table.name where=wherex}; \\n \\n rows = resultsToDict(result.Fetch); \\n return {scenario = rows, table = result.Fetch}; \\n \\n end; \\n\\n function destroyTable(caslib,name); \\n action table.dropTable/ \\n caslib=caslib name=name quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib=caslib source= name||'.sashdat' quiet=TRUE; \\n \\n return true; \\n end; \\n \\n \\n function dictToWhere(filter); \\n where =''; \\n andbit=' '; \\n do k,v over filter; \\n if (isString(v) ) then do; \\n where = where || andbit || k || ' eq ' || '\\\"'||v||'\\\"'; \\n end; \\n else do; \\n where = where || andbit || k || ' eq ' || v ; \\n end; \\n andbit =' and '; \\n end; \\n return where; \\n end; \\n \\n function resultsToDict(r); \\n casResults = {}; \\n i = 1; \\n do row over r; \\n casResults[i] = row; \\n i = i + 1; \\n end; \\n return casResults; \\n end; \\n \\n function argsToTable(_arg_, caslib, name ); \\n action table.droptable/ \\n caslib=caslib name=name quiet=TRUE; \\n i = 1; \\n do key,obj over _arg_; \\n columns[i] = key; \\n row[i] = obj; \\n if ( isString(obj) ) then \\n type[i] = 'varchar'; \\n else if ( isInteger(obj) ) then \\n type[i] = 'int'; \\n else type[i] = 'double'; \\n i = i + 1; \\n end; \\n \\n data1 = newTable('data1', columns, type, row ); \\n \\n saveresult data1 casout=name caslib=caslib replace; \\n end; \\n\\n \";\n return casl;\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (commonCasl);\n\n//# sourceURL=webpack://restaflib/./programs/commonCasl.js?");
|
|
1317
|
+
eval("/*\r\n* Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\r\n* SPDX-License-Identifier: Apache-2.0\r\n*/\n\nfunction commonCasl() {\n var casl = \"\\n \\n /*------------------------------------------------*/\\n /*Does the tables exist and if not try to load it */\\n /*\\n Typical usage:\\n rc = checkAndLoadTable(caslib, name);\\n if ( rc ne true) then do;\\n ...handle errors...\\n end; \\n else do;\\n ...your stuff...\\n end;\\n rc = true - the data is ready for use\\n rc = false - the table could not be found\\n rc = -1 - the caslib does not exist\\n */\\n /*------------------------------------------------*/\\n\\n\\n\\n function checkAndLoadTable(caslib, name); \\n\\n /* verify caslib is there */\\n table.queryCaslib status=status result=result/\\n caslib = caslib;\\n do k,v over result; /* to handle casuser[user] */ \\n rc = v;\\n end;\\n if ( rc eq false ) then \\n return -1;\\n /* \\n * Check to see if table is already loaded \\n */ \\n action table.tableExists r=result/ \\n caslib = caslib \\n name = name; \\n /* \\n * if not loaded then try to load it \\n */ \\n rc = true;\\n if (result.exists eq 0 or result.exists eq 2) then do; \\n path = lookupPath(caslib, name);\\n if (path eq '*') then do;\\n rc = false;\\n end;\\n else do;\\n\\t action table.loadTable status=status/ \\n\\t caslib = caslib \\n\\t source = path \\n\\t casout={caslib= caslib name=name}; \\n\\t if (status.statusCode ne 0 ) then rc = false;\\n end; \\n end; \\n return rc; \\n end; \\n\\n function saveAndLoadTable(caslib, source, targetlib, targetname);\\n\\n /* load source */\\n r = checkAndLoadTable(caslib, source);\\n\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= targetlib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n \\n table.droptable /\\n caslib=targetlib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\\n path=sashdat;\\n \\n return r;\\n\\n end;\\n function saveAndPromoteTable(caslib, target, source);\\n sashdat = target||\\\".sashdat\\\";\\n table.save /\\n caslib= caslib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n\\n table.droptable /\\n caslib=caslib name=target quiet=true;\\n \\n table.loadtable result=r/\\n caslib=caslib casout={caslib=caslib name=target promote=TRUE}\\n path=sashdat;\\n\\n return r;\\n end;\\n/*\\n * return path to table\\n */\\n\\nfunction lookupPath(caslib, name ) ; \\n table.fileInfo r = result/ \\n caslib=caslib; \\n\\n names = result.fileInfo[,4]; \\n nameu = upcase(name)||'.SASHDAT'; \\n cpath = '*'; \\n count = 0; \\n\\n do n over names; \\n\\t if (upcase(n) eq nameu) then do; \\n\\t count = count + 1; \\n\\t if ( cpath eq '*') then do; \\n\\t cpath = n; \\n\\t end; \\n\\t end; \\n end; \\n \\n if (count GT 1 ) then do; \\n print 'Warning: ' count 'Files with names only different in case exist - First one chosen';\\n print 'Path: ' cpath ' will be used****'; \\n end; \\n r = cpath; \\n return r; \\nend; \\n\\n /*-----------------------------------------*/ \\n /* isModel: is it model table */ \\n /*-----------------------------------------*/ \\n \\n function isModel(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n validTable = false; \\n mtype = 'bad'; \\n do c over result.columninfo; \\n cu = upCase(c.Column); \\n if ( cu eq 'DATASTEPSRC') then do; \\n mtype = 'ds'; \\n end; \\n else if ( cu eq '_STATE_' ) then do; \\n mtype = 'astore'; \\n end; \\n else if (cu eq 'MODELMETADATA') then do; \\n mtype = 'ds2'; \\n end; \\n end; \\n print 'Specified model type: ' || mtype; \\n return mtype; \\n end; \\n \\n /*-----------------------------------------*/ \\n /* Returns contents of the specified table */ \\n /*-----------------------------------------*/ \\n \\n function contents(caslib, name) ; \\n table.columnInfo r = result / \\n table = {caslib=caslib , name=name}; \\n /* columns ={{Column='_Index_',ID=0,Type='double',RawLength=5,FormattedLength=5,NFL=0,NFD=0}}; */ \\n i = 1; \\n columns = {}; \\n do c over result.columninfo; \\n columns[i] = c; \\n i = i + 1; \\n end; \\n return {describe = columns, table = {}}; \\n end; \\n \\n /*------------------------------------------*/ \\n /* Returns unique values */ \\n /*-----------------------------------------*/ \\n \\n function selectionLists(idvars,caslib, name, where); \\n \\n s = checkAndLoadTable(caslib, name); \\n if ( s ne true) then do; \\n results = {Errors= 'Unable to access ' ||caslib||'.'||name, statusCode = s}; \\n \\n end; \\n print idvars;\\n do k over idvars; \\n r = _getValues(k, caslib, name, where); \\n results[k] = r; \\n end; \\n return { data=results, statusCode=0}; \\n end; \\n \\n function _getValues(id, caslib, name, where) ; \\n \\n action table.dropTable/ \\n caslib='casuser' name='dtemp1' quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib='casuser' source= 'dtemp1.sashdat' quiet=TRUE; \\n \\n action simple.groupby result=r status=rc/ \\n aggregator = 'N' \\n inputs = {id} \\n table = {caslib=caslib name=name, where=where} \\n casout = {caslib='casuser' name='dtemp1'} \\n ; \\n action table.fetch result=r/ \\n table={caslib='casuser' name='dtemp1'} \\n sortby={{name=id, order='ascending'}}; \\n result = r.Fetch[,2]; \\n return result; \\n end; \\n \\n /*------------------------------------------*/ \\n /* get a record */ \\n /*------------------------------------------*/ \\n \\n function _fetchData(filter, table); \\n s = checkAndLoadTable(table.caslib, table.name); \\n if ( s ne 0 ) then do; \\n results = {Errors= 'Unable to access ' ||table.caslib||'.'||table.name}; \\n return results; \\n end; \\n wherex = dictTowhere(filter); \\n /* wherex = table.caslib||'.'||table.name||'(where=('||wherex||'));'; \\n \\n destroyTable('casuser', 'input'); \\n \\n action datastep.runCode r=result status=rc/ \\n single='yes' \\n code = 'data casuser.input; set ' || wherex||'run;'; \\n */ \\n \\n action table.fetch r = result / \\n table={caslib=table.caslib name=table.name where=wherex}; \\n \\n rows = resultsToDict(result.Fetch); \\n return {scenario = rows, table = result.Fetch}; \\n \\n end; \\n\\n function destroyTable(caslib,name); \\n action table.dropTable/ \\n caslib=caslib name=name quiet=TRUE; \\n \\n action table.deleteSource status=src / \\n caslib=caslib source= name||'.sashdat' quiet=TRUE; \\n \\n return true; \\n end; \\n \\n \\n function dictToWhere(filter); \\n where =''; \\n andbit=' '; \\n do k,v over filter; \\n if (isString(v) ) then do; \\n where = where || andbit || k || ' eq ' || '\\\"'||v||'\\\"'; \\n end; \\n else do; \\n where = where || andbit || k || ' eq ' || v ; \\n end; \\n andbit =' and '; \\n end; \\n return where; \\n end; \\n \\n function resultsToDict(r); \\n casResults = {}; \\n i = 1; \\n do row over r; \\n casResults[i] = row; \\n i = i + 1; \\n end; \\n return casResults; \\n end; \\n \\n function argsToTable(_arg_, caslib, name ); \\n action table.droptable/ \\n caslib=caslib name=name quiet=TRUE; \\n i = 1; \\n do key,obj over _arg_; \\n columns[i] = key; \\n row[i] = obj; \\n if ( isString(obj) ) then \\n type[i] = 'varchar'; \\n else if ( isInteger(obj) ) then \\n type[i] = 'int'; \\n else type[i] = 'double'; \\n i = i + 1; \\n end; \\n \\n data1 = newTable('data1', columns, type, row ); \\n \\n saveresult data1 casout=name caslib=caslib replace; \\n end; \\n\\n \";\n return casl;\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (commonCasl);\n\n//# sourceURL=webpack://restaflib/./programs/commonCasl.js?");
|
|
1318
1318
|
|
|
1319
1319
|
/***/ }),
|
|
1320
1320
|
|