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(plugin): optional fields for oneof properties #549

Open
wants to merge 1 commit into
base: main
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
Binary file modified integration/batching-with-context/batching.bin
Binary file not shown.
Binary file modified integration/batching/batching.bin
Binary file not shown.
12 changes: 6 additions & 6 deletions integration/grpc-js/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ export interface Struct_FieldsEntry {
*/
export interface Value {
/** Represents a null value. */
nullValue: NullValue | undefined;
nullValue?: NullValue | undefined;
/** Represents a double value. */
numberValue: number | undefined;
numberValue?: number | undefined;
/** Represents a string value. */
stringValue: string | undefined;
stringValue?: string | undefined;
/** Represents a boolean value. */
boolValue: boolean | undefined;
boolValue?: boolean | undefined;
/** Represents a structured value. */
structValue: { [key: string]: any } | undefined;
structValue?: { [key: string]: any } | undefined;
/** Represents a repeated `Value`. */
listValue: Array<any> | undefined;
listValue?: Array<any> | undefined;
}

/**
Expand Down
Binary file modified integration/grpc-js/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/grpc-js/simple.bin
Binary file not shown.
Binary file modified integration/grpc-web-go-server/example.bin
Binary file not shown.
Binary file modified integration/grpc-web-no-streaming-observable/example.bin
Binary file not shown.
Binary file modified integration/grpc-web-no-streaming/example.bin
Binary file not shown.
Binary file modified integration/grpc-web/example.bin
Binary file not shown.
Binary file modified integration/meta-typings/google/protobuf/wrappers.bin
Binary file not shown.
36 changes: 18 additions & 18 deletions integration/meta-typings/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,134 +655,134 @@ export const protoMetadata: ProtoMetadata = {
path: [4, 0],
span: [50, 0, 53, 1],
leadingComments:
' Wrapper message for `double`.\n\n The JSON representation for `DoubleValue` is JSON number.\n',
' Wrapper message for `double`.\r\n\r\n The JSON representation for `DoubleValue` is JSON number.\r\n',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Larkooo FWIW these changes (and the *.bin file changes) might be from running proto2bin:local instead of the docker-based proto2bin?

We used to have a lot of churn on these files from contributors having different versions of protoc installed on their machines, but in theory the docker-based setup that @boukeversteegh put in place should have removed this churn.

Can you try the docker-based commands and see if it resolves these differences? Or were you already doing that, and we still have some non-determinism issues?

trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 0, 2, 0],
span: [52, 2, 19],
leadingComments: ' The double value.\n',
leadingComments: ' The double value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 1],
span: [58, 0, 61, 1],
leadingComments:
' Wrapper message for `float`.\n\n The JSON representation for `FloatValue` is JSON number.\n',
' Wrapper message for `float`.\r\n\r\n The JSON representation for `FloatValue` is JSON number.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 1, 2, 0],
span: [60, 2, 18],
leadingComments: ' The float value.\n',
leadingComments: ' The float value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 2],
span: [66, 0, 69, 1],
leadingComments:
' Wrapper message for `int64`.\n\n The JSON representation for `Int64Value` is JSON string.\n',
' Wrapper message for `int64`.\r\n\r\n The JSON representation for `Int64Value` is JSON string.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 2, 2, 0],
span: [68, 2, 18],
leadingComments: ' The int64 value.\n',
leadingComments: ' The int64 value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 3],
span: [74, 0, 77, 1],
leadingComments:
' Wrapper message for `uint64`.\n\n The JSON representation for `UInt64Value` is JSON string.\n',
' Wrapper message for `uint64`.\r\n\r\n The JSON representation for `UInt64Value` is JSON string.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 3, 2, 0],
span: [76, 2, 19],
leadingComments: ' The uint64 value.\n',
leadingComments: ' The uint64 value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 4],
span: [82, 0, 85, 1],
leadingComments:
' Wrapper message for `int32`.\n\n The JSON representation for `Int32Value` is JSON number.\n',
' Wrapper message for `int32`.\r\n\r\n The JSON representation for `Int32Value` is JSON number.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 4, 2, 0],
span: [84, 2, 18],
leadingComments: ' The int32 value.\n',
leadingComments: ' The int32 value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 5],
span: [90, 0, 93, 1],
leadingComments:
' Wrapper message for `uint32`.\n\n The JSON representation for `UInt32Value` is JSON number.\n',
' Wrapper message for `uint32`.\r\n\r\n The JSON representation for `UInt32Value` is JSON number.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 5, 2, 0],
span: [92, 2, 19],
leadingComments: ' The uint32 value.\n',
leadingComments: ' The uint32 value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 6],
span: [98, 0, 101, 1],
leadingComments:
' Wrapper message for `bool`.\n\n The JSON representation for `BoolValue` is JSON `true` and `false`.\n',
' Wrapper message for `bool`.\r\n\r\n The JSON representation for `BoolValue` is JSON `true` and `false`.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 6, 2, 0],
span: [100, 2, 17],
leadingComments: ' The bool value.\n',
leadingComments: ' The bool value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 7],
span: [106, 0, 109, 1],
leadingComments:
' Wrapper message for `string`.\n\n The JSON representation for `StringValue` is JSON string.\n',
' Wrapper message for `string`.\r\n\r\n The JSON representation for `StringValue` is JSON string.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 7, 2, 0],
span: [108, 2, 19],
leadingComments: ' The string value.\n',
leadingComments: ' The string value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 8],
span: [114, 0, 117, 1],
leadingComments:
' Wrapper message for `bytes`.\n\n The JSON representation for `BytesValue` is JSON string.\n',
' Wrapper message for `bytes`.\r\n\r\n The JSON representation for `BytesValue` is JSON string.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 8, 2, 0],
span: [116, 2, 18],
leadingComments: ' The bytes value.\n',
leadingComments: ' The bytes value.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
Expand Down
Binary file modified integration/meta-typings/google/type/date.bin
Binary file not shown.
8 changes: 4 additions & 4 deletions integration/meta-typings/google/type/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,30 @@ export const protoMetadata: ProtoMetadata = {
path: [4, 0],
span: [36, 0, 49, 1],
leadingComments:
' Represents a whole or partial calendar date, e.g. a birthday. The time of day\n and time zone are either specified elsewhere or are not significant. The date\n is relative to the Proleptic Gregorian Calendar. This can represent:\n\n * A full date, with non-zero year, month and day values\n * A month and day value, with a zero year, e.g. an anniversary\n * A year on its own, with zero month and day values\n * A year and month value, with a zero day, e.g. a credit card expiration date\n\n Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`.\n',
' Represents a whole or partial calendar date, e.g. a birthday. The time of day\r\n and time zone are either specified elsewhere or are not significant. The date\r\n is relative to the Proleptic Gregorian Calendar. This can represent:\r\n\r\n * A full date, with non-zero year, month and day values\r\n * A month and day value, with a zero year, e.g. an anniversary\r\n * A year on its own, with zero month and day values\r\n * A year and month value, with a zero day, e.g. a credit card expiration date\r\n\r\n Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 0, 2, 0],
span: [39, 2, 17],
leadingComments: ' Year of date. Must be from 1 to 9999, or 0 if specifying a date without\n a year.\n',
leadingComments: ' Year of date. Must be from 1 to 9999, or 0 if specifying a date without\r\n a year.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 0, 2, 1],
span: [43, 2, 18],
leadingComments:
' Month of year. Must be from 1 to 12, or 0 if specifying a year without a\n month and day.\n',
' Month of year. Must be from 1 to 12, or 0 if specifying a year without a\r\n month and day.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 0, 2, 2],
span: [48, 2, 16],
leadingComments:
' Day of month. Must be from 1 to 31 and valid for the year and month, or 0\n if specifying a year by itself or a year and month where the day is not\n significant.\n',
' Day of month. Must be from 1 to 31 and valid for the year and month, or 0\r\n if specifying a year by itself or a year and month where the day is not\r\n significant.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
Expand Down
Binary file modified integration/meta-typings/simple.bin
Binary file not shown.
22 changes: 11 additions & 11 deletions integration/meta-typings/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export interface Nested_InnerMessage_DeepMessage {
}

export interface OneOfMessage {
first: string | undefined;
last: string | undefined;
first?: string | undefined;
last?: string | undefined;
}

export interface SimpleWithWrappers {
Expand Down Expand Up @@ -2638,7 +2638,7 @@ export const protoMetadata: ProtoMetadata = {
path: [12],
span: [2, 0, 18],
leadingComments:
' Adding a comment to the syntax will become the first\n comment in the output source file.\n',
' Adding a comment to the syntax will become the first\r\n comment in the output source file.\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
Expand All @@ -2648,13 +2648,13 @@ export const protoMetadata: ProtoMetadata = {
leadingComments: '* Example comment on the Simple message ',
trailingComments: '',
leadingDetachedComments: [
' This comment is seperated by a blank non-comment line, and will detatch from \n the following comment on the message Simple.\n',
' This comment is seperated by a blank non-comment line, and will detatch from \r\n the following comment on the message Simple.\r\n',
],
},
{
path: [4, 0, 2, 0],
span: [15, 2, 18],
leadingComments: ' Name field\n',
leadingComments: ' Name field\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
Expand All @@ -2669,20 +2669,20 @@ export const protoMetadata: ProtoMetadata = {
path: [4, 0, 2, 2],
span: [18, 2, 43],
leadingComments: '',
trailingComments: ' This comment will also attach\n',
trailingComments: ' This comment will also attach\r\n',
leadingDetachedComments: [],
},
{
path: [4, 0, 2, 9],
span: [26, 2, 27],
leadingComments: ' A thing (imported from thing)\n',
leadingComments: ' A thing (imported from thing)\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
{
path: [4, 2, 3, 0],
span: [54, 2, 61, 3],
leadingComments: ' Comment for a nested message */\n',
leadingComments: ' Comment for a nested message */\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
Expand All @@ -2696,7 +2696,7 @@ export const protoMetadata: ProtoMetadata = {
{
path: [4, 12, 2, 0],
span: [135, 2, 27],
leadingComments: ' Name field\n',
leadingComments: ' Name field\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
Expand All @@ -2711,13 +2711,13 @@ export const protoMetadata: ProtoMetadata = {
path: [4, 12, 2, 2],
span: [138, 2, 52],
leadingComments: '',
trailingComments: ' This comment will also attach\n',
trailingComments: ' This comment will also attach\r\n',
leadingDetachedComments: [],
},
{
path: [4, 12, 2, 5],
span: [142, 2, 36],
leadingComments: ' A thing (imported from thing)\n',
leadingComments: ' A thing (imported from thing)\r\n',
trailingComments: '',
leadingDetachedComments: [],
},
Expand Down
Binary file modified integration/oneof-properties/oneof.bin
Binary file not shown.
18 changes: 9 additions & 9 deletions integration/oneof-properties/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ export interface PleaseChoose {
* Use this if you want a number. Numbers are great. Who doesn't
* like them?
*/
aNumber: number | undefined;
aNumber?: number | undefined;
/**
* Use this if you want a string. Strings are also nice. Not as
* nice as numbers, but what are you going to do...
*/
aString: string | undefined;
aMessage: PleaseChoose_Submessage | undefined;
aString?: string | undefined;
aMessage?: PleaseChoose_Submessage | undefined;
/**
* We also added a bool option! This was added after the 'age'
* field, so it has a higher number.
*/
aBool: boolean | undefined;
bunchaBytes: Uint8Array | undefined;
anEnum: PleaseChoose_StateEnum | undefined;
aBool?: boolean | undefined;
bunchaBytes?: Uint8Array | undefined;
anEnum?: PleaseChoose_StateEnum | undefined;
age: number;
either: string | undefined;
or: string | undefined;
thirdOption: string | undefined;
either?: string | undefined;
or?: string | undefined;
thirdOption?: string | undefined;
}

export enum PleaseChoose_StateEnum {
Expand Down
Binary file modified integration/oneof-unions/oneof.bin
Binary file not shown.
Binary file modified integration/simple-deprecated-fields/simple.bin
Binary file not shown.
Binary file modified integration/simple-long-string/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/simple-long-string/simple.bin
Binary file not shown.
Binary file modified integration/simple-long/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/simple-long/simple.bin
Binary file not shown.
Binary file modified integration/simple-optionals/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/simple-optionals/simple.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions integration/simple-optionals/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export interface Nested_InnerMessage_DeepMessage {
}

export interface OneOfMessage {
first: string | undefined;
last: string | undefined;
first?: string | undefined;
last?: string | undefined;
}

export interface SimpleWithWrappers {
Expand Down
Binary file modified integration/simple-prototype-defaults/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/simple-prototype-defaults/google/type/date.bin
Binary file not shown.
Binary file modified integration/simple-prototype-defaults/simple.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions integration/simple-prototype-defaults/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ export interface Nested_InnerMessage_DeepMessage {
}

export interface OneOfMessage {
first: string | undefined;
last: string | undefined;
first?: string | undefined;
last?: string | undefined;
}

export interface SimpleWithWrappers {
Expand Down
Binary file modified integration/simple-snake/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/simple-snake/simple.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions integration/simple-snake/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export interface Nested_InnerMessage_DeepMessage {
}

export interface OneOfMessage {
first: string | undefined;
last: string | undefined;
first?: string | undefined;
last?: string | undefined;
}

export interface SimpleWithWrappers {
Expand Down
12 changes: 6 additions & 6 deletions integration/simple-string-enums/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ export interface Struct_FieldsEntry {
*/
export interface Value {
/** Represents a null value. */
nullValue: NullValue | undefined;
nullValue?: NullValue | undefined;
/** Represents a double value. */
numberValue: number | undefined;
numberValue?: number | undefined;
/** Represents a string value. */
stringValue: string | undefined;
stringValue?: string | undefined;
/** Represents a boolean value. */
boolValue: boolean | undefined;
boolValue?: boolean | undefined;
/** Represents a structured value. */
structValue: { [key: string]: any } | undefined;
structValue?: { [key: string]: any } | undefined;
/** Represents a repeated `Value`. */
listValue: Array<any> | undefined;
listValue?: Array<any> | undefined;
}

/**
Expand Down
Binary file modified integration/simple-unrecognized-enum/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/simple-unrecognized-enum/simple.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions integration/simple-unrecognized-enum/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export interface Nested_InnerMessage_DeepMessage {
}

export interface OneOfMessage {
first: string | undefined;
last: string | undefined;
first?: string | undefined;
last?: string | undefined;
}

export interface SimpleWithWrappers {
Expand Down
Binary file modified integration/simple/google/protobuf/wrappers.bin
Binary file not shown.
Binary file modified integration/simple/google/type/date.bin
Binary file not shown.
Binary file modified integration/simple/simple.bin
Binary file not shown.
Loading