fix(mocks): drop derived variables before staging

stagedata.sas removes the MPE_DERIVED droplist from the submitted data before
anything is staged, and writes its approval CSV from that stripped dataset - the
mock staged the derived columns into both.
This commit is contained in:
dc committed 2026-10-24 20:30:17 +00:00
1 parent c4021a42ff
commit 73d25b1220
1 file changed
+23
@@ -104,6 +104,29 @@ if (rkName && !jsDataHeaders.some((h) => h.toUpperCase() === rkName.toUpperCase(
jsDataHeaders.push(rkName)
}
// ─── Derived variables ───────────────────────────────────────────────────────
// stagedata.sas drops the MPE_DERIVED droplist from the submitted data before
// anything is staged (they are display-only), and the approval CSV is written
// from that stripped dataset - so neither the staged rows nor the pack may
// carry them.
const derivedVars = mpeDerived({
libref,
table: dsn,
dataDir: mpeDataDir,
columns: schema
})
if (derivedVars.length > 0) {
const derivedNames = new Set(derivedVars.map((d) => d.name.toUpperCase()))
const keep = (key) => !derivedNames.has(key.toUpperCase())
jsDataHeaders = jsDataHeaders.filter(keep)
jsDataRows = jsDataRows.map((row) => {
const copy = {}
for (const key of Object.keys(row)) if (keep(key)) copy[key] = row[key]
return copy
})
}
// ─── Stage the data ──────────────────────────────────────────────────────────
// One subfolder per submission (DSID) under the staging directory, so that the
// staged data can sit alongside related artifacts (submit/approval logs,