verify-workshop-board-api.mjs 2.3 KB

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