import fs from 'node:fs'; import assert from 'node:assert/strict'; import {compileFunction} from 'node:vm'; import {createRequire} from 'node:module'; import {createHash} from 'node:crypto'; import ts from 'typescript'; import React from 'react'; import {renderToStaticMarkup} from 'react-dom/server'; const require=createRequire(import.meta.url),root=new URL('../',import.meta.url),out=new URL('outputs/funding-directory-20261110/',root); const content=JSON.parse(fs.readFileSync(new URL('content-qa.json',out),'utf8')),dossier=JSON.parse(fs.readFileSync(new URL('dossier-qa.json',out),'utf8')); const records=Object.values(content.records),ids=Object.fromEntries(records.map(r=>[r.id,r.code])); assert.equal(records.length,11);assert.equal(records.filter(r=>r.payload.kind==='institution').length,7); assert.ok(content.cabo_delgado_investment_results.includes('bni'));assert.ok(!content.cabo_delgado_investment_results.includes('fcid-viii')); assert.equal(content.records.bni.payload.products[1].needs[0],'equity');assert.equal(content.records.semeia.payload.windows[0].state,'closed'); assert.equal(dossier.recovered.selections.length,1);assert.equal(dossier.recovered.selections[0].title,content.records.bni.payload.title); assert.equal(dossier.no_external_submission,true); const cache={}; function load(file){ if(cache[file])return cache[file]; const module={exports:{}};cache[file]=module.exports; const code=ts.transpileModule(fs.readFileSync(new URL('resources/js/'+file,root),'utf8'),{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,jsx:ts.JsxEmit.ReactJSX}}).outputText; compileFunction(code,['require','module','exports'])(name=>{ if(name==='@inertiajs/react')return {Link:({href,children,...props})=>{let target=href;if(href==='/fundos')target='../catalogo-qa.html';else if(typeof href==='string'&&href.startsWith('/fundos/')){const id=href.split('/')[2].split('?')[0];if(ids[id])target='fichas/'+ids[id]+'.html';}return React.createElement('a',{...props,href:target},children);},useForm:data=>({data,processing:false,setData:()=>{},get:()=>{}}),router:{}}; if(name==='@/pages/investment/shared')return {Frame:({title,children})=>React.createElement('main',{},React.createElement('h1',{},title),children),card:'card',button:'button'}; if(name==='./shared')return {windowLabels:{closed:'Janela encerrada',unknown:'Janela por confirmar',open:'Segundo datas documentadas'}}; if(name==='@/components/funding-classification')return load('components/funding-classification.tsx'); if(name==='@/components/funding-institution')return load('components/funding-institution.tsx'); if(name==='@/components/funding-dossier-choice')return {}; if(name==='@/components/funding-criteria-assessment')return {default:()=>null}; return require(name); },module,module.exports);cache[file]=module.exports;return module.exports; } const wrap=body=>'
Revisão QA — conteúdo fornecido; sem publicação na homologação. Renderização estática dos componentes; não é conferência visual num navegador. Não envia dados ou candidaturas.
'+body+''; fs.mkdirSync(new URL('fichas/',out),{recursive:true}); const Show=load('pages/funding/show.tsx').default,Index=load('pages/funding/index.tsx').default; for(const record of records){const html=renderToStaticMarkup(React.createElement(Show,{record,saved:null,authenticated:false}));assert.ok(html.includes(record.payload.title.replace(/&/g,'&')));fs.writeFileSync(new URL('fichas/'+record.code+'.html',out),wrap(html));} const catalogue=renderToStaticMarkup(React.createElement(Index,{items:{data:records,links:[]},filters:{},kinds:{institution:'Instituição financeira',fund:'Fundo',programme:'Programa'},management:false,options:{territories:[],sectors:[]},needs:{investment:'Investimento',working_capital:'Fundo de maneio'}})); fs.writeFileSync(new URL('catalogo-qa.html',out),wrap(catalogue)); const pkg=JSON.parse(fs.readFileSync(new URL('database/data/funding-references.json',root),'utf8')); assert.equal(Object.keys(pkg.references).length,12);assert.ok(pkg.references.fdel); const proof={provided_source_sha256:content.provided_source_sha256,provided_entries:12,prepared_fiches:11,institutions:7,programmes_or_funds:4,bni_capital:'BNI product; no duplicate institution',headquarters_and_lending_coverage_distinct:true,one_product_must_match_need_and_territory:true,unknowns_explicit:true,fcid_six_provinces:true,semeia_closed:true,dossier_save_recovery_native:true,one_selection_without_duplicate_event:true,withdrawn_public_source_snapshot_retained:true,qa_transactions_rolled_back:true,qa_port:55441,installed:false,live_publication:false,visual_review:'pending; browser connector unavailable',package_data_sha256:createHash('sha256').update(fs.readFileSync(new URL('database/data/funding-references.json',root))).digest('hex')}; fs.writeFileSync(new URL('verification.json',out),JSON.stringify(proof,null,2));console.log(JSON.stringify(proof));