@@ -17,8 +17,6 @@ const toStringTree = (tab: string = '', type: FnType<Type, Type, any> | FnRxType
1717export class FnType < Req extends Type , Res extends Type , Ctx = unknown > extends AbsType <
1818 schema . FnSchema < SchemaOf < Req > , SchemaOf < Res > , Ctx >
1919> {
20- public fn : schema . FunctionValue < schema . TypeOf < SchemaOf < Req > > , schema . TypeOf < SchemaOf < Res > > > = fnNotImplemented ;
21-
2220 constructor (
2321 public readonly req : Req ,
2422 public readonly res : Res ,
@@ -68,6 +66,11 @@ export class FnType<Req extends Type, Res extends Type, Ctx = unknown> extends A
6866 } ;
6967 }
7068
69+ public default ( value : schema . FunctionValue < schema . TypeOf < SchemaOf < Req > > , schema . TypeOf < SchemaOf < Res > > > ) : this {
70+ this . schema . default = value ;
71+ return this ;
72+ }
73+
7174 public toString ( tab : string = '' ) : string {
7275 return super . toString ( tab ) + toStringTree ( tab , this ) ;
7376 }
@@ -89,22 +92,34 @@ export class FnRxType<Req extends Type, Res extends Type, Ctx = unknown> extends
8992 } as any ) ;
9093 }
9194
92- public request < T extends Type > ( req : T ) : FnType < T , Res > {
95+ public input < T extends Type > ( req : T ) : FnRxType < T , Res > {
96+ return this . inp ( req ) ;
97+ }
98+
99+ public inp < T extends Type > ( req : T ) : FnRxType < T , Res > {
93100 ( this as any ) . req = req ;
94101 return this as any ;
95102 }
96103
97- public inp < T extends Type > ( req : T ) : FnType < T , Res > {
98- return this . request ( req ) ;
104+ public output < T extends Type > ( res : T ) : FnRxType < Req , T > {
105+ return this . out ( res ) ;
99106 }
100107
101- public response < T extends Type > ( res : T ) : FnType < Req , T > {
108+ public out < T extends Type > ( res : T ) : FnRxType < Req , T > {
102109 ( this as any ) . res = res ;
103110 return this as any ;
104111 }
105112
106- public out < T extends Type > ( res : T ) : FnType < Req , T > {
107- return this . response ( res ) ;
113+ public io < I extends Type , O extends Type > ( request : I , response : O ) : FnRxType < I , O , Ctx > {
114+ return this . inp ( request ) . out ( response ) as FnRxType < I , O , Ctx > ;
115+ }
116+
117+ public signature < I extends Type , O extends Type > ( request : I , response : O ) : FnRxType < I , O , Ctx > {
118+ return this . io ( request , response ) as FnRxType < I , O , Ctx > ;
119+ }
120+
121+ public ctx < T > ( ) : FnRxType < Req , Res , T > {
122+ return this as any ;
108123 }
109124
110125 public getSchema ( ) : schema . FnRxSchema < SchemaOf < Req > , SchemaOf < Res > , Ctx > {
@@ -115,6 +130,11 @@ export class FnRxType<Req extends Type, Res extends Type, Ctx = unknown> extends
115130 } ;
116131 }
117132
133+ public default ( value : schema . FnStreamingValue < schema . TypeOf < SchemaOf < Req > > , schema . TypeOf < SchemaOf < Res > > > ) : this {
134+ this . schema . default = value ;
135+ return this ;
136+ }
137+
118138 public toString ( tab : string = '' ) : string {
119139 return super . toString ( tab ) + toStringTree ( tab , this ) ;
120140 }
0 commit comments