Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add types #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import { Schema } from "./types";
declare namespace parse {
function parse(buffer: string | Uint8Array): Schema;
function stringify(schema: Schema): string;
}

declare function parse(buffer: string | Uint8Array): Schema;

export = parse;
9 changes: 9 additions & 0 deletions parse.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Schema } from "./types";
declare namespace parse {
function parse(buffer: string | Uint8Array): Schema;
function stringify(schema: Schema): string;
}

declare function parse(buffer: string | Uint8Array): Schema;

export = parse;
5 changes: 5 additions & 0 deletions stringify.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Schema } from "./types";

declare function stringify(schema: Schema): string;

export = stringify;
5 changes: 5 additions & 0 deletions tokenize.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Schema } from "./types";

declare function tokenize(schema: Schema): string[];

export = tokenize;
82 changes: 82 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export interface Option {
[key: string]: string | boolean;
}

export interface Options {
[key: string]: string | boolean | Option | Option[];
}

export interface Enum {
name: string;
values: {
[key: string]: {
value: number;
options: Options;
};
};
options: Options;
}

export interface FieldOptions {
[key: string]: string;
}

export interface Field {
name: string;
type: string;
tag: number;
map: {
from: string;
to: string;
};
oneof: null | string;
required: boolean;
repeated: boolean;
options: FieldOptions;
}

export interface Message {
name: string;
enums: Enum[];
extends: Extend[];
extensions: Extension[];
messages: Message[];
options: Options;
fields: Field[];
}

export interface Extend {
name: string;
message: Message;
}

export interface Extension {
from: number;
to: number;
}

export interface Service {
name: string;
methods: Method[];
options: Options;
}

export interface Method {
name: string;
input_type: string;
output_type: string;
client_streaming: boolean;
server_streaming: boolean;
options: Options;
}

export interface Schema {
syntax: number;
package: null | string;
imports: string[];
enums: Enum[];
messages: Message[];
options: Options;
extends: Extend[];
services?: Service[];
}