@sassoftware/restaflib 4.10.5 → 4.11.1
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 +3 -3
- package/dist/restaflib.min.js +3 -3
- package/lib/restaflib.js +3 -3
- package/package.json +1 -1
package/lib/restaflib.js
CHANGED
|
@@ -846,7 +846,7 @@ eval("/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_
|
|
|
846
846
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
847
847
|
|
|
848
848
|
"use strict";
|
|
849
|
-
eval("/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ \"../../../node_modules/@babel/runtime/helpers/defineProperty.js\");\n/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime/helpers/asyncToGenerator.js\");\n/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/regenerator */ \"../../../node_modules/@babel/runtime/regenerator/index.js\");\n/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n/*\n * Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n/**\n* \n* @description Fetch data from a SAS Table\n* @async\n* @module computeFetchData\n* @category restaflib/compute\n* @param {object} store - restaf store\n* @param {computeSummary} computeSummary - Summary object created by computeSummary method\n* @param {string} table - name of the table\n* @param {string} scroll direction - null(to get first set)|next|prev|first|last\n* @param {object} payload - query values\n* \n* @returns {promise} - {columns: <columnames>, rows: <data for rows> , scrollOptions: <available scroll directions>}\n*/\nfunction computeFetchData(_x, _x2, _x3, _x4, _x5, _x6) {\n return _computeFetchData.apply(this, arguments);\n}\nfunction _computeFetchData() {\n _computeFetchData = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee(store, computeSummary, table, direction, payload, useRow) {\n var data, tname, ipayload, adhoc, tableInfo, t1, colCount, qc, columns, schema, items, linkRel, cx, c, newcol, result, rowsData, current, dir, _result, _rowsData;\n return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n data = null;\n tname = typeof table === 'string' ? table : \"\".concat(table.libref, \".\").concat(table.name);\n tname = tname.toUpperCase(); /*to allow for compute service table info */\n ipayload = payload != null ? _objectSpread({}, payload) : {\n qs: {}\n };\n ipayload.qs.includeIndex = true;\n\n // is payload an override or the real thing?\n adhoc = payload != null && direction == null ? true : false;\n tableInfo = computeSummary.tables[tname];\n if (!(tableInfo != null)) {\n _context.next = 45;\n break;\n }\n // reset info on this table if user does adhoc retrieval\n // trying to keep track of multiple streams for same table is a nightmare\n if (adhoc === true) {\n tableInfo.current = null;\n }\n if (!(tableInfo.current === null || direction == null || direction === 'first')) {\n _context.next = 33;\n break;\n }\n _context.next = 12;\n return store.apiCall(tableInfo.self);\n case 12:\n t1 = _context.sent;\n colCount = t1.items().toJS()['columnCount']; // get columns explicitly since user can control this thru payload\n qc = {\n qs: {\n start: 0,\n limit: colCount\n }\n };\n _context.next = 17;\n return store.apiCall(t1.links('columns'), qc);\n case 17:\n columns = _context.sent;\n schema = [];\n items = columns.items().toJS();\n linkRel = useRow === 'rows' ? 'rows' : 'rowSet';\n if (linkRel === 'rows') {\n schema.push({\n name: '_index_',\n Column: '_Index_',\n Label: 'Index',\n length: 8,\n type: 'FLOAT',\n custom: false\n });\n }\n for (cx in items) {\n c = items[cx];\n newcol = {\n name: c.name.toLowerCase(),\n Column: c.name.toLowerCase(),\n Label: c.data.label,\n length: c.data.length,\n type: c.data.type,\n custom: false\n };\n schema.push(newcol);\n }\n\n // Now get data using rows or rowSet rel\n // should probably drop rowSet since is seems to be missing query features\n _context.next = 25;\n return store.apiCall(t1.links(linkRel), ipayload);\n case 25:\n result = _context.sent;\n // If using linkRel of rows, convert the data to rowSet schema\n rowsData = linkRel === 'rowSet' ? result.items().toJS().rows : cells2RowSet(schema, result);\n tableInfo.current = result;\n tableInfo.schema = schema;\n tableInfo.columns = columns;\n data = {\n columns: columns,\n /* need to remove this */\n schema: schema,\n rows: rowsData,\n scrollOptions: result.scrollCmds().keySeq().toJS()\n };\n _context.next = 45;\n break;\n case 33:\n current = tableInfo.current;\n dir = direction;\n if (direction === 'next' && current.scrollCmds('next') === null) {\n dir = current.links('last') !== null ? 'last' : null;\n }\n if (direction === 'prev' && current.scrollCmds('prev') === null) {\n dir = current.links('first') !== null ? 'first' : null;\n }\n data = {\n schema: tableInfo.schema,\n columns: tableInfo.columns,\n rows: [],\n scrollOptions: current.scrollCmds().keySeq().toJS()\n };\n if (!(dir !== null && current.scrollCmds(dir) !== null)) {\n _context.next = 45;\n break;\n }\n _context.next = 41;\n return store.apiCall(current.scrollCmds(dir), ipayload);\n case 41:\n _result = _context.sent;\n tableInfo.current = _result;\n _rowsData = useRow !== 'rows' ? _result.items().toJS().rows : cells2RowSet(tableInfo.schema, _result);\n data = {\n schema: tableInfo.schema,\n columns: tableInfo.schema,\n rows: _rowsData,\n scrollOptions: _result.scrollCmds().keySeq().toJS()\n };\n case 45:\n return _context.abrupt(\"return\", data);\n case 46:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return _computeFetchData.apply(this, arguments);\n}\nfunction cells2RowSet(schema, result) {\n var rowsData = result.items().toJS().map(function (r) {\n var cell = r.cells;\n return cell;\n });\n return rowsData;\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (computeFetchData);\n\n/*\nlet cell = r.cells; \n let row = {};\n for (let j=0; j < cell.length; j++ ){\n let colName = schema[j].name;\n row[colName] = cell[j];\n }\n return row;\n*/\n\n//# sourceURL=webpack://restaflib/./computeFetchData.js?");
|
|
849
|
+
eval("/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ \"../../../node_modules/@babel/runtime/helpers/defineProperty.js\");\n/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime/helpers/asyncToGenerator.js\");\n/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/regenerator */ \"../../../node_modules/@babel/runtime/regenerator/index.js\");\n/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n/*\r\n * Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\r\n * SPDX-License-Identifier: Apache-2.0\r\n */\n/**\r\n* \r\n* @description Fetch data from a SAS Table\r\n* @async\r\n* @module computeFetchData\r\n* @category restaflib/compute\r\n* @param {object} store - restaf store\r\n* @param {computeSummary} computeSummary - Summary object created by computeSummary method\r\n* @param {string} table - name of the table\r\n* @param {string} scroll direction - null(to get first set)|next|prev|first|last\r\n* @param {object} payload - query values\r\n* \r\n* @returns {promise} - {columns: <columnames>, rows: <data for rows> , scrollOptions: <available scroll directions>}\r\n*/\nfunction computeFetchData(_x, _x2, _x3, _x4, _x5, _x6) {\n return _computeFetchData.apply(this, arguments);\n}\nfunction _computeFetchData() {\n _computeFetchData = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee(store, computeSummary, table, direction, payload, useRow) {\n var data, tname, ipayload, adhoc, tableInfo, t1, colCount, qc, columns, schema, items, linkRel, cx, c, newcol, result, rowsData, current, dir, _result, _rowsData;\n return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n data = null;\n tname = typeof table === 'string' ? table : \"\".concat(table.libref, \".\").concat(table.name);\n tname = tname.toUpperCase(); /*to allow for compute service table info */\n ipayload = payload != null ? _objectSpread({}, payload) : {\n qs: {}\n };\n ipayload.qs.includeIndex = true;\n\n // is payload an override or the real thing?\n adhoc = payload != null && direction == null ? true : false;\n tableInfo = computeSummary.tables[tname];\n if (!(tableInfo != null)) {\n _context.next = 45;\n break;\n }\n // reset info on this table if user does adhoc retrieval\n // trying to keep track of multiple streams for same table is a nightmare\n if (adhoc === true) {\n tableInfo.current = null;\n }\n if (!(tableInfo.current === null || direction == null || direction === 'first')) {\n _context.next = 33;\n break;\n }\n _context.next = 12;\n return store.apiCall(tableInfo.self);\n case 12:\n t1 = _context.sent;\n colCount = t1.items().toJS()['columnCount']; // get columns explicitly since user can control this thru payload\n qc = {\n qs: {\n start: 0,\n limit: colCount\n }\n };\n _context.next = 17;\n return store.apiCall(t1.links('columns'), qc);\n case 17:\n columns = _context.sent;\n schema = [];\n items = columns.items().toJS();\n linkRel = useRow === 'rows' ? 'rows' : 'rowSet';\n if (linkRel === 'rows') {\n schema.push({\n name: '_index_',\n Column: '_Index_',\n Label: 'Index',\n length: 8,\n type: 'FLOAT',\n custom: false\n });\n }\n for (cx in items) {\n c = items[cx];\n newcol = {\n name: c.name.toLowerCase(),\n Column: c.name.toLowerCase(),\n Label: c.data.label,\n length: c.data.length,\n type: c.data.type,\n custom: false\n };\n schema.push(newcol);\n }\n\n // Now get data using rows or rowSet rel\n // should probably drop rowSet since is seems to be missing query features\n _context.next = 25;\n return store.apiCall(t1.links(linkRel), ipayload);\n case 25:\n result = _context.sent;\n // If using linkRel of rows, convert the data to rowSet schema\n rowsData = linkRel === 'rowSet' ? result.items().toJS().rows : cells2RowSet(schema, result);\n tableInfo.current = result;\n tableInfo.schema = schema;\n tableInfo.columns = columns;\n data = {\n columns: columns,\n /* need to remove this */\n schema: schema,\n rows: rowsData,\n scrollOptions: result.scrollCmds().keySeq().toJS()\n };\n _context.next = 45;\n break;\n case 33:\n current = tableInfo.current;\n dir = direction;\n if (direction === 'next' && current.scrollCmds('next') === null) {\n dir = current.links('last') !== null ? 'last' : null;\n }\n if (direction === 'prev' && current.scrollCmds('prev') === null) {\n dir = current.links('first') !== null ? 'first' : null;\n }\n data = {\n schema: tableInfo.schema,\n columns: tableInfo.columns,\n rows: [],\n scrollOptions: current.scrollCmds().keySeq().toJS()\n };\n if (!(dir !== null && current.scrollCmds(dir) !== null)) {\n _context.next = 45;\n break;\n }\n _context.next = 41;\n return store.apiCall(current.scrollCmds(dir), ipayload);\n case 41:\n _result = _context.sent;\n tableInfo.current = _result;\n _rowsData = useRow !== 'rows' ? _result.items().toJS().rows : cells2RowSet(tableInfo.schema, _result);\n data = {\n schema: tableInfo.schema,\n columns: tableInfo.schema,\n rows: _rowsData,\n scrollOptions: _result.scrollCmds().keySeq().toJS()\n };\n case 45:\n return _context.abrupt(\"return\", data);\n case 46:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return _computeFetchData.apply(this, arguments);\n}\nfunction cells2RowSet(schema, result) {\n var rowsData = result.items().toJS().map(function (r) {\n var cell = r.cells;\n return cell;\n });\n return rowsData;\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (computeFetchData);\n\n/*\r\nlet cell = r.cells; \r\n let row = {};\r\n for (let j=0; j < cell.length; j++ ){\r\n let colName = schema[j].name;\r\n row[colName] = cell[j];\r\n }\r\n return row;\r\n*/\n\n//# sourceURL=webpack://restaflib/./computeFetchData.js?");
|
|
850
850
|
|
|
851
851
|
/***/ }),
|
|
852
852
|
|
|
@@ -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 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,promote);\\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 status=rc/\\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\\n path=sashdat;\\n\\n if (promote eq true) then do;\\n table.promote result=r status=rc/\\n caslib=caslib name=target quiet=true\\n targetLib=caslib target=target;\\n if (rc.severity eq 2) then do;\\n print rc;\\n print 'Ignoring error';\\n end;\\n r = 0;\\n return r;\\n\\n end;\\n function saveAndPromoteTable(caslib, target, source);\\n sashdat = target||\\\".sashdat\\\";\\n rc = checkAndLoadTable(caslib, source);\\n table.droptable /\\n caslib=caslib name=target quiet=true;\\n\\n table.save /\\n caslib= caslib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n \\n table.loadtable result=r/\\n caslib=caslib casout={caslib=caslib name=target replace=TRUE}\\n path=sashdat;\\n\\n table.promote result=r status=rc/\\n caslib=caslib name=target quiet=true\\n targetLib=caslib target=target;\\n print rc;\\n r = rc.severity;\\n if (rc.severity gt 0) then do;\\n print rc;\\n print 'Ignoring error';\\n rc = 0;\\n end;\\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 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 action table.loadTable status=status/ \\n caslib = caslib \\n source = path \\n casout={caslib= caslib name=name}; \\n 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,promote);\\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 status=rc/\\n caslib=targetlib casout={caslib=targetlib name=target replace=TRUE}\\n path=sashdat;\\n \\n if (promote eq true) then do;\\n table.promote result=r status=rc/\\n caslib=caslib name=target quiet=true\\n targetLib=caslib target=target;\\n if (rc.severity eq 2) then do;\\n print rc;\\n print 'Ignoring error';\\n end;\\n r = 0;\\n return r;\\n \\n end;\\n \\n unction 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 if (upcase(n) eq nameu) then do; \\n count = count + 1; \\n if ( cpath eq '*') then do; \\n cpath = n; \\n end; \\n 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; \\n end; \\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 function saveAndPromoteTable(caslib, target, source);\\n sashdat = target||\\\".sashdat\\\";\\n rc = checkAndLoadTable(caslib, source);\\n table.droptable /\\n caslib=caslib name=target quiet=true;\\n \\n table.save /\\n caslib= caslib name=sashdat\\n table = {caslib=caslib name=source} replace=true;\\n \\n table.loadtable result=r/\\n caslib=caslib casout={caslib=caslib name=target replace=TRUE}\\n path=sashdat;\\n \\n table.promote result=r status=rc/\\n caslib=caslib name=target quiet=true\\n targetLib=caslib target=target;\\n print rc;\\n r = rc.severity;\\n if (rc.severity gt 0) then do;\\n print rc;\\n print 'Ignoring error';\\n rc = 0;\\n end;\\n \\n return r;\\n end;\\n \\n end;\\n \\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
|
|
|
@@ -1417,7 +1417,7 @@ eval("/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_
|
|
|
1417
1417
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1418
1418
|
|
|
1419
1419
|
"use strict";
|
|
1420
|
-
eval("/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime/helpers/slicedToArray.js\");\n/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./uploadHandlers */ \"./uploadHandlers/index.js\");\n\n/*\n * Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * parse a source file name\n * @module uploadSetup\n * @private\n * @param {string} source - the source file( absolute or relative path can be used)\n * @returns {object} - returns {ext: file-extension, fileOptions: <option for fread>, transform: transform for content-type, contentType: content-type}\n * @alias module: uploadSetup\n * @example\n * let t = uploadSetup('./cars.sashdat');\n */\n\nfunction uploadSetup(source, output) {\n var fileOptions = null; /* option for file reader */\n var contentType = 'binary/octet-stream'; /* header content-type on API call */\n\n var fileType; /* fileType for use in API call */\n var handler = _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__[/* uploadSrc */ \"c\"];\n var transform = noChange;\n var fext;\n if (source == null) {\n fext = 'csv';\n } else {\n fext = source.split('.').pop().toLowerCase();\n }\n switch (fext) {\n case 'sas7bdat':\n {\n fileType = 'basesas';\n break;\n }\n case 'sashdat':\n {\n fileType = 'hdat';\n break;\n }\n case 'csv':\n {\n fileType = fext;\n fileOptions = 'UTF8';\n break;\n }\n case 'xslx':\n case 'xsl':\n {\n fileType = fext;\n break;\n }\n case 'astore':\n case 'sasast':\n {\n fileType = fext;\n handler = _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__[/* uploadAstore */ \"b\"];\n transform = toBase64;\n break;\n }\n case 'ds2':\n case 'sas':\n {\n fileType = 'csv';\n fileOptions = 'UTF8';\n handler = _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__[/* uploadSrc */ \"c\"];\n transform = toCsv;\n break;\n }\n default:\n {\n throw \"Currently file type of \".concat(fext, \" is not supported\");\n }\n }\n var _output$split = output.split('.'),\n _output$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_output$split, 2),\n caslib = _output$split2[0],\n name = _output$split2[1];\n return {\n source: source,\n output: {\n caslib: caslib,\n name: name.toLowerCase()\n },\n fileType: fileType /* for cas actions */,\n fileExt: fext,\n fileOptions: fileOptions,\n transform: transform,\n contentType: contentType,\n handler: handler\n };\n function toBase64(data) {\n return new Buffer.from(data).toString('base64');\n }\n function toCsv(data, fileInfo) {\n // preprocess to get rid of things that upset datastep\n // eslint-disable-next-line no-control-regex\n var isrc = data.replace(/[^\\x00-\\x7F]/g, '');\n var src = isrc.replace(/\\r?\\n/g, '');\n // convert to a csv\n var fileType = fileInfo.fileExt;\n var varname = fileType === 'sas' ? 'dataStepSrc' : fileType === 'ds2' ? 'ds2Src' : fileType === 'casl' ? 'caslSrc' : 'dataStepsrc';\n var csv = 'modelName' + '\\\\' + varname + '\\n' + fileInfo.output.name + '\\\\' + ' ' + src + '\\n';\n return csv;\n }\n function noChange(data) {\n return data;\n }\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (uploadSetup);\n\n//# sourceURL=webpack://restaflib/./uploadSetup.js?");
|
|
1420
|
+
eval("/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime/helpers/slicedToArray.js\");\n/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./uploadHandlers */ \"./uploadHandlers/index.js\");\n\n/*\r\n * Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\r\n * SPDX-License-Identifier: Apache-2.0\r\n */\n\n/**\r\n * parse a source file name\r\n * @module uploadSetup\r\n * @private\r\n * @param {string} source - the source file( absolute or relative path can be used)\r\n * @returns {object} - returns {ext: file-extension, fileOptions: <option for fread>, transform: transform for content-type, contentType: content-type}\r\n * @alias module: uploadSetup\r\n * @example\r\n * let t = uploadSetup('./cars.sashdat');\r\n */\n\nfunction uploadSetup(source, output) {\n var fileOptions = null; /* option for file reader */\n var contentType = 'binary/octet-stream'; /* header content-type on API call */\n\n var fileType; /* fileType for use in API call */\n var handler = _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__[/* uploadSrc */ \"c\"];\n var transform = noChange;\n var fext;\n if (source == null) {\n fext = 'csv';\n } else {\n fext = source.split('.').pop().toLowerCase();\n }\n switch (fext) {\n case 'sas7bdat':\n {\n fileType = 'basesas';\n break;\n }\n case 'sashdat':\n {\n fileType = 'hdat';\n break;\n }\n case 'csv':\n {\n fileType = fext;\n fileOptions = 'UTF8';\n break;\n }\n case 'xslx':\n case 'xsl':\n {\n fileType = fext;\n break;\n }\n case 'astore':\n case 'sasast':\n {\n fileType = fext;\n handler = _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__[/* uploadAstore */ \"b\"];\n transform = toBase64;\n break;\n }\n case 'ds2':\n case 'sas':\n {\n fileType = 'csv';\n fileOptions = 'UTF8';\n handler = _uploadHandlers__WEBPACK_IMPORTED_MODULE_1__[/* uploadSrc */ \"c\"];\n transform = toCsv;\n break;\n }\n default:\n {\n throw \"Currently file type of \".concat(fext, \" is not supported\");\n }\n }\n var _output$split = output.split('.'),\n _output$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_output$split, 2),\n caslib = _output$split2[0],\n name = _output$split2[1];\n return {\n source: source,\n output: {\n caslib: caslib,\n name: name.toLowerCase()\n },\n fileType: fileType /* for cas actions */,\n fileExt: fext,\n fileOptions: fileOptions,\n transform: transform,\n contentType: contentType,\n handler: handler\n };\n function toBase64(data) {\n return new Buffer.from(data).toString('base64');\n }\n function toCsv(data, fileInfo) {\n // preprocess to get rid of things that upset datastep\n // eslint-disable-next-line no-control-regex\n var isrc = data.replace(/[^\\x00-\\x7F]/g, '');\n var src = isrc.replace(/\\r?\\n/g, '');\n // convert to a csv\n var fileType = fileInfo.fileExt;\n var varname = fileType === 'sas' ? 'dataStepSrc' : fileType === 'ds2' ? 'ds2Src' : fileType === 'casl' ? 'caslSrc' : 'dataStepsrc';\n var csv = 'modelName' + '\\\\' + varname + '\\n' + fileInfo.output.name + '\\\\' + ' ' + src + '\\n';\n return csv;\n }\n function noChange(data) {\n return data;\n }\n}\n/* harmony default export */ __webpack_exports__[\"a\"] = (uploadSetup);\n\n//# sourceURL=webpack://restaflib/./uploadSetup.js?");
|
|
1421
1421
|
|
|
1422
1422
|
/***/ }),
|
|
1423
1423
|
|