-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
266f2af
commit d24df4c
Showing
13 changed files
with
315 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { JSONValue } from 'types'; | ||
import type { HandlerType } from './types'; | ||
|
||
abstract class Caller< | ||
Input extends JSONValue = JSONValue, | ||
Output extends JSONValue = JSONValue, | ||
> { | ||
protected _inputType: Input; | ||
protected _outputType: Output; | ||
// Need this to distinguish the classes when inferring types | ||
abstract type: HandlerType; | ||
} | ||
|
||
class RawCaller extends Caller { | ||
public type: 'RAW' = 'RAW' as const; | ||
} | ||
|
||
class DuplexCaller< | ||
Input extends JSONValue = JSONValue, | ||
Output extends JSONValue = JSONValue, | ||
> extends Caller<Input, Output> { | ||
public type: 'DUPLEX' = 'DUPLEX' as const; | ||
} | ||
|
||
class ServerCaller< | ||
Input extends JSONValue = JSONValue, | ||
Output extends JSONValue = JSONValue, | ||
> extends Caller<Input, Output> { | ||
public type: 'SERVER' = 'SERVER' as const; | ||
} | ||
|
||
class ClientCaller< | ||
Input extends JSONValue = JSONValue, | ||
Output extends JSONValue = JSONValue, | ||
> extends Caller<Input, Output> { | ||
public type: 'CLIENT' = 'CLIENT' as const; | ||
} | ||
|
||
class UnaryCaller< | ||
Input extends JSONValue = JSONValue, | ||
Output extends JSONValue = JSONValue, | ||
> extends Caller<Input, Output> { | ||
public type: 'UNARY' = 'UNARY' as const; | ||
} | ||
|
||
export { | ||
Caller, | ||
RawCaller, | ||
DuplexCaller, | ||
ServerCaller, | ||
ClientCaller, | ||
UnaryCaller, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.