genosdb 0.36.0 → 0.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -1,2 +1,2 @@
1
1
  var log=(()=>{const n=()=>{};return new Proxy(console,{get:(c,m)=>globalThis.__gdbDebug?c[m].bind(c):n})})();
2
- var D=null,F=[],H=[],B=null,J=(q)=>!!q&&H.some((j)=>j&&j.toLowerCase()===q.toLowerCase()),L=async()=>{let q=new Map;for(let j of F){let x=j.then?.assignRole;if(!x)continue;let z=[];try{({results:z=[]}=await D.map({query:j.if}))}catch(f){log.error("❌ GOVERNANCE: rule evaluation failed.",{rule:j,error:f.message});continue}for(let f of z){if(!f.id.startsWith("user:"))continue;if(J(f.id.slice(5)))continue;if(j.offsetTimestamp&&(f.timestamp?.physical??0)>Date.now()-j.offsetTimestamp)continue;q.set(f.id,{role:x,current:f.value?.role})}}for(let[j,{role:x,current:z}]of q){if(z===x)continue;let f=j.slice(5);try{await D.sm.assignRole(f,x),log.info(`\uD83D\uDCDC GOVERNANCE: ${f} '${z}' -> '${x}'`)}catch(K){log.error("❌ GOVERNANCE: assignRole failed.",{target:f,role:x,error:K.message})}}},M=()=>{if(B)return;log.info("✅ GOVERNANCE ENGINE: activated (superadmin present)."),B=setInterval(L,4000)},N=()=>{if(!B)return;clearInterval(B),B=null,log.info("\uD83D\uDED1 GOVERNANCE ENGINE: deactivated.")},P=(q,{governanceRules:j,superAdmins:x}={})=>{if(!q||!j)return log.error("❌ GOVERNANCE: initialization failed — gdb instance and governanceRules are required.");D=q,F=j,H=x||[],q.sm.setGovernanceStateChangeCallback(({isActive:z,activeAddress:f})=>{if(z&&f&&J(f))M();else N()})};export{P as start};
2
+ var H=null,J=[],K=[],B=null,L=(q)=>!!q&&K.some((f)=>f&&f.toLowerCase()===q.toLowerCase()),D=new Map,N=({id:q,timestamp:f})=>{let x=`${f?.physical??0}:${f?.logical??0}`;if(D.get(q)?.stamp!==x)D.set(q,{stamp:x,since:Date.now()});return Date.now()-D.get(q).since},P=async()=>{let q=new Map;for(let f of J){let x=f.then?.assignRole;if(!x)continue;let z=[];try{({results:z=[]}=await H.map({query:f.if}))}catch(j){log.error("❌ GOVERNANCE: rule evaluation failed.",{rule:f,error:j.message});continue}for(let j of z){if(!j.id.startsWith("user:"))continue;if(L(j.id.slice(5)))continue;if(f.offsetTimestamp&&N(j)<f.offsetTimestamp)continue;q.set(j.id,{role:x,current:j.value?.role})}}for(let[f,{role:x,current:z}]of q){if(z===x)continue;let j=f.slice(5);try{await H.sm.assignRole(j,x),log.info(`\uD83D\uDCDC GOVERNANCE: ${j} '${z}' -> '${x}'`)}catch(M){log.error("❌ GOVERNANCE: assignRole failed.",{target:j,role:x,error:M.message})}}},Q=()=>{if(B)return;log.info("✅ GOVERNANCE ENGINE: activated (superadmin present)."),B=setInterval(P,4000)},U=()=>{if(!B)return;clearInterval(B),B=null,log.info("\uD83D\uDED1 GOVERNANCE ENGINE: deactivated.")},V=(q,{governanceRules:f,superAdmins:x}={})=>{if(!q||!f)return log.error("❌ GOVERNANCE: initialization failed — gdb instance and governanceRules are required.");H=q,J=f,K=x||[],q.sm.setGovernanceStateChangeCallback(({isActive:z,activeAddress:j})=>{if(z&&j&&L(j))Q();else U()})};export{V as start};
Binary file