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.
53 lines
1.8 KiB
JavaScript
53 lines
1.8 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"))
|
|
const dcLibref = 'DC_JSLIB'
|
|
const dataDir = nodePath.resolve(driveRoot, 'files', appLoc, 'data', dcLibref)
|
|
|
|
// Helper: load a table JSON file
|
|
function loadTableData(tableName) {
|
|
try {
|
|
const file = nodePath.resolve(dataDir, tableName.toLowerCase() + '.json')
|
|
return JSON.parse(fs.readFileSync(file, {encoding:'utf8'}).toString())
|
|
} catch(err) { return null }
|
|
}
|
|
|
|
// Build groups list from MPE_GROUPS data (one row per group_name + user_name)
|
|
// The real Viya service queries the identity provider for custom groups;
|
|
// the mock derives them from the MPE_GROUPS table instead.
|
|
let groups = []
|
|
const groupsData = loadTableData('MPE_GROUPS')
|
|
if (groupsData && groupsData.rows) {
|
|
const seen = new Set()
|
|
for (const r of groupsData.rows) {
|
|
const groupName = r.GROUP_NAME || r.group_name
|
|
const groupDesc = r.GROUP_DESC || r.group_desc
|
|
if (groupName && !seen.has(groupName)) {
|
|
seen.add(groupName)
|
|
groups.push({
|
|
GROUPDESC: groupDesc || ' ',
|
|
GROUPURI: groupName,
|
|
GROUPNAME: groupName
|
|
})
|
|
}
|
|
}
|
|
groups.sort((a, b) => a.GROUPNAME.localeCompare(b.GROUPNAME))
|
|
}
|
|
|
|
// Always include the AllUsers group so the frontend can reference it
|
|
if (!groups.find(g => g.GROUPNAME === 'AllUsers')) {
|
|
groups.unshift({
|
|
GROUPDESC: 'Group contains all users',
|
|
GROUPURI: 'AllUsers',
|
|
GROUPNAME: 'AllUsers'
|
|
})
|
|
}
|
|
|
|
webout('OPEN')
|
|
webout('OBJ', 'groups', groups)
|
|
webout('CLOSE')
|