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.
37 lines
1.5 KiB
JavaScript
37 lines
1.5 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)
|
|
|
|
// Load MPE_SUBMIT - return all submitted items that haven't been approved yet
|
|
let fromsas = []
|
|
try {
|
|
const file = nodePath.resolve(dataDir, 'mpe_submit.json')
|
|
const raw = fs.readFileSync(file, {encoding:'utf8'}).toString()
|
|
const submitData = JSON.parse(raw)
|
|
fromsas = submitData.rows
|
|
.filter(r => r.SUBMIT_STATUS_CD === 'SUBMITTED')
|
|
.map(r => ({
|
|
TABLE_ID: r.TABLE_ID,
|
|
REVIEW_STATUS_ID: r.SUBMIT_STATUS_CD,
|
|
SUBMITTED_BY_NM: r.SUBMITTED_BY_NM,
|
|
BASE_TABLE: r.BASE_LIB + '.' + r.BASE_DS,
|
|
SUBMITTED_ON_DTTM: ' ' + new Date(r.SUBMITTED_ON_DTTM * 1000).toISOString().replace('T',' ').replace(/\.\d+Z$/, ''),
|
|
SUBMITTED_ON_DTTM2: r.SUBMITTED_ON_DTTM,
|
|
SUBMITTED_REASON_TXT: r.SUBMITTED_REASON_TXT || '',
|
|
NUM_OF_APPROVALS_REQUIRED: r.NUM_OF_APPROVALS_REQUIRED,
|
|
NUM_OF_APPROVALS_REMAINING: r.NUM_OF_APPROVALS_REMAINING,
|
|
LIBREF: r.BASE_LIB,
|
|
DSN: r.BASE_DS
|
|
}))
|
|
} catch(err) {}
|
|
|
|
webout('OPEN')
|
|
webout('OBJ', 'fromsas', fromsas)
|
|
webout('CLOSE')
|