| 1234567891011121314151617181920 |
- // Read only: four exact ksfGetRecord calls; no import/save/update or retries.
- import fs from 'node:fs';
- import assert from 'node:assert/strict';
- import {invoke} from '../server/scripts/platform-client.mjs';
- const output='work/S4-public-record-inspection-20261103.json';
- assert.equal(fs.existsSync(output),false,'Preserve existing inspection');
- const targets=[['KfSource','PjORcvaRHn'],['KfEvidence','xHGV_mRWcG'],['KfSource','5S_Y4IgT5q'],['KfEvidence','CeAEIwymTa']];
- const keep=['objectId','title','sourceKind','sourceUrl','platform','rawText','collectedAt','contentHash','dataMode','recordState','reviewState','schemaVersion','externalKey','quote','locator','evidenceKind','verificationState','quoteForm','authorLabel','parentObjectId','publishedAt','productRef','artifactRef','sourceRef'];
- const settled=await Promise.allSettled(targets.map(async([className,objectId])=>{
- const response=await invoke('ksfGetRecord',{className,objectId});
- assert.equal(response.http,200);assert.equal(response.body?.result?.ok,true);
- const row=response.body.result.data.record;assert.equal(row?.objectId,objectId);
- return{className,objectId,requestId:response.body.result.requestId??null,record:Object.fromEntries(keep.filter(key=>Object.hasOwn(row,key)).map(key=>[key,row[key]]))};
- }));
- const failures=settled.flatMap((r,i)=>r.status==='rejected'?[targets[i]]:[]);
- const result={ok:failures.length===0,at:new Date().toISOString(),readOnly:true,businessWrites:0,readFunctionCalls:4,failures,records:settled.filter(r=>r.status==='fulfilled').map(r=>r.value)};
- fs.writeFileSync(output,JSON.stringify(result,null,2)+'\n',{flag:'wx'});
- console.log(JSON.stringify({ok:result.ok,readFunctionCalls:4,failures,records:result.records.map(({className,objectId,record})=>({className,objectId,characters:record.rawText?[...record.rawText].length:undefined,evidenceKind:record.evidenceKind,verificationState:record.verificationState,quoteForm:record.quoteForm,authorLabel:record.authorLabel,publishedAt:record.publishedAt,locatorKeys:record.locator?Object.keys(record.locator):undefined}))},null,2));
- if(failures.length)process.exitCode=1;
|