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

[Won't Merge] Proof Of Concept: JSON Types #13

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
721fd35
remove the need for the flow=true flag
chrisgervang Jan 30, 2019
cbfc2b2
regenerate
chrisgervang Jan 30, 2019
2208291
Revert "regenerate"
chrisgervang Jan 30, 2019
8d54f72
allow for ts generation
chrisgervang Jan 30, 2019
c9a6e46
Continue to export example TS definitions
chrisgervang Jan 30, 2019
1d78200
Fix lock file
chrisgervang Jan 30, 2019
6489285
Fix CI
chrisgervang Jan 30, 2019
6b059f8
init
chrisgervang Jan 30, 2019
08e6d1d
Remove class printers
chrisgervang Jan 30, 2019
a857e7c
Remove $AsObject, $AsClass, List, Map postfixes
chrisgervang Jan 30, 2019
2d598cb
Generate json types by default
chrisgervang Jan 30, 2019
4046cd5
fix lint
chrisgervang Jan 30, 2019
5db1dd4
correcting json type codegen
chrisgervang Jan 30, 2019
08cb0cb
Proof Of Concept: JSON Types
chrisgervang Jan 30, 2019
fa6c5ff
Fix lint
chrisgervang Jan 30, 2019
e406a54
regenerate
chrisgervang Jan 30, 2019
765f8da
Revert "regenerate"
chrisgervang Jan 30, 2019
3d4b0fd
init
chrisgervang Jan 30, 2019
5c275d8
Remove class printers
chrisgervang Jan 30, 2019
bcd47c9
Remove $AsObject, $AsClass, List, Map postfixes
chrisgervang Jan 30, 2019
6fa6958
Generate json types by default
chrisgervang Jan 30, 2019
c894257
fix lint
chrisgervang Jan 30, 2019
b9b657f
correcting json type codegen
chrisgervang Jan 30, 2019
81b3aa7
Proof Of Concept: JSON Types
chrisgervang Jan 30, 2019
fed0058
Fix lint
chrisgervang Jan 30, 2019
4bbf023
Merge branch 'json-types' of https://github.com/chrisgervang/ts-proto…
chrisgervang Jan 30, 2019
591ddde
fix build
chrisgervang Jan 30, 2019
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow
// package: examplecom
// file: proto/examplecom/annotations.proto

export type AnnotatedMessage = {
myunit64: string,
myint64: string,
myfixed64: string,
mysint64: string,
mysfixed64: string,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @flow
// package: examplecom
// file: proto/examplecom/empty_message_no_service.proto

export type NoService = {
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @flow
// package: examplecom
// file: proto/examplecom/enum_message.proto

import * as proto_othercom_external_enum_pb from "../../proto/othercom/external_enum_pb.flow.js";
export type EnumMessage = {
internalEnum: $Values<typeof EnumMessage_InternalEnum>,
internalEnums: Array<$Values<typeof EnumMessage_InternalEnum>>,
externalEnum: $Values<typeof proto_othercom_external_enum_pb.ExternalEnum>,
externalEnums: Array<$Values<typeof proto_othercom_external_enum_pb.ExternalEnum>>,
}

export const EnumMessage_InternalEnum = Object.freeze({
DEFAULT: 0,
FIRST: 1,
SECOND: 2,
THIRD: 3,
})

export const EnumMessage_InternalEnum$ReverseLookUp = Object.freeze({
"0": "DEFAULT",
"1": "FIRST",
"2": "SECOND",
"3": "THIRD",
})

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @flow
// package: examplecom
// file: proto/examplecom/map_message.proto

import * as proto_othercom_external_enum_pb from "../../proto/othercom/external_enum_pb.flow.js";
import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb.flow.js";
export type MapMessage = {
internalEnums: Array<[number, $Values<typeof MapMessage$AsClass_InternalEnum>]>,
internalChildren: Array<[string, MapMessage$AsClass_InternalChildMessage]>,
externalEnums: Array<[number, $Values<typeof proto_othercom_external_enum_pb.ExternalEnum>]>,
externalChildren: Array<[string, proto_othercom_external_child_message_pb.ExternalChildMessage]>,
primitiveInts: Array<[string, number]>,
}
export type MapMessage_InternalChildMessage = {
myString: string,
}

export const MapMessage_InternalEnum = Object.freeze({
DEFAULT: 0,
FIRST: 1,
SECOND: 2,
})

export const MapMessage_InternalEnum$ReverseLookUp = Object.freeze({
"0": "DEFAULT",
"1": "FIRST",
"2": "SECOND",
})

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @flow
// package: examplecom
// file: proto/examplecom/oneof_message.proto

import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb.flow.js";
export type OneOfMessage = {
internalChildMessage?: OneOfMessage_InternalChildMessage,
externalChildMessage?: proto_othercom_external_child_message_pb.ExternalChildMessage,
myString: string,
myInt64: number,
}
export type OneOfMessage_InternalChildMessage = {
myString: string,
}

export const OneOfMessage_GroupCase = {
GROUP_NOT_SET: 0,
INTERNAL_CHILD_MESSAGE: 1,
EXTERNAL_CHILD_MESSAGE: 2,
MY_STRING: 3,
MY_INT64: 4,
}
export type CamelCasedOneOfMessage = {
anint: number,
thestring: string,
}

export const CamelCasedOneOfMessage_CamelcasedmessageCase = {
CAMELCASEDMESSAGE_NOT_SET: 0,
ANINT: 1,
THESTRING: 2,
}
export type SnakeCasedOneOfMessage = {
anint: number,
thestring: string,
}

export const SnakeCasedOneOfMessage_SnakeCasedMessageCase = {
SNAKE_CASED_MESSAGE_NOT_SET: 0,
ANINT: 1,
THESTRING: 2,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @flow
// package: examplecom
// file: proto/examplecom/parent_message_v2.proto

import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb.flow.js";
export type ParentMessageV2 = {
internalChildMessage: ParentMessageV2_InternalChildMessage,
optInternalChildMessage?: ParentMessageV2_InternalChildMessage,
internalChildren: Array<ParentMessageV2_InternalChildMessage>,
externalChildMessage: proto_othercom_external_child_message_pb.ExternalChildMessage,
optExternalChildMessage?: proto_othercom_external_child_message_pb.ExternalChildMessage,
externalChildren: Array<proto_othercom_external_child_message_pb.ExternalChildMessage>,
}
export type ParentMessageV2_InternalChildMessage = {
myString?: string,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow
// package: examplecom
// file: proto/examplecom/parent_message_v3.proto

import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb.flow.js";
export type ParentMessageV3 = {
internalChildMessage?: ParentMessageV3_InternalChildMessage,
internalChildren: Array<ParentMessageV3_InternalChildMessage>,
externalChildMessage?: proto_othercom_external_child_message_pb.ExternalChildMessage,
externalChildren: Array<proto_othercom_external_child_message_pb.ExternalChildMessage>,
}
export type ParentMessageV3_InternalChildMessage = {
myString: string,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// @flow
// package: examplecom
// file: proto/examplecom/primitive_message_v2.proto

export type PrimitiveMessageV2 = {
myDouble?: number,
myFloat?: number,
myInt32?: number,
myInt64?: number,
myUint32?: number,
myUint64?: number,
mySint32?: number,
mySint64?: number,
myFixed32?: number,
myFixed64?: number,
mySfixed32?: number,
mySfixed64?: number,
myBool?: boolean,
myString?: string,
myBytes: Uint8Array | string,
optDouble?: number,
optFloat?: number,
optInt32?: number,
optInt64?: number,
optUint32?: number,
optUint64?: number,
optSint32?: number,
optSint64?: number,
optFixed32?: number,
optFixed64?: number,
optSfixed32?: number,
optSfixed64?: number,
optBool?: boolean,
optString?: string,
optBytes: Uint8Array | string,
optNumber?: number,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow
// package: examplecom
// file: proto/examplecom/primitive_message_v3.proto

export type PrimitiveMessageV3 = {
myDouble: number,
myFloat: number,
myInt32: number,
myInt64: number,
myUint32: number,
myUint64: number,
mySint32: number,
mySint64: number,
myFixed32: number,
myFixed64: number,
mySfixed32: number,
mySfixed64: number,
myBool: boolean,
myString: string,
myBytes: Uint8Array | string,
myNumber: number,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @flow
// package: examplecom
// file: proto/examplecom/repeated_primitive_message.proto

export type RepeatedPrimitiveMessage = {
myDouble: Array<number>,
myFloat: Array<number>,
myInt32: Array<number>,
myInt64: Array<number>,
myUint32: Array<number>,
myUint64: Array<number>,
mySint32: Array<number>,
mySint64: Array<number>,
myFixed32: Array<number>,
myFixed64: Array<number>,
mySfixed32: Array<number>,
mySfixed64: Array<number>,
myBool: Array<boolean>,
myString: Array<string>,
myBytes: Array<Uint8Array | string>,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// @flow
// package: examplecom
// file: proto/examplecom/reserved_words.proto

export type ReservedWordsMessage = {
pb_abstract: string,
pb_boolean: string,
pb_break: string,
pb_byte: string,
pb_case: string,
pb_catch: string,
pb_char: string,
pb_class: string,
pb_const: string,
pb_continue: string,
pb_debugger: string,
pb_default: string,
pb_delete: string,
pb_do: string,
pb_double: string,
pb_else: string,
pb_enum: string,
pb_export: string,
pb_extends: string,
pb_false: string,
pb_final: string,
pb_finally: string,
pb_float: string,
pb_for: string,
pb_function: string,
pb_goto: string,
pb_if: string,
pb_implements: string,
pb_import: string,
pb_in: string,
pb_instanceof: string,
pb_int: string,
pb_interface: string,
pb_long: string,
pb_native: string,
pb_new: string,
pb_null: string,
pb_package: string,
pb_private: string,
pb_protected: string,
pb_public: string,
pb_return: string,
pb_short: string,
pb_static: string,
pb_super: string,
pb_switch: string,
pb_synchronized: string,
pb_this: string,
pb_throw: string,
pb_throws: string,
pb_transient: string,
pb_try: string,
pb_typeof: string,
pb_var: string,
pb_void: string,
pb_volatile: string,
pb_while: string,
pb_with: string,
}

34 changes: 34 additions & 0 deletions examples/flow/generated/proto/examplecom/simple_pb.json.flow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @flow
// package: examplecom
// file: proto/examplecom/simple.proto

import * as google_protobuf_compiler_plugin_pb from "google-protobuf/google/protobuf/compiler/plugin_pb";
import * as google_protobuf_any_pb from "google-protobuf/google/protobuf/any_pb";
import * as google_protobuf_api_pb from "google-protobuf/google/protobuf/api_pb";
import * as google_protobuf_descriptor_pb from "google-protobuf/google/protobuf/descriptor_pb";
import * as google_protobuf_duration_pb from "google-protobuf/google/protobuf/duration_pb";
import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb";
import * as google_protobuf_field_mask_pb from "google-protobuf/google/protobuf/field_mask_pb";
import * as google_protobuf_source_context_pb from "google-protobuf/google/protobuf/source_context_pb";
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";
import * as google_protobuf_type_pb from "google-protobuf/google/protobuf/type_pb";
import * as google_protobuf_wrappers_pb from "google-protobuf/google/protobuf/wrappers_pb";
export type MySimple = {
myString: string,
myBool: boolean,
someLabels: Array<string>,
someCodeGeneratorRequest?: google_protobuf_compiler_plugin_pb.CodeGeneratorRequest,
someAny?: google_protobuf_any_pb.Any,
someMethod?: google_protobuf_api_pb.Method,
someGeneratedCodeInfo?: google_protobuf_descriptor_pb.GeneratedCodeInfo,
someDuration?: google_protobuf_duration_pb.Duration,
someEmpty?: google_protobuf_empty_pb.Empty,
someFieldMask?: google_protobuf_field_mask_pb.FieldMask,
someSourceContext?: google_protobuf_source_context_pb.SourceContext,
someStruct?: google_protobuf_struct_pb.Struct,
someTimestamp?: google_protobuf_timestamp_pb.Timestamp,
someType?: google_protobuf_type_pb.Type,
someDoubleValue?: google_protobuf_wrappers_pb.DoubleValue,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @flow
// package: examplecom
// file: proto/examplecom/simple_service.proto

import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb.flow.js";
import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";
export type UnaryRequest = {
someInt64: number,
someTimestamp?: google_protobuf_timestamp_pb.Timestamp,
}
export type UnaryResponse = {
}
export type StreamRequest = {
someString: string,
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @flow
// package: examplecom
// file: proto/examplecom/simplevalue.proto

export type SimpleValue = {
firstField: string,
secondField: number,
numberValue: number,
stringValue: string,
boolValue: boolean,
number2Value: number,
string2Value: string,
bool2Value: boolean,
}

export const SimpleValue_KindCase = {
KIND_NOT_SET: 0,
NUMBER_VALUE: 3,
STRING_VALUE: 6,
BOOL_VALUE: 8,
}

export const SimpleValue_AnotherCase = {
ANOTHER_NOT_SET: 0,
NUMBER2_VALUE: 4,
STRING2_VALUE: 5,
BOOL2_VALUE: 7,
}

Loading