@@ -45,13 +45,22 @@ const ME = 'usr_nf_member';
4545const OTHER = 'usr_nf_other' ;
4646const CALLER = { userId : ME , positions : [ 'qa_pos' ] , permissions : [ 'qa_nf_guard' ] , posture : 'MEMBER' } ;
4747
48- type Rig = Awaited < ReturnType < typeof boot > > ;
48+ interface Refusal { code ?: string ; status ?: number ; message : string ; name ?: string }
49+ type Outcome = { kind : 'landed' } | ( { kind : 'refused' } & Refusal ) ;
50+
51+ interface Rig {
52+ engine : ObjectQL ;
53+ update : ( object : string , id : string , data ?: Record < string , unknown > ) => Promise < Outcome > ;
54+ remove : ( object : string , id : string ) => Promise < Outcome > ;
55+ stored : ( object : string , id : string ) => Promise < Record < string , unknown > | null > ;
56+ teardown : ( ) => Promise < void > ;
57+ }
4958const rigs : Rig [ ] = [ ] ;
5059afterEach ( async ( ) => {
5160 for ( const rig of rigs . splice ( 0 ) ) await rig . teardown ( ) ;
5261} ) ;
5362
54- async function boot ( ) {
63+ async function boot ( ) : Promise < Rig > {
5564 const engine = new ObjectQL ( ) ;
5665 engine . registerDriver (
5766 new SqlDriver ( { client : 'better-sqlite3' , connection : { filename : ':memory:' } , useNullAsDefault : true } ) as never ,
@@ -134,7 +143,7 @@ async function boot() {
134143 await plugin . init ( ctx as never ) ;
135144 await plugin . start ( ctx as never ) ;
136145
137- const rig = {
146+ const rig : Rig = {
138147 engine,
139148 update : ( object : string , id : string , data : Record < string , unknown > = { name : 'renamed' } ) =>
140149 outcome ( engine . update ( object , data , { where : { id } , context : { ...CALLER } } as never ) ) ,
@@ -148,9 +157,6 @@ async function boot() {
148157 return rig ;
149158}
150159
151- interface Refusal { code ?: string ; status ?: number ; message : string ; name ?: string }
152- type Outcome = { kind : 'landed' } | ( { kind : 'refused' } & Refusal ) ;
153-
154160function outcome ( p : Promise < unknown > ) : Promise < Outcome > {
155161 return p . then (
156162 ( ) => ( { kind : 'landed' as const } ) ,
0 commit comments