@@ -98,6 +98,7 @@ export interface port {
98
98
now : ( ) => hrtime
99
99
} ,
100
100
fireEvent ( event : string , data : any , mapper ?: 'asyncMap' | 'reduce' ) ,
101
+ config : Record < string , unknown > ,
101
102
[ name : string ] : any
102
103
}
103
104
@@ -114,6 +115,29 @@ interface vfs {
114
115
readFileSync : typeof readFileSync ;
115
116
}
116
117
118
+ type info = ( ) => {
119
+ encrypt : object ,
120
+ sign : object ,
121
+ uri : string ,
122
+ port : number | string ,
123
+ host : string ,
124
+ address : undefined | string ,
125
+ protocol : 'http' | 'https' | 'socket'
126
+ }
127
+
128
+ interface serviceBus {
129
+ config : Record < string , unknown > ,
130
+ jsonrpc : object ,
131
+ rpc : {
132
+ info : info
133
+ } ,
134
+ publicApi : {
135
+ config : Record < string , unknown > ,
136
+ importMethod : ( name : string ) => ( params , $meta ) => any
137
+ info : info
138
+ }
139
+ }
140
+
117
141
type api < imports > = {
118
142
joi : joi . Root ,
119
143
/**
@@ -166,20 +190,7 @@ type api<imports> = {
166
190
version : ( version : string ) => boolean ,
167
191
vfs : vfs ,
168
192
callSite : ( ) => CallSiteLike ,
169
- utBus : {
170
- config : {
171
- workDir : string
172
- } ,
173
- info : ( ) => {
174
- encrypt : object ,
175
- sign : object ,
176
- uri : string ,
177
- port : number | string ,
178
- host : string ,
179
- address : undefined | string ,
180
- protocol : 'http' | 'https' | 'socket'
181
- }
182
- }
193
+ utBus : serviceBus [ 'publicApi' ]
183
194
}
184
195
185
196
interface genericExport {
@@ -345,13 +356,9 @@ export function run(params: {
345
356
root ?: string ,
346
357
resolve ?: ( string ) => string
347
358
} ) : Promise < {
348
- ports : { } [ ] ,
349
- portsMap : Record < string , any > ,
350
- serviceBus : {
351
- publicApi : {
352
- importMethod : ( name : string ) => ( params , $meta ) => any
353
- }
354
- } ,
359
+ ports : port [ ] ,
360
+ portsMap : Record < string , port > ,
361
+ serviceBus : serviceBus ,
355
362
log : any ,
356
363
logger : any ,
357
364
config : { } ,
@@ -368,8 +375,10 @@ export function microservice(module: Partial<NodeJS.Module>, require: NodeJS.Req
368
375
369
376
type Step < methods > = {
370
377
name : string ,
371
- params ?: ( ) => boolean ,
378
+ params ?: any ,
372
379
steps ?: ( ) => ( Step < methods > | string ) [ ]
380
+ result ?: ( this : any , result : any , assert : Tap . Test , $meta ?: meta ) => void ,
381
+ error ?: ( this : any , error : any , assert : Tap . Test , $meta ?: meta ) => void
373
382
} | {
374
383
[ Property in keyof methods ] : methods [ Property ] extends ( ( ...args : any ) => any ) ? {
375
384
method : Property ,
@@ -407,13 +416,13 @@ type Imported<methods> = {
407
416
408
417
export type test < methods > = ( ) => Record < string , (
409
418
test : unknown ,
410
- bus : unknown ,
419
+ bus : serviceBus ,
411
420
run : (
412
421
test : unknown ,
413
- bus : unknown ,
422
+ bus : serviceBus ,
414
423
steps : ( Step < methods > | string ) [ ]
415
424
) => unknown ,
416
- ports : { } [ ] ,
425
+ ports : port [ ] ,
417
426
steps : Record < string , Imported < methods > >
418
427
) => unknown > ;
419
428
0 commit comments