The SASjs Server emits a webout() block into every JS program it runs (@sasjs/utils >= 4.4, server >= 3.12.0), mirroring %ms_webout in @sasjs/core: OPEN, ARR, OBJ, CLOSE. Ten of the mock services are two-year functional implementations of their SAS counterparts, and they were hand-building that same envelope through dcMockUtils' webOutOpen/Obj/Close. Move those ten onto webout(), so the response envelope is built by the runtime that owns it - real SYSUSERID, SYSPROCESSNAME, host name, a numeric SYSCC and a content-type header - instead of constants in a mock. The services that send showmeta metadata stay on the dcMockUtils helpers, which webout() has no argument for yet. The old 3.6.2 server pin in release, lighthouse and sites predates the block, so those three move to 3.12.2 with it.
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
const nodePath = require('path')
|
|
|
|
let appLoc = nodePath.join(..._program.split('services')[0].split('/'))
|
|
const sasjsRoot = nodePath.resolve(weboutPath, '..', '..', '..')
|
|
const driveRoot = nodePath.resolve(sasjsRoot, 'drive')
|
|
|
|
eval(fs.readFileSync(nodePath.resolve(driveRoot, 'files', appLoc, 'services', 'dcMockUtils.js'), 'utf8'))
|
|
|
|
// Parse input: SASControlTable.MPLIB is the libref to list tables for.
|
|
const _sctRow = fetchTable('SASControlTable')[0] || {}
|
|
const mplib = (_sctRow.MPLIB || _sctRow.mplib || '').toString().trim()
|
|
|
|
// Build mptables from all JSON files in the requested library's data folder.
|
|
// Each JSON file is one table; its `name` field is the table (MEMNAME).
|
|
let mptables = []
|
|
if (mplib) {
|
|
const dataDir = libDataDir(mplib)
|
|
try {
|
|
const files = fs.readdirSync(dataDir)
|
|
for (const f of files) {
|
|
if (f.endsWith('.json')) {
|
|
try {
|
|
const raw = fs.readFileSync(nodePath.resolve(dataDir, f), {encoding:'utf8'}).toString()
|
|
const tableData = JSON.parse(raw)
|
|
if (tableData.name) {
|
|
mptables.push({ MEMNAME: tableData.name })
|
|
}
|
|
} catch(e) {}
|
|
}
|
|
}
|
|
mptables.sort((a, b) => a.MEMNAME.localeCompare(b.MEMNAME))
|
|
} catch(err) {}
|
|
}
|
|
|
|
webout('OPEN')
|
|
webout('OBJ', 'mptables', mptables)
|
|
webout('OBJ', 'libinfo', [])
|
|
webout('CLOSE')
|