-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
100 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export default function main(): null { | ||
return null; | ||
} | ||
export * from './types'; |
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,67 @@ | ||
import { ErrorCode } from './error'; | ||
import { Schema } from './schema'; | ||
import { Observable } from './observable'; | ||
|
||
export type Element = Tree | Type | Service; | ||
export type Tree = CollectionTree | ScopeTree; | ||
export type Type = ErrorType | RequestType | ResponseType; | ||
export type Service = QueryService | MutationService | SubscriptionService; | ||
|
||
// Tree | ||
export interface CollectionTree { | ||
types: TreeTypes; | ||
services: TreeServices; | ||
scopes: { [key: string]: ScopeTree }; | ||
} | ||
export interface ScopeTree { | ||
services: TreeServices; | ||
scopes: { [key: string]: ScopeTree }; | ||
} | ||
export interface TreeTypes { | ||
error: { [key: string]: ErrorType }; | ||
request: { [key: string]: RequestType }; | ||
response: { [key: string]: ResponseType }; | ||
} | ||
export interface TreeServices { | ||
query: { [key: string]: QueryService }; | ||
mutation: { [key: string]: MutationService }; | ||
subscription: { [key: string]: SubscriptionService }; | ||
} | ||
|
||
// Types | ||
export interface ErrorType { | ||
code: ErrorCode; | ||
} | ||
export interface RequestType { | ||
schema: Schema; | ||
} | ||
export interface ResponseType<T = any> { | ||
schema: Schema; | ||
children: ResponseTypeChildren<T>; | ||
} | ||
export interface ResponseTypeChildren<I = any> { | ||
query: { [key: string]: QueryService<I> }; | ||
subscription: { [key: string]: SubscriptionService<I> }; | ||
} | ||
|
||
// Services | ||
export interface QueryService<I = any, O = any> { | ||
types: ServiceTypes; | ||
resolve(data: I, context: any): O | Promise<O>; | ||
} | ||
export interface MutationService<I = any, O = any> { | ||
types: ServiceTypes; | ||
resolve(data: I, context: any): O | Promise<O>; | ||
} | ||
export interface SubscriptionService<I = any, O = any> { | ||
types: ServiceTypes; | ||
resolve( | ||
data: I, | ||
context: any | ||
): Observable<O | Promise<O>> | Promise<Observable<O | Promise<O>>>; | ||
} | ||
export interface ServiceTypes { | ||
errors: string[]; | ||
request: string; | ||
response: string; | ||
} |
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,17 @@ | ||
export type ErrorCode = ClientErrorCode | ServerErrorCode; | ||
|
||
export type ClientErrorCode = | ||
| 'ClientError' | ||
| 'ClientNotFound' | ||
| 'ClientForbidden' | ||
| 'ClientUnauthorized' | ||
| 'ClientConflict' | ||
| 'ClientUnsupported' | ||
| 'ClientTooEarly' | ||
| 'ClientRateLimit'; | ||
|
||
export type ServerErrorCode = | ||
| 'ServerError' | ||
| 'ServerNotImplemented' | ||
| 'ServerUnavailable' | ||
| 'ServerTimeout'; |
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,4 @@ | ||
export * from './collection'; | ||
export * from './error'; | ||
export * from './observable'; | ||
export * from './schema'; |
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 @@ | ||
export { Observable } from 'rxjs'; |
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,3 @@ | ||
import { JSONSchema4 } from 'json-schema'; | ||
|
||
export type Schema = JSONSchema4; |