From dfc692fb7f13dbdf6110ab8595cd5b450881733d Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 12:53:51 -0700 Subject: [PATCH 1/9] add a no-tags option to the type-registry --- README.markdown | 2 +- integration/type-registry-no-tags/bar/bar.bin | Bin 0 -> 11627 bytes .../type-registry-no-tags/bar/bar.proto | 9 + integration/type-registry-no-tags/bar/bar.ts | 74 +++ integration/type-registry-no-tags/foo.bin | Bin 0 -> 11422 bytes integration/type-registry-no-tags/foo.proto | 18 + integration/type-registry-no-tags/foo.ts | 207 ++++++++ .../google/protobuf/struct.ts | 478 ++++++++++++++++++ .../google/protobuf/timestamp.ts | 221 ++++++++ .../type-registry-no-tags/parameters.txt | 1 + .../type-registry-test.ts | 23 + .../type-registry-no-tags/typeRegistry.ts | 20 + src/generate-type-registry.ts | 16 +- src/main.ts | 30 +- src/options.ts | 2 +- 15 files changed, 1080 insertions(+), 21 deletions(-) create mode 100644 integration/type-registry-no-tags/bar/bar.bin create mode 100644 integration/type-registry-no-tags/bar/bar.proto create mode 100644 integration/type-registry-no-tags/bar/bar.ts create mode 100644 integration/type-registry-no-tags/foo.bin create mode 100644 integration/type-registry-no-tags/foo.proto create mode 100644 integration/type-registry-no-tags/foo.ts create mode 100644 integration/type-registry-no-tags/google/protobuf/struct.ts create mode 100644 integration/type-registry-no-tags/google/protobuf/timestamp.ts create mode 100755 integration/type-registry-no-tags/parameters.txt create mode 100644 integration/type-registry-no-tags/type-registry-test.ts create mode 100644 integration/type-registry-no-tags/typeRegistry.ts diff --git a/README.markdown b/README.markdown index 0342b6a39..1ad4191b3 100644 --- a/README.markdown +++ b/README.markdown @@ -398,7 +398,7 @@ Generated code will be placed in the Gradle build directory. - With `--ts_proto_opt=outputSchema=true`, meta typings will be generated that can later be used in other code generators. -- With `--ts_proto_opt=outputTypeRegistry=true`, the type registry will be generated that can be used to resolve message types by fully-qualified name. Also, each message will get extra `$type` field containing fully-qualified name. +- With `--ts_proto_opt=outputTypeRegistry=true`, the type registry will be generated that can be used to resolve message types by fully-qualified name. Also, each message will get extra `$type` field containing fully-qualified name. If you would prefer to avoid the `$type`, you can `--ts_proto_opt=outputTypeRegistry=no-tags` - With `--ts_proto_opt=outputServices=grpc-js`, ts-proto will output service definitions and server / client stubs in [grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) format. diff --git a/integration/type-registry-no-tags/bar/bar.bin b/integration/type-registry-no-tags/bar/bar.bin new file mode 100644 index 0000000000000000000000000000000000000000..15ddb6a942e619ffe20d3d4251ddd88f8ac9921a GIT binary patch literal 11627 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 H6fp9CP3tR# literal 0 HcmV?d00001 diff --git a/integration/type-registry-no-tags/bar/bar.proto b/integration/type-registry-no-tags/bar/bar.proto new file mode 100644 index 000000000..43aa08bd9 --- /dev/null +++ b/integration/type-registry-no-tags/bar/bar.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package foo.bar; + +import "foo.proto"; + +message Bar { + Foo foo = 1; +} diff --git a/integration/type-registry-no-tags/bar/bar.ts b/integration/type-registry-no-tags/bar/bar.ts new file mode 100644 index 000000000..d7d4164c2 --- /dev/null +++ b/integration/type-registry-no-tags/bar/bar.ts @@ -0,0 +1,74 @@ +/* eslint-disable */ +import * as _m0 from "protobufjs/minimal"; +import { Foo } from "../foo"; +import { messageTypeRegistry } from "../typeRegistry"; + +export const protobufPackage = "foo.bar"; + +export interface Bar { + foo: Foo | undefined; +} + +function createBaseBar(): Bar { + return { foo: undefined }; +} + +export const Bar = { + encode(message: Bar, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.foo !== undefined) { + Foo.encode(message.foo, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Bar { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBar(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.foo = Foo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Bar { + return { foo: isSet(object.foo) ? Foo.fromJSON(object.foo) : undefined }; + }, + + toJSON(message: Bar): unknown { + const obj: any = {}; + message.foo !== undefined && (obj.foo = message.foo ? Foo.toJSON(message.foo) : undefined); + return obj; + }, + + fromPartial, I>>(object: I): Bar { + const message = createBaseBar(); + message.foo = (object.foo !== undefined && object.foo !== null) ? Foo.fromPartial(object.foo) : undefined; + return message; + }, +}; + +messageTypeRegistry.set("foo.bar.Bar", Bar); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude | "$type">]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/integration/type-registry-no-tags/foo.bin b/integration/type-registry-no-tags/foo.bin new file mode 100644 index 0000000000000000000000000000000000000000..275db905464feb96e690ff1e713a085d8b530561 GIT binary patch literal 11422 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 3) { + case 1: + message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Foo { + return { timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined }; + }, + + toJSON(message: Foo): unknown { + const obj: any = {}; + message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString()); + return obj; + }, + + fromPartial, I>>(object: I): Foo { + const message = createBaseFoo(); + message.timestamp = object.timestamp ?? undefined; + return message; + }, +}; + +messageTypeRegistry.set("foo.Foo", Foo); + +function createBaseFoo2(): Foo2 { + return { timestamp: undefined }; +} + +export const Foo2 = { + encode(message: Foo2, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.timestamp !== undefined) { + Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Foo2 { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFoo2(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Foo2 { + return { timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined }; + }, + + toJSON(message: Foo2): unknown { + const obj: any = {}; + message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString()); + return obj; + }, + + fromPartial, I>>(object: I): Foo2 { + const message = createBaseFoo2(); + message.timestamp = object.timestamp ?? undefined; + return message; + }, +}; + +messageTypeRegistry.set("foo.Foo2", Foo2); + +function createBaseWithStruct(): WithStruct { + return { struct: undefined }; +} + +export const WithStruct = { + encode(message: WithStruct, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.struct !== undefined) { + Struct.encode(Struct.wrap(message.struct), writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): WithStruct { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWithStruct(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.struct = Struct.unwrap(Struct.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): WithStruct { + return { struct: isObject(object.struct) ? object.struct : undefined }; + }, + + toJSON(message: WithStruct): unknown { + const obj: any = {}; + message.struct !== undefined && (obj.struct = message.struct); + return obj; + }, + + fromPartial, I>>(object: I): WithStruct { + const message = createBaseWithStruct(); + message.struct = object.struct ?? undefined; + return message; + }, +}; + +messageTypeRegistry.set("foo.WithStruct", WithStruct); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude | "$type">]: never }; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function isObject(value: any): boolean { + return typeof value === "object" && value !== null; +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/integration/type-registry-no-tags/google/protobuf/struct.ts b/integration/type-registry-no-tags/google/protobuf/struct.ts new file mode 100644 index 000000000..558f8cffa --- /dev/null +++ b/integration/type-registry-no-tags/google/protobuf/struct.ts @@ -0,0 +1,478 @@ +/* eslint-disable */ +import * as _m0 from "protobufjs/minimal"; +import { messageTypeRegistry } from "../../typeRegistry"; + +export const protobufPackage = "google.protobuf"; + +/** + * `NullValue` is a singleton enumeration to represent the null value for the + * `Value` type union. + * + * The JSON representation for `NullValue` is JSON `null`. + */ +export enum NullValue { + /** NULL_VALUE - Null value. */ + NULL_VALUE = 0, + UNRECOGNIZED = -1, +} + +export function nullValueFromJSON(object: any): NullValue { + switch (object) { + case 0: + case "NULL_VALUE": + return NullValue.NULL_VALUE; + case -1: + case "UNRECOGNIZED": + default: + return NullValue.UNRECOGNIZED; + } +} + +export function nullValueToJSON(object: NullValue): string { + switch (object) { + case NullValue.NULL_VALUE: + return "NULL_VALUE"; + case NullValue.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +/** + * `Struct` represents a structured data value, consisting of fields + * which map to dynamically typed values. In some languages, `Struct` + * might be supported by a native representation. For example, in + * scripting languages like JS a struct is represented as an + * object. The details of that representation are described together + * with the proto support for the language. + * + * The JSON representation for `Struct` is JSON object. + */ +export interface Struct { + /** Unordered map of dynamically typed values. */ + fields: { [key: string]: any | undefined }; +} + +export interface Struct_FieldsEntry { + key: string; + value: any | undefined; +} + +/** + * `Value` represents a dynamically typed value which can be either + * null, a number, a string, a boolean, a recursive struct value, or a + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. + * + * The JSON representation for `Value` is JSON value. + */ +export interface Value { + /** Represents a null value. */ + nullValue: + | NullValue + | undefined; + /** Represents a double value. */ + numberValue: + | number + | undefined; + /** Represents a string value. */ + stringValue: + | string + | undefined; + /** Represents a boolean value. */ + boolValue: + | boolean + | undefined; + /** Represents a structured value. */ + structValue: + | { [key: string]: any } + | undefined; + /** Represents a repeated `Value`. */ + listValue: Array | undefined; +} + +/** + * `ListValue` is a wrapper around a repeated field of values. + * + * The JSON representation for `ListValue` is JSON array. + */ +export interface ListValue { + /** Repeated field of dynamically typed values. */ + values: any[]; +} + +function createBaseStruct(): Struct { + return { fields: {} }; +} + +export const Struct = { + encode(message: Struct, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + Object.entries(message.fields).forEach(([key, value]) => { + if (value !== undefined) { + Struct_FieldsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim(); + } + }); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Struct { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStruct(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32()); + if (entry1.value !== undefined) { + message.fields[entry1.key] = entry1.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Struct { + return { + fields: isObject(object.fields) + ? Object.entries(object.fields).reduce<{ [key: string]: any | undefined }>((acc, [key, value]) => { + acc[key] = value as any | undefined; + return acc; + }, {}) + : {}, + }; + }, + + toJSON(message: Struct): unknown { + const obj: any = {}; + obj.fields = {}; + if (message.fields) { + Object.entries(message.fields).forEach(([k, v]) => { + obj.fields[k] = v; + }); + } + return obj; + }, + + fromPartial, I>>(object: I): Struct { + const message = createBaseStruct(); + message.fields = Object.entries(object.fields ?? {}).reduce<{ [key: string]: any | undefined }>( + (acc, [key, value]) => { + if (value !== undefined) { + acc[key] = value; + } + return acc; + }, + {}, + ); + return message; + }, + + wrap(object: { [key: string]: any } | undefined): Struct { + const struct = createBaseStruct(); + if (object !== undefined) { + Object.keys(object).forEach((key) => { + struct.fields[key] = object[key]; + }); + } + return struct; + }, + + unwrap(message: Struct): { [key: string]: any } { + const object: { [key: string]: any } = {}; + Object.keys(message.fields).forEach((key) => { + object[key] = message.fields[key]; + }); + return object; + }, +}; + +messageTypeRegistry.set("google.protobuf.Struct", Struct); + +function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { + return { key: "", value: undefined }; +} + +export const Struct_FieldsEntry = { + encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStruct_FieldsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = Value.unwrap(Value.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Struct_FieldsEntry { + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; + }, + + toJSON(message: Struct_FieldsEntry): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial, I>>(object: I): Struct_FieldsEntry { + const message = createBaseStruct_FieldsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? undefined; + return message; + }, +}; + +messageTypeRegistry.set("google.protobuf.Struct.FieldsEntry", Struct_FieldsEntry); + +function createBaseValue(): Value { + return { + nullValue: undefined, + numberValue: undefined, + stringValue: undefined, + boolValue: undefined, + structValue: undefined, + listValue: undefined, + }; +} + +export const Value = { + encode(message: Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.nullValue !== undefined) { + writer.uint32(8).int32(message.nullValue); + } + if (message.numberValue !== undefined) { + writer.uint32(17).double(message.numberValue); + } + if (message.stringValue !== undefined) { + writer.uint32(26).string(message.stringValue); + } + if (message.boolValue !== undefined) { + writer.uint32(32).bool(message.boolValue); + } + if (message.structValue !== undefined) { + Struct.encode(Struct.wrap(message.structValue), writer.uint32(42).fork()).ldelim(); + } + if (message.listValue !== undefined) { + ListValue.encode(ListValue.wrap(message.listValue), writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Value { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nullValue = reader.int32() as any; + break; + case 2: + message.numberValue = reader.double(); + break; + case 3: + message.stringValue = reader.string(); + break; + case 4: + message.boolValue = reader.bool(); + break; + case 5: + message.structValue = Struct.unwrap(Struct.decode(reader, reader.uint32())); + break; + case 6: + message.listValue = ListValue.unwrap(ListValue.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Value { + return { + nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined, + numberValue: isSet(object.numberValue) ? Number(object.numberValue) : undefined, + stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, + boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, + structValue: isObject(object.structValue) ? object.structValue : undefined, + listValue: Array.isArray(object.listValue) ? [...object.listValue] : undefined, + }; + }, + + toJSON(message: Value): unknown { + const obj: any = {}; + message.nullValue !== undefined && + (obj.nullValue = message.nullValue !== undefined ? nullValueToJSON(message.nullValue) : undefined); + message.numberValue !== undefined && (obj.numberValue = message.numberValue); + message.stringValue !== undefined && (obj.stringValue = message.stringValue); + message.boolValue !== undefined && (obj.boolValue = message.boolValue); + message.structValue !== undefined && (obj.structValue = message.structValue); + message.listValue !== undefined && (obj.listValue = message.listValue); + return obj; + }, + + fromPartial, I>>(object: I): Value { + const message = createBaseValue(); + message.nullValue = object.nullValue ?? undefined; + message.numberValue = object.numberValue ?? undefined; + message.stringValue = object.stringValue ?? undefined; + message.boolValue = object.boolValue ?? undefined; + message.structValue = object.structValue ?? undefined; + message.listValue = object.listValue ?? undefined; + return message; + }, + + wrap(value: any): Value { + const result = createBaseValue(); + + if (value === null) { + result.nullValue = NullValue.NULL_VALUE; + } else if (typeof value === "boolean") { + result.boolValue = value; + } else if (typeof value === "number") { + result.numberValue = value; + } else if (typeof value === "string") { + result.stringValue = value; + } else if (Array.isArray(value)) { + result.listValue = value; + } else if (typeof value === "object") { + result.structValue = value; + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); + } + + return result; + }, + + unwrap(message: Value): string | number | boolean | Object | null | Array | undefined { + if (message?.stringValue !== undefined) { + return message.stringValue; + } else if (message?.numberValue !== undefined) { + return message.numberValue; + } else if (message?.boolValue !== undefined) { + return message.boolValue; + } else if (message?.structValue !== undefined) { + return message.structValue; + } else if (message?.listValue !== undefined) { + return message.listValue; + } else if (message?.nullValue !== undefined) { + return null; + } + return undefined; + }, +}; + +messageTypeRegistry.set("google.protobuf.Value", Value); + +function createBaseListValue(): ListValue { + return { values: [] }; +} + +export const ListValue = { + encode(message: ListValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.values) { + Value.encode(Value.wrap(v!), writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.values.push(Value.unwrap(Value.decode(reader, reader.uint32()))); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ListValue { + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; + }, + + toJSON(message: ListValue): unknown { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map((e) => e); + } else { + obj.values = []; + } + return obj; + }, + + fromPartial, I>>(object: I): ListValue { + const message = createBaseListValue(); + message.values = object.values?.map((e) => e) || []; + return message; + }, + + wrap(value: Array | undefined): ListValue { + const result = createBaseListValue(); + + result.values = value ?? []; + + return result; + }, + + unwrap(message: ListValue): Array { + return message.values; + }, +}; + +messageTypeRegistry.set("google.protobuf.ListValue", ListValue); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude | "$type">]: never }; + +function isObject(value: any): boolean { + return typeof value === "object" && value !== null; +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/integration/type-registry-no-tags/google/protobuf/timestamp.ts b/integration/type-registry-no-tags/google/protobuf/timestamp.ts new file mode 100644 index 000000000..c9fec54c6 --- /dev/null +++ b/integration/type-registry-no-tags/google/protobuf/timestamp.ts @@ -0,0 +1,221 @@ +/* eslint-disable */ +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; +import { messageTypeRegistry } from "../../typeRegistry"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +function createBaseTimestamp(): Timestamp { + return { seconds: 0, nanos: 0 }; +} + +export const Timestamp = { + encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTimestamp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + return { + seconds: isSet(object.seconds) ? Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + }; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = Math.round(message.seconds)); + message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); + return obj; + }, + + fromPartial, I>>(object: I): Timestamp { + const message = createBaseTimestamp(); + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; + return message; + }, +}; + +messageTypeRegistry.set("google.protobuf.Timestamp", Timestamp); + +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude | "$type">]: never }; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +// If you get a compile-error about 'Constructor and ... have no overlap', +// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/integration/type-registry-no-tags/parameters.txt b/integration/type-registry-no-tags/parameters.txt new file mode 100755 index 000000000..93d1b4fc2 --- /dev/null +++ b/integration/type-registry-no-tags/parameters.txt @@ -0,0 +1 @@ +outputTypeRegistry=no-tags diff --git a/integration/type-registry-no-tags/type-registry-test.ts b/integration/type-registry-no-tags/type-registry-test.ts new file mode 100644 index 000000000..53b08f945 --- /dev/null +++ b/integration/type-registry-no-tags/type-registry-test.ts @@ -0,0 +1,23 @@ +import { Foo, Foo2 } from './foo'; +import { Bar } from './bar/bar'; +import { messageTypeRegistry } from './typeRegistry'; + +describe('type-registry-no-tags', () => { + it('should not output $type field for every message', () => { + expect(Foo.fromPartial({})).toMatchInlineSnapshot(` + Object { + "timestamp": undefined, + } + `); + expect(Bar.fromPartial({})).toMatchInlineSnapshot(` + Object { + "foo": undefined, + } + `); + }); + + it('should register every type', () => { + expect(messageTypeRegistry.get('foo.Foo')).toBe(Foo); + expect(messageTypeRegistry.get('foo.bar.Bar')).toBe(Bar); + }); +}); diff --git a/integration/type-registry-no-tags/typeRegistry.ts b/integration/type-registry-no-tags/typeRegistry.ts new file mode 100644 index 000000000..11a0fe77b --- /dev/null +++ b/integration/type-registry-no-tags/typeRegistry.ts @@ -0,0 +1,20 @@ +/* eslint-disable */ +import * as _m0 from "protobufjs/minimal"; + +export interface MessageType { + encode(message: Message, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): Message; + fromJSON(object: any): Message; + toJSON(message: Message): unknown; + fromPartial(object: DeepPartial): Message; +} + +export type UnknownMessage = {}; + +export const messageTypeRegistry = new Map(); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/src/generate-type-registry.ts b/src/generate-type-registry.ts index 8a65d18b5..f6c1147ca 100644 --- a/src/generate-type-registry.ts +++ b/src/generate-type-registry.ts @@ -7,9 +7,15 @@ export function generateTypeRegistry(ctx: Context): Code { chunks.push(generateMessageType(ctx)); - chunks.push(code` - export type UnknownMessage = {$type: string}; - `); + if (ctx.options.outputTypeRegistry == "no-tags") { + chunks.push(code` + export type UnknownMessage = {}; + `); + } else { + chunks.push(code` + export type UnknownMessage = {$type: string}; + `); + } chunks.push(code` export const messageTypeRegistry = new Map(); @@ -25,7 +31,9 @@ function generateMessageType(ctx: Context): Code { chunks.push(code`export interface MessageType {`); - chunks.push(code`$type: Message['$type'];`); + if (ctx.options.outputTypeRegistry != "no-tags") { + chunks.push(code`$type: Message['$type'];`); + } if (ctx.options.outputEncodeMethods) { const Writer = impFile(ctx.options, "Writer@protobufjs/minimal"); diff --git a/src/main.ts b/src/main.ts index 6ca0bf753..910a4a3c8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -168,7 +168,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri const staticMembers: Code[] = []; - if (options.outputTypeRegistry) { + if (options.outputTypeRegistry === true) { staticMembers.push(code`$type: '${fullTypeName}' as const`); } @@ -209,7 +209,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri const messageTypeRegistry = impFile(options, "messageTypeRegistry@./typeRegistry"); chunks.push(code` - ${messageTypeRegistry}.set(${fullName}.$type, ${fullName}); + ${messageTypeRegistry}.set("${fullTypeName}", ${fullName}); `); } }, @@ -518,7 +518,7 @@ function makeDeepPartial(options: Options, longs: ReturnType` : code`keyof T`; + const keys = options.outputTypeRegistry === true ? code`Exclude` : code`keyof T`; const DeepPartial = conditionalOutput( "DeepPartial", code` @@ -594,7 +594,7 @@ function makeTimestampMethods(options: Options, longs: ReturnType code`${type}.encode(${utils.toTimestamp}(${place}), writer.uint32(${tag}).fork()).ldelim()`; } else if (isValueType(ctx, field)) { - const maybeTypeField = options.outputTypeRegistry ? `$type: '${field.typeName.slice(1)}',` : ""; + const maybeTypeField = options.outputTypeRegistry === true ? `$type: '${field.typeName.slice(1)}',` : ""; const type = basicTypeName(ctx, field, { keepValueType: true }); const wrappedValue = (place: string): Code => { @@ -1068,7 +1068,7 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP if (isRepeated(field)) { if (isMapType(ctx, messageDesc, field)) { const valueType = (typeMap.get(field.typeName)![2] as DescriptorProto).field[1]; - const maybeTypeField = options.outputTypeRegistry ? `$type: '${field.typeName.slice(1)}',` : ""; + const maybeTypeField = options.outputTypeRegistry === true ? `$type: '${field.typeName.slice(1)}',` : ""; const entryWriteSnippet = isValueType(ctx, valueType) ? code` if (value !== undefined) { @@ -1218,7 +1218,7 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, return { `); - if (ctx.options.outputTypeRegistry) { + if (ctx.options.outputTypeRegistry === true) { chunks.push(code`$type: ${fullName}.$type,`); } diff --git a/src/options.ts b/src/options.ts index 1cbc67b70..62397a854 100644 --- a/src/options.ts +++ b/src/options.ts @@ -47,7 +47,7 @@ export type Options = { outputEncodeMethods: boolean; outputJsonMethods: boolean; outputPartialMethods: boolean; - outputTypeRegistry: boolean; + outputTypeRegistry: boolean | "no-tags"; stringEnums: boolean; constEnums: boolean; enumsAsLiterals: boolean; From 18eda487cecd618130e00205b41918691fa61fc6 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 13:26:36 -0700 Subject: [PATCH 2/9] fix linter --- src/main.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 910a4a3c8..64880a2b3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -833,12 +833,12 @@ function generateBaseInstanceFactory( const val = isWithinOneOf(field) ? "undefined" : isMapType(ctx, messageDesc, field) - ? ctx.options.useMapType - ? "new Map()" - : "{}" - : isRepeated(field) - ? "[]" - : defaultValue(ctx, field); + ? ctx.options.useMapType + ? "new Map()" + : "{}" + : isRepeated(field) + ? "[]" + : defaultValue(ctx, field); fields.push(code`${name}: ${val}`); } From 3f6da6ce8a9bd2586b99cbfefffaee0c65be276f Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 13:46:45 -0700 Subject: [PATCH 3/9] failing regression test --- .../google/protobuf/empty.ts | 68 ++ .../google/protobuf/timestamp.ts | 218 +++++++ .../google/protobuf/wrappers.ts | 592 ++++++++++++++++++ .../wrappers-regression/parameters.txt | 1 + .../wrappers-regression-test.ts | 14 + .../wrappers-regression.bin | Bin 0 -> 13889 bytes .../wrappers-regression.proto | 10 + .../wrappers-regression.ts | 84 +++ 8 files changed, 987 insertions(+) create mode 100644 integration/wrappers-regression/google/protobuf/empty.ts create mode 100644 integration/wrappers-regression/google/protobuf/timestamp.ts create mode 100644 integration/wrappers-regression/google/protobuf/wrappers.ts create mode 100644 integration/wrappers-regression/parameters.txt create mode 100644 integration/wrappers-regression/wrappers-regression-test.ts create mode 100644 integration/wrappers-regression/wrappers-regression.bin create mode 100644 integration/wrappers-regression/wrappers-regression.proto create mode 100644 integration/wrappers-regression/wrappers-regression.ts diff --git a/integration/wrappers-regression/google/protobuf/empty.ts b/integration/wrappers-regression/google/protobuf/empty.ts new file mode 100644 index 000000000..4318905c6 --- /dev/null +++ b/integration/wrappers-regression/google/protobuf/empty.ts @@ -0,0 +1,68 @@ +/* eslint-disable */ +import * as _m0 from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A generic empty message that you can re-use to avoid defining duplicated + * empty messages in your APIs. A typical example is to use it as the request + * or the response type of an API method. For instance: + * + * service Foo { + * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + * } + * + * The JSON representation for `Empty` is empty JSON object `{}`. + */ +export interface Empty { +} + +function createBaseEmpty(): Empty { + return {}; +} + +export const Empty = { + encode(_: Empty, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Empty { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEmpty(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): Empty { + return {}; + }, + + toJSON(_: Empty): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial, I>>(_: I): Empty { + const message = createBaseEmpty(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; diff --git a/integration/wrappers-regression/google/protobuf/timestamp.ts b/integration/wrappers-regression/google/protobuf/timestamp.ts new file mode 100644 index 000000000..5497f7183 --- /dev/null +++ b/integration/wrappers-regression/google/protobuf/timestamp.ts @@ -0,0 +1,218 @@ +/* eslint-disable */ +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +function createBaseTimestamp(): Timestamp { + return { seconds: 0, nanos: 0 }; +} + +export const Timestamp = { + encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTimestamp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + return { + seconds: isSet(object.seconds) ? Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + }; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = Math.round(message.seconds)); + message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); + return obj; + }, + + fromPartial, I>>(object: I): Timestamp { + const message = createBaseTimestamp(); + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +// If you get a compile-error about 'Constructor and ... have no overlap', +// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/integration/wrappers-regression/google/protobuf/wrappers.ts b/integration/wrappers-regression/google/protobuf/wrappers.ts new file mode 100644 index 000000000..3145298cb --- /dev/null +++ b/integration/wrappers-regression/google/protobuf/wrappers.ts @@ -0,0 +1,592 @@ +/* eslint-disable */ +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * Wrapper message for `double`. + * + * The JSON representation for `DoubleValue` is JSON number. + */ +export interface DoubleValue { + /** The double value. */ + value: number; +} + +/** + * Wrapper message for `float`. + * + * The JSON representation for `FloatValue` is JSON number. + */ +export interface FloatValue { + /** The float value. */ + value: number; +} + +/** + * Wrapper message for `int64`. + * + * The JSON representation for `Int64Value` is JSON string. + */ +export interface Int64Value { + /** The int64 value. */ + value: number; +} + +/** + * Wrapper message for `uint64`. + * + * The JSON representation for `UInt64Value` is JSON string. + */ +export interface UInt64Value { + /** The uint64 value. */ + value: number; +} + +/** + * Wrapper message for `int32`. + * + * The JSON representation for `Int32Value` is JSON number. + */ +export interface Int32Value { + /** The int32 value. */ + value: number; +} + +/** + * Wrapper message for `uint32`. + * + * The JSON representation for `UInt32Value` is JSON number. + */ +export interface UInt32Value { + /** The uint32 value. */ + value: number; +} + +/** + * Wrapper message for `bool`. + * + * The JSON representation for `BoolValue` is JSON `true` and `false`. + */ +export interface BoolValue { + /** The bool value. */ + value: boolean; +} + +/** + * Wrapper message for `string`. + * + * The JSON representation for `StringValue` is JSON string. + */ +export interface StringValue { + /** The string value. */ + value: string; +} + +/** + * Wrapper message for `bytes`. + * + * The JSON representation for `BytesValue` is JSON string. + */ +export interface BytesValue { + /** The bytes value. */ + value: Uint8Array; +} + +function createBaseDoubleValue(): DoubleValue { + return { value: 0 }; +} + +export const DoubleValue = { + encode(message: DoubleValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(9).double(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDoubleValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DoubleValue { + return { value: isSet(object.value) ? Number(object.value) : 0 }; + }, + + toJSON(message: DoubleValue): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial, I>>(object: I): DoubleValue { + const message = createBaseDoubleValue(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseFloatValue(): FloatValue { + return { value: 0 }; +} + +export const FloatValue = { + encode(message: FloatValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(13).float(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFloatValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FloatValue { + return { value: isSet(object.value) ? Number(object.value) : 0 }; + }, + + toJSON(message: FloatValue): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial, I>>(object: I): FloatValue { + const message = createBaseFloatValue(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseInt64Value(): Int64Value { + return { value: 0 }; +} + +export const Int64Value = { + encode(message: Int64Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(8).int64(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInt64Value(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Int64Value { + return { value: isSet(object.value) ? Number(object.value) : 0 }; + }, + + toJSON(message: Int64Value): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + + fromPartial, I>>(object: I): Int64Value { + const message = createBaseInt64Value(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseUInt64Value(): UInt64Value { + return { value: 0 }; +} + +export const UInt64Value = { + encode(message: UInt64Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(8).uint64(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUInt64Value(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UInt64Value { + return { value: isSet(object.value) ? Number(object.value) : 0 }; + }, + + toJSON(message: UInt64Value): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + + fromPartial, I>>(object: I): UInt64Value { + const message = createBaseUInt64Value(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseInt32Value(): Int32Value { + return { value: 0 }; +} + +export const Int32Value = { + encode(message: Int32Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(8).int32(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInt32Value(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Int32Value { + return { value: isSet(object.value) ? Number(object.value) : 0 }; + }, + + toJSON(message: Int32Value): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + + fromPartial, I>>(object: I): Int32Value { + const message = createBaseInt32Value(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseUInt32Value(): UInt32Value { + return { value: 0 }; +} + +export const UInt32Value = { + encode(message: UInt32Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(8).uint32(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUInt32Value(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UInt32Value { + return { value: isSet(object.value) ? Number(object.value) : 0 }; + }, + + toJSON(message: UInt32Value): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + + fromPartial, I>>(object: I): UInt32Value { + const message = createBaseUInt32Value(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseBoolValue(): BoolValue { + return { value: false }; +} + +export const BoolValue = { + encode(message: BoolValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value === true) { + writer.uint32(8).bool(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBoolValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BoolValue { + return { value: isSet(object.value) ? Boolean(object.value) : false }; + }, + + toJSON(message: BoolValue): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial, I>>(object: I): BoolValue { + const message = createBaseBoolValue(); + message.value = object.value ?? false; + return message; + }, +}; + +function createBaseStringValue(): StringValue { + return { value: "" }; +} + +export const StringValue = { + encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== "") { + writer.uint32(10).string(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStringValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StringValue { + return { value: isSet(object.value) ? String(object.value) : "" }; + }, + + toJSON(message: StringValue): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial, I>>(object: I): StringValue { + const message = createBaseStringValue(); + message.value = object.value ?? ""; + return message; + }, +}; + +function createBaseBytesValue(): BytesValue { + return { value: new Uint8Array() }; +} + +export const BytesValue = { + encode(message: BytesValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value.length !== 0) { + writer.uint32(10).bytes(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBytesValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BytesValue { + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; + }, + + toJSON(message: BytesValue): unknown { + const obj: any = {}; + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + + fromPartial, I>>(object: I): BytesValue { + const message = createBaseBytesValue(); + message.value = object.value ?? new Uint8Array(); + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw "Unable to locate global object"; +})(); + +function bytesFromBase64(b64: string): Uint8Array { + if (globalThis.Buffer) { + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); + } else { + const bin = globalThis.atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; + } +} + +function base64FromBytes(arr: Uint8Array): string { + if (globalThis.Buffer) { + return globalThis.Buffer.from(arr).toString("base64"); + } else { + const bin: string[] = []; + arr.forEach((byte) => { + bin.push(String.fromCharCode(byte)); + }); + return globalThis.btoa(bin.join("")); + } +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +// If you get a compile-error about 'Constructor and ... have no overlap', +// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/integration/wrappers-regression/parameters.txt b/integration/wrappers-regression/parameters.txt new file mode 100644 index 000000000..5bfbc855e --- /dev/null +++ b/integration/wrappers-regression/parameters.txt @@ -0,0 +1 @@ +useDate=true,outputServices=generic-definitions,outputServices=default diff --git a/integration/wrappers-regression/wrappers-regression-test.ts b/integration/wrappers-regression/wrappers-regression-test.ts new file mode 100644 index 000000000..676d669d7 --- /dev/null +++ b/integration/wrappers-regression/wrappers-regression-test.ts @@ -0,0 +1,14 @@ +import { Clock } from './wrappers-regression'; + +const jan1 = new Date('1970-01-01T00:00:00.000Z'); +const feb1 = new Date('1970-02-01T00:00:00.000Z'); + +describe('useDate=true', () => { + it('generates a services that compiles', () => { + let c: Clock = { + Now: () => Promise.resolve(jan1), + NowString: () => Promise.resolve("anything, really"), + NowBool: () => Promise.resolve(true), + }; + }); +}); diff --git a/integration/wrappers-regression/wrappers-regression.bin b/integration/wrappers-regression/wrappers-regression.bin new file mode 100644 index 0000000000000000000000000000000000000000..fccc27c7add7545615ebb0da181d679abd052c4d GIT binary patch literal 13889 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 + NowString(request: Empty): Promise; + NowBool(request: Empty): Promise; +} + +export class ClockClientImpl implements Clock { + private readonly rpc: Rpc; + private readonly service: string; + constructor(rpc: Rpc, opts?: { service?: string }) { + this.service = opts?.service || "Clock"; + this.rpc = rpc; + this.Now = this.Now.bind(this); + this.NowString = this.NowString.bind(this); + this.NowBool = this.NowBool.bind(this); + } + Now(request: Empty): Promise { + const data = Empty.encode(request).finish(); + const promise = this.rpc.request(this.service, "Now", data); + return promise.then((data) => fromTimestamp(Timestamp.decode(new _m0.Reader(data)))); + } + + NowString(request: Empty): Promise { + const data = Empty.encode(request).finish(); + const promise = this.rpc.request(this.service, "NowString", data); + return promise.then((data) => string | undefined.decode(new _m0.Reader(data))); + } + + NowBool(request: Empty): Promise { + const data = Empty.encode(request).finish(); + const promise = this.rpc.request(this.service, "NowBool", data); + return promise.then((data) => boolean | undefined.decode(new _m0.Reader(data))); + } +} + +export type ClockDefinition = typeof ClockDefinition; +export const ClockDefinition = { + name: "Clock", + fullName: "Clock", + methods: { + now: { + name: "Now", + requestType: Empty, + requestStream: false, + responseType: Timestamp, + responseStream: false, + options: {}, + }, + nowString: { + name: "NowString", + requestType: Empty, + requestStream: false, + responseType: StringValue, + responseStream: false, + options: {}, + }, + nowBool: { + name: "NowBool", + requestType: Empty, + requestStream: false, + responseType: BoolValue, + responseStream: false, + options: {}, + }, + }, +} as const; + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} From c4c389d4b350d4a1c12e49d7b5a63bdb435d22d8 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 14:22:01 -0700 Subject: [PATCH 4/9] fix --- integration/angular/simple-message.bin | Bin 235 -> 235 bytes .../async-iterable-services/simple.bin | Bin 1033 -> 1033 bytes integration/async-iterable-services/simple.ts | 4 +-- .../simple.bin | Bin 1282 -> 1282 bytes .../simple2.bin | Bin 514 -> 514 bytes integration/avoid-import-conflicts/simple.bin | Bin 1947 -> 1947 bytes .../avoid-import-conflicts/simple2.bin | Bin 714 -> 714 bytes integration/barrel-imports/bar.bin | Bin 258 -> 258 bytes integration/barrel-imports/foo.bin | Bin 527 -> 527 bytes .../batching-with-context/batching.bin | Bin 2067 -> 2067 bytes integration/batching/batching.bin | Bin 2067 -> 2067 bytes integration/bytes-as-base64/message.bin | Bin 181 -> 181 bytes integration/bytes-node/point.bin | Bin 4899 -> 4899 bytes integration/const-enum/const-enum.bin | Bin 692 -> 692 bytes .../enums-as-literals-with-string-enums.bin | Bin 547 -> 547 bytes .../enums-as-literals/enums-as-literals.bin | Bin 511 -> 511 bytes integration/fieldmask/fieldmask.bin | Bin 8099 -> 8099 bytes integration/file-suffix/child.bin | Bin 340 -> 340 bytes integration/file-suffix/parent.bin | Bin 7180 -> 7180 bytes integration/generic-metadata/hero.bin | Bin 1049 -> 1049 bytes integration/generic-metadata/hero.ts | 2 +- .../simple.bin | Bin 1232 -> 1232 bytes .../generic-service-definitions/simple.bin | Bin 1232 -> 1232 bytes integration/global-this/global-this.bin | Bin 315 -> 315 bytes integration/grpc-js/google/protobuf/struct.ts | 4 +-- .../grpc-js/google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes integration/grpc-js/simple.bin | Bin 20909 -> 20908 bytes integration/grpc-web-go-server/example.bin | Bin 3082 -> 3082 bytes .../example.bin | Bin 1443 -> 1443 bytes integration/grpc-web-no-streaming/example.bin | Bin 1443 -> 1443 bytes integration/grpc-web/example.bin | Bin 3278 -> 3278 bytes integration/import-mapping/mapping.bin | Bin 19707 -> 19706 bytes .../some/internal/repo/very_private.bin | Bin 271 -> 271 bytes integration/import-suffix/child.bin | Bin 340 -> 340 bytes integration/import-suffix/parent.bin | Bin 7180 -> 7180 bytes integration/lower-case-svc-methods/math.bin | Bin 792 -> 792 bytes .../meta-typings/google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes integration/meta-typings/google/type/date.bin | Bin 2086 -> 2086 bytes integration/meta-typings/import_dir/thing.bin | Bin 6652 -> 6652 bytes integration/meta-typings/simple.bin | Bin 21424 -> 21424 bytes integration/nestjs-metadata-grpc-js/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-metadata-observables/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-metadata-restparameters/hero.bin | Bin 1049 -> 1049 bytes integration/nestjs-metadata/hero.bin | Bin 1049 -> 1049 bytes integration/nestjs-restparameters/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-simple-observables/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-simple-restparameters/hero.bin | Bin 2821 -> 2821 bytes integration/nestjs-simple-usedate/hero.bin | Bin 10339 -> 10339 bytes integration/nestjs-simple/hero.bin | Bin 10339 -> 10339 bytes .../nice-grpc/google/protobuf/struct.ts | 4 +-- .../nice-grpc/google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes integration/nice-grpc/simple.bin | Bin 20909 -> 20908 bytes .../no-proto-package/no-proto-package.bin | Bin 364 -> 364 bytes integration/omit-optionals/simple.bin | Bin 313 -> 313 bytes integration/oneof-properties/oneof.bin | Bin 1927 -> 1927 bytes .../google/protobuf/struct.ts | 4 +-- integration/oneof-unions-snake/simple.bin | Bin 4860 -> 4859 bytes .../oneof-unions/google/protobuf/struct.ts | 4 +-- integration/oneof-unions/oneof.bin | Bin 6933 -> 6932 bytes .../only-types-grpc-metadata.bin | Bin 518 -> 518 bytes integration/only-types/reservation.bin | Bin 12585 -> 12585 bytes integration/options/options.bin | Bin 53110 -> 53110 bytes integration/options/something/something.bin | Bin 50401 -> 50401 bytes integration/point/point.bin | Bin 437 -> 437 bytes integration/reserved-words/reserved-words.bin | Bin 118 -> 118 bytes integration/return-observable/observable.bin | Bin 463 -> 463 bytes .../simple-deprecated-fields/simple.bin | Bin 887 -> 887 bytes .../simple-esmodule-interop/simple.bin | Bin 1260 -> 1260 bytes integration/simple-json-name/simple.bin | Bin 7629 -> 7629 bytes .../google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes integration/simple-long-string/simple.bin | Bin 12009 -> 12009 bytes .../simple-long/google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes integration/simple-long/simple.bin | Bin 6984 -> 6984 bytes .../google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes .../simple-optionals/import_dir/thing.bin | Bin 6652 -> 6652 bytes integration/simple-optionals/simple.bin | Bin 17257 -> 17257 bytes integration/simple-optionals/thing.bin | Bin 6630 -> 6630 bytes integration/simple-proto2/simple.bin | Bin 368 -> 368 bytes .../google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes .../google/type/date.bin | Bin 2086 -> 2086 bytes .../import_dir/thing.bin | Bin 6652 -> 6652 bytes .../simple-prototype-defaults/simple.bin | Bin 21978 -> 21978 bytes .../simple-snake/google/protobuf/struct.ts | 4 +-- .../simple-snake/google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes integration/simple-snake/import_dir/thing.bin | Bin 6652 -> 6652 bytes integration/simple-snake/simple.bin | Bin 21936 -> 21935 bytes .../google/protobuf/struct.ts | 4 +-- integration/simple-string-enums/simple.bin | Bin 5425 -> 5424 bytes .../google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes .../import_dir/thing.bin | Bin 6652 -> 6652 bytes .../simple-unrecognized-enum/simple.bin | Bin 17257 -> 17257 bytes .../simple/google/protobuf/wrappers.bin | Bin 4316 -> 4316 bytes integration/simple/google/type/date.bin | Bin 2086 -> 2086 bytes integration/simple/import_dir/thing.bin | Bin 6652 -> 6652 bytes integration/simple/simple.bin | Bin 22063 -> 22063 bytes integration/struct/google/protobuf/struct.ts | 4 +-- integration/struct/struct.bin | Bin 4735 -> 4734 bytes integration/type-registry/bar/bar.bin | Bin 11628 -> 11627 bytes integration/type-registry/foo.bin | Bin 11423 -> 11422 bytes .../type-registry/google/protobuf/struct.ts | 4 +-- integration/types-with-underscores/file.bin | Bin 253 -> 253 bytes .../google/protobuf/compiler/plugin.bin | Bin 59345 -> 59345 bytes .../google/protobuf/descriptor.bin | Bin 49697 -> 49697 bytes integration/unknown-fields/options.bin | Bin 52894 -> 52894 bytes .../unknown-fields/something/something.bin | Bin 50185 -> 50185 bytes integration/use-date-false/metadata.bin | Bin 6615 -> 6615 bytes .../use-date-string/use-date-string.bin | Bin 7234 -> 7234 bytes .../use-date-true/use-date-true-test.ts | 4 +-- integration/use-date-true/use-date-true.bin | Bin 9787 -> 9787 bytes integration/use-date-true/use-date-true.ts | 6 ++-- integration/use-exact-types-false/foo.bin | Bin 256 -> 256 bytes .../use-json-wire-format.bin | Bin 19667 -> 19667 bytes integration/use-map-type/use-map-type.bin | Bin 7634 -> 7634 bytes .../google/protobuf/struct.ts | 4 +-- integration/use-numeric-enum-json/simple.bin | Bin 5425 -> 5424 bytes .../objectid/objectid.bin | Bin 228 -> 228 bytes .../use-objectid-true.bin | Bin 1014 -> 1014 bytes integration/use-optionals-all/test.bin | Bin 2755 -> 2755 bytes integration/value/google/protobuf/struct.ts | 4 +-- integration/value/value.bin | Bin 9829 -> 9828 bytes integration/vector-tile/vector_tile.bin | Bin 2942 -> 2942 bytes .../wrappers-regression-test.ts | 16 +++++++--- .../wrappers-regression.bin | Bin 13889 -> 13896 bytes .../wrappers-regression.proto | 3 +- .../wrappers-regression.ts | 28 +++++++----------- src/generate-services.ts | 12 ++++---- src/types.ts | 14 +++++---- 127 files changed, 68 insertions(+), 61 deletions(-) diff --git a/integration/angular/simple-message.bin b/integration/angular/simple-message.bin index 7a24454348ff64ccbd9084fb5ac4bb0b98a78af0..21b89c308516484424853dd9cc8f1d726c1fb822 100644 GIT binary patch delta 13 UcmaFO_?mHoG_#-t^F+C`03Xf-F8}}l delta 13 UcmaFO_?mHoG_$Y-<3zc$03Xr>F8}}l diff --git a/integration/async-iterable-services/simple.bin b/integration/async-iterable-services/simple.bin index 51973c2d88e7b26464905a62e5a918c127cfdd29..5294e475257e367dd84900f46fa40cc895f03f8a 100644 GIT binary patch delta 31 mcmeC==;RRN;wjF|EyzjLD=5k@$(Q2bU=|RRVBRS9nHd0z2?${T delta 31 mcmeC==;RRN;wjF|EyzjLD=5k@$(Q2bU=|RTVB9G7nHd0z4G3WX diff --git a/integration/async-iterable-services/simple.ts b/integration/async-iterable-services/simple.ts index 73c36d6c7..b63b952b8 100644 --- a/integration/async-iterable-services/simple.ts +++ b/integration/async-iterable-services/simple.ts @@ -122,13 +122,13 @@ export class EchoerClientImpl implements Echoer { return EchoMsg.decodeTransform(result); } - EchoClientStream(request: AsyncIterable): Promise { + EchoClientStream(request: EchoMsg): Promise { const data = EchoMsg.encodeTransform(request); const promise = this.rpc.clientStreamingRequest(this.service, "EchoClientStream", data); return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); } - EchoBidiStream(request: AsyncIterable): AsyncIterable { + EchoBidiStream(request: EchoMsg): AsyncIterable { const data = EchoMsg.encodeTransform(request); const result = this.rpc.bidirectionalStreamingRequest(this.service, "EchoBidiStream", data); return EchoMsg.decodeTransform(result); diff --git a/integration/avoid-import-conflicts-types-only/simple.bin b/integration/avoid-import-conflicts-types-only/simple.bin index 75915195a7f2a06bab35fda280e54969138b0d5c..de3374c941be52bda0b8dabeab25bbedccdd9149 100644 GIT binary patch delta 31 mcmZqTYT^>(;wjF|EyzjLD=5k@$(Q2bU=|RRVBRS9h6MnK%m`5c delta 31 mcmZqTYT^>(;wjF|EyzjLD=5k@$(Q2bU=|RTVB9G7h6MnK&EjEj0|+Sq diff --git a/integration/avoid-import-conflicts/simple2.bin b/integration/avoid-import-conflicts/simple2.bin index a172b14bd31dd090ec2567e466acb65f211cdc68..f3d40f0b96209660c1502d72b7c1adaaf9686719 100644 GIT binary patch delta 14 VcmX@bdWv;|2(zFB^G5N_OaLJL1MdI; delta 14 VcmX@bdWv;|2(z#R<3{n#OaLJP1MdI; diff --git a/integration/barrel-imports/bar.bin b/integration/barrel-imports/bar.bin index 8b84bf73907da9e45870748142e9b8e39a12d045..5e870abc46ef54c2022fd372ca0414fc3654afb1 100644 GIT binary patch delta 27 icmZo-YGM-R;!H{`(km#+FUgnU;9wRIlwh7H{2l;Y>IT99 delta 27 icmZo-YGM-R;!H{`(km#+FUgnU;9wRImSCJH{2l;Y?gqjD diff --git a/integration/barrel-imports/foo.bin b/integration/barrel-imports/foo.bin index 26df53209563317a81ef59344b7843191822ace8..47ee411d838e237ad4d96a9c3c2bb452309a420e 100644 GIT binary patch delta 28 jcmeBY>1Pq<;!MlW*DEN>FUgnU;9wRIlwjT{{D%<$XrKoj delta 28 jcmeBY>1Pq<;!MlW*DEN>FUgnU;9wRImSEf{{D%<$Xru=n diff --git a/integration/batching-with-context/batching.bin b/integration/batching-with-context/batching.bin index 5d6ad57e0e1c0de99ad8aa323e9806a6faa3cd12..0e8e853370a2cfd6a111be605c470225a26b55e8 100644 GIT binary patch delta 14 VcmbO%Fj-)ND6^mh^G1o^>;N4Q1Lgn# delta 14 VcmbO%Fj-)ND6_Bx<3@?!>;N4U1Lgn# diff --git a/integration/batching/batching.bin b/integration/batching/batching.bin index 5d6ad57e0e1c0de99ad8aa323e9806a6faa3cd12..0e8e853370a2cfd6a111be605c470225a26b55e8 100644 GIT binary patch delta 14 VcmbO%Fj-)ND6^mh^G1o^>;N4Q1Lgn# delta 14 VcmbO%Fj-)ND6_Bx<3@?!>;N4U1Lgn# diff --git a/integration/bytes-as-base64/message.bin b/integration/bytes-as-base64/message.bin index b035d9e0987c3b631972dc4504f0c0488a8a70b1..af5507d7e90153bc654e65e464984f1c9745fa13 100644 GIT binary patch delta 13 UcmdnWxRr5&2(zFB^F;A^02)aHh5!Hn delta 13 UcmdnWxRr5&2(z#R<3#a!02)mLh5!Hn diff --git a/integration/bytes-node/point.bin b/integration/bytes-node/point.bin index da2590837ef704fc90bf268666036ac5f13c650e..b4ff5033a4bea2a324e961a968fffcbf8e7f1c02 100644 GIT binary patch delta 30 lcmZ3iwpdM+i@P8{Gp|IipeVm2Uy6f+SwK*Nd7~(wFaU}62bll> delta 30 lcmZ3iwpdM+i@P8{Gp|IipeVm2Uy6f+SwL8Vaib`oFaU}A2bll> diff --git a/integration/const-enum/const-enum.bin b/integration/const-enum/const-enum.bin index 978b99505904c60903aa720123e5d8338c931cf0..8f9416c8e6733397366d626d256a5be62060c639 100644 GIT binary patch delta 14 VcmdnOx`lOuIJ2Mx^G2yzOaLCU1F!%9 delta 14 VcmdnOx`lOuIJ2+><3_1jOaLCY1F!%9 diff --git a/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.bin b/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.bin index b5d5687aeedf9b00abd60c01571961464e4a717e..de5ef01a99cbc7af461b01da5d4110939305e674 100644 GIT binary patch delta 21 dcmZ3?vY2Ip0f(Rjvl2tqYvu{s8zqY^{aYvu{s8p3>1PuTH delta 14 VcmZ2%zu10)7_+bh<3`CYc>p3_1PuTH diff --git a/integration/file-suffix/child.bin b/integration/file-suffix/child.bin index 7c926897631cb09bc5d2042d1ab6dff7e70e104f..29e6d303107e85e6f0efbc3fec06760ffd859f8e 100644 GIT binary patch delta 30 lcmcb@bcIQji#s_ZGbcr_peVm2Uy6f+SwK*Nd84R3BLIqH2dn@9 delta 30 lcmcb@bcIQji#s_ZGbcr_peVm2Uy6f+SwL8Vaigd`BLIqL2dn@9 diff --git a/integration/file-suffix/parent.bin b/integration/file-suffix/parent.bin index 222ccda6aa9607a569b8ad0af498f677f795da51..f4da644572c491875271fca726ae95a9e1c0905a 100644 GIT binary patch delta 41 wcmeCN=&_LD;weZhO3f?LD=5k@$(Q2bU=|RRU{+$NI&R1{*-lDfqs;|r0QTAokpKVy delta 41 wcmeCN=&_LD;weZhO3f?LD=5k@$(Q2bU=|RTU{qqLI&R1{*-lDfqs;|r0QTMskpKVy diff --git a/integration/generic-metadata/hero.bin b/integration/generic-metadata/hero.bin index ad7849d17bff39fbe083ea9e81562311c70283f2..cef024802e293270d1c4a54aa67689f913804365 100644 GIT binary patch delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv05tqX;Vt0CZFavH$=8 delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv;rtqX;Vt0CZRevH$=8 diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index d6e622b97..7dcda39fd 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -256,7 +256,7 @@ export class HeroServiceClientImpl implements HeroService { return promise.then((data) => Villain.decode(new _m0.Reader(data))); } - FindManyVillain(request: Observable): Observable { + FindManyVillain(request: VillainById): Observable { const data = request.pipe(map((request) => VillainById.encode(request).finish())); const result = this.rpc.bidirectionalStreamingRequest(this.service, "FindManyVillain", data); return result.pipe(map((data) => Villain.decode(new _m0.Reader(data)))); diff --git a/integration/generic-service-definitions-and-services/simple.bin b/integration/generic-service-definitions-and-services/simple.bin index f101042dfad06cea0dd9f01bac4101bc8aaececa..5962c62769252da8bc2b9293481899eb101fedab 100644 GIT binary patch delta 31 mcmcb>d4W@mi>Ejd4W@mi>Ejd4W@mi>Ejd4W@mi>Ej13v%& diff --git a/integration/grpc-js/google/protobuf/struct.ts b/integration/grpc-js/google/protobuf/struct.ts index 80a98258e..081b74075 100644 --- a/integration/grpc-js/google/protobuf/struct.ts +++ b/integration/grpc-js/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/grpc-js/google/protobuf/wrappers.bin b/integration/grpc-js/google/protobuf/wrappers.bin index 7f34d6ce0cd3a5ebf8b18b31567e0fd536c12f1b..1c3a982c95fd4b1add11db32f11cfd2f5f4fd90c 100644 GIT binary patch delta 21 ccmcbkct>%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/grpc-js/simple.bin b/integration/grpc-js/simple.bin index a4adec6064309d08147fbbb804084e27b84dc709..fe10fc851f4b806bece4608878e4e293a36d1905 100644 GIT binary patch delta 106 zcmV-w0G0o(qXDd=0Tv1jb7^gGY-KKRa&L5R8VCpj5D^#yu@=EH1O6fklh8yRv-dK+ z0tuNN3I-Ac9spjmUkZ%|vr0UO0uI9h3IYTH5(GT}O#vFVli)td4`Fl)Aa-GLX<=@3 Mb1WcXv$;R?5xJBg-T(jq delta 117 zcmV-*0E+*tqXDg>0UQbpb7^gGY-KKRa&L5R8VCpj5EB>yA^>{75(<-XL>#d=pE3jg zA_|kwL>;sDGQ9!`njH!T5(FLqUb9~cjRvzyJct4g!~zNe1OXBRJpfGs8n=_+KFJVe Xb7cx3c42a9VQzGDE+9d(xIgp}9atm` diff --git a/integration/grpc-web-go-server/example.bin b/integration/grpc-web-go-server/example.bin index 1c0736d4271b1dc3ee5e1730b07fa1117635745a..3ad33b93bf0d53bacfcf455c64e00c4133f6683e 100644 GIT binary patch delta 14 VcmeB@=#rQq!YnAkyixo!Hvk;Y1Kt1t delta 14 VcmeB@=#rQq!YnMoxKaEwHvk;c1Kt1t diff --git a/integration/grpc-web-no-streaming-observable/example.bin b/integration/grpc-web-no-streaming-observable/example.bin index 0b96ce0c60a7879c3d721d3e3c69ad69ecc6c789..4b52601f5c539bb58ca15e3014b860d7beae15d9 100644 GIT binary patch delta 14 VcmZ3?y_kD~2(zFB^G5L=RsbDL1Bn0t delta 14 VcmZ3?y_kD~2(z#R<3{lwRsbDP1Bn0t diff --git a/integration/grpc-web-no-streaming/example.bin b/integration/grpc-web-no-streaming/example.bin index 0b96ce0c60a7879c3d721d3e3c69ad69ecc6c789..4b52601f5c539bb58ca15e3014b860d7beae15d9 100644 GIT binary patch delta 14 VcmZ3?y_kD~2(zFB^G5L=RsbDL1Bn0t delta 14 VcmZ3?y_kD~2(z#R<3{lwRsbDP1Bn0t diff --git a/integration/grpc-web/example.bin b/integration/grpc-web/example.bin index 72f331cf3e1bc492cb01c75424a58d5c31f7426c..ea862e9d0c0875f6eb035acfbecaa74acc896772 100644 GIT binary patch delta 14 VcmX>nc}{YI2(zFB^G5OQJOCqC1T6pn delta 14 VcmX>nc}{YI2(z#R<3{oAJOCqG1T6pn diff --git a/integration/import-mapping/mapping.bin b/integration/import-mapping/mapping.bin index 28d0434e139369d296e27172d0b00ad32f4eccff..20e991f853a71d289dcc61e5085f444df63212ce 100644 GIT binary patch delta 76 zcmV-S0JH!5nF0El0gw~}5f}rp7a$x1{vryKz(*akR~)?p0hzNE9~}t}!vYEd1OXBR iJpfGs8n%-_D9I0DbP6DLVRC6Svmu!z?JlJW>Av02l!St^fc4 delta 13 UcmeBY>Svmu!z?VpI8pxr02l=Wt^fc4 diff --git a/integration/import-suffix/child.bin b/integration/import-suffix/child.bin index 7c926897631cb09bc5d2042d1ab6dff7e70e104f..29e6d303107e85e6f0efbc3fec06760ffd859f8e 100644 GIT binary patch delta 30 lcmcb@bcIQji#s_ZGbcr_peVm2Uy6f+SwK*Nd84R3BLIqH2dn@9 delta 30 lcmcb@bcIQji#s_ZGbcr_peVm2Uy6f+SwL8Vaigd`BLIqL2dn@9 diff --git a/integration/import-suffix/parent.bin b/integration/import-suffix/parent.bin index 222ccda6aa9607a569b8ad0af498f677f795da51..f4da644572c491875271fca726ae95a9e1c0905a 100644 GIT binary patch delta 41 wcmeCN=&_LD;weZhO3f?LD=5k@$(Q2bU=|RRU{+$NI&R1{*-lDfqs;|r0QTAokpKVy delta 41 wcmeCN=&_LD;weZhO3f?LD=5k@$(Q2bU=|RTU{qqLI&R1{*-lDfqs;|r0QTMskpKVy diff --git a/integration/lower-case-svc-methods/math.bin b/integration/lower-case-svc-methods/math.bin index eddba34a47ed61e44755939da6271b2a424e561e..588e6998f8462ef420a8c1ff6e95a1fa83d9854e 100644 GIT binary patch delta 29 kcmbQiHiJ!siz_#=Btx&DD8D3Mii3k$Kv05tqX-K#0CQ>vrT_o{ delta 29 kcmbQiHiJ!siz_#=Btx&DD8D3Mii3k$Kv;rtqX-K#0CR2zrT_o{ diff --git a/integration/meta-typings/google/protobuf/wrappers.bin b/integration/meta-typings/google/protobuf/wrappers.bin index 7f34d6ce0cd3a5ebf8b18b31567e0fd536c12f1b..1c3a982c95fd4b1add11db32f11cfd2f5f4fd90c 100644 GIT binary patch delta 21 ccmcbkct>%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/meta-typings/google/type/date.bin b/integration/meta-typings/google/type/date.bin index 680ba7e6dd305c29b45f37db9716864b397b1a72..79b7489a478d8c39160305aeda937b750ffabd82 100644 GIT binary patch delta 14 VcmZ1`uuNcrEVG~l^F{?W4gei>11JCh delta 14 VcmZ1`uuNcrEVHl#<3c)Mlmj);>_HFoK(GnqWqG4DGm;10YM4ojbgKc0lO0k<^TWy delta 33 ocmdn6oN>c)Mlmj);>_HFoK(GnqWqG4DGm;10bvQojbgKc0lOCo<^TWy diff --git a/integration/nestjs-metadata-grpc-js/hero.bin b/integration/nestjs-metadata-grpc-js/hero.bin index ad7849d17bff39fbe083ea9e81562311c70283f2..cef024802e293270d1c4a54aa67689f913804365 100644 GIT binary patch delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv05tqX;Vt0CZFavH$=8 delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv;rtqX;Vt0CZRevH$=8 diff --git a/integration/nestjs-metadata-observables/hero.bin b/integration/nestjs-metadata-observables/hero.bin index ad7849d17bff39fbe083ea9e81562311c70283f2..cef024802e293270d1c4a54aa67689f913804365 100644 GIT binary patch delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv05tqX;Vt0CZFavH$=8 delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv;rtqX;Vt0CZRevH$=8 diff --git a/integration/nestjs-metadata-restparameters/hero.bin b/integration/nestjs-metadata-restparameters/hero.bin index ad7849d17bff39fbe083ea9e81562311c70283f2..cef024802e293270d1c4a54aa67689f913804365 100644 GIT binary patch delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv05tqX;Vt0CZFavH$=8 delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv;rtqX;Vt0CZRevH$=8 diff --git a/integration/nestjs-metadata/hero.bin b/integration/nestjs-metadata/hero.bin index ad7849d17bff39fbe083ea9e81562311c70283f2..cef024802e293270d1c4a54aa67689f913804365 100644 GIT binary patch delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv05tqX;Vt0CZFavH$=8 delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv;rtqX;Vt0CZRevH$=8 diff --git a/integration/nestjs-restparameters/hero.bin b/integration/nestjs-restparameters/hero.bin index ad7849d17bff39fbe083ea9e81562311c70283f2..cef024802e293270d1c4a54aa67689f913804365 100644 GIT binary patch delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv05tqX;Vt0CZFavH$=8 delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv;rtqX;Vt0CZRevH$=8 diff --git a/integration/nestjs-simple-observables/hero.bin b/integration/nestjs-simple-observables/hero.bin index ad7849d17bff39fbe083ea9e81562311c70283f2..cef024802e293270d1c4a54aa67689f913804365 100644 GIT binary patch delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv05tqX;Vt0CZFavH$=8 delta 29 kcmbQqF_S}tiz_3wC||FjD8D3Mii3k$Kv;rtqX;Vt0CZRevH$=8 diff --git a/integration/nestjs-simple-restparameters/hero.bin b/integration/nestjs-simple-restparameters/hero.bin index 0e82b21bc0fadcd898a0b49d002579d1074c5fd5..709f8464cb82cb0cb0c09ff473a0de47ad474309 100644 GIT binary patch delta 39 ucmZn_YZa5?;>t)Z%GWC>$}h>6;^1Hw5R_n6VyN0L#5FmOQ)Z*tc`g9ST?#t@ delta 39 ucmZn_YZa5?;>t)Z%GWC>$}h>6;^1Hw5SCz6VyN0L#5FmOQ)Z*tc`g9SVG26{ diff --git a/integration/nestjs-simple-usedate/hero.bin b/integration/nestjs-simple-usedate/hero.bin index 3ce8c0002f7898aaeb78e40ea3d5a6a27c2c00c6..72f5de73a9e0bdda7ab1679a6d4bc19145a75f57 100644 GIT binary patch delta 29 kcmaDH@Hjw(iz_3wC||FjD8D3Mii3k$Kv05tqlmu-0F-P9L;wH) delta 29 kcmaDH@Hjw(iz_3wC||FjD8D3Mii3k$Kv;rtqlmu-0F-bDL;wH) diff --git a/integration/nestjs-simple/hero.bin b/integration/nestjs-simple/hero.bin index 3ce8c0002f7898aaeb78e40ea3d5a6a27c2c00c6..72f5de73a9e0bdda7ab1679a6d4bc19145a75f57 100644 GIT binary patch delta 29 kcmaDH@Hjw(iz_3wC||FjD8D3Mii3k$Kv05tqlmu-0F-P9L;wH) delta 29 kcmaDH@Hjw(iz_3wC||FjD8D3Mii3k$Kv;rtqlmu-0F-bDL;wH) diff --git a/integration/nice-grpc/google/protobuf/struct.ts b/integration/nice-grpc/google/protobuf/struct.ts index 41ef5d717..9041af0bb 100644 --- a/integration/nice-grpc/google/protobuf/struct.ts +++ b/integration/nice-grpc/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/nice-grpc/google/protobuf/wrappers.bin b/integration/nice-grpc/google/protobuf/wrappers.bin index 7f34d6ce0cd3a5ebf8b18b31567e0fd536c12f1b..1c3a982c95fd4b1add11db32f11cfd2f5f4fd90c 100644 GIT binary patch delta 21 ccmcbkct>%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/nice-grpc/simple.bin b/integration/nice-grpc/simple.bin index a4adec6064309d08147fbbb804084e27b84dc709..fe10fc851f4b806bece4608878e4e293a36d1905 100644 GIT binary patch delta 106 zcmV-w0G0o(qXDd=0Tv1jb7^gGY-KKRa&L5R8VCpj5D^#yu@=EH1O6fklh8yRv-dK+ z0tuNN3I-Ac9spjmUkZ%|vr0UO0uI9h3IYTH5(GT}O#vFVli)td4`Fl)Aa-GLX<=@3 Mb1WcXv$;R?5xJBg-T(jq delta 117 zcmV-*0E+*tqXDg>0UQbpb7^gGY-KKRa&L5R8VCpj5EB>yA^>{75(<-XL>#d=pE3jg zA_|kwL>;sDGQ9!`njH!T5(FLqUb9~cjRvzyJct4g!~zNe1OXBRJpfGs8n=_+KFJVe Xb7cx3c42a9VQzGDE+9d(xIgp}9atm` diff --git a/integration/no-proto-package/no-proto-package.bin b/integration/no-proto-package/no-proto-package.bin index b23df4108ff9bd5aee9eae4ae174a6702ef7ab4c..06e8a111a3b76772a904c53338e2f3f1451a314e 100644 GIT binary patch delta 14 VcmaFE^oD7IEVG~l^F{?9MgSwm1J?im delta 14 VcmaFE^oD7IEVHl#<3EjEj)SD9SI%m*U`H77&zR-Y8nc4gh`I2Y3Jg delta 30 lcmZqYZ|4`~;?B=Y%}>)SD9SI%m*U`H77&(T+$dVa4gh`M2Y3Jg diff --git a/integration/oneof-unions-snake/google/protobuf/struct.ts b/integration/oneof-unions-snake/google/protobuf/struct.ts index fdf3803b1..a6fd88863 100644 --- a/integration/oneof-unions-snake/google/protobuf/struct.ts +++ b/integration/oneof-unions-snake/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/oneof-unions-snake/simple.bin b/integration/oneof-unions-snake/simple.bin index ca4927412a548a0607195dd36430ccde631d9237..f6cbaf1fe7dcb7d7d873315c8bdc86ac2b547bae 100644 GIT binary patch delta 82 zcmeyP`dd|si>Ejfc7GJ4}o-H-Bf6<>Wie#KpwI mD8ypR;L9krZL$*2N&dtVE`_qhqRhm+l42c&#Ld5X7})>-gBUpg delta 83 zcmeyZ`bSlYi>EjDW~>iWiU#KpwI nD8ypR;L9kreXSZyE>)0}v4y10n!={vryKu@N1yIK2V^nX~o+ t9SIJ@0tx~I0TKi~08IfJwv!SZyE>)0}vA!0U`i;{~`*Lun`@xIK2V^nzQx- u9SIJ^0tx~I0TKi~08IfJx04|Z$q;38WeOm6VRC6ywgSs5b$ diff --git a/integration/only-types-grpc-metadata/only-types-grpc-metadata.bin b/integration/only-types-grpc-metadata/only-types-grpc-metadata.bin index e43e9b9970279217195549a756fd9ee5ff6043a1..1d80a96d221f415ee5a5b6fc3855c629ef9a58df 100644 GIT binary patch delta 21 ccmZo;X=9n7${{Ghti(`tlX-%|M&F%`06F>v-T(jq delta 21 ccmZo;X=9n7${{SlsKiiplX-%|M&F%`06G2z-T(jq diff --git a/integration/only-types/reservation.bin b/integration/only-types/reservation.bin index 27024a9e94493da12640f0ee3d79d10277033396..fd75bd8480e48c465c2fedeb069750fd762a7c0c 100644 GIT binary patch delta 14 VcmZ3Pv@&Ue1hb$7^G0btLjWak1Ni^| delta 14 VcmZ3Pv@&Ue1hcRN<3?#dLjWao1Ni^| diff --git a/integration/options/options.bin b/integration/options/options.bin index a96b5e3cb2a86729b4d7b39e7a5e3713dda39be5..0621b262785274b4d1ac191070e363712ff3d1ac 100644 GIT binary patch delta 27 jcmex1kNMj?<_RKPf)dP13{@vvnYktl99Gs$i@P8{Gp|IipeVm2Uy6f+SwK*Nd86n8MgWI&2loH~ delta 30 lcmdnWyp>s$i@P8{Gp|IipeVm2Uy6f+SwL8Vaii!0MgWI+2loH~ diff --git a/integration/reserved-words/reserved-words.bin b/integration/reserved-words/reserved-words.bin index 9d07dc9bf82eaca2f3785a5dab05d9298ed45140..7a55377a27dcc3d97abde42eeb2746fa64b82263 100644 GIT binary patch delta 11 ScmXRbn;^|BD8W2YE&>1&=K{_E delta 11 ScmXRbn;^|BEWtQYE&>1&>jKUI diff --git a/integration/return-observable/observable.bin b/integration/return-observable/observable.bin index 267c620b980172d49684a2a9fe685d4da039efea..8a42177f52bfb309763a41b176429ca86695610b 100644 GIT binary patch delta 14 VcmX@le4crNIJ2Mx^G2zyi~u2a1N;C0 delta 14 VcmX@le4crNIJ2+><3_2ii~u2e1N;C0 diff --git a/integration/simple-deprecated-fields/simple.bin b/integration/simple-deprecated-fields/simple.bin index edc1b92bd4925c96e9de9d59b141d76e7448e6da..6e2d774abaa9daedd9ab4b3d71cdce42a2cfcaed 100644 GIT binary patch delta 31 mcmey)_MJ_Pi>EjEjEjEjEjEj%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/simple-long-string/simple.bin b/integration/simple-long-string/simple.bin index 486951c66c1bdf852db9b45c8c771dd674819fbd..5793ee87c2a40d8b422fb14d309d817599500e59 100644 GIT binary patch delta 41 xcmaDE`!ZIBi>EjEjDW~YP}-Y%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/simple-long/simple.bin b/integration/simple-long/simple.bin index 28e779a04fd87f68e62cade58bc74d219e39b719..1a8171469f15ecbb01969a9b151b9e6353f64fcb 100644 GIT binary patch delta 31 mcmX?McEU`Ii>EjEj%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/simple-optionals/import_dir/thing.bin b/integration/simple-optionals/import_dir/thing.bin index 18377ed61039b9e0223782d6b1fd66d34cd8c98e..777648ff4502757afb78a7feacbec6bb9ac73adf 100644 GIT binary patch delta 14 Vcmexk{Kt5LEVG~l^G1a`k^n0<1pxp6 delta 14 Vcmexk{Kt5LEVHl#<3@!$k^n0@1pxp6 diff --git a/integration/simple-optionals/simple.bin b/integration/simple-optionals/simple.bin index d6a2033aed6652e29d11a35799c6e4c716c2ab34..b9bddba28a71f7bed47eeca462b1c7c63c8cde83 100644 GIT binary patch delta 43 ycmaFa#`v<0QHG1BI5W2(CsnVYD8D3Mii3k$Kv05NiJ@w}BG=@7TJjsM^_&4QqYTvm delta 43 ycmaFa#`v<0QHG1BI5W2(CsnVYD8D3Mii3k$Kv;rNiJ@w}BG=@7TJjsM^_&4Qrwr8q diff --git a/integration/simple-optionals/thing.bin b/integration/simple-optionals/thing.bin index 1320735295cf71c32f1f3133a17ffdb8820e901f..188b45a5849c0ef42dc90c4a87073867498bf787 100644 GIT binary patch delta 30 lcmaE6{LEOCi@PKvGcR4QpeVm2Uy6f+SwK*Nd86n>NdTNv2=V{` delta 30 lcmaE6{LEOCi@PKvGcR4QpeVm2Uy6f+SwL8Vaii!(NdTNz2=V{` diff --git a/integration/simple-proto2/simple.bin b/integration/simple-proto2/simple.bin index c879526ac6a7c2e75ecbbb8c90a5ac4aa159bd02..624b4f62c200feeda5b8336a960ffb1b7e83c0c2 100644 GIT binary patch delta 31 mcmeys^npo?i>EjEj%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/simple-prototype-defaults/google/type/date.bin b/integration/simple-prototype-defaults/google/type/date.bin index 680ba7e6dd305c29b45f37db9716864b397b1a72..79b7489a478d8c39160305aeda937b750ffabd82 100644 GIT binary patch delta 14 VcmZ1`uuNcrEVG~l^F{?W4gei>11JCh delta 14 VcmZ1`uuNcrEVHl#<3_HFoK(GnqWqG4DGm;10YM4ojbcYa0micmZU6uP delta 33 ocmcb$n(@|ZMlmj);>_HFoK(GnqWqG4DGm;10bvQojbcYa0mioqZU6uP diff --git a/integration/simple-snake/google/protobuf/struct.ts b/integration/simple-snake/google/protobuf/struct.ts index 802676863..196c1758e 100644 --- a/integration/simple-snake/google/protobuf/struct.ts +++ b/integration/simple-snake/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/simple-snake/google/protobuf/wrappers.bin b/integration/simple-snake/google/protobuf/wrappers.bin index 7f34d6ce0cd3a5ebf8b18b31567e0fd536c12f1b..1c3a982c95fd4b1add11db32f11cfd2f5f4fd90c 100644 GIT binary patch delta 21 ccmcbkct>%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/simple-snake/import_dir/thing.bin b/integration/simple-snake/import_dir/thing.bin index 18377ed61039b9e0223782d6b1fd66d34cd8c98e..777648ff4502757afb78a7feacbec6bb9ac73adf 100644 GIT binary patch delta 14 Vcmexk{Kt5LEVG~l^G1a`k^n0<1pxp6 delta 14 Vcmexk{Kt5LEVHl#<3@!$k^n0@1pxp6 diff --git a/integration/simple-snake/simple.bin b/integration/simple-snake/simple.bin index a8fca9efde0f3f52f3bc1124b37b41b78c33ccf5..4324b53660d22a36047d634e460875ca08418a4c 100644 GIT binary patch delta 116 zcmV-)0E_>ys{ya80UQbpb7^gGY-KKRa&L5R8VCpj5D^#yA^>`?AqtZ~JRh+;S}6nm zA_|j%JRP&ODZK&-nH>rS5(FLqUbD{;jRvy_Gl&8X!vYEd1OXBRJpfGs8n%<3HOUWQ WbP6DLVRC6yA^>`?AqtZ}JRh+;S}6nn zA_|j$JRP&ODZK&-njH!T5(FLqUbD{;jRvy_Gl&8X!~zNe1OXBRJpfGs8n=_4HOUZV Xb7cx3c42a9VQzGDE+9d(b~ZU5)bt_d diff --git a/integration/simple-string-enums/google/protobuf/struct.ts b/integration/simple-string-enums/google/protobuf/struct.ts index 4e88bc237..66f3c2821 100644 --- a/integration/simple-string-enums/google/protobuf/struct.ts +++ b/integration/simple-string-enums/google/protobuf/struct.ts @@ -70,8 +70,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/simple-string-enums/simple.bin b/integration/simple-string-enums/simple.bin index 091d8c01e8f5b65c8a088cfe2880da556242b18f..f32eb0779f277526a4ad9ea6aadca3030b2fb6d3 100644 GIT binary patch delta 82 zcmdm}wLwdYi>Ejfc7GJ4}o-H-Bf6<>Wie#KpwI mD8ypR;L9krZL$*2N&dtVE`_qhqRhm+l42c&#Ld5X%s2qliWlSn delta 83 zcmdm>wNXooi>EjDW~>iWiU#KpwI nD8ypR;L9kreX%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/simple-unrecognized-enum/import_dir/thing.bin b/integration/simple-unrecognized-enum/import_dir/thing.bin index 18377ed61039b9e0223782d6b1fd66d34cd8c98e..777648ff4502757afb78a7feacbec6bb9ac73adf 100644 GIT binary patch delta 14 Vcmexk{Kt5LEVG~l^G1a`k^n0<1pxp6 delta 14 Vcmexk{Kt5LEVHl#<3@!$k^n0@1pxp6 diff --git a/integration/simple-unrecognized-enum/simple.bin b/integration/simple-unrecognized-enum/simple.bin index d6a2033aed6652e29d11a35799c6e4c716c2ab34..b9bddba28a71f7bed47eeca462b1c7c63c8cde83 100644 GIT binary patch delta 43 ycmaFa#`v<0QHG1BI5W2(CsnVYD8D3Mii3k$Kv05NiJ@w}BG=@7TJjsM^_&4QqYTvm delta 43 ycmaFa#`v<0QHG1BI5W2(CsnVYD8D3Mii3k$Kv;rNiJ@w}BG=@7TJjsM^_&4Qrwr8q diff --git a/integration/simple/google/protobuf/wrappers.bin b/integration/simple/google/protobuf/wrappers.bin index 7f34d6ce0cd3a5ebf8b18b31567e0fd536c12f1b..1c3a982c95fd4b1add11db32f11cfd2f5f4fd90c 100644 GIT binary patch delta 21 ccmcbkct>%9Du%9Du=KHqY^{adc_F}8-4o)0804=od5s; diff --git a/integration/simple/google/type/date.bin b/integration/simple/google/type/date.bin index 680ba7e6dd305c29b45f37db9716864b397b1a72..79b7489a478d8c39160305aeda937b750ffabd82 100644 GIT binary patch delta 14 VcmZ1`uuNcrEVG~l^F{?W4gei>11JCh delta 14 VcmZ1`uuNcrEVHl#<3_HFoK(GnqWqG4DGm;10YM4ojbf5v0J{bWZ~y=R delta 33 ocmZ3#hH?EGMlmj);>_HFoK(GnqWqG4DGm;10bvQojbf5v0J{naZ~y=R diff --git a/integration/struct/google/protobuf/struct.ts b/integration/struct/google/protobuf/struct.ts index 80a98258e..081b74075 100644 --- a/integration/struct/google/protobuf/struct.ts +++ b/integration/struct/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/struct/struct.bin b/integration/struct/struct.bin index d9a1b260e4053e4b102673e7298fa2363c7d0065..9460f80e7401284f3c4bac00e69ab88bc99df063 100644 GIT binary patch delta 82 zcmeyb@=ryIi>J7xs5H4mub?QuBwvbygIPdOf?0{7>fc7GJ4}o-H-Bf6<>Wie#KpwI mD8ypR;L9krZL$*2N&dtVE`_qhqRhm+l42c&#Ld5XT37)JY#7=A delta 83 zcmeyT@?S-Yi>J7xs5H4mub?QuBwvbygIPdWf>DW~>iWiU#KpwI nD8ypR;L9kreX8R!52 delta 88 zcmV-e0H^=!TI^bo6ay0&0kId&7z6(z3X_>C9kT=(y#fiE9SQ~#1RelhvmODB2D4Wp uhyo780tx~I0TKi~08IfJx0CH8$q;38WeOm6VRC60RR91 delta 83 zcmV-Z0IdI>S)W-G3JGR!Z!U0hZ**@O2nYiZ6Bq%p6U`U_|Fhv3+yVibv%VW02@b>p p3IYTH5(GT}O#vFWlj$VM5M^^^3Lti2a%o|1baO5sL9@Xn-3BPw8czTK diff --git a/integration/type-registry/google/protobuf/struct.ts b/integration/type-registry/google/protobuf/struct.ts index 6f035c984..bc857915f 100644 --- a/integration/type-registry/google/protobuf/struct.ts +++ b/integration/type-registry/google/protobuf/struct.ts @@ -63,8 +63,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/types-with-underscores/file.bin b/integration/types-with-underscores/file.bin index eeb5f3f23c96a916ed4aaa3ed9432a90b2ef8ea2..665393a841628d3d641ca5a25bb7d23cedd4c234 100644 GIT binary patch delta 28 jcmey%_?J delta 16 XcmZ43!o0ABd4f8#ums~qt?vf`E~W*_ diff --git a/integration/unknown-fields/options.bin b/integration/unknown-fields/options.bin index 949f7217a17979380d9944fc1cc4fc75d0c1b7e9..7c36de720e37cee499ab8d582d985e78bed0185c 100644 GIT binary patch delta 27 jcmbO?mwDb?<_RKPf)dP13{@YSnYktl98uh8AAb%2crFPU delta 27 jcmbO?mwDb?<_RKP!V-*13{@YSnYktl98uh8AAb%2crpnY diff --git a/integration/unknown-fields/something/something.bin b/integration/unknown-fields/something/something.bin index 0f4e0f37aa01a2fac6cff8e07bcc9316d6ec860c..c2fb37b5f9c2ca64414a2cf31a873b927e1007d3 100644 GIT binary patch delta 16 XcmeC|VD9W-o}j=iD8al@`PpFrE8+!( delta 16 XcmeC|VD9W-o}j=iEWx-@`PpFrE9M1- diff --git a/integration/use-date-false/metadata.bin b/integration/use-date-false/metadata.bin index c4c8c725625b755ef79e006dd251c3e1e7d3fa46..3cbf03e086903d2101d9f17fc4bf9ba02c364289 100644 GIT binary patch delta 14 Vcmca^eBF40D6^mh^G1pNk^m;!1d0Fv delta 14 Vcmca^eBF40D6_Bx<3@@7k^m;&1d0Fv diff --git a/integration/use-date-string/use-date-string.bin b/integration/use-date-string/use-date-string.bin index 79e656e01000f5d7270deddc4d832437ec5448d9..c51c02f87592c41627537ef1a43108b7839cb094 100644 GIT binary patch delta 14 VcmX?PamZqV46~pF^G11P82}_t1K$7u delta 14 VcmX?PamZqV470EV<3@R982}_x1K$7u diff --git a/integration/use-date-true/use-date-true-test.ts b/integration/use-date-true/use-date-true-test.ts index b387eff35..75dd2b2f5 100644 --- a/integration/use-date-true/use-date-true-test.ts +++ b/integration/use-date-true/use-date-true-test.ts @@ -1,12 +1,12 @@ import { Todo, Clock } from './use-date-true'; - +import { Timestamp } from './google/protobuf/timestamp'; const jan1 = new Date('1970-01-01T00:00:00.000Z'); const feb1 = new Date('1970-02-01T00:00:00.000Z'); describe('useDate=true', () => { it('generates a services that compiles', () => { let c: Clock = { - Now: () => Promise.resolve(jan1), + Now: () => Promise.resolve(Timestamp.fromPartial({})), }; }); it('generates types that compile and encode', () => { diff --git a/integration/use-date-true/use-date-true.bin b/integration/use-date-true/use-date-true.bin index a5b93133cffa9a3b7f040b380a937605c8df4e84..67698706cbf0e719bfa0b5c5e19e181d6b5cb13c 100644 GIT binary patch delta 14 Vcmdn(v)gBa6tkcN^F~=YH2@`H1Nr~} delta 14 Vcmdn(v)gBa6tl1d<3?FIH2@`L1Nr~} diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index 75efc6e36..7e0b7f33c 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -189,7 +189,7 @@ export const Todo_MapOfTimestampsEntry = { }; export interface Clock { - Now(request: Empty): Promise; + Now(request: Empty): Promise; } export class ClockClientImpl implements Clock { @@ -200,10 +200,10 @@ export class ClockClientImpl implements Clock { this.rpc = rpc; this.Now = this.Now.bind(this); } - Now(request: Empty): Promise { + Now(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "Now", data); - return promise.then((data) => fromTimestamp(Timestamp.decode(new _m0.Reader(data)))); + return promise.then((data) => Timestamp.decode(new _m0.Reader(data))); } } diff --git a/integration/use-exact-types-false/foo.bin b/integration/use-exact-types-false/foo.bin index b98932d4bcbb845eb9f7c8d9a7734fe233a59d53..faa9f81b67d4488a4994a04ad783b181117a5b5d 100644 GIT binary patch delta 27 icmZo*YG4xP;!MlW*DEN>FUgnU;9wRIlwh7H{1yORqz20X delta 27 icmZo*YG4xP;!MlW*DEN>FUgnU;9wRImSCJH{1yORs0Pab diff --git a/integration/use-json-wire-format/use-json-wire-format.bin b/integration/use-json-wire-format/use-json-wire-format.bin index 723fabc328f2116b00c90c220cc43fdc016b215b..0165a793cdfc15767b6da63675daa412dc41277b 100644 GIT binary patch delta 16 YcmcaSlkxIQ#tDkdf)dOdRo43e05t>!ivR!s delta 16 YcmcaSlkxIQ#tDkd!V-)dRo43e05u2&ivR!s diff --git a/integration/use-map-type/use-map-type.bin b/integration/use-map-type/use-map-type.bin index 777daacec49ac349d0ec9c03373078ff604c8bc6..8de61dbd7ed58be13c3d431aecaef5a1032cccfc 100644 GIT binary patch delta 14 Vcmca)eaU))B(tCd^G2C%vH&MK1d{*& delta 14 Vcmca)eaU))B(tyt<3^cnvH&MO1d{*& diff --git a/integration/use-numeric-enum-json/google/protobuf/struct.ts b/integration/use-numeric-enum-json/google/protobuf/struct.ts index d17382273..56f48c7b3 100644 --- a/integration/use-numeric-enum-json/google/protobuf/struct.ts +++ b/integration/use-numeric-enum-json/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/use-numeric-enum-json/simple.bin b/integration/use-numeric-enum-json/simple.bin index 091d8c01e8f5b65c8a088cfe2880da556242b18f..f32eb0779f277526a4ad9ea6aadca3030b2fb6d3 100644 GIT binary patch delta 82 zcmdm}wLwdYi>Ejfc7GJ4}o-H-Bf6<>Wie#KpwI mD8ypR;L9krZL$*2N&dtVE`_qhqRhm+l42c&#Ld5X%s2qliWlSn delta 83 zcmdm>wNXooi>EjDW~>iWiU#KpwI nD8ypR;L9kreX703SXC9RL6T diff --git a/integration/use-objectid-true-external-import/use-objectid-true.bin b/integration/use-objectid-true-external-import/use-objectid-true.bin index 781274c90f835d8695f68d64361fad522238e994..7b757e848cfd647c9e31f156d4a61a4c7d5da20d 100644 GIT binary patch delta 14 Vcmeyy{*8Tt9J8PV^G3z1%m5~01cCqn delta 14 Vcmeyy{*8Tt9J8sdRSD1i>oBHxJ0j@D8D3Mii3k$Kv05tqsV$L0D~6?;s5{u delta 29 kcmX>sdRSD1i>oBHxJ0j@D8D3Mii3k$Kv;rtqsV$L0D~I`;s5{u diff --git a/integration/value/google/protobuf/struct.ts b/integration/value/google/protobuf/struct.ts index 80a98258e..081b74075 100644 --- a/integration/value/google/protobuf/struct.ts +++ b/integration/value/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of these - * variants. Absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/value/value.bin b/integration/value/value.bin index 3564a9fe873051599c65f8b92610f1f9988481d0..0f63332d29f0c4466c3aac283094554309cb3074 100644 GIT binary patch delta 87 zcmV-d0I2`vOyo=(3JZ2&Y;|QWaB^>SZyE>)0}v4y10n!={vryKd?OvPIK2V^nX~o+ t9SIJ@0tx~I0TKi~08IfJwv!OpLQOe`Av6 { +describe('wrappers in service methods', () => { it('generates a services that compiles', () => { let c: Clock = { - Now: () => Promise.resolve(jan1), - NowString: () => Promise.resolve("anything, really"), - NowBool: () => Promise.resolve(true), + Now: () => Promise.resolve(Timestamp.fromPartial({ seconds: 0, nanos: 0 })), + NowString: (inp: StringValue) => Promise.resolve(inp), + NowBool: () => Promise.resolve(BoolValue.fromPartial({ value: true })) }; }); }); diff --git a/integration/wrappers-regression/wrappers-regression.bin b/integration/wrappers-regression/wrappers-regression.bin index fccc27c7add7545615ebb0da181d679abd052c4d..b158d79a6fdb64cdcf422977f1aebc489ac0b26b 100644 GIT binary patch delta 183 zcmX?@b0TL0iwV;qmI*SGl}zFoPfcz#ap866;`GZe4=yRn%u5%V{K`aj@=KFA&X0^- zY(gvy3|x}~OwAa%Cbyfqmho`0urV+(3bC*=ap-XIaIu1Tj6%%pZ2T}D6ObpM4dXEj uF>~;1adCt70i`&ZJfTuRQ; - NowString(request: Empty): Promise; - NowBool(request: Empty): Promise; + Now(request: Empty): Promise; + NowString(request: StringValue): Promise; + NowBool(request: Empty): Promise; } export class ClockClientImpl implements Clock { @@ -22,22 +22,22 @@ export class ClockClientImpl implements Clock { this.NowString = this.NowString.bind(this); this.NowBool = this.NowBool.bind(this); } - Now(request: Empty): Promise { + Now(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "Now", data); - return promise.then((data) => fromTimestamp(Timestamp.decode(new _m0.Reader(data)))); + return promise.then((data) => Timestamp.decode(new _m0.Reader(data))); } - NowString(request: Empty): Promise { - const data = Empty.encode(request).finish(); + NowString(request: StringValue): Promise { + const data = StringValue.encode(request).finish(); const promise = this.rpc.request(this.service, "NowString", data); - return promise.then((data) => string | undefined.decode(new _m0.Reader(data))); + return promise.then((data) => StringValue.decode(new _m0.Reader(data))); } - NowBool(request: Empty): Promise { + NowBool(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "NowBool", data); - return promise.then((data) => boolean | undefined.decode(new _m0.Reader(data))); + return promise.then((data) => BoolValue.decode(new _m0.Reader(data))); } } @@ -56,7 +56,7 @@ export const ClockDefinition = { }, nowString: { name: "NowString", - requestType: Empty, + requestType: StringValue, requestStream: false, responseType: StringValue, responseStream: false, @@ -76,9 +76,3 @@ export const ClockDefinition = { interface Rpc { request(service: string, method: string, data: Uint8Array): Promise; } - -function fromTimestamp(t: Timestamp): Date { - let millis = t.seconds * 1_000; - millis += t.nanos / 1_000_000; - return new Date(millis); -} diff --git a/src/generate-services.ts b/src/generate-services.ts index 66e1d43c7..41f97d1bd 100644 --- a/src/generate-services.ts +++ b/src/generate-services.ts @@ -112,20 +112,20 @@ function generateRegularRpcMethod( assertInstanceOf(methodDesc, FormattedMethodDescriptor); const { options, utils } = ctx; const Reader = impFile(ctx.options, "Reader@protobufjs/minimal"); - const rawInputType = rawRequestType(ctx, methodDesc); + const rawInputType = rawRequestType(ctx, methodDesc, { keepValueType: true }); const inputType = requestType(ctx, methodDesc); const outputType = responseType(ctx, methodDesc); const rawOutputType = responseType(ctx, methodDesc, { keepValueType: true }); - const params = [...(options.context ? [code`ctx: Context`] : []), code`request: ${inputType}`]; + const params = [...(options.context ? [code`ctx: Context`] : []), code`request: ${rawInputType}`]; const maybeCtx = options.context ? "ctx," : ""; let encode = code`${rawInputType}.encode(request).finish()`; - let decode = code`data => ${outputType}.decode(new ${Reader}(data))`; + let decode = code`data => ${rawOutputType}.decode(new ${Reader}(data))`; - if (options.useDate && rawOutputType.toString().includes("Timestamp")) { - decode = code`data => ${utils.fromTimestamp}(${rawOutputType}.decode(new ${Reader}(data)))`; - } + // if (options.useDate && rawOutputType.toString().includes("Timestamp")) { + // decode = code`data => ${utils.fromTimestamp}(${rawOutputType}.decode(new ${Reader}(data)))`; + // } if (methodDesc.clientStreaming) { if (options.useAsyncIterable) { encode = code`${rawInputType}.encodeTransform(request)`; diff --git a/src/types.ts b/src/types.ts index ef9784ced..1296960c1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -659,8 +659,12 @@ export function detectMapType( return undefined; } -export function rawRequestType(ctx: Context, methodDesc: MethodDescriptorProto): Code { - return messageToTypeName(ctx, methodDesc.inputType); +export function rawRequestType( + ctx: Context, + methodDesc: MethodDescriptorProto, + typeOptions: { keepValueType?: boolean; repeated?: boolean } = {} +): Code { + return messageToTypeName(ctx, methodDesc.inputType, typeOptions); } export function observableType(ctx: Context): Code { @@ -671,7 +675,7 @@ export function observableType(ctx: Context): Code { } export function requestType(ctx: Context, methodDesc: MethodDescriptorProto, partial: boolean = false): Code { - let typeName = rawRequestType(ctx, methodDesc); + let typeName = rawRequestType(ctx, methodDesc, { keepValueType: true }); if (partial) { typeName = code`${ctx.utils.DeepPartial}<${typeName}>`; @@ -692,11 +696,11 @@ export function responseType( } export function responsePromise(ctx: Context, methodDesc: MethodDescriptorProto): Code { - return code`Promise<${responseType(ctx, methodDesc)}>`; + return code`Promise<${responseType(ctx, methodDesc, { keepValueType: true })}>`; } export function responseObservable(ctx: Context, methodDesc: MethodDescriptorProto): Code { - return code`${observableType(ctx)}<${responseType(ctx, methodDesc)}>`; + return code`${observableType(ctx)}<${responseType(ctx, methodDesc, { keepValueType: true })}>`; } export function responsePromiseOrObservable(ctx: Context, methodDesc: MethodDescriptorProto): Code { From 9dd9f0f3cba047191b58d347cab306d0b4d8bd63 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 14:41:57 -0700 Subject: [PATCH 5/9] fix client streaming --- integration/async-iterable-services/simple.ts | 4 ++-- integration/generic-metadata/hero.ts | 2 +- .../wrappers-regression-test.ts | 2 ++ .../wrappers-regression.bin | Bin 13896 -> 14063 bytes .../wrappers-regression.proto | 2 ++ .../wrappers-regression.ts | 21 ++++++++++++++++++ src/generate-services.ts | 7 +++--- src/types.ts | 18 +++++++-------- 8 files changed, 40 insertions(+), 16 deletions(-) diff --git a/integration/async-iterable-services/simple.ts b/integration/async-iterable-services/simple.ts index b63b952b8..73c36d6c7 100644 --- a/integration/async-iterable-services/simple.ts +++ b/integration/async-iterable-services/simple.ts @@ -122,13 +122,13 @@ export class EchoerClientImpl implements Echoer { return EchoMsg.decodeTransform(result); } - EchoClientStream(request: EchoMsg): Promise { + EchoClientStream(request: AsyncIterable): Promise { const data = EchoMsg.encodeTransform(request); const promise = this.rpc.clientStreamingRequest(this.service, "EchoClientStream", data); return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); } - EchoBidiStream(request: EchoMsg): AsyncIterable { + EchoBidiStream(request: AsyncIterable): AsyncIterable { const data = EchoMsg.encodeTransform(request); const result = this.rpc.bidirectionalStreamingRequest(this.service, "EchoBidiStream", data); return EchoMsg.decodeTransform(result); diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index 7dcda39fd..d6e622b97 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -256,7 +256,7 @@ export class HeroServiceClientImpl implements HeroService { return promise.then((data) => Villain.decode(new _m0.Reader(data))); } - FindManyVillain(request: VillainById): Observable { + FindManyVillain(request: Observable): Observable { const data = request.pipe(map((request) => VillainById.encode(request).finish())); const result = this.rpc.bidirectionalStreamingRequest(this.service, "FindManyVillain", data); return result.pipe(map((data) => Villain.decode(new _m0.Reader(data)))); diff --git a/integration/wrappers-regression/wrappers-regression-test.ts b/integration/wrappers-regression/wrappers-regression-test.ts index 0162ec9f6..eb187e2c1 100644 --- a/integration/wrappers-regression/wrappers-regression-test.ts +++ b/integration/wrappers-regression/wrappers-regression-test.ts @@ -7,6 +7,7 @@ import { BoolValue, StringValue } from "./google/protobuf/wrappers"; +import { Observable } from 'rxjs'; const jan1 = new Date('1970-01-01T00:00:00.000Z'); const feb1 = new Date('1970-02-01T00:00:00.000Z'); @@ -16,6 +17,7 @@ describe('wrappers in service methods', () => { let c: Clock = { Now: () => Promise.resolve(Timestamp.fromPartial({ seconds: 0, nanos: 0 })), NowString: (inp: StringValue) => Promise.resolve(inp), + NowStringStream: (inp: Observable) => inp, NowBool: () => Promise.resolve(BoolValue.fromPartial({ value: true })) }; }); diff --git a/integration/wrappers-regression/wrappers-regression.bin b/integration/wrappers-regression/wrappers-regression.bin index b158d79a6fdb64cdcf422977f1aebc489ac0b26b..a22d7aaa121140a95b26ea05a4c3fb164fda7edc 100644 GIT binary patch delta 223 zcmX?+^FDV2iwV<9)(J9`l}zH8<}yugGU*WtKY8#Kk7W!oa{YIn30Ik!NzRX>C0Z7YiE$6O#}NCli-37Y`RJh{q_z%*iGS z~?5RWbv4VuoDYU^9UnZYEEtLS~?m+-$rs9?%eOK4l-k&%l{h=qZHYw}7{Ge)k-4@_(A vxVc!^7?_xZm^qm|xp=r(K^#UPkBt|`1Ih6z!+6X; NowString(request: StringValue): Promise; + NowStringStream(request: Observable): Observable; NowBool(request: Empty): Promise; } @@ -20,6 +23,7 @@ export class ClockClientImpl implements Clock { this.rpc = rpc; this.Now = this.Now.bind(this); this.NowString = this.NowString.bind(this); + this.NowStringStream = this.NowStringStream.bind(this); this.NowBool = this.NowBool.bind(this); } Now(request: Empty): Promise { @@ -34,6 +38,12 @@ export class ClockClientImpl implements Clock { return promise.then((data) => StringValue.decode(new _m0.Reader(data))); } + NowStringStream(request: Observable): Observable { + const data = request.pipe(map((request) => StringValue.encode(request).finish())); + const result = this.rpc.bidirectionalStreamingRequest(this.service, "NowStringStream", data); + return result.pipe(map((data) => StringValue.decode(new _m0.Reader(data)))); + } + NowBool(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "NowBool", data); @@ -62,6 +72,14 @@ export const ClockDefinition = { responseStream: false, options: {}, }, + nowStringStream: { + name: "NowStringStream", + requestType: StringValue, + requestStream: true, + responseType: StringValue, + responseStream: true, + options: {}, + }, nowBool: { name: "NowBool", requestType: Empty, @@ -75,4 +93,7 @@ export const ClockDefinition = { interface Rpc { request(service: string, method: string, data: Uint8Array): Promise; + clientStreamingRequest(service: string, method: string, data: Observable): Promise; + serverStreamingRequest(service: string, method: string, data: Uint8Array): Observable; + bidirectionalStreamingRequest(service: string, method: string, data: Observable): Observable; } diff --git a/src/generate-services.ts b/src/generate-services.ts index 41f97d1bd..845f4931c 100644 --- a/src/generate-services.ts +++ b/src/generate-services.ts @@ -117,7 +117,7 @@ function generateRegularRpcMethod( const outputType = responseType(ctx, methodDesc); const rawOutputType = responseType(ctx, methodDesc, { keepValueType: true }); - const params = [...(options.context ? [code`ctx: Context`] : []), code`request: ${rawInputType}`]; + const params = [...(options.context ? [code`ctx: Context`] : []), code`request: ${inputType}`]; const maybeCtx = options.context ? "ctx," : ""; let encode = code`${rawInputType}.encode(request).finish()`; @@ -291,9 +291,8 @@ function generateCachingRpcMethod( (requests) => { const responses = requests.map(async request => { const data = ${inputType}.encode(request).finish() - const response = await this.rpc.request(ctx, "${maybePrefixPackage(fileDesc, serviceDesc.name)}", "${ - methodDesc.name - }", data); + const response = await this.rpc.request(ctx, "${maybePrefixPackage(fileDesc, serviceDesc.name)}", "${methodDesc.name + }", data); return ${outputType}.decode(new ${Reader}(response)); }); return Promise.all(responses); diff --git a/src/types.ts b/src/types.ts index 1296960c1..5035ef821 100644 --- a/src/types.ts +++ b/src/types.ts @@ -480,8 +480,8 @@ export function valueTypeName(ctx: Context, typeName: string): Code | undefined return ctx.options.env === EnvOption.NODE ? code`Buffer` : ctx.options.useJsonWireFormat - ? code`string` - : code`Uint8Array`; + ? code`string` + : code`Uint8Array`; case ".google.protobuf.ListValue": return code`Array`; case ".google.protobuf.Value": @@ -636,12 +636,12 @@ export function detectMapType( fieldDesc: FieldDescriptorProto ): | { - messageDesc: DescriptorProto; - keyField: FieldDescriptorProto; - keyType: Code; - valueField: FieldDescriptorProto; - valueType: Code; - } + messageDesc: DescriptorProto; + keyField: FieldDescriptorProto; + keyType: Code; + valueField: FieldDescriptorProto; + valueType: Code; + } | undefined { const { typeMap } = ctx; if ( @@ -692,7 +692,7 @@ export function responseType( methodDesc: MethodDescriptorProto, typeOptions: { keepValueType?: boolean; repeated?: boolean } = {} ): Code { - return messageToTypeName(ctx, methodDesc.outputType, typeOptions); + return messageToTypeName(ctx, methodDesc.outputType, { keepValueType: true }); } export function responsePromise(ctx: Context, methodDesc: MethodDescriptorProto): Code { From 6862c75292b6972ba88bf518cd6e0bfa175f30d6 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 14:42:48 -0700 Subject: [PATCH 6/9] appease the linter --- src/generate-services.ts | 5 +++-- src/types.ts | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/generate-services.ts b/src/generate-services.ts index 845f4931c..6c12b722c 100644 --- a/src/generate-services.ts +++ b/src/generate-services.ts @@ -291,8 +291,9 @@ function generateCachingRpcMethod( (requests) => { const responses = requests.map(async request => { const data = ${inputType}.encode(request).finish() - const response = await this.rpc.request(ctx, "${maybePrefixPackage(fileDesc, serviceDesc.name)}", "${methodDesc.name - }", data); + const response = await this.rpc.request(ctx, "${maybePrefixPackage(fileDesc, serviceDesc.name)}", "${ + methodDesc.name + }", data); return ${outputType}.decode(new ${Reader}(response)); }); return Promise.all(responses); diff --git a/src/types.ts b/src/types.ts index 5035ef821..589adbbd0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -480,8 +480,8 @@ export function valueTypeName(ctx: Context, typeName: string): Code | undefined return ctx.options.env === EnvOption.NODE ? code`Buffer` : ctx.options.useJsonWireFormat - ? code`string` - : code`Uint8Array`; + ? code`string` + : code`Uint8Array`; case ".google.protobuf.ListValue": return code`Array`; case ".google.protobuf.Value": @@ -636,12 +636,12 @@ export function detectMapType( fieldDesc: FieldDescriptorProto ): | { - messageDesc: DescriptorProto; - keyField: FieldDescriptorProto; - keyType: Code; - valueField: FieldDescriptorProto; - valueType: Code; - } + messageDesc: DescriptorProto; + keyField: FieldDescriptorProto; + keyType: Code; + valueField: FieldDescriptorProto; + valueType: Code; + } | undefined { const { typeMap } = ctx; if ( From 5b035e15c7961e74bbdf896fd6f795be23294982 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 14:52:22 -0700 Subject: [PATCH 7/9] pull the typenames into the method definition directly --- integration/generic-metadata/hero.ts | 6 +++ .../simple.ts | 14 +++++++ .../generic-service-definitions/simple.ts | 14 +++++++ integration/nice-grpc/simple.ts | 42 +++++++++++++++++++ integration/type-registry/bar/bar.ts | 2 +- integration/type-registry/foo.ts | 6 +-- .../type-registry/google/protobuf/struct.ts | 8 ++-- .../google/protobuf/timestamp.ts | 2 +- integration/use-date-true/use-date-true.ts | 2 + .../wrappers-regression.ts | 8 ++++ src/generate-generic-service-definition.ts | 2 + 11 files changed, 97 insertions(+), 9 deletions(-) diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index d6e622b97..06bcd911a 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -271,24 +271,30 @@ export const HeroServiceDefinition = { findOneHero: { name: "FindOneHero", requestType: HeroById, + requestTypeName: ".hero.HeroById", requestStream: false, responseType: Hero, + responseTypeName: ".hero.Hero", responseStream: false, options: {}, }, findOneVillain: { name: "FindOneVillain", requestType: VillainById, + requestTypeName: ".hero.VillainById", requestStream: false, responseType: Villain, + responseTypeName: ".hero.Villain", responseStream: false, options: {}, }, findManyVillain: { name: "FindManyVillain", requestType: VillainById, + requestTypeName: ".hero.VillainById", requestStream: true, responseType: Villain, + responseTypeName: ".hero.Villain", responseStream: true, options: {}, }, diff --git a/integration/generic-service-definitions-and-services/simple.ts b/integration/generic-service-definitions-and-services/simple.ts index 7e3c5d5a0..32862bec8 100644 --- a/integration/generic-service-definitions-and-services/simple.ts +++ b/integration/generic-service-definitions-and-services/simple.ts @@ -63,32 +63,40 @@ export const TestDefinition = { unary: { name: "Unary", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: {}, }, serverStreaming: { name: "ServerStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: true, options: {}, }, clientStreaming: { name: "ClientStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: true, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: {}, }, bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: true, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: true, options: {}, }, @@ -96,24 +104,30 @@ export const TestDefinition = { deprecated: { name: "Deprecated", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: {}, }, idempotent: { name: "Idempotent", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { name: "NoSideEffects", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, diff --git a/integration/generic-service-definitions/simple.ts b/integration/generic-service-definitions/simple.ts index 7e3c5d5a0..32862bec8 100644 --- a/integration/generic-service-definitions/simple.ts +++ b/integration/generic-service-definitions/simple.ts @@ -63,32 +63,40 @@ export const TestDefinition = { unary: { name: "Unary", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: {}, }, serverStreaming: { name: "ServerStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: true, options: {}, }, clientStreaming: { name: "ClientStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: true, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: {}, }, bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: true, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: true, options: {}, }, @@ -96,24 +104,30 @@ export const TestDefinition = { deprecated: { name: "Deprecated", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: {}, }, idempotent: { name: "Idempotent", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { name: "NoSideEffects", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, diff --git a/integration/nice-grpc/simple.ts b/integration/nice-grpc/simple.ts index c171462de..58c80e2c6 100644 --- a/integration/nice-grpc/simple.ts +++ b/integration/nice-grpc/simple.ts @@ -87,112 +87,140 @@ export const TestDefinition = { unary: { name: "Unary", requestType: Empty, + requestTypeName: ".google.protobuf.Empty", requestStream: false, responseType: Empty, + responseTypeName: ".google.protobuf.Empty", responseStream: false, options: {}, }, unaryStringValue: { name: "UnaryStringValue", requestType: StringValue, + requestTypeName: ".google.protobuf.StringValue", requestStream: false, responseType: StringValue, + responseTypeName: ".google.protobuf.StringValue", responseStream: false, options: {}, }, unaryInt64Value: { name: "UnaryInt64Value", requestType: Int64Value, + requestTypeName: ".google.protobuf.Int64Value", requestStream: false, responseType: Int64Value, + responseTypeName: ".google.protobuf.Int64Value", responseStream: false, options: {}, }, unaryUint64Value: { name: "UnaryUint64Value", requestType: UInt64Value, + requestTypeName: ".google.protobuf.UInt64Value", requestStream: false, responseType: UInt64Value, + responseTypeName: ".google.protobuf.UInt64Value", responseStream: false, options: {}, }, unaryInt32Value: { name: "UnaryInt32Value", requestType: Int32Value, + requestTypeName: ".google.protobuf.Int32Value", requestStream: false, responseType: Int32Value, + responseTypeName: ".google.protobuf.Int32Value", responseStream: false, options: {}, }, unaryUInt32Value: { name: "UnaryUInt32Value", requestType: UInt32Value, + requestTypeName: ".google.protobuf.UInt32Value", requestStream: false, responseType: UInt32Value, + responseTypeName: ".google.protobuf.UInt32Value", responseStream: false, options: {}, }, unaryBytesValue: { name: "UnaryBytesValue", requestType: BytesValue, + requestTypeName: ".google.protobuf.BytesValue", requestStream: false, responseType: BytesValue, + responseTypeName: ".google.protobuf.BytesValue", responseStream: false, options: {}, }, unaryFloatValue: { name: "UnaryFloatValue", requestType: FloatValue, + requestTypeName: ".google.protobuf.FloatValue", requestStream: false, responseType: FloatValue, + responseTypeName: ".google.protobuf.FloatValue", responseStream: false, options: {}, }, unaryDoubleValue: { name: "UnaryDoubleValue", requestType: DoubleValue, + requestTypeName: ".google.protobuf.DoubleValue", requestStream: false, responseType: DoubleValue, + responseTypeName: ".google.protobuf.DoubleValue", responseStream: false, options: {}, }, unaryBoolValue: { name: "UnaryBoolValue", requestType: BoolValue, + requestTypeName: ".google.protobuf.BoolValue", requestStream: false, responseType: BoolValue, + responseTypeName: ".google.protobuf.BoolValue", responseStream: false, options: {}, }, unaryTimestamp: { name: "UnaryTimestamp", requestType: Timestamp, + requestTypeName: ".google.protobuf.Timestamp", requestStream: false, responseType: Timestamp, + responseTypeName: ".google.protobuf.Timestamp", responseStream: false, options: {}, }, struct: { name: "Struct", requestType: Struct, + requestTypeName: ".google.protobuf.Struct", requestStream: false, responseType: Struct, + responseTypeName: ".google.protobuf.Struct", responseStream: false, options: {}, }, value: { name: "Value", requestType: Value, + requestTypeName: ".google.protobuf.Value", requestStream: false, responseType: Value, + responseTypeName: ".google.protobuf.Value", responseStream: false, options: {}, }, listValue: { name: "ListValue", requestType: ListValue, + requestTypeName: ".google.protobuf.ListValue", requestStream: false, responseType: ListValue, + responseTypeName: ".google.protobuf.ListValue", responseStream: false, options: {}, }, @@ -200,24 +228,30 @@ export const TestDefinition = { serverStreaming: { name: "ServerStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: false, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: true, options: {}, }, serverStreamingStringValue: { name: "ServerStreamingStringValue", requestType: StringValue, + requestTypeName: ".google.protobuf.StringValue", requestStream: false, responseType: StringValue, + responseTypeName: ".google.protobuf.StringValue", responseStream: true, options: {}, }, serverStreamingStruct: { name: "ServerStreamingStruct", requestType: Struct, + requestTypeName: ".google.protobuf.Struct", requestStream: false, responseType: Struct, + responseTypeName: ".google.protobuf.Struct", responseStream: true, options: {}, }, @@ -225,16 +259,20 @@ export const TestDefinition = { clientStreaming: { name: "ClientStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: true, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: false, options: {}, }, clientStreamingStringValue: { name: "ClientStreamingStringValue", requestType: StringValue, + requestTypeName: ".google.protobuf.StringValue", requestStream: true, responseType: StringValue, + responseTypeName: ".google.protobuf.StringValue", responseStream: false, options: {}, }, @@ -242,16 +280,20 @@ export const TestDefinition = { bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, + requestTypeName: ".simple.TestMessage", requestStream: true, responseType: TestMessage, + responseTypeName: ".simple.TestMessage", responseStream: true, options: {}, }, bidiStreamingStringValue: { name: "BidiStreamingStringValue", requestType: StringValue, + requestTypeName: ".google.protobuf.StringValue", requestStream: true, responseType: StringValue, + responseTypeName: ".google.protobuf.StringValue", responseStream: true, options: {}, }, diff --git a/integration/type-registry/bar/bar.ts b/integration/type-registry/bar/bar.ts index a5829e86c..0037a4828 100644 --- a/integration/type-registry/bar/bar.ts +++ b/integration/type-registry/bar/bar.ts @@ -59,7 +59,7 @@ export const Bar = { }, }; -messageTypeRegistry.set(Bar.$type, Bar); +messageTypeRegistry.set("foo.bar.Bar", Bar); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; diff --git a/integration/type-registry/foo.ts b/integration/type-registry/foo.ts index 3a72b6cec..523e0d13e 100644 --- a/integration/type-registry/foo.ts +++ b/integration/type-registry/foo.ts @@ -70,7 +70,7 @@ export const Foo = { }, }; -messageTypeRegistry.set(Foo.$type, Foo); +messageTypeRegistry.set("foo.Foo", Foo); function createBaseFoo2(): Foo2 { return { $type: "foo.Foo2", timestamp: undefined }; @@ -121,7 +121,7 @@ export const Foo2 = { }, }; -messageTypeRegistry.set(Foo2.$type, Foo2); +messageTypeRegistry.set("foo.Foo2", Foo2); function createBaseWithStruct(): WithStruct { return { $type: "foo.WithStruct", struct: undefined }; @@ -172,7 +172,7 @@ export const WithStruct = { }, }; -messageTypeRegistry.set(WithStruct.$type, WithStruct); +messageTypeRegistry.set("foo.WithStruct", WithStruct); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; diff --git a/integration/type-registry/google/protobuf/struct.ts b/integration/type-registry/google/protobuf/struct.ts index bc857915f..a17eeb5b1 100644 --- a/integration/type-registry/google/protobuf/struct.ts +++ b/integration/type-registry/google/protobuf/struct.ts @@ -201,7 +201,7 @@ export const Struct = { }, }; -messageTypeRegistry.set(Struct.$type, Struct); +messageTypeRegistry.set("google.protobuf.Struct", Struct); function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { return { $type: "google.protobuf.Struct.FieldsEntry", key: "", value: undefined }; @@ -264,7 +264,7 @@ export const Struct_FieldsEntry = { }, }; -messageTypeRegistry.set(Struct_FieldsEntry.$type, Struct_FieldsEntry); +messageTypeRegistry.set("google.protobuf.Struct.FieldsEntry", Struct_FieldsEntry); function createBaseValue(): Value { return { @@ -411,7 +411,7 @@ export const Value = { }, }; -messageTypeRegistry.set(Value.$type, Value); +messageTypeRegistry.set("google.protobuf.Value", Value); function createBaseListValue(): ListValue { return { $type: "google.protobuf.ListValue", values: [] }; @@ -478,7 +478,7 @@ export const ListValue = { }, }; -messageTypeRegistry.set(ListValue.$type, ListValue); +messageTypeRegistry.set("google.protobuf.ListValue", ListValue); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index bec2e71ed..f7717dcd8 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -174,7 +174,7 @@ export const Timestamp = { }, }; -messageTypeRegistry.set(Timestamp.$type, Timestamp); +messageTypeRegistry.set("google.protobuf.Timestamp", Timestamp); declare var self: any | undefined; declare var window: any | undefined; diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index 7e0b7f33c..4c4d97e2a 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -215,8 +215,10 @@ export const ClockDefinition = { now: { name: "Now", requestType: Empty, + requestTypeName: ".google.protobuf.Empty", requestStream: false, responseType: Timestamp, + responseTypeName: ".google.protobuf.Timestamp", responseStream: false, options: {}, }, diff --git a/integration/wrappers-regression/wrappers-regression.ts b/integration/wrappers-regression/wrappers-regression.ts index b8147b2fc..28121d8b6 100644 --- a/integration/wrappers-regression/wrappers-regression.ts +++ b/integration/wrappers-regression/wrappers-regression.ts @@ -59,32 +59,40 @@ export const ClockDefinition = { now: { name: "Now", requestType: Empty, + requestTypeName: ".google.protobuf.Empty", requestStream: false, responseType: Timestamp, + responseTypeName: ".google.protobuf.Timestamp", responseStream: false, options: {}, }, nowString: { name: "NowString", requestType: StringValue, + requestTypeName: ".google.protobuf.StringValue", requestStream: false, responseType: StringValue, + responseTypeName: ".google.protobuf.StringValue", responseStream: false, options: {}, }, nowStringStream: { name: "NowStringStream", requestType: StringValue, + requestTypeName: ".google.protobuf.StringValue", requestStream: true, responseType: StringValue, + responseTypeName: ".google.protobuf.StringValue", responseStream: true, options: {}, }, nowBool: { name: "NowBool", requestType: Empty, + requestTypeName: ".google.protobuf.Empty", requestStream: false, responseType: BoolValue, + responseTypeName: ".google.protobuf.BoolValue", responseStream: false, options: {}, }, diff --git a/src/generate-generic-service-definition.ts b/src/generate-generic-service-definition.ts index 0ba118d1b..237e0afeb 100644 --- a/src/generate-generic-service-definition.ts +++ b/src/generate-generic-service-definition.ts @@ -68,8 +68,10 @@ function generateMethodDefinition(ctx: Context, methodDesc: MethodDescriptorProt { name: '${methodDesc.name}', requestType: ${inputType}, + requestTypeName: '${methodDesc.inputType}', requestStream: ${methodDesc.clientStreaming}, responseType: ${outputType}, + responseTypeName: '${methodDesc.outputType}', responseStream: ${methodDesc.serverStreaming}, options: ${generateMethodOptions(methodDesc.options)} } From d06a3ceea10826e8e685873154b1efc485d493ec Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Wed, 19 Oct 2022 19:21:03 -0700 Subject: [PATCH 8/9] strip leading dots from type names --- integration/generic-metadata/hero.ts | 12 +-- .../simple.ts | 28 +++---- .../generic-service-definitions/simple.ts | 28 +++---- integration/nice-grpc/simple.ts | 84 +++++++++---------- integration/use-date-true/use-date-true.ts | 4 +- .../wrappers-regression.ts | 16 ++-- src/generate-generic-service-definition.ts | 8 +- 7 files changed, 92 insertions(+), 88 deletions(-) diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index 06bcd911a..6846d4e44 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -271,30 +271,30 @@ export const HeroServiceDefinition = { findOneHero: { name: "FindOneHero", requestType: HeroById, - requestTypeName: ".hero.HeroById", + requestTypeName: "hero.HeroById", requestStream: false, responseType: Hero, - responseTypeName: ".hero.Hero", + responseTypeName: "hero.Hero", responseStream: false, options: {}, }, findOneVillain: { name: "FindOneVillain", requestType: VillainById, - requestTypeName: ".hero.VillainById", + requestTypeName: "hero.VillainById", requestStream: false, responseType: Villain, - responseTypeName: ".hero.Villain", + responseTypeName: "hero.Villain", responseStream: false, options: {}, }, findManyVillain: { name: "FindManyVillain", requestType: VillainById, - requestTypeName: ".hero.VillainById", + requestTypeName: "hero.VillainById", requestStream: true, responseType: Villain, - responseTypeName: ".hero.Villain", + responseTypeName: "hero.Villain", responseStream: true, options: {}, }, diff --git a/integration/generic-service-definitions-and-services/simple.ts b/integration/generic-service-definitions-and-services/simple.ts index 32862bec8..66cf8a340 100644 --- a/integration/generic-service-definitions-and-services/simple.ts +++ b/integration/generic-service-definitions-and-services/simple.ts @@ -63,40 +63,40 @@ export const TestDefinition = { unary: { name: "Unary", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, serverStreaming: { name: "ServerStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, clientStreaming: { name: "ClientStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, @@ -104,30 +104,30 @@ export const TestDefinition = { deprecated: { name: "Deprecated", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, idempotent: { name: "Idempotent", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { name: "NoSideEffects", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, diff --git a/integration/generic-service-definitions/simple.ts b/integration/generic-service-definitions/simple.ts index 32862bec8..66cf8a340 100644 --- a/integration/generic-service-definitions/simple.ts +++ b/integration/generic-service-definitions/simple.ts @@ -63,40 +63,40 @@ export const TestDefinition = { unary: { name: "Unary", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, serverStreaming: { name: "ServerStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, clientStreaming: { name: "ClientStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, @@ -104,30 +104,30 @@ export const TestDefinition = { deprecated: { name: "Deprecated", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, idempotent: { name: "Idempotent", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { name: "NoSideEffects", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, diff --git a/integration/nice-grpc/simple.ts b/integration/nice-grpc/simple.ts index 58c80e2c6..0d19a579a 100644 --- a/integration/nice-grpc/simple.ts +++ b/integration/nice-grpc/simple.ts @@ -87,140 +87,140 @@ export const TestDefinition = { unary: { name: "Unary", requestType: Empty, - requestTypeName: ".google.protobuf.Empty", + requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: Empty, - responseTypeName: ".google.protobuf.Empty", + responseTypeName: "google.protobuf.Empty", responseStream: false, options: {}, }, unaryStringValue: { name: "UnaryStringValue", requestType: StringValue, - requestTypeName: ".google.protobuf.StringValue", + requestTypeName: "google.protobuf.StringValue", requestStream: false, responseType: StringValue, - responseTypeName: ".google.protobuf.StringValue", + responseTypeName: "google.protobuf.StringValue", responseStream: false, options: {}, }, unaryInt64Value: { name: "UnaryInt64Value", requestType: Int64Value, - requestTypeName: ".google.protobuf.Int64Value", + requestTypeName: "google.protobuf.Int64Value", requestStream: false, responseType: Int64Value, - responseTypeName: ".google.protobuf.Int64Value", + responseTypeName: "google.protobuf.Int64Value", responseStream: false, options: {}, }, unaryUint64Value: { name: "UnaryUint64Value", requestType: UInt64Value, - requestTypeName: ".google.protobuf.UInt64Value", + requestTypeName: "google.protobuf.UInt64Value", requestStream: false, responseType: UInt64Value, - responseTypeName: ".google.protobuf.UInt64Value", + responseTypeName: "google.protobuf.UInt64Value", responseStream: false, options: {}, }, unaryInt32Value: { name: "UnaryInt32Value", requestType: Int32Value, - requestTypeName: ".google.protobuf.Int32Value", + requestTypeName: "google.protobuf.Int32Value", requestStream: false, responseType: Int32Value, - responseTypeName: ".google.protobuf.Int32Value", + responseTypeName: "google.protobuf.Int32Value", responseStream: false, options: {}, }, unaryUInt32Value: { name: "UnaryUInt32Value", requestType: UInt32Value, - requestTypeName: ".google.protobuf.UInt32Value", + requestTypeName: "google.protobuf.UInt32Value", requestStream: false, responseType: UInt32Value, - responseTypeName: ".google.protobuf.UInt32Value", + responseTypeName: "google.protobuf.UInt32Value", responseStream: false, options: {}, }, unaryBytesValue: { name: "UnaryBytesValue", requestType: BytesValue, - requestTypeName: ".google.protobuf.BytesValue", + requestTypeName: "google.protobuf.BytesValue", requestStream: false, responseType: BytesValue, - responseTypeName: ".google.protobuf.BytesValue", + responseTypeName: "google.protobuf.BytesValue", responseStream: false, options: {}, }, unaryFloatValue: { name: "UnaryFloatValue", requestType: FloatValue, - requestTypeName: ".google.protobuf.FloatValue", + requestTypeName: "google.protobuf.FloatValue", requestStream: false, responseType: FloatValue, - responseTypeName: ".google.protobuf.FloatValue", + responseTypeName: "google.protobuf.FloatValue", responseStream: false, options: {}, }, unaryDoubleValue: { name: "UnaryDoubleValue", requestType: DoubleValue, - requestTypeName: ".google.protobuf.DoubleValue", + requestTypeName: "google.protobuf.DoubleValue", requestStream: false, responseType: DoubleValue, - responseTypeName: ".google.protobuf.DoubleValue", + responseTypeName: "google.protobuf.DoubleValue", responseStream: false, options: {}, }, unaryBoolValue: { name: "UnaryBoolValue", requestType: BoolValue, - requestTypeName: ".google.protobuf.BoolValue", + requestTypeName: "google.protobuf.BoolValue", requestStream: false, responseType: BoolValue, - responseTypeName: ".google.protobuf.BoolValue", + responseTypeName: "google.protobuf.BoolValue", responseStream: false, options: {}, }, unaryTimestamp: { name: "UnaryTimestamp", requestType: Timestamp, - requestTypeName: ".google.protobuf.Timestamp", + requestTypeName: "google.protobuf.Timestamp", requestStream: false, responseType: Timestamp, - responseTypeName: ".google.protobuf.Timestamp", + responseTypeName: "google.protobuf.Timestamp", responseStream: false, options: {}, }, struct: { name: "Struct", requestType: Struct, - requestTypeName: ".google.protobuf.Struct", + requestTypeName: "google.protobuf.Struct", requestStream: false, responseType: Struct, - responseTypeName: ".google.protobuf.Struct", + responseTypeName: "google.protobuf.Struct", responseStream: false, options: {}, }, value: { name: "Value", requestType: Value, - requestTypeName: ".google.protobuf.Value", + requestTypeName: "google.protobuf.Value", requestStream: false, responseType: Value, - responseTypeName: ".google.protobuf.Value", + responseTypeName: "google.protobuf.Value", responseStream: false, options: {}, }, listValue: { name: "ListValue", requestType: ListValue, - requestTypeName: ".google.protobuf.ListValue", + requestTypeName: "google.protobuf.ListValue", requestStream: false, responseType: ListValue, - responseTypeName: ".google.protobuf.ListValue", + responseTypeName: "google.protobuf.ListValue", responseStream: false, options: {}, }, @@ -228,30 +228,30 @@ export const TestDefinition = { serverStreaming: { name: "ServerStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, serverStreamingStringValue: { name: "ServerStreamingStringValue", requestType: StringValue, - requestTypeName: ".google.protobuf.StringValue", + requestTypeName: "google.protobuf.StringValue", requestStream: false, responseType: StringValue, - responseTypeName: ".google.protobuf.StringValue", + responseTypeName: "google.protobuf.StringValue", responseStream: true, options: {}, }, serverStreamingStruct: { name: "ServerStreamingStruct", requestType: Struct, - requestTypeName: ".google.protobuf.Struct", + requestTypeName: "google.protobuf.Struct", requestStream: false, responseType: Struct, - responseTypeName: ".google.protobuf.Struct", + responseTypeName: "google.protobuf.Struct", responseStream: true, options: {}, }, @@ -259,20 +259,20 @@ export const TestDefinition = { clientStreaming: { name: "ClientStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, clientStreamingStringValue: { name: "ClientStreamingStringValue", requestType: StringValue, - requestTypeName: ".google.protobuf.StringValue", + requestTypeName: "google.protobuf.StringValue", requestStream: true, responseType: StringValue, - responseTypeName: ".google.protobuf.StringValue", + responseTypeName: "google.protobuf.StringValue", responseStream: false, options: {}, }, @@ -280,20 +280,20 @@ export const TestDefinition = { bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, - requestTypeName: ".simple.TestMessage", + requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: ".simple.TestMessage", + responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, bidiStreamingStringValue: { name: "BidiStreamingStringValue", requestType: StringValue, - requestTypeName: ".google.protobuf.StringValue", + requestTypeName: "google.protobuf.StringValue", requestStream: true, responseType: StringValue, - responseTypeName: ".google.protobuf.StringValue", + responseTypeName: "google.protobuf.StringValue", responseStream: true, options: {}, }, diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index 4c4d97e2a..e6445f19b 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -215,10 +215,10 @@ export const ClockDefinition = { now: { name: "Now", requestType: Empty, - requestTypeName: ".google.protobuf.Empty", + requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: Timestamp, - responseTypeName: ".google.protobuf.Timestamp", + responseTypeName: "google.protobuf.Timestamp", responseStream: false, options: {}, }, diff --git a/integration/wrappers-regression/wrappers-regression.ts b/integration/wrappers-regression/wrappers-regression.ts index 28121d8b6..622e9a321 100644 --- a/integration/wrappers-regression/wrappers-regression.ts +++ b/integration/wrappers-regression/wrappers-regression.ts @@ -59,40 +59,40 @@ export const ClockDefinition = { now: { name: "Now", requestType: Empty, - requestTypeName: ".google.protobuf.Empty", + requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: Timestamp, - responseTypeName: ".google.protobuf.Timestamp", + responseTypeName: "google.protobuf.Timestamp", responseStream: false, options: {}, }, nowString: { name: "NowString", requestType: StringValue, - requestTypeName: ".google.protobuf.StringValue", + requestTypeName: "google.protobuf.StringValue", requestStream: false, responseType: StringValue, - responseTypeName: ".google.protobuf.StringValue", + responseTypeName: "google.protobuf.StringValue", responseStream: false, options: {}, }, nowStringStream: { name: "NowStringStream", requestType: StringValue, - requestTypeName: ".google.protobuf.StringValue", + requestTypeName: "google.protobuf.StringValue", requestStream: true, responseType: StringValue, - responseTypeName: ".google.protobuf.StringValue", + responseTypeName: "google.protobuf.StringValue", responseStream: true, options: {}, }, nowBool: { name: "NowBool", requestType: Empty, - requestTypeName: ".google.protobuf.Empty", + requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: BoolValue, - responseTypeName: ".google.protobuf.BoolValue", + responseTypeName: "google.protobuf.BoolValue", responseStream: false, options: {}, }, diff --git a/src/generate-generic-service-definition.ts b/src/generate-generic-service-definition.ts index 237e0afeb..f71da8065 100644 --- a/src/generate-generic-service-definition.ts +++ b/src/generate-generic-service-definition.ts @@ -60,6 +60,10 @@ export function generateGenericServiceDefinition( return joinCode(chunks, { on: "\n" }); } +function stripDot(str: string) { + return str.startsWith(".") ? str.slice(1) : str; +} + function generateMethodDefinition(ctx: Context, methodDesc: MethodDescriptorProto) { const inputType = messageToTypeName(ctx, methodDesc.inputType, { keepValueType: true }); const outputType = messageToTypeName(ctx, methodDesc.outputType, { keepValueType: true }); @@ -68,10 +72,10 @@ function generateMethodDefinition(ctx: Context, methodDesc: MethodDescriptorProt { name: '${methodDesc.name}', requestType: ${inputType}, - requestTypeName: '${methodDesc.inputType}', + requestTypeName: '${stripDot(methodDesc.inputType)}', requestStream: ${methodDesc.clientStreaming}, responseType: ${outputType}, - responseTypeName: '${methodDesc.outputType}', + responseTypeName: '${stripDot(methodDesc.outputType)}', responseStream: ${methodDesc.serverStreaming}, options: ${generateMethodOptions(methodDesc.options)} } From 9aff5b628f4264e047eb5a652e4701e37efaa4f7 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Thu, 20 Oct 2022 10:02:10 -0700 Subject: [PATCH 9/9] add $type back for the MessageType, but not the message --- integration/generic-metadata/hero.ts | 6 --- .../simple.ts | 14 ------- .../generic-service-definitions/simple.ts | 14 ------- integration/nice-grpc/simple.ts | 42 ------------------- integration/type-registry-no-tags/bar/bar.ts | 2 + integration/type-registry-no-tags/foo.ts | 6 +++ .../google/protobuf/struct.ts | 8 ++++ .../google/protobuf/timestamp.ts | 2 + .../type-registry-no-tags/typeRegistry.ts | 1 + integration/use-date-true/use-date-true.ts | 2 - .../wrappers-regression.ts | 8 ---- src/generate-generic-service-definition.ts | 2 - src/generate-type-registry.ts | 4 +- src/main.ts | 14 +++---- 14 files changed, 29 insertions(+), 96 deletions(-) diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index 6846d4e44..d6e622b97 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -271,30 +271,24 @@ export const HeroServiceDefinition = { findOneHero: { name: "FindOneHero", requestType: HeroById, - requestTypeName: "hero.HeroById", requestStream: false, responseType: Hero, - responseTypeName: "hero.Hero", responseStream: false, options: {}, }, findOneVillain: { name: "FindOneVillain", requestType: VillainById, - requestTypeName: "hero.VillainById", requestStream: false, responseType: Villain, - responseTypeName: "hero.Villain", responseStream: false, options: {}, }, findManyVillain: { name: "FindManyVillain", requestType: VillainById, - requestTypeName: "hero.VillainById", requestStream: true, responseType: Villain, - responseTypeName: "hero.Villain", responseStream: true, options: {}, }, diff --git a/integration/generic-service-definitions-and-services/simple.ts b/integration/generic-service-definitions-and-services/simple.ts index 66cf8a340..7e3c5d5a0 100644 --- a/integration/generic-service-definitions-and-services/simple.ts +++ b/integration/generic-service-definitions-and-services/simple.ts @@ -63,40 +63,32 @@ export const TestDefinition = { unary: { name: "Unary", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, serverStreaming: { name: "ServerStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, clientStreaming: { name: "ClientStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, @@ -104,30 +96,24 @@ export const TestDefinition = { deprecated: { name: "Deprecated", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, idempotent: { name: "Idempotent", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { name: "NoSideEffects", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, diff --git a/integration/generic-service-definitions/simple.ts b/integration/generic-service-definitions/simple.ts index 66cf8a340..7e3c5d5a0 100644 --- a/integration/generic-service-definitions/simple.ts +++ b/integration/generic-service-definitions/simple.ts @@ -63,40 +63,32 @@ export const TestDefinition = { unary: { name: "Unary", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, serverStreaming: { name: "ServerStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, clientStreaming: { name: "ClientStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, @@ -104,30 +96,24 @@ export const TestDefinition = { deprecated: { name: "Deprecated", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, idempotent: { name: "Idempotent", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { name: "NoSideEffects", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, diff --git a/integration/nice-grpc/simple.ts b/integration/nice-grpc/simple.ts index 0d19a579a..c171462de 100644 --- a/integration/nice-grpc/simple.ts +++ b/integration/nice-grpc/simple.ts @@ -87,140 +87,112 @@ export const TestDefinition = { unary: { name: "Unary", requestType: Empty, - requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: Empty, - responseTypeName: "google.protobuf.Empty", responseStream: false, options: {}, }, unaryStringValue: { name: "UnaryStringValue", requestType: StringValue, - requestTypeName: "google.protobuf.StringValue", requestStream: false, responseType: StringValue, - responseTypeName: "google.protobuf.StringValue", responseStream: false, options: {}, }, unaryInt64Value: { name: "UnaryInt64Value", requestType: Int64Value, - requestTypeName: "google.protobuf.Int64Value", requestStream: false, responseType: Int64Value, - responseTypeName: "google.protobuf.Int64Value", responseStream: false, options: {}, }, unaryUint64Value: { name: "UnaryUint64Value", requestType: UInt64Value, - requestTypeName: "google.protobuf.UInt64Value", requestStream: false, responseType: UInt64Value, - responseTypeName: "google.protobuf.UInt64Value", responseStream: false, options: {}, }, unaryInt32Value: { name: "UnaryInt32Value", requestType: Int32Value, - requestTypeName: "google.protobuf.Int32Value", requestStream: false, responseType: Int32Value, - responseTypeName: "google.protobuf.Int32Value", responseStream: false, options: {}, }, unaryUInt32Value: { name: "UnaryUInt32Value", requestType: UInt32Value, - requestTypeName: "google.protobuf.UInt32Value", requestStream: false, responseType: UInt32Value, - responseTypeName: "google.protobuf.UInt32Value", responseStream: false, options: {}, }, unaryBytesValue: { name: "UnaryBytesValue", requestType: BytesValue, - requestTypeName: "google.protobuf.BytesValue", requestStream: false, responseType: BytesValue, - responseTypeName: "google.protobuf.BytesValue", responseStream: false, options: {}, }, unaryFloatValue: { name: "UnaryFloatValue", requestType: FloatValue, - requestTypeName: "google.protobuf.FloatValue", requestStream: false, responseType: FloatValue, - responseTypeName: "google.protobuf.FloatValue", responseStream: false, options: {}, }, unaryDoubleValue: { name: "UnaryDoubleValue", requestType: DoubleValue, - requestTypeName: "google.protobuf.DoubleValue", requestStream: false, responseType: DoubleValue, - responseTypeName: "google.protobuf.DoubleValue", responseStream: false, options: {}, }, unaryBoolValue: { name: "UnaryBoolValue", requestType: BoolValue, - requestTypeName: "google.protobuf.BoolValue", requestStream: false, responseType: BoolValue, - responseTypeName: "google.protobuf.BoolValue", responseStream: false, options: {}, }, unaryTimestamp: { name: "UnaryTimestamp", requestType: Timestamp, - requestTypeName: "google.protobuf.Timestamp", requestStream: false, responseType: Timestamp, - responseTypeName: "google.protobuf.Timestamp", responseStream: false, options: {}, }, struct: { name: "Struct", requestType: Struct, - requestTypeName: "google.protobuf.Struct", requestStream: false, responseType: Struct, - responseTypeName: "google.protobuf.Struct", responseStream: false, options: {}, }, value: { name: "Value", requestType: Value, - requestTypeName: "google.protobuf.Value", requestStream: false, responseType: Value, - responseTypeName: "google.protobuf.Value", responseStream: false, options: {}, }, listValue: { name: "ListValue", requestType: ListValue, - requestTypeName: "google.protobuf.ListValue", requestStream: false, responseType: ListValue, - responseTypeName: "google.protobuf.ListValue", responseStream: false, options: {}, }, @@ -228,30 +200,24 @@ export const TestDefinition = { serverStreaming: { name: "ServerStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: false, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, serverStreamingStringValue: { name: "ServerStreamingStringValue", requestType: StringValue, - requestTypeName: "google.protobuf.StringValue", requestStream: false, responseType: StringValue, - responseTypeName: "google.protobuf.StringValue", responseStream: true, options: {}, }, serverStreamingStruct: { name: "ServerStreamingStruct", requestType: Struct, - requestTypeName: "google.protobuf.Struct", requestStream: false, responseType: Struct, - responseTypeName: "google.protobuf.Struct", responseStream: true, options: {}, }, @@ -259,20 +225,16 @@ export const TestDefinition = { clientStreaming: { name: "ClientStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: false, options: {}, }, clientStreamingStringValue: { name: "ClientStreamingStringValue", requestType: StringValue, - requestTypeName: "google.protobuf.StringValue", requestStream: true, responseType: StringValue, - responseTypeName: "google.protobuf.StringValue", responseStream: false, options: {}, }, @@ -280,20 +242,16 @@ export const TestDefinition = { bidiStreaming: { name: "BidiStreaming", requestType: TestMessage, - requestTypeName: "simple.TestMessage", requestStream: true, responseType: TestMessage, - responseTypeName: "simple.TestMessage", responseStream: true, options: {}, }, bidiStreamingStringValue: { name: "BidiStreamingStringValue", requestType: StringValue, - requestTypeName: "google.protobuf.StringValue", requestStream: true, responseType: StringValue, - responseTypeName: "google.protobuf.StringValue", responseStream: true, options: {}, }, diff --git a/integration/type-registry-no-tags/bar/bar.ts b/integration/type-registry-no-tags/bar/bar.ts index d7d4164c2..d97f72277 100644 --- a/integration/type-registry-no-tags/bar/bar.ts +++ b/integration/type-registry-no-tags/bar/bar.ts @@ -14,6 +14,8 @@ function createBaseBar(): Bar { } export const Bar = { + $type: "foo.bar.Bar" as const, + encode(message: Bar, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.foo !== undefined) { Foo.encode(message.foo, writer.uint32(10).fork()).ldelim(); diff --git a/integration/type-registry-no-tags/foo.ts b/integration/type-registry-no-tags/foo.ts index 5dc82377e..5a9e58db0 100644 --- a/integration/type-registry-no-tags/foo.ts +++ b/integration/type-registry-no-tags/foo.ts @@ -23,6 +23,8 @@ function createBaseFoo(): Foo { } export const Foo = { + $type: "foo.Foo" as const, + encode(message: Foo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.timestamp !== undefined) { Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim(); @@ -72,6 +74,8 @@ function createBaseFoo2(): Foo2 { } export const Foo2 = { + $type: "foo.Foo2" as const, + encode(message: Foo2, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.timestamp !== undefined) { Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim(); @@ -121,6 +125,8 @@ function createBaseWithStruct(): WithStruct { } export const WithStruct = { + $type: "foo.WithStruct" as const, + encode(message: WithStruct, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.struct !== undefined) { Struct.encode(Struct.wrap(message.struct), writer.uint32(10).fork()).ldelim(); diff --git a/integration/type-registry-no-tags/google/protobuf/struct.ts b/integration/type-registry-no-tags/google/protobuf/struct.ts index 558f8cffa..eae6b2530 100644 --- a/integration/type-registry-no-tags/google/protobuf/struct.ts +++ b/integration/type-registry-no-tags/google/protobuf/struct.ts @@ -106,6 +106,8 @@ function createBaseStruct(): Struct { } export const Struct = { + $type: "google.protobuf.Struct" as const, + encode(message: Struct, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { Object.entries(message.fields).forEach(([key, value]) => { if (value !== undefined) { @@ -198,6 +200,8 @@ function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { } export const Struct_FieldsEntry = { + $type: "google.protobuf.Struct.FieldsEntry" as const, + encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.key !== "") { writer.uint32(10).string(message.key); @@ -262,6 +266,8 @@ function createBaseValue(): Value { } export const Value = { + $type: "google.protobuf.Value" as const, + encode(message: Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.nullValue !== undefined) { writer.uint32(8).int32(message.nullValue); @@ -398,6 +404,8 @@ function createBaseListValue(): ListValue { } export const ListValue = { + $type: "google.protobuf.ListValue" as const, + encode(message: ListValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.values) { Value.encode(Value.wrap(v!), writer.uint32(10).fork()).ldelim(); diff --git a/integration/type-registry-no-tags/google/protobuf/timestamp.ts b/integration/type-registry-no-tags/google/protobuf/timestamp.ts index c9fec54c6..19e930efc 100644 --- a/integration/type-registry-no-tags/google/protobuf/timestamp.ts +++ b/integration/type-registry-no-tags/google/protobuf/timestamp.ts @@ -117,6 +117,8 @@ function createBaseTimestamp(): Timestamp { } export const Timestamp = { + $type: "google.protobuf.Timestamp" as const, + encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.seconds !== 0) { writer.uint32(8).int64(message.seconds); diff --git a/integration/type-registry-no-tags/typeRegistry.ts b/integration/type-registry-no-tags/typeRegistry.ts index 11a0fe77b..b309ef5be 100644 --- a/integration/type-registry-no-tags/typeRegistry.ts +++ b/integration/type-registry-no-tags/typeRegistry.ts @@ -2,6 +2,7 @@ import * as _m0 from "protobufjs/minimal"; export interface MessageType { + $type: string; encode(message: Message, writer?: _m0.Writer): _m0.Writer; decode(input: _m0.Reader | Uint8Array, length?: number): Message; fromJSON(object: any): Message; diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index e6445f19b..7e0b7f33c 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -215,10 +215,8 @@ export const ClockDefinition = { now: { name: "Now", requestType: Empty, - requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: Timestamp, - responseTypeName: "google.protobuf.Timestamp", responseStream: false, options: {}, }, diff --git a/integration/wrappers-regression/wrappers-regression.ts b/integration/wrappers-regression/wrappers-regression.ts index 622e9a321..b8147b2fc 100644 --- a/integration/wrappers-regression/wrappers-regression.ts +++ b/integration/wrappers-regression/wrappers-regression.ts @@ -59,40 +59,32 @@ export const ClockDefinition = { now: { name: "Now", requestType: Empty, - requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: Timestamp, - responseTypeName: "google.protobuf.Timestamp", responseStream: false, options: {}, }, nowString: { name: "NowString", requestType: StringValue, - requestTypeName: "google.protobuf.StringValue", requestStream: false, responseType: StringValue, - responseTypeName: "google.protobuf.StringValue", responseStream: false, options: {}, }, nowStringStream: { name: "NowStringStream", requestType: StringValue, - requestTypeName: "google.protobuf.StringValue", requestStream: true, responseType: StringValue, - responseTypeName: "google.protobuf.StringValue", responseStream: true, options: {}, }, nowBool: { name: "NowBool", requestType: Empty, - requestTypeName: "google.protobuf.Empty", requestStream: false, responseType: BoolValue, - responseTypeName: "google.protobuf.BoolValue", responseStream: false, options: {}, }, diff --git a/src/generate-generic-service-definition.ts b/src/generate-generic-service-definition.ts index f71da8065..9990efce6 100644 --- a/src/generate-generic-service-definition.ts +++ b/src/generate-generic-service-definition.ts @@ -72,10 +72,8 @@ function generateMethodDefinition(ctx: Context, methodDesc: MethodDescriptorProt { name: '${methodDesc.name}', requestType: ${inputType}, - requestTypeName: '${stripDot(methodDesc.inputType)}', requestStream: ${methodDesc.clientStreaming}, responseType: ${outputType}, - responseTypeName: '${stripDot(methodDesc.outputType)}', responseStream: ${methodDesc.serverStreaming}, options: ${generateMethodOptions(methodDesc.options)} } diff --git a/src/generate-type-registry.ts b/src/generate-type-registry.ts index f6c1147ca..7c279b9c4 100644 --- a/src/generate-type-registry.ts +++ b/src/generate-type-registry.ts @@ -31,7 +31,9 @@ function generateMessageType(ctx: Context): Code { chunks.push(code`export interface MessageType {`); - if (ctx.options.outputTypeRegistry != "no-tags") { + if (ctx.options.outputTypeRegistry == "no-tags") { + chunks.push(code`$type: string;`); + } else { chunks.push(code`$type: Message['$type'];`); } diff --git a/src/main.ts b/src/main.ts index 64880a2b3..d210d68a5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -168,7 +168,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri const staticMembers: Code[] = []; - if (options.outputTypeRegistry === true) { + if (options.outputTypeRegistry) { staticMembers.push(code`$type: '${fullTypeName}' as const`); } @@ -833,12 +833,12 @@ function generateBaseInstanceFactory( const val = isWithinOneOf(field) ? "undefined" : isMapType(ctx, messageDesc, field) - ? ctx.options.useMapType - ? "new Map()" - : "{}" - : isRepeated(field) - ? "[]" - : defaultValue(ctx, field); + ? ctx.options.useMapType + ? "new Map()" + : "{}" + : isRepeated(field) + ? "[]" + : defaultValue(ctx, field); fields.push(code`${name}: ${val}`); }