import fs from 'node:fs/promises'; import path from 'node:path'; import assert from 'node:assert/strict'; import { loadPublicBoard, publicBoardAction } from '../src/services/workshop-data.js'; const work = path.resolve('work/ksf-workshop-board-20261110-r1'); const out = path.resolve('docs/ksf-workshop-board-20261110-r1/package/evidence'); const connection = { url: 'https://kangshifu.fmode.cn/api/functions', appId: 'FKieRbIoGt_main' }; const [before, groupsBefore, receipt, current, groups] = await Promise.all([ fs.readFile(path.join(work, 'public-before.json')).then(JSON.parse), fs.readFile(path.join(work, 'groups-before.json')).then(JSON.parse), fs.readFile(path.join(work, 'series-deployment.json')).then(JSON.parse), loadPublicBoard(connection), publicBoardAction({ ...connection, name: 'ksfGetPublicMemberGroups', params: {} }), ]); for (const kind of ['project', 'artifact', 'insight', 'source', 'session', 'opportunity']) { const normalize = rows => rows.map(row => Object.fromEntries(Object.entries(row).filter(([key]) => key !== 'reportSeriesKey'))) .sort((a, b) => String(a.objectId).localeCompare(String(b.objectId))); assert.deepEqual(normalize(current[kind]), normalize(before[kind]), kind + ' changed beyond the added field'); } assert.deepEqual(groups, groupsBefore, 'Shared groups changed'); const withSeries = current.artifact.filter(a => a.reportSeriesKey); assert.ok(withSeries.length > 0, 'Series field is absent from public response'); await fs.writeFile(path.join(work, 'public-after.json'), JSON.stringify(current)); await fs.writeFile(path.join(work, 'groups-after.json'), JSON.stringify(groups)); const { backup, ...safeReceipt } = receipt; const result = { schema: 'ksf.workshop-board.public-api-acceptance.v1', checkedAt: new Date().toISOString(), functionDeployment: safeReceipt, publicReadbackPassed: true, counts: Object.fromEntries(['project', 'artifact', 'insight', 'source', 'session', 'opportunity'].map(k => [k, current[k].length])), artifactsWithSeries: withSeries.length, originalPublicRecordsUnchanged: true, sharedGroupStateUnchanged: true, groups: groups.groups.length, groupsRevision: groups.revision, businessRowsChanged: 0, secretOrPrivateFunctionSourceIncluded: false }; await fs.writeFile(path.join(out, 'public-api-acceptance.json'), JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));