Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
ci/windows-dual-app-lab-20261016
ci/public-windows-bridge-probe-20261017
ci/windows-dispatch-bootstrap-20261016
ci/windows-dual-app-lab-20261016
dev/v7-production-failclosed-20261021
feature/reconciliation-guard-20261013
main
phase-1-foundation
phase-1-implementation
phase-2-treasury-core
phase-3-banking-reconciliation
phase-4-operations-enterprise-ux
phase-5-hardening-release
phase-6-production-platform
phase-7-production-infrastructure-bank-golive
phase-7-sql-readonly-ux-20261015
transfer-exe-to-drive-20261006
| 1 | import sql from 'mssql'; |
| 2 | import type {ExternalSqlServerConfig} from './sql-server-adapter'; |
| 3 | |
| 4 | type Driver={connect:(config:any)=>Promise<any>}; |
| 5 | export class SqlServerAccountingAdapter{ |
| 6 | constructor(private config:ExternalSqlServerConfig,private driver:Driver=sql as unknown as Driver,private approvedWriteContract?:string){} |
| 7 | private driverConfig(){const c:any={server:this.config.server,database:this.config.database,options:{encrypt:this.config.encrypt??false,trustServerCertificate:this.config.trustServerCertificate??true}};if(this.config.auth==='sql'){c.user=this.config.user;c.password=this.config.password}else{c.options.trustedConnection=true}return c} |
| 8 | private async withPool<T>(fn:(pool:any)=>Promise<T>){const pool=await this.driver.connect(this.driverConfig());try{return await fn(pool)}finally{await pool.close()}} |
| 9 | async testConnection(){return this.withPool(async pool=>{const r=await pool.request().query('SELECT 1 AS ok');return {ok:Number(r.recordset?.[0]?.ok)===1}})} |
| 10 | async inspectSchema(){return this.withPool(async pool=>(await pool.request().query(`SELECT TABLE_SCHEMA AS schema_name,TABLE_NAME AS table_name,COLUMN_NAME AS column_name,DATA_TYPE AS data_type FROM INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_SCHEMA,TABLE_NAME,ORDINAL_POSITION`)).recordset)} |
| 11 | async executeApprovedWrite(_operation:string,_params:Record<string,unknown>){if(!this.approvedWriteContract)throw new Error('approved write contract required');throw new Error('write contract implementation not installed')} |
| 12 | } |