@@ -17,8 +17,6 @@ const toStringTree = (tab: string = '', type: FnType<Type, Type, any> | FnRxType
17
17
export class FnType < Req extends Type , Res extends Type , Ctx = unknown > extends AbsType <
18
18
schema . FnSchema < SchemaOf < Req > , SchemaOf < Res > , Ctx >
19
19
> {
20
- public fn : schema . FunctionValue < schema . TypeOf < SchemaOf < Req > > , schema . TypeOf < SchemaOf < Res > > > = fnNotImplemented ;
21
-
22
20
constructor (
23
21
public readonly req : Req ,
24
22
public readonly res : Res ,
@@ -68,6 +66,11 @@ export class FnType<Req extends Type, Res extends Type, Ctx = unknown> extends A
68
66
} ;
69
67
}
70
68
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
+
71
74
public toString ( tab : string = '' ) : string {
72
75
return super . toString ( tab ) + toStringTree ( tab , this ) ;
73
76
}
@@ -89,22 +92,34 @@ export class FnRxType<Req extends Type, Res extends Type, Ctx = unknown> extends
89
92
} as any ) ;
90
93
}
91
94
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 > {
93
100
( this as any ) . req = req ;
94
101
return this as any ;
95
102
}
96
103
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 ) ;
99
106
}
100
107
101
- public response < T extends Type > ( res : T ) : FnType < Req , T > {
108
+ public out < T extends Type > ( res : T ) : FnRxType < Req , T > {
102
109
( this as any ) . res = res ;
103
110
return this as any ;
104
111
}
105
112
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 ;
108
123
}
109
124
110
125
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
115
130
} ;
116
131
}
117
132
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
+
118
138
public toString ( tab : string = '' ) : string {
119
139
return super . toString ( tab ) + toStringTree ( tab , this ) ;
120
140
}
0 commit comments