-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Takes the types from [@types/protocol-buffers-schema](https://www.npmjs.com/package/@types/protocol-buffers-schema) and adds them to this module. It swaps node `Buffer`s for `Uint8Array`s in the interfaces because this module doesn't use any `Buffer` features that aren't available on `Uint8Array`s which makes it a bit kinder to the browser.
- Loading branch information
1 parent
5de5b21
commit a1a4954
Showing
5 changed files
with
106 additions
and
0 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
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; |
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,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; |
Empty file.
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,5 @@ | ||
import { Schema } from "./types"; | ||
|
||
declare function tokenize(schema: Schema): string[]; | ||
|
||
export = tokenize; |
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,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[]; | ||
} |