-
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.
feat: class based client and server manifests
- Loading branch information
1 parent
6cceeda
commit 282913e
Showing
14 changed files
with
543 additions
and
482 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, | ||
}; |
Oops, something went wrong.