fix: recheck linked documents after Excel generation

This commit is contained in:
2026-09-06 15:14:29 +03:00
parent 4d6d7009ca
commit bdc9f9dfbf
4 changed files with 39 additions and 14 deletions
+21 -7
View File
@@ -19,6 +19,8 @@ const keyToken=signToken(keyUser);
let apiKeyListFailure=false;
let briefFailure='none';
let holdDocuments=false;
let skipDocumentReads=0,qaFiles=null,outputDocumentReads=0;
const qaFile={id:'qa-owned-file',ad:'QA zorunlu firma belgesi.pdf',tur:'firma',boyut:100,olusturma:'2026-09-06T00:00:00Z',erisilebilir:true};
const pendingDocuments=new Set();
process.env.IHALEIST_USER_DATA_DIR=dir;
const {createBriefOutbox}=await import('../server/brief-outbox.mjs');
@@ -104,14 +106,22 @@ const ui=await createServer({server:{host:'127.0.0.1',port:0,proxy:{'/api':{targ
}
if(req.url?.startsWith('/qa-output-documents?')&&req.method==='POST') {
const mode=new URL(req.url,'http://localhost').searchParams.get('mode');
if(mode==='hold')holdDocuments=true;
if(mode==='release'){holdDocuments=false;for(const pending of pendingDocuments){pending.writeHead(200,{'Content-Type':'application/json'});pending.end(JSON.stringify({success:true,belgeler:[]}));}pendingDocuments.clear();}
res.end('Belge yanıtı: '+mode);return;
if(mode==='hold'){holdDocuments=true;skipDocumentReads=0;outputDocumentReads=0;}
if(mode==='hold-final'){holdDocuments=true;skipDocumentReads=1;outputDocumentReads=0;}
if(mode==='revise')qaFiles=qaFiles?.map(file=>({...file,boyut:file.boyut+1}));
if(mode==='remove')qaFiles=[];
if(mode==='release'){holdDocuments=false;for(const pending of pendingDocuments){pending.writeHead(200,{'Content-Type':'application/json'});pending.end(JSON.stringify({success:true,belgeler:qaFiles || []}));}pendingDocuments.clear();}
res.end('Belge yanıtı: '+mode+'; okunan: '+outputDocumentReads+'; bekleyen: '+pendingDocuments.size);return;
}
if(req.url==='/api/me/documents'&&req.method==='GET'&&holdDocuments){pendingDocuments.add(res);res.on('close',()=>pendingDocuments.delete(res));return;}
if(req.url==='/qa-source-update'||req.url==='/qa-source-update?ready=1') {
const selected=req.url.endsWith('?ready=1')?readyBid(tenders[0]):tenders[0];
if(selected.bidDraft){const summary=preparationSummary(selected,{loading:false,error:null,documents:[]});if(summary.issues.length)throw new Error('QA ready fixture: '+JSON.stringify(summary.issues));}
if(req.url==='/api/me/documents'&&req.method==='GET'){
if(holdDocuments){outputDocumentReads++;if(skipDocumentReads>0)skipDocumentReads--;else{pendingDocuments.add(res);res.on('close',()=>pendingDocuments.delete(res));return;}}
if(qaFiles){res.writeHead(200,{'Content-Type':'application/json'});res.end(JSON.stringify({success:true,belgeler:qaFiles}));return;}
}
if(req.url==='/qa-source-update'||req.url==='/qa-source-update?ready=1'||req.url==='/qa-source-update?ready=1&file=1') {
const query=new URL(req.url,'http://localhost').searchParams;
qaFiles=query.has('file')?[{...qaFile}]:null;
const selected=query.has('ready')?readyBid(tenders[0],qaFiles?.[0]):tenders[0];
if(selected.bidDraft){const summary=preparationSummary(selected,{loading:false,error:null,documents:qaFiles || []});if(summary.issues.length)throw new Error('QA ready fixture: '+JSON.stringify(summary.issues));}
const html=`<html lang="tr"><head><meta name="viewport" content="width=device-width,initial-scale=1"></head><body><div id="root"></div><script type="module">
import React from '/node_modules/.vite/deps/react.js';
import ReactDOM from '/node_modules/.vite/deps/react-dom_client.js';
@@ -123,6 +133,10 @@ const ui=await createServer({server:{host:'127.0.0.1',port:0,proxy:{'/api':{targ
React.createElement('h1',{},'Yerel kaynak güncelleme testi'),
React.createElement('p',{},'Yalnız sentetik veri. Açık dosya korunurken güncel kaynak değişir.'),
React.createElement('button',{onClick:()=>control('hold')},'Belge yanıtını beklet'),
React.createElement('button',{onClick:()=>control('hold-final')},'Son belge kontrolünü beklet'),
React.createElement('button',{onClick:()=>control('revise')},'Bağlı belgenin sürümünü değiştir'),
React.createElement('button',{onClick:()=>control('remove')},'Bağlı belgeyi kaldır'),
React.createElement('button',{onClick:()=>control('status')},'Bekleyen belge isteklerini göster'),
React.createElement('button',{onClick:()=>control('release')},'Belge yanıtını serbest bırak'),
React.createElement('p',{role:'status'},status),
React.createElement('button',{onClick:()=>setTenders([{...selected,id:'qa-rotated-source',baslik:'QA Güncellenmiş alım',kazananFirma:'QA Kazanan'}])},'Aynı İKN için yeni kayıt ID ve kazanan yayımla'),