Files
MikrotikManager/backend/scripts/writer-profile/catalogue-value-bridge.ts
T

16 lines
1.5 KiB
TypeScript

// Typed bounded VALUE -> fixed44 semantic bridge. Requires real EOF, never emits authority.
// SQL retained cursor/context/source-before-and-after remains the protected host's obligation.
import {CatalogueValueStream} from './application-writer-profile-catalogue-values.js'
import {Fixed44CatalogueDataVerifier,type InstallationRoleBindingsData} from './application-writer-profile-catalogue.js'
import type {CatalogueEdition} from './catalogue-projection.js'
export class Fixed44CatalogueValueBridgeData {
private readonly values=new CatalogueValueStream();private readonly schema:Fixed44CatalogueDataVerifier
private eof=false;private closed=false;private failed=false
constructor(bindings:InstallationRoleBindingsData,edition:CatalogueEdition=44){this.schema=new Fixed44CatalogueDataVerifier(bindings,edition)}
acceptPage(page:readonly unknown[]):void {
if(this.eof||this.closed||this.failed)throw Error('Closed/refused VALUE catalogue bridge')
try{for(const record of this.values.acceptPage(page))this.schema.consume(record);if(page.length===0)this.eof=true}catch(error){this.failed=true;throw error}
}
finish(){if(this.closed||this.failed||!this.eof)throw Error('Real cursor EOF required for VALUE catalogue bridge');try{const values=this.values.finish(),catalogue=this.schema.finish();this.closed=true;return Object.freeze({values,catalogue,authority:false,sourceGenerationAuthenticated:false,allWriterDrainAuthenticated:false,readyAuthorized:false})}catch(error){this.failed=true;throw error}}
}